]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/notebook.h
Make generic wxDataViewCtrl draw its contents.
[wxWidgets.git] / include / wx / generic / notebook.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: notebook.h
3 // Purpose: wxNotebook class (a.k.a. property sheet, tabbed dialog)
4 // Author: Julian Smart
5 // Modified by:
6 // RCS-ID: $Id$
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_NOTEBOOK_H_
12 #define _WX_NOTEBOOK_H_
13
14 // ----------------------------------------------------------------------------
15 // headers
16 // ----------------------------------------------------------------------------
17 #include "wx/event.h"
18 #include "wx/control.h"
19
20 // ----------------------------------------------------------------------------
21 // types
22 // ----------------------------------------------------------------------------
23
24 // fwd declarations
25 class WXDLLEXPORT wxImageList;
26 class WXDLLEXPORT wxWindow;
27 class WXDLLEXPORT wxTabView;
28
29 // ----------------------------------------------------------------------------
30 // wxNotebook
31 // ----------------------------------------------------------------------------
32
33 class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase
34 {
35 public:
36 // ctors
37 // -----
38 // default for dynamic class
39 wxNotebook();
40 // the same arguments as for wxControl (@@@ any special styles?)
41 wxNotebook(wxWindow *parent,
42 wxWindowID id,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 long style = 0,
46 const wxString& name = wxNotebookNameStr);
47 // Create() function
48 bool Create(wxWindow *parent,
49 wxWindowID id,
50 const wxPoint& pos = wxDefaultPosition,
51 const wxSize& size = wxDefaultSize,
52 long style = 0,
53 const wxString& name = wxNotebookNameStr);
54 // dtor
55 ~wxNotebook();
56
57 // accessors
58 // ---------
59 // Find the position of the wxNotebookPage, -1 if not found.
60 int FindPagePosition(wxNotebookPage* page) const;
61
62 // set the currently selected page, return the index of the previously
63 // selected one (or -1 on error)
64 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
65 int SetSelection(size_t nPage);
66 // cycle thru the tabs
67 // void AdvanceSelection(bool bForward = true);
68 // get the currently selected page
69 int GetSelection() const { return m_nSelection; }
70
71 // set/get the title of a page
72 bool SetPageText(size_t nPage, const wxString& strText);
73 wxString GetPageText(size_t nPage) const;
74
75 // get the number of rows for a control with wxNB_MULTILINE style (not all
76 // versions support it - they will always return 1 then)
77 virtual int GetRowCount() const ;
78
79 // sets/returns item's image index in the current image list
80 int GetPageImage(size_t nPage) const;
81 bool SetPageImage(size_t nPage, int nImage);
82
83 // control the appearance of the notebook pages
84 // set the size (the same for all pages)
85 void SetPageSize(const wxSize& size);
86 // set the padding between tabs (in pixels)
87 void SetPadding(const wxSize& padding);
88
89 // Sets the size of the tabs (assumes all tabs are the same size)
90 void SetTabSize(const wxSize& sz);
91
92 // operations
93 // ----------
94 // remove one page from the notebook, and delete the page.
95 bool DeletePage(size_t nPage);
96 bool DeletePage(wxNotebookPage* page);
97 // remove one page from the notebook, without deleting the page.
98 bool RemovePage(size_t nPage);
99 bool RemovePage(wxNotebookPage* page);
100 virtual wxWindow* DoRemovePage(size_t nPage);
101
102 // remove all pages
103 bool DeleteAllPages();
104 // the same as AddPage(), but adds it at the specified position
105 bool InsertPage(size_t nPage,
106 wxNotebookPage *pPage,
107 const wxString& strText,
108 bool bSelect = false,
109 int imageId = -1);
110
111 // callbacks
112 // ---------
113 void OnSize(wxSizeEvent& event);
114 void OnInternalIdle();
115 void OnSelChange(wxNotebookEvent& event);
116 void OnSetFocus(wxFocusEvent& event);
117 void OnNavigationKey(wxNavigationKeyEvent& event);
118
119 // base class virtuals
120 // -------------------
121 virtual void Command(wxCommandEvent& event);
122 virtual void SetConstraintSizes(bool recurse = true);
123 virtual bool DoPhase(int nPhase);
124
125 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
126
127 // Implementation
128
129 // wxNotebook on Motif uses a generic wxTabView to implement itself.
130 wxTabView *GetTabView() const { return m_tabView; }
131 void SetTabView(wxTabView *v) { m_tabView = v; }
132
133 void OnMouseEvent(wxMouseEvent& event);
134 void OnPaint(wxPaintEvent& event);
135
136 virtual wxRect GetAvailableClientSize();
137
138 // Implementation: calculate the layout of the view rect
139 // and resize the children if required
140 bool RefreshLayout(bool force = true);
141
142 protected:
143 // common part of all ctors
144 void Init();
145
146 // helper functions
147 void ChangePage(int nOldSel, int nSel); // change pages
148
149 int m_nSelection; // the current selection (-1 if none)
150
151 wxTabView* m_tabView;
152
153 DECLARE_DYNAMIC_CLASS(wxNotebook)
154 DECLARE_EVENT_TABLE()
155 };
156
157 #endif // _WX_NOTEBOOK_H_