]>
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 | 7 | // Copyright: (c) Julian Smart |
65571936 | 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 | ||
078cf5cb | 36 | void Create( wxNotebookPage *page , const wxString &text , bool selected , int imageId ) |
8acd402f SC |
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 | ||
91c9dbdc | 52 | WX_DECLARE_EXPORTED_LIST(wxNotebookPageInfo, wxNotebookPageInfoList ); |
8acd402f | 53 | |
1e6feb95 | 54 | class WXDLLEXPORT wxNotebook : public wxNotebookBase |
b5f2afe5 VZ |
55 | { |
56 | public: | |
57 | // ctors | |
58 | // ----- | |
59 | // default for dynamic class | |
60 | wxNotebook(); | |
61 | // the same arguments as for wxControl (@@@ any special styles?) | |
62 | wxNotebook(wxWindow *parent, | |
35eca07c | 63 | wxWindowID id, |
b5f2afe5 VZ |
64 | const wxPoint& pos = wxDefaultPosition, |
65 | const wxSize& size = wxDefaultSize, | |
debe6624 | 66 | long style = 0, |
630ad6c6 | 67 | const wxString& name = wxNotebookNameStr); |
b5f2afe5 VZ |
68 | // Create() function |
69 | bool Create(wxWindow *parent, | |
35eca07c | 70 | wxWindowID id, |
b5f2afe5 VZ |
71 | const wxPoint& pos = wxDefaultPosition, |
72 | const wxSize& size = wxDefaultSize, | |
debe6624 | 73 | long style = 0, |
630ad6c6 | 74 | const wxString& name = wxNotebookNameStr); |
caf95d2a | 75 | virtual ~wxNotebook(); |
b5f2afe5 VZ |
76 | |
77 | // accessors | |
78 | // --------- | |
79 | // get number of pages in the dialog | |
8d34bf5c | 80 | virtual size_t GetPageCount() const; |
b5f2afe5 VZ |
81 | |
82 | // set the currently selected page, return the index of the previously | |
83 | // selected one (or -1 on error) | |
84 | // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events | |
15aad3b9 | 85 | int SetSelection(size_t nPage); |
b5f2afe5 VZ |
86 | // get the currently selected page |
87 | int GetSelection() const { return m_nSelection; } | |
88 | ||
89 | // set/get the title of a page | |
15aad3b9 VZ |
90 | bool SetPageText(size_t nPage, const wxString& strText); |
91 | wxString GetPageText(size_t nPage) const; | |
b5f2afe5 VZ |
92 | |
93 | // image list stuff: each page may have an image associated with it. All | |
94 | // the images belong to an image list, so you have to | |
95 | // 1) create an image list | |
96 | // 2) associate it with the notebook | |
97 | // 3) set for each page it's image | |
98 | // associate image list with a control | |
99 | void SetImageList(wxImageList* imageList); | |
b5f2afe5 VZ |
100 | |
101 | // sets/returns item's image index in the current image list | |
15aad3b9 VZ |
102 | int GetPageImage(size_t nPage) const; |
103 | bool SetPageImage(size_t nPage, int nImage); | |
b5f2afe5 | 104 | |
b5f2afe5 VZ |
105 | // currently it's always 1 because wxGTK doesn't support multi-row |
106 | // tab controls | |
107 | int GetRowCount() const; | |
108 | ||
109 | // control the appearance of the notebook pages | |
110 | // set the size (the same for all pages) | |
111 | void SetPageSize(const wxSize& size); | |
112 | // set the padding between tabs (in pixels) | |
113 | void SetPadding(const wxSize& padding); | |
114 | ||
115 | // operations | |
116 | // ---------- | |
b5f2afe5 VZ |
117 | // remove all pages |
118 | bool DeleteAllPages(); | |
e450aa69 | 119 | |
efa14cf2 | 120 | // inserts a new page to the notebook (it will be deleted ny the notebook, |
b5f2afe5 | 121 | // don't delete it yourself). If bSelect, this page becomes active. |
15aad3b9 | 122 | bool InsertPage(size_t nPage, |
b5f2afe5 VZ |
123 | wxNotebookPage *pPage, |
124 | const wxString& strText, | |
078cf5cb | 125 | bool bSelect = false, |
8a33ea62 | 126 | int imageId = -1); |
b5f2afe5 | 127 | |
8acd402f SC |
128 | void AddPageInfo( wxNotebookPageInfo* info ) { AddPage( info->GetPage() , info->GetText() , info->GetSelected() , info->GetImageId() ) ; } |
129 | const wxNotebookPageInfoList& GetPageInfos() const ; | |
130 | ||
58a8ab88 JS |
131 | // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH |
132 | // style. | |
133 | void SetTabSize(const wxSize& sz); | |
134 | ||
e450aa69 VZ |
135 | // hit test |
136 | virtual int HitTest(const wxPoint& pt, long *flags = NULL) const; | |
137 | ||
138 | // calculate the size of the notebook from the size of its page | |
2ce7af35 JS |
139 | virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; |
140 | ||
b5f2afe5 VZ |
141 | // callbacks |
142 | // --------- | |
9026ad85 | 143 | void OnSize(wxSizeEvent& event); |
b5f2afe5 | 144 | void OnSelChange(wxNotebookEvent& event); |
8a33ea62 | 145 | void OnNavigationKey(wxNavigationKeyEvent& event); |
35eca07c | 146 | |
b5f2afe5 VZ |
147 | // base class virtuals |
148 | // ------------------- | |
0b481c72 | 149 | |
a23fd0e1 | 150 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); |
0df3fbd7 VZ |
151 | virtual bool MSWOnScroll(int orientation, WXWORD nSBCode, |
152 | WXWORD pos, WXHWND control); | |
b8bdaa7c | 153 | virtual bool MSWTranslateMessage(WXMSG *wxmsg); |
0b481c72 VZ |
154 | |
155 | #if wxUSE_CONSTRAINTS | |
078cf5cb | 156 | virtual void SetConstraintSizes(bool recurse = true); |
5475b960 | 157 | virtual bool DoPhase(int nPhase); |
0b481c72 | 158 | #endif // wxUSE_CONSTRAINTS |
b5f2afe5 | 159 | |
caf95d2a VZ |
160 | |
161 | // implementation only | |
162 | // ------------------- | |
163 | ||
164 | #if wxUSE_UXTHEME | |
c4a95f6f VZ |
165 | virtual bool SetBackgroundColour(const wxColour& colour) |
166 | { | |
167 | if ( !wxNotebookBase::SetBackgroundColour(colour) ) | |
168 | return false; | |
caf95d2a | 169 | |
c4a95f6f | 170 | UpdateBgBrush(); |
9b7d2b81 | 171 | |
c4a95f6f VZ |
172 | return true; |
173 | } | |
174 | ||
175 | virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindow *win); | |
176 | virtual wxColour MSWGetBgColourForChild(wxWindow *win); | |
caf95d2a VZ |
177 | #endif // wxUSE_UXTHEME |
178 | ||
b5f2afe5 VZ |
179 | protected: |
180 | // common part of all ctors | |
181 | void Init(); | |
182 | ||
0df3fbd7 VZ |
183 | // translate wxWin styles to the Windows ones |
184 | virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const; | |
185 | ||
1e6feb95 | 186 | // remove one page from the notebook, without deleting |
15aad3b9 | 187 | virtual wxNotebookPage *DoRemovePage(size_t nPage); |
1e6feb95 | 188 | |
2015f2b3 VZ |
189 | // set the size of the given page to fit in the notebook |
190 | void AdjustPageSize(wxNotebookPage *page); | |
191 | ||
ffafd8a5 | 192 | #if wxUSE_UXTHEME |
c4a95f6f VZ |
193 | // this is a slightly ugly function which gets the bitmap of notebook |
194 | // background and either returns the colour under the specified window in it | |
195 | // or creates a brush from it | |
196 | // | |
197 | // so if win == NULL, a brush is created and returned | |
198 | // win != NULL, returns COLORREF of the pixel under its top left corner | |
199 | WXHANDLE QueryBgBitmap(wxWindow *win = NULL); | |
200 | ||
caf95d2a VZ |
201 | // creates the brush to be used for drawing the tab control background |
202 | void UpdateBgBrush(); | |
203 | #endif // wxUSE_UXTHEME | |
2015f2b3 | 204 | |
2b5f62a0 VZ |
205 | // the current selection (-1 if none) |
206 | int m_nSelection; | |
b5f2afe5 | 207 | |
caf95d2a VZ |
208 | wxNotebookPageInfoList m_pageInfos; |
209 | ||
210 | #if wxUSE_UXTHEME | |
211 | // background brush used to paint the tab control | |
212 | WXHBRUSH m_hbrBackground; | |
213 | #endif // wxUSE_UXTHEME | |
8acd402f | 214 | |
2015f2b3 | 215 | |
fc7a2a60 | 216 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxNotebook) |
b5f2afe5 VZ |
217 | DECLARE_EVENT_TABLE() |
218 | }; | |
219 | ||
1e6feb95 VZ |
220 | #endif // wxUSE_NOTEBOOK |
221 | ||
b5f2afe5 | 222 | #endif // _NOTEBOOK_H |