Пример #1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Changes the scrollbar of the list box
        /// </summary>
        ///
        /// <param name="scrollbarConfigFileFilename">Filename of the config file.
        /// The config file must contain a Scrollbar section with the needed information.</param>
        ///
        /// <returns>True when the scrollbar was successfully loaded</returns>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void SetScrollbar(string scrollbarConfigFileFilename)
        {
            // Calling setScrollbar with an empty string does the same as removeScrollbar
            if (scrollbarConfigFileFilename.Length == 0)
            {
                RemoveScrollbar();
                return;
            }

            // load the scrollbar
            m_Scroll = new Scrollbar(scrollbarConfigFileFilename);
            m_Scroll.VerticalScroll = true;
            m_Scroll.Size = new Vector2f(m_Scroll.Size.X, m_Size.Y);
            m_Scroll.LowValue = (int)(m_Size.Y);
            m_Scroll.Maximum = (int)(m_Items.Count * m_ItemHeight);
        }
Пример #2
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a ListBox section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public ListBox(string configFileFilename)
        {
            m_DraggableWidget = true;

            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile (m_LoadedConfigFile, "ListBox");

            // Find the folder that contains the config file
            string configFileFolder = configFileFilename.Substring(0, configFileFilename.LastIndexOfAny(new char[] {'/', '\\'}) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "backgroundcolor")
                    BackgroundColor = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "textcolor")
                    TextColor = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "selectedbackgroundcolor")
                    SelectedBackgroundColor = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "selectedtextcolor")
                    SelectedTextColor = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "bordercolor")
                    BorderColor = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "borders")
                {
                    Borders borders;
                    if (Internal.ExtractBorders(configFile.Values [i], out borders))
                        Borders = borders;
                }
                else if (configFile.Properties[i] == "scrollbar")
                {
                    if ((configFile.Values[i].Length < 3) || (configFile.Values[i][0] != '"') || (configFile.Values[i][configFile.Values[i].Length-1] != '"'))
                        throw new Exception("Failed to parse value for Scrollbar in section ChatBox in " + m_LoadedConfigFile + ".");

                    // load the scrollbar
                    m_Scroll = new Scrollbar(configFileFolder + (configFile.Values[i]).Substring(1, configFile.Values[i].Length - 2));
                    m_Scroll.VerticalScroll = true;
                    m_Scroll.Size = new Vector2f(m_Scroll.Size.X, m_Size.Y);
                    m_Scroll.LowValue = (int)(m_Size.Y);
                    m_Scroll.Maximum = (int)(m_Items.Count * m_ItemHeight);
                }
                else
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section ListBox in " + m_LoadedConfigFile + ".");
            }
        }
Пример #3
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Removes the scrollbar from the list box
        /// </summary>
        ///
        /// <remarks>When there are too many items to fit in the list then the items will be removed.</remarks>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void RemoveScrollbar()
        {
            m_Scroll = null;

            // When the items no longer fit inside the list box then we need to remove some
            if ((m_Items.Count * m_ItemHeight) > m_Size.Y)
            {
                // Calculate ho many items fit inside the list box
                m_MaxItems = (uint)System.Math.Floor(m_Size.Y / m_ItemHeight);

                // Remove the items that didn't fit inside the list box
                m_Items.RemoveRange((int)m_MaxItems, (int)(m_Items.Count - m_MaxItems));
            }
        }
Пример #4
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <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);
        }
Пример #5
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <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);
        }
Пример #6
0
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Removes the scrollbar from the chat box
 /// </summary>
 ///
 /// <remarks>When there are too many lines to fit in the chat box then some lines will be removed.</remarks>
 ///
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 public void RemoveScrollbar()
 {
     m_Scroll = null;
 }
Пример #7
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Copy constructor
        /// </summary>
        ///
        /// <param name="copy">Instance to copy</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public Scrollbar(Scrollbar copy)
            : base(copy)
        {
            ValueChangedCallback = copy.ValueChangedCallback;

            m_LoadedConfigFile    = copy.m_LoadedConfigFile;
            m_MouseDownOnThumb    = copy.m_MouseDownOnThumb;
            m_MouseDownOnThumbPos = copy.m_MouseDownOnThumbPos;
            m_Maximum             = copy.m_Maximum;
            m_Value               = copy.m_Value;
            m_LowValue            = copy.m_LowValue;
            m_VerticalScroll      = copy.m_VerticalScroll;
            m_VerticalImage       = copy.m_VerticalImage;
            m_AutoHide            = copy.m_AutoHide;
            m_MouseDownOnArrow    = copy.m_MouseDownOnArrow;
            m_SplitImage          = copy.m_SplitImage;
            m_SeparateHoverImage  = copy.m_SeparateHoverImage;
            m_Size                = copy.m_Size;
            m_ThumbSize           = copy.m_ThumbSize;

            Global.TextureManager.CopyTexture(copy.m_TextureTrackNormal_L, m_TextureTrackNormal_L);
            Global.TextureManager.CopyTexture(copy.m_TextureTrackNormal_M, m_TextureTrackNormal_M);
            Global.TextureManager.CopyTexture(copy.m_TextureTrackNormal_R, m_TextureTrackNormal_R);
            Global.TextureManager.CopyTexture(copy.m_TextureTrackHover_L, m_TextureTrackHover_L);
            Global.TextureManager.CopyTexture(copy.m_TextureTrackHover_M, m_TextureTrackHover_M);
            Global.TextureManager.CopyTexture(copy.m_TextureTrackHover_R, m_TextureTrackHover_R);
            Global.TextureManager.CopyTexture(copy.m_TextureThumbNormal, m_TextureThumbNormal);
            Global.TextureManager.CopyTexture(copy.m_TextureThumbHover, m_TextureThumbHover);
            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);
        }
Пример #8
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="copy">Object to copy</param>
 public Scrollbar(Scrollbar copy)
     : base(copy)
 {
 }