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