]> git.saurik.com Git - wxWidgets.git/blob - samples/widgets/combobox.cpp
allow passing -1 range to SetScrollbar() to indicate the the scrollbar should be...
[wxWidgets.git] / samples / widgets / combobox.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Program: wxWidgets Widgets Sample
3 // Name: combobox.cpp
4 // Purpose: Part of the widgets sample showing wxComboBox
5 // Author: Vadim Zeitlin
6 // Created: 27.03.01
7 // Id: $Id$
8 // Copyright: (c) 2001 Vadim Zeitlin
9 // License: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // for compilers that support precompilation, includes "wx/wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #if wxUSE_COMBOBOX
28
29 // for all others, include the necessary headers
30 #ifndef WX_PRECOMP
31 #include "wx/log.h"
32
33 #include "wx/bitmap.h"
34 #include "wx/button.h"
35 #include "wx/checkbox.h"
36 #include "wx/combobox.h"
37 #include "wx/radiobox.h"
38 #include "wx/statbox.h"
39 #include "wx/textctrl.h"
40 #endif
41
42 #include "wx/sizer.h"
43
44 #include "itemcontainer.h"
45 #include "widgets.h"
46 #if 1
47 #include "icons/combobox.xpm"
48
49 // ----------------------------------------------------------------------------
50 // constants
51 // ----------------------------------------------------------------------------
52
53 // control ids
54 enum
55 {
56 ComboPage_Reset = wxID_HIGHEST,
57 ComboPage_SetCurrent,
58 ComboPage_CurText,
59 ComboPage_InsertionPointText,
60 ComboPage_Insert,
61 ComboPage_InsertText,
62 ComboPage_Add,
63 ComboPage_AddText,
64 ComboPage_AddSeveral,
65 ComboPage_AddMany,
66 ComboPage_Clear,
67 ComboPage_Change,
68 ComboPage_ChangeText,
69 ComboPage_Delete,
70 ComboPage_DeleteText,
71 ComboPage_DeleteSel,
72 ComboPage_SetValue,
73 ComboPage_SetValueText,
74 ComboPage_Combo,
75 ComboPage_ContainerTests
76 };
77
78 // kinds of comboboxes
79 enum
80 {
81 ComboKind_Default,
82 ComboKind_Simple,
83 ComboKind_DropDown
84 };
85
86 // ----------------------------------------------------------------------------
87 // ComboboxWidgetsPage
88 // ----------------------------------------------------------------------------
89
90 class ComboboxWidgetsPage : public ItemContainerWidgetsPage
91 {
92 public:
93 ComboboxWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
94
95 virtual wxControl *GetWidget() const { return m_combobox; }
96 virtual wxTextEntryBase *GetTextEntry() const { return m_combobox; }
97 virtual wxItemContainer* GetContainer() const { return m_combobox; }
98 virtual void RecreateWidget() { CreateCombo(); }
99
100 // lazy creation of the content
101 virtual void CreateContent();
102
103 protected:
104 // event handlers
105 void OnButtonReset(wxCommandEvent& event);
106 void OnButtonChange(wxCommandEvent& event);
107 void OnButtonDelete(wxCommandEvent& event);
108 void OnButtonDeleteSel(wxCommandEvent& event);
109 void OnButtonClear(wxCommandEvent& event);
110 void OnButtonInsert(wxCommandEvent &event);
111 void OnButtonAdd(wxCommandEvent& event);
112 void OnButtonAddSeveral(wxCommandEvent& event);
113 void OnButtonAddMany(wxCommandEvent& event);
114 void OnButtonSetValue(wxCommandEvent& event);
115 void OnButtonSetCurrent(wxCommandEvent& event);
116
117 void OnComboBox(wxCommandEvent& event);
118 void OnComboText(wxCommandEvent& event);
119
120 void OnCheckOrRadioBox(wxCommandEvent& event);
121
122 void OnUpdateUIInsertionPointText(wxUpdateUIEvent& event);
123
124 void OnUpdateUIInsert(wxUpdateUIEvent& event);
125 void OnUpdateUIAddSeveral(wxUpdateUIEvent& event);
126 void OnUpdateUIClearButton(wxUpdateUIEvent& event);
127 void OnUpdateUIDeleteButton(wxUpdateUIEvent& event);
128 void OnUpdateUIDeleteSelButton(wxUpdateUIEvent& event);
129 void OnUpdateUIResetButton(wxUpdateUIEvent& event);
130 void OnUpdateUISetCurrent(wxUpdateUIEvent& event);
131
132 // reset the combobox parameters
133 void Reset();
134
135 // (re)create the combobox
136 void CreateCombo();
137
138 // the controls
139 // ------------
140
141 // the sel mode radiobox
142 wxRadioBox *m_radioKind;
143
144 // the checkboxes for styles
145 wxCheckBox *m_chkSort,
146 *m_chkReadonly,
147 *m_chkFilename;
148
149 // the combobox itself and the sizer it is in
150 wxComboBox *m_combobox;
151 wxSizer *m_sizerCombo;
152
153 // the text entries for "Add/change string" and "Delete" buttons
154 wxTextCtrl *m_textInsert,
155 *m_textAdd,
156 *m_textChange,
157 *m_textSetValue,
158 *m_textDelete,
159 *m_textCur;
160
161 private:
162 DECLARE_EVENT_TABLE()
163 DECLARE_WIDGETS_PAGE(ComboboxWidgetsPage)
164 };
165
166 // ----------------------------------------------------------------------------
167 // event tables
168 // ----------------------------------------------------------------------------
169
170 BEGIN_EVENT_TABLE(ComboboxWidgetsPage, WidgetsPage)
171 EVT_BUTTON(ComboPage_Reset, ComboboxWidgetsPage::OnButtonReset)
172 EVT_BUTTON(ComboPage_Change, ComboboxWidgetsPage::OnButtonChange)
173 EVT_BUTTON(ComboPage_Delete, ComboboxWidgetsPage::OnButtonDelete)
174 EVT_BUTTON(ComboPage_DeleteSel, ComboboxWidgetsPage::OnButtonDeleteSel)
175 EVT_BUTTON(ComboPage_Clear, ComboboxWidgetsPage::OnButtonClear)
176 EVT_BUTTON(ComboPage_Insert, ComboboxWidgetsPage::OnButtonInsert)
177 EVT_BUTTON(ComboPage_Add, ComboboxWidgetsPage::OnButtonAdd)
178 EVT_BUTTON(ComboPage_AddSeveral, ComboboxWidgetsPage::OnButtonAddSeveral)
179 EVT_BUTTON(ComboPage_AddMany, ComboboxWidgetsPage::OnButtonAddMany)
180 EVT_BUTTON(ComboPage_SetValue, ComboboxWidgetsPage::OnButtonSetValue)
181 EVT_BUTTON(ComboPage_SetCurrent, ComboboxWidgetsPage::OnButtonSetCurrent)
182 EVT_BUTTON(ComboPage_ContainerTests, ItemContainerWidgetsPage::OnButtonTestItemContainer)
183
184 EVT_TEXT_ENTER(ComboPage_InsertText, ComboboxWidgetsPage::OnButtonInsert)
185 EVT_TEXT_ENTER(ComboPage_AddText, ComboboxWidgetsPage::OnButtonAdd)
186 EVT_TEXT_ENTER(ComboPage_DeleteText, ComboboxWidgetsPage::OnButtonDelete)
187
188 EVT_UPDATE_UI(ComboPage_InsertionPointText, ComboboxWidgetsPage::OnUpdateUIInsertionPointText)
189
190 EVT_UPDATE_UI(ComboPage_Reset, ComboboxWidgetsPage::OnUpdateUIResetButton)
191 EVT_UPDATE_UI(ComboPage_Insert, ComboboxWidgetsPage::OnUpdateUIInsert)
192 EVT_UPDATE_UI(ComboPage_AddSeveral, ComboboxWidgetsPage::OnUpdateUIAddSeveral)
193 EVT_UPDATE_UI(ComboPage_Clear, ComboboxWidgetsPage::OnUpdateUIClearButton)
194 EVT_UPDATE_UI(ComboPage_DeleteText, ComboboxWidgetsPage::OnUpdateUIClearButton)
195 EVT_UPDATE_UI(ComboPage_Delete, ComboboxWidgetsPage::OnUpdateUIDeleteButton)
196 EVT_UPDATE_UI(ComboPage_Change, ComboboxWidgetsPage::OnUpdateUIDeleteSelButton)
197 EVT_UPDATE_UI(ComboPage_ChangeText, ComboboxWidgetsPage::OnUpdateUIDeleteSelButton)
198 EVT_UPDATE_UI(ComboPage_DeleteSel, ComboboxWidgetsPage::OnUpdateUIDeleteSelButton)
199 EVT_UPDATE_UI(ComboPage_SetCurrent, ComboboxWidgetsPage::OnUpdateUISetCurrent)
200
201 EVT_COMBOBOX(ComboPage_Combo, ComboboxWidgetsPage::OnComboBox)
202 EVT_TEXT(ComboPage_Combo, ComboboxWidgetsPage::OnComboText)
203 EVT_TEXT_ENTER(ComboPage_Combo, ComboboxWidgetsPage::OnComboText)
204
205 EVT_CHECKBOX(wxID_ANY, ComboboxWidgetsPage::OnCheckOrRadioBox)
206 EVT_RADIOBOX(wxID_ANY, ComboboxWidgetsPage::OnCheckOrRadioBox)
207 END_EVENT_TABLE()
208
209 // ============================================================================
210 // implementation
211 // ============================================================================
212
213 #if defined(__WXUNIVERSAL__)
214 #define FAMILY_CTRLS UNIVERSAL_CTRLS
215 #else
216 #define FAMILY_CTRLS NATIVE_CTRLS
217 #endif
218
219 IMPLEMENT_WIDGETS_PAGE(ComboboxWidgetsPage, _T("Combobox"),
220 FAMILY_CTRLS | WITH_ITEMS_CTRLS | COMBO_CTRLS
221 );
222
223 ComboboxWidgetsPage::ComboboxWidgetsPage(WidgetsBookCtrl *book,
224 wxImageList *imaglist)
225 : ItemContainerWidgetsPage(book, imaglist, combobox_xpm)
226 {
227 // init everything
228 m_chkSort =
229 m_chkReadonly =
230 m_chkFilename = (wxCheckBox *)NULL;
231
232 m_combobox = (wxComboBox *)NULL;
233 m_sizerCombo = (wxSizer *)NULL;
234 }
235
236 void ComboboxWidgetsPage::CreateContent()
237 {
238 /*
239 What we create here is a frame having 3 panes: style pane is the
240 leftmost one, in the middle the pane with buttons allowing to perform
241 miscellaneous combobox operations and the pane containing the combobox
242 itself to the right
243 */
244 wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
245
246 // left pane
247 wxStaticBox *box = new wxStaticBox(this, wxID_ANY, _T("&Set style"));
248
249 // should be in sync with ComboKind_XXX values
250 static const wxString kinds[] =
251 {
252 _T("default"),
253 _T("simple"),
254 _T("drop down"),
255 };
256
257 m_radioKind = new wxRadioBox(this, wxID_ANY, _T("Combobox &kind:"),
258 wxDefaultPosition, wxDefaultSize,
259 WXSIZEOF(kinds), kinds,
260 1, wxRA_SPECIFY_COLS);
261
262 wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
263
264 m_chkSort = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Sort items"));
265 m_chkReadonly = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Read only"));
266 m_chkFilename = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&File name"));
267 m_chkFilename->Disable(); // not implemented yet
268
269 sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
270 sizerLeft->Add(m_radioKind, 0, wxGROW | wxALL, 5);
271
272 wxButton *btn = new wxButton(this, ComboPage_Reset, _T("&Reset"));
273 sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
274
275 // middle pane
276 wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY,
277 _T("&Change combobox contents"));
278 wxSizer *sizerMiddle = new wxStaticBoxSizer(box2, wxVERTICAL);
279
280 wxSizer *sizerRow;
281
282 sizerRow = CreateSizerWithTextAndButton(ComboPage_SetCurrent,
283 _T("Current &selection"),
284 ComboPage_CurText,
285 &m_textCur);
286
287 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
288
289 wxTextCtrl *text;
290 sizerRow = CreateSizerWithTextAndLabel(_T("Insertion Point"),
291 ComboPage_InsertionPointText,
292 &text);
293 text->SetEditable(false);
294
295 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
296
297 sizerRow = CreateSizerWithTextAndButton(ComboPage_Insert,
298 _T("&Insert this string"),
299 ComboPage_InsertText,
300 &m_textInsert);
301 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
302
303 sizerRow = CreateSizerWithTextAndButton(ComboPage_Add,
304 _T("&Add this string"),
305 ComboPage_AddText,
306 &m_textAdd);
307 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
308
309 btn = new wxButton(this, ComboPage_AddSeveral, _T("&Append a few strings"));
310 sizerMiddle->Add(btn, 0, wxALL | wxGROW, 5);
311
312 btn = new wxButton(this, ComboPage_AddMany, _T("Append &many strings"));
313 sizerMiddle->Add(btn, 0, wxALL | wxGROW, 5);
314
315 sizerRow = CreateSizerWithTextAndButton(ComboPage_Change,
316 _T("C&hange current"),
317 ComboPage_ChangeText,
318 &m_textChange);
319 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
320
321 sizerRow = CreateSizerWithTextAndButton(ComboPage_Delete,
322 _T("&Delete this item"),
323 ComboPage_DeleteText,
324 &m_textDelete);
325 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
326
327 btn = new wxButton(this, ComboPage_DeleteSel, _T("Delete &selection"));
328 sizerMiddle->Add(btn, 0, wxALL | wxGROW, 5);
329
330 btn = new wxButton(this, ComboPage_Clear, _T("&Clear"));
331 sizerMiddle->Add(btn, 0, wxALL | wxGROW, 5);
332
333 sizerRow = CreateSizerWithTextAndButton(ComboPage_SetValue,
334 _T("SetValue"),
335 ComboPage_SetValueText,
336 &m_textSetValue);
337 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
338
339 btn = new wxButton(this, ComboPage_ContainerTests, _T("Run &tests"));
340 sizerMiddle->Add(btn, 0, wxALL | wxGROW, 5);
341
342
343
344 // right pane
345 wxSizer *sizerRight = new wxBoxSizer(wxVERTICAL);
346 m_combobox = new wxComboBox(this, ComboPage_Combo, wxEmptyString,
347 wxDefaultPosition, wxDefaultSize,
348 0, NULL,
349 0);
350 sizerRight->Add(m_combobox, 0, wxGROW | wxALL, 5);
351 sizerRight->SetMinSize(150, 0);
352 m_sizerCombo = sizerRight; // save it to modify it later
353
354 // the 3 panes panes compose the window
355 sizerTop->Add(sizerLeft, 0, wxGROW | (wxALL & ~wxLEFT), 10);
356 sizerTop->Add(sizerMiddle, 1, wxGROW | wxALL, 10);
357 sizerTop->Add(sizerRight, 1, wxGROW | (wxALL & ~wxRIGHT), 10);
358
359 // final initializations
360 Reset();
361
362 SetSizer(sizerTop);
363 }
364
365 // ----------------------------------------------------------------------------
366 // operations
367 // ----------------------------------------------------------------------------
368
369 void ComboboxWidgetsPage::Reset()
370 {
371 m_chkSort->SetValue(false);
372 m_chkReadonly->SetValue(false);
373 m_chkFilename->SetValue(false);
374 }
375
376 void ComboboxWidgetsPage::CreateCombo()
377 {
378 int flags = ms_defaultFlags;
379
380 if ( m_chkSort->GetValue() )
381 flags |= wxCB_SORT;
382 if ( m_chkReadonly->GetValue() )
383 flags |= wxCB_READONLY;
384
385 switch ( m_radioKind->GetSelection() )
386 {
387 default:
388 wxFAIL_MSG( _T("unknown combo kind") );
389 // fall through
390
391 case ComboKind_Default:
392 break;
393
394 case ComboKind_Simple:
395 flags |= wxCB_SIMPLE;
396 break;
397
398 case ComboKind_DropDown:
399 flags = wxCB_DROPDOWN;
400 break;
401 }
402
403 wxArrayString items;
404 if ( m_combobox )
405 {
406 unsigned int count = m_combobox->GetCount();
407 for ( unsigned int n = 0; n < count; n++ )
408 {
409 items.Add(m_combobox->GetString(n));
410 }
411
412 m_sizerCombo->Detach( m_combobox );
413 delete m_combobox;
414 }
415
416 m_combobox = new wxComboBox(this, ComboPage_Combo, wxEmptyString,
417 wxDefaultPosition, wxDefaultSize,
418 0, NULL,
419 flags);
420
421 #if 0
422 if ( m_chkFilename->GetValue() )
423 ;
424 #endif // TODO
425
426 unsigned int count = items.GetCount();
427 for ( unsigned int n = 0; n < count; n++ )
428 {
429 m_combobox->Append(items[n]);
430 }
431
432 m_sizerCombo->Add(m_combobox, 0, wxGROW | wxALL, 5);
433 m_sizerCombo->Layout();
434 }
435
436 // ----------------------------------------------------------------------------
437 // event handlers
438 // ----------------------------------------------------------------------------
439
440 void ComboboxWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
441 {
442 Reset();
443
444 CreateCombo();
445 }
446
447 void ComboboxWidgetsPage::OnButtonChange(wxCommandEvent& WXUNUSED(event))
448 {
449 int sel = m_combobox->GetSelection();
450 if ( sel != wxNOT_FOUND )
451 {
452 #ifndef __WXGTK__
453 m_combobox->SetString(sel, m_textChange->GetValue());
454 #else
455 wxLogMessage(_T("Not implemented in wxGTK"));
456 #endif
457 }
458 }
459
460 void ComboboxWidgetsPage::OnButtonDelete(wxCommandEvent& WXUNUSED(event))
461 {
462 unsigned long n;
463 if ( !m_textDelete->GetValue().ToULong(&n) ||
464 (n >= m_combobox->GetCount()) )
465 {
466 return;
467 }
468
469 m_combobox->Delete(n);
470 }
471
472 void ComboboxWidgetsPage::OnButtonDeleteSel(wxCommandEvent& WXUNUSED(event))
473 {
474 int sel = m_combobox->GetSelection();
475 if ( sel != wxNOT_FOUND )
476 {
477 m_combobox->Delete(sel);
478 }
479 }
480
481 void ComboboxWidgetsPage::OnButtonSetValue(wxCommandEvent& WXUNUSED(event))
482 {
483 wxString value = m_textSetValue->GetValue();
484 m_combobox->SetValue( value );
485 }
486
487 void ComboboxWidgetsPage::OnButtonClear(wxCommandEvent& WXUNUSED(event))
488 {
489 m_combobox->Clear();
490 }
491
492 void ComboboxWidgetsPage::OnButtonInsert(wxCommandEvent& WXUNUSED(event))
493 {
494 static unsigned int s_item = 0;
495
496 wxString s = m_textInsert->GetValue();
497 if ( !m_textInsert->IsModified() )
498 {
499 // update the default string
500 m_textInsert->SetValue(wxString::Format(_T("test item %u"), ++s_item));
501 }
502
503 if (m_combobox->GetSelection() >= 0)
504 m_combobox->Insert(s, m_combobox->GetSelection());
505 }
506
507 void ComboboxWidgetsPage::OnButtonAdd(wxCommandEvent& WXUNUSED(event))
508 {
509 static unsigned int s_item = 0;
510
511 wxString s = m_textAdd->GetValue();
512 if ( !m_textAdd->IsModified() )
513 {
514 // update the default string
515 m_textAdd->SetValue(wxString::Format(_T("test item %u"), ++s_item));
516 }
517
518 m_combobox->Append(s);
519 }
520
521 void ComboboxWidgetsPage::OnButtonAddMany(wxCommandEvent& WXUNUSED(event))
522 {
523 // "many" means 1000 here
524 for ( unsigned int n = 0; n < 1000; n++ )
525 {
526 m_combobox->Append(wxString::Format(_T("item #%u"), n));
527 }
528 }
529
530 void ComboboxWidgetsPage::OnButtonSetCurrent(wxCommandEvent& WXUNUSED(event))
531 {
532 long n;
533 if ( !m_textCur->GetValue().ToLong(&n) )
534 return;
535
536 m_combobox->SetSelection(n);
537 }
538
539 void ComboboxWidgetsPage::OnButtonAddSeveral(wxCommandEvent& WXUNUSED(event))
540 {
541 m_combobox->Append(_T("First"));
542 m_combobox->Append(_T("another one"));
543 m_combobox->Append(_T("and the last (very very very very very very very very very very long) one"));
544 }
545
546 void ComboboxWidgetsPage::OnUpdateUIInsertionPointText(wxUpdateUIEvent& event)
547 {
548 if (m_combobox)
549 event.SetText( wxString::Format(_T("%ld"), m_combobox->GetInsertionPoint()) );
550 }
551
552 void ComboboxWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
553 {
554 event.Enable( m_chkSort->GetValue() ||
555 m_chkReadonly->GetValue() ||
556 m_chkFilename->GetValue() );
557 }
558
559 void ComboboxWidgetsPage::OnUpdateUIInsert(wxUpdateUIEvent& event)
560 {
561 if (m_combobox)
562 {
563 bool enable = !(m_combobox->GetWindowStyle() & wxCB_SORT) &&
564 (m_combobox->GetSelection() >= 0);
565
566 event.Enable(enable);
567 }
568 }
569
570 void ComboboxWidgetsPage::OnUpdateUIDeleteButton(wxUpdateUIEvent& event)
571 {
572 if (m_combobox)
573 {
574 unsigned long n;
575 event.Enable(m_textDelete->GetValue().ToULong(&n) &&
576 (n < (unsigned)m_combobox->GetCount()));
577 }
578 }
579
580 void ComboboxWidgetsPage::OnUpdateUIDeleteSelButton(wxUpdateUIEvent& event)
581 {
582 if (m_combobox)
583 event.Enable(m_combobox->GetSelection() != wxNOT_FOUND);
584 }
585
586 void ComboboxWidgetsPage::OnUpdateUIClearButton(wxUpdateUIEvent& event)
587 {
588 if (m_combobox)
589 event.Enable(m_combobox->GetCount() != 0);
590 }
591
592 void ComboboxWidgetsPage::OnUpdateUIAddSeveral(wxUpdateUIEvent& event)
593 {
594 if (m_combobox)
595 event.Enable(!(m_combobox->GetWindowStyle() & wxCB_SORT));
596 }
597
598 void ComboboxWidgetsPage::OnUpdateUISetCurrent(wxUpdateUIEvent& event)
599 {
600 long n;
601 event.Enable( m_textCur->GetValue().ToLong(&n) &&
602 (n == wxNOT_FOUND ||
603 (n >= 0 && (unsigned)n < m_combobox->GetCount())) );
604 }
605
606 void ComboboxWidgetsPage::OnComboText(wxCommandEvent& event)
607 {
608 if (!m_combobox)
609 return;
610
611 wxString s = event.GetString();
612
613 wxASSERT_MSG( s == m_combobox->GetValue(),
614 _T("event and combobox values should be the same") );
615
616 if (event.GetEventType() == wxEVT_COMMAND_TEXT_ENTER)
617 wxLogMessage(_T("Combobox enter pressed (now '%s')"), s.c_str());
618 else
619 wxLogMessage(_T("Combobox text changed (now '%s')"), s.c_str());
620 }
621
622 void ComboboxWidgetsPage::OnComboBox(wxCommandEvent& event)
623 {
624 long sel = event.GetInt();
625 const wxString selstr = wxString::Format(_T("%ld"), sel);
626 m_textDelete->SetValue(selstr);
627 m_textCur->SetValue(selstr);
628
629 wxLogMessage(_T("Combobox item %ld selected"), sel);
630
631 wxLogMessage(_T("Combobox GetValue(): %s"), m_combobox->GetValue().c_str() );
632 }
633
634 void ComboboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
635 {
636 CreateCombo();
637 }
638
639 #endif //wxUSE_COMBOBOX
640
641 #endif