]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/bmpcbox.h
fix memory leak; allocate the DC before SetFont() is called on the status bar
[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.
a236aa20
VZ
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);
95a46303 92
a236aa20
VZ
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);
95a46303 100
95a46303
RR
101 // Sets the image for the given item.
102 virtual void SetItemBitmap(unsigned int n, const wxBitmap& bitmap);
1dff2537 103 virtual bool SetFont(const wxFont& font);
95a46303 104
95a46303
RR
105protected:
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
95a46303 112 // Event handlers
012967ef 113 void OnSize(wxSizeEvent& event);
95a46303 114
f696015c 115 virtual wxSize DoGetBestSize() const;
95a46303 116
f696015c
VZ
117 virtual wxItemContainer* GetItemContainer() { return this; }
118 virtual wxWindow* GetControl() { return this; }
95a46303 119
f696015c
VZ
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);
95a46303
RR
126
127private:
95a46303
RR
128 bool m_inResize;
129
130 void Init();
95a46303
RR
131
132 DECLARE_EVENT_TABLE()
133
134 DECLARE_DYNAMIC_CLASS(wxBitmapComboBox)
135};
136
8d37334f 137#endif // _WX_GENERIC_BMPCBOX_H_