controls.cpp 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: controls.cpp
  3. // Purpose: Controls wxWidgets sample
  4. // Author: Robert Roebling
  5. // Modified by:
  6. // Copyright: (c) Robert Roebling, Julian Smart
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. // For compilers that support precompilation, includes "wx/wx.h".
  10. #include "wx/wxprec.h"
  11. #ifdef __BORLANDC__
  12. #pragma hdrstop
  13. #endif
  14. #ifndef WX_PRECOMP
  15. #include "wx/wx.h"
  16. #endif
  17. #include "wx/spinbutt.h"
  18. #include "wx/tglbtn.h"
  19. #include "wx/bookctrl.h"
  20. #include "wx/imaglist.h"
  21. #include "wx/artprov.h"
  22. #include "wx/cshelp.h"
  23. #include "wx/gbsizer.h"
  24. #if wxUSE_TOOLTIPS
  25. #include "wx/tooltip.h"
  26. #ifdef __WXMSW__
  27. #include "wx/numdlg.h"
  28. #endif // __WXMSW__
  29. #endif // wxUSE_TOOLTIPS
  30. #ifndef __WXMSW__
  31. #include "icons/choice.xpm"
  32. #include "icons/combo.xpm"
  33. #include "icons/list.xpm"
  34. #include "icons/radio.xpm"
  35. #include "icons/text.xpm"
  36. #include "icons/gauge.xpm"
  37. #endif
  38. #ifndef wxUSE_SPINBTN
  39. #define wxUSE_SPINBTN 1
  40. #endif
  41. #include "wx/progdlg.h"
  42. #if wxUSE_SPINCTRL
  43. #include "wx/spinctrl.h"
  44. #endif // wxUSE_SPINCTRL
  45. #if !wxUSE_TOGGLEBTN
  46. #define wxToggleButton wxCheckBox
  47. #define EVT_TOGGLEBUTTON EVT_CHECKBOX
  48. #endif
  49. #ifndef wxHAS_IMAGES_IN_RESOURCES
  50. #include "../sample.xpm"
  51. #endif
  52. //----------------------------------------------------------------------
  53. // class definitions
  54. //----------------------------------------------------------------------
  55. class MyApp: public wxApp
  56. {
  57. public:
  58. bool OnInit();
  59. };
  60. class MyPanel: public wxPanel
  61. {
  62. public:
  63. MyPanel(wxFrame *frame, int x, int y, int w, int h);
  64. virtual ~MyPanel();
  65. #if wxUSE_TOOLTIPS
  66. void SetAllToolTips();
  67. #endif // wxUSE_TOOLTIPS
  68. void OnIdle( wxIdleEvent &event );
  69. void OnListBox( wxCommandEvent &event );
  70. void OnListBoxDoubleClick( wxCommandEvent &event );
  71. void OnListBoxButtons( wxCommandEvent &event );
  72. #if wxUSE_CHOICE
  73. void OnChoice( wxCommandEvent &event );
  74. void OnChoiceButtons( wxCommandEvent &event );
  75. #endif
  76. void OnCombo( wxCommandEvent &event );
  77. void OnComboTextChanged( wxCommandEvent &event );
  78. void OnComboTextEnter( wxCommandEvent &event );
  79. void OnComboButtons( wxCommandEvent &event );
  80. void OnRadio( wxCommandEvent &event );
  81. void OnRadioButtons( wxCommandEvent &event );
  82. void OnRadioButton1( wxCommandEvent &event );
  83. void OnRadioButton2( wxCommandEvent &event );
  84. void OnSetFont( wxCommandEvent &event );
  85. void OnPageChanged( wxBookCtrlEvent &event );
  86. void OnPageChanging( wxBookCtrlEvent &event );
  87. void OnSliderUpdate( wxCommandEvent &event );
  88. void OnUpdateLabel( wxCommandEvent &event );
  89. #if wxUSE_SPINBTN
  90. void OnSpinUp( wxSpinEvent &event );
  91. void OnSpinDown( wxSpinEvent &event );
  92. void OnSpinUpdate( wxSpinEvent &event );
  93. #if wxUSE_PROGRESSDLG
  94. void OnUpdateShowProgress( wxUpdateUIEvent& event );
  95. void OnShowProgress( wxCommandEvent &event );
  96. #endif // wxUSE_PROGRESSDLG
  97. #endif // wxUSE_SPINBTN
  98. void OnNewText( wxCommandEvent &event );
  99. #if wxUSE_SPINCTRL
  100. void OnSpinCtrl(wxSpinEvent& event);
  101. void OnSpinCtrlUp(wxSpinEvent& event);
  102. void OnSpinCtrlDown(wxSpinEvent& event);
  103. void OnSpinCtrlText(wxCommandEvent& event);
  104. #endif // wxUSE_SPINCTRL
  105. void OnEnableAll(wxCommandEvent& event);
  106. void OnChangeColour(wxCommandEvent& event);
  107. void OnTestButton(wxCommandEvent& event);
  108. void OnBmpButton(wxCommandEvent& event);
  109. void OnBmpButtonToggle(wxCommandEvent& event);
  110. void OnSizerCheck (wxCommandEvent &event);
  111. wxListBox *m_listbox,
  112. *m_listboxSorted;
  113. #if wxUSE_CHOICE
  114. wxChoice *m_choice,
  115. *m_choiceSorted;
  116. #endif // wxUSE_CHOICE
  117. wxComboBox *m_combo;
  118. wxRadioBox *m_radio;
  119. #if wxUSE_GAUGE
  120. wxGauge *m_gauge,
  121. *m_gaugeVert;
  122. #endif // wxUSE_GAUGE
  123. #if wxUSE_SLIDER
  124. wxSlider *m_slider;
  125. #endif // wxUSE_SLIDER
  126. wxButton *m_fontButton;
  127. wxButton *m_lbSelectNum;
  128. wxButton *m_lbSelectThis;
  129. #if wxUSE_SPINBTN
  130. wxSpinButton *m_spinbutton;
  131. #if wxUSE_PROGRESSDLG
  132. wxButton *m_btnProgress;
  133. #endif // wxUSE_PROGRESSDLG
  134. #endif // wxUSE_SPINBTN
  135. wxStaticText *m_wrappingText;
  136. wxStaticText *m_nonWrappingText;
  137. #if wxUSE_SPINCTRL
  138. wxSpinCtrl *m_spinctrl;
  139. #endif // wxUSE_SPINCTRL
  140. wxTextCtrl *m_spintext;
  141. wxCheckBox *m_checkbox;
  142. wxTextCtrl *m_text;
  143. wxBookCtrl *m_book;
  144. wxStaticText *m_label;
  145. wxBoxSizer *m_buttonSizer;
  146. wxButton *m_sizerBtn1;
  147. wxButton *m_sizerBtn2;
  148. wxButton *m_sizerBtn3;
  149. wxButton *m_sizerBtn4;
  150. wxBoxSizer *m_hsizer;
  151. wxButton *m_bigBtn;
  152. private:
  153. wxLog *m_logTargetOld;
  154. wxDECLARE_EVENT_TABLE();
  155. };
  156. class MyFrame: public wxFrame
  157. {
  158. public:
  159. MyFrame(const wxChar *title, int x, int y);
  160. void OnQuit(wxCommandEvent& event);
  161. void OnAbout(wxCommandEvent& event);
  162. void OnClearLog(wxCommandEvent& event);
  163. #if wxUSE_TOOLTIPS
  164. void OnSetTooltipDelay(wxCommandEvent& event);
  165. void OnToggleTooltips(wxCommandEvent& event);
  166. #ifdef __WXMSW__
  167. void OnSetMaxTooltipWidth(wxCommandEvent& event);
  168. #endif // __WXMSW__
  169. #endif // wxUSE_TOOLTIPS
  170. void OnEnableAll(wxCommandEvent& event);
  171. void OnHideAll(wxCommandEvent& event);
  172. void OnHideList(wxCommandEvent& event);
  173. void OnContextHelp(wxCommandEvent& event);
  174. void OnIdle( wxIdleEvent& event );
  175. void OnIconized( wxIconizeEvent& event );
  176. void OnMaximized( wxMaximizeEvent& event );
  177. void OnSize( wxSizeEvent& event );
  178. void OnMove( wxMoveEvent& event );
  179. MyPanel *GetPanel() const { return m_panel; }
  180. private:
  181. #if wxUSE_STATUSBAR
  182. void UpdateStatusBar(const wxPoint& pos, const wxSize& size)
  183. {
  184. if ( m_frameStatusBar )
  185. {
  186. wxString msg;
  187. wxSize sizeAll = GetSize(),
  188. sizeCl = GetClientSize();
  189. msg.Printf(_("pos=(%d, %d), size=%dx%d or %dx%d (client=%dx%d)"),
  190. pos.x, pos.y,
  191. size.x, size.y,
  192. sizeAll.x, sizeAll.y,
  193. sizeCl.x, sizeCl.y);
  194. SetStatusText(msg, 1);
  195. }
  196. }
  197. #endif // wxUSE_STATUSBAR
  198. MyPanel *m_panel;
  199. wxDECLARE_EVENT_TABLE();
  200. };
  201. // a button which intercepts double clicks (for testing...)
  202. class MyButton : public wxButton
  203. {
  204. public:
  205. MyButton(wxWindow *parent,
  206. wxWindowID id,
  207. const wxString& label = wxEmptyString,
  208. const wxPoint& pos = wxDefaultPosition,
  209. const wxSize& size = wxDefaultSize)
  210. : wxButton(parent, id, label, pos, size)
  211. {
  212. }
  213. void OnDClick(wxMouseEvent& event)
  214. {
  215. wxLogMessage(wxT("MyButton::OnDClick"));
  216. event.Skip();
  217. }
  218. private:
  219. wxDECLARE_EVENT_TABLE();
  220. };
  221. // a combo which intercepts chars (to test Windows behaviour)
  222. class MyComboBox : public wxComboBox
  223. {
  224. public:
  225. MyComboBox(wxWindow *parent, wxWindowID id,
  226. const wxString& value = wxEmptyString,
  227. const wxPoint& pos = wxDefaultPosition,
  228. const wxSize& size = wxDefaultSize,
  229. int n = 0, const wxString choices[] = NULL,
  230. long style = 0,
  231. const wxValidator& validator = wxDefaultValidator,
  232. const wxString& name = wxComboBoxNameStr)
  233. : wxComboBox(parent, id, value, pos, size, n, choices, style,
  234. validator, name) { }
  235. protected:
  236. void OnChar(wxKeyEvent& event);
  237. void OnKeyDown(wxKeyEvent& event);
  238. void OnKeyUp(wxKeyEvent& event);
  239. void OnFocusGot(wxFocusEvent& event)
  240. {
  241. wxLogMessage(wxT("MyComboBox::OnFocusGot"));
  242. event.Skip();
  243. }
  244. private:
  245. wxDECLARE_EVENT_TABLE();
  246. };
  247. // a radiobox which handles focus set/kill (for testing)
  248. class MyRadioBox : public wxRadioBox
  249. {
  250. public:
  251. MyRadioBox(wxWindow *parent,
  252. wxWindowID id,
  253. const wxString& title = wxEmptyString,
  254. const wxPoint& pos = wxDefaultPosition,
  255. const wxSize& size = wxDefaultSize,
  256. int n = 0, const wxString choices[] = NULL,
  257. int majorDim = 1,
  258. long style = wxRA_SPECIFY_COLS,
  259. const wxValidator& validator = wxDefaultValidator,
  260. const wxString& name = wxRadioBoxNameStr)
  261. : wxRadioBox(parent, id, title, pos, size, n, choices, majorDim,
  262. style, validator, name)
  263. {
  264. }
  265. protected:
  266. void OnFocusGot(wxFocusEvent& event)
  267. {
  268. wxLogMessage(wxT("MyRadioBox::OnFocusGot"));
  269. event.Skip();
  270. }
  271. void OnFocusLost(wxFocusEvent& event)
  272. {
  273. wxLogMessage(wxT("MyRadioBox::OnFocusLost"));
  274. event.Skip();
  275. }
  276. private:
  277. wxDECLARE_EVENT_TABLE();
  278. };
  279. // a choice which handles focus set/kill (for testing)
  280. class MyChoice : public wxChoice
  281. {
  282. public:
  283. MyChoice(wxWindow *parent,
  284. wxWindowID id,
  285. const wxPoint& pos = wxDefaultPosition,
  286. const wxSize& size = wxDefaultSize,
  287. int n = 0, const wxString choices[] = NULL,
  288. long style = 0,
  289. const wxValidator& validator = wxDefaultValidator,
  290. const wxString& name = wxChoiceNameStr )
  291. : wxChoice(parent, id, pos, size, n, choices,
  292. style, validator, name) { }
  293. protected:
  294. void OnFocusGot(wxFocusEvent& event)
  295. {
  296. wxLogMessage(wxT("MyChoice::OnFocusGot"));
  297. event.Skip();
  298. }
  299. void OnFocusLost(wxFocusEvent& event)
  300. {
  301. wxLogMessage(wxT("MyChoice::OnFocusLost"));
  302. event.Skip();
  303. }
  304. private:
  305. wxDECLARE_EVENT_TABLE();
  306. };
  307. //----------------------------------------------------------------------
  308. // other
  309. //----------------------------------------------------------------------
  310. static void SetListboxClientData(const wxChar *name, wxListBox *control);
  311. #if wxUSE_CHOICE
  312. static void SetChoiceClientData(const wxChar *name, wxChoice *control);
  313. #endif // wxUSE_CHOICE
  314. IMPLEMENT_APP(MyApp)
  315. //----------------------------------------------------------------------
  316. // MyApp
  317. //----------------------------------------------------------------------
  318. enum
  319. {
  320. CONTROLS_QUIT = wxID_EXIT,
  321. CONTROLS_ABOUT = wxID_ABOUT,
  322. CONTROLS_TEXT = 100,
  323. CONTROLS_CLEAR_LOG,
  324. // tooltip menu
  325. CONTROLS_SET_TOOLTIP_DELAY = 200,
  326. CONTROLS_ENABLE_TOOLTIPS,
  327. CONTROLS_SET_TOOLTIPS_MAX_WIDTH,
  328. // panel menu
  329. CONTROLS_ENABLE_ALL,
  330. CONTROLS_HIDE_ALL,
  331. CONTROLS_HIDE_LIST,
  332. CONTROLS_CONTEXT_HELP
  333. };
  334. bool MyApp::OnInit()
  335. {
  336. // use standard command line handling:
  337. if ( !wxApp::OnInit() )
  338. return false;
  339. // parse the cmd line
  340. int x = 50,
  341. y = 50;
  342. if ( argc == 3 )
  343. {
  344. wxSscanf(wxString(argv[1]), wxT("%d"), &x);
  345. wxSscanf(wxString(argv[2]), wxT("%d"), &y);
  346. }
  347. #if wxUSE_HELP
  348. wxHelpProvider::Set( new wxSimpleHelpProvider );
  349. #endif // wxUSE_HELP
  350. // Create the main frame window
  351. MyFrame *frame = new MyFrame(wxT("Controls wxWidgets App"), x, y);
  352. frame->Show(true);
  353. return true;
  354. }
  355. //----------------------------------------------------------------------
  356. // MyPanel
  357. //----------------------------------------------------------------------
  358. const int ID_BOOK = 1000;
  359. const int ID_LISTBOX = 130;
  360. const int ID_LISTBOX_SEL_NUM = 131;
  361. const int ID_LISTBOX_SEL_STR = 132;
  362. const int ID_LISTBOX_CLEAR = 133;
  363. const int ID_LISTBOX_APPEND = 134;
  364. const int ID_LISTBOX_DELETE = 135;
  365. const int ID_LISTBOX_FONT = 136;
  366. const int ID_LISTBOX_ENABLE = 137;
  367. const int ID_LISTBOX_SORTED = 138;
  368. const int ID_CHOICE = 120;
  369. const int ID_CHOICE_SEL_NUM = 121;
  370. const int ID_CHOICE_SEL_STR = 122;
  371. const int ID_CHOICE_CLEAR = 123;
  372. const int ID_CHOICE_APPEND = 124;
  373. const int ID_CHOICE_DELETE = 125;
  374. const int ID_CHOICE_FONT = 126;
  375. const int ID_CHOICE_ENABLE = 127;
  376. const int ID_CHOICE_SORTED = 128;
  377. const int ID_COMBO = 140;
  378. const int ID_COMBO_SEL_NUM = 141;
  379. const int ID_COMBO_SEL_STR = 142;
  380. const int ID_COMBO_CLEAR = 143;
  381. const int ID_COMBO_APPEND = 144;
  382. const int ID_COMBO_DELETE = 145;
  383. const int ID_COMBO_FONT = 146;
  384. const int ID_COMBO_ENABLE = 147;
  385. const int ID_COMBO_SET_TEXT = 148;
  386. const int ID_RADIOBOX = 160;
  387. const int ID_RADIOBOX_SEL_NUM = 161;
  388. const int ID_RADIOBOX_SEL_STR = 162;
  389. const int ID_RADIOBOX_FONT = 163;
  390. const int ID_RADIOBOX_ENABLE = 164;
  391. const int ID_RADIOBOX2 = 165;
  392. const int ID_RADIOBUTTON_1 = 166;
  393. const int ID_RADIOBUTTON_2 = 167;
  394. const int ID_SET_FONT = 170;
  395. #if wxUSE_GAUGE
  396. const int ID_GAUGE = 180;
  397. #endif // wxUSE_GAUGE
  398. #if wxUSE_SLIDER
  399. const int ID_SLIDER = 181;
  400. #endif // wxUSE_SLIDER
  401. const int ID_SPIN = 182;
  402. #if wxUSE_PROGRESSDLG
  403. const int ID_BTNPROGRESS = 183;
  404. #endif // wxUSE_PROGRESSDLG
  405. const int ID_BUTTON_LABEL = 184;
  406. const int ID_SPINCTRL = 185;
  407. const int ID_BTNNEWTEXT = 186;
  408. const int ID_BUTTON_TEST1 = 190;
  409. const int ID_BUTTON_TEST2 = 191;
  410. const int ID_BITMAP_BTN = 192;
  411. const int ID_BITMAP_BTN_ENABLE = 193;
  412. const int ID_CHANGE_COLOUR = 200;
  413. const int ID_SIZER_CHECK1 = 201;
  414. const int ID_SIZER_CHECK2 = 202;
  415. const int ID_SIZER_CHECK3 = 203;
  416. const int ID_SIZER_CHECK4 = 204;
  417. const int ID_SIZER_CHECK14 = 205;
  418. const int ID_SIZER_CHECKBIG = 206;
  419. const int ID_HYPERLINK = 300;
  420. wxBEGIN_EVENT_TABLE(MyPanel, wxPanel)
  421. EVT_IDLE ( MyPanel::OnIdle)
  422. EVT_BOOKCTRL_PAGE_CHANGING(ID_BOOK, MyPanel::OnPageChanging)
  423. EVT_BOOKCTRL_PAGE_CHANGED(ID_BOOK, MyPanel::OnPageChanged)
  424. EVT_LISTBOX (ID_LISTBOX, MyPanel::OnListBox)
  425. EVT_LISTBOX (ID_LISTBOX_SORTED, MyPanel::OnListBox)
  426. EVT_LISTBOX_DCLICK(ID_LISTBOX, MyPanel::OnListBoxDoubleClick)
  427. EVT_BUTTON (ID_LISTBOX_SEL_NUM, MyPanel::OnListBoxButtons)
  428. EVT_BUTTON (ID_LISTBOX_SEL_STR, MyPanel::OnListBoxButtons)
  429. EVT_BUTTON (ID_LISTBOX_CLEAR, MyPanel::OnListBoxButtons)
  430. EVT_BUTTON (ID_LISTBOX_APPEND, MyPanel::OnListBoxButtons)
  431. EVT_BUTTON (ID_LISTBOX_DELETE, MyPanel::OnListBoxButtons)
  432. EVT_BUTTON (ID_LISTBOX_FONT, MyPanel::OnListBoxButtons)
  433. EVT_CHECKBOX (ID_LISTBOX_ENABLE, MyPanel::OnListBoxButtons)
  434. #if wxUSE_CHOICE
  435. EVT_CHOICE (ID_CHOICE, MyPanel::OnChoice)
  436. EVT_CHOICE (ID_CHOICE_SORTED, MyPanel::OnChoice)
  437. EVT_BUTTON (ID_CHOICE_SEL_NUM, MyPanel::OnChoiceButtons)
  438. EVT_BUTTON (ID_CHOICE_SEL_STR, MyPanel::OnChoiceButtons)
  439. EVT_BUTTON (ID_CHOICE_CLEAR, MyPanel::OnChoiceButtons)
  440. EVT_BUTTON (ID_CHOICE_APPEND, MyPanel::OnChoiceButtons)
  441. EVT_BUTTON (ID_CHOICE_DELETE, MyPanel::OnChoiceButtons)
  442. EVT_BUTTON (ID_CHOICE_FONT, MyPanel::OnChoiceButtons)
  443. EVT_CHECKBOX (ID_CHOICE_ENABLE, MyPanel::OnChoiceButtons)
  444. #endif
  445. EVT_COMBOBOX (ID_COMBO, MyPanel::OnCombo)
  446. EVT_TEXT (ID_COMBO, MyPanel::OnComboTextChanged)
  447. EVT_TEXT_ENTER(ID_COMBO, MyPanel::OnComboTextEnter)
  448. EVT_BUTTON (ID_COMBO_SEL_NUM, MyPanel::OnComboButtons)
  449. EVT_BUTTON (ID_COMBO_SEL_STR, MyPanel::OnComboButtons)
  450. EVT_BUTTON (ID_COMBO_CLEAR, MyPanel::OnComboButtons)
  451. EVT_BUTTON (ID_COMBO_APPEND, MyPanel::OnComboButtons)
  452. EVT_BUTTON (ID_COMBO_DELETE, MyPanel::OnComboButtons)
  453. EVT_BUTTON (ID_COMBO_FONT, MyPanel::OnComboButtons)
  454. EVT_BUTTON (ID_COMBO_SET_TEXT, MyPanel::OnComboButtons)
  455. EVT_CHECKBOX (ID_COMBO_ENABLE, MyPanel::OnComboButtons)
  456. EVT_RADIOBOX (ID_RADIOBOX, MyPanel::OnRadio)
  457. EVT_RADIOBOX (ID_RADIOBOX2, MyPanel::OnRadio)
  458. EVT_BUTTON (ID_RADIOBOX_SEL_NUM, MyPanel::OnRadioButtons)
  459. EVT_BUTTON (ID_RADIOBOX_SEL_STR, MyPanel::OnRadioButtons)
  460. EVT_BUTTON (ID_RADIOBOX_FONT, MyPanel::OnRadioButtons)
  461. EVT_CHECKBOX (ID_RADIOBOX_ENABLE, MyPanel::OnRadioButtons)
  462. EVT_RADIOBUTTON(ID_RADIOBUTTON_1, MyPanel::OnRadioButton1)
  463. EVT_RADIOBUTTON(ID_RADIOBUTTON_2, MyPanel::OnRadioButton2)
  464. EVT_BUTTON (ID_SET_FONT, MyPanel::OnSetFont)
  465. #if wxUSE_SLIDER
  466. EVT_SLIDER (ID_SLIDER, MyPanel::OnSliderUpdate)
  467. #endif // wxUSE_SLIDER
  468. #if wxUSE_SPINBTN
  469. EVT_SPIN (ID_SPIN, MyPanel::OnSpinUpdate)
  470. EVT_SPIN_UP (ID_SPIN, MyPanel::OnSpinUp)
  471. EVT_SPIN_DOWN (ID_SPIN, MyPanel::OnSpinDown)
  472. #if wxUSE_PROGRESSDLG
  473. EVT_UPDATE_UI (ID_BTNPROGRESS, MyPanel::OnUpdateShowProgress)
  474. EVT_BUTTON (ID_BTNPROGRESS, MyPanel::OnShowProgress)
  475. #endif // wxUSE_PROGRESSDLG
  476. #endif // wxUSE_SPINBTN
  477. #if wxUSE_SPINCTRL
  478. EVT_SPINCTRL (ID_SPINCTRL, MyPanel::OnSpinCtrl)
  479. EVT_SPIN_UP (ID_SPINCTRL, MyPanel::OnSpinCtrlUp)
  480. EVT_SPIN_DOWN (ID_SPINCTRL, MyPanel::OnSpinCtrlDown)
  481. EVT_TEXT (ID_SPINCTRL, MyPanel::OnSpinCtrlText)
  482. #endif // wxUSE_SPINCTRL
  483. EVT_BUTTON (ID_BTNNEWTEXT, MyPanel::OnNewText)
  484. EVT_TOGGLEBUTTON(ID_BUTTON_LABEL, MyPanel::OnUpdateLabel)
  485. EVT_CHECKBOX (ID_CHANGE_COLOUR, MyPanel::OnChangeColour)
  486. EVT_BUTTON (ID_BUTTON_TEST1, MyPanel::OnTestButton)
  487. EVT_BUTTON (ID_BUTTON_TEST2, MyPanel::OnTestButton)
  488. EVT_BUTTON (ID_BITMAP_BTN, MyPanel::OnBmpButton)
  489. EVT_TOGGLEBUTTON(ID_BITMAP_BTN_ENABLE, MyPanel::OnBmpButtonToggle)
  490. EVT_CHECKBOX (ID_SIZER_CHECK1, MyPanel::OnSizerCheck)
  491. EVT_CHECKBOX (ID_SIZER_CHECK2, MyPanel::OnSizerCheck)
  492. EVT_CHECKBOX (ID_SIZER_CHECK3, MyPanel::OnSizerCheck)
  493. EVT_CHECKBOX (ID_SIZER_CHECK4, MyPanel::OnSizerCheck)
  494. EVT_CHECKBOX (ID_SIZER_CHECK14, MyPanel::OnSizerCheck)
  495. EVT_CHECKBOX (ID_SIZER_CHECKBIG, MyPanel::OnSizerCheck)
  496. wxEND_EVENT_TABLE()
  497. wxBEGIN_EVENT_TABLE(MyButton, wxButton)
  498. EVT_LEFT_DCLICK(MyButton::OnDClick)
  499. wxEND_EVENT_TABLE()
  500. wxBEGIN_EVENT_TABLE(MyComboBox, wxComboBox)
  501. EVT_CHAR(MyComboBox::OnChar)
  502. EVT_KEY_DOWN(MyComboBox::OnKeyDown)
  503. EVT_KEY_UP(MyComboBox::OnKeyUp)
  504. EVT_SET_FOCUS(MyComboBox::OnFocusGot)
  505. wxEND_EVENT_TABLE()
  506. wxBEGIN_EVENT_TABLE(MyRadioBox, wxRadioBox)
  507. EVT_SET_FOCUS(MyRadioBox::OnFocusGot)
  508. EVT_KILL_FOCUS(MyRadioBox::OnFocusLost)
  509. wxEND_EVENT_TABLE()
  510. wxBEGIN_EVENT_TABLE(MyChoice, wxChoice)
  511. EVT_SET_FOCUS(MyChoice::OnFocusGot)
  512. EVT_KILL_FOCUS(MyChoice::OnFocusLost)
  513. wxEND_EVENT_TABLE()
  514. // ============================================================================
  515. // implementation
  516. // ============================================================================
  517. MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
  518. : wxPanel( frame, wxID_ANY, wxPoint(x, y), wxSize(w, h) )
  519. {
  520. m_listbox = NULL;
  521. m_listboxSorted = NULL;
  522. #if wxUSE_CHOICE
  523. m_choice = NULL;
  524. m_choiceSorted = NULL;
  525. #endif // wxUSE_CHOICE
  526. m_combo = NULL;
  527. m_radio = NULL;
  528. #if wxUSE_GAUGE
  529. m_gauge = NULL;
  530. m_gaugeVert = NULL;
  531. #endif // wxUSE_GAUGE
  532. #if wxUSE_SLIDER
  533. m_slider = NULL;
  534. #endif // wxUSE_SLIDER
  535. m_fontButton = NULL;
  536. m_lbSelectNum = NULL;
  537. m_lbSelectThis = NULL;
  538. #if wxUSE_SPINBTN
  539. m_spinbutton = NULL;
  540. #if wxUSE_PROGRESSDLG
  541. m_btnProgress = NULL;
  542. #endif // wxUSE_PROGRESSDLG
  543. #endif // wxUSE_SPINBTN
  544. #if wxUSE_SPINCTRL
  545. m_spinctrl = NULL;
  546. #endif // wxUSE_SPINCTRL
  547. m_spintext = NULL;
  548. m_checkbox = NULL;
  549. m_text = NULL;
  550. m_book = NULL;
  551. m_label = NULL;
  552. m_text = new wxTextCtrl(this, wxID_ANY, wxT("This is the log window.\n"),
  553. wxPoint(0, 250), wxSize(100, 50), wxTE_MULTILINE);
  554. m_logTargetOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_text));
  555. m_book = new wxBookCtrl(this, ID_BOOK);
  556. wxString choices[] =
  557. {
  558. wxT("This"),
  559. wxT("is"),
  560. wxT("one of my long and"),
  561. wxT("wonderful"),
  562. wxT("examples.")
  563. };
  564. #ifndef __WXMSW__
  565. // image ids
  566. enum
  567. {
  568. Image_List,
  569. Image_Choice,
  570. Image_Combo,
  571. Image_Text,
  572. Image_Radio,
  573. #if wxUSE_GAUGE
  574. Image_Gauge,
  575. #endif // wxUSE_GAUGE
  576. Image_Max
  577. };
  578. // fill the image list
  579. wxBitmap bmp(list_xpm);
  580. wxImageList *imagelist = new wxImageList(bmp.GetWidth(), bmp.GetHeight());
  581. imagelist-> Add( bmp );
  582. imagelist-> Add( wxBitmap( choice_xpm ));
  583. imagelist-> Add( wxBitmap( combo_xpm ));
  584. imagelist-> Add( wxBitmap( text_xpm ));
  585. imagelist-> Add( wxBitmap( radio_xpm ));
  586. #if wxUSE_GAUGE
  587. imagelist-> Add( wxBitmap( gauge_xpm ));
  588. #endif // wxUSE_GAUGE
  589. m_book->SetImageList(imagelist);
  590. #else
  591. // load images from resources
  592. enum
  593. {
  594. Image_List,
  595. Image_Choice,
  596. Image_Combo,
  597. Image_Text,
  598. Image_Radio,
  599. #if wxUSE_GAUGE
  600. Image_Gauge,
  601. #endif // wxUSE_GAUGE
  602. Image_Max
  603. };
  604. wxImageList *imagelist = new wxImageList(16, 16, false, Image_Max);
  605. static const wxChar *s_iconNames[Image_Max] =
  606. {
  607. wxT("list")
  608. , wxT("choice")
  609. , wxT("combo")
  610. , wxT("text")
  611. , wxT("radio")
  612. #if wxUSE_GAUGE
  613. , wxT("gauge")
  614. #endif // wxUSE_GAUGE
  615. };
  616. for ( size_t n = 0; n < Image_Max; n++ )
  617. {
  618. wxBitmap bmp(s_iconNames[n]);
  619. if ( !bmp.IsOk() || (imagelist->Add(bmp) == -1) )
  620. {
  621. wxLogWarning(wxT("Couldn't load the image '%s' for the book control page %d."),
  622. s_iconNames[n], n);
  623. }
  624. }
  625. m_book->SetImageList(imagelist);
  626. #endif
  627. // ------------------------------------------------------------------------
  628. // listbox page
  629. // ------------------------------------------------------------------------
  630. wxPanel *panel = new wxPanel(m_book);
  631. m_listbox = new wxListBox( panel, ID_LISTBOX,
  632. wxPoint(10,10), wxSize(120,70),
  633. 5, choices, wxLB_MULTIPLE | wxLB_ALWAYS_SB | wxHSCROLL );
  634. m_listboxSorted = new wxListBox( panel, ID_LISTBOX_SORTED,
  635. wxPoint(10,90), wxSize(120,70),
  636. 3, choices, wxLB_SORT );
  637. SetListboxClientData(wxT("listbox"), m_listbox);
  638. SetListboxClientData(wxT("listbox"), m_listboxSorted);
  639. m_listbox->SetCursor(*wxCROSS_CURSOR);
  640. m_lbSelectNum = new wxButton( panel, ID_LISTBOX_SEL_NUM, wxT("Select #&2"), wxPoint(180,30), wxSize(140,30) );
  641. m_lbSelectThis = new wxButton( panel, ID_LISTBOX_SEL_STR, wxT("&Select 'This'"), wxPoint(340,30), wxSize(140,30) );
  642. (void)new wxButton( panel, ID_LISTBOX_CLEAR, wxT("&Clear"), wxPoint(180,80), wxSize(140,30) );
  643. (void)new MyButton( panel, ID_LISTBOX_APPEND, wxT("&Append 'Hi!'"), wxPoint(340,80), wxSize(140,30) );
  644. (void)new wxButton( panel, ID_LISTBOX_DELETE, wxT("D&elete selected item"), wxPoint(180,130), wxSize(140,30) );
  645. wxButton *button = new MyButton( panel, ID_LISTBOX_FONT, wxT("Set &Italic font"), wxPoint(340,130), wxSize(140,30) );
  646. button->SetDefault();
  647. m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, wxT("&Disable"), wxPoint(20,170) );
  648. m_checkbox->SetValue(false);
  649. button->MoveAfterInTabOrder(m_checkbox);
  650. (void)new wxCheckBox( panel, ID_CHANGE_COLOUR, wxT("&Toggle colour"),
  651. wxPoint(110,170) );
  652. panel->SetCursor(wxCursor(wxCURSOR_HAND));
  653. m_book->AddPage(panel, wxT("wxListBox"), true, Image_List);
  654. // ------------------------------------------------------------------------
  655. // choice page
  656. // ------------------------------------------------------------------------
  657. #if wxUSE_CHOICE
  658. panel = new wxPanel(m_book);
  659. m_choice = new MyChoice( panel, ID_CHOICE, wxPoint(10,10), wxDefaultSize, 5, choices );
  660. m_choiceSorted = new MyChoice( panel, ID_CHOICE_SORTED, wxPoint(10,70), wxSize(120,wxDefaultCoord),
  661. 5, choices, wxCB_SORT );
  662. SetChoiceClientData(wxT("choice"), m_choice);
  663. SetChoiceClientData(wxT("choice"), m_choiceSorted);
  664. m_choice->SetSelection(2);
  665. (void)new wxButton( panel, ID_CHOICE_SEL_NUM, wxT("Select #&2"), wxPoint(220,30), wxSize(140,30) );
  666. (void)new wxButton( panel, ID_CHOICE_SEL_STR, wxT("&Select 'This'"), wxPoint(380,30), wxSize(140,30) );
  667. (void)new wxButton( panel, ID_CHOICE_CLEAR, wxT("&Clear"), wxPoint(220,80), wxSize(140,30) );
  668. (void)new wxButton( panel, ID_CHOICE_APPEND, wxT("&Append 'Hi!'"), wxPoint(380,80), wxSize(140,30) );
  669. (void)new wxButton( panel, ID_CHOICE_DELETE, wxT("D&elete selected item"), wxPoint(220,130), wxSize(140,30) );
  670. (void)new wxButton( panel, ID_CHOICE_FONT, wxT("Set &Italic font"), wxPoint(380,130), wxSize(140,30) );
  671. (void)new wxCheckBox( panel, ID_CHOICE_ENABLE, wxT("&Disable"), wxPoint(20,130), wxSize(140,30) );
  672. m_book->AddPage(panel, wxT("wxChoice"), false, Image_Choice);
  673. #endif // wxUSE_CHOICE
  674. // ------------------------------------------------------------------------
  675. // combo page
  676. // ------------------------------------------------------------------------
  677. panel = new wxPanel(m_book);
  678. m_combo = new MyComboBox( panel, ID_COMBO, wxT("This"),
  679. wxPoint(15,25), wxDefaultSize,
  680. 5, choices,
  681. wxTE_PROCESS_ENTER);
  682. wxSize combosize(m_combo->GetBestSize().x + 20, 100);
  683. (void)new wxStaticBox( panel, wxID_ANY, wxT("&Box around combobox"),
  684. wxPoint(5, 5), combosize);
  685. (void)new wxButton( panel, ID_COMBO_SEL_NUM, wxT("Select #&2"), wxPoint(220,30), wxSize(140,30) );
  686. (void)new wxButton( panel, ID_COMBO_SEL_STR, wxT("&Select 'This'"), wxPoint(380,30), wxSize(140,30) );
  687. (void)new wxButton( panel, ID_COMBO_CLEAR, wxT("&Clear"), wxPoint(220,80), wxSize(140,30) );
  688. (void)new wxButton( panel, ID_COMBO_APPEND, wxT("&Append 'Hi!'"), wxPoint(380,80), wxSize(140,30) );
  689. (void)new wxButton( panel, ID_COMBO_DELETE, wxT("D&elete selected item"), wxPoint(220,130), wxSize(140,30) );
  690. (void)new wxButton( panel, ID_COMBO_FONT, wxT("Set &Italic font"), wxPoint(380,130), wxSize(140,30) );
  691. (void)new wxButton( panel, ID_COMBO_SET_TEXT, wxT("Set 'Hi!' at #2"), wxPoint(380,180), wxSize(140,30) );
  692. (void)new wxCheckBox( panel, ID_COMBO_ENABLE, wxT("&Disable"), wxPoint(20,130), wxSize(140,30) );
  693. m_book->AddPage(panel, wxT("wxComboBox"), false, Image_Combo);
  694. // ------------------------------------------------------------------------
  695. // radio box
  696. // ------------------------------------------------------------------------
  697. wxString choices2[] =
  698. {
  699. wxT("First"), wxT("Second"),
  700. /* "Third",
  701. "Fourth", "Fifth", "Sixth",
  702. "Seventh", "Eighth", "Nineth", "Tenth" */
  703. };
  704. panel = new wxPanel(m_book);
  705. wxGridBagSizer* radio_page_sizer = new wxGridBagSizer(5, 5);
  706. m_radio = new wxRadioBox(panel, ID_RADIOBOX, wxT("T&his"),
  707. wxPoint(10,10), wxDefaultSize,
  708. WXSIZEOF(choices), choices,
  709. 1, wxRA_SPECIFY_COLS );
  710. MyRadioBox* mybox = new MyRadioBox(panel, ID_RADIOBOX2, wxT("&That"),
  711. wxPoint(10,160), wxDefaultSize,
  712. WXSIZEOF(choices2), choices2,
  713. 1, wxRA_SPECIFY_ROWS );
  714. radio_page_sizer->Add( m_radio, wxGBPosition(0,0), wxGBSpan(2,1) );
  715. radio_page_sizer->Add( mybox, wxGBPosition(2,0), wxGBSpan(2,1) );
  716. #if wxUSE_HELP
  717. for (unsigned int item = 0; item < WXSIZEOF(choices); ++item)
  718. m_radio->SetItemHelpText( item, wxString::Format( wxT("Help text for \"%s\""),
  719. choices[item].c_str() ) );
  720. // erase help text for the second item
  721. m_radio->SetItemHelpText( 1, wxT("") );
  722. // set default help text for control
  723. m_radio->SetHelpText( wxT("Default helptext for wxRadioBox") );
  724. #endif // wxUSE_HELP
  725. wxButton* select_two = new wxButton ( panel, ID_RADIOBOX_SEL_NUM, wxT("Select #&2") );
  726. wxButton* select_this = new wxButton ( panel, ID_RADIOBOX_SEL_STR, wxT("&Select 'This'") );
  727. m_fontButton = new wxButton ( panel, ID_SET_FONT, wxT("Set &more Italic font") );
  728. wxButton* set_italic = new wxButton ( panel, ID_RADIOBOX_FONT, wxT("Set &Italic font") );
  729. wxCheckBox* disable_cb = new wxCheckBox( panel, ID_RADIOBOX_ENABLE, wxT("&Disable") );
  730. wxRadioButton *rb = new wxRadioButton( panel, ID_RADIOBUTTON_1, wxT("Radiobutton1"),
  731. wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
  732. wxRadioButton *rb2 = new wxRadioButton( panel, ID_RADIOBUTTON_2, wxT("&Radiobutton2"),
  733. wxDefaultPosition, wxDefaultSize );
  734. rb->SetValue( false );
  735. radio_page_sizer->Add( select_two, wxGBPosition(0, 1), wxDefaultSpan, wxALL , 10 );
  736. radio_page_sizer->Add( select_this, wxGBPosition(1, 1), wxDefaultSpan, wxALL , 10 );
  737. radio_page_sizer->Add( m_fontButton, wxGBPosition(0, 2), wxDefaultSpan, wxALL , 10 );
  738. radio_page_sizer->Add( set_italic, wxGBPosition(1, 2), wxDefaultSpan, wxALL , 10 );
  739. radio_page_sizer->Add( disable_cb, wxGBPosition(2, 2), wxDefaultSpan, wxLEFT | wxRIGHT, 10 );
  740. radio_page_sizer->Add( rb, wxGBPosition(3, 1), wxDefaultSpan, wxLEFT | wxRIGHT, 10 );
  741. radio_page_sizer->Add( rb2, wxGBPosition(3, 2), wxDefaultSpan, wxLEFT | wxRIGHT, 10 );
  742. panel->SetSizer( radio_page_sizer );
  743. m_book->AddPage(panel, wxT("wxRadioBox"), false, Image_Radio);
  744. // ------------------------------------------------------------------------
  745. // gauge and slider
  746. // ------------------------------------------------------------------------
  747. #if wxUSE_SLIDER && wxUSE_GAUGE
  748. panel = new wxPanel(m_book);
  749. wxBoxSizer *gauge_page_vsizer = new wxBoxSizer( wxVERTICAL );
  750. wxBoxSizer *gauge_page_first_row_sizer = new wxBoxSizer( wxHORIZONTAL );
  751. wxStaticBoxSizer *gauge_sizer = new wxStaticBoxSizer( wxHORIZONTAL, panel, wxT("&wxGauge and wxSlider") );
  752. gauge_page_first_row_sizer->Add( gauge_sizer, 0, wxALL, 5 );
  753. wxBoxSizer *sz = new wxBoxSizer( wxVERTICAL );
  754. gauge_sizer->Add( sz );
  755. m_gauge = new wxGauge( panel, wxID_ANY, 200, wxDefaultPosition, wxSize(155, 30), wxGA_HORIZONTAL|wxNO_BORDER );
  756. sz->Add( m_gauge, 0, wxALL, 10 );
  757. m_slider = new wxSlider( panel, ID_SLIDER, 0, 0, 200,
  758. wxDefaultPosition, wxSize(155,wxDefaultCoord),
  759. wxSL_AUTOTICKS | wxSL_LABELS);
  760. m_slider->SetTickFreq(40);
  761. sz->Add( m_slider, 0, wxALL, 10 );
  762. m_gaugeVert = new wxGauge( panel, wxID_ANY, 100,
  763. wxDefaultPosition, wxSize(wxDefaultCoord, 90),
  764. wxGA_VERTICAL | wxGA_SMOOTH | wxNO_BORDER );
  765. gauge_sizer->Add( m_gaugeVert, 0, wxALL, 10 );
  766. wxStaticBox *sb = new wxStaticBox( panel, wxID_ANY, wxT("&Explanation"),
  767. wxDefaultPosition, wxDefaultSize ); //, wxALIGN_CENTER );
  768. wxStaticBoxSizer *wrapping_sizer = new wxStaticBoxSizer( sb, wxVERTICAL );
  769. gauge_page_first_row_sizer->Add( wrapping_sizer, 0, wxALL, 5 );
  770. #ifdef __WXMOTIF__
  771. // No wrapping text in wxStaticText yet :-(
  772. m_wrappingText = new wxStaticText( panel, wxID_ANY,
  773. wxT("Drag the slider!"),
  774. wxPoint(250,30),
  775. wxSize(240, wxDefaultCoord)
  776. );
  777. #else
  778. m_wrappingText = new wxStaticText( panel, wxID_ANY,
  779. wxT("In order see the gauge (aka progress bar) ")
  780. wxT("control do something you have to drag the ")
  781. wxT("handle of the slider to the right.")
  782. wxT("\n\n")
  783. wxT("This is also supposed to demonstrate how ")
  784. wxT("to use static controls with line wrapping."),
  785. wxDefaultPosition,
  786. wxSize(240, wxDefaultCoord)
  787. );
  788. #endif
  789. wrapping_sizer->Add( m_wrappingText );
  790. wxStaticBoxSizer *non_wrapping_sizer = new wxStaticBoxSizer( wxVERTICAL, panel, wxT("Non-wrapping") );
  791. gauge_page_first_row_sizer->Add( non_wrapping_sizer, 0, wxALL, 5 );
  792. m_nonWrappingText = new wxStaticText( panel, wxID_ANY,
  793. wxT("This static text has two lines.\nThey do not wrap."),
  794. wxDefaultPosition,
  795. wxDefaultSize
  796. );
  797. non_wrapping_sizer->Add( m_nonWrappingText );
  798. gauge_page_vsizer->Add( gauge_page_first_row_sizer, 1 );
  799. wxBoxSizer *gauge_page_second_row_sizer = new wxBoxSizer( wxHORIZONTAL );
  800. int initialSpinValue = -5;
  801. wxString s;
  802. s << initialSpinValue;
  803. m_spintext = new wxTextCtrl( panel, wxID_ANY, s );
  804. gauge_page_second_row_sizer->Add( m_spintext, 0, wxALL, 5 );
  805. #if wxUSE_SPINBTN
  806. m_spinbutton = new wxSpinButton( panel, ID_SPIN );
  807. m_spinbutton->SetRange(-40,30);
  808. m_spinbutton->SetValue(initialSpinValue);
  809. gauge_page_second_row_sizer->Add( m_spinbutton, 0, wxALL, 5 );
  810. #endif // wxUSE_SPINBTN
  811. #if wxUSE_SPINCTRL
  812. m_spinctrl = new wxSpinCtrl( panel, ID_SPINCTRL, wxEmptyString );
  813. m_spinctrl->SetRange(-10,30);
  814. m_spinctrl->SetValue(15);
  815. gauge_page_second_row_sizer->Add( m_spinctrl, 0, wxALL, 5 );
  816. #endif // wxUSE_SPINCTRL
  817. #if wxUSE_SPINBTN
  818. #if wxUSE_PROGRESSDLG
  819. m_btnProgress = new wxButton( panel, ID_BTNPROGRESS, wxT("&Show progress dialog") );
  820. gauge_page_second_row_sizer->Add( m_btnProgress, 0, wxALL, 5 );
  821. #endif // wxUSE_PROGRESSDLG
  822. #endif // wxUSE_SPINBTN
  823. wxButton* newTextButton = new wxButton( panel, ID_BTNNEWTEXT, wxT("New text"));
  824. gauge_page_second_row_sizer->Add( newTextButton, 0, wxALL, 5 );
  825. gauge_page_vsizer->Add(gauge_page_second_row_sizer, 1);
  826. panel->SetSizer( gauge_page_vsizer );
  827. m_book->AddPage(panel, wxT("wxGauge"), false, Image_Gauge);
  828. #endif // wxUSE_SLIDER && wxUSE_GAUGE
  829. // ------------------------------------------------------------------------
  830. // wxBitmapXXX
  831. // ------------------------------------------------------------------------
  832. panel = new wxPanel(m_book);
  833. #if !defined(__WXMOTIF__) // wxStaticBitmap not working under Motif yet.
  834. wxIcon icon = wxArtProvider::GetIcon(wxART_INFORMATION);
  835. (void) new wxStaticBitmap( panel, wxID_ANY, icon, wxPoint(10, 10) );
  836. // VZ: don't leak memory
  837. // bmpStatic = new wxStaticBitmap(panel, wxID_ANY, wxNullIcon, wxPoint(50, 10));
  838. // bmpStatic->SetIcon(wxArtProvider::GetIcon(wxART_QUESTION));
  839. #endif // !Motif
  840. wxBitmap bitmap( 100, 100 );
  841. wxMemoryDC dc;
  842. dc.SelectObject( bitmap );
  843. dc.SetBackground(*wxGREEN);
  844. dc.SetPen(*wxRED_PEN);
  845. dc.Clear();
  846. dc.DrawEllipse(5, 5, 90, 90);
  847. dc.DrawText(wxT("Bitmap"), 30, 40);
  848. dc.SelectObject( wxNullBitmap );
  849. wxPanel *panel2 = new wxPanel(panel, -1, wxPoint(100, 0), wxSize(100, 200));
  850. (void)new wxBitmapButton(panel2, ID_BITMAP_BTN, bitmap, wxPoint(0, 20));
  851. (void)new wxToggleButton(panel2, ID_BITMAP_BTN_ENABLE,
  852. wxT("Enable/disable &bitmap"), wxPoint(0, 140));
  853. #if defined(__WXMSW__) || defined(__WXMOTIF__)
  854. // test for masked bitmap display
  855. bitmap = wxBitmap(wxT("test2.bmp"), wxBITMAP_TYPE_BMP);
  856. if (bitmap.IsOk())
  857. {
  858. bitmap.SetMask(new wxMask(bitmap, *wxBLUE));
  859. (void)new wxStaticBitmap(panel, wxID_ANY, bitmap, wxPoint(300, 120));
  860. }
  861. #endif
  862. wxBitmap bmp1(wxArtProvider::GetBitmap(wxART_INFORMATION)),
  863. bmp2(wxArtProvider::GetBitmap(wxART_WARNING)),
  864. bmp3(wxArtProvider::GetBitmap(wxART_QUESTION));
  865. wxBitmapButton *bmpBtn = new wxBitmapButton
  866. (
  867. panel, wxID_ANY,
  868. bmp1,
  869. wxPoint(30, 70)
  870. );
  871. bmpBtn->SetBitmapSelected(bmp2);
  872. bmpBtn->SetBitmapFocus(bmp3);
  873. (void)new wxToggleButton(panel, ID_BUTTON_LABEL,
  874. wxT("&Toggle label"), wxPoint(250, 20));
  875. m_label = new wxStaticText(panel, wxID_ANY, wxT("Label with some long text"),
  876. wxPoint(250, 60), wxDefaultSize,
  877. wxALIGN_RIGHT /*| wxST_NO_AUTORESIZE*/);
  878. m_label->SetForegroundColour( *wxBLUE );
  879. m_book->AddPage(panel, wxT("wxBitmapXXX"));
  880. // ------------------------------------------------------------------------
  881. // sizer page
  882. // ------------------------------------------------------------------------
  883. panel = new wxPanel(m_book);
  884. wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
  885. wxStaticBoxSizer *csizer =
  886. new wxStaticBoxSizer (new wxStaticBox (panel, wxID_ANY, wxT("Show Buttons")), wxHORIZONTAL );
  887. wxCheckBox *check1, *check2, *check3, *check4, *check14, *checkBig;
  888. check1 = new wxCheckBox (panel, ID_SIZER_CHECK1, wxT("1"));
  889. check1->SetValue (true);
  890. csizer->Add (check1);
  891. check2 = new wxCheckBox (panel, ID_SIZER_CHECK2, wxT("2"));
  892. check2->SetValue (true);
  893. csizer->Add (check2);
  894. check3 = new wxCheckBox (panel, ID_SIZER_CHECK3, wxT("3"));
  895. check3->SetValue (true);
  896. csizer->Add (check3);
  897. check4 = new wxCheckBox (panel, ID_SIZER_CHECK4, wxT("4"));
  898. check4->SetValue (true);
  899. csizer->Add (check4);
  900. check14 = new wxCheckBox (panel, ID_SIZER_CHECK14, wxT("1-4"));
  901. check14->SetValue (true);
  902. csizer->Add (check14);
  903. checkBig = new wxCheckBox (panel, ID_SIZER_CHECKBIG, wxT("Big"));
  904. checkBig->SetValue (true);
  905. csizer->Add (checkBig);
  906. sizer->Add (csizer);
  907. m_hsizer = new wxBoxSizer( wxHORIZONTAL );
  908. m_buttonSizer = new wxBoxSizer (wxVERTICAL);
  909. m_sizerBtn1 = new wxButton(panel, wxID_ANY, wxT("Test Button &1 (tab order 1)") );
  910. m_buttonSizer->Add( m_sizerBtn1, 0, wxALL, 10 );
  911. m_sizerBtn2 = new wxButton(panel, wxID_ANY, wxT("Test Button &2 (tab order 3)") );
  912. m_buttonSizer->Add( m_sizerBtn2, 0, wxALL, 10 );
  913. m_sizerBtn3 = new wxButton(panel, wxID_ANY, wxT("Test Button &3 (tab order 2)") );
  914. m_buttonSizer->Add( m_sizerBtn3, 0, wxALL, 10 );
  915. m_sizerBtn4 = new wxButton(panel, wxID_ANY, wxT("Test Button &4 (tab order 4)") );
  916. m_buttonSizer->Add( m_sizerBtn4, 0, wxALL, 10 );
  917. m_sizerBtn3->MoveBeforeInTabOrder(m_sizerBtn2);
  918. m_hsizer->Add (m_buttonSizer);
  919. m_hsizer->Add( 20,20, 1 );
  920. m_bigBtn = new wxButton(panel, wxID_ANY, wxT("Multiline\nbutton") );
  921. m_hsizer->Add( m_bigBtn , 3, wxGROW|wxALL, 10 );
  922. sizer->Add (m_hsizer, 1, wxGROW);
  923. panel->SetSizer( sizer );
  924. m_book->AddPage(panel, wxT("wxSizer"));
  925. // set the sizer for the panel itself
  926. sizer = new wxBoxSizer(wxVERTICAL);
  927. sizer->Add(m_book, wxSizerFlags().Border().Expand());
  928. sizer->Add(m_text, wxSizerFlags(1).Border().Expand());
  929. SetSizer(sizer);
  930. #if wxUSE_TOOLTIPS
  931. SetAllToolTips();
  932. #endif // wxUSE_TOOLTIPS
  933. }
  934. #if wxUSE_TOOLTIPS
  935. namespace
  936. {
  937. void ResetToolTip(wxWindow *win, const char *tip)
  938. {
  939. wxCHECK_RET( win, "NULL window?" );
  940. win->UnsetToolTip();
  941. win->SetToolTip(tip);
  942. }
  943. }
  944. void MyPanel::SetAllToolTips()
  945. {
  946. ResetToolTip(FindWindow(ID_LISTBOX_FONT), "Press here to set italic font");
  947. ResetToolTip(m_checkbox, "Click here to disable the listbox");
  948. ResetToolTip(m_listbox, "This is a list box");
  949. ResetToolTip(m_combo, "This is a natural\ncombobox - can you believe me?");
  950. ResetToolTip(m_slider, "This is a sliding slider");
  951. ResetToolTip(FindWindow(ID_RADIOBOX2), "Ever seen a radiobox?");
  952. //ResetToolTip(m_radio, "Tooltip for the entire radiobox");
  953. for ( unsigned int nb = 0; nb < m_radio->GetCount(); nb++ )
  954. {
  955. m_radio->SetItemToolTip(nb, "");
  956. m_radio->SetItemToolTip(nb, "tooltip for\n" + m_radio->GetString(nb));
  957. }
  958. // remove the tooltip for one of the items
  959. m_radio->SetItemToolTip(2, "");
  960. }
  961. #endif // wxUSE_TOOLTIPS
  962. void MyPanel::OnIdle(wxIdleEvent& event)
  963. {
  964. static const int INVALID_SELECTION = -2;
  965. static int s_selCombo = INVALID_SELECTION;
  966. if (!m_combo || !m_choice)
  967. {
  968. event.Skip();
  969. return;
  970. }
  971. int sel = m_combo->GetSelection();
  972. if ( sel != s_selCombo )
  973. {
  974. if ( s_selCombo != INVALID_SELECTION )
  975. {
  976. wxLogMessage(wxT("EVT_IDLE: combobox selection changed from %d to %d"),
  977. s_selCombo, sel);
  978. }
  979. s_selCombo = sel;
  980. }
  981. static int s_selChoice = INVALID_SELECTION;
  982. sel = m_choice->GetSelection();
  983. if ( sel != s_selChoice )
  984. {
  985. if ( s_selChoice != INVALID_SELECTION )
  986. {
  987. wxLogMessage(wxT("EVT_IDLE: choice selection changed from %d to %d"),
  988. s_selChoice, sel);
  989. }
  990. s_selChoice = sel;
  991. }
  992. event.Skip();
  993. }
  994. void MyPanel::OnPageChanging( wxBookCtrlEvent &event )
  995. {
  996. int selOld = event.GetOldSelection();
  997. if ( selOld == 2 )
  998. {
  999. if ( wxMessageBox(wxT("This demonstrates how a program may prevent the\n")
  1000. wxT("page change from taking place - if you select\n")
  1001. wxT("[No] the current page will stay the third one\n"),
  1002. wxT("Control sample"),
  1003. wxICON_QUESTION | wxYES_NO, this) != wxYES )
  1004. {
  1005. event.Veto();
  1006. return;
  1007. }
  1008. }
  1009. *m_text << wxT("Book selection is being changed from ") << selOld
  1010. << wxT(" to ") << event.GetSelection()
  1011. << wxT(" (current page from book is ")
  1012. << m_book->GetSelection() << wxT(")\n");
  1013. }
  1014. void MyPanel::OnPageChanged( wxBookCtrlEvent &event )
  1015. {
  1016. *m_text << wxT("Book selection is now ") << event.GetSelection()
  1017. << wxT(" (from book: ") << m_book->GetSelection()
  1018. << wxT(")\n");
  1019. }
  1020. void MyPanel::OnTestButton(wxCommandEvent& event)
  1021. {
  1022. wxLogMessage(wxT("Button %c clicked."),
  1023. event.GetId() == ID_BUTTON_TEST1 ? wxT('1') : wxT('2'));
  1024. }
  1025. void MyPanel::OnBmpButton(wxCommandEvent& WXUNUSED(event))
  1026. {
  1027. wxLogMessage(wxT("Bitmap button clicked."));
  1028. }
  1029. void MyPanel::OnBmpButtonToggle(wxCommandEvent& event)
  1030. {
  1031. FindWindow(ID_BITMAP_BTN)->Enable(!event.IsChecked());
  1032. }
  1033. void MyPanel::OnChangeColour(wxCommandEvent& WXUNUSED(event))
  1034. {
  1035. static wxColour s_colOld;
  1036. SetThemeEnabled(false);
  1037. // test panel colour changing and propagation to the subcontrols
  1038. if ( s_colOld.IsOk() )
  1039. {
  1040. SetBackgroundColour(s_colOld);
  1041. s_colOld = wxNullColour;
  1042. m_lbSelectThis->SetForegroundColour(wxNullColour);
  1043. m_lbSelectThis->SetBackgroundColour(wxNullColour);
  1044. }
  1045. else
  1046. {
  1047. s_colOld = *wxRED;
  1048. SetBackgroundColour(*wxWHITE);
  1049. m_lbSelectThis->SetForegroundColour(wxT("white"));
  1050. m_lbSelectThis->SetBackgroundColour(wxT("red"));
  1051. }
  1052. m_lbSelectThis->Refresh();
  1053. Refresh();
  1054. }
  1055. void MyPanel::OnListBox( wxCommandEvent &event )
  1056. {
  1057. wxListBox *listbox = event.GetId() == ID_LISTBOX ? m_listbox
  1058. : m_listboxSorted;
  1059. bool deselect = false;
  1060. if (listbox->HasFlag(wxLB_MULTIPLE) || listbox->HasFlag(wxLB_EXTENDED))
  1061. {
  1062. deselect = !event.IsSelection();
  1063. if (deselect)
  1064. m_text->AppendText( wxT("ListBox deselection event\n") );
  1065. }
  1066. m_text->AppendText( wxT("ListBox event selection string is: '") );
  1067. m_text->AppendText( event.GetString() );
  1068. m_text->AppendText( wxT("'\n") );
  1069. // can't use GetStringSelection() with multiple selections, there could be
  1070. // more than one of them
  1071. if ( !listbox->HasFlag(wxLB_MULTIPLE) && !listbox->HasFlag(wxLB_EXTENDED) )
  1072. {
  1073. m_text->AppendText( wxT("ListBox control selection string is: '") );
  1074. m_text->AppendText( listbox->GetStringSelection() );
  1075. m_text->AppendText( wxT("'\n") );
  1076. }
  1077. wxStringClientData *obj = ((wxStringClientData *)event.GetClientObject());
  1078. m_text->AppendText( wxT("ListBox event client data string is: '") );
  1079. if (obj) // BC++ doesn't like use of '? .. : .. ' in this context
  1080. m_text->AppendText( obj->GetData() );
  1081. else
  1082. m_text->AppendText( wxString(wxT("none")) );
  1083. m_text->AppendText( wxT("'\n") );
  1084. m_text->AppendText( wxT("ListBox control client data string is: '") );
  1085. obj = (wxStringClientData *)listbox->GetClientObject(event.GetInt());
  1086. if (obj)
  1087. m_text->AppendText( obj->GetData() );
  1088. else
  1089. m_text->AppendText( wxString(wxT("none")) );
  1090. m_text->AppendText( wxT("'\n") );
  1091. }
  1092. void MyPanel::OnListBoxDoubleClick( wxCommandEvent &event )
  1093. {
  1094. m_text->AppendText( wxT("ListBox double click string is: ") );
  1095. m_text->AppendText( event.GetString() );
  1096. m_text->AppendText( wxT("\n") );
  1097. }
  1098. void MyPanel::OnListBoxButtons( wxCommandEvent &event )
  1099. {
  1100. switch (event.GetId())
  1101. {
  1102. case ID_LISTBOX_ENABLE:
  1103. {
  1104. m_text->AppendText(wxT("Checkbox clicked.\n"));
  1105. #if wxUSE_TOOLTIPS
  1106. wxCheckBox *cb = (wxCheckBox*)event.GetEventObject();
  1107. if (event.GetInt())
  1108. cb->SetToolTip( wxT("Click to enable listbox") );
  1109. else
  1110. cb->SetToolTip( wxT("Click to disable listbox") );
  1111. #endif // wxUSE_TOOLTIPS
  1112. m_listbox->Enable( event.GetInt() == 0 );
  1113. m_lbSelectThis->Enable( event.GetInt() == 0 );
  1114. m_lbSelectNum->Enable( event.GetInt() == 0 );
  1115. m_listboxSorted->Enable( event.GetInt() == 0 );
  1116. FindWindow(ID_CHANGE_COLOUR)->Enable( event.GetInt() == 0 );
  1117. break;
  1118. }
  1119. case ID_LISTBOX_SEL_NUM:
  1120. {
  1121. if (m_listbox->GetCount() > 2)
  1122. m_listbox->SetSelection( 2 );
  1123. if (m_listboxSorted->GetCount() > 2)
  1124. m_listboxSorted->SetSelection( 2 );
  1125. m_lbSelectThis->WarpPointer( 40, 14 );
  1126. break;
  1127. }
  1128. case ID_LISTBOX_SEL_STR:
  1129. {
  1130. if (m_listbox->FindString(wxT("This")) != wxNOT_FOUND)
  1131. m_listbox->SetStringSelection( wxT("This") );
  1132. if (m_listboxSorted->FindString(wxT("This")) != wxNOT_FOUND)
  1133. m_listboxSorted->SetStringSelection( wxT("This") );
  1134. m_lbSelectNum->WarpPointer( 40, 14 );
  1135. break;
  1136. }
  1137. case ID_LISTBOX_CLEAR:
  1138. {
  1139. m_listbox->Clear();
  1140. m_listboxSorted->Clear();
  1141. break;
  1142. }
  1143. case ID_LISTBOX_APPEND:
  1144. {
  1145. m_listbox->Append( wxT("Hi kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk!") );
  1146. m_listboxSorted->Append( wxT("Hi hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!") );
  1147. break;
  1148. }
  1149. case ID_LISTBOX_DELETE:
  1150. {
  1151. int idx;
  1152. idx = m_listbox->GetSelection();
  1153. if ( idx != wxNOT_FOUND )
  1154. m_listbox->Delete( idx );
  1155. idx = m_listboxSorted->GetSelection();
  1156. if ( idx != wxNOT_FOUND )
  1157. m_listboxSorted->Delete( idx );
  1158. break;
  1159. }
  1160. case ID_LISTBOX_FONT:
  1161. {
  1162. m_listbox->SetFont( *wxITALIC_FONT );
  1163. m_listboxSorted->SetFont( *wxITALIC_FONT );
  1164. m_checkbox->SetFont( *wxITALIC_FONT );
  1165. break;
  1166. }
  1167. }
  1168. }
  1169. #if wxUSE_CHOICE
  1170. static wxString GetDataString(wxClientData *data)
  1171. {
  1172. return data ? static_cast<wxStringClientData *>(data)->GetData()
  1173. : wxString("none");
  1174. }
  1175. void MyPanel::OnChoice( wxCommandEvent &event )
  1176. {
  1177. wxChoice *choice = event.GetId() == ID_CHOICE ? m_choice
  1178. : m_choiceSorted;
  1179. const int sel = choice->GetSelection();
  1180. wxClientData *dataEvt = event.GetClientObject(),
  1181. *dataCtrl = choice->GetClientObject(sel);
  1182. wxLogMessage(wxT("EVT_CHOICE: item %d/%d (event/control), ")
  1183. wxT("string \"%s\"/\"%s\", ")
  1184. wxT("data \"%s\"/\"%s\""),
  1185. (int)event.GetInt(),
  1186. sel,
  1187. event.GetString(),
  1188. choice->GetStringSelection(),
  1189. GetDataString(dataEvt),
  1190. GetDataString(dataCtrl));
  1191. }
  1192. void MyPanel::OnChoiceButtons( wxCommandEvent &event )
  1193. {
  1194. switch (event.GetId())
  1195. {
  1196. case ID_CHOICE_ENABLE:
  1197. {
  1198. m_choice->Enable( event.GetInt() == 0 );
  1199. m_choiceSorted->Enable( event.GetInt() == 0 );
  1200. break;
  1201. }
  1202. case ID_CHOICE_SEL_NUM:
  1203. {
  1204. m_choice->SetSelection( 2 );
  1205. m_choiceSorted->SetSelection( 2 );
  1206. break;
  1207. }
  1208. case ID_CHOICE_SEL_STR:
  1209. {
  1210. m_choice->SetStringSelection( wxT("This") );
  1211. m_choiceSorted->SetStringSelection( wxT("This") );
  1212. break;
  1213. }
  1214. case ID_CHOICE_CLEAR:
  1215. {
  1216. m_choice->Clear();
  1217. m_choiceSorted->Clear();
  1218. break;
  1219. }
  1220. case ID_CHOICE_APPEND:
  1221. {
  1222. m_choice->Append( wxT("Hi!") );
  1223. m_choiceSorted->Append( wxT("Hi!") );
  1224. break;
  1225. }
  1226. case ID_CHOICE_DELETE:
  1227. {
  1228. int idx = m_choice->GetSelection();
  1229. if ( idx != wxNOT_FOUND )
  1230. m_choice->Delete( idx );
  1231. idx = m_choiceSorted->GetSelection();
  1232. if ( idx != wxNOT_FOUND )
  1233. m_choiceSorted->Delete( idx );
  1234. break;
  1235. }
  1236. case ID_CHOICE_FONT:
  1237. {
  1238. m_choice->SetFont( *wxITALIC_FONT );
  1239. m_choiceSorted->SetFont( *wxITALIC_FONT );
  1240. break;
  1241. }
  1242. }
  1243. }
  1244. #endif // wxUSE_CHOICE
  1245. void MyPanel::OnCombo( wxCommandEvent &event )
  1246. {
  1247. if (!m_combo)
  1248. return;
  1249. wxLogMessage(wxT("EVT_COMBOBOX: item %d/%d (event/control), string \"%s\"/\"%s\""),
  1250. (int)event.GetInt(),
  1251. m_combo->GetSelection(),
  1252. event.GetString().c_str(),
  1253. m_combo->GetStringSelection().c_str());
  1254. }
  1255. void MyPanel::OnComboTextChanged(wxCommandEvent& event)
  1256. {
  1257. if (m_combo)
  1258. {
  1259. wxLogMessage(wxT("EVT_TEXT for the combobox: \"%s\" (event) or \"%s\" (control)."),
  1260. event.GetString().c_str(),
  1261. m_combo->GetValue().c_str());
  1262. }
  1263. }
  1264. void MyPanel::OnComboTextEnter(wxCommandEvent& WXUNUSED(event))
  1265. {
  1266. if (m_combo)
  1267. {
  1268. wxLogMessage(wxT("Enter pressed in the combobox: value is '%s'."),
  1269. m_combo->GetValue().c_str());
  1270. }
  1271. }
  1272. void MyPanel::OnComboButtons( wxCommandEvent &event )
  1273. {
  1274. switch (event.GetId())
  1275. {
  1276. case ID_COMBO_ENABLE:
  1277. {
  1278. m_combo->Enable( event.GetInt() == 0 );
  1279. break;
  1280. }
  1281. case ID_COMBO_SEL_NUM:
  1282. {
  1283. m_combo->SetSelection( 2 );
  1284. break;
  1285. }
  1286. case ID_COMBO_SEL_STR:
  1287. {
  1288. m_combo->SetStringSelection( wxT("This") );
  1289. break;
  1290. }
  1291. case ID_COMBO_CLEAR:
  1292. {
  1293. m_combo->Clear();
  1294. break;
  1295. }
  1296. case ID_COMBO_APPEND:
  1297. {
  1298. m_combo->Append( wxT("Hi!") );
  1299. break;
  1300. }
  1301. case ID_COMBO_DELETE:
  1302. {
  1303. int idx = m_combo->GetSelection();
  1304. m_combo->Delete( idx );
  1305. break;
  1306. }
  1307. case ID_COMBO_FONT:
  1308. {
  1309. m_combo->SetFont( *wxITALIC_FONT );
  1310. break;
  1311. }
  1312. case ID_COMBO_SET_TEXT:
  1313. {
  1314. m_combo->SetString( 2, wxT("Hi!") );
  1315. break;
  1316. }
  1317. }
  1318. }
  1319. void MyPanel::OnRadio( wxCommandEvent &event )
  1320. {
  1321. m_text->AppendText( wxT("RadioBox selection string is: ") );
  1322. m_text->AppendText( event.GetString() );
  1323. m_text->AppendText( wxT("\n") );
  1324. }
  1325. void MyPanel::OnRadioButton1( wxCommandEvent & WXUNUSED(event) )
  1326. {
  1327. wxMessageBox(wxT("First wxRadioButton selected."), wxT("wxControl sample"));
  1328. }
  1329. void MyPanel::OnRadioButton2( wxCommandEvent & WXUNUSED(event) )
  1330. {
  1331. m_text->AppendText(wxT("Second wxRadioButton selected.\n"));
  1332. }
  1333. void MyPanel::OnRadioButtons( wxCommandEvent &event )
  1334. {
  1335. switch (event.GetId())
  1336. {
  1337. case ID_RADIOBOX_ENABLE:
  1338. m_radio->Enable( event.GetInt() == 0 );
  1339. break;
  1340. case ID_RADIOBOX_SEL_NUM:
  1341. m_radio->SetSelection( 2 );
  1342. break;
  1343. case ID_RADIOBOX_SEL_STR:
  1344. m_radio->SetStringSelection( wxT("This") );
  1345. break;
  1346. case ID_RADIOBOX_FONT:
  1347. m_radio->SetFont( *wxITALIC_FONT );
  1348. break;
  1349. }
  1350. }
  1351. void MyPanel::OnSetFont( wxCommandEvent &WXUNUSED(event) )
  1352. {
  1353. m_fontButton->SetFont( *wxITALIC_FONT );
  1354. m_text->SetFont( *wxITALIC_FONT );
  1355. }
  1356. void MyPanel::OnUpdateLabel( wxCommandEvent &event )
  1357. {
  1358. m_label->SetLabel(event.GetInt() ? wxT("Very very very very very long text.")
  1359. : wxT("Shorter text."));
  1360. }
  1361. #if wxUSE_SLIDER
  1362. void MyPanel::OnSliderUpdate( wxCommandEvent &WXUNUSED(event) )
  1363. {
  1364. #if wxUSE_GAUGE
  1365. m_gauge->SetValue( m_slider->GetValue() );
  1366. m_gaugeVert->SetValue( m_slider->GetValue() / 2 );
  1367. #endif // wxUSE_GAUGE
  1368. }
  1369. #endif // wxUSE_SLIDER
  1370. #if wxUSE_SPINCTRL
  1371. void MyPanel::OnSpinCtrlText(wxCommandEvent& event)
  1372. {
  1373. if ( m_spinctrl )
  1374. {
  1375. wxString s;
  1376. s.Printf( wxT("Spin ctrl text changed: now %d (from event: %s)\n"),
  1377. m_spinctrl->GetValue(), event.GetString().c_str() );
  1378. m_text->AppendText(s);
  1379. }
  1380. }
  1381. void MyPanel::OnSpinCtrl(wxSpinEvent& event)
  1382. {
  1383. if ( m_spinctrl )
  1384. {
  1385. wxString s;
  1386. s.Printf( wxT("Spin ctrl changed: now %d (from event: %d)\n"),
  1387. m_spinctrl->GetValue(), event.GetInt() );
  1388. m_text->AppendText(s);
  1389. }
  1390. }
  1391. void MyPanel::OnSpinCtrlUp(wxSpinEvent& event)
  1392. {
  1393. if ( m_spinctrl )
  1394. {
  1395. m_text->AppendText( wxString::Format(
  1396. wxT("Spin up: %d (from event: %d)\n"),
  1397. m_spinctrl->GetValue(), event.GetInt() ) );
  1398. }
  1399. }
  1400. void MyPanel::OnSpinCtrlDown(wxSpinEvent& event)
  1401. {
  1402. if ( m_spinctrl )
  1403. {
  1404. m_text->AppendText( wxString::Format(
  1405. wxT("Spin down: %d (from event: %d)\n"),
  1406. m_spinctrl->GetValue(), event.GetInt() ) );
  1407. }
  1408. }
  1409. #endif // wxUSE_SPINCTRL
  1410. #if wxUSE_SPINBTN
  1411. void MyPanel::OnSpinUp( wxSpinEvent &event )
  1412. {
  1413. wxString value;
  1414. value.Printf( wxT("Spin control up: current = %d\n"),
  1415. m_spinbutton->GetValue());
  1416. if ( event.GetPosition() > 17 )
  1417. {
  1418. value += wxT("Preventing the spin button from going above 17.\n");
  1419. event.Veto();
  1420. }
  1421. m_text->AppendText(value);
  1422. }
  1423. void MyPanel::OnSpinDown( wxSpinEvent &event )
  1424. {
  1425. wxString value;
  1426. value.Printf( wxT("Spin control down: current = %d\n"),
  1427. m_spinbutton->GetValue());
  1428. if ( event.GetPosition() < -17 )
  1429. {
  1430. value += wxT("Preventing the spin button from going below -17.\n");
  1431. event.Veto();
  1432. }
  1433. m_text->AppendText(value);
  1434. }
  1435. void MyPanel::OnSpinUpdate( wxSpinEvent &event )
  1436. {
  1437. wxString value;
  1438. value.Printf( wxT("%d"), event.GetPosition() );
  1439. m_spintext->SetValue( value );
  1440. value.Printf( wxT("Spin control range: (%d, %d), current = %d\n"),
  1441. m_spinbutton->GetMin(), m_spinbutton->GetMax(),
  1442. m_spinbutton->GetValue());
  1443. m_text->AppendText(value);
  1444. }
  1445. void MyPanel::OnNewText( wxCommandEvent& /* event */)
  1446. {
  1447. m_nonWrappingText->SetLabel( wxT("This text is short\nbut still spans\nover three lines.") );
  1448. m_wrappingText->SetLabel( wxT("This text is short but will still be wrapped if it is too long.") );
  1449. m_wrappingText->GetParent()->Layout();
  1450. }
  1451. #if wxUSE_PROGRESSDLG
  1452. void MyPanel::OnUpdateShowProgress( wxUpdateUIEvent& event )
  1453. {
  1454. event.Enable( m_spinbutton->GetValue() > 0 );
  1455. }
  1456. void MyPanel::OnShowProgress( wxCommandEvent& WXUNUSED(event) )
  1457. {
  1458. int max = m_spinbutton->GetValue();
  1459. if ( max <= 0 )
  1460. {
  1461. wxLogError(wxT("You must set positive range!"));
  1462. return;
  1463. }
  1464. wxProgressDialog dialog(wxT("Progress dialog example"),
  1465. wxT("An informative message"),
  1466. max, // range
  1467. this, // parent
  1468. wxPD_CAN_ABORT |
  1469. wxPD_AUTO_HIDE |
  1470. wxPD_APP_MODAL |
  1471. wxPD_ELAPSED_TIME |
  1472. wxPD_ESTIMATED_TIME |
  1473. wxPD_REMAINING_TIME);
  1474. bool cont = true;
  1475. for ( int i = 0; i <= max && cont; i++ )
  1476. {
  1477. wxSleep(1);
  1478. if ( i == max )
  1479. {
  1480. cont = dialog.Update(i, wxT("That's all, folks!"));
  1481. }
  1482. else if ( i == max / 2 )
  1483. {
  1484. cont = dialog.Update(i, wxT("Only a half left (very long message)!"));
  1485. }
  1486. else
  1487. {
  1488. cont = dialog.Update(i);
  1489. }
  1490. }
  1491. if ( !cont )
  1492. {
  1493. *m_text << wxT("Progress dialog aborted!\n");
  1494. }
  1495. else
  1496. {
  1497. *m_text << wxT("Countdown from ") << max << wxT(" finished.\n");
  1498. }
  1499. }
  1500. #endif // wxUSE_PROGRESSDLG
  1501. #endif // wxUSE_SPINBTN
  1502. void MyPanel::OnSizerCheck( wxCommandEvent &event)
  1503. {
  1504. switch (event.GetId ()) {
  1505. case ID_SIZER_CHECK1:
  1506. m_buttonSizer->Show (m_sizerBtn1, event.IsChecked ());
  1507. m_buttonSizer->Layout ();
  1508. break;
  1509. case ID_SIZER_CHECK2:
  1510. m_buttonSizer->Show (m_sizerBtn2, event.IsChecked ());
  1511. m_buttonSizer->Layout ();
  1512. break;
  1513. case ID_SIZER_CHECK3:
  1514. m_buttonSizer->Show (m_sizerBtn3, event.IsChecked ());
  1515. m_buttonSizer->Layout ();
  1516. break;
  1517. case ID_SIZER_CHECK4:
  1518. m_buttonSizer->Show (m_sizerBtn4, event.IsChecked ());
  1519. m_buttonSizer->Layout ();
  1520. break;
  1521. case ID_SIZER_CHECK14:
  1522. m_hsizer->Show (m_buttonSizer, event.IsChecked ());
  1523. m_hsizer->Layout ();
  1524. break;
  1525. case ID_SIZER_CHECKBIG:
  1526. m_hsizer->Show (m_bigBtn, event.IsChecked ());
  1527. m_hsizer->Layout ();
  1528. break;
  1529. }
  1530. }
  1531. MyPanel::~MyPanel()
  1532. {
  1533. //wxLog::RemoveTraceMask(wxT("focus"));
  1534. delete wxLog::SetActiveTarget(m_logTargetOld);
  1535. delete m_book->GetImageList();
  1536. }
  1537. //----------------------------------------------------------------------
  1538. // MyFrame
  1539. //----------------------------------------------------------------------
  1540. wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
  1541. EVT_MENU(CONTROLS_QUIT, MyFrame::OnQuit)
  1542. EVT_MENU(CONTROLS_ABOUT, MyFrame::OnAbout)
  1543. EVT_MENU(CONTROLS_CLEAR_LOG, MyFrame::OnClearLog)
  1544. #if wxUSE_TOOLTIPS
  1545. EVT_MENU(CONTROLS_SET_TOOLTIP_DELAY, MyFrame::OnSetTooltipDelay)
  1546. EVT_MENU(CONTROLS_ENABLE_TOOLTIPS, MyFrame::OnToggleTooltips)
  1547. #ifdef __WXMSW__
  1548. EVT_MENU(CONTROLS_SET_TOOLTIPS_MAX_WIDTH, MyFrame::OnSetMaxTooltipWidth)
  1549. #endif // __WXMSW__
  1550. #endif // wxUSE_TOOLTIPS
  1551. EVT_MENU(CONTROLS_ENABLE_ALL, MyFrame::OnEnableAll)
  1552. EVT_MENU(CONTROLS_HIDE_ALL, MyFrame::OnHideAll)
  1553. EVT_MENU(CONTROLS_HIDE_LIST, MyFrame::OnHideList)
  1554. EVT_MENU(CONTROLS_CONTEXT_HELP, MyFrame::OnContextHelp)
  1555. EVT_ICONIZE(MyFrame::OnIconized)
  1556. EVT_MAXIMIZE(MyFrame::OnMaximized)
  1557. EVT_SIZE(MyFrame::OnSize)
  1558. EVT_MOVE(MyFrame::OnMove)
  1559. EVT_IDLE(MyFrame::OnIdle)
  1560. wxEND_EVENT_TABLE()
  1561. MyFrame::MyFrame(const wxChar *title, int x, int y)
  1562. : wxFrame(NULL, wxID_ANY, title, wxPoint(x, y), wxSize(700, 450))
  1563. {
  1564. SetHelpText( wxT("Controls sample demonstrating various widgets") );
  1565. // Give it an icon
  1566. // The wxICON() macros loads an icon from a resource under Windows
  1567. // and uses an #included XPM image under GTK+ and Motif
  1568. SetIcon( wxICON(sample) );
  1569. wxMenu *file_menu = new wxMenu;
  1570. file_menu->Append(CONTROLS_CLEAR_LOG, wxT("&Clear log\tCtrl-L"));
  1571. file_menu->AppendSeparator();
  1572. file_menu->Append(CONTROLS_ABOUT, wxT("&About\tF1"));
  1573. file_menu->AppendSeparator();
  1574. file_menu->Append(CONTROLS_QUIT, wxT("E&xit\tAlt-X"), wxT("Quit controls sample"));
  1575. wxMenuBar *menu_bar = new wxMenuBar;
  1576. menu_bar->Append(file_menu, wxT("&File"));
  1577. #if wxUSE_TOOLTIPS
  1578. wxMenu *tooltip_menu = new wxMenu;
  1579. tooltip_menu->Append(CONTROLS_SET_TOOLTIP_DELAY, wxT("Set &delay\tCtrl-D"));
  1580. tooltip_menu->AppendSeparator();
  1581. tooltip_menu->Append(CONTROLS_ENABLE_TOOLTIPS, wxT("&Toggle tooltips\tCtrl-T"),
  1582. wxT("enable/disable tooltips"), true);
  1583. tooltip_menu->Check(CONTROLS_ENABLE_TOOLTIPS, true);
  1584. #ifdef __WXMSW__
  1585. tooltip_menu->Append(CONTROLS_SET_TOOLTIPS_MAX_WIDTH, "Set maximal &width");
  1586. #endif // __WXMSW__
  1587. menu_bar->Append(tooltip_menu, wxT("&Tooltips"));
  1588. #endif // wxUSE_TOOLTIPS
  1589. wxMenu *panel_menu = new wxMenu;
  1590. panel_menu->Append(CONTROLS_ENABLE_ALL, wxT("&Disable all\tCtrl-E"),
  1591. wxT("Enable/disable all panel controls"), true);
  1592. panel_menu->Append(CONTROLS_HIDE_ALL, wxT("&Hide all\tCtrl-I"),
  1593. wxT("Show/hide thoe whole panel controls"), true);
  1594. panel_menu->Append(CONTROLS_HIDE_LIST, wxT("Hide &list ctrl\tCtrl-S"),
  1595. wxT("Enable/disable all panel controls"), true);
  1596. panel_menu->Append(CONTROLS_CONTEXT_HELP, wxT("&Context help...\tCtrl-H"),
  1597. wxT("Get context help for a control"));
  1598. menu_bar->Append(panel_menu, wxT("&Panel"));
  1599. SetMenuBar(menu_bar);
  1600. #if wxUSE_STATUSBAR
  1601. CreateStatusBar(2);
  1602. #endif // wxUSE_STATUSBAR
  1603. m_panel = new MyPanel( this, 10, 10, 300, 100 );
  1604. }
  1605. void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) )
  1606. {
  1607. Close(true);
  1608. }
  1609. void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
  1610. {
  1611. wxBusyCursor bc;
  1612. wxMessageDialog dialog(this, wxT("This is a control sample"), wxT("About Controls"), wxOK );
  1613. dialog.ShowModal();
  1614. }
  1615. void MyFrame::OnClearLog(wxCommandEvent& WXUNUSED(event))
  1616. {
  1617. m_panel->m_text->Clear();
  1618. }
  1619. #if wxUSE_TOOLTIPS
  1620. void MyFrame::OnSetTooltipDelay(wxCommandEvent& WXUNUSED(event))
  1621. {
  1622. static long s_delay = 5000;
  1623. wxString delay;
  1624. delay.Printf( wxT("%ld"), s_delay);
  1625. delay = wxGetTextFromUser(wxT("Enter delay (in milliseconds)"),
  1626. wxT("Set tooltip delay"),
  1627. delay,
  1628. this);
  1629. if ( !delay )
  1630. return; // cancelled
  1631. wxSscanf(delay, wxT("%ld"), &s_delay);
  1632. wxToolTip::SetDelay(s_delay);
  1633. wxLogStatus(this, wxT("Tooltip delay set to %ld milliseconds"), s_delay);
  1634. }
  1635. void MyFrame::OnToggleTooltips(wxCommandEvent& WXUNUSED(event))
  1636. {
  1637. static bool s_enabled = true;
  1638. s_enabled = !s_enabled;
  1639. wxToolTip::Enable(s_enabled);
  1640. wxLogStatus(this, wxT("Tooltips %sabled"), s_enabled ? wxT("en") : wxT("dis") );
  1641. }
  1642. #ifdef __WXMSW__
  1643. void MyFrame::OnSetMaxTooltipWidth(wxCommandEvent& WXUNUSED(event))
  1644. {
  1645. static int s_maxWidth = 0;
  1646. wxNumberEntryDialog dlg
  1647. (
  1648. this,
  1649. "Change maximal tooltip width",
  1650. "&Width in pixels:",
  1651. GetTitle(),
  1652. s_maxWidth,
  1653. -1,
  1654. 600
  1655. );
  1656. if ( dlg.ShowModal() == wxID_CANCEL )
  1657. return;
  1658. s_maxWidth = dlg.GetValue();
  1659. wxToolTip::SetMaxWidth(s_maxWidth);
  1660. // we need to set the tooltip again to test the new width
  1661. m_panel->SetAllToolTips();
  1662. }
  1663. #endif // __WXMSW__
  1664. #endif // wxUSE_TOOLTIPS
  1665. void MyFrame::OnEnableAll(wxCommandEvent& WXUNUSED(event))
  1666. {
  1667. static bool s_enable = true;
  1668. s_enable = !s_enable;
  1669. m_panel->Enable(s_enable);
  1670. static bool s_enableCheckbox = true;
  1671. if ( !s_enable )
  1672. {
  1673. // this is a test for correct behaviour of either enabling or disabling
  1674. // a child when its parent is disabled: the checkbox should have the
  1675. // correct state when the parent is enabled back
  1676. m_panel->m_checkbox->Enable(s_enableCheckbox);
  1677. s_enableCheckbox = !s_enableCheckbox;
  1678. }
  1679. }
  1680. void MyFrame::OnHideAll(wxCommandEvent& WXUNUSED(event))
  1681. {
  1682. static bool s_show = true;
  1683. s_show = !s_show;
  1684. m_panel->Show(s_show);
  1685. }
  1686. void MyFrame::OnHideList(wxCommandEvent& WXUNUSED(event))
  1687. {
  1688. static bool s_show = true;
  1689. s_show = !s_show;
  1690. m_panel->m_listbox->Show(s_show);
  1691. }
  1692. void MyFrame::OnContextHelp(wxCommandEvent& WXUNUSED(event))
  1693. {
  1694. // starts a local event loop
  1695. wxContextHelp chelp(this);
  1696. }
  1697. void MyFrame::OnMove( wxMoveEvent& event )
  1698. {
  1699. #if wxUSE_STATUSBAR
  1700. UpdateStatusBar(event.GetPosition(), GetSize());
  1701. #endif // wxUSE_STATUSBAR
  1702. event.Skip();
  1703. }
  1704. void MyFrame::OnIconized( wxIconizeEvent& event )
  1705. {
  1706. wxLogMessage(wxT("Frame %s"), event.IsIconized() ? wxT("iconized")
  1707. : wxT("restored"));
  1708. event.Skip();
  1709. }
  1710. void MyFrame::OnMaximized( wxMaximizeEvent& WXUNUSED(event) )
  1711. {
  1712. wxLogMessage(wxT("Frame maximized"));
  1713. }
  1714. void MyFrame::OnSize( wxSizeEvent& event )
  1715. {
  1716. #if wxUSE_STATUSBAR
  1717. UpdateStatusBar(GetPosition(), event.GetSize());
  1718. #endif // wxUSE_STATUSBAR
  1719. event.Skip();
  1720. }
  1721. void MyFrame::OnIdle( wxIdleEvent& WXUNUSED(event) )
  1722. {
  1723. // track the window which has the focus in the status bar
  1724. static wxWindow *s_windowFocus = NULL;
  1725. wxWindow *focus = wxWindow::FindFocus();
  1726. if ( focus != s_windowFocus )
  1727. {
  1728. s_windowFocus = focus;
  1729. wxString msg;
  1730. if ( focus )
  1731. {
  1732. msg.Printf(
  1733. "Focus: %s"
  1734. #ifdef __WXMSW__
  1735. ", HWND = %08x"
  1736. #endif
  1737. , s_windowFocus->GetName().c_str()
  1738. #ifdef __WXMSW__
  1739. , (unsigned)wxPtrToUInt(s_windowFocus->GetHWND())
  1740. #endif
  1741. );
  1742. }
  1743. else
  1744. {
  1745. msg = wxT("No focus");
  1746. }
  1747. #if wxUSE_STATUSBAR
  1748. SetStatusText(msg);
  1749. #endif // wxUSE_STATUSBAR
  1750. }
  1751. }
  1752. void MyComboBox::OnChar(wxKeyEvent& event)
  1753. {
  1754. wxLogMessage(wxT("MyComboBox::OnChar"));
  1755. if ( event.GetKeyCode() == 'w' )
  1756. {
  1757. wxLogMessage(wxT("MyComboBox: 'w' will be ignored."));
  1758. }
  1759. else
  1760. {
  1761. event.Skip();
  1762. }
  1763. }
  1764. void MyComboBox::OnKeyDown(wxKeyEvent& event)
  1765. {
  1766. wxLogMessage(wxT("MyComboBox::OnKeyDown"));
  1767. if ( event.GetKeyCode() == 'w' )
  1768. {
  1769. wxLogMessage(wxT("MyComboBox: 'w' will be ignored."));
  1770. }
  1771. else
  1772. {
  1773. event.Skip();
  1774. }
  1775. }
  1776. void MyComboBox::OnKeyUp(wxKeyEvent& event)
  1777. {
  1778. wxLogMessage(wxT("MyComboBox::OnKeyUp"));
  1779. event.Skip();
  1780. }
  1781. static void SetListboxClientData(const wxChar *name, wxListBox *control)
  1782. {
  1783. size_t count = control->GetCount();
  1784. for ( size_t n = 0; n < count; n++ )
  1785. {
  1786. wxString s;
  1787. s.Printf(wxT("%s client data for '%s'"),
  1788. name, control->GetString(n).c_str());
  1789. control->SetClientObject(n, new wxStringClientData(s));
  1790. }
  1791. }
  1792. #if wxUSE_CHOICE
  1793. static void SetChoiceClientData(const wxChar *name, wxChoice *control)
  1794. {
  1795. size_t count = control->GetCount();
  1796. for ( size_t n = 0; n < count; n++ )
  1797. {
  1798. wxString s;
  1799. s.Printf(wxT("%s client data for '%s'"),
  1800. name, control->GetString(n).c_str());
  1801. control->SetClientObject(n, new wxStringClientData(s));
  1802. }
  1803. }
  1804. #endif // wxUSE_CHOICE