Get wxDC defined when nescessary
[wxWidgets.git] / include / wx / bmpcbox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/bmpcbox.h
3 // Purpose: wxBitmapComboBox base header
4 // Author: Jaakko Salli
5 // Modified by:
6 // Created: Aug-31-2006
7 // Copyright: (c) Jaakko Salli
8 // RCS-ID: $Id$
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_BMPCBOX_H_BASE_
13 #define _WX_BMPCBOX_H_BASE_
14
15
16 #include "wx/defs.h"
17
18 #if wxUSE_BITMAPCOMBOBOX
19
20 #include "wx/bitmap.h"
21
22 class WXDLLIMPEXP_FWD_CORE wxWindow;
23 class WXDLLIMPEXP_FWD_CORE wxItemContainer;
24 #if defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED)
25 class WXDLLIMPEXP_FWD_CORE wxDC;
26 #endif
27
28 // Define wxBITMAPCOMBOBOX_OWNERDRAWN_BASED for platforms which
29 // wxBitmapComboBox implementation utilizes ownerdrawn combobox
30 // (either native or generic).
31 #if !defined(__WXGTK20__) || defined(__WXUNIVERSAL__)
32 #define wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
33 #endif
34
35 extern WXDLLIMPEXP_DATA_ADV(const char) wxBitmapComboBoxNameStr[];
36
37
38 class WXDLLIMPEXP_ADV wxBitmapComboBoxBase
39 {
40 public:
41 // ctors and such
42 wxBitmapComboBoxBase() { Init(); }
43
44 virtual ~wxBitmapComboBoxBase() { }
45
46 // Sets the image for the given item.
47 virtual void SetItemBitmap(unsigned int n, const wxBitmap& bitmap) = 0;
48
49 #if !defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED)
50
51 // Returns the image of the item with the given index.
52 virtual wxBitmap GetItemBitmap(unsigned int n) const = 0;
53
54 // Returns size of the image used in list
55 virtual wxSize GetBitmapSize() const = 0;
56
57 private:
58 void Init() {}
59
60 #else // wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
61
62 // Returns the image of the item with the given index.
63 virtual wxBitmap GetItemBitmap(unsigned int n) const;
64
65 // Returns size of the image used in list
66 virtual wxSize GetBitmapSize() const
67 {
68 return m_usedImgSize;
69 }
70
71 protected:
72
73 // Returns pointer to the combobox item container
74 virtual wxItemContainer* GetItemContainer() = 0;
75
76 // Return pointer to the owner-drawn combobox control
77 virtual wxWindow* GetControl() = 0;
78
79 // wxItemContainer functions
80 void BCBDoClear();
81 void BCBDoDeleteOneItem(unsigned int n);
82
83 void DoSetItemBitmap(unsigned int n, const wxBitmap& bitmap);
84
85 void DrawBackground(wxDC& dc, const wxRect& rect, int item, int flags) const;
86 void DrawItem(wxDC& dc, const wxRect& rect, int item, const wxString& text,
87 int flags) const;
88 wxCoord MeasureItem(size_t item) const;
89
90 // Returns true if image size was affected
91 virtual bool OnAddBitmap(const wxBitmap& bitmap);
92
93 // Recalculates amount of empty space needed in front of text
94 // in control itself. Returns number that can be passed to
95 // wxOwnerDrawnComboBox::SetCustomPaintWidth() and similar
96 // functions.
97 virtual int DetermineIndent();
98
99 void UpdateInternals();
100
101 wxArrayPtrVoid m_bitmaps; // Images associated with items
102 wxSize m_usedImgSize; // Size of bitmaps
103
104 int m_imgAreaWidth; // Width and height of area next to text field
105 int m_fontHeight;
106 int m_indent;
107
108 private:
109 void Init();
110 #endif // !wxBITMAPCOMBOBOX_OWNERDRAWN_BASED/wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
111 };
112
113
114 #if defined(__WXUNIVERSAL__)
115 #include "wx/generic/bmpcbox.h"
116 #elif defined(__WXMSW__)
117 #include "wx/msw/bmpcbox.h"
118 #elif defined(__WXGTK20__)
119 #include "wx/gtk/bmpcbox.h"
120 #else
121 #include "wx/generic/bmpcbox.h"
122 #endif
123
124 #endif // wxUSE_BITMAPCOMBOBOX
125
126 #endif // _WX_BMPCBOX_H_BASE_