void OnClickRow(object theSender, EventArgs theArgs)
    {
        KGFDataRow aRow = theSender as KGFDataRow;

        if (aRow != null)
        {
            itsCurrentSelectedItem = (KGFITaggable)aRow [0].Value;
            if (itsCurrentSelectedRow != aRow)
            {
                itsCurrentSelectedRow = aRow;
            }
            if (EventSelect != null)
            {
                EventSelect(this, new KGFGUIObjectListSelectEventArgs(itsCurrentSelectedItem));
            }
        }
    }
	void OnClickRow (object theSender, EventArgs theArgs)
	{
		KGFDataRow aRow = theSender as KGFDataRow;
		
		if (aRow != null)
		{
			itsCurrentSelectedItem = (KGFITaggable)aRow [0].Value;
			if (itsCurrentSelectedRow != aRow)
			{
				itsCurrentSelectedRow = aRow;
			}
			if (EventSelect != null)
			{
				EventSelect (this, new KGFGUIObjectListSelectEventArgs (itsCurrentSelectedItem));
			}
		}
	}
Example #3
0
	public KGFDataCell(KGFDataColumn theColumn, KGFDataRow theRow)
	{
		itsColumn = theColumn;
		itsRow = theRow;
		itsValue = null;
	}
 public KGFDataCell(KGFDataColumn theColumn, KGFDataRow theRow)
 {
     itsColumn = theColumn;
     itsRow    = theRow;
     itsValue  = null;
 }
	private void RenderTableRows()
	{
		itsDataTableScrollViewPosition = KGFGUIUtility.BeginScrollView(itsDataTableScrollViewPosition, false, true, GUILayout.ExpandHeight(true));
		{
			//Log List Heading
//			RenderTableHeadings();
			
			if(itsDataTable.Rows.Count > 0)
			{
				GUILayout.BeginVertical();
				{
					Color aDefaultColor = GUI.color;
					
					for(int aRowIndex = (int)itsStartRow; aRowIndex < itsStartRow + itsDisplayRowCount && aRowIndex < itsDataTable.Rows.Count; aRowIndex++)
					{
						KGFDataRow aRow = itsDataTable.Rows[aRowIndex];
						
						//Pre Row Hook
						if(PreRenderRow != null)
						{
							PreRenderRow(aRow, EventArgs.Empty);
						}
						
						if(aRow == itsCurrentSelected)
						{
							KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTopInteractive, GUILayout.ExpandWidth(true));
						}
						else
						{
							KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVerticalInteractive, GUILayout.ExpandWidth(true));
						}
						
						//Row
						{
							foreach(KGFDataColumn aColumn in itsDataTable.Columns)
							{
								//check if the column is visible
								if(itsColumnVisible[aColumn])
								{
									//Pre Column Hook
									if(PreRenderColumn != null)
									{
										PreRenderColumn(aColumn, EventArgs.Empty);
									}
									
									bool aCustomDrawer = false;
									if(PreCellContentHandler != null)
									{
										aCustomDrawer = PreCellContentHandler(aRow, aColumn,itsColumnWidth[aColumn]);
									}
									
									if(!aCustomDrawer)
									{
										// create the string
										int itsStringMaxLenght = 85;
										string aString = aRow[aColumn].ToString().Substring(0, Math.Min(itsStringMaxLenght,aRow[aColumn].ToString().Length));
										
										if(aString.Length == itsStringMaxLenght)
										{
											aString += "...";
										}
										
										if(itsColumnWidth[aColumn] > 0)
										{
											KGFGUIUtility.Label(aString, KGFGUIUtility.eStyleLabel.eLabelFitIntoBox, GUILayout.Width(itsColumnWidth[aColumn]));
										}
										else
										{
											KGFGUIUtility.Label(aString, KGFGUIUtility.eStyleLabel.eLabelFitIntoBox, GUILayout.ExpandWidth(true));
										}
									}
									
									KGFGUIUtility.Separator(KGFGUIUtility.eStyleSeparator.eSeparatorVerticalFitInBox);

									//Post Column Hook
									if(PostRenderColumn != null)
									{
										PostRenderColumn(aColumn, EventArgs.Empty);
									}
								}
							}
						}
						KGFGUIUtility.EndHorizontalBox();
						
						//check if the rect contains the mouse and the pressed mouse button is the left mouse button
						if(GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown && Event.current.button == 0)
						{
							itsClickedRow = aRow;
							itsRepaint = true;
						}
						
						//only send this event on layouting
						if(OnClickRow != null && itsClickedRow != null && Event.current.type == EventType.Layout)
						{
							if(itsCurrentSelected != itsClickedRow)
							{
								itsCurrentSelected = itsClickedRow;
								//Debug.Log("itsCurrentSelected is set");
							}
							else
							{
								itsCurrentSelected = null;
							}
							
							OnClickRow(itsClickedRow, EventArgs.Empty);
							itsClickedRow = null;
							//Debug.Log("itsClickedRow is set to null");
						}
						
						//Post Row Hook
						if(PostRenderRow != null)
						{
							PostRenderRow(aRow, EventArgs.Empty);
						}
					}
					GUI.color = aDefaultColor;
					GUILayout.FlexibleSpace();
				}
				GUILayout.EndVertical();
			}
			else
			{
				GUILayout.Label("no items found");
				GUILayout.FlexibleSpace();
			}
		}
		GUILayout.EndScrollView();
		itsRectScrollView = GUILayoutUtility.GetLastRect();
	}
	int RowComparison(KGFDataRow theRow1, KGFDataRow theRow2)
	{
		if (itsSortColumn != null)
		{
			return theRow1[itsSortColumn].Value.ToString().CompareTo(theRow2[itsSortColumn].Value.ToString());
		}
		return 0;
	}
	public void SetCurrentSelected(KGFDataRow theDataRow)
	{
		if(itsDataTable.Rows.Contains(theDataRow))
		{
			itsCurrentSelected = theDataRow;
		}
	}
Example #8
0
    private void RenderTableRows()
    {
        itsDataTableScrollViewPosition = KGFGUIUtility.BeginScrollView(itsDataTableScrollViewPosition, false, itsForceDisplayVerticalSlider, GUILayout.ExpandHeight(true));
        {
            //Log List Heading
            RenderTableHeadings();

            if (itsDataTable.Rows.Count > 0)
            {
                GUILayout.BeginVertical();
                {
                    Color aDefaultColor = GUI.color;

                    for (int aRowIndex = (int)itsStartRow; aRowIndex < itsStartRow + itsDisplayRowCount && aRowIndex < itsDataTable.Rows.Count; aRowIndex++)
                    {
                        KGFDataRow aRow = itsDataTable.Rows[aRowIndex];

                        //Pre Row Hook
                        if (PreRenderRow != null)
                        {
                            PreRenderRow(aRow, EventArgs.Empty);
                        }

                        if (aRow == itsCurrentSelected)
                        {
                            KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTopInteractive, GUILayout.ExpandWidth(true));
                        }
                        else
                        {
                            KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVerticalInteractive, GUILayout.ExpandWidth(true));
                        }

                        //Row
                        {
                            foreach (KGFDataColumn aColumn in itsDataTable.Columns)
                            {
                                //check if the column is visible
                                if (itsColumnVisible[aColumn])
                                {
                                    //Pre Column Hook
                                    if (PreRenderColumn != null)
                                    {
                                        PreRenderColumn(aColumn, EventArgs.Empty);
                                    }

                                    bool aCustomDrawer = false;
                                    if (PreCellContentHandler != null)
                                    {
                                        aCustomDrawer = PreCellContentHandler(aRow, aColumn);
                                    }

                                    if (!aCustomDrawer)
                                    {
                                        // crate the string
                                        int    itsStringMaxLenght = 85;
                                        string aString            = aRow[aColumn].ToString().Substring(0, Math.Min(itsStringMaxLenght, aRow[aColumn].ToString().Length));

                                        if (aString.Length == itsStringMaxLenght)
                                        {
                                            aString += "...";
                                        }

                                        if (itsColumnWidth[aColumn] > 0)
                                        {
                                            KGFGUIUtility.Label(aString, KGFGUIUtility.eStyleLabel.eLabelFitIntoBox, GUILayout.Width(itsColumnWidth[aColumn]));
                                        }
                                        else
                                        {
                                            KGFGUIUtility.Label(aString, KGFGUIUtility.eStyleLabel.eLabelFitIntoBox, GUILayout.ExpandWidth(true));
                                        }
                                    }

                                    KGFGUIUtility.Separator(KGFGUIUtility.eStyleSeparator.eSeparatorVerticalFitInBox);

                                    //Post Column Hook
                                    if (PostRenderColumn != null)
                                    {
                                        PostRenderColumn(aColumn, EventArgs.Empty);
                                    }
                                }
                            }
                        }
                        KGFGUIUtility.EndHorizontalBox();

                        //check if the rect contains the mouse and the pressed mouse button is the left mouse button
                        if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown && Event.current.button == 0)
                        {
                            itsClickedRow = aRow;
                        }

                        //only send this event on layouting
                        if (OnClickRow != null && itsClickedRow != null && Event.current.type == EventType.Layout)
                        {
                            if (itsCurrentSelected != itsClickedRow)
                            {
                                itsCurrentSelected = itsClickedRow;
                                //Debug.Log("itsCurrentSelected is set");
                            }
                            else
                            {
                                itsCurrentSelected = null;
                            }

                            OnClickRow(itsClickedRow, EventArgs.Empty);
                            itsClickedRow = null;
                            //Debug.Log("itsClickedRow is set to null");
                        }

                        //Post Row Hook
                        if (PostRenderRow != null)
                        {
                            PostRenderRow(aRow, EventArgs.Empty);
                        }
                    }
                    GUI.color = aDefaultColor;
                    GUILayout.FlexibleSpace();
                }
                GUILayout.EndVertical();
            }
            else
            {
                GUILayout.Label("no items found");
                GUILayout.FlexibleSpace();
            }
        }
        GUILayout.EndScrollView();
    }