00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef PG_LISTBOX_H
00030 #define PG_LISTBOX_H
00031
00032 #include "pgwidgetlist.h"
00033 #include "pglabel.h"
00034
00035 class PG_ListBoxBaseItem;
00036
00049 class DECLSPEC PG_ListBox : public PG_WidgetList {
00050 public:
00051
00055 template<class datatype = PG_Pointer>
00056 class SignalSelectItem : public PG_Signal1<PG_ListBoxBaseItem*, datatype> {}
00057 ;
00058
00060 PG_ListBox(PG_Widget* parent, const PG_Rect& r = PG_Rect::null, const std::string& style="ListBox");
00061
00063 ~PG_ListBox();
00064
00066 void SetMultiSelect(bool multi = true);
00067
00069 bool GetMultiSelect();
00070
00072 PG_ListBoxBaseItem* GetSelectedItem();
00073
00075 void SelectItem(PG_ListBoxBaseItem* item, bool select = true, bool fireEvent = true);
00076
00077
00078 void SelectFirstItem( bool fireEvent = true );
00079
00080
00081 void SelectNextItem( bool fireEvent = true );
00082
00083
00084 void SelectPrevItem( bool fireEvent = true );
00085
00089 void RemoveAll();
00090
00094 void DeleteAll();
00095
00100 void SetIndent(Uint16 indent);
00101
00105 Uint16 GetIndent();
00106
00111 void SetAlignment(PG_Label::TextAlign style);
00112
00116 PG_Label::TextAlign GetAlignment();
00117
00121 int GetSelectedIndex();
00122
00123 void GetSelectedItems(std::vector<PG_ListBoxBaseItem*>& items);
00124
00125 void AddChild(PG_Widget* child);
00126
00127 SignalSelectItem<> sigSelectItem;
00128
00129 protected:
00130
00132 virtual bool eventSelectItem(PG_ListBoxBaseItem* item);
00133
00135 bool eventMouseButtonUp(const SDL_MouseButtonEvent* button);
00136
00138 bool eventMouseButtonDown(const SDL_MouseButtonEvent* button);
00139
00141 bool eventMouseMotion(const SDL_MouseMotionEvent* motion);
00142
00143 friend class PG_ListBoxBaseItem;
00144
00145 private:
00146
00147 bool my_multiselect;
00148
00149 Uint16 my_indent;
00150
00151 int my_selectindex;
00152
00153 PG_ListBoxBaseItem* my_selectedItem;
00154
00155 PG_Label::TextAlign my_alignment;
00156
00157 };
00158
00159 #endif // PG_LISTBOX_H