///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Add a widget to the grid /// </summary> /// /// <param name="widget">Fully created widget that will be added to the grid</param> /// <param name="row">The row in which the widget should be placed</param> /// <param name="col">The column in which the widget should be placed</param> /// <param name="borders">Distance from the grid square to the widget (left, top, right, bottom)</param> /// <param name="layout">Where the widget is located in the square</param> /// /// Usage example: /// <code> /// Picture pic = grid.Add(new Picture("1.png")); /// pic.Size = new Vector2f(400, 300); /// grid.AddWidget(pic, 0, 0); /// </code> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void AddWidget(Widget widget, uint row, uint col, Borders borders, Layouts layout) { // Create the row if it didn't exist yet while (m_GridWidgets.Count < row + 1) { m_GridWidgets.Add(new List <Widget>()); } while (m_ObjBorders.Count < row + 1) { m_ObjBorders.Add(new List <Borders>()); } while (m_ObjLayout.Count < row + 1) { m_ObjLayout.Add(new List <Layouts>()); } while (m_GridWidgets[(int)row].Count < col + 1) { m_GridWidgets [(int)row].Add(null); } while (m_ObjBorders[(int)row].Count < col + 1) { m_ObjBorders [(int)row].Add(new Borders(0, 0, 0, 0)); } while (m_ObjLayout[(int)row].Count < col + 1) { m_ObjLayout [(int)row].Add(Layouts.Center); } // If this is a new row then reserve some space for it while (m_RowHeight.Count < row + 1) { m_RowHeight.Add(0); } // If this is the first row to have so many columns then reserve some space for it if (m_ColumnWidth.Count < col + 1) { m_ColumnWidth.Add(0); } // Add the widget to the grid m_GridWidgets[(int)row][(int)col] = widget; m_ObjBorders[(int)row][(int)col] = borders; m_ObjLayout[(int)row][(int)col] = layout; // Update the widgets UpdateWidgets(); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Copy constructor /// </summary> /// /// <param name="copy">Instance to copy</param> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public ChatBox(ChatBox copy) : base(copy) { m_LoadedConfigFile = copy.m_LoadedConfigFile; m_LineSpacing = copy.m_LineSpacing; m_TextSize = copy.m_TextSize; m_TextColor = copy.m_TextColor; m_BorderColor = copy.m_BorderColor; m_Borders = copy.m_Borders; m_MaxLines = copy.m_MaxLines; m_FullTextHeight = copy.m_FullTextHeight; m_Panel = new Panel(copy.m_Panel); // If there is a scrollbar then copy it if (copy.m_Scroll != null) m_Scroll = new Scrollbar(copy.m_Scroll); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Changes borders of a given widget /// </summary> /// /// <param name="widget">The widget to which borders should be added</param> /// <param name="borders">The new borders around the widget</param> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void ChangeWidgetBorders(Widget widget, Borders borders) { // Find the widget in the grid for (int row = 0; row < m_GridWidgets.Count; ++row) { for (int col = 0; col < m_GridWidgets[row].Count; ++col) { if (m_GridWidgets[row][col] == widget) { // Change borders of the widget m_ObjBorders[row][col] = borders; // Update all widgets UpdateWidgets(); } } } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Copy constructor /// </summary> /// /// <param name="copy">Instance to copy</param> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public ComboBox(ComboBox copy) : base(copy) { ItemSelectedCallback = copy.ItemSelectedCallback; m_LoadedConfigFile = copy.m_LoadedConfigFile; m_SeparateHoverImage = copy.m_SeparateHoverImage; m_NrOfItemsToDisplay = copy.m_NrOfItemsToDisplay; m_Borders = copy.m_Borders; Global.TextureManager.CopyTexture(copy.m_TextureArrowUpNormal, m_TextureArrowUpNormal); Global.TextureManager.CopyTexture(copy.m_TextureArrowUpHover, m_TextureArrowUpHover); Global.TextureManager.CopyTexture(copy.m_TextureArrowDownNormal, m_TextureArrowDownNormal); Global.TextureManager.CopyTexture(copy.m_TextureArrowDownHover, m_TextureArrowDownHover); // Copy the list box m_ListBox = new ListBox(copy.m_ListBox); m_ListBox.Visible = false; m_ListBox.ItemSelectedCallback -= copy.NewItemSelectedCallbackFunction; m_ListBox.UnfocusedCallback -= copy.ListBoxUnfocusedCallbackFunction; m_ListBox.ItemSelectedCallback += NewItemSelectedCallbackFunction; m_ListBox.UnfocusedCallback += ListBoxUnfocusedCallbackFunction; }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static bool ExtractBorders(string str, out Borders borders) { borders = new Borders(0, 0, 0, 0); // If the string is too small then it has to be wrong if (str.Length < 9) return false; // Drop the brackets if (str [0] == '(' && str [str.Length-1] == ')') { str = str.Substring (1, str.Length - 2); // Extract the borders string[] strBorders = str.Split (','); // Return the color if (strBorders.Length == 4) { borders = new Borders(Convert.ToUInt32(strBorders [0]), Convert.ToUInt32(strBorders [1]), Convert.ToUInt32(strBorders [2]), Convert.ToUInt32(strBorders [3])); return true; } else return false; } else // The string doesn't begin and end with a bracket return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Copy constructor /// </summary> /// /// <param name="copy">Instance to copy</param> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public EditBox(EditBox copy) : base(copy) { TextChangedCallback = copy.TextChangedCallback; ReturnKeyPressedCallback = copy.ReturnKeyPressedCallback; m_LoadedConfigFile = copy.m_LoadedConfigFile; m_SelectionPointVisible = copy.m_SelectionPointVisible; m_LimitTextWidth = copy.m_LimitTextWidth; m_DisplayedText = copy.m_DisplayedText; m_Text = copy.m_Text; m_TextSize = copy.m_TextSize; m_TextAlignment = copy.m_TextAlignment; m_SelChars = copy.m_SelChars; m_SelStart = copy.m_SelStart; m_SelEnd = copy.m_SelEnd; m_PasswordChar = copy.m_PasswordChar; m_MaxChars = copy.m_MaxChars; m_SplitImage = copy.m_SplitImage; m_TextCropPosition = copy.m_TextCropPosition; m_SelectedTextBackground = new RectangleShape(copy.m_SelectedTextBackground); m_SelectionPoint = new RectangleShape(copy.m_SelectionPoint); m_TextBeforeSelection = new Text(copy.m_TextBeforeSelection); m_TextSelection = new Text(copy.m_TextSelection); m_TextAfterSelection = new Text(copy.m_TextAfterSelection); m_TextFull = new Text(copy.m_TextFull); m_PossibleDoubleClick = copy.m_PossibleDoubleClick; m_NumbersOnly = copy.m_NumbersOnly; m_SeparateHoverImage = copy.m_SeparateHoverImage; m_Borders = copy.m_Borders; Global.TextureManager.CopyTexture(copy.m_TextureNormal_L, m_TextureNormal_L); Global.TextureManager.CopyTexture(copy.m_TextureNormal_M, m_TextureNormal_M); Global.TextureManager.CopyTexture(copy.m_TextureNormal_R, m_TextureNormal_R); Global.TextureManager.CopyTexture(copy.m_TextureHover_L, m_TextureHover_L); Global.TextureManager.CopyTexture(copy.m_TextureHover_M, m_TextureHover_M); Global.TextureManager.CopyTexture(copy.m_TextureHover_R, m_TextureHover_R); Global.TextureManager.CopyTexture(copy.m_TextureFocused_L, m_TextureFocused_L); Global.TextureManager.CopyTexture(copy.m_TextureFocused_M, m_TextureFocused_M); Global.TextureManager.CopyTexture(copy.m_TextureFocused_R, m_TextureFocused_R); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Copy constructor /// </summary> /// /// <param name="copy">Instance to copy</param> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public ChildWindow(ChildWindow copy) : base(copy) { ClosedCallback = copy.ClosedCallback; MovedCallback = copy.MovedCallback; m_LoadedConfigFile = copy.m_LoadedConfigFile; m_Size = copy.m_Size; m_BackgroundColor = copy.m_BackgroundColor; m_BackgroundTexture = copy.m_BackgroundTexture; m_TitleText = new Text(copy.m_TitleText); m_TitleBarHeight = copy.m_TitleBarHeight; m_SplitImage = copy.m_SplitImage; m_DraggingPosition = copy.m_DraggingPosition; m_DistanceToSide = copy.m_DistanceToSide; m_TitleAlignment = copy.m_TitleAlignment; m_BorderColor = copy.m_BorderColor; m_Borders = copy.m_Borders; m_CloseButton = new Button(copy.m_CloseButton); m_KeepInParent = copy.m_KeepInParent; Global.TextureManager.CopyTexture(copy.m_IconTexture, m_IconTexture); Global.TextureManager.CopyTexture(copy.m_TextureTitleBar_L, m_TextureTitleBar_L); Global.TextureManager.CopyTexture(copy.m_TextureTitleBar_M, m_TextureTitleBar_M); Global.TextureManager.CopyTexture(copy.m_TextureTitleBar_R, m_TextureTitleBar_R); if (copy.m_BackgroundTexture != null) { m_BackgroundSprite.Texture = m_BackgroundTexture; m_BackgroundSprite.Scale = new Vector2f(m_Size.X / m_BackgroundTexture.Size.X, m_Size.Y / m_BackgroundTexture.Size.Y); m_BackgroundSprite.Color = new Color (255, 255, 255, m_Opacity); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Add a widget to the grid /// </summary> /// /// <param name="widget">Fully created widget that will be added to the grid</param> /// <param name="row">The row in which the widget should be placed</param> /// <param name="col">The column in which the widget should be placed</param> /// <param name="borders">Distance from the grid square to the widget (left, top, right, bottom)</param> /// <param name="layout">Where the widget is located in the square</param> /// /// Usage example: /// <code> /// Picture pic = grid.Add(new Picture("1.png")); /// pic.Size = new Vector2f(400, 300); /// grid.AddWidget(pic, 0, 0); /// </code> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void AddWidget(Widget widget, uint row, uint col, Borders borders, Layouts layout) { // Create the row if it didn't exist yet while (m_GridWidgets.Count < row + 1) m_GridWidgets.Add (new List<Widget>()); while (m_ObjBorders.Count < row + 1) m_ObjBorders.Add (new List<Borders>()); while (m_ObjLayout.Count < row + 1) m_ObjLayout.Add (new List<Layouts>()); while (m_GridWidgets[(int)row].Count < col + 1) m_GridWidgets [(int)row].Add (null); while (m_ObjBorders[(int)row].Count < col + 1) m_ObjBorders [(int)row].Add (new Borders(0, 0, 0, 0)); while (m_ObjLayout[(int)row].Count < col + 1) m_ObjLayout [(int)row].Add (Layouts.Center); // If this is a new row then reserve some space for it while (m_RowHeight.Count < row + 1) m_RowHeight.Add(0); // If this is the first row to have so many columns then reserve some space for it if (m_ColumnWidth.Count < col + 1) m_ColumnWidth.Add(0); // Add the widget to the grid m_GridWidgets[(int)row][(int)col] = widget; m_ObjBorders[(int)row][(int)col] = borders; m_ObjLayout[(int)row][(int)col] = layout; // Update the widgets UpdateWidgets(); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Copy constructor /// </summary> /// /// <param name="copy">Instance to copy</param> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public ListBox(ListBox copy) : base(copy) { ItemSelectedCallback = copy.ItemSelectedCallback; m_LoadedConfigFile = copy.m_LoadedConfigFile; m_Items = new List<string>(copy.m_Items); m_SelectedItem = copy.m_SelectedItem; m_Size = copy.m_Size; m_ItemHeight = copy.m_ItemHeight; m_TextSize = copy.m_TextSize; m_MaxItems = copy.m_MaxItems; m_BackgroundColor = copy.m_BackgroundColor; m_TextColor = copy.m_TextColor; m_SelectedBackgroundColor = copy.m_SelectedBackgroundColor; m_SelectedTextColor = copy.m_SelectedTextColor; m_BorderColor = copy.m_BorderColor; m_TextFont = copy.m_TextFont; m_Borders = copy.m_Borders; // If there is a scrollbar then copy it if (copy.m_Scroll != null) m_Scroll = new Scrollbar(copy.m_Scroll); }