]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/bmpcbox.h
Apply parts of patch #1719888 to fix compilation on Mac and with
[wxWidgets.git] / include / wx / generic / bmpcbox.h
CommitLineData
95a46303
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/generic/bmpcbox.h
3// Purpose: wxBitmapComboBox
4// Author: Jaakko Salli
5// Modified by:
6// Created: Aug-30-2006
1c4e8f38 7// RCS-ID: $Id$
95a46303
RR
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
95a46303
RR
18#include "wx/odcombo.h"
19
95a46303
RR
20// ----------------------------------------------------------------------------
21// wxBitmapComboBox: a wxComboBox that allows images to be shown
22// in front of string items.
23// ----------------------------------------------------------------------------
24
25class WXDLLIMPEXP_ADV wxBitmapComboBox : public wxOwnerDrawnComboBox,
26 public wxBitmapComboBoxBase
27{
28public:
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 { return DoAppendWithImage(item, bitmap); }
91
92 int Append(const wxString& item, const wxBitmap& bitmap, void *clientData)
93 { int n = DoAppendWithImage(item, bitmap); SetClientData(n, clientData); return n; }
94 int Append(const wxString& item, const wxBitmap& bitmap, wxClientData *clientData)
95 { int n = DoAppendWithImage(item, bitmap); SetClientObject(n, clientData); return n; }
96
97 // Returns size of image used in list.
98 virtual wxSize GetBitmapSize() const
99 {
100 return m_usedImgSize;
101 }
102
103 // Returns the image of the item with the given index.
104 virtual wxBitmap GetItemBitmap(unsigned int n) const;
105
106 // Inserts item with image into the list before pos. Not valid for wxCB_SORT or wxCB_SORT
107 // styles, use Append instead.
108 int Insert(const wxString& item, const wxBitmap& bitmap, unsigned int pos)
109 { return DoInsertWithImage(item, bitmap, pos); }
110
111 int Insert(const wxString& item, const wxBitmap& bitmap,
112 unsigned int pos, void *clientData);
113 int Insert(const wxString& item, const wxBitmap& bitmap,
114 unsigned int pos, wxClientData *clientData);
115
116 // Sets the image for the given item.
117 virtual void SetItemBitmap(unsigned int n, const wxBitmap& bitmap);
118
119 virtual void Clear();
120 virtual void Delete(unsigned int n);
121
122protected:
123
124 virtual void OnDrawBackground(wxDC& dc, const wxRect& rect, int item, int flags) const;
125 virtual void OnDrawItem(wxDC& dc, const wxRect& rect, int item, int flags) const;
126 virtual wxCoord OnMeasureItem(size_t item) const;
127 virtual wxCoord OnMeasureItemWidth(size_t item) const;
128
129 virtual int DoAppendWithImage(const wxString& item, const wxBitmap& bitmap);
130 virtual int DoInsertWithImage(const wxString& item, const wxBitmap& bitmap,
131 unsigned int pos);
132
133 virtual int DoAppend(const wxString& item);
134 virtual int DoInsert(const wxString& item, unsigned int pos);
135
136 virtual bool SetFont(const wxFont& font);
137
138 virtual wxSize DoGetBestSize() const;
139
140 // Event handlers
012967ef 141 void OnSize(wxSizeEvent& event);
95a46303
RR
142
143 // Recalculates amount of empty space needed in front of
144 // text in control itself.
145 void DetermineIndent();
146
147 bool OnAddBitmap(const wxBitmap& bitmap);
148
149 // Adds image to position - called in Append/Insert before
150 // string is added.
151 bool DoInsertBitmap(const wxBitmap& image, unsigned int pos);
152
153
154 wxArrayPtrVoid m_bitmaps; // Images associated with items
155 wxSize m_usedImgSize; // Size of bitmaps
156
157private:
158 int m_imgAreaWidth; // Width and height of area next to text field
159 int m_fontHeight;
160 bool m_inResize;
161
162 void Init();
163 void PostCreate();
164
165 DECLARE_EVENT_TABLE()
166
167 DECLARE_DYNAMIC_CLASS(wxBitmapComboBox)
168};
169
8d37334f 170#endif // _WX_GENERIC_BMPCBOX_H_