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 wxItemContainer
;
24 // Define wxBITMAPCOMBOBOX_OWNERDRAWN_BASED for platforms which
25 // wxBitmapComboBox implementation utilizes ownerdrawn combobox
26 // (either native or generic).
28 #define wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
31 extern WXDLLIMPEXP_DATA_ADV(const wxChar
) wxBitmapComboBoxNameStr
[];
34 class WXDLLIMPEXP_ADV wxBitmapComboBoxBase
38 wxBitmapComboBoxBase() { Init(); }
40 virtual ~wxBitmapComboBoxBase() { }
42 // Sets the image for the given item.
43 virtual void SetItemBitmap(unsigned int n
, const wxBitmap
& bitmap
) = 0;
45 #if !defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED)
47 // Returns the image of the item with the given index.
48 virtual wxBitmap
GetItemBitmap(unsigned int n
) const = 0;
50 // Returns size of the image used in list
51 virtual wxSize
GetBitmapSize() const = 0;
56 #else // wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
58 // Returns the image of the item with the given index.
59 virtual wxBitmap
GetItemBitmap(unsigned int n
) const;
61 // Returns size of the image used in list
62 virtual wxSize
GetBitmapSize() const
69 // Returns pointer to the combobox item container
70 virtual wxItemContainer
* GetItemContainer() = 0;
72 // Return pointer to the owner-drawn combobox control
73 virtual wxWindow
* GetControl() = 0;
75 // wxItemContainer functions
77 void BCBDoDeleteOneItem(unsigned int n
);
79 void DoSetItemBitmap(unsigned int n
, const wxBitmap
& bitmap
);
81 void DrawBackground(wxDC
& dc
, const wxRect
& rect
, int item
, int flags
) const;
82 void DrawItem(wxDC
& dc
, const wxRect
& rect
, int item
, const wxString
& text
,
84 wxCoord
MeasureItem(size_t item
) const;
86 // Returns true if image size was affected
87 virtual bool OnAddBitmap(const wxBitmap
& bitmap
);
89 // Recalculates amount of empty space needed in front of text
90 // in control itself. Returns number that can be passed to
91 // wxOwnerDrawnComboBox::SetCustomPaintWidth() and similar
93 virtual int DetermineIndent();
95 void UpdateInternals();
97 wxArrayPtrVoid m_bitmaps
; // Images associated with items
98 wxSize m_usedImgSize
; // Size of bitmaps
100 int m_imgAreaWidth
; // Width and height of area next to text field
106 #endif // !wxBITMAPCOMBOBOX_OWNERDRAWN_BASED/wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
110 #if defined(__WXUNIVERSAL__)
111 #include "wx/generic/bmpcbox.h"
112 #elif defined(__WXMSW__)
113 #include "wx/msw/bmpcbox.h"
115 #include "wx/generic/bmpcbox.h"
118 #endif // wxUSE_BITMAPCOMBOBOX
120 #endif // _WX_BMPCBOX_H_BASE_