]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/combobox.h
wxTextCtrk::GetRange() shouldn't crash on out of range request
[wxWidgets.git] / include / wx / gtk / combobox.h
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 #include "wx/choice.h"
15
16 typedef struct _GtkEntry GtkEntry;
17
18 //-----------------------------------------------------------------------------
19 // wxComboBox
20 //-----------------------------------------------------------------------------
21
22 class WXDLLIMPEXP_CORE wxComboBox : public wxChoice,
23 public wxTextEntry
24 {
25 public:
26 wxComboBox() { m_strings = NULL; }
27 wxComboBox(wxWindow *parent,
28 wxWindowID id,
29 const wxString& value = wxEmptyString,
30 const wxPoint& pos = wxDefaultPosition,
31 const wxSize& size = wxDefaultSize,
32 int n = 0, const wxString choices[] = NULL,
33 long style = 0,
34 const wxValidator& validator = wxDefaultValidator,
35 const wxString& name = wxComboBoxNameStr)
36 {
37 Create(parent, id, value, pos, size, n, choices, style, validator, name);
38 }
39
40 wxComboBox(wxWindow *parent, wxWindowID id,
41 const wxString& value,
42 const wxPoint& pos,
43 const wxSize& size,
44 const wxArrayString& choices,
45 long style = 0,
46 const wxValidator& validator = wxDefaultValidator,
47 const wxString& name = wxComboBoxNameStr)
48 {
49 Create(parent, id, value, pos, size, choices, style, validator, name);
50 }
51
52 bool Create(wxWindow *parent, wxWindowID id,
53 const wxString& value = wxEmptyString,
54 const wxPoint& pos = wxDefaultPosition,
55 const wxSize& size = wxDefaultSize,
56 int n = 0, const wxString choices[] = (const wxString *) NULL,
57 long style = 0,
58 const wxValidator& validator = wxDefaultValidator,
59 const wxString& name = wxComboBoxNameStr);
60 bool Create(wxWindow *parent, wxWindowID id,
61 const wxString& value,
62 const wxPoint& pos,
63 const wxSize& size,
64 const wxArrayString& choices,
65 long style = 0,
66 const wxValidator& validator = wxDefaultValidator,
67 const wxString& name = wxComboBoxNameStr);
68
69 // Set/GetSelection() from wxTextEntry and wxChoice
70
71 virtual void SetSelection(int n) { wxChoice::SetSelection(n); }
72 virtual void SetSelection(long from, long to)
73 { wxTextEntry::SetSelection(from, to); }
74
75 virtual int GetSelection() const { return wxChoice::GetSelection(); }
76 virtual void GetSelection(long *from, long *to) const
77 { return wxTextEntry::GetSelection(from, to); }
78
79 virtual wxString GetStringSelection() const
80 {
81 return wxItemContainer::GetStringSelection();
82 }
83
84 virtual void Clear()
85 {
86 wxTextEntry::Clear();
87 wxItemContainer::Clear();
88 }
89
90 bool IsEmpty() const { return wxItemContainer::IsEmpty(); }
91
92 void OnChar( wxKeyEvent &event );
93
94 // Standard event handling
95 void OnCut(wxCommandEvent& event);
96 void OnCopy(wxCommandEvent& event);
97 void OnPaste(wxCommandEvent& event);
98 void OnUndo(wxCommandEvent& event);
99 void OnRedo(wxCommandEvent& event);
100 void OnDelete(wxCommandEvent& event);
101 void OnSelectAll(wxCommandEvent& event);
102
103 void OnUpdateCut(wxUpdateUIEvent& event);
104 void OnUpdateCopy(wxUpdateUIEvent& event);
105 void OnUpdatePaste(wxUpdateUIEvent& event);
106 void OnUpdateUndo(wxUpdateUIEvent& event);
107 void OnUpdateRedo(wxUpdateUIEvent& event);
108 void OnUpdateDelete(wxUpdateUIEvent& event);
109 void OnUpdateSelectAll(wxUpdateUIEvent& event);
110
111 virtual void DisableEvents();
112 virtual void EnableEvents();
113 GtkWidget* GetConnectWidget();
114
115 static wxVisualAttributes
116 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
117
118 protected:
119 // From wxWindowGTK:
120 virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
121
122 // Widgets that use the style->base colour for the BG colour should
123 // override this and return true.
124 virtual bool UseGTKStyleBase() const { return true; }
125
126 // return the GtkEntry part of the combobox
127 GtkEntry *GetEntry() const;
128
129 private:
130 // From wxTextEntry:
131 virtual const wxWindow *GetEditableWindow() const { return this; }
132 virtual GtkEditable *GetEditable() const;
133 virtual void EnableTextChangedEvents(bool enable)
134 {
135 if ( enable )
136 EnableEvents();
137 else
138 DisableEvents();
139 }
140
141 DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox)
142 DECLARE_EVENT_TABLE()
143 };
144
145 #endif // _WX_GTK_COMBOBOX_H_