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
;
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
31 class WXDLLIMPEXP_FWD_CORE wxDC
;
34 extern WXDLLIMPEXP_DATA_ADV(const char) wxBitmapComboBoxNameStr
[];
37 class WXDLLIMPEXP_ADV wxBitmapComboBoxBase
41 wxBitmapComboBoxBase() { Init(); }
43 virtual ~wxBitmapComboBoxBase() { }
45 // Sets the image for the given item.
46 virtual void SetItemBitmap(unsigned int n
, const wxBitmap
& bitmap
) = 0;
48 #if !defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED)
50 // Returns the image of the item with the given index.
51 virtual wxBitmap
GetItemBitmap(unsigned int n
) const = 0;
53 // Returns size of the image used in list
54 virtual wxSize
GetBitmapSize() const = 0;
59 #else // wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
61 // Returns the image of the item with the given index.
62 virtual wxBitmap
GetItemBitmap(unsigned int n
) const;
64 // Returns size of the image used in list
65 virtual wxSize
GetBitmapSize() const
72 // Returns pointer to the combobox item container
73 virtual wxItemContainer
* GetItemContainer() = 0;
75 // Return pointer to the owner-drawn combobox control
76 virtual wxWindow
* GetControl() = 0;
78 // wxItemContainer functions
80 void BCBDoDeleteOneItem(unsigned int n
);
82 void DoSetItemBitmap(unsigned int n
, const wxBitmap
& bitmap
);
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
,
87 wxCoord
MeasureItem(size_t item
) const;
89 // Returns true if image size was affected
90 virtual bool OnAddBitmap(const wxBitmap
& bitmap
);
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
96 virtual int DetermineIndent();
98 void UpdateInternals();
100 wxArrayPtrVoid m_bitmaps
; // Images associated with items
101 wxSize m_usedImgSize
; // Size of bitmaps
103 int m_imgAreaWidth
; // Width and height of area next to text field
109 #endif // !wxBITMAPCOMBOBOX_OWNERDRAWN_BASED/wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
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"
120 #include "wx/generic/bmpcbox.h"
123 #endif // wxUSE_BITMAPCOMBOBOX
125 #endif // _WX_BMPCBOX_H_BASE_