]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/combobox.h
Add wxComboBox::Popup() and Dismiss() to manually show or hide its popup.
[wxWidgets.git] / include / wx / gtk / combobox.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
853dcc57 2// Name: wx/gtk/combobox.h
c801d85f
KB
3// Purpose:
4// Author: Robert Roebling
5// Created: 01/02/97
5ebd1fb2 6// Id: $Id$
dbf858b5 7// Copyright: (c) 1998 Robert Roebling
7d8268a1 8// Licence: wxWindows licence
c801d85f
KB
9/////////////////////////////////////////////////////////////////////////////
10
0416c418
PC
11#ifndef _WX_GTK_COMBOBOX_H_
12#define _WX_GTK_COMBOBOX_H_
7f4dc78d 13
a2c94110
VZ
14#include "wx/choice.h"
15
ff654490
VZ
16typedef struct _GtkEntry GtkEntry;
17
c801d85f
KB
18//-----------------------------------------------------------------------------
19// wxComboBox
20//-----------------------------------------------------------------------------
21
a2c94110
VZ
22class WXDLLIMPEXP_CORE wxComboBox : public wxChoice,
23 public wxTextEntry
7f4dc78d 24{
fd0eed64 25public:
e78c1d78
RR
26 wxComboBox()
27 : wxChoice(), wxTextEntry()
28 {
29 Init();
30 }
0ec1179b
VZ
31 wxComboBox(wxWindow *parent,
32 wxWindowID id,
33 const wxString& value = wxEmptyString,
34 const wxPoint& pos = wxDefaultPosition,
35 const wxSize& size = wxDefaultSize,
36 int n = 0, const wxString choices[] = NULL,
37 long style = 0,
38 const wxValidator& validator = wxDefaultValidator,
39 const wxString& name = wxComboBoxNameStr)
e78c1d78 40 : wxChoice(), wxTextEntry()
738f9e5a 41 {
e78c1d78 42 Init();
738f9e5a
RR
43 Create(parent, id, value, pos, size, n, choices, style, validator, name);
44 }
0ec1179b
VZ
45
46 wxComboBox(wxWindow *parent, wxWindowID id,
47 const wxString& value,
48 const wxPoint& pos,
49 const wxSize& size,
50 const wxArrayString& choices,
51 long style = 0,
52 const wxValidator& validator = wxDefaultValidator,
53 const wxString& name = wxComboBoxNameStr)
e78c1d78 54 : wxChoice(), wxTextEntry()
584ad2a3 55 {
e78c1d78 56 Init();
584ad2a3
MB
57 Create(parent, id, value, pos, size, choices, style, validator, name);
58 }
6f6f938f 59
738f9e5a 60 bool Create(wxWindow *parent, wxWindowID id,
0ec1179b
VZ
61 const wxString& value = wxEmptyString,
62 const wxPoint& pos = wxDefaultPosition,
63 const wxSize& size = wxDefaultSize,
64 int n = 0, const wxString choices[] = (const wxString *) NULL,
65 long style = 0,
66 const wxValidator& validator = wxDefaultValidator,
67 const wxString& name = wxComboBoxNameStr);
584ad2a3 68 bool Create(wxWindow *parent, wxWindowID id,
0ec1179b
VZ
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);
7f4dc78d 76
a2c94110 77 // Set/GetSelection() from wxTextEntry and wxChoice
d95c5149 78
a2c94110 79 virtual void SetSelection(int n) { wxChoice::SetSelection(n); }
0ec1179b 80 virtual void SetSelection(long from, long to)
a2c94110 81 { wxTextEntry::SetSelection(from, to); }
d95c5149 82
a2c94110 83 virtual int GetSelection() const { return wxChoice::GetSelection(); }
0ec1179b 84 virtual void GetSelection(long *from, long *to) const
a2c94110 85 { return wxTextEntry::GetSelection(from, to); }
0ec1179b
VZ
86
87 virtual wxString GetStringSelection() const
88 {
89 return wxItemContainer::GetStringSelection();
90 }
d1d1f817
VZ
91 virtual void Popup();
92 virtual void Dismiss();
0ec1179b 93
a2c94110
VZ
94 virtual void Clear()
95 {
96 wxTextEntry::Clear();
97 wxItemContainer::Clear();
98 }
99
100 bool IsEmpty() const { return wxItemContainer::IsEmpty(); }
30ed6e5c 101
738f9e5a 102 void OnChar( wxKeyEvent &event );
30ed6e5c 103
150e31d2
JS
104 // Standard event handling
105 void OnCut(wxCommandEvent& event);
106 void OnCopy(wxCommandEvent& event);
107 void OnPaste(wxCommandEvent& event);
108 void OnUndo(wxCommandEvent& event);
109 void OnRedo(wxCommandEvent& event);
110 void OnDelete(wxCommandEvent& event);
111 void OnSelectAll(wxCommandEvent& event);
112
113 void OnUpdateCut(wxUpdateUIEvent& event);
114 void OnUpdateCopy(wxUpdateUIEvent& event);
115 void OnUpdatePaste(wxUpdateUIEvent& event);
116 void OnUpdateUndo(wxUpdateUIEvent& event);
117 void OnUpdateRedo(wxUpdateUIEvent& event);
118 void OnUpdateDelete(wxUpdateUIEvent& event);
119 void OnUpdateSelectAll(wxUpdateUIEvent& event);
120
a2c94110
VZ
121 virtual void DisableEvents();
122 virtual void EnableEvents();
738f9e5a 123 GtkWidget* GetConnectWidget();
30ed6e5c 124
9d522606
RD
125 static wxVisualAttributes
126 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
150e31d2 127
f68586e5 128protected:
d95c5149 129 // From wxWindowGTK:
ef5c70f9 130 virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
d95c5149 131
3c75d8ba
PC
132 // Widgets that use the style->base colour for the BG colour should
133 // override this and return true.
134 virtual bool UseGTKStyleBase() const { return true; }
135
e78c1d78
RR
136 // Override in derived classes to create combo box widgets with
137 // custom list stores.
138 virtual void GTKCreateComboBoxWidget();
139
0847e36e
JS
140 virtual GtkEntry *GetEntry() const
141 { return m_entry; }
e78c1d78
RR
142
143 GtkEntry* m_entry;
ff654490 144
3c75d8ba 145private:
0ec1179b 146 // From wxTextEntry:
63f7d502 147 virtual wxWindow *GetEditableWindow() { return this; }
0ec1179b
VZ
148 virtual GtkEditable *GetEditable() const;
149 virtual void EnableTextChangedEvents(bool enable)
150 {
151 if ( enable )
152 EnableEvents();
153 else
154 DisableEvents();
155 }
156
e78c1d78
RR
157 void Init();
158
6f6f938f 159 DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox)
738f9e5a 160 DECLARE_EVENT_TABLE()
7f4dc78d
RR
161};
162
0416c418 163#endif // _WX_GTK_COMBOBOX_H_