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