1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/notebook/notebook.h
3 // Purpose: a sample demonstrating notebook usage
4 // Author: Julian Smart
5 // Modified by: Dimitri Schoolwerth
8 // Copyright: (c) 1998-2002 wxWidgets team
9 // License: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // this sample can be used to test both wxNotebook and wxListbook
13 //#define TEST_LISTBOOK
16 #include "wx/listbook.h"
18 #define wxNotebook wxListbook
19 #define wxNotebookEvent wxListbookEvent
21 #define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED
22 #define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING
23 #define EVT_NOTEBOOK_PAGE_CHANGED EVT_LISTBOOK_PAGE_CHANGED
24 #define EVT_NOTEBOOK_PAGE_CHANGING EVT_LISTBOOK_PAGE_CHANGING
27 #define wxNB_TOP wxLB_TOP
29 #define wxNB_BOTTOM wxLB_BOTTOM
31 #define wxNB_LEFT wxLB_LEFT
33 #define wxNB_RIGHT wxLB_RIGHT
35 #include "wx/notebook.h"
38 // Define a new application
39 class MyApp
: public wxApp
48 class MyNotebook
: public wxNotebook
51 MyNotebook(wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
52 const wxPoint
& pos
= wxDefaultPosition
,
53 const wxSize
& size
= wxDefaultSize
, long style
= 0);
55 void CreateInitialPages();
57 wxPanel
*CreatePage(const wxString
& pageName
);
59 wxPanel
*CreateUserCreatedPage();
61 int GetIconIndex() const;
64 wxPanel
*CreateInsertPage();
65 wxPanel
*CreateRadioButtonsPage();
66 wxPanel
*CreateVetoPage();
67 wxPanel
*CreateBigButtonPage();
71 class MyFrame
: public wxFrame
74 MyFrame(const wxString
& title
, const wxPoint
& pos
= wxDefaultPosition
,
75 const wxSize
& size
= wxDefaultSize
, long style
= wxDEFAULT_FRAME_STYLE
|wxCLIP_CHILDREN
|wxNO_FULL_REPAINT_ON_RESIZE
);
79 // Recreates the notebook with the same pages, but with possibly
80 // a different orientation and optionally with images.
81 void ReInitNotebook();
83 void OnCheckOrRadioBox(wxCommandEvent
& event
);
85 void OnButtonAddPage(wxCommandEvent
& event
);
86 void OnButtonInsertPage(wxCommandEvent
& event
);
87 void OnButtonDeleteCurPage(wxCommandEvent
& event
);
88 void OnButtonDeleteLastPage(wxCommandEvent
& event
);
89 void OnButtonNextPage(wxCommandEvent
& event
);
90 void OnButtonExit(wxCommandEvent
& event
);
92 void OnNotebook(wxNotebookEvent
& event
);
94 void OnUpdateUIBtnDeleteCurPage(wxUpdateUIEvent
& event
);
95 void OnUpdateUIBtnDeleteLastPage(wxUpdateUIEvent
& event
);
97 void OnIdle(wxIdleEvent
& event
);
100 wxLog
*m_logTargetOld
;
105 wxPanel
*m_panel
; // Panel containing notebook and other controls
107 wxRadioBox
*m_radioOrient
;
108 wxCheckBox
*m_chkShowImages
,
111 wxButton
*m_btnAddPage
;
112 wxButton
*m_btnInsertPage
;
113 wxButton
*m_btnDeleteCurPage
;
114 wxButton
*m_btnDeleteLastPage
;
115 wxButton
*m_btnNextPage
;
118 MyNotebook
*m_notebook
;
127 // The frame's sizer. Consists of m_sizerTop and the log window
129 wxBoxSizer
*m_sizerFrame
;
131 // Sizer that contains the notebook and controls on the left
132 wxBoxSizer
*m_sizerTop
;
134 wxImageList
*m_imageList
;
136 DECLARE_EVENT_TABLE()
141 ID_RADIO_ORIENT
= wxID_HIGHEST
,
146 ID_BTN_DELETE_CUR_PAGE
,
147 ID_BTN_DELETE_LAST_PAGE
,
152 // notebook orientations
163 Name of each notebook page.
164 Used as a label for a page, and used when cloning the notebook
165 to decide what type of page it is.
168 #define I_WAS_INSERTED_PAGE_NAME wxT("Inserted")
169 #define RADIOBUTTONS_PAGE_NAME wxT("Radiobuttons")
170 #define VETO_PAGE_NAME wxT("Veto")
171 #define MAXIMIZED_BUTTON_PAGE_NAME wxT("Maximized button")
173 // Pages that can be added by the user
174 #define INSERTED_PAGE_NAME wxT("Inserted ")
175 #define ADDED_PAGE_NAME wxT("Added ")