1998-10-26 13:32:07 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2002-07-19 15:57:58 -04:00
|
|
|
// Name: samples/notebook/notebook.h
|
|
|
|
// Purpose: a sample demonstrating notebook usage
|
1998-10-26 13:32:07 -05:00
|
|
|
// Author: Julian Smart
|
2002-07-19 15:57:58 -04:00
|
|
|
// Modified by: Dimitri Schoolwerth
|
1998-10-26 13:32:07 -05:00
|
|
|
// Created: 25/10/98
|
|
|
|
// RCS-ID: $Id$
|
2004-05-25 07:20:37 -04:00
|
|
|
// Copyright: (c) 1998-2002 wxWidgets team
|
2002-07-19 15:57:58 -04:00
|
|
|
// License: wxWindows license
|
1998-10-26 13:32:07 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2004-09-17 13:39:53 -04:00
|
|
|
#include "wx/choicebk.h"
|
|
|
|
#include "wx/listbook.h"
|
2005-10-09 14:40:36 -04:00
|
|
|
#include "wx/treebook.h"
|
2004-09-17 13:39:53 -04:00
|
|
|
#include "wx/notebook.h"
|
|
|
|
|
|
|
|
#if wxUSE_LOG && !defined( __SMARTPHONE__ )
|
|
|
|
#define USE_LOG 1
|
2003-08-21 19:12:41 -04:00
|
|
|
#else
|
2004-09-17 13:39:53 -04:00
|
|
|
#define USE_LOG 0
|
2003-08-21 19:12:41 -04:00
|
|
|
#endif
|
1998-10-26 13:32:07 -05:00
|
|
|
|
|
|
|
// Define a new application
|
2002-07-19 15:57:58 -04:00
|
|
|
class MyApp : public wxApp
|
1998-10-26 13:32:07 -05:00
|
|
|
{
|
|
|
|
public:
|
2000-02-28 20:49:05 -05:00
|
|
|
bool OnInit();
|
1998-10-26 13:32:07 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
DECLARE_APP(MyApp)
|
|
|
|
|
2005-10-09 14:40:36 -04:00
|
|
|
|
2002-07-19 15:57:58 -04:00
|
|
|
class MyFrame : public wxFrame
|
1998-10-26 13:32:07 -05:00
|
|
|
{
|
|
|
|
public:
|
2005-10-09 14:40:36 -04:00
|
|
|
MyFrame();
|
2002-07-19 15:57:58 -04:00
|
|
|
virtual ~MyFrame();
|
|
|
|
|
2004-09-17 13:39:53 -04:00
|
|
|
void OnType(wxCommandEvent& event);
|
|
|
|
void OnOrient(wxCommandEvent& event);
|
|
|
|
void OnShowImages(wxCommandEvent& event);
|
|
|
|
void OnMulti(wxCommandEvent& event);
|
|
|
|
void OnExit(wxCommandEvent& event);
|
2002-07-19 15:57:58 -04:00
|
|
|
|
2004-09-17 13:39:53 -04:00
|
|
|
void OnAddPage(wxCommandEvent& event);
|
|
|
|
void OnInsertPage(wxCommandEvent& event);
|
|
|
|
void OnDeleteCurPage(wxCommandEvent& event);
|
|
|
|
void OnDeleteLastPage(wxCommandEvent& event);
|
|
|
|
void OnNextPage(wxCommandEvent& event);
|
2002-07-19 15:57:58 -04:00
|
|
|
|
2005-10-09 14:40:36 -04:00
|
|
|
void OnAddSubPage(wxCommandEvent& event);
|
|
|
|
void OnAddPageBefore(wxCommandEvent& event);
|
|
|
|
|
|
|
|
void OnBookCtrl(wxBookCtrlBaseEvent& event);
|
2004-09-24 09:45:52 -04:00
|
|
|
#if wxUSE_NOTEBOOK
|
2005-10-09 14:40:36 -04:00
|
|
|
void OnNotebook(wxNotebookEvent& event) { OnBookCtrl(event); }
|
2004-09-24 09:45:52 -04:00
|
|
|
#endif
|
|
|
|
#if wxUSE_CHOICEBOOK
|
2005-10-09 14:40:36 -04:00
|
|
|
void OnChoicebook(wxChoicebookEvent& event) { OnBookCtrl(event); }
|
2004-09-24 09:45:52 -04:00
|
|
|
#endif
|
|
|
|
#if wxUSE_LISTBOOK
|
2005-10-09 14:40:36 -04:00
|
|
|
void OnListbook(wxListbookEvent& event) { OnBookCtrl(event); }
|
|
|
|
#endif
|
|
|
|
#if wxUSE_TREEBOOK
|
|
|
|
void OnTreebook(wxTreebookEvent& event) { OnBookCtrl(event); }
|
2004-09-24 09:45:52 -04:00
|
|
|
#endif
|
1999-06-24 17:27:52 -04:00
|
|
|
|
2002-08-15 20:09:29 -04:00
|
|
|
void OnIdle(wxIdleEvent& event);
|
1999-06-24 17:27:52 -04:00
|
|
|
|
2005-10-09 14:40:36 -04:00
|
|
|
#if wxUSE_TREEBOOK
|
|
|
|
void OnUpdateTreeMenu(wxUpdateUIEvent& event);
|
|
|
|
#endif // wxUSE_TREEBOOK
|
|
|
|
|
|
|
|
wxBookCtrlBase *GetCurrentBook() const { return m_bookCtrl; }
|
2004-09-17 13:39:53 -04:00
|
|
|
|
2002-07-19 15:57:58 -04:00
|
|
|
private:
|
|
|
|
wxLog *m_logTargetOld;
|
|
|
|
|
2005-10-09 14:40:36 -04:00
|
|
|
void RecreateBook();
|
|
|
|
wxPanel *CreateNewPage() const;
|
|
|
|
int TranslateBookFlag(int nb, int lb, int chb, int tbk) const;
|
2004-09-17 13:39:53 -04:00
|
|
|
|
|
|
|
// Sample setup
|
2005-10-09 14:40:36 -04:00
|
|
|
enum BookType
|
|
|
|
{
|
|
|
|
Type_Notebook,
|
|
|
|
Type_Listbook,
|
2005-10-09 18:09:35 -04:00
|
|
|
Type_Choicebook,
|
2005-10-09 14:40:36 -04:00
|
|
|
Type_Treebook,
|
|
|
|
Type_Max
|
|
|
|
} m_type;
|
2004-09-17 13:39:53 -04:00
|
|
|
int m_orient;
|
|
|
|
bool m_chkShowImages;
|
|
|
|
bool m_multi;
|
2002-07-19 15:57:58 -04:00
|
|
|
|
|
|
|
// Controls
|
|
|
|
|
|
|
|
wxPanel *m_panel; // Panel containing notebook and other controls
|
2005-10-09 14:40:36 -04:00
|
|
|
wxBookCtrlBase *m_bookCtrl;
|
2002-07-19 15:57:58 -04:00
|
|
|
|
2004-09-17 13:39:53 -04:00
|
|
|
#if USE_LOG
|
2002-07-19 15:57:58 -04:00
|
|
|
// Log window
|
|
|
|
wxTextCtrl *m_text;
|
2004-09-17 13:39:53 -04:00
|
|
|
#endif // USE_LOG
|
2002-07-19 15:57:58 -04:00
|
|
|
|
|
|
|
wxBoxSizer *m_sizerFrame;
|
|
|
|
|
|
|
|
wxImageList *m_imageList;
|
1998-10-26 13:32:07 -05:00
|
|
|
|
1999-08-02 17:31:09 -04:00
|
|
|
DECLARE_EVENT_TABLE()
|
1998-10-26 13:32:07 -05:00
|
|
|
};
|
|
|
|
|
2004-09-17 13:39:53 -04:00
|
|
|
enum ID_COMMANDS
|
2002-07-19 15:57:58 -04:00
|
|
|
{
|
2005-10-09 14:40:36 -04:00
|
|
|
// these should be in the same order as Type_XXX elements above
|
2004-09-17 13:39:53 -04:00
|
|
|
ID_BOOK_NOTEBOOK = wxID_HIGHEST,
|
|
|
|
ID_BOOK_LISTBOOK,
|
|
|
|
ID_BOOK_CHOICEBOOK,
|
2005-10-09 14:40:36 -04:00
|
|
|
ID_BOOK_TREEBOOK,
|
2004-09-17 13:39:53 -04:00
|
|
|
ID_BOOK_MAX,
|
2005-10-09 14:40:36 -04:00
|
|
|
|
2004-09-17 13:39:53 -04:00
|
|
|
ID_ORIENT_DEFAULT,
|
|
|
|
ID_ORIENT_TOP,
|
|
|
|
ID_ORIENT_BOTTOM,
|
|
|
|
ID_ORIENT_LEFT,
|
|
|
|
ID_ORIENT_RIGHT,
|
|
|
|
ID_ORIENT_MAX,
|
|
|
|
ID_SHOW_IMAGES,
|
|
|
|
ID_MULTI,
|
|
|
|
ID_ADD_PAGE,
|
|
|
|
ID_INSERT_PAGE,
|
|
|
|
ID_DELETE_CUR_PAGE,
|
|
|
|
ID_DELETE_LAST_PAGE,
|
|
|
|
ID_NEXT_PAGE,
|
2005-10-09 14:40:36 -04:00
|
|
|
ID_ADD_PAGE_BEFORE,
|
|
|
|
ID_ADD_SUB_PAGE
|
2002-07-19 15:57:58 -04:00
|
|
|
};
|
2002-07-21 10:43:09 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
Name of each notebook page.
|
|
|
|
Used as a label for a page, and used when cloning the notebook
|
|
|
|
to decide what type of page it is.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define I_WAS_INSERTED_PAGE_NAME wxT("Inserted")
|
|
|
|
#define RADIOBUTTONS_PAGE_NAME wxT("Radiobuttons")
|
|
|
|
#define VETO_PAGE_NAME wxT("Veto")
|
|
|
|
#define MAXIMIZED_BUTTON_PAGE_NAME wxT("Maximized button")
|
|
|
|
|
|
|
|
// Pages that can be added by the user
|
|
|
|
#define INSERTED_PAGE_NAME wxT("Inserted ")
|
|
|
|
#define ADDED_PAGE_NAME wxT("Added ")
|
2005-10-09 14:40:36 -04:00
|
|
|
#define ADDED_PAGE_NAME_BEFORE wxT(" Inserted before ")
|
|
|
|
#define ADDED_SUB_PAGE_NAME wxT(" Inserted sub-page ")
|
|
|
|
|
|
|
|
|