layout.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: layout.h
  3. // Purpose: Layout sample
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 04/01/98
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. // Define a new application
  11. class MyApp: public wxApp
  12. {
  13. public:
  14. MyApp(){};
  15. bool OnInit();
  16. };
  17. // the main frame class
  18. class MyFrame : public wxFrame
  19. {
  20. public:
  21. MyFrame();
  22. void TestProportions(wxCommandEvent& event);
  23. void TestFlexSizers(wxCommandEvent& event);
  24. void TestNotebookSizers(wxCommandEvent& event);
  25. void TestGridBagSizer(wxCommandEvent& event);
  26. void TestNested(wxCommandEvent& event);
  27. void TestSetMinimal(wxCommandEvent& event);
  28. void TestWrap(wxCommandEvent& event);
  29. void OnAbout(wxCommandEvent& event);
  30. void OnQuit(wxCommandEvent& event);
  31. private:
  32. wxDECLARE_EVENT_TABLE();
  33. };
  34. // a frame showing the box sizer proportions
  35. class MyProportionsFrame : public wxFrame
  36. {
  37. public:
  38. MyProportionsFrame(wxFrame *parent);
  39. protected:
  40. void UpdateProportions();
  41. void OnProportionChanged(wxSpinEvent& event);
  42. void OnProportionUpdated(wxCommandEvent& event);
  43. wxSpinCtrl *m_spins[3]; // size can be changed without changing anything else
  44. wxSizer *m_sizer;
  45. };
  46. // a frame using flex sizers for layout
  47. class MyFlexSizerFrame : public wxFrame
  48. {
  49. public:
  50. MyFlexSizerFrame(wxFrame* parent);
  51. private:
  52. void InitFlexSizer(wxFlexGridSizer *sizer, wxWindow* parent);
  53. };
  54. // a dialog using notebook sizer for layout
  55. class MySizerDialog : public wxDialog
  56. {
  57. public:
  58. MySizerDialog(wxWindow *parent, const wxString &title );
  59. };
  60. // a frame using wxGridBagSizer for layout
  61. class MyGridBagSizerFrame : public wxFrame
  62. {
  63. public:
  64. MyGridBagSizerFrame(wxFrame* parent);
  65. void OnHideBtn(wxCommandEvent&);
  66. void OnShowBtn(wxCommandEvent&);
  67. void OnMoveBtn(wxCommandEvent&);
  68. private:
  69. wxGridBagSizer* m_gbs;
  70. wxPanel* m_panel;
  71. wxButton* m_hideBtn;
  72. wxButton* m_showBtn;
  73. wxTextCtrl* m_hideTxt;
  74. wxButton* m_moveBtn1;
  75. wxButton* m_moveBtn2;
  76. wxGBPosition m_lastPos;
  77. wxDECLARE_EVENT_TABLE();
  78. };
  79. // a frame for testing simple setting of "default size"
  80. class MySimpleSizerFrame : public wxFrame
  81. {
  82. public:
  83. MySimpleSizerFrame(wxFrame* parent);
  84. void OnSetSmallSize( wxCommandEvent &event);
  85. void OnSetBigSize( wxCommandEvent &event);
  86. private:
  87. wxTextCtrl *m_target;
  88. wxDECLARE_EVENT_TABLE();
  89. };
  90. // a frame for testing simple setting of a frame containing
  91. // a sizer containing a panel containing a sizer containing
  92. // controls
  93. class MyNestedSizerFrame : public wxFrame
  94. {
  95. public:
  96. MyNestedSizerFrame(wxFrame* parent);
  97. private:
  98. wxTextCtrl *m_target;
  99. };
  100. // a frame with several wrapping sizers
  101. class MyWrapSizerFrame: public wxFrame
  102. {
  103. public:
  104. MyWrapSizerFrame(wxFrame* parent);
  105. private:
  106. void OnAddCheckbox(wxCommandEvent& event);
  107. void OnRemoveCheckbox(wxCommandEvent& event);
  108. void DoAddCheckbox();
  109. wxWindow* m_checkboxParent;
  110. wxSizer* m_wrapSizer;
  111. wxDECLARE_EVENT_TABLE();
  112. };
  113. // controls and menu constants
  114. enum
  115. {
  116. LAYOUT_TEST_SIZER = 101,
  117. LAYOUT_TEST_NB_SIZER,
  118. LAYOUT_TEST_GB_SIZER,
  119. LAYOUT_TEST_PROPORTIONS,
  120. LAYOUT_TEST_SET_MINIMAL,
  121. LAYOUT_TEST_NESTED,
  122. LAYOUT_TEST_WRAP,
  123. LAYOUT_QUIT = wxID_EXIT,
  124. LAYOUT_ABOUT = wxID_ABOUT
  125. };