1998-06-02 19:04:33 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1998-07-22 22:13:31 +00:00
|
|
|
// Name: notebook.h
|
|
|
|
// Purpose: wxNotebook class
|
1998-06-02 19:04:33 +00:00
|
|
|
// Author: Robert Roebling
|
|
|
|
// Modified by:
|
|
|
|
// RCS-ID: $Id$
|
1998-12-04 07:43:56 +00:00
|
|
|
// Copyright: (c) Julian Smart and Robert Roebling
|
1998-06-26 14:29:11 +00:00
|
|
|
// Licence: wxWindows license
|
1998-06-02 19:04:33 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-11-03 11:19:58 +00:00
|
|
|
#ifndef __GTKNOTEBOOKH__
|
|
|
|
#define __GTKNOTEBOOKH__
|
1998-06-02 19:04:33 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
1998-11-03 11:19:58 +00:00
|
|
|
#pragma interface
|
1998-06-02 19:04:33 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
|
|
|
#include "wx/control.h"
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class wxImageList;
|
|
|
|
class wxNotebook;
|
1998-06-15 09:21:45 +00:00
|
|
|
class wxNotebookPage;
|
1998-06-02 19:04:33 +00:00
|
|
|
|
1998-06-26 14:29:11 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// notebook events
|
|
|
|
// ----------------------------------------------------------------------------
|
1998-07-12 20:06:59 +00:00
|
|
|
|
1998-06-26 14:29:11 +00:00
|
|
|
class wxNotebookEvent : public wxCommandEvent
|
|
|
|
{
|
|
|
|
public:
|
1998-06-26 22:00:38 +00:00
|
|
|
wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
|
1998-06-26 14:29:11 +00:00
|
|
|
int nSel = -1, int nOldSel = -1)
|
1998-11-24 23:30:50 +00:00
|
|
|
: wxCommandEvent(commandType, id)
|
|
|
|
{
|
|
|
|
m_bAllow = TRUE;
|
|
|
|
m_nSel = nSel;
|
|
|
|
m_nOldSel = nOldSel;
|
|
|
|
}
|
1998-06-02 19:04:33 +00:00
|
|
|
|
1998-06-26 14:29:11 +00:00
|
|
|
// accessors
|
|
|
|
int GetSelection() const { return m_nSel; }
|
|
|
|
int GetOldSelection() const { return m_nOldSel; }
|
1998-06-02 19:04:33 +00:00
|
|
|
|
1998-11-24 23:30:50 +00:00
|
|
|
// for wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING event this method may be called
|
|
|
|
// to disallow the page change
|
|
|
|
void Veto() { m_bAllow = FALSE; }
|
|
|
|
|
|
|
|
// implementation: for wxNotebook usage only
|
|
|
|
bool Allowed() const { return m_bAllow; }
|
|
|
|
|
1998-06-26 14:29:11 +00:00
|
|
|
private:
|
1998-11-24 23:30:50 +00:00
|
|
|
bool m_bAllow;
|
|
|
|
|
1998-06-26 14:29:11 +00:00
|
|
|
int m_nSel, // currently selected page
|
|
|
|
m_nOldSel; // previously selected page
|
1998-06-02 19:04:33 +00:00
|
|
|
|
1998-06-26 14:29:11 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxNotebookEvent)
|
1998-06-02 19:04:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
1998-06-26 14:29:11 +00:00
|
|
|
// wxNotebook
|
1998-06-02 19:04:33 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
1998-06-26 14:29:11 +00:00
|
|
|
class wxNotebook : public wxControl
|
1998-06-02 19:04:33 +00:00
|
|
|
{
|
1998-06-26 14:29:11 +00:00
|
|
|
public:
|
|
|
|
// ctors
|
|
|
|
// -----
|
|
|
|
// default for dynamic class
|
|
|
|
wxNotebook();
|
|
|
|
// the same arguments as for wxControl (@@@ any special styles?)
|
|
|
|
wxNotebook(wxWindow *parent,
|
1998-07-04 15:17:59 +00:00
|
|
|
wxWindowID id,
|
1998-06-26 14:29:11 +00:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
1998-07-04 15:17:59 +00:00
|
|
|
long style = 0,
|
1998-06-26 14:29:11 +00:00
|
|
|
const wxString& name = "notebook");
|
|
|
|
// Create() function
|
|
|
|
bool Create(wxWindow *parent,
|
1998-07-04 15:17:59 +00:00
|
|
|
wxWindowID id,
|
1998-06-26 14:29:11 +00:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
1998-07-04 15:17:59 +00:00
|
|
|
long style = 0,
|
1998-06-26 14:29:11 +00:00
|
|
|
const wxString& name = "notebook");
|
|
|
|
// dtor
|
|
|
|
~wxNotebook();
|
|
|
|
|
|
|
|
// accessors
|
|
|
|
// ---------
|
|
|
|
// get number of pages in the dialog
|
|
|
|
int GetPageCount() const;
|
|
|
|
|
|
|
|
// set the currently selected page, return the index of the previously
|
|
|
|
// selected one (or -1 on error)
|
|
|
|
// NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
|
|
|
|
int SetSelection(int nPage);
|
|
|
|
// cycle thru the tabs
|
|
|
|
void AdvanceSelection(bool bForward = TRUE);
|
|
|
|
// get the currently selected page
|
|
|
|
int GetSelection() const;
|
|
|
|
|
|
|
|
// set/get the title of a page
|
|
|
|
bool SetPageText(int nPage, const wxString& strText);
|
|
|
|
wxString GetPageText(int nPage) const;
|
|
|
|
|
|
|
|
// image list stuff: each page may have an image associated with it. All
|
|
|
|
// the images belong to an image list, so you have to
|
|
|
|
// 1) create an image list
|
|
|
|
// 2) associate it with the notebook
|
|
|
|
// 3) set for each page it's image
|
|
|
|
// associate image list with a control
|
|
|
|
void SetImageList(wxImageList* imageList);
|
|
|
|
// get pointer (may be NULL) to the associated image list
|
|
|
|
wxImageList* GetImageList() const { return m_imageList; }
|
|
|
|
|
|
|
|
// sets/returns item's image index in the current image list
|
|
|
|
int GetPageImage(int nPage) const;
|
|
|
|
bool SetPageImage(int nPage, int nImage);
|
|
|
|
|
|
|
|
// currently it's always 1 because wxGTK doesn't support multi-row
|
|
|
|
// tab controls
|
|
|
|
int GetRowCount() const;
|
|
|
|
|
|
|
|
// control the appearance of the notebook pages
|
|
|
|
// set the size (the same for all pages)
|
|
|
|
void SetPageSize(const wxSize& size);
|
|
|
|
// set the padding between tabs (in pixels)
|
|
|
|
void SetPadding(const wxSize& padding);
|
|
|
|
|
|
|
|
// operations
|
|
|
|
// ----------
|
1998-11-24 13:29:09 +00:00
|
|
|
// remove one page from the notebook but do not destroy it
|
|
|
|
bool RemovePage(int nPage);
|
1998-06-26 14:29:11 +00:00
|
|
|
// remove one page from the notebook
|
|
|
|
bool DeletePage(int nPage);
|
|
|
|
// remove all pages
|
|
|
|
bool DeleteAllPages();
|
|
|
|
// adds a new page to the notebook (it will be deleted ny the notebook,
|
|
|
|
// don't delete it yourself). If bSelect, this page becomes active.
|
|
|
|
bool AddPage(wxWindow *pPage,
|
|
|
|
const wxString& strText,
|
|
|
|
bool bSelect = FALSE,
|
|
|
|
int imageId = -1);
|
|
|
|
// @@@@ VZ: I don't know how to implement InsertPage()
|
|
|
|
|
|
|
|
// get the panel which represents the given page
|
|
|
|
wxWindow *GetPage(int nPage) const;
|
|
|
|
|
1998-11-03 11:19:58 +00:00
|
|
|
|
1998-07-13 16:57:43 +00:00
|
|
|
// implementation
|
1998-10-29 18:03:18 +00:00
|
|
|
|
|
|
|
void SetConstraintSizes(bool recurse);
|
|
|
|
bool DoPhase(int phase);
|
|
|
|
void ApplyWidgetStyle();
|
1998-06-26 14:29:11 +00:00
|
|
|
|
|
|
|
// common part of all ctors
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
// helper function
|
|
|
|
wxNotebookPage* GetNotebookPage(int page) const;
|
|
|
|
|
|
|
|
wxImageList* m_imageList;
|
|
|
|
wxList m_pages;
|
1998-08-18 15:36:12 +00:00
|
|
|
size_t m_idHandler; // the change page handler id
|
1998-06-02 19:04:33 +00:00
|
|
|
|
1998-06-26 14:29:11 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
1998-06-02 19:04:33 +00:00
|
|
|
};
|
|
|
|
|
1998-06-26 14:29:11 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// event macros
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&);
|
|
|
|
|
|
|
|
#define EVT_NOTEBOOK_PAGE_CHANGED(id, fn) \
|
|
|
|
{ \
|
|
|
|
wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, \
|
|
|
|
id, \
|
|
|
|
-1, \
|
|
|
|
(wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
|
|
|
|
NULL \
|
|
|
|
},
|
|
|
|
|
|
|
|
#define EVT_NOTEBOOK_PAGE_CHANGING(id, fn) \
|
|
|
|
{ \
|
1998-09-28 14:55:45 +00:00
|
|
|
wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, \
|
1998-06-26 14:29:11 +00:00
|
|
|
id, \
|
|
|
|
-1, \
|
|
|
|
(wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
|
|
|
|
NULL \
|
|
|
|
},
|
1998-06-02 19:04:33 +00:00
|
|
|
|
|
|
|
#endif
|
1998-11-03 11:19:58 +00:00
|
|
|
// __GTKNOTEBOOKH__
|