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