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