1998-06-14 19:16:19 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2006-02-12 08:06:54 -05:00
|
|
|
// Name: wx/msw/notebook.h
|
1998-06-14 19:16:19 -04:00
|
|
|
// Purpose: MSW/GTK compatible notebook (a.k.a. property sheet)
|
|
|
|
// Author: Robert Roebling
|
|
|
|
// Modified by: Vadim Zeitlin for Windows version
|
|
|
|
// RCS-ID: $Id$
|
2003-03-17 05:34:04 -05:00
|
|
|
// Copyright: (c) Julian Smart
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-06-14 19:16:19 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _NOTEBOOK_H
|
|
|
|
#define _NOTEBOOK_H
|
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
#if wxUSE_NOTEBOOK
|
|
|
|
|
1998-06-14 19:16:19 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
1999-09-29 18:47:56 -04:00
|
|
|
|
1999-11-16 16:31:40 -05:00
|
|
|
#include "wx/control.h"
|
1998-06-14 19:16:19 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxNotebook
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxNotebookPageInfo : public wxObject
|
2003-08-14 14:06:49 -04:00
|
|
|
{
|
|
|
|
public :
|
2005-02-06 11:17:18 -05:00
|
|
|
wxNotebookPageInfo() { m_page = NULL; m_imageId = -1; m_selected = false; }
|
2003-08-14 14:06:49 -04:00
|
|
|
virtual ~wxNotebookPageInfo() { }
|
|
|
|
|
2005-02-06 11:17:18 -05:00
|
|
|
void Create(wxNotebookPage *page,
|
|
|
|
const wxString& text,
|
|
|
|
bool selected,
|
|
|
|
int imageId)
|
|
|
|
{
|
|
|
|
m_page = page;
|
|
|
|
m_text = text;
|
|
|
|
m_selected = selected;
|
|
|
|
m_imageId = imageId;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxNotebookPage* GetPage() const { return m_page; }
|
|
|
|
wxString GetText() const { return m_text; }
|
|
|
|
bool GetSelected() const { return m_selected; }
|
2003-08-14 14:06:49 -04:00
|
|
|
int GetImageId() const { return m_imageId; }
|
|
|
|
|
2005-02-06 11:17:18 -05:00
|
|
|
private:
|
|
|
|
wxNotebookPage *m_page;
|
|
|
|
wxString m_text;
|
|
|
|
bool m_selected;
|
|
|
|
int m_imageId;
|
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxNotebookPageInfo)
|
|
|
|
};
|
2003-08-14 14:06:49 -04:00
|
|
|
|
|
|
|
|
2003-08-24 11:41:05 -04:00
|
|
|
WX_DECLARE_EXPORTED_LIST(wxNotebookPageInfo, wxNotebookPageInfoList );
|
2003-08-14 14:06:49 -04:00
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase
|
1998-06-14 19:16:19 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// ctors
|
|
|
|
// -----
|
|
|
|
// default for dynamic class
|
|
|
|
wxNotebook();
|
|
|
|
// the same arguments as for wxControl (@@@ any special styles?)
|
|
|
|
wxNotebook(wxWindow *parent,
|
1998-08-07 13:32:54 -04:00
|
|
|
wxWindowID id,
|
1998-06-14 19:16:19 -04:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
1998-07-04 11:17:59 -04:00
|
|
|
long style = 0,
|
2005-01-13 15:30:21 -05:00
|
|
|
const wxString& name = wxNotebookNameStr);
|
1998-06-14 19:16:19 -04:00
|
|
|
// Create() function
|
|
|
|
bool Create(wxWindow *parent,
|
1998-08-07 13:32:54 -04:00
|
|
|
wxWindowID id,
|
1998-06-14 19:16:19 -04:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
1998-07-04 11:17:59 -04:00
|
|
|
long style = 0,
|
2005-01-13 15:30:21 -05:00
|
|
|
const wxString& name = wxNotebookNameStr);
|
2004-11-19 13:36:45 -05:00
|
|
|
virtual ~wxNotebook();
|
1998-06-14 19:16:19 -04:00
|
|
|
|
|
|
|
// accessors
|
|
|
|
// ---------
|
|
|
|
// get number of pages in the dialog
|
2003-08-21 08:54:31 -04:00
|
|
|
virtual size_t GetPageCount() const;
|
1998-06-14 19:16:19 -04:00
|
|
|
|
|
|
|
// set the currently selected page, return the index of the previously
|
2010-10-27 12:54:24 -04:00
|
|
|
// selected one (or wxNOT_FOUND on error)
|
1998-06-14 19:16:19 -04:00
|
|
|
// NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
|
2003-08-20 18:57:07 -04:00
|
|
|
int SetSelection(size_t nPage);
|
1998-06-14 19:16:19 -04:00
|
|
|
|
2006-10-08 13:37:23 -04:00
|
|
|
// changes selected page without sending events
|
|
|
|
int ChangeSelection(size_t nPage);
|
|
|
|
|
1998-06-14 19:16:19 -04:00
|
|
|
// set/get the title of a page
|
2003-08-20 18:57:07 -04:00
|
|
|
bool SetPageText(size_t nPage, const wxString& strText);
|
|
|
|
wxString GetPageText(size_t nPage) const;
|
1998-06-14 19:16:19 -04:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
// sets/returns item's image index in the current image list
|
2003-08-20 18:57:07 -04:00
|
|
|
int GetPageImage(size_t nPage) const;
|
|
|
|
bool SetPageImage(size_t nPage, int nImage);
|
1998-06-14 19:16:19 -04:00
|
|
|
|
|
|
|
// 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
|
|
|
|
// ----------
|
|
|
|
// remove all pages
|
|
|
|
bool DeleteAllPages();
|
2003-07-06 17:02:24 -04:00
|
|
|
|
2003-04-06 13:46:48 -04:00
|
|
|
// inserts a new page to the notebook (it will be deleted ny the notebook,
|
1998-06-14 19:16:19 -04:00
|
|
|
// don't delete it yourself). If bSelect, this page becomes active.
|
2003-08-20 18:57:07 -04:00
|
|
|
bool InsertPage(size_t nPage,
|
1998-06-14 19:16:19 -04:00
|
|
|
wxNotebookPage *pPage,
|
|
|
|
const wxString& strText,
|
2004-08-31 08:38:46 -04:00
|
|
|
bool bSelect = false,
|
1998-07-08 18:39:21 -04:00
|
|
|
int imageId = -1);
|
1998-06-14 19:16:19 -04:00
|
|
|
|
2005-02-06 11:17:18 -05:00
|
|
|
void AddPageInfo( wxNotebookPageInfo* info ) { AddPage( info->GetPage() , info->GetText() , info->GetSelected() , info->GetImageId() ); }
|
|
|
|
const wxNotebookPageInfoList& GetPageInfos() const;
|
2003-08-14 14:06:49 -04:00
|
|
|
|
1999-03-21 17:39:45 -05:00
|
|
|
// Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
|
|
|
|
// style.
|
|
|
|
void SetTabSize(const wxSize& sz);
|
|
|
|
|
2003-07-06 17:02:24 -04:00
|
|
|
// hit test
|
|
|
|
virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
|
|
|
|
|
|
|
|
// calculate the size of the notebook from the size of its page
|
2003-06-01 09:13:03 -04:00
|
|
|
virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
|
|
|
|
|
1998-06-14 19:16:19 -04:00
|
|
|
// callbacks
|
|
|
|
// ---------
|
1999-06-10 16:48:15 -04:00
|
|
|
void OnSize(wxSizeEvent& event);
|
1998-07-08 18:39:21 -04:00
|
|
|
void OnNavigationKey(wxNavigationKeyEvent& event);
|
1998-08-07 13:32:54 -04:00
|
|
|
|
1998-06-14 19:16:19 -04:00
|
|
|
// base class virtuals
|
|
|
|
// -------------------
|
2003-01-14 14:40:55 -05:00
|
|
|
|
1999-05-13 17:21:04 -04:00
|
|
|
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
2002-04-09 20:22:49 -04:00
|
|
|
virtual bool MSWOnScroll(int orientation, WXWORD nSBCode,
|
|
|
|
WXWORD pos, WXHWND control);
|
2003-01-14 14:40:55 -05:00
|
|
|
|
|
|
|
#if wxUSE_CONSTRAINTS
|
2004-08-31 08:38:46 -04:00
|
|
|
virtual void SetConstraintSizes(bool recurse = true);
|
1998-07-12 18:47:09 -04:00
|
|
|
virtual bool DoPhase(int nPhase);
|
2003-01-14 14:40:55 -05:00
|
|
|
#endif // wxUSE_CONSTRAINTS
|
1998-06-14 19:16:19 -04:00
|
|
|
|
2005-02-06 14:17:35 -05:00
|
|
|
// Attempts to get colour for UX theme page background
|
|
|
|
wxColour GetThemeBackgroundColour() const;
|
2004-11-19 13:36:45 -05:00
|
|
|
|
|
|
|
// implementation only
|
|
|
|
// -------------------
|
|
|
|
|
|
|
|
#if wxUSE_UXTHEME
|
2004-12-12 19:11:14 -05:00
|
|
|
virtual bool SetBackgroundColour(const wxColour& colour)
|
|
|
|
{
|
|
|
|
if ( !wxNotebookBase::SetBackgroundColour(colour) )
|
|
|
|
return false;
|
2004-11-19 13:36:45 -05:00
|
|
|
|
2004-12-12 19:11:14 -05:00
|
|
|
UpdateBgBrush();
|
2004-11-19 15:50:25 -05:00
|
|
|
|
2004-12-12 19:11:14 -05:00
|
|
|
return true;
|
|
|
|
}
|
2006-02-08 16:47:09 -05:00
|
|
|
|
|
|
|
// return the themed brush for painting our children
|
2009-12-18 15:49:23 -05:00
|
|
|
virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindow *child);
|
2006-02-08 16:47:09 -05:00
|
|
|
|
|
|
|
// draw child background
|
|
|
|
virtual bool MSWPrintChild(WXHDC hDC, wxWindow *win);
|
2010-08-10 17:48:17 -04:00
|
|
|
|
|
|
|
virtual bool MSWHasInheritableBackground() const { return true; }
|
2006-02-12 08:06:54 -05:00
|
|
|
#endif // wxUSE_UXTHEME
|
|
|
|
|
|
|
|
// translate wxWin styles to the Windows ones
|
|
|
|
virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
|
2006-02-08 16:47:09 -05:00
|
|
|
|
1998-06-14 19:16:19 -04:00
|
|
|
protected:
|
|
|
|
// common part of all ctors
|
|
|
|
void Init();
|
|
|
|
|
2006-10-09 08:10:01 -04:00
|
|
|
// hides the currently shown page and shows the given one (if not -1) and
|
2010-10-27 12:54:36 -04:00
|
|
|
// updates m_selection accordingly
|
2006-10-09 08:10:01 -04:00
|
|
|
void UpdateSelection(int selNew);
|
2006-10-08 13:37:23 -04:00
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
// remove one page from the notebook, without deleting
|
2003-08-20 18:57:07 -04:00
|
|
|
virtual wxNotebookPage *DoRemovePage(size_t nPage);
|
2001-06-26 16:59:19 -04:00
|
|
|
|
2005-04-10 11:23:08 -04:00
|
|
|
// get the page rectangle for the current notebook size
|
|
|
|
//
|
|
|
|
// returns empty rectangle if an error occurs, do test for it
|
|
|
|
wxRect GetPageSize() const;
|
|
|
|
|
2003-05-01 12:39:59 -04:00
|
|
|
// set the size of the given page to fit in the notebook
|
|
|
|
void AdjustPageSize(wxNotebookPage *page);
|
|
|
|
|
2003-12-11 17:20:22 -05:00
|
|
|
#if wxUSE_UXTHEME
|
2005-03-23 15:59:00 -05:00
|
|
|
// gets the bitmap of notebook background and returns a brush from it
|
|
|
|
WXHBRUSH QueryBgBitmap();
|
2004-12-12 19:11:14 -05:00
|
|
|
|
2004-11-19 13:36:45 -05:00
|
|
|
// creates the brush to be used for drawing the tab control background
|
|
|
|
void UpdateBgBrush();
|
2005-02-19 15:49:50 -05:00
|
|
|
|
2005-04-10 11:23:08 -04:00
|
|
|
// common part of QueryBgBitmap() and MSWPrintChild()
|
|
|
|
//
|
|
|
|
// if child == NULL, draw background for the entire notebook itself
|
|
|
|
bool DoDrawBackground(WXHDC hDC, wxWindow *child = NULL);
|
2004-11-19 13:36:45 -05:00
|
|
|
#endif // wxUSE_UXTHEME
|
2003-05-01 12:39:59 -04:00
|
|
|
|
2005-05-24 15:18:15 -04:00
|
|
|
// these function are only used for reducing flicker on notebook resize and
|
|
|
|
// we don't need to do this for WinCE
|
|
|
|
#ifndef __WXWINCE__
|
|
|
|
void OnEraseBackground(wxEraseEvent& event);
|
|
|
|
void OnPaint(wxPaintEvent& event);
|
|
|
|
|
|
|
|
// true if we have already subclassed our updown control
|
|
|
|
bool m_hasSubclassedUpdown;
|
|
|
|
#endif // __WXWINCE__
|
|
|
|
|
1998-06-14 19:16:19 -04:00
|
|
|
|
2004-11-19 13:36:45 -05:00
|
|
|
wxNotebookPageInfoList m_pageInfos;
|
|
|
|
|
|
|
|
#if wxUSE_UXTHEME
|
|
|
|
// background brush used to paint the tab control
|
|
|
|
WXHBRUSH m_hbrBackground;
|
|
|
|
#endif // wxUSE_UXTHEME
|
2003-08-14 14:06:49 -04:00
|
|
|
|
2003-05-01 12:39:59 -04:00
|
|
|
|
2003-07-21 20:24:07 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxNotebook)
|
1998-06-14 19:16:19 -04:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
#endif // wxUSE_NOTEBOOK
|
|
|
|
|
1998-06-14 19:16:19 -04:00
|
|
|
#endif // _NOTEBOOK_H
|