29 #ifndef Pt_Forms_ListBox_H
30 #define Pt_Forms_ListBox_H
32 #include <Pt/Forms/Control.h>
33 #include <Pt/Forms/Button.h>
34 #include <Pt/Forms/ScrollView.h>
35 #include <Pt/Forms/FlowLayout.h>
36 #include <Pt/Forms/Icon.h>
37 #include <Pt/Forms/PixmapSurface.h>
38 #include <Pt/Gfx/Color.h>
39 #include <Pt/Gfx/Image.h>
40 #include <Pt/SmartPtr.h>
47 class PT_FORMS_API ListBoxItem :
public Button
54 virtual ~ListBoxItem();
56 bool isSelectable()
const;
58 void setSelectable(
bool b);
60 bool isSelected()
const;
62 void setSelected(
bool b);
68 void setIcon(
const Icon& icon,
const Gfx::SizeF& size);
70 const Gfx::SizeF& iconSize()
const
76 const Gfx::Brush& background()
const;
78 void setBackground(
const Gfx::Brush& b);
80 const Gfx::Pen& contour()
const;
82 void setContour(
const Gfx::Pen& p);
84 const Gfx::Color& textColor()
const;
86 void setTextColor(
const Gfx::Color& color);
88 const Gfx::Font& font()
const;
90 void setFont(
const Gfx::Font& font);
92 void setFontSize(std::size_t size);
94 void setFontWeight(Gfx::Font::Weight weight);
96 void setFontSlant(Gfx::Font::Slant slant);
98 void setRenderer(ListBoxRenderer* renderer);
101 const PixmapSurface& picture()
const
104 const Gfx::Font& currentFont()
const
108 virtual void onPressed();
110 virtual void onReleased();
112 virtual void onCanceled();
115 virtual Gfx::SizeF onMeasure(
const SizePolicy& p);
117 virtual void onInvalidate();
119 virtual void onPaint(PaintSurface& surface,
const Gfx::RectF& updateRect);
122 virtual void onPaintContent(PaintSurface& surface, Gfx::Painter& painter);
125 Gfx::Font getFont()
const;
128 enum FontOverride :
unsigned
131 OverrideWeight = 0x02,
132 OverrideSlant = 0x04,
142 Gfx::SizeF _iconSize;
144 FacetPtr<ListBoxRenderer> _renderer;
147 AutoPtr<Gfx::Brush> _background;
148 AutoPtr<Gfx::Pen> _contour;
149 AutoPtr<Gfx::Color> _textColor;
150 Gfx::Font _customFont;
151 unsigned _fontOverride;
157 PixmapSurface _picture;
161 class ListBoxLayout :
public FlowLayout
163 friend class ListBox;
168 const std::vector<ListBoxItem*>& selectedItems()
const;
173 virtual void onAddControl(Control& control);
175 virtual void onRemoveControl(Control& control);
178 void onItemSelected(ListBoxItem& item);
182 std::vector<ListBoxItem*> _selectedItems;
186 class PT_FORMS_API ListBox :
public Control
188 typedef Control Base;
195 void setScrollBars(
bool hasScrollBars);
197 void addItem(ListBoxItem& item);
199 void removeItem(ListBoxItem& item);
201 const std::vector<ListBoxItem*>& selectedItems()
const;
205 void scrollX(
int xpos);
207 void scrollY(
int ypos);
209 int maximumX()
const;
211 int maximumY()
const;
214 const Gfx::Brush* background()
const;
216 void setBackground(
const Gfx::Brush& b);
218 void setBackground(
bool b);
220 const Gfx::Pen* contour()
const;
222 void setContour(
const Gfx::Pen& pen);
224 void setFrame(
bool b);
226 void setRenderer(ListBoxRenderer* renderer);
229 virtual void onInvalidate();
231 virtual void onPaint(PaintSurface& surface,
const Gfx::RectF& updateRect);
233 virtual Gfx::SizeF onMeasure(
const SizePolicy& policy);
235 virtual void onLayout(
const Gfx::RectF& rect);
238 ScrollView _scrollView;
239 ListBoxLayout _layout;
240 FacetPtr<ListBoxRenderer> _renderer;
242 AutoPtr<Gfx::Brush> _background;
244 AutoPtr<Gfx::Pen> _contour;
Unicode capable basic_string.
Definition: String.h:42