]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/combobox.h
wxMGL revitalised with OpenWatcom.
[wxWidgets.git] / include / wx / msw / combobox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/combobox.h
3 // Purpose: wxComboBox class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_COMBOBOX_H_
13 #define _WX_COMBOBOX_H_
14
15 #include "wx/choice.h"
16
17 #if wxUSE_COMBOBOX
18
19 // ----------------------------------------------------------------------------
20 // Combobox control
21 // ----------------------------------------------------------------------------
22
23 class WXDLLEXPORT wxComboBox: public wxChoice
24 {
25 public:
26 wxComboBox() { Init(); }
27
28 wxComboBox(wxWindow *parent, 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 Init();
38
39 Create(parent, id, value, pos, size, n, choices, style, validator, name);
40 }
41 wxComboBox(wxWindow *parent, wxWindowID id,
42 const wxString& value,
43 const wxPoint& pos,
44 const wxSize& size,
45 const wxArrayString& choices,
46 long style = 0,
47 const wxValidator& validator = wxDefaultValidator,
48 const wxString& name = wxComboBoxNameStr)
49 {
50 Init();
51
52 Create(parent, id, value, pos, size, choices, style, validator, name);
53 }
54
55 bool Create(wxWindow *parent,
56 wxWindowID id,
57 const wxString& value = wxEmptyString,
58 const wxPoint& pos = wxDefaultPosition,
59 const wxSize& size = wxDefaultSize,
60 int n = 0,
61 const wxString choices[] = NULL,
62 long style = 0,
63 const wxValidator& validator = wxDefaultValidator,
64 const wxString& name = wxComboBoxNameStr);
65 bool Create(wxWindow *parent,
66 wxWindowID id,
67 const wxString& value,
68 const wxPoint& pos,
69 const wxSize& size,
70 const wxArrayString& choices,
71 long style = 0,
72 const wxValidator& validator = wxDefaultValidator,
73 const wxString& name = wxComboBoxNameStr);
74
75 // List functions: see wxChoice
76
77 // Text field functions
78 wxString GetValue() const { return m_value; }
79 virtual void SetValue(const wxString& value);
80
81 // Clipboard operations
82 virtual void Copy();
83 virtual void Cut();
84 virtual void Paste();
85 virtual bool CanCopy() const;
86 virtual bool CanCut() const;
87 virtual bool CanPaste() const;
88 virtual void SetInsertionPoint(long pos);
89 virtual void SetInsertionPointEnd();
90 virtual long GetInsertionPoint() const;
91 virtual wxTextPos GetLastPosition() const;
92 virtual void Replace(long from, long to, const wxString& value);
93 virtual void Remove(long from, long to);
94 virtual void SetSelection(int n) { wxChoice::SetSelection(n); }
95 virtual void SetSelection(long from, long to);
96 virtual int GetSelection() const;
97 virtual void GetSelection(long* from, long* to) const;
98 virtual void SetEditable(bool editable);
99 virtual void Clear() { wxChoice::Clear(); m_selectionOld = -1; }
100
101 virtual void Undo() ;
102 virtual void Redo() ;
103 virtual bool CanUndo() const;
104 virtual bool CanRedo() const;
105 virtual void SelectAll();
106 virtual bool IsEditable() const ;
107 virtual bool HasSelection() const;
108
109 // implementation only from now on
110 virtual bool MSWCommand(WXUINT param, WXWORD id);
111 bool MSWProcessEditMsg(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam);
112 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
113
114 WXHWND GetEditHWND() const;
115
116 // Standard event handling
117 void OnCut(wxCommandEvent& event);
118 void OnCopy(wxCommandEvent& event);
119 void OnPaste(wxCommandEvent& event);
120 void OnUndo(wxCommandEvent& event);
121 void OnRedo(wxCommandEvent& event);
122 void OnDelete(wxCommandEvent& event);
123 void OnSelectAll(wxCommandEvent& event);
124
125 void OnUpdateCut(wxUpdateUIEvent& event);
126 void OnUpdateCopy(wxUpdateUIEvent& event);
127 void OnUpdatePaste(wxUpdateUIEvent& event);
128 void OnUpdateUndo(wxUpdateUIEvent& event);
129 void OnUpdateRedo(wxUpdateUIEvent& event);
130 void OnUpdateDelete(wxUpdateUIEvent& event);
131 void OnUpdateSelectAll(wxUpdateUIEvent& event);
132
133 protected:
134 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
135
136 // common part of all ctors
137 void Init() { m_selectionOld = -1; }
138
139
140 // the previous selection (see MSWCommand() to see why it is needed)
141 int m_selectionOld;
142
143 // the current selection (also see MSWCommand())
144 wxString m_value;
145
146 private:
147 DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox)
148 DECLARE_EVENT_TABLE()
149 };
150
151 #endif // wxUSE_COMBOBOX
152 #endif
153 // _WX_COMBOBOX_H_