]> git.saurik.com Git - wxWidgets.git/blame - include/wx/bmpcbox.h
Split up the context menu functionality to make it easier to customise.
[wxWidgets.git] / include / wx / bmpcbox.h
CommitLineData
95a46303
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/bmpcbox.h
3// Purpose: wxBitmapComboBox base header
4// Author: Jaakko Salli
5// Modified by:
6// Created: Aug-31-2006
7// Copyright: (c) Jaakko Salli
1c4e8f38 8// RCS-ID: $Id$
95a46303
RR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_BMPCBOX_H_BASE_
13#define _WX_BMPCBOX_H_BASE_
14
15
16#include "wx/defs.h"
17
18#if wxUSE_BITMAPCOMBOBOX
19
20#include "wx/bitmap.h"
21
65391c8f 22class WXDLLIMPEXP_FWD_CORE wxWindow;
c574bfa9
VZ
23class WXDLLIMPEXP_FWD_CORE wxItemContainer;
24
f696015c
VZ
25// Define wxBITMAPCOMBOBOX_OWNERDRAWN_BASED for platforms which
26// wxBitmapComboBox implementation utilizes ownerdrawn combobox
27// (either native or generic).
4c7b2d36 28#if !defined(__WXGTK20__) || defined(__WXUNIVERSAL__)
f696015c 29 #define wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
b1b5ebb7
JJ
30
31class WXDLLIMPEXP_FWD_CORE wxDC;
f696015c 32#endif
95a46303 33
23318a53 34extern WXDLLIMPEXP_DATA_ADV(const char) wxBitmapComboBoxNameStr[];
95a46303
RR
35
36
37class WXDLLIMPEXP_ADV wxBitmapComboBoxBase
38{
39public:
95a46303 40 // ctors and such
f696015c 41 wxBitmapComboBoxBase() { Init(); }
95a46303
RR
42
43 virtual ~wxBitmapComboBoxBase() { }
44
95a46303
RR
45 // Sets the image for the given item.
46 virtual void SetItemBitmap(unsigned int n, const wxBitmap& bitmap) = 0;
47
f696015c
VZ
48#if !defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED)
49
50 // Returns the image of the item with the given index.
51 virtual wxBitmap GetItemBitmap(unsigned int n) const = 0;
52
95a46303
RR
53 // Returns size of the image used in list
54 virtual wxSize GetBitmapSize() const = 0;
f696015c
VZ
55
56private:
57 void Init() {}
58
59#else // wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
60
61 // Returns the image of the item with the given index.
62 virtual wxBitmap GetItemBitmap(unsigned int n) const;
63
64 // Returns size of the image used in list
65 virtual wxSize GetBitmapSize() const
66 {
67 return m_usedImgSize;
68 }
69
70protected:
71
72 // Returns pointer to the combobox item container
73 virtual wxItemContainer* GetItemContainer() = 0;
74
75 // Return pointer to the owner-drawn combobox control
76 virtual wxWindow* GetControl() = 0;
77
78 // wxItemContainer functions
79 void BCBDoClear();
80 void BCBDoDeleteOneItem(unsigned int n);
81
82 void DoSetItemBitmap(unsigned int n, const wxBitmap& bitmap);
83
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,
86 int flags) const;
87 wxCoord MeasureItem(size_t item) const;
88
89 // Returns true if image size was affected
90 virtual bool OnAddBitmap(const wxBitmap& bitmap);
91
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
95 // functions.
96 virtual int DetermineIndent();
97
98 void UpdateInternals();
99
100 wxArrayPtrVoid m_bitmaps; // Images associated with items
101 wxSize m_usedImgSize; // Size of bitmaps
102
103 int m_imgAreaWidth; // Width and height of area next to text field
104 int m_fontHeight;
105 int m_indent;
106
107private:
108 void Init();
109#endif // !wxBITMAPCOMBOBOX_OWNERDRAWN_BASED/wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
95a46303
RR
110};
111
112
f696015c
VZ
113#if defined(__WXUNIVERSAL__)
114 #include "wx/generic/bmpcbox.h"
115#elif defined(__WXMSW__)
116 #include "wx/msw/bmpcbox.h"
faba238f 117#elif defined(__WXGTK20__)
e78c1d78 118 #include "wx/gtk/bmpcbox.h"
f696015c
VZ
119#else
120 #include "wx/generic/bmpcbox.h"
121#endif
95a46303
RR
122
123#endif // wxUSE_BITMAPCOMBOBOX
124
8d37334f 125#endif // _WX_BMPCBOX_H_BASE_