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
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
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"
|
2006-01-30 10:40:32 -05:00
|
|
|
#include "wx/toolbook.h"
|
2004-09-17 13:39:53 -04:00
|
|
|
|
|
|
|
#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);
|
2006-11-04 13:24:07 -05:00
|
|
|
void OnAddPageNoSelect(wxCommandEvent& event);
|
2004-09-17 13:39:53 -04:00
|
|
|
void OnInsertPage(wxCommandEvent& event);
|
|
|
|
void OnDeleteCurPage(wxCommandEvent& event);
|
|
|
|
void OnDeleteLastPage(wxCommandEvent& event);
|
|
|
|
void OnNextPage(wxCommandEvent& event);
|
2006-10-08 13:37:23 -04:00
|
|
|
void OnGoHome(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);
|
|
|
|
|
2006-06-14 14:32:26 -04:00
|
|
|
#if wxUSE_HELP
|
|
|
|
void OnContextHelp(wxCommandEvent& event);
|
|
|
|
#endif // wxUSE_HELP
|
|
|
|
|
2006-06-14 11:54:24 -04:00
|
|
|
void OnHitTest(wxCommandEvent& event);
|
|
|
|
|
2005-10-09 14:40:36 -04:00
|
|
|
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
|
2006-01-30 10:40:32 -05:00
|
|
|
#if wxUSE_TOOLBOOK
|
|
|
|
void OnToolbook(wxToolbookEvent& event) { OnBookCtrl(event); }
|
|
|
|
#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;
|
2006-01-30 10:40:32 -05:00
|
|
|
int TranslateBookFlag(int nb, int lb, int chb, int tbk, int toolbk) const;
|
2006-06-14 11:54:24 -04:00
|
|
|
void AddFlagStrIfFlagPresent(wxString & flagStr, long flags, long flag, const wxChar * flagName) 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,
|
2006-01-30 10:40:32 -05:00
|
|
|
Type_Toolbook,
|
2005-10-09 14:40:36 -04:00
|
|
|
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,
|
2006-01-30 10:40:32 -05:00
|
|
|
ID_BOOK_TOOLBOOK,
|
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,
|
2006-11-04 13:24:07 -05:00
|
|
|
ID_ADD_PAGE_NO_SELECT,
|
2004-09-17 13:39:53 -04:00
|
|
|
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,
|
2006-06-14 11:54:24 -04:00
|
|
|
ID_ADD_SUB_PAGE,
|
2006-10-08 13:37:23 -04:00
|
|
|
ID_GO_HOME,
|
2006-06-14 11:54:24 -04:00
|
|
|
|
2006-06-14 14:32:26 -04:00
|
|
|
#if wxUSE_HELP
|
|
|
|
ID_CONTEXT_HELP,
|
|
|
|
#endif // wxUSE_HELP
|
2006-06-14 11:54:24 -04:00
|
|
|
ID_HITTEST
|
2002-07-19 15:57:58 -04:00
|
|
|
};
|
2002-07-21 10:43:09 -04:00
|
|
|
|
2009-03-04 10:23:56 -05:00
|
|
|
|
2002-07-21 10:43:09 -04:00
|
|
|
/*
|
2009-03-04 10:23:56 -05: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.
|
2002-07-21 10:43:09 -04:00
|
|
|
*/
|
|
|
|
|
2009-03-04 10:23:56 -05:00
|
|
|
#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")
|
2002-07-21 10:43:09 -04:00
|
|
|
|
|
|
|
// Pages that can be added by the user
|
2009-03-04 10:23:56 -05:00
|
|
|
#define INSERTED_PAGE_NAME wxT("Inserted ")
|
|
|
|
#define ADDED_PAGE_NAME wxT("Added ")
|
|
|
|
#define ADDED_PAGE_NAME_BEFORE wxT(" Inserted before ")
|
|
|
|
#define ADDED_SUB_PAGE_NAME wxT(" Inserted sub-page ")
|
2005-10-09 14:40:36 -04:00
|
|
|
|
|
|
|
|