Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

listbox.h

Go to the documentation of this file.
00001 /*
00002         ClanGUI, copyrights by various people. Have a look in the CREDITS file.
00003         
00004         This sourcecode is distributed using the Library GNU Public Licence,
00005         version 2 or (at your option) any later version. Please read LICENSE
00006         for details.
00007 */
00008 
00010 
00011 #ifndef header_listbox
00012 #define header_listbox
00013 
00014 #include "component.h"
00015 
00016 class CL_ListBox : public CL_Component
00017 //: Listbox component
00018 {
00020 public:
00021         CL_ListBox(
00022                 const CL_ComponentOptions &options,
00023                 CL_Component *parent,
00024                 CL_StyleManager *style = NULL);
00025         
00026         CL_ListBox(
00027                 const CL_Rect &pos,
00028                 CL_Component *parent,
00029                 CL_StyleManager *style = NULL);
00030 
00031         virtual ~CL_ListBox();
00032 
00034 public:
00035         CL_Component *get_client_area() const;
00036         //: Returns the client area of the component.
00037 
00038         int get_count() const;
00039         //: Returns the number of items in the list box. 
00040 
00041         std::list<std::string> &get_items() const;
00042         //: Returns all items in the list.
00043 
00044         std::string get_current_text() const;
00045         //: Returns the text of the current item.
00046 
00047         std::string get_text(int index) const;
00048         //: Returns the text at position index.
00049 
00050         int get_current_item() const;
00051         //: Returns the index of the current item of the listbox, or -1 if no item has been selected. 
00052 
00053         bool is_selected(int index) const;
00054         //: Returns true if item index is selected. Returns false if it is not selected or if there is an error.
00055 
00056         int get_item_height() const;
00057         //: Returns the height of one item.
00058 
00059         int get_top_item() const;
00060         //: Returns the index of the item at the top of the screen.
00061 
00062         int get_max_visible_items() const;
00063         //: Returns number of items maximum visible in listbox (without scrolling)
00064 
00065         bool has_scrollbar() const;
00066         //: Returns true if a scrollbar is visible in the listbox.
00067 
00069 public:
00070         int insert_item(const std::string &text, int index = -1);
00071         //: Inserts text into the list at index. 
00072         // If index is negative, text is inserted at the end of the list.
00073         // Returns the index of the text
00074 
00075         void remove_item(int index);
00076         //: Removes and deletes the item at position index.
00077         // If index is equal to get_current_item(), a new item gets highlighted and the sig_highlighted() signal is emitted. 
00078 
00079         void change_item(const std::string &text, int index);
00080         //: Replaces the item at position index with text. 
00081 
00082         void set_current_item(int index);
00083         //: Sets the highlighted item to the item index.
00084         // The highlighting is moved and the listbox scrolled as necessary. 
00085 
00086         void clear_selection();
00087         //: Deselects current selected item.
00088 
00089         void set_item_height(int height);
00090         //: Sets the height of each item.
00091 
00092         void set_max_visible_items(int count);
00093         //: Sets the number of items maximum visible in listbox (without scrolling)
00094 
00095         void set_top_item(int index);
00096         //: Scrolls the list box so the item at position index in the list is displayed in the top row of the listbox. 
00097 
00098         void sort(bool ascending = true);
00099         //: Sorts the items in ascending order, if ascending is true, or descending otherwise. 
00100 
00101         void clear();
00102         //: Deletes all items in the list. 
00103 
00105 public:
00106         CL_Signal_v1<int> &sig_highlighted();
00107         //: This signal is emitted when the user highlights a new current item.
00108         // The argument is the index of the new item, which is already current. 
00109 
00110         CL_Signal_v1<int> &sig_activated();
00111         //: This signal is emitted when the user clicks on an item or presses return when an item is highlighted.
00112         // The argument is the index of the selected item. 
00113 
00115 private:
00116         CL_ListBox(const CL_ListBox &copy) : CL_Component(NULL, NULL) { return; } // disallow copy construction.
00117         class CL_ListBox_Generic *impl;
00118 };
00119 
00120 #endif

Generated at Wed Apr 4 19:54:01 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001