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