1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        wx/gtk/notebook.h
3 // Purpose:     wxNotebook class
4 // Author:      Robert Roebling
5 // Modified by:
6 // Copyright:   (c) Julian Smart and Robert Roebling
7 // Licence:     wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9 
10 #ifndef _WX_GTKNOTEBOOK_H_
11 #define _WX_GTKNOTEBOOK_H_
12 
13 //-----------------------------------------------------------------------------
14 // internal class
15 //-----------------------------------------------------------------------------
16 
17 class WXDLLIMPEXP_FWD_CORE wxGtkNotebookPage;
18 
19 #include "wx/list.h"
20 WX_DECLARE_LIST(wxGtkNotebookPage, wxGtkNotebookPagesList);
21 
22 //-----------------------------------------------------------------------------
23 // wxNotebook
24 //-----------------------------------------------------------------------------
25 
26 class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase
27 {
28 public:
29       // default for dynamic class
30     wxNotebook();
31       // the same arguments as for wxControl
32     wxNotebook(wxWindow *parent,
33              wxWindowID id,
34              const wxPoint& pos = wxDefaultPosition,
35              const wxSize& size = wxDefaultSize,
36              long style = 0,
37              const wxString& name = wxASCII_STR(wxNotebookNameStr));
38       // Create() function
39     bool Create(wxWindow *parent,
40               wxWindowID id,
41               const wxPoint& pos = wxDefaultPosition,
42               const wxSize& size = wxDefaultSize,
43               long style = 0,
44               const wxString& name = wxASCII_STR(wxNotebookNameStr));
45       // dtor
46     virtual ~wxNotebook();
47 
48   // accessors
49   // ---------
50 
51     // set the currently selected page, return the index of the previously
52     // selected one (or wxNOT_FOUND on error)
53     // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
SetSelection(size_t nPage)54     int SetSelection(size_t nPage) wxOVERRIDE { return DoSetSelection(nPage, SetSelection_SendEvent); }
55     // get the currently selected page
56   int GetSelection() const wxOVERRIDE;
57 
58   // changes selected page without sending events
ChangeSelection(size_t nPage)59   int ChangeSelection(size_t nPage) wxOVERRIDE { return DoSetSelection(nPage); }
60 
61     // set/get the title of a page
62   bool SetPageText(size_t nPage, const wxString& strText) wxOVERRIDE;
63   wxString GetPageText(size_t nPage) const wxOVERRIDE;
64 
65     // sets/returns item's image index in the current image list
66   int  GetPageImage(size_t nPage) const wxOVERRIDE;
67   bool SetPageImage(size_t nPage, int nImage) wxOVERRIDE;
68 
69   // control the appearance of the notebook pages
70     // set the padding between tabs (in pixels)
71   void SetPadding(const wxSize& padding) wxOVERRIDE;
72     // sets the size of the tabs (assumes all tabs are the same size)
73   void SetTabSize(const wxSize& sz) wxOVERRIDE;
74 
75   // geometry
76   virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const wxOVERRIDE;
77   virtual int HitTest(const wxPoint& pt, long *flags = NULL) const wxOVERRIDE;
78 
79   // operations
80   // ----------
81     // remove all pages
82   bool DeleteAllPages() wxOVERRIDE;
83 
84     // adds a new page to the notebook (it will be deleted by the notebook,
85     // don't delete it yourself). If bSelect, this page becomes active.
86     // the same as AddPage(), but adds it at the specified position
87     bool InsertPage( size_t position,
88                      wxNotebookPage *win,
89                      const wxString& strText,
90                      bool bSelect = false,
91                      int imageId = NO_IMAGE ) wxOVERRIDE;
92 
93     // handler for tab navigation
94     // --------------------------
95     void OnNavigationKey(wxNavigationKeyEvent& event);
96 
97 
98     static wxVisualAttributes
99     GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
100 
101     // implementation
102     // --------------
103 
104 #if wxUSE_CONSTRAINTS
105     void SetConstraintSizes(bool recurse) wxOVERRIDE;
106     bool DoPhase(int phase) wxOVERRIDE;
107 #endif
108 
109     // Called by GTK event handler when the current page is definitely changed.
110     void GTKOnPageChanged();
111 
112     // helper function
113     wxGtkNotebookPage* GetNotebookPage(int page) const;
114 
115     // the additional page data (the pages themselves are in m_pages array)
116     wxGtkNotebookPagesList m_pagesData;
117 
118     // we need to store the old selection since there
119     // is no other way to know about it at the time
120     // of the change selection event
121     int m_oldSelection;
122 
123 protected:
124     // set all page's attributes
125     virtual void DoApplyWidgetStyle(GtkRcStyle *style) wxOVERRIDE;
126     virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const wxOVERRIDE;
127 
128     // remove one page from the notebook but do not destroy it
129     virtual wxNotebookPage *DoRemovePage(size_t nPage) wxOVERRIDE;
130 
131     int DoSetSelection(size_t nPage, int flags = 0) wxOVERRIDE;
132 
133 private:
134     // the padding set by SetPadding()
135     int m_padding;
136 
137     void Init();
138     virtual void AddChildGTK(wxWindowGTK* child) wxOVERRIDE;
139 
140     wxDECLARE_DYNAMIC_CLASS(wxNotebook);
141     wxDECLARE_EVENT_TABLE();
142 };
143 
144 #endif // _WX_GTKNOTEBOOK_H_
145