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"
21 #include "wx/window.h"
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).
29 #define wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
32 extern WXDLLIMPEXP_DATA_ADV(const wxChar
) wxBitmapComboBoxNameStr
[];
35 class WXDLLIMPEXP_ADV wxBitmapComboBoxBase
39 wxBitmapComboBoxBase() { Init(); }
41 virtual ~wxBitmapComboBoxBase() { }
43 // Sets the image for the given item.
44 virtual void SetItemBitmap(unsigned int n
, const wxBitmap
& bitmap
) = 0;
46 #if !defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED)
48 // Returns the image of the item with the given index.
49 virtual wxBitmap
GetItemBitmap(unsigned int n
) const = 0;
51 // Returns size of the image used in list
52 virtual wxSize
GetBitmapSize() const = 0;
57 #else // wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
59 // Returns the image of the item with the given index.
60 virtual wxBitmap
GetItemBitmap(unsigned int n
) const;
62 // Returns size of the image used in list
63 virtual wxSize
GetBitmapSize() const
70 // Returns pointer to the combobox item container
71 virtual wxItemContainer
* GetItemContainer() = 0;
73 // Return pointer to the owner-drawn combobox control
74 virtual wxWindow
* GetControl() = 0;
76 // wxItemContainer functions
78 void BCBDoDeleteOneItem(unsigned int n
);
80 void DoSetItemBitmap(unsigned int n
, const wxBitmap
& bitmap
);
82 void DrawBackground(wxDC
& dc
, const wxRect
& rect
, int item
, int flags
) const;
83 void DrawItem(wxDC
& dc
, const wxRect
& rect
, int item
, const wxString
& text
,
85 wxCoord
MeasureItem(size_t item
) const;
87 // Returns true if image size was affected
88 virtual bool OnAddBitmap(const wxBitmap
& bitmap
);
90 // Recalculates amount of empty space needed in front of text
91 // in control itself. Returns number that can be passed to
92 // wxOwnerDrawnComboBox::SetCustomPaintWidth() and similar
94 virtual int DetermineIndent();
96 void UpdateInternals();
98 wxArrayPtrVoid m_bitmaps
; // Images associated with items
99 wxSize m_usedImgSize
; // Size of bitmaps
101 int m_imgAreaWidth
; // Width and height of area next to text field
107 #endif // !wxBITMAPCOMBOBOX_OWNERDRAWN_BASED/wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
111 #if defined(__WXUNIVERSAL__)
112 #include "wx/generic/bmpcbox.h"
113 #elif defined(__WXMSW__)
114 #include "wx/msw/bmpcbox.h"
116 #include "wx/generic/bmpcbox.h"
119 #endif // wxUSE_BITMAPCOMBOBOX
121 #endif // _WX_BMPCBOX_H_BASE_