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