]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/gtk/combobox.h
another DMC build fix (http://thread.gmane.org/gmane.comp.lib.wxwidgets.devel/93155)
[wxWidgets.git] / include / wx / gtk / combobox.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/gtk/combobox.h
3// Purpose:
4// Author: Robert Roebling
5// Created: 01/02/97
6// Id: $Id$
7// Copyright: (c) 1998 Robert Roebling
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_GTK_COMBOBOX_H_
12#define _WX_GTK_COMBOBOX_H_
13
14//-----------------------------------------------------------------------------
15// wxComboBox
16//-----------------------------------------------------------------------------
17
18class WXDLLIMPEXP_CORE wxComboBox : public wxControl,
19 public wxComboBoxBase
20{
21public:
22 wxComboBox() { m_strings = NULL; }
23 wxComboBox(wxWindow *parent,
24 wxWindowID id,
25 const wxString& value = wxEmptyString,
26 const wxPoint& pos = wxDefaultPosition,
27 const wxSize& size = wxDefaultSize,
28 int n = 0, const wxString choices[] = NULL,
29 long style = 0,
30 const wxValidator& validator = wxDefaultValidator,
31 const wxString& name = wxComboBoxNameStr)
32 {
33 Create(parent, id, value, pos, size, n, choices, style, validator, name);
34 }
35
36 wxComboBox(wxWindow *parent, wxWindowID id,
37 const wxString& value,
38 const wxPoint& pos,
39 const wxSize& size,
40 const wxArrayString& choices,
41 long style = 0,
42 const wxValidator& validator = wxDefaultValidator,
43 const wxString& name = wxComboBoxNameStr)
44 {
45 Create(parent, id, value, pos, size, choices, style, validator, name);
46 }
47
48 virtual ~wxComboBox();
49
50 bool Create(wxWindow *parent, wxWindowID id,
51 const wxString& value = wxEmptyString,
52 const wxPoint& pos = wxDefaultPosition,
53 const wxSize& size = wxDefaultSize,
54 int n = 0, const wxString choices[] = (const wxString *) NULL,
55 long style = 0,
56 const wxValidator& validator = wxDefaultValidator,
57 const wxString& name = wxComboBoxNameStr);
58 bool Create(wxWindow *parent, wxWindowID id,
59 const wxString& value,
60 const wxPoint& pos,
61 const wxSize& size,
62 const wxArrayString& choices,
63 long style = 0,
64 const wxValidator& validator = wxDefaultValidator,
65 const wxString& name = wxComboBoxNameStr);
66
67 // From wxItemContainerImmutable:
68 virtual unsigned int GetCount() const;
69 virtual wxString GetString(unsigned int n) const;
70 virtual void SetString(unsigned int n, const wxString &text);
71 virtual int FindString(const wxString& s, bool bCase = false) const;
72 virtual void SetSelection(int n);
73 virtual int GetSelection() const;
74
75 // from wxTextEntry: we need to override them to avoid virtual function
76 // hiding
77 virtual void SetSelection(long from, long to)
78 {
79 wxTextEntry::SetSelection(from, to);
80 }
81
82 virtual void GetSelection(long *from, long *to) const
83 {
84 return wxTextEntry::GetSelection(from, to);
85 }
86
87 virtual wxString GetStringSelection() const
88 {
89 return wxItemContainer::GetStringSelection();
90 }
91
92 // From wxComboBoxBase:
93 virtual int GetCurrentSelection() const;
94
95 virtual void SetFocus();
96
97 void OnSize( wxSizeEvent &event );
98 void OnChar( wxKeyEvent &event );
99
100 // Standard event handling
101 void OnCut(wxCommandEvent& event);
102 void OnCopy(wxCommandEvent& event);
103 void OnPaste(wxCommandEvent& event);
104 void OnUndo(wxCommandEvent& event);
105 void OnRedo(wxCommandEvent& event);
106 void OnDelete(wxCommandEvent& event);
107 void OnSelectAll(wxCommandEvent& event);
108
109 void OnUpdateCut(wxUpdateUIEvent& event);
110 void OnUpdateCopy(wxUpdateUIEvent& event);
111 void OnUpdatePaste(wxUpdateUIEvent& event);
112 void OnUpdateUndo(wxUpdateUIEvent& event);
113 void OnUpdateRedo(wxUpdateUIEvent& event);
114 void OnUpdateDelete(wxUpdateUIEvent& event);
115 void OnUpdateSelectAll(wxUpdateUIEvent& event);
116
117 bool m_ignoreNextUpdate:1;
118 wxArrayPtrVoid m_clientData;
119 int m_prevSelection;
120
121 void DisableEvents();
122 void EnableEvents();
123 GtkWidget* GetConnectWidget();
124
125 wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
126
127 static wxVisualAttributes
128 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
129
130 virtual bool IsSorted() const { return HasFlag(wxCB_SORT); }
131
132protected:
133 // From wxWindowGTK:
134 virtual void DoApplyWidgetStyle(GtkRcStyle *style);
135 virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
136
137 // From wxItemContainer:
138 virtual int DoInsertItems(const wxArrayStringsAdapter& items,
139 unsigned int pos,
140 void **clientData, wxClientDataType type);
141 virtual void DoSetItemClientData(unsigned int n, void* clientData);
142 virtual void* DoGetItemClientData(unsigned int n) const;
143 virtual void DoClear();
144 virtual void DoDeleteOneItem(unsigned int n);
145
146 // From wxControl:
147 virtual wxSize DoGetBestSize() const;
148
149 // Widgets that use the style->base colour for the BG colour should
150 // override this and return true.
151 virtual bool UseGTKStyleBase() const { return true; }
152
153private:
154 // From wxTextEntry:
155 virtual const wxWindow *GetEditableWindow() const { return this; }
156 virtual GtkEditable *GetEditable() const;
157 virtual void EnableTextChangedEvents(bool enable)
158 {
159 if ( enable )
160 EnableEvents();
161 else
162 DisableEvents();
163 }
164
165 // this array is only used for controls with wxCB_SORT style, so only
166 // allocate it if it's needed (hence using pointer)
167 wxSortedArrayString *m_strings;
168
169 DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox)
170 DECLARE_EVENT_TABLE()
171};
172
173#endif // _WX_GTK_COMBOBOX_H_