]>
Commit | Line | Data |
---|---|---|
f696015c VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/msw/bmpcbox.h | |
3 | // Purpose: wxBitmapComboBox | |
4 | // Author: Jaakko Salli | |
5 | // Created: 2008-04-06 | |
f696015c VZ |
6 | // Copyright: (c) 2008 Jaakko Salli |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #ifndef _WX_MSW_BMPCBOX_H_ | |
11 | #define _WX_MSW_BMPCBOX_H_ | |
12 | ||
13 | ||
14 | #include "wx/combobox.h" | |
15 | ||
16 | ||
17 | // ---------------------------------------------------------------------------- | |
18 | // wxBitmapComboBox: a wxComboBox that allows images to be shown | |
19 | // in front of string items. | |
20 | // ---------------------------------------------------------------------------- | |
21 | ||
22 | class WXDLLIMPEXP_ADV wxBitmapComboBox : public wxComboBox, | |
23 | public wxBitmapComboBoxBase | |
24 | { | |
25 | public: | |
26 | // ctors and such | |
27 | wxBitmapComboBox() : wxComboBox(), wxBitmapComboBoxBase() | |
28 | { | |
29 | Init(); | |
30 | } | |
31 | ||
32 | wxBitmapComboBox(wxWindow *parent, | |
33 | wxWindowID id = wxID_ANY, | |
34 | const wxString& value = wxEmptyString, | |
35 | const wxPoint& pos = wxDefaultPosition, | |
36 | const wxSize& size = wxDefaultSize, | |
37 | int n = 0, | |
38 | const wxString choices[] = NULL, | |
39 | long style = 0, | |
40 | const wxValidator& validator = wxDefaultValidator, | |
41 | const wxString& name = wxBitmapComboBoxNameStr) | |
42 | : wxComboBox(), | |
43 | wxBitmapComboBoxBase() | |
44 | { | |
45 | Init(); | |
46 | ||
47 | (void)Create(parent, id, value, pos, size, n, | |
48 | choices, style, validator, name); | |
49 | } | |
50 | ||
51 | wxBitmapComboBox(wxWindow *parent, | |
52 | wxWindowID id, | |
53 | const wxString& value, | |
54 | const wxPoint& pos, | |
55 | const wxSize& size, | |
56 | const wxArrayString& choices, | |
57 | long style, | |
58 | const wxValidator& validator = wxDefaultValidator, | |
59 | const wxString& name = wxBitmapComboBoxNameStr); | |
60 | ||
61 | bool Create(wxWindow *parent, | |
62 | wxWindowID id, | |
63 | const wxString& value, | |
64 | const wxPoint& pos, | |
65 | const wxSize& size, | |
66 | int n, | |
67 | const wxString choices[], | |
68 | long style = 0, | |
69 | const wxValidator& validator = wxDefaultValidator, | |
70 | const wxString& name = wxBitmapComboBoxNameStr); | |
71 | ||
72 | bool Create(wxWindow *parent, | |
73 | wxWindowID id, | |
74 | const wxString& value, | |
75 | const wxPoint& pos, | |
76 | const wxSize& size, | |
77 | const wxArrayString& choices, | |
78 | long style = 0, | |
79 | const wxValidator& validator = wxDefaultValidator, | |
80 | const wxString& name = wxBitmapComboBoxNameStr); | |
81 | ||
82 | virtual ~wxBitmapComboBox(); | |
83 | ||
84 | // Sets the image for the given item. | |
85 | virtual void SetItemBitmap(unsigned int n, const wxBitmap& bitmap); | |
86 | ||
ed8f00db JS |
87 | virtual bool SetFont(const wxFont& font); |
88 | ||
f696015c VZ |
89 | // Adds item with image to the end of the combo box. |
90 | int Append(const wxString& item, const wxBitmap& bitmap = wxNullBitmap); | |
91 | int Append(const wxString& item, const wxBitmap& bitmap, void *clientData); | |
92 | int Append(const wxString& item, const wxBitmap& bitmap, wxClientData *clientData); | |
93 | ||
94 | // Inserts item with image into the list before pos. Not valid for wxCB_SORT | |
95 | // styles, use Append instead. | |
96 | int Insert(const wxString& item, const wxBitmap& bitmap, unsigned int pos); | |
97 | int Insert(const wxString& item, const wxBitmap& bitmap, | |
98 | unsigned int pos, void *clientData); | |
99 | int Insert(const wxString& item, const wxBitmap& bitmap, | |
100 | unsigned int pos, wxClientData *clientData); | |
101 | ||
102 | protected: | |
103 | ||
104 | WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; | |
105 | virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item); | |
106 | virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item); | |
107 | ||
108 | // Event handlers | |
109 | void OnSize(wxSizeEvent& event); | |
110 | ||
f696015c VZ |
111 | virtual wxItemContainer* GetItemContainer() { return this; } |
112 | virtual wxWindow* GetControl() { return this; } | |
113 | ||
114 | // wxItemContainer implementation | |
115 | virtual int DoInsertItems(const wxArrayStringsAdapter & items, | |
116 | unsigned int pos, | |
117 | void **clientData, wxClientDataType type); | |
118 | virtual void DoClear(); | |
119 | virtual void DoDeleteOneItem(unsigned int n); | |
120 | ||
121 | virtual bool OnAddBitmap(const wxBitmap& bitmap); | |
41ce9ae1 | 122 | virtual wxSize DoGetBestSize() const; |
f696015c VZ |
123 | void RecreateControl(); |
124 | ||
125 | private: | |
126 | void Init(); | |
127 | ||
128 | bool m_inResize; | |
129 | ||
130 | DECLARE_EVENT_TABLE() | |
131 | ||
132 | DECLARE_DYNAMIC_CLASS(wxBitmapComboBox) | |
133 | }; | |
134 | ||
135 | #endif // _WX_MSW_BMPCBOX_H_ |