]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/combobox.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[wxWidgets.git] / include / wx / msw / combobox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/combobox.h
3 // Purpose: wxComboBox class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_COMBOBOX_H_
12 #define _WX_COMBOBOX_H_
13
14 #include "wx/choice.h"
15 #include "wx/textentry.h"
16
17 #if wxUSE_COMBOBOX
18
19 // ----------------------------------------------------------------------------
20 // Combobox control
21 // ----------------------------------------------------------------------------
22
23 class WXDLLIMPEXP_CORE wxComboBox : public wxChoice,
24 public wxTextEntry
25 {
26 public:
27 wxComboBox() { Init(); }
28
29 wxComboBox(wxWindow *parent, wxWindowID id,
30 const wxString& value = wxEmptyString,
31 const wxPoint& pos = wxDefaultPosition,
32 const wxSize& size = wxDefaultSize,
33 int n = 0, const wxString choices[] = NULL,
34 long style = 0,
35 const wxValidator& validator = wxDefaultValidator,
36 const wxString& name = wxComboBoxNameStr)
37 {
38 Init();
39 Create(parent, id, value, pos, size, n, choices, style, validator, name);
40
41 }
42
43 wxComboBox(wxWindow *parent, wxWindowID id,
44 const wxString& value,
45 const wxPoint& pos,
46 const wxSize& size,
47 const wxArrayString& choices,
48 long style = 0,
49 const wxValidator& validator = wxDefaultValidator,
50 const wxString& name = wxComboBoxNameStr)
51 {
52 Init();
53
54 Create(parent, id, value, pos, size, choices, style, validator, name);
55 }
56
57 bool Create(wxWindow *parent,
58 wxWindowID id,
59 const wxString& value = wxEmptyString,
60 const wxPoint& pos = wxDefaultPosition,
61 const wxSize& size = wxDefaultSize,
62 int n = 0,
63 const wxString choices[] = NULL,
64 long style = 0,
65 const wxValidator& validator = wxDefaultValidator,
66 const wxString& name = wxComboBoxNameStr);
67 bool Create(wxWindow *parent,
68 wxWindowID id,
69 const wxString& value,
70 const wxPoint& pos,
71 const wxSize& size,
72 const wxArrayString& choices,
73 long style = 0,
74 const wxValidator& validator = wxDefaultValidator,
75 const wxString& name = wxComboBoxNameStr);
76
77 // See wxComboBoxBase discussion of IsEmpty().
78 bool IsListEmpty() const { return wxItemContainer::IsEmpty(); }
79 bool IsTextEmpty() const { return wxTextEntry::IsEmpty(); }
80
81 // resolve ambiguities among virtual functions inherited from both base
82 // classes
83 virtual void Clear();
84 virtual wxString GetValue() const;
85 virtual void SetValue(const wxString& value);
86 virtual wxString GetStringSelection() const
87 { return wxChoice::GetStringSelection(); }
88 virtual void Popup() { MSWDoPopupOrDismiss(true); }
89 virtual void Dismiss() { MSWDoPopupOrDismiss(false); }
90 virtual void SetSelection(int n) { wxChoice::SetSelection(n); }
91 virtual void SetSelection(long from, long to)
92 { wxTextEntry::SetSelection(from, to); }
93 virtual int GetSelection() const { return wxChoice::GetSelection(); }
94 virtual bool ContainsHWND(WXHWND hWnd) const;
95 virtual void GetSelection(long *from, long *to) const;
96
97 virtual bool IsEditable() const;
98
99 // implementation only from now on
100 virtual bool MSWCommand(WXUINT param, WXWORD id);
101 bool MSWProcessEditMsg(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam);
102 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
103 bool MSWShouldPreProcessMessage(WXMSG *pMsg);
104
105 // Standard event handling
106 void OnCut(wxCommandEvent& event);
107 void OnCopy(wxCommandEvent& event);
108 void OnPaste(wxCommandEvent& event);
109 void OnUndo(wxCommandEvent& event);
110 void OnRedo(wxCommandEvent& event);
111 void OnDelete(wxCommandEvent& event);
112 void OnSelectAll(wxCommandEvent& event);
113
114 void OnUpdateCut(wxUpdateUIEvent& event);
115 void OnUpdateCopy(wxUpdateUIEvent& event);
116 void OnUpdatePaste(wxUpdateUIEvent& event);
117 void OnUpdateUndo(wxUpdateUIEvent& event);
118 void OnUpdateRedo(wxUpdateUIEvent& event);
119 void OnUpdateDelete(wxUpdateUIEvent& event);
120 void OnUpdateSelectAll(wxUpdateUIEvent& event);
121
122 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
123
124 #if wxUSE_UXTHEME
125 // override wxTextEntry method to work around Windows bug
126 virtual bool SetHint(const wxString& hint);
127 #endif // wxUSE_UXTHEME
128
129 protected:
130 #if wxUSE_TOOLTIPS
131 virtual void DoSetToolTip(wxToolTip *tip);
132 #endif
133
134 virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const;
135
136 // this is the implementation of GetEditHWND() which can also be used when
137 // we don't have the edit control, it simply returns NULL then
138 //
139 // try not to use this function unless absolutely necessary (as in the
140 // message handling code where the edit control might not be created yet
141 // for the messages we receive during the control creation) as normally
142 // just testing for IsEditable() and using GetEditHWND() should be enough
143 WXHWND GetEditHWNDIfAvailable() const;
144
145 virtual void EnableTextChangedEvents(bool enable)
146 {
147 m_allowTextEvents = enable;
148 }
149
150 private:
151 // there are the overridden wxTextEntry methods which should only be called
152 // when we do have an edit control so they assert if this is not the case
153 virtual wxWindow *GetEditableWindow();
154 virtual WXHWND GetEditHWND() const;
155
156 // common part of all ctors
157 void Init()
158 {
159 m_allowTextEvents = true;
160 }
161
162 // normally true, false if text events are currently disabled
163 bool m_allowTextEvents;
164
165 DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox)
166 DECLARE_EVENT_TABLE()
167 };
168
169 #endif // wxUSE_COMBOBOX
170
171 #endif // _WX_COMBOBOX_H_