]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/combobox.h
Disconnect "hide" menu signal to fix menu destruction in wxGTK.
[wxWidgets.git] / include / wx / msw / combobox.h
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
f6bcfd97 2// Name: wx/msw/combobox.h
2bda0e17
KB
3// Purpose: wxComboBox class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
bbcdf8bc 8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_COMBOBOX_H_
13#define _WX_COMBOBOX_H_
2bda0e17 14
2bda0e17 15#include "wx/choice.h"
74f35eea 16#include "wx/textentry.h"
2bda0e17 17
47d67540 18#if wxUSE_COMBOBOX
2bda0e17 19
4438caf4
VZ
20// ----------------------------------------------------------------------------
21// Combobox control
22// ----------------------------------------------------------------------------
23
53a2db12 24class WXDLLIMPEXP_CORE wxComboBox : public wxChoice,
b7bfef38 25 public wxTextEntry
2bda0e17 26{
4438caf4 27public:
b7bfef38 28 wxComboBox() { Init(); }
4438caf4
VZ
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,
6463b9f5
JS
37 const wxString& name = wxComboBoxNameStr)
38 {
b7bfef38 39 Init();
6463b9f5 40 Create(parent, id, value, pos, size, n, choices, style, validator, name);
b7bfef38 41
6463b9f5 42 }
b7bfef38 43
584ad2a3
MB
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 {
b7bfef38
VZ
53 Init();
54
584ad2a3
MB
55 Create(parent, id, value, pos, size, choices, style, validator, name);
56 }
4438caf4 57
f6bcfd97
BP
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);
584ad2a3
MB
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);
4438caf4 77
74f35eea
VZ
78 // resolve ambiguities among virtual functions inherited from both base
79 // classes
e6a84162 80 virtual void Clear();
e9717bd5 81 virtual wxString GetValue() const;
4438caf4 82 virtual void SetValue(const wxString& value);
74f35eea
VZ
83 virtual wxString GetStringSelection() const
84 { return wxChoice::GetStringSelection(); }
d1d1f817
VZ
85 virtual void Popup() { MSWDoPopupOrDismiss(true); }
86 virtual void Dismiss() { MSWDoPopupOrDismiss(false); }
7d90194c 87 virtual void SetSelection(int n) { wxChoice::SetSelection(n); }
74f35eea
VZ
88 virtual void SetSelection(long from, long to)
89 { wxTextEntry::SetSelection(from, to); }
7d90194c 90 virtual int GetSelection() const { return wxChoice::GetSelection(); }
e9717bd5 91 virtual void GetSelection(long *from, long *to) const;
74f35eea 92
7d90194c 93 virtual bool IsEditable() const;
150e31d2 94
f6bcfd97 95 // implementation only from now on
4438caf4 96 virtual bool MSWCommand(WXUINT param, WXWORD id);
f6bcfd97 97 bool MSWProcessEditMsg(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam);
c140b7e7 98 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
90ac8b50 99 bool MSWShouldPreProcessMessage(WXMSG *pMsg);
fc7a2a60 100
150e31d2
JS
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);
109
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);
117
71e57cd6
VZ
118 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
119
63f7d502
VZ
120#if wxUSE_UXTHEME
121 // override wxTextEntry method to work around Windows bug
122 virtual bool SetHint(const wxString& hint);
123#endif // wxUSE_UXTHEME
124
3c75d8ba 125protected:
d6b9cc87
VZ
126#if wxUSE_TOOLTIPS
127 virtual void DoSetToolTip(wxToolTip *tip);
128#endif
d1d1f817 129 void MSWDoPopupOrDismiss(bool show);
d6b9cc87 130
e9717bd5
VZ
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
133 //
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;
139
b7bfef38
VZ
140 virtual void EnableTextChangedEvents(bool enable)
141 {
142 m_allowTextEvents = enable;
143 }
144
fc7a2a60 145private:
63f7d502
VZ
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();
3c75d8ba
PC
149 virtual WXHWND GetEditHWND() const;
150
b7bfef38
VZ
151 // common part of all ctors
152 void Init()
153 {
154 m_allowTextEvents = true;
155 }
156
157 // normally true, false if text events are currently disabled
158 bool m_allowTextEvents;
159
fc7a2a60 160 DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox)
150e31d2 161 DECLARE_EVENT_TABLE()
2bda0e17
KB
162};
163
47d67540 164#endif // wxUSE_COMBOBOX
74f35eea
VZ
165
166#endif // _WX_COMBOBOX_H_