]>
Commit | Line | Data |
---|---|---|
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 | ||
52 | void OnAddSubPage(wxCommandEvent& event); | |
53 | void OnAddPageBefore(wxCommandEvent& event); | |
54 | ||
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 | ||
72 | void OnIdle(wxIdleEvent& event); | |
73 | ||
74 | #if wxUSE_TREEBOOK | |
75 | void OnUpdateTreeMenu(wxUpdateUIEvent& event); | |
76 | #endif // wxUSE_TREEBOOK | |
77 | ||
78 | wxBookCtrlBase *GetCurrentBook() const { return m_bookCtrl; } | |
79 | ||
80 | private: | |
81 | wxLog *m_logTargetOld; | |
82 | ||
83 | void RecreateBook(); | |
84 | wxPanel *CreateNewPage() const; | |
85 | int TranslateBookFlag(int nb, int lb, int chb, int tbk, int toolbk) const; | |
86 | ||
87 | // Sample setup | |
88 | enum BookType | |
89 | { | |
90 | Type_Notebook, | |
91 | Type_Listbook, | |
92 | Type_Choicebook, | |
93 | Type_Treebook, | |
94 | Type_Toolbook, | |
95 | Type_Max | |
96 | } m_type; | |
97 | int m_orient; | |
98 | bool m_chkShowImages; | |
99 | bool m_multi; | |
100 | ||
101 | // Controls | |
102 | ||
103 | wxPanel *m_panel; // Panel containing notebook and other controls | |
104 | wxBookCtrlBase *m_bookCtrl; | |
105 | ||
106 | #if USE_LOG | |
107 | // Log window | |
108 | wxTextCtrl *m_text; | |
109 | #endif // USE_LOG | |
110 | ||
111 | wxBoxSizer *m_sizerFrame; | |
112 | ||
113 | wxImageList *m_imageList; | |
114 | ||
115 | DECLARE_EVENT_TABLE() | |
116 | }; | |
117 | ||
118 | enum ID_COMMANDS | |
119 | { | |
120 | // these should be in the same order as Type_XXX elements above | |
121 | ID_BOOK_NOTEBOOK = wxID_HIGHEST, | |
122 | ID_BOOK_LISTBOOK, | |
123 | ID_BOOK_CHOICEBOOK, | |
124 | ID_BOOK_TREEBOOK, | |
125 | ID_BOOK_TOOLBOOK, | |
126 | ID_BOOK_MAX, | |
127 | ||
128 | ID_ORIENT_DEFAULT, | |
129 | ID_ORIENT_TOP, | |
130 | ID_ORIENT_BOTTOM, | |
131 | ID_ORIENT_LEFT, | |
132 | ID_ORIENT_RIGHT, | |
133 | ID_ORIENT_MAX, | |
134 | ID_SHOW_IMAGES, | |
135 | ID_MULTI, | |
136 | ID_ADD_PAGE, | |
137 | ID_INSERT_PAGE, | |
138 | ID_DELETE_CUR_PAGE, | |
139 | ID_DELETE_LAST_PAGE, | |
140 | ID_NEXT_PAGE, | |
141 | ID_ADD_PAGE_BEFORE, | |
142 | ID_ADD_SUB_PAGE | |
143 | }; | |
144 | ||
145 | /* | |
146 | Name of each notebook page. | |
147 | Used as a label for a page, and used when cloning the notebook | |
148 | to decide what type of page it is. | |
149 | */ | |
150 | ||
151 | #define I_WAS_INSERTED_PAGE_NAME wxT("Inserted") | |
152 | #define RADIOBUTTONS_PAGE_NAME wxT("Radiobuttons") | |
153 | #define VETO_PAGE_NAME wxT("Veto") | |
154 | #define MAXIMIZED_BUTTON_PAGE_NAME wxT("Maximized button") | |
155 | ||
156 | // Pages that can be added by the user | |
157 | #define INSERTED_PAGE_NAME wxT("Inserted ") | |
158 | #define ADDED_PAGE_NAME wxT("Added ") | |
159 | #define ADDED_PAGE_NAME_BEFORE wxT(" Inserted before ") | |
160 | #define ADDED_SUB_PAGE_NAME wxT(" Inserted sub-page ") | |
161 | ||
162 |