2001-06-26 16:59:19 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/univ/notebook.h
|
|
|
|
// Purpose: universal version of wxNotebook
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01.02.01
|
|
|
|
// RCS-ID: $Id$
|
2001-07-02 15:42:27 -04:00
|
|
|
// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2001-06-26 16:59:19 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_UNIV_NOTEBOOK_H_
|
|
|
|
#define _WX_UNIV_NOTEBOOK_H_
|
|
|
|
|
2003-07-21 06:01:56 -04:00
|
|
|
#include "wx/arrstr.h"
|
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxSpinButton;
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// the actions supported by this control
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// change the page: to the next/previous/given one
|
|
|
|
#define wxACTION_NOTEBOOK_NEXT _T("nexttab")
|
|
|
|
#define wxACTION_NOTEBOOK_PREV _T("prevtab")
|
|
|
|
#define wxACTION_NOTEBOOK_GOTO _T("gototab")
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxNotebook
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxNotebook : public wxNotebookBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// ctors and such
|
|
|
|
// --------------
|
|
|
|
|
2004-01-15 08:49:22 -05:00
|
|
|
wxNotebook() { Init(); }
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
wxNotebook(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
2005-01-13 15:30:21 -05:00
|
|
|
const wxString& name = wxNotebookNameStr)
|
2004-01-15 08:49:22 -05:00
|
|
|
{
|
|
|
|
Init();
|
|
|
|
|
|
|
|
(void)Create(parent, id, pos, size, style, name);
|
|
|
|
}
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
// quasi ctor
|
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
2005-01-13 15:30:21 -05:00
|
|
|
const wxString& name = wxNotebookNameStr);
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
// dtor
|
|
|
|
virtual ~wxNotebook();
|
|
|
|
|
|
|
|
// implement wxNotebookBase pure virtuals
|
|
|
|
// --------------------------------------
|
|
|
|
|
2006-10-08 13:37:23 -04:00
|
|
|
virtual int SetSelection(size_t nPage) { return DoSetSelection(nPage, SetSelection_SendEvent); }
|
2005-08-26 04:21:43 -04:00
|
|
|
virtual int GetSelection() const { return (int) m_sel; }
|
2001-06-26 16:59:19 -04:00
|
|
|
|
2006-10-08 13:37:23 -04:00
|
|
|
// changes selected page without sending events
|
|
|
|
int ChangeSelection(size_t nPage) { return DoSetSelection(nPage); }
|
|
|
|
|
2003-08-20 18:57:07 -04:00
|
|
|
virtual bool SetPageText(size_t nPage, const wxString& strText);
|
|
|
|
virtual wxString GetPageText(size_t nPage) const;
|
2001-06-26 16:59:19 -04:00
|
|
|
|
2003-08-20 18:57:07 -04:00
|
|
|
virtual int GetPageImage(size_t nPage) const;
|
|
|
|
virtual bool SetPageImage(size_t nPage, int nImage);
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
virtual void SetPageSize(const wxSize& size);
|
|
|
|
virtual void SetPadding(const wxSize& padding);
|
|
|
|
virtual void SetTabSize(const wxSize& sz);
|
|
|
|
|
2003-06-01 09:13:03 -04:00
|
|
|
virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
virtual bool DeleteAllPages();
|
|
|
|
|
2003-08-20 18:57:07 -04:00
|
|
|
virtual bool InsertPage(size_t nPage,
|
2001-06-26 16:59:19 -04:00
|
|
|
wxNotebookPage *pPage,
|
|
|
|
const wxString& strText,
|
2004-08-10 09:08:43 -04:00
|
|
|
bool bSelect = false,
|
2001-06-26 16:59:19 -04:00
|
|
|
int imageId = -1);
|
|
|
|
|
|
|
|
// style tests
|
|
|
|
// -----------
|
|
|
|
|
2004-08-10 09:08:43 -04:00
|
|
|
// return true if all tabs have the same width
|
2003-10-07 09:37:43 -04:00
|
|
|
bool FixedSizeTabs() const { return HasFlag(wxNB_FIXEDWIDTH); }
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
// return wxTOP/wxBOTTOM/wxRIGHT/wxLEFT
|
|
|
|
wxDirection GetTabOrientation() const;
|
|
|
|
|
2004-08-10 09:08:43 -04:00
|
|
|
// return true if the notebook has tabs at the sidesand not at the top (or
|
2001-06-26 16:59:19 -04:00
|
|
|
// bottom) as usual
|
|
|
|
bool IsVertical() const;
|
|
|
|
|
|
|
|
// hit testing
|
|
|
|
// -----------
|
|
|
|
|
2003-07-06 17:02:24 -04:00
|
|
|
virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
// input handling
|
|
|
|
// --------------
|
|
|
|
|
|
|
|
virtual bool PerformAction(const wxControlAction& action,
|
|
|
|
long numArg = 0l,
|
|
|
|
const wxString& strArg = wxEmptyString);
|
|
|
|
|
2006-09-14 15:36:47 -04:00
|
|
|
static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
|
|
|
|
virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
|
|
|
|
{
|
|
|
|
return GetStdInputHandler(handlerDef);
|
|
|
|
}
|
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
// refresh the currently selected tab
|
|
|
|
void RefreshCurrent();
|
|
|
|
|
|
|
|
protected:
|
2003-08-20 18:57:07 -04:00
|
|
|
virtual wxNotebookPage *DoRemovePage(size_t nPage);
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
// drawing
|
|
|
|
virtual void DoDraw(wxControlRenderer *renderer);
|
|
|
|
void DoDrawTab(wxDC& dc, const wxRect& rect, size_t n);
|
|
|
|
|
|
|
|
// resizing
|
|
|
|
virtual wxSize DoGetBestClientSize() const;
|
|
|
|
virtual void DoMoveWindow(int x, int y, int width, int height);
|
|
|
|
virtual void DoSetSize(int x, int y,
|
|
|
|
int width, int height,
|
|
|
|
int sizeFlags = wxSIZE_AUTO);
|
|
|
|
|
2006-10-08 13:37:23 -04:00
|
|
|
int DoSetSelection(size_t nPage, int flags = 0);
|
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
// common part of all ctors
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
// resize the tab to fit its title (and icon if any)
|
|
|
|
void ResizeTab(int page);
|
|
|
|
|
|
|
|
// recalculate the geometry of the notebook completely
|
|
|
|
void Relayout();
|
|
|
|
|
|
|
|
// is the spin button currently shown?
|
|
|
|
bool HasSpinBtn() const;
|
|
|
|
|
|
|
|
// calculate last (fully) visible tab: updates m_lastVisible
|
|
|
|
void CalcLastVisibleTab();
|
|
|
|
|
|
|
|
// show or hide the spin control for tabs scrolling depending on whether it
|
|
|
|
// is needed or not
|
|
|
|
void UpdateSpinBtn();
|
|
|
|
|
|
|
|
// position the spin button
|
|
|
|
void PositionSpinBtn();
|
|
|
|
|
|
|
|
// refresh the given tab only
|
2004-08-10 09:08:43 -04:00
|
|
|
void RefreshTab(int page, bool forceSelected = false);
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
// refresh all tabs
|
|
|
|
void RefreshAllTabs();
|
|
|
|
|
|
|
|
// get the tab rect (inefficient, don't use this in a loop)
|
|
|
|
wxRect GetTabRect(int page) const;
|
|
|
|
|
|
|
|
// get the rectangle containing all tabs
|
|
|
|
wxRect GetAllTabsRect() const;
|
|
|
|
|
|
|
|
// get the part occupied by the tabs - slightly smaller than
|
|
|
|
// GetAllTabsRect() because the tabs may be indented from it
|
|
|
|
wxRect GetTabsPart() const;
|
|
|
|
|
|
|
|
// calculate the tab size (without padding)
|
|
|
|
wxSize CalcTabSize(int page) const;
|
|
|
|
|
|
|
|
// get the (cached) size of a tab
|
|
|
|
void GetTabSize(int page, wxCoord *w, wxCoord *h) const;
|
|
|
|
|
|
|
|
// get the (cached) width of the tab
|
|
|
|
wxCoord GetTabWidth(int page) const
|
|
|
|
{ return FixedSizeTabs() ? m_widthMax : m_widths[page]; }
|
|
|
|
|
2004-08-10 09:08:43 -04:00
|
|
|
// return true if the tab has an associated image
|
2001-06-26 16:59:19 -04:00
|
|
|
bool HasImage(int page) const
|
|
|
|
{ return m_imageList && m_images[page] != -1; }
|
|
|
|
|
|
|
|
// get the part of the notebook reserved for the pages (slightly larger
|
|
|
|
// than GetPageRect() as we draw a border and leave marginin between)
|
|
|
|
wxRect GetPagePart() const;
|
|
|
|
|
|
|
|
// get the page rect in our client coords
|
|
|
|
wxRect GetPageRect() const;
|
|
|
|
|
|
|
|
// get our client size from the page size
|
|
|
|
wxSize GetSizeForPage(const wxSize& size) const;
|
|
|
|
|
|
|
|
// scroll the tabs so that the first page shown becomes the given one
|
|
|
|
void ScrollTo(int page);
|
|
|
|
|
|
|
|
// scroll the tabs so that the first page shown becomes the given one
|
|
|
|
void ScrollLastTo(int page);
|
|
|
|
|
|
|
|
// the pages titles
|
|
|
|
wxArrayString m_titles;
|
|
|
|
|
|
|
|
// the current selection
|
|
|
|
size_t m_sel;
|
|
|
|
|
|
|
|
// the spin button to change the pages
|
|
|
|
wxSpinButton *m_spinbtn;
|
|
|
|
|
|
|
|
// the offset of the first page shown (may be changed with m_spinbtn)
|
|
|
|
wxCoord m_offset;
|
|
|
|
|
|
|
|
// the first and last currently visible tabs: the name is not completely
|
|
|
|
// accurate as m_lastVisible is, in fact, the first tab which is *not*
|
|
|
|
// visible: so the visible tabs are those with indexes such that
|
|
|
|
// m_firstVisible <= n < m_lastVisible
|
|
|
|
size_t m_firstVisible,
|
|
|
|
m_lastVisible;
|
|
|
|
|
|
|
|
// the last fully visible item, usually just m_lastVisible - 1 but may be
|
|
|
|
// different from it
|
|
|
|
size_t m_lastFullyVisible;
|
|
|
|
|
|
|
|
// the height of tabs in a normal notebook or the width of tabs in a
|
|
|
|
// notebook with tabs on a side
|
|
|
|
wxCoord m_heightTab;
|
|
|
|
|
|
|
|
// the biggest height (or width) of a notebook tab (used only if
|
|
|
|
// FixedSizeTabs()) or -1 if not calculated yet
|
|
|
|
wxCoord m_widthMax;
|
|
|
|
|
|
|
|
// the cached widths (or heights) of tabs
|
|
|
|
wxArrayInt m_widths;
|
|
|
|
|
|
|
|
// the icon indices
|
|
|
|
wxArrayInt m_images;
|
|
|
|
|
|
|
|
// the accel indexes for labels
|
|
|
|
wxArrayInt m_accels;
|
|
|
|
|
|
|
|
// the padding
|
|
|
|
wxSize m_sizePad;
|
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_UNIV_NOTEBOOK_H_
|
|
|
|
|