1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/combobox.h
3 // Purpose: wxComboBox class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_COMBOBOX_H_
13 #define _WX_COMBOBOX_H_
15 #include "wx/choice.h"
16 #include "wx/textentry.h"
20 // ----------------------------------------------------------------------------
22 // ----------------------------------------------------------------------------
24 class WXDLLIMPEXP_CORE wxComboBox
: public wxChoice
,
28 wxComboBox() { Init(); }
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
,
36 const wxValidator
& validator
= wxDefaultValidator
,
37 const wxString
& name
= wxComboBoxNameStr
)
40 Create(parent
, id
, value
, pos
, size
, n
, choices
, style
, validator
, name
);
44 wxComboBox(wxWindow
*parent
, wxWindowID id
,
45 const wxString
& value
,
48 const wxArrayString
& choices
,
50 const wxValidator
& validator
= wxDefaultValidator
,
51 const wxString
& name
= wxComboBoxNameStr
)
55 Create(parent
, id
, value
, pos
, size
, choices
, style
, validator
, name
);
58 bool Create(wxWindow
*parent
,
60 const wxString
& value
= wxEmptyString
,
61 const wxPoint
& pos
= wxDefaultPosition
,
62 const wxSize
& size
= wxDefaultSize
,
64 const wxString choices
[] = NULL
,
66 const wxValidator
& validator
= wxDefaultValidator
,
67 const wxString
& name
= wxComboBoxNameStr
);
68 bool Create(wxWindow
*parent
,
70 const wxString
& value
,
73 const wxArrayString
& choices
,
75 const wxValidator
& validator
= wxDefaultValidator
,
76 const wxString
& name
= wxComboBoxNameStr
);
78 // resolve ambiguities among virtual functions inherited from both base
81 virtual wxString
GetValue() const;
82 virtual void SetValue(const wxString
& value
);
83 virtual wxString
GetStringSelection() const
84 { return wxChoice::GetStringSelection(); }
85 virtual void Popup() { MSWDoPopupOrDismiss(true); }
86 virtual void Dismiss() { MSWDoPopupOrDismiss(false); }
87 virtual void SetSelection(int n
) { wxChoice::SetSelection(n
); }
88 virtual void SetSelection(long from
, long to
)
89 { wxTextEntry::SetSelection(from
, to
); }
90 virtual int GetSelection() const { return wxChoice::GetSelection(); }
91 virtual void GetSelection(long *from
, long *to
) const;
93 virtual bool IsEditable() const;
95 // implementation only from now on
96 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
97 bool MSWProcessEditMsg(WXUINT msg
, WXWPARAM wParam
, WXLPARAM lParam
);
98 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
99 bool MSWShouldPreProcessMessage(WXMSG
*pMsg
);
101 // Standard event handling
102 void OnCut(wxCommandEvent
& event
);
103 void OnCopy(wxCommandEvent
& event
);
104 void OnPaste(wxCommandEvent
& event
);
105 void OnUndo(wxCommandEvent
& event
);
106 void OnRedo(wxCommandEvent
& event
);
107 void OnDelete(wxCommandEvent
& event
);
108 void OnSelectAll(wxCommandEvent
& event
);
110 void OnUpdateCut(wxUpdateUIEvent
& event
);
111 void OnUpdateCopy(wxUpdateUIEvent
& event
);
112 void OnUpdatePaste(wxUpdateUIEvent
& event
);
113 void OnUpdateUndo(wxUpdateUIEvent
& event
);
114 void OnUpdateRedo(wxUpdateUIEvent
& event
);
115 void OnUpdateDelete(wxUpdateUIEvent
& event
);
116 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
118 virtual WXDWORD
MSWGetStyle(long style
, WXDWORD
*exstyle
) const;
121 // override wxTextEntry method to work around Windows bug
122 virtual bool SetHint(const wxString
& hint
);
123 #endif // wxUSE_UXTHEME
127 virtual void DoSetToolTip(wxToolTip
*tip
);
129 void MSWDoPopupOrDismiss(bool show
);
131 // this is the implementation of GetEditHWND() which can also be used when
132 // we don't have the edit control, it simply returns NULL then
134 // try not to use this function unless absolutely necessary (as in the
135 // message handling code where the edit control might not be created yet
136 // for the messages we receive during the control creation) as normally
137 // just testing for IsEditable() and using GetEditHWND() should be enough
138 WXHWND
GetEditHWNDIfAvailable() const;
140 virtual void EnableTextChangedEvents(bool enable
)
142 m_allowTextEvents
= enable
;
146 // there are the overridden wxTextEntry methods which should only be called
147 // when we do have an edit control so they assert if this is not the case
148 virtual wxWindow
*GetEditableWindow();
149 virtual WXHWND
GetEditHWND() const;
151 // common part of all ctors
154 m_allowTextEvents
= true;
157 // normally true, false if text events are currently disabled
158 bool m_allowTextEvents
;
160 DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox
)
161 DECLARE_EVENT_TABLE()
164 #endif // wxUSE_COMBOBOX
166 #endif // _WX_COMBOBOX_H_