]>
Commit | Line | Data |
---|---|---|
b5f2afe5 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: msw/notebook.h | |
3 | // Purpose: MSW/GTK compatible notebook (a.k.a. property sheet) | |
4 | // Author: Robert Roebling | |
5 | // Modified by: Vadim Zeitlin for Windows version | |
6 | // RCS-ID: $Id$ | |
371a5b4e JS |
7 | // Copyright: (c) Julian Smart |
8 | // Licence: wxWindows licence | |
b5f2afe5 VZ |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | #ifndef _NOTEBOOK_H | |
12 | #define _NOTEBOOK_H | |
13 | ||
12028905 | 14 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
b5f2afe5 VZ |
15 | #pragma interface "notebook.h" |
16 | #endif | |
17 | ||
1e6feb95 VZ |
18 | #if wxUSE_NOTEBOOK |
19 | ||
b5f2afe5 VZ |
20 | // ---------------------------------------------------------------------------- |
21 | // headers | |
22 | // ---------------------------------------------------------------------------- | |
74b31181 | 23 | |
7c0ea335 | 24 | #include "wx/control.h" |
b5f2afe5 | 25 | |
b5f2afe5 VZ |
26 | // ---------------------------------------------------------------------------- |
27 | // wxNotebook | |
28 | // ---------------------------------------------------------------------------- | |
29 | ||
8acd402f SC |
30 | class WXDLLEXPORT wxNotebookPageInfo : public wxObject |
31 | { | |
32 | public : | |
33 | wxNotebookPageInfo() { m_page = NULL ; m_imageId = -1 ; m_selected = false ; } | |
34 | virtual ~wxNotebookPageInfo() { } | |
35 | ||
36 | void Create( wxNotebookPage *page , const wxString &text , bool selected , int imageId ) | |
37 | { m_page = page ; m_text = text ; m_selected = selected ; m_imageId = imageId ; } | |
38 | wxNotebookPage* GetPage() const { return m_page ; } | |
39 | wxString GetText() const { return m_text ; } | |
40 | bool GetSelected() const { return m_selected ; } | |
41 | int GetImageId() const { return m_imageId; } | |
42 | private : | |
43 | wxNotebookPage *m_page ; | |
44 | wxString m_text ; | |
45 | bool m_selected ; | |
46 | int m_imageId ; | |
47 | ||
48 | DECLARE_DYNAMIC_CLASS(wxNotebookPageInfo) ; | |
49 | } ; | |
50 | ||
51 | ||
52 | WX_DECLARE_LIST(wxNotebookPageInfo, wxNotebookPageInfoList); | |
53 | // WX_DECLARE_EXPORTED_LIST(wxNotebookPageInfo, wxNotebookPageInfoList ); | |
54 | // WX_DECLARE_LIST_3(wxNotebookPageInfo, wxNotebookPageInfo, wxNotebookPageInfoList, wxNotebookPageInfoListNode, class WXDLLEXPORT); | |
55 | ||
1e6feb95 | 56 | class WXDLLEXPORT wxNotebook : public wxNotebookBase |
b5f2afe5 VZ |
57 | { |
58 | public: | |
59 | // ctors | |
60 | // ----- | |
61 | // default for dynamic class | |
62 | wxNotebook(); | |
63 | // the same arguments as for wxControl (@@@ any special styles?) | |
64 | wxNotebook(wxWindow *parent, | |
35eca07c | 65 | wxWindowID id, |
b5f2afe5 VZ |
66 | const wxPoint& pos = wxDefaultPosition, |
67 | const wxSize& size = wxDefaultSize, | |
debe6624 | 68 | long style = 0, |
2b5f62a0 | 69 | const wxString& name = wxNOTEBOOK_NAME); |
b5f2afe5 VZ |
70 | // Create() function |
71 | bool Create(wxWindow *parent, | |
35eca07c | 72 | wxWindowID id, |
b5f2afe5 VZ |
73 | const wxPoint& pos = wxDefaultPosition, |
74 | const wxSize& size = wxDefaultSize, | |
debe6624 | 75 | long style = 0, |
2b5f62a0 | 76 | const wxString& name = wxNOTEBOOK_NAME); |
b5f2afe5 VZ |
77 | |
78 | // accessors | |
79 | // --------- | |
80 | // get number of pages in the dialog | |
8d34bf5c | 81 | virtual size_t GetPageCount() const; |
b5f2afe5 VZ |
82 | |
83 | // set the currently selected page, return the index of the previously | |
84 | // selected one (or -1 on error) | |
85 | // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events | |
15aad3b9 | 86 | int SetSelection(size_t nPage); |
b5f2afe5 VZ |
87 | // get the currently selected page |
88 | int GetSelection() const { return m_nSelection; } | |
89 | ||
90 | // set/get the title of a page | |
15aad3b9 VZ |
91 | bool SetPageText(size_t nPage, const wxString& strText); |
92 | wxString GetPageText(size_t nPage) const; | |
b5f2afe5 VZ |
93 | |
94 | // image list stuff: each page may have an image associated with it. All | |
95 | // the images belong to an image list, so you have to | |
96 | // 1) create an image list | |
97 | // 2) associate it with the notebook | |
98 | // 3) set for each page it's image | |
99 | // associate image list with a control | |
100 | void SetImageList(wxImageList* imageList); | |
b5f2afe5 VZ |
101 | |
102 | // sets/returns item's image index in the current image list | |
15aad3b9 VZ |
103 | int GetPageImage(size_t nPage) const; |
104 | bool SetPageImage(size_t nPage, int nImage); | |
b5f2afe5 | 105 | |
b5f2afe5 VZ |
106 | // currently it's always 1 because wxGTK doesn't support multi-row |
107 | // tab controls | |
108 | int GetRowCount() const; | |
109 | ||
110 | // control the appearance of the notebook pages | |
111 | // set the size (the same for all pages) | |
112 | void SetPageSize(const wxSize& size); | |
113 | // set the padding between tabs (in pixels) | |
114 | void SetPadding(const wxSize& padding); | |
115 | ||
85b43fbf JS |
116 | // Windows only: attempts to get colour for UX theme page background |
117 | wxColour GetThemeBackgroundColour(); | |
118 | ||
b5f2afe5 VZ |
119 | // operations |
120 | // ---------- | |
b5f2afe5 VZ |
121 | // remove all pages |
122 | bool DeleteAllPages(); | |
e450aa69 | 123 | |
efa14cf2 | 124 | // inserts a new page to the notebook (it will be deleted ny the notebook, |
b5f2afe5 | 125 | // don't delete it yourself). If bSelect, this page becomes active. |
15aad3b9 | 126 | bool InsertPage(size_t nPage, |
b5f2afe5 VZ |
127 | wxNotebookPage *pPage, |
128 | const wxString& strText, | |
129 | bool bSelect = FALSE, | |
8a33ea62 | 130 | int imageId = -1); |
b5f2afe5 | 131 | |
8acd402f SC |
132 | void AddPageInfo( wxNotebookPageInfo* info ) { AddPage( info->GetPage() , info->GetText() , info->GetSelected() , info->GetImageId() ) ; } |
133 | const wxNotebookPageInfoList& GetPageInfos() const ; | |
134 | ||
58a8ab88 JS |
135 | // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH |
136 | // style. | |
137 | void SetTabSize(const wxSize& sz); | |
138 | ||
85b43fbf JS |
139 | // Windows only: attempts to apply the UX theme page background to this page |
140 | void ApplyThemeBackground(wxWindow* window, const wxColour& colour); | |
17816c2e | 141 | |
e450aa69 VZ |
142 | // hit test |
143 | virtual int HitTest(const wxPoint& pt, long *flags = NULL) const; | |
144 | ||
145 | // calculate the size of the notebook from the size of its page | |
2ce7af35 JS |
146 | virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; |
147 | ||
b5f2afe5 VZ |
148 | // callbacks |
149 | // --------- | |
9026ad85 | 150 | void OnSize(wxSizeEvent& event); |
b5f2afe5 | 151 | void OnSelChange(wxNotebookEvent& event); |
8a33ea62 VZ |
152 | void OnSetFocus(wxFocusEvent& event); |
153 | void OnNavigationKey(wxNavigationKeyEvent& event); | |
35eca07c | 154 | |
b5f2afe5 VZ |
155 | // base class virtuals |
156 | // ------------------- | |
0b481c72 | 157 | |
a23fd0e1 | 158 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); |
0df3fbd7 VZ |
159 | virtual bool MSWOnScroll(int orientation, WXWORD nSBCode, |
160 | WXWORD pos, WXHWND control); | |
0b481c72 VZ |
161 | |
162 | #if wxUSE_CONSTRAINTS | |
5475b960 VZ |
163 | virtual void SetConstraintSizes(bool recurse = TRUE); |
164 | virtual bool DoPhase(int nPhase); | |
0b481c72 | 165 | #endif // wxUSE_CONSTRAINTS |
b5f2afe5 VZ |
166 | |
167 | protected: | |
168 | // common part of all ctors | |
169 | void Init(); | |
170 | ||
0df3fbd7 VZ |
171 | // translate wxWin styles to the Windows ones |
172 | virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const; | |
173 | ||
1e6feb95 | 174 | // remove one page from the notebook, without deleting |
15aad3b9 | 175 | virtual wxNotebookPage *DoRemovePage(size_t nPage); |
1e6feb95 | 176 | |
2015f2b3 VZ |
177 | // set the size of the given page to fit in the notebook |
178 | void AdjustPageSize(wxNotebookPage *page); | |
179 | ||
c02e5a31 JS |
180 | // override WndProc |
181 | virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
2015f2b3 | 182 | |
2b5f62a0 VZ |
183 | // the current selection (-1 if none) |
184 | int m_nSelection; | |
b5f2afe5 | 185 | |
8acd402f SC |
186 | wxNotebookPageInfoList m_pageInfos ; |
187 | ||
2015f2b3 | 188 | |
fc7a2a60 | 189 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxNotebook) |
b5f2afe5 VZ |
190 | DECLARE_EVENT_TABLE() |
191 | }; | |
192 | ||
1e6feb95 VZ |
193 | #endif // wxUSE_NOTEBOOK |
194 | ||
b5f2afe5 | 195 | #endif // _NOTEBOOK_H |