]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/combobox.h
added unit test for some of wxTextCtrl methods and its events generation
[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
c801d85f
KB
14//-----------------------------------------------------------------------------
15// wxComboBox
16//-----------------------------------------------------------------------------
17
20123d49 18class WXDLLIMPEXP_CORE wxComboBox : public wxControl, public wxComboBoxBase
7f4dc78d 19{
fd0eed64 20public:
a236aa20 21 inline wxComboBox() { m_strings = NULL; }
738f9e5a 22 inline wxComboBox(wxWindow *parent, wxWindowID id,
7f4dc78d
RR
23 const wxString& value = wxEmptyString,
24 const wxPoint& pos = wxDefaultPosition,
25 const wxSize& size = wxDefaultSize,
c67daf87 26 int n = 0, const wxString choices[] = (const wxString *) NULL,
debe6624 27 long style = 0,
6de97a3b 28 const wxValidator& validator = wxDefaultValidator,
7f4dc78d 29 const wxString& name = wxComboBoxNameStr)
738f9e5a
RR
30 {
31 Create(parent, id, value, pos, size, n, choices, style, validator, name);
32 }
584ad2a3
MB
33 inline wxComboBox(wxWindow *parent, wxWindowID id,
34 const wxString& value,
35 const wxPoint& pos,
36 const wxSize& size,
37 const wxArrayString& choices,
38 long style = 0,
39 const wxValidator& validator = wxDefaultValidator,
40 const wxString& name = wxComboBoxNameStr)
41 {
42 Create(parent, id, value, pos, size, choices, style, validator, name);
43 }
6f6f938f 44
d3c7fc99 45 virtual ~wxComboBox();
6f6f938f 46
738f9e5a 47 bool Create(wxWindow *parent, wxWindowID id,
7f4dc78d
RR
48 const wxString& value = wxEmptyString,
49 const wxPoint& pos = wxDefaultPosition,
50 const wxSize& size = wxDefaultSize,
c67daf87 51 int n = 0, const wxString choices[] = (const wxString *) NULL,
debe6624 52 long style = 0,
6de97a3b 53 const wxValidator& validator = wxDefaultValidator,
7f4dc78d 54 const wxString& name = wxComboBoxNameStr);
584ad2a3
MB
55 bool Create(wxWindow *parent, wxWindowID id,
56 const wxString& value,
57 const wxPoint& pos,
58 const wxSize& size,
59 const wxArrayString& choices,
60 long style = 0,
61 const wxValidator& validator = wxDefaultValidator,
62 const wxString& name = wxComboBoxNameStr);
7f4dc78d 63
d95c5149 64 // From wxItemContainerImmutable:
aa61d352 65 virtual unsigned int GetCount() const;
d95c5149 66 virtual wxString GetString(unsigned int n) const;
aa61d352 67 virtual void SetString(unsigned int n, const wxString &text);
d95c5149
MR
68 virtual int FindString(const wxString& s, bool bCase = false) const;
69 virtual void SetSelection(int n);
70 virtual int GetSelection() const;
71 wxString GetStringSelection() const; // not a virtual in parent class
72
73 // From wxItemContainer:
a236aa20
VZ
74 virtual void DoClear();
75 virtual void DoDeleteOneItem(unsigned int n);
d95c5149
MR
76
77 // From wxBomboBoxBase:
78 virtual wxString GetValue() const;
79 virtual void SetValue(const wxString& value);
80 virtual void Copy();
81 virtual void Cut();
82 virtual void Paste();
83 virtual void SetInsertionPoint( long pos );
84 virtual long GetInsertionPoint() const;
7d8268a1 85 virtual wxTextPos GetLastPosition() const;
d95c5149
MR
86 virtual void Replace( long from, long to, const wxString& value );
87 virtual void SetSelection( long from, long to );
88 virtual void SetEditable( bool editable );
89 virtual void SetInsertionPointEnd() { SetInsertionPoint( -1 ); }
90 virtual void Remove(long from, long to) { Replace(from, to, wxEmptyString); }
91 virtual bool IsEditable() const;
92 virtual void Undo();
93 virtual void Redo();
94 virtual void SelectAll();
95 virtual bool CanCopy() const;
96 virtual bool CanCut() const;
97 virtual bool CanPaste() const;
98 virtual bool CanUndo() const;
99 virtual bool CanRedo() const;
30ed6e5c 100
738f9e5a 101 // implementation
d95c5149
MR
102 bool HasSelection() const;
103 void GetSelection( long* from, long* to ) const;
104 int GetCurrentSelection() const;
30ed6e5c 105
2b5f62a0 106 virtual void SetFocus();
30ed6e5c 107
738f9e5a
RR
108 void OnSize( wxSizeEvent &event );
109 void OnChar( wxKeyEvent &event );
30ed6e5c 110
150e31d2
JS
111 // Standard event handling
112 void OnCut(wxCommandEvent& event);
113 void OnCopy(wxCommandEvent& event);
114 void OnPaste(wxCommandEvent& event);
115 void OnUndo(wxCommandEvent& event);
116 void OnRedo(wxCommandEvent& event);
117 void OnDelete(wxCommandEvent& event);
118 void OnSelectAll(wxCommandEvent& event);
119
120 void OnUpdateCut(wxUpdateUIEvent& event);
121 void OnUpdateCopy(wxUpdateUIEvent& event);
122 void OnUpdatePaste(wxUpdateUIEvent& event);
123 void OnUpdateUndo(wxUpdateUIEvent& event);
124 void OnUpdateRedo(wxUpdateUIEvent& event);
125 void OnUpdateDelete(wxUpdateUIEvent& event);
126 void OnUpdateSelectAll(wxUpdateUIEvent& event);
127
a236aa20
VZ
128 bool m_ignoreNextUpdate:1;
129 wxArrayPtrVoid m_clientData;
130 int m_prevSelection;
738f9e5a
RR
131
132 void DisableEvents();
133 void EnableEvents();
738f9e5a 134 GtkWidget* GetConnectWidget();
30ed6e5c 135
6f6f938f
VZ
136 wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
137
9d522606
RD
138 static wxVisualAttributes
139 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
150e31d2 140
f68586e5 141protected:
d95c5149 142 // From wxWindowGTK:
ef5c70f9
VZ
143 virtual void DoApplyWidgetStyle(GtkRcStyle *style);
144 virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
d95c5149
MR
145
146 // From wxItemContainer:
a236aa20
VZ
147 virtual int DoInsertItems(const wxArrayStringsAdapter& items,
148 unsigned int pos,
149 void **clientData, wxClientDataType type);
aa61d352
VZ
150 virtual void DoSetItemClientData(unsigned int n, void* clientData);
151 virtual void* DoGetItemClientData(unsigned int n) const;
a236aa20 152 virtual bool IsSorted() const { return HasFlag(wxCB_SORT); }
6f6f938f 153
d95c5149 154 // From wxControl:
f68586e5
VZ
155 virtual wxSize DoGetBestSize() const;
156
9d522606
RD
157 // Widgets that use the style->base colour for the BG colour should
158 // override this and return true.
159 virtual bool UseGTKStyleBase() const { return true; }
160
30ed6e5c 161private:
a236aa20
VZ
162 // this array is only used for controls with wxCB_SORT style, so only
163 // allocate it if it's needed (hence using pointer)
164 wxSortedArrayString *m_strings;
165
6f6f938f 166 DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox)
738f9e5a 167 DECLARE_EVENT_TABLE()
7f4dc78d
RR
168};
169
0416c418 170#endif // _WX_GTK_COMBOBOX_H_