notebook.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: samples/notebook/notebook.h
  3. // Purpose: a sample demonstrating notebook usage
  4. // Author: Julian Smart
  5. // Modified by: Dimitri Schoolwerth
  6. // Created: 25/10/98
  7. // Copyright: (c) 1998-2002 wxWidgets team
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #include "wx/choicebk.h"
  11. #include "wx/listbook.h"
  12. #include "wx/treebook.h"
  13. #include "wx/notebook.h"
  14. #include "wx/simplebook.h"
  15. #include "wx/toolbook.h"
  16. #include "wx/aui/auibook.h"
  17. #if wxUSE_LOG && !defined( __SMARTPHONE__ )
  18. #define USE_LOG 1
  19. #else
  20. #define USE_LOG 0
  21. #endif
  22. // Define a new application
  23. class MyApp : public wxApp
  24. {
  25. public:
  26. bool OnInit();
  27. };
  28. DECLARE_APP(MyApp)
  29. class MyFrame : public wxFrame
  30. {
  31. public:
  32. MyFrame();
  33. virtual ~MyFrame();
  34. void OnType(wxCommandEvent& event);
  35. void OnOrient(wxCommandEvent& event);
  36. void OnShowImages(wxCommandEvent& event);
  37. void OnStyle(wxCommandEvent& event);
  38. void OnExit(wxCommandEvent& event);
  39. void OnAddPage(wxCommandEvent& event);
  40. void OnAddPageNoSelect(wxCommandEvent& event);
  41. void OnInsertPage(wxCommandEvent& event);
  42. void OnDeleteCurPage(wxCommandEvent& event);
  43. void OnDeleteLastPage(wxCommandEvent& event);
  44. void OnNextPage(wxCommandEvent& event);
  45. void OnChangeSelection(wxCommandEvent &event);
  46. void OnSetSelection(wxCommandEvent &event);
  47. void OnGetPageSize(wxCommandEvent &event);
  48. void OnSetPageSize(wxCommandEvent &event);
  49. void OnAddSubPage(wxCommandEvent& event);
  50. void OnAddPageBefore(wxCommandEvent& event);
  51. #if wxUSE_HELP
  52. void OnContextHelp(wxCommandEvent& event);
  53. #endif // wxUSE_HELP
  54. void OnHitTest(wxCommandEvent& event);
  55. void OnBookCtrl(wxBookCtrlBaseEvent& event);
  56. #if wxUSE_NOTEBOOK
  57. void OnNotebook(wxNotebookEvent& event) { OnBookCtrl(event); }
  58. #endif
  59. #if wxUSE_CHOICEBOOK
  60. void OnChoicebook(wxChoicebookEvent& event) { OnBookCtrl(event); }
  61. #endif
  62. #if wxUSE_LISTBOOK
  63. void OnListbook(wxListbookEvent& event) { OnBookCtrl(event); }
  64. #endif
  65. #if wxUSE_TREEBOOK
  66. void OnTreebook(wxTreebookEvent& event) { OnBookCtrl(event); }
  67. #endif
  68. #if wxUSE_TOOLBOOK
  69. void OnToolbook(wxToolbookEvent& event) { OnBookCtrl(event); }
  70. #endif
  71. #if wxUSE_AUI
  72. void OnAuiNotebook(wxAuiNotebookEvent& event) { OnBookCtrl(event); }
  73. #endif
  74. void OnIdle(wxIdleEvent& event);
  75. #if wxUSE_TREEBOOK
  76. void OnUpdateTreeMenu(wxUpdateUIEvent& event);
  77. #endif // wxUSE_TREEBOOK
  78. wxBookCtrlBase *GetCurrentBook() const { return m_bookCtrl; }
  79. private:
  80. wxLog *m_logTargetOld;
  81. void RecreateBook();
  82. wxPanel *CreateNewPage() const;
  83. void AddFlagStrIfFlagPresent(wxString & flagStr, long flags, long flag, const wxChar * flagName) const;
  84. // Sample setup
  85. enum BookType
  86. {
  87. Type_Notebook,
  88. Type_Listbook,
  89. Type_Choicebook,
  90. Type_Treebook,
  91. Type_Toolbook,
  92. Type_AuiNotebook,
  93. Type_Simplebook,
  94. Type_Max
  95. } m_type;
  96. int m_orient;
  97. bool m_chkShowImages;
  98. bool m_fixedWidth;
  99. bool m_multi;
  100. bool m_noPageTheme;
  101. bool m_buttonBar;
  102. bool m_horzLayout;
  103. // Controls
  104. wxPanel *m_panel; // Panel containing notebook and other controls
  105. wxBookCtrlBase *m_bookCtrl;
  106. #if USE_LOG
  107. // Log window
  108. wxTextCtrl *m_text;
  109. #endif // USE_LOG
  110. wxBoxSizer *m_sizerFrame;
  111. wxImageList *m_imageList;
  112. wxDECLARE_EVENT_TABLE();
  113. };
  114. enum ID_COMMANDS
  115. {
  116. // these should be in the same order as Type_XXX elements above
  117. ID_BOOK_NOTEBOOK = wxID_HIGHEST,
  118. ID_BOOK_LISTBOOK,
  119. ID_BOOK_CHOICEBOOK,
  120. ID_BOOK_TREEBOOK,
  121. ID_BOOK_TOOLBOOK,
  122. ID_BOOK_AUINOTEBOOK,
  123. ID_BOOK_SIMPLEBOOK,
  124. ID_BOOK_MAX,
  125. ID_ORIENT_DEFAULT,
  126. ID_ORIENT_TOP,
  127. ID_ORIENT_BOTTOM,
  128. ID_ORIENT_LEFT,
  129. ID_ORIENT_RIGHT,
  130. ID_ORIENT_MAX,
  131. ID_SHOW_IMAGES,
  132. ID_FIXEDWIDTH,
  133. ID_MULTI,
  134. ID_NOPAGETHEME,
  135. ID_BUTTONBAR,
  136. ID_HORZ_LAYOUT,
  137. ID_ADD_PAGE,
  138. ID_ADD_PAGE_NO_SELECT,
  139. ID_INSERT_PAGE,
  140. ID_DELETE_CUR_PAGE,
  141. ID_DELETE_LAST_PAGE,
  142. ID_NEXT_PAGE,
  143. ID_ADD_PAGE_BEFORE,
  144. ID_ADD_SUB_PAGE,
  145. ID_CHANGE_SELECTION,
  146. ID_SET_SELECTION,
  147. ID_GET_PAGE_SIZE,
  148. ID_SET_PAGE_SIZE,
  149. #if wxUSE_HELP
  150. ID_CONTEXT_HELP,
  151. #endif // wxUSE_HELP
  152. ID_HITTEST
  153. };
  154. /*
  155. Name of each notebook page.
  156. Used as a label for a page, and used when cloning the notebook
  157. to decide what type of page it is.
  158. */
  159. #define I_WAS_INSERTED_PAGE_NAME wxT("Inserted")
  160. #define RADIOBUTTONS_PAGE_NAME wxT("Radiobuttons")
  161. #define VETO_PAGE_NAME wxT("Veto")
  162. #define MAXIMIZED_BUTTON_PAGE_NAME wxT("Maximized button")
  163. // Pages that can be added by the user
  164. #define INSERTED_PAGE_NAME wxT("Inserted ")
  165. #define ADDED_PAGE_NAME wxT("Added ")
  166. #define ADDED_PAGE_NAME_BEFORE wxT(" Inserted before ")
  167. #define ADDED_SUB_PAGE_NAME wxT(" Inserted sub-page ")