]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/bmpcbox.h
use global operator new to fix compilation errors if type T overloads new (as wxObjec...
[wxWidgets.git] / include / wx / generic / bmpcbox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/bmpcbox.h
3 // Purpose: wxBitmapComboBox
4 // Author: Jaakko Salli
5 // Modified by:
6 // Created: Aug-30-2006
7 // RCS-ID: $Id$
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_GENERIC_BMPCBOX_H_
13 #define _WX_GENERIC_BMPCBOX_H_
14
15
16 #define wxGENERIC_BITMAPCOMBOBOX 1
17
18 #include "wx/odcombo.h"
19
20 // ----------------------------------------------------------------------------
21 // wxBitmapComboBox: a wxComboBox that allows images to be shown
22 // in front of string items.
23 // ----------------------------------------------------------------------------
24
25 class WXDLLIMPEXP_ADV wxBitmapComboBox : public wxOwnerDrawnComboBox,
26 public wxBitmapComboBoxBase
27 {
28 public:
29
30 // ctors and such
31 wxBitmapComboBox() : wxOwnerDrawnComboBox(), wxBitmapComboBoxBase()
32 {
33 Init();
34 }
35
36 wxBitmapComboBox(wxWindow *parent,
37 wxWindowID id = wxID_ANY,
38 const wxString& value = wxEmptyString,
39 const wxPoint& pos = wxDefaultPosition,
40 const wxSize& size = wxDefaultSize,
41 int n = 0,
42 const wxString choices[] = NULL,
43 long style = 0,
44 const wxValidator& validator = wxDefaultValidator,
45 const wxString& name = wxBitmapComboBoxNameStr)
46 : wxOwnerDrawnComboBox(),
47 wxBitmapComboBoxBase()
48 {
49 Init();
50
51 (void)Create(parent, id, value, pos, size, n,
52 choices, style, validator, name);
53 }
54
55 wxBitmapComboBox(wxWindow *parent,
56 wxWindowID id,
57 const wxString& value,
58 const wxPoint& pos,
59 const wxSize& size,
60 const wxArrayString& choices,
61 long style,
62 const wxValidator& validator = wxDefaultValidator,
63 const wxString& name = wxBitmapComboBoxNameStr);
64
65 bool Create(wxWindow *parent,
66 wxWindowID id,
67 const wxString& value,
68 const wxPoint& pos,
69 const wxSize& size,
70 int n,
71 const wxString choices[],
72 long style = 0,
73 const wxValidator& validator = wxDefaultValidator,
74 const wxString& name = wxBitmapComboBoxNameStr);
75
76 bool Create(wxWindow *parent,
77 wxWindowID id,
78 const wxString& value,
79 const wxPoint& pos,
80 const wxSize& size,
81 const wxArrayString& choices,
82 long style = 0,
83 const wxValidator& validator = wxDefaultValidator,
84 const wxString& name = wxBitmapComboBoxNameStr);
85
86 virtual ~wxBitmapComboBox();
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 // Sets the image for the given item.
102 virtual void SetItemBitmap(unsigned int n, const wxBitmap& bitmap);
103 virtual bool SetFont(const wxFont& font);
104
105 protected:
106
107 virtual void OnDrawBackground(wxDC& dc, const wxRect& rect, int item, int flags) const;
108 virtual void OnDrawItem(wxDC& dc, const wxRect& rect, int item, int flags) const;
109 virtual wxCoord OnMeasureItem(size_t item) const;
110 virtual wxCoord OnMeasureItemWidth(size_t item) const;
111
112 // Event handlers
113 void OnSize(wxSizeEvent& event);
114
115 virtual wxSize DoGetBestSize() const;
116
117 virtual wxItemContainer* GetItemContainer() { return this; }
118 virtual wxWindow* GetControl() { return this; }
119
120 // wxItemContainer implementation
121 virtual int DoInsertItems(const wxArrayStringsAdapter & items,
122 unsigned int pos,
123 void **clientData, wxClientDataType type);
124 virtual void DoClear();
125 virtual void DoDeleteOneItem(unsigned int n);
126
127 private:
128 bool m_inResize;
129
130 void Init();
131
132 DECLARE_EVENT_TABLE()
133
134 DECLARE_DYNAMIC_CLASS(wxBitmapComboBox)
135 };
136
137 #endif // _WX_GENERIC_BMPCBOX_H_