]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk1/combobox.h
Fix build with Sun CC under Linux.
[wxWidgets.git] / include / wx / gtk1 / combobox.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
8ef94bfc 2// Name: wx/gtk1/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
c801d85f
KB
11#ifndef __GTKCOMBOBOXH__
12#define __GTKCOMBOBOXH__
13
c801d85f 14#include "wx/defs.h"
ac57418f 15
dcf924a3
RR
16#if wxUSE_COMBOBOX
17
c801d85f 18#include "wx/object.h"
c801d85f
KB
19
20//-----------------------------------------------------------------------------
21// classes
22//-----------------------------------------------------------------------------
23
b5dbe15d 24class WXDLLIMPEXP_FWD_CORE wxComboBox;
c801d85f 25
7f4dc78d
RR
26//-----------------------------------------------------------------------------
27// global data
28//-----------------------------------------------------------------------------
29
53a2db12 30extern WXDLLIMPEXP_DATA_CORE(const char) wxComboBoxNameStr[];
20123d49 31extern WXDLLIMPEXP_BASE const wxChar* wxEmptyString;
7f4dc78d 32
c801d85f
KB
33//-----------------------------------------------------------------------------
34// wxComboBox
35//-----------------------------------------------------------------------------
36
bf8f1022
VZ
37class WXDLLIMPEXP_CORE wxComboBox :
38 public wxWindowWithItems<wxControl, wxComboBoxBase>
7f4dc78d 39{
fd0eed64 40public:
738f9e5a
RR
41 inline wxComboBox() {}
42 inline wxComboBox(wxWindow *parent, wxWindowID id,
7f4dc78d
RR
43 const wxString& value = wxEmptyString,
44 const wxPoint& pos = wxDefaultPosition,
45 const wxSize& size = wxDefaultSize,
c67daf87 46 int n = 0, const wxString choices[] = (const wxString *) NULL,
debe6624 47 long style = 0,
6de97a3b 48 const wxValidator& validator = wxDefaultValidator,
7f4dc78d 49 const wxString& name = wxComboBoxNameStr)
738f9e5a
RR
50 {
51 Create(parent, id, value, pos, size, n, choices, style, validator, name);
52 }
584ad2a3
MB
53 inline wxComboBox(wxWindow *parent, wxWindowID id,
54 const wxString& value,
55 const wxPoint& pos,
56 const wxSize& size,
57 const wxArrayString& choices,
58 long style = 0,
59 const wxValidator& validator = wxDefaultValidator,
60 const wxString& name = wxComboBoxNameStr)
61 {
62 Create(parent, id, value, pos, size, choices, style, validator, name);
63 }
6f6f938f 64
d3c7fc99 65 virtual ~wxComboBox();
6f6f938f 66
738f9e5a 67 bool Create(wxWindow *parent, wxWindowID id,
7f4dc78d
RR
68 const wxString& value = wxEmptyString,
69 const wxPoint& pos = wxDefaultPosition,
70 const wxSize& size = wxDefaultSize,
c67daf87 71 int n = 0, const wxString choices[] = (const wxString *) NULL,
debe6624 72 long style = 0,
6de97a3b 73 const wxValidator& validator = wxDefaultValidator,
7f4dc78d 74 const wxString& name = wxComboBoxNameStr);
584ad2a3
MB
75 bool Create(wxWindow *parent, wxWindowID id,
76 const wxString& value,
77 const wxPoint& pos,
78 const wxSize& size,
79 const wxArrayString& choices,
80 long style = 0,
81 const wxValidator& validator = wxDefaultValidator,
82 const wxString& name = wxComboBoxNameStr);
7f4dc78d 83
a236aa20
VZ
84 void DoClear();
85 void DoDeleteOneItem(unsigned int n);
30ed6e5c 86
853dcc57 87 virtual int FindString(const wxString& s, bool bCase = false) const;
738f9e5a 88 int GetSelection() const;
40eb3606 89 int GetCurrentSelection() const;
aa61d352 90 virtual wxString GetString(unsigned int n) const;
738f9e5a 91 wxString GetStringSelection() const;
aa61d352
VZ
92 virtual unsigned int GetCount() const;
93 virtual void SetSelection(int n);
94 virtual void SetString(unsigned int n, const wxString &text);
738f9e5a 95
55410bb4 96 wxString GetValue() const { return DoGetValue(); }
738f9e5a 97 void SetValue(const wxString& value);
c282ec44 98 void WriteText(const wxString& value);
738f9e5a
RR
99
100 void Copy();
101 void Cut();
102 void Paste();
150e31d2
JS
103 bool CanCopy() const;
104 bool CanCut() const;
105 bool CanPaste() const;
738f9e5a 106 void SetInsertionPoint( long pos );
6f6f938f 107 void SetInsertionPointEnd() { SetInsertionPoint( -1 ); }
738f9e5a 108 long GetInsertionPoint() const;
7d8268a1 109 virtual wxTextPos GetLastPosition() const;
6f6f938f 110 void Remove(long from, long to) { Replace(from, to, wxEmptyString); }
738f9e5a 111 void Replace( long from, long to, const wxString& value );
738f9e5a 112 void SetSelection( long from, long to );
150e31d2 113 void GetSelection( long* from, long* to ) const;
738f9e5a 114 void SetEditable( bool editable );
150e31d2
JS
115 void Undo() ;
116 void Redo() ;
117 bool CanUndo() const;
118 bool CanRedo() const;
119 void SelectAll();
4e324a3f 120 bool IsEditable() const ;
150e31d2 121 bool HasSelection() const ;
30ed6e5c 122
738f9e5a 123 // implementation
30ed6e5c 124
2b5f62a0 125 virtual void SetFocus();
30ed6e5c 126
738f9e5a
RR
127 void OnSize( wxSizeEvent &event );
128 void OnChar( wxKeyEvent &event );
30ed6e5c 129
150e31d2
JS
130 // Standard event handling
131 void OnCut(wxCommandEvent& event);
132 void OnCopy(wxCommandEvent& event);
133 void OnPaste(wxCommandEvent& event);
134 void OnUndo(wxCommandEvent& event);
135 void OnRedo(wxCommandEvent& event);
136 void OnDelete(wxCommandEvent& event);
137 void OnSelectAll(wxCommandEvent& event);
138
139 void OnUpdateCut(wxUpdateUIEvent& event);
140 void OnUpdateCopy(wxUpdateUIEvent& event);
141 void OnUpdatePaste(wxUpdateUIEvent& event);
142 void OnUpdateUndo(wxUpdateUIEvent& event);
143 void OnUpdateRedo(wxUpdateUIEvent& event);
144 void OnUpdateDelete(wxUpdateUIEvent& event);
145 void OnUpdateSelectAll(wxUpdateUIEvent& event);
146
78b3b018 147 bool m_ignoreNextUpdate:1;
738f9e5a
RR
148 wxList m_clientDataList;
149 wxList m_clientObjectList;
159b66c0 150 int m_prevSelection;
738f9e5a
RR
151
152 void DisableEvents();
153 void EnableEvents();
738f9e5a
RR
154 GtkWidget* GetConnectWidget();
155 bool IsOwnGtkWindow( GdkWindow *window );
f40fdaa3 156 void DoApplyWidgetStyle(GtkRcStyle *style);
30ed6e5c 157
9d522606
RD
158 static wxVisualAttributes
159 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
150e31d2 160
f68586e5 161protected:
a236aa20
VZ
162 virtual int DoInsertItems(const wxArrayStringsAdapter& items,
163 unsigned int pos,
164 void **clientData, wxClientDataType type);
6f6f938f 165
aa61d352
VZ
166 virtual void DoSetItemClientData(unsigned int n, void* clientData);
167 virtual void* DoGetItemClientData(unsigned int n) const;
6f6f938f 168
f68586e5
VZ
169 virtual wxSize DoGetBestSize() const;
170
55410bb4
VZ
171 // implement wxTextEntry pure virtual methods
172 virtual wxString DoGetValue() const;
63f7d502
VZ
173 virtual wxWindow *GetEditableWindow() { return this; }
174
9d522606
RD
175 // Widgets that use the style->base colour for the BG colour should
176 // override this and return true.
177 virtual bool UseGTKStyleBase() const { return true; }
178
30ed6e5c 179private:
6f6f938f 180 DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox)
738f9e5a 181 DECLARE_EVENT_TABLE()
7f4dc78d
RR
182};
183
dcf924a3
RR
184#endif
185
ac57418f
RR
186#endif
187
188 // __GTKCOMBOBOXH__