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