1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxBitmapComboBox base header
4 // Author: Jaakko Salli
6 // Created: Aug-31-2006
7 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_BMPCBOX_H_BASE_
13 #define _WX_BMPCBOX_H_BASE_
18 #if wxUSE_BITMAPCOMBOBOX
20 #include "wx/bitmap.h"
22 class WXDLLIMPEXP_FWD_CORE wxWindow
;
23 class WXDLLIMPEXP_FWD_CORE wxItemContainer
;
24 #if defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED)
25 class WXDLLIMPEXP_FWD_CORE wxDC
;
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
35 extern WXDLLIMPEXP_DATA_ADV(const char) wxBitmapComboBoxNameStr
[];
38 class WXDLLIMPEXP_ADV wxBitmapComboBoxBase
42 wxBitmapComboBoxBase() { Init(); }
44 virtual ~wxBitmapComboBoxBase() { }
46 // Sets the image for the given item.
47 virtual void SetItemBitmap(unsigned int n
, const wxBitmap
& bitmap
) = 0;
49 #if !defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED)
51 // Returns the image of the item with the given index.
52 virtual wxBitmap
GetItemBitmap(unsigned int n
) const = 0;
54 // Returns size of the image used in list
55 virtual wxSize
GetBitmapSize() const = 0;
60 #else // wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
62 // Returns the image of the item with the given index.
63 virtual wxBitmap
GetItemBitmap(unsigned int n
) const;
65 // Returns size of the image used in list
66 virtual wxSize
GetBitmapSize() const
73 // Returns pointer to the combobox item container
74 virtual wxItemContainer
* GetItemContainer() = 0;
76 // Return pointer to the owner-drawn combobox control
77 virtual wxWindow
* GetControl() = 0;
79 // wxItemContainer functions
81 void BCBDoDeleteOneItem(unsigned int n
);
83 void DoSetItemBitmap(unsigned int n
, const wxBitmap
& bitmap
);
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
,
88 wxCoord
MeasureItem(size_t item
) const;
90 // Returns true if image size was affected
91 virtual bool OnAddBitmap(const wxBitmap
& bitmap
);
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
97 virtual int DetermineIndent();
99 void UpdateInternals();
101 wxArrayPtrVoid m_bitmaps
; // Images associated with items
102 wxSize m_usedImgSize
; // Size of bitmaps
104 int m_imgAreaWidth
; // Width and height of area next to text field
110 #endif // !wxBITMAPCOMBOBOX_OWNERDRAWN_BASED/wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
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"
121 #include "wx/generic/bmpcbox.h"
124 #endif // wxUSE_BITMAPCOMBOBOX
126 #endif // _WX_BMPCBOX_H_BASE_