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