]>
Commit | Line | Data |
---|---|---|
88310e2e | 1 | /////////////////////////////////////////////////////////////////////////////// |
2ddb4d13 | 2 | // Name: src/msw/notebook.cpp |
88310e2e VZ |
3 | // Purpose: implementation of wxNotebook |
4 | // Author: Vadim Zeitlin | |
907f37b3 | 5 | // Modified by: |
88310e2e VZ |
6 | // Created: 11.06.98 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> | |
65571936 | 9 | // Licence: wxWindows licence |
88310e2e VZ |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
88310e2e VZ |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
1e6feb95 | 16 | #pragma hdrstop |
88310e2e VZ |
17 | #endif |
18 | ||
1e6feb95 VZ |
19 | #if wxUSE_NOTEBOOK |
20 | ||
57bd4c60 | 21 | #include "wx/notebook.h" |
e4db172a | 22 | |
88310e2e | 23 | #ifndef WX_PRECOMP |
57bd4c60 WS |
24 | #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly" |
25 | #include "wx/string.h" | |
26 | #include "wx/dc.h" | |
27 | #include "wx/log.h" | |
28 | #include "wx/event.h" | |
29 | #include "wx/app.h" | |
30 | #include "wx/dcclient.h" | |
31 | #include "wx/dcmemory.h" | |
32 | #include "wx/control.h" | |
bb93b4a8 | 33 | #include "wx/panel.h" |
88310e2e VZ |
34 | #endif // WX_PRECOMP |
35 | ||
57bd4c60 WS |
36 | #include "wx/imaglist.h" |
37 | #include "wx/sysopt.h" | |
88310e2e | 38 | |
57bd4c60 | 39 | #include "wx/msw/private.h" |
74052fe8 | 40 | #include "wx/msw/dc.h" |
88310e2e | 41 | |
57bd4c60 | 42 | #include <windowsx.h> |
85b43fbf JS |
43 | #include "wx/msw/winundef.h" |
44 | ||
45 | #if wxUSE_UXTHEME | |
caf95d2a | 46 | #include "wx/msw/uxtheme.h" |
85b43fbf JS |
47 | #endif |
48 | ||
88310e2e VZ |
49 | // ---------------------------------------------------------------------------- |
50 | // macros | |
51 | // ---------------------------------------------------------------------------- | |
52 | ||
53 | // check that the page index is valid | |
8d34bf5c | 54 | #define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount()) |
88310e2e | 55 | |
014ee083 VZ |
56 | // you can set USE_NOTEBOOK_ANTIFLICKER to 0 for desktop Windows versions too |
57 | // to disable code whih results in flicker-less notebook redrawing at the | |
58 | // expense of some extra GDI resource consumption | |
254fbd14 | 59 | #ifdef __WXWINCE__ |
014ee083 VZ |
60 | // notebooks are never resized under CE anyhow |
61 | #define USE_NOTEBOOK_ANTIFLICKER 0 | |
254fbd14 | 62 | #else |
014ee083 | 63 | #define USE_NOTEBOOK_ANTIFLICKER 1 |
254fbd14 JS |
64 | #endif |
65 | ||
74b31181 VZ |
66 | // ---------------------------------------------------------------------------- |
67 | // constants | |
68 | // ---------------------------------------------------------------------------- | |
69 | ||
70 | // This is a work-around for missing defines in gcc-2.95 headers | |
71 | #ifndef TCS_RIGHT | |
72 | #define TCS_RIGHT 0x0002 | |
73 | #endif | |
74 | ||
75 | #ifndef TCS_VERTICAL | |
76 | #define TCS_VERTICAL 0x0080 | |
77 | #endif | |
78 | ||
79 | #ifndef TCS_BOTTOM | |
80 | #define TCS_BOTTOM TCS_RIGHT | |
81 | #endif | |
82 | ||
014ee083 VZ |
83 | // ---------------------------------------------------------------------------- |
84 | // global variables | |
85 | // ---------------------------------------------------------------------------- | |
86 | ||
87 | #if USE_NOTEBOOK_ANTIFLICKER | |
88 | ||
89 | // the pointer to standard spin button wnd proc | |
90 | static WXFARPROC gs_wndprocNotebookSpinBtn = (WXFARPROC)NULL; | |
91 | ||
6143d3b6 | 92 | // the pointer to standard tab control wnd proc |
e1cffcd6 | 93 | static WXFARPROC gs_wndprocNotebook = (WXFARPROC)NULL; |
6143d3b6 VZ |
94 | |
95 | LRESULT APIENTRY _EXPORT wxNotebookWndProc(HWND hwnd, | |
96 | UINT message, | |
97 | WPARAM wParam, | |
98 | LPARAM lParam); | |
99 | ||
014ee083 VZ |
100 | #endif // USE_NOTEBOOK_ANTIFLICKER |
101 | ||
b013c971 VZ |
102 | // ---------------------------------------------------------------------------- |
103 | // global functions | |
104 | // ---------------------------------------------------------------------------- | |
105 | ||
106 | static bool HasTroubleWithNonTopTabs() | |
107 | { | |
108 | const int verComCtl32 = wxApp::GetComCtl32Version(); | |
109 | ||
110 | // 600 is XP, 616 is Vista -- and both have a problem with tabs not on top | |
111 | // (but don't just test for >= 600 as Microsoft might decide to fix it in | |
112 | // later versions, who knows...) | |
113 | return verComCtl32 >= 600 && verComCtl32 <= 616; | |
114 | } | |
115 | ||
88310e2e VZ |
116 | // ---------------------------------------------------------------------------- |
117 | // event table | |
118 | // ---------------------------------------------------------------------------- | |
119 | ||
7ec69821 | 120 | #include "wx/listimpl.cpp" |
51741307 | 121 | |
259c43f6 | 122 | WX_DEFINE_LIST( wxNotebookPageInfoList ) |
51741307 | 123 | |
8dba4c72 | 124 | BEGIN_EVENT_TABLE(wxNotebook, wxBookCtrlBase) |
9026ad85 | 125 | EVT_SIZE(wxNotebook::OnSize) |
88310e2e | 126 | EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) |
014ee083 VZ |
127 | |
128 | #if USE_NOTEBOOK_ANTIFLICKER | |
129 | EVT_ERASE_BACKGROUND(wxNotebook::OnEraseBackground) | |
130 | EVT_PAINT(wxNotebook::OnPaint) | |
131 | #endif // USE_NOTEBOOK_ANTIFLICKER | |
d9317fd4 | 132 | END_EVENT_TABLE() |
88310e2e | 133 | |
51596bcb | 134 | #if wxUSE_EXTENDED_RTTI |
bc9fb572 JS |
135 | WX_DEFINE_FLAGS( wxNotebookStyle ) |
136 | ||
3ff066a4 | 137 | wxBEGIN_FLAGS( wxNotebookStyle ) |
bc9fb572 JS |
138 | // new style border flags, we put them first to |
139 | // use them for streaming out | |
3ff066a4 SC |
140 | wxFLAGS_MEMBER(wxBORDER_SIMPLE) |
141 | wxFLAGS_MEMBER(wxBORDER_SUNKEN) | |
142 | wxFLAGS_MEMBER(wxBORDER_DOUBLE) | |
143 | wxFLAGS_MEMBER(wxBORDER_RAISED) | |
144 | wxFLAGS_MEMBER(wxBORDER_STATIC) | |
145 | wxFLAGS_MEMBER(wxBORDER_NONE) | |
078cf5cb | 146 | |
bc9fb572 | 147 | // old style border flags |
3ff066a4 SC |
148 | wxFLAGS_MEMBER(wxSIMPLE_BORDER) |
149 | wxFLAGS_MEMBER(wxSUNKEN_BORDER) | |
150 | wxFLAGS_MEMBER(wxDOUBLE_BORDER) | |
151 | wxFLAGS_MEMBER(wxRAISED_BORDER) | |
152 | wxFLAGS_MEMBER(wxSTATIC_BORDER) | |
cb0afb26 | 153 | wxFLAGS_MEMBER(wxBORDER) |
bc9fb572 JS |
154 | |
155 | // standard window styles | |
3ff066a4 SC |
156 | wxFLAGS_MEMBER(wxTAB_TRAVERSAL) |
157 | wxFLAGS_MEMBER(wxCLIP_CHILDREN) | |
158 | wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) | |
159 | wxFLAGS_MEMBER(wxWANTS_CHARS) | |
cb0afb26 | 160 | wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) |
3ff066a4 SC |
161 | wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) |
162 | wxFLAGS_MEMBER(wxVSCROLL) | |
163 | wxFLAGS_MEMBER(wxHSCROLL) | |
164 | ||
165 | wxFLAGS_MEMBER(wxNB_FIXEDWIDTH) | |
2ddb4d13 WS |
166 | wxFLAGS_MEMBER(wxBK_DEFAULT) |
167 | wxFLAGS_MEMBER(wxBK_TOP) | |
168 | wxFLAGS_MEMBER(wxBK_LEFT) | |
169 | wxFLAGS_MEMBER(wxBK_RIGHT) | |
170 | wxFLAGS_MEMBER(wxBK_BOTTOM) | |
b554cf63 JS |
171 | wxFLAGS_MEMBER(wxNB_NOPAGETHEME) |
172 | wxFLAGS_MEMBER(wxNB_FLAT) | |
3ff066a4 SC |
173 | |
174 | wxEND_FLAGS( wxNotebookStyle ) | |
51741307 | 175 | |
8dba4c72 | 176 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebook, wxBookCtrlBase,"wx/notebook.h") |
51741307 SC |
177 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebookPageInfo, wxObject , "wx/notebook.h" ) |
178 | ||
3ff066a4 | 179 | wxCOLLECTION_TYPE_INFO( wxNotebookPageInfo * , wxNotebookPageInfoList ) ; |
51596bcb | 180 | |
f0a126fe SC |
181 | template<> void wxCollectionToVariantArray( wxNotebookPageInfoList const &theList, wxxVariantArray &value) |
182 | { | |
0c6b0084 | 183 | wxListCollectionToVariantArray<wxNotebookPageInfoList::compatibility_iterator>( theList , value ) ; |
f0a126fe SC |
184 | } |
185 | ||
3ff066a4 | 186 | wxBEGIN_PROPERTIES_TABLE(wxNotebook) |
3e97a905 VZ |
187 | wxEVENT_PROPERTY( PageChanging , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING , wxBookCtrlEvent ) |
188 | wxEVENT_PROPERTY( PageChanged , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED , wxBookCtrlEvent ) | |
c5ca409b | 189 | |
3ff066a4 | 190 | wxPROPERTY_COLLECTION( PageInfos , wxNotebookPageInfoList , wxNotebookPageInfo* , AddPageInfo , GetPageInfos , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) |
af498247 | 191 | wxPROPERTY_FLAGS( WindowStyle , wxNotebookStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style |
3ff066a4 | 192 | wxEND_PROPERTIES_TABLE() |
51596bcb | 193 | |
3ff066a4 SC |
194 | wxBEGIN_HANDLERS_TABLE(wxNotebook) |
195 | wxEND_HANDLERS_TABLE() | |
51596bcb | 196 | |
078cf5cb | 197 | wxCONSTRUCTOR_5( wxNotebook , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle) |
51596bcb | 198 | |
51741307 | 199 | |
3ff066a4 | 200 | wxBEGIN_PROPERTIES_TABLE(wxNotebookPageInfo) |
af498247 | 201 | wxREADONLY_PROPERTY( Page , wxNotebookPage* , GetPage , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) |
3ff066a4 SC |
202 | wxREADONLY_PROPERTY( Text , wxString , GetText , wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) |
203 | wxREADONLY_PROPERTY( Selected , bool , GetSelected , false, 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) | |
204 | wxREADONLY_PROPERTY( ImageId , int , GetImageId , -1 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
205 | wxEND_PROPERTIES_TABLE() | |
51741307 | 206 | |
3ff066a4 SC |
207 | wxBEGIN_HANDLERS_TABLE(wxNotebookPageInfo) |
208 | wxEND_HANDLERS_TABLE() | |
51741307 | 209 | |
078cf5cb | 210 | wxCONSTRUCTOR_4( wxNotebookPageInfo , wxNotebookPage* , Page , wxString , Text , bool , Selected , int , ImageId ) |
51741307 | 211 | |
51596bcb | 212 | #else |
8dba4c72 | 213 | IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxBookCtrlBase) |
51741307 | 214 | IMPLEMENT_DYNAMIC_CLASS(wxNotebookPageInfo, wxObject ) |
51596bcb | 215 | #endif |
88310e2e VZ |
216 | |
217 | // ============================================================================ | |
218 | // implementation | |
219 | // ============================================================================ | |
220 | ||
221 | // ---------------------------------------------------------------------------- | |
222 | // wxNotebook construction | |
223 | // ---------------------------------------------------------------------------- | |
224 | ||
51741307 SC |
225 | const wxNotebookPageInfoList& wxNotebook::GetPageInfos() const |
226 | { | |
227 | wxNotebookPageInfoList* list = const_cast< wxNotebookPageInfoList* >( &m_pageInfos ) ; | |
228 | WX_CLEAR_LIST( wxNotebookPageInfoList , *list ) ; | |
34a0c9f4 | 229 | for( size_t i = 0 ; i < GetPageCount() ; ++i ) |
51741307 SC |
230 | { |
231 | wxNotebookPageInfo *info = new wxNotebookPageInfo() ; | |
34a0c9f4 | 232 | info->Create( const_cast<wxNotebook*>(this)->GetPage(i) , GetPageText(i) , GetSelection() == int(i) , GetPageImage(i) ) ; |
51741307 SC |
233 | list->Append( info ) ; |
234 | } | |
235 | return m_pageInfos ; | |
236 | } | |
237 | ||
88310e2e VZ |
238 | // common part of all ctors |
239 | void wxNotebook::Init() | |
240 | { | |
7ec69821 | 241 | m_imageList = NULL; |
caf95d2a VZ |
242 | |
243 | #if wxUSE_UXTHEME | |
7ec69821 | 244 | m_hbrBackground = NULL; |
caf95d2a | 245 | #endif // wxUSE_UXTHEME |
dfb47d83 VZ |
246 | |
247 | #if USE_NOTEBOOK_ANTIFLICKER | |
7ec69821 | 248 | m_hasSubclassedUpdown = false; |
dfb47d83 | 249 | #endif // USE_NOTEBOOK_ANTIFLICKER |
88310e2e VZ |
250 | } |
251 | ||
252 | // default for dynamic class | |
253 | wxNotebook::wxNotebook() | |
254 | { | |
255 | Init(); | |
256 | } | |
257 | ||
258 | // the same arguments as for wxControl | |
259 | wxNotebook::wxNotebook(wxWindow *parent, | |
8b9518ee | 260 | wxWindowID id, |
88310e2e VZ |
261 | const wxPoint& pos, |
262 | const wxSize& size, | |
8b9518ee | 263 | long style, |
88310e2e VZ |
264 | const wxString& name) |
265 | { | |
266 | Init(); | |
267 | ||
268 | Create(parent, id, pos, size, style, name); | |
269 | } | |
270 | ||
271 | // Create() function | |
272 | bool wxNotebook::Create(wxWindow *parent, | |
8b9518ee | 273 | wxWindowID id, |
88310e2e VZ |
274 | const wxPoint& pos, |
275 | const wxSize& size, | |
8b9518ee | 276 | long style, |
88310e2e VZ |
277 | const wxString& name) |
278 | { | |
895cc205 WS |
279 | if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT ) |
280 | { | |
281 | #if defined(__POCKETPC__) | |
282 | style |= wxBK_BOTTOM | wxNB_FLAT; | |
283 | #else | |
284 | style |= wxBK_TOP; | |
285 | #endif | |
286 | } | |
287 | ||
45418059 JS |
288 | #ifdef __WXWINCE__ |
289 | // Not sure why, but without this style, there is no border | |
290 | // around the notebook tabs. | |
291 | if (style & wxNB_FLAT) | |
292 | style |= wxBORDER_SUNKEN; | |
293 | #endif | |
c3732409 | 294 | |
e4db172a | 295 | #if !wxUSE_UXTHEME |
b013c971 VZ |
296 | // ComCtl32 notebook tabs simply don't work unless they're on top if we |
297 | // have uxtheme, we can work around it later (after control creation), but | |
298 | // if we have been compiled without uxtheme support, we have to clear those | |
299 | // styles | |
300 | if ( HasTroubleWithNonTopTabs() ) | |
04eb05b0 | 301 | { |
5483756f | 302 | style &= ~(wxBK_BOTTOM | wxBK_LEFT | wxBK_RIGHT); |
04eb05b0 | 303 | } |
7cc1ad29 | 304 | #endif //wxUSE_UXTHEME |
078cf5cb | 305 | |
82c51a8e JS |
306 | #if defined(__WINE__) && wxUSE_UNICODE |
307 | LPCTSTR className = L"SysTabControl32"; | |
308 | #else | |
c1637c89 | 309 | LPCTSTR className = WC_TABCONTROL; |
82c51a8e | 310 | #endif |
c1637c89 | 311 | |
6143d3b6 | 312 | #if USE_NOTEBOOK_ANTIFLICKER |
c1637c89 VZ |
313 | // SysTabCtl32 class has natively CS_HREDRAW and CS_VREDRAW enabled and it |
314 | // causes horrible flicker when resizing notebook, so get rid of it by | |
315 | // using a class without these styles (but otherwise identical to it) | |
316 | if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) ) | |
317 | { | |
318 | static ClassRegistrar s_clsNotebook; | |
319 | if ( !s_clsNotebook.IsInitialized() ) | |
320 | { | |
321 | // get a copy of standard class and modify it | |
322 | WNDCLASS wc; | |
323 | ||
6143d3b6 | 324 | if ( ::GetClassInfo(NULL, WC_TABCONTROL, &wc) ) |
c1637c89 | 325 | { |
6143d3b6 | 326 | gs_wndprocNotebook = |
5c33522f | 327 | reinterpret_cast<WXFARPROC>(wc.lpfnWndProc); |
c1637c89 VZ |
328 | wc.lpszClassName = wxT("_wx_SysTabCtl32"); |
329 | wc.style &= ~(CS_HREDRAW | CS_VREDRAW); | |
6143d3b6 VZ |
330 | wc.hInstance = wxGetInstance(); |
331 | wc.lpfnWndProc = wxNotebookWndProc; | |
c1637c89 VZ |
332 | s_clsNotebook.Register(wc); |
333 | } | |
334 | else | |
335 | { | |
9a83f860 | 336 | wxLogLastError(wxT("GetClassInfoEx(SysTabCtl32)")); |
c1637c89 VZ |
337 | } |
338 | } | |
339 | ||
340 | // use our custom class if available but fall back to the standard | |
341 | // notebook if we failed to register it | |
342 | if ( s_clsNotebook.IsRegistered() ) | |
343 | { | |
344 | // it's ok to use c_str() here as the static s_clsNotebook object | |
345 | // has sufficiently long lifetime | |
346 | className = s_clsNotebook.GetName().c_str(); | |
347 | } | |
348 | } | |
6143d3b6 | 349 | #endif // USE_NOTEBOOK_ANTIFLICKER |
c1637c89 | 350 | |
6dd16e4f VZ |
351 | if ( !CreateControl(parent, id, pos, size, style | wxTAB_TRAVERSAL, |
352 | wxDefaultValidator, name) ) | |
b8bdaa7c | 353 | return false; |
88310e2e | 354 | |
c1637c89 | 355 | if ( !MSWCreateControl(className, wxEmptyString, pos, size) ) |
b8bdaa7c | 356 | return false; |
907f37b3 | 357 | |
7dccdf81 VZ |
358 | #if wxUSE_UXTHEME |
359 | if ( HasFlag(wxNB_NOPAGETHEME) || | |
360 | wxSystemOptions::IsFalse(wxT("msw.notebook.themed-background")) ) | |
f2b7be7a | 361 | { |
7dccdf81 | 362 | SetBackgroundColour(GetThemeBackgroundColour()); |
f2b7be7a | 363 | } |
30556182 VZ |
364 | else // use themed background by default |
365 | { | |
366 | // create backing store | |
367 | UpdateBgBrush(); | |
368 | } | |
e4db172a | 369 | |
7cc1ad29 JS |
370 | // comctl32.dll 6.0 doesn't support non-top tabs with visual styles (the |
371 | // control is simply not rendered correctly), so we disable themes | |
372 | // if possible, otherwise we simply clear the styles. | |
b013c971 VZ |
373 | if ( HasTroubleWithNonTopTabs() && |
374 | (style & (wxBK_BOTTOM | wxBK_LEFT | wxBK_RIGHT)) ) | |
7cc1ad29 JS |
375 | { |
376 | // check if we use themes at all -- if we don't, we're still okay | |
b013c971 | 377 | if ( wxUxThemeEngine::GetIfActive() ) |
7cc1ad29 | 378 | { |
b013c971 VZ |
379 | wxUxThemeEngine::GetIfActive()->SetWindowTheme(GetHwnd(), L"", L""); |
380 | ||
381 | // correct the background color for the new non-themed control | |
8dba4c72 | 382 | SetBackgroundColour(GetThemeBackgroundColour()); |
7cc1ad29 JS |
383 | } |
384 | } | |
7dccdf81 | 385 | #endif // wxUSE_UXTHEME |
b554cf63 JS |
386 | |
387 | // Undocumented hack to get flat notebook style | |
388 | // In fact, we should probably only do this in some | |
389 | // curcumstances, i.e. if we know we will have a border | |
390 | // at the bottom (the tab control doesn't draw it itself) | |
391 | #if defined(__POCKETPC__) || defined(__SMARTPHONE__) | |
392 | if (HasFlag(wxNB_FLAT)) | |
393 | { | |
01c8cbf5 | 394 | SendMessage(GetHwnd(), CCM_SETVERSION, COMCTL32_VERSION, 0); |
b554cf63 JS |
395 | if (!m_hasBgCol) |
396 | SetBackgroundColour(*wxWHITE); | |
397 | } | |
398 | #endif | |
b8bdaa7c | 399 | return true; |
0df3fbd7 VZ |
400 | } |
401 | ||
402 | WXDWORD wxNotebook::MSWGetStyle(long style, WXDWORD *exstyle) const | |
403 | { | |
404 | WXDWORD tabStyle = wxControl::MSWGetStyle(style, exstyle); | |
405 | ||
406 | tabStyle |= WS_TABSTOP | TCS_TABS; | |
407 | ||
2b5f62a0 | 408 | if ( style & wxNB_MULTILINE ) |
0df3fbd7 VZ |
409 | tabStyle |= TCS_MULTILINE; |
410 | if ( style & wxNB_FIXEDWIDTH ) | |
411 | tabStyle |= TCS_FIXEDWIDTH; | |
412 | ||
2ddb4d13 | 413 | if ( style & wxBK_BOTTOM ) |
0df3fbd7 | 414 | tabStyle |= TCS_RIGHT; |
2ddb4d13 | 415 | else if ( style & wxBK_LEFT ) |
0df3fbd7 | 416 | tabStyle |= TCS_VERTICAL; |
2ddb4d13 | 417 | else if ( style & wxBK_RIGHT ) |
c3732409 | 418 | tabStyle |= TCS_VERTICAL | TCS_RIGHT; |
0df3fbd7 | 419 | |
0df3fbd7 | 420 | return tabStyle; |
88310e2e VZ |
421 | } |
422 | ||
caf95d2a VZ |
423 | wxNotebook::~wxNotebook() |
424 | { | |
425 | #if wxUSE_UXTHEME | |
426 | if ( m_hbrBackground ) | |
427 | ::DeleteObject((HBRUSH)m_hbrBackground); | |
428 | #endif // wxUSE_UXTHEME | |
429 | } | |
430 | ||
88310e2e VZ |
431 | // ---------------------------------------------------------------------------- |
432 | // wxNotebook accessors | |
433 | // ---------------------------------------------------------------------------- | |
07b8d7ec | 434 | |
8d34bf5c | 435 | size_t wxNotebook::GetPageCount() const |
88310e2e | 436 | { |
8ecd5de2 WS |
437 | // consistency check |
438 | wxASSERT( (int)m_pages.Count() == TabCtrl_GetItemCount(GetHwnd()) ); | |
88310e2e | 439 | |
8ecd5de2 | 440 | return m_pages.Count(); |
88310e2e VZ |
441 | } |
442 | ||
443 | int wxNotebook::GetRowCount() const | |
444 | { | |
8ecd5de2 | 445 | return TabCtrl_GetRowCount(GetHwnd()); |
88310e2e VZ |
446 | } |
447 | ||
8d34bf5c | 448 | int wxNotebook::SetSelection(size_t nPage) |
88310e2e | 449 | { |
8ecd5de2 WS |
450 | wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") ); |
451 | ||
681be2ef | 452 | if ( m_selection == wxNOT_FOUND || nPage != (size_t)m_selection ) |
2b5f62a0 | 453 | { |
a570e8f8 | 454 | if ( SendPageChangingEvent(nPage) ) |
8ecd5de2 WS |
455 | { |
456 | // program allows the page change | |
426ebc99 | 457 | const int selectionOld = m_selection; |
2b5f62a0 | 458 | |
409f747e VZ |
459 | UpdateSelection(nPage); |
460 | ||
a570e8f8 | 461 | TabCtrl_SetCurSel(GetHwnd(), nPage); |
426ebc99 VZ |
462 | |
463 | SendPageChangedEvent(selectionOld, nPage); | |
8ecd5de2 | 464 | } |
2b5f62a0 | 465 | } |
88310e2e | 466 | |
681be2ef | 467 | return m_selection; |
88310e2e VZ |
468 | } |
469 | ||
5482ee07 | 470 | void wxNotebook::UpdateSelection(int selNew) |
1d6fcbcc | 471 | { |
681be2ef VZ |
472 | if ( m_selection != wxNOT_FOUND ) |
473 | m_pages[m_selection]->Show(false); | |
1d6fcbcc | 474 | |
5482ee07 | 475 | if ( selNew != wxNOT_FOUND ) |
1d6fcbcc | 476 | { |
5482ee07 | 477 | wxNotebookPage *pPage = m_pages[selNew]; |
1d6fcbcc VZ |
478 | pPage->Show(true); |
479 | } | |
480 | ||
481 | // Changing the page should give the focus to it but, as per bug report | |
482 | // http://sf.net/tracker/index.php?func=detail&aid=1150659&group_id=9863&atid=109863, | |
483 | // we should not set the focus to it directly since it erroneously | |
484 | // selects radio buttons and breaks keyboard handling for a notebook's | |
485 | // scroll buttons. So give focus to the notebook and not the page. | |
486 | ||
487 | // but don't do this is the notebook is hidden | |
488 | if ( ::IsWindowVisible(GetHwnd()) ) | |
489 | SetFocus(); | |
490 | ||
681be2ef | 491 | m_selection = selNew; |
1d6fcbcc VZ |
492 | } |
493 | ||
494 | int wxNotebook::ChangeSelection(size_t nPage) | |
495 | { | |
496 | wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") ); | |
497 | ||
681be2ef | 498 | const int selOld = m_selection; |
937d5b60 | 499 | |
681be2ef | 500 | if ( m_selection == wxNOT_FOUND || nPage != (size_t)m_selection ) |
1d6fcbcc VZ |
501 | { |
502 | TabCtrl_SetCurSel(GetHwnd(), nPage); | |
503 | ||
504 | UpdateSelection(nPage); | |
505 | } | |
506 | ||
937d5b60 | 507 | return selOld; |
1d6fcbcc VZ |
508 | } |
509 | ||
8d34bf5c | 510 | bool wxNotebook::SetPageText(size_t nPage, const wxString& strText) |
88310e2e | 511 | { |
8ecd5de2 | 512 | wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("notebook page out of range") ); |
88310e2e | 513 | |
8ecd5de2 WS |
514 | TC_ITEM tcItem; |
515 | tcItem.mask = TCIF_TEXT; | |
c9f78968 | 516 | tcItem.pszText = (wxChar *)strText.wx_str(); |
88310e2e | 517 | |
88a01064 JS |
518 | if ( !HasFlag(wxNB_MULTILINE) ) |
519 | return TabCtrl_SetItem(GetHwnd(), nPage, &tcItem) != 0; | |
520 | ||
521 | // multiline - we need to set new page size if a line is added or removed | |
522 | int rows = GetRowCount(); | |
523 | bool ret = TabCtrl_SetItem(GetHwnd(), nPage, &tcItem) != 0; | |
524 | ||
525 | if ( ret && rows != GetRowCount() ) | |
526 | { | |
527 | const wxRect r = GetPageSize(); | |
528 | const size_t count = m_pages.Count(); | |
529 | for ( size_t page = 0; page < count; page++ ) | |
530 | m_pages[page]->SetSize(r); | |
531 | } | |
532 | ||
533 | return ret; | |
88310e2e VZ |
534 | } |
535 | ||
8d34bf5c | 536 | wxString wxNotebook::GetPageText(size_t nPage) const |
88310e2e | 537 | { |
8ecd5de2 | 538 | wxCHECK_MSG( IS_VALID_PAGE(nPage), wxEmptyString, wxT("notebook page out of range") ); |
88310e2e | 539 | |
8ecd5de2 WS |
540 | wxChar buf[256]; |
541 | TC_ITEM tcItem; | |
542 | tcItem.mask = TCIF_TEXT; | |
543 | tcItem.pszText = buf; | |
544 | tcItem.cchTextMax = WXSIZEOF(buf); | |
88310e2e | 545 | |
8ecd5de2 WS |
546 | wxString str; |
547 | if ( TabCtrl_GetItem(GetHwnd(), nPage, &tcItem) ) | |
548 | str = tcItem.pszText; | |
88310e2e | 549 | |
8ecd5de2 | 550 | return str; |
88310e2e VZ |
551 | } |
552 | ||
8d34bf5c | 553 | int wxNotebook::GetPageImage(size_t nPage) const |
88310e2e | 554 | { |
8ecd5de2 | 555 | wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") ); |
88310e2e | 556 | |
8ecd5de2 WS |
557 | TC_ITEM tcItem; |
558 | tcItem.mask = TCIF_IMAGE; | |
88310e2e | 559 | |
5482ee07 VZ |
560 | return TabCtrl_GetItem(GetHwnd(), nPage, &tcItem) ? tcItem.iImage |
561 | : wxNOT_FOUND; | |
88310e2e VZ |
562 | } |
563 | ||
8d34bf5c | 564 | bool wxNotebook::SetPageImage(size_t nPage, int nImage) |
88310e2e | 565 | { |
8ecd5de2 | 566 | wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("notebook page out of range") ); |
88310e2e | 567 | |
8ecd5de2 WS |
568 | TC_ITEM tcItem; |
569 | tcItem.mask = TCIF_IMAGE; | |
570 | tcItem.iImage = nImage; | |
88310e2e | 571 | |
8ecd5de2 | 572 | return TabCtrl_SetItem(GetHwnd(), nPage, &tcItem) != 0; |
88310e2e VZ |
573 | } |
574 | ||
575 | void wxNotebook::SetImageList(wxImageList* imageList) | |
907f37b3 | 576 | { |
8ecd5de2 | 577 | wxNotebookBase::SetImageList(imageList); |
07b8d7ec | 578 | |
8ecd5de2 WS |
579 | if ( imageList ) |
580 | { | |
5482ee07 | 581 | (void) TabCtrl_SetImageList(GetHwnd(), GetHimagelistOf(imageList)); |
8ecd5de2 | 582 | } |
b656febd VS |
583 | } |
584 | ||
d9506e77 VZ |
585 | // ---------------------------------------------------------------------------- |
586 | // wxNotebook size settings | |
587 | // ---------------------------------------------------------------------------- | |
588 | ||
c3732409 VZ |
589 | wxRect wxNotebook::GetPageSize() const |
590 | { | |
591 | wxRect r; | |
592 | ||
593 | RECT rc; | |
594 | ::GetClientRect(GetHwnd(), &rc); | |
595 | ||
596 | // This check is to work around a bug in TabCtrl_AdjustRect which will | |
628eae0b VZ |
597 | // cause a crash on win2k or on XP with themes disabled if either |
598 | // wxNB_MULTILINE is used or tabs are placed on a side, if the rectangle | |
599 | // is too small. | |
600 | // | |
601 | // The value of 20 is chosen arbitrarily but seems to work | |
602 | if ( rc.right > 20 && rc.bottom > 20 ) | |
c3732409 | 603 | { |
01c8cbf5 | 604 | TabCtrl_AdjustRect(GetHwnd(), false, &rc); |
c3732409 VZ |
605 | |
606 | wxCopyRECTToRect(rc, r); | |
607 | } | |
608 | ||
609 | return r; | |
610 | } | |
611 | ||
d9506e77 VZ |
612 | void wxNotebook::SetPageSize(const wxSize& size) |
613 | { | |
614 | // transform the page size into the notebook size | |
615 | RECT rc; | |
616 | rc.left = | |
617 | rc.top = 0; | |
618 | rc.right = size.x; | |
619 | rc.bottom = size.y; | |
620 | ||
b8bdaa7c | 621 | TabCtrl_AdjustRect(GetHwnd(), true, &rc); |
d9506e77 VZ |
622 | |
623 | // and now set it | |
624 | SetSize(rc.right - rc.left, rc.bottom - rc.top); | |
625 | } | |
626 | ||
627 | void wxNotebook::SetPadding(const wxSize& padding) | |
628 | { | |
629 | TabCtrl_SetPadding(GetHwnd(), padding.x, padding.y); | |
630 | } | |
42e69d6b VZ |
631 | |
632 | // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH | |
633 | // style. | |
634 | void wxNotebook::SetTabSize(const wxSize& sz) | |
635 | { | |
636 | ::SendMessage(GetHwnd(), TCM_SETITEMSIZE, 0, MAKELPARAM(sz.x, sz.y)); | |
637 | } | |
638 | ||
2ce7af35 JS |
639 | wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const |
640 | { | |
669c595d | 641 | // we can't use TabCtrl_AdjustRect here because it only works for wxNB_TOP |
2ce7af35 | 642 | wxSize sizeTotal = sizePage; |
078cf5cb | 643 | |
8b5d5223 | 644 | wxSize tabSize; |
669c595d | 645 | if ( GetPageCount() > 0 ) |
2ce7af35 JS |
646 | { |
647 | RECT rect; | |
669c595d | 648 | TabCtrl_GetItemRect(GetHwnd(), 0, &rect); |
2ce7af35 JS |
649 | tabSize.x = rect.right - rect.left; |
650 | tabSize.y = rect.bottom - rect.top; | |
651 | } | |
669c595d | 652 | |
49ac39e3 VZ |
653 | const int rows = GetRowCount(); |
654 | ||
669c595d VZ |
655 | // add an extra margin in both directions |
656 | const int MARGIN = 8; | |
657 | if ( IsVertical() ) | |
2ce7af35 | 658 | { |
669c595d | 659 | sizeTotal.x += MARGIN; |
49ac39e3 | 660 | sizeTotal.y += tabSize.y * rows + MARGIN; |
2ce7af35 | 661 | } |
669c595d | 662 | else // horizontal layout |
2ce7af35 | 663 | { |
49ac39e3 | 664 | sizeTotal.x += tabSize.x * rows + MARGIN; |
669c595d | 665 | sizeTotal.y += MARGIN; |
2ce7af35 JS |
666 | } |
667 | ||
668 | return sizeTotal; | |
669 | } | |
670 | ||
2015f2b3 VZ |
671 | void wxNotebook::AdjustPageSize(wxNotebookPage *page) |
672 | { | |
9a83f860 | 673 | wxCHECK_RET( page, wxT("NULL page in wxNotebook::AdjustPageSize") ); |
2015f2b3 | 674 | |
c3732409 VZ |
675 | const wxRect r = GetPageSize(); |
676 | if ( !r.IsEmpty() ) | |
14a6b6e5 | 677 | { |
c3732409 | 678 | page->SetSize(r); |
14a6b6e5 | 679 | } |
2015f2b3 VZ |
680 | } |
681 | ||
88310e2e VZ |
682 | // ---------------------------------------------------------------------------- |
683 | // wxNotebook operations | |
684 | // ---------------------------------------------------------------------------- | |
685 | ||
621793f4 | 686 | // remove one page from the notebook, without deleting |
8d34bf5c | 687 | wxNotebookPage *wxNotebook::DoRemovePage(size_t nPage) |
621793f4 | 688 | { |
df7145da VZ |
689 | wxNotebookPage *pageRemoved = wxNotebookBase::DoRemovePage(nPage); |
690 | if ( !pageRemoved ) | |
691 | return NULL; | |
621793f4 | 692 | |
8138f406 VS |
693 | // hide the removed page to maintain the invariant that only the |
694 | // selected page is visible and others are hidden: | |
695 | pageRemoved->Show(false); | |
696 | ||
01c8cbf5 | 697 | TabCtrl_DeleteItem(GetHwnd(), nPage); |
621793f4 | 698 | |
df7145da VZ |
699 | if ( m_pages.IsEmpty() ) |
700 | { | |
701 | // no selection any more, the notebook becamse empty | |
681be2ef | 702 | m_selection = wxNOT_FOUND; |
df7145da VZ |
703 | } |
704 | else // notebook still not empty | |
705 | { | |
01c8cbf5 | 706 | int selNew = TabCtrl_GetCurSel(GetHwnd()); |
5482ee07 | 707 | if ( selNew != wxNOT_FOUND ) |
df7145da | 708 | { |
623f5f70 | 709 | // No selection change, just refresh the current selection. |
078cf5cb WS |
710 | // Because it could be that the slection index changed |
711 | // we need to update it. | |
623f5f70 | 712 | // Note: this does not mean the selection it self changed. |
681be2ef VZ |
713 | m_selection = selNew; |
714 | m_pages[m_selection]->Refresh(); | |
df7145da | 715 | } |
681be2ef | 716 | else if (int(nPage) == m_selection) |
43a997b6 | 717 | { |
623f5f70 | 718 | // The selection was deleted. |
078cf5cb | 719 | |
623f5f70 | 720 | // Determine new selection. |
681be2ef VZ |
721 | if (m_selection == int(GetPageCount())) |
722 | selNew = m_selection - 1; | |
623f5f70 | 723 | else |
681be2ef | 724 | selNew = m_selection; |
078cf5cb | 725 | |
681be2ef | 726 | // m_selection must be always valid so reset it before calling |
43a997b6 | 727 | // SetSelection() |
681be2ef | 728 | m_selection = wxNOT_FOUND; |
43a997b6 VZ |
729 | SetSelection(selNew); |
730 | } | |
623f5f70 JS |
731 | else |
732 | { | |
733 | wxFAIL; // Windows did not behave ok. | |
734 | } | |
df7145da | 735 | } |
47f12f58 | 736 | |
df7145da | 737 | return pageRemoved; |
621793f4 JS |
738 | } |
739 | ||
88310e2e VZ |
740 | // remove all pages |
741 | bool wxNotebook::DeleteAllPages() | |
742 | { | |
7ec69821 WS |
743 | size_t nPageCount = GetPageCount(); |
744 | size_t nPage; | |
745 | for ( nPage = 0; nPage < nPageCount; nPage++ ) | |
746 | delete m_pages[nPage]; | |
88310e2e | 747 | |
7ec69821 | 748 | m_pages.Clear(); |
88310e2e | 749 | |
7ec69821 | 750 | TabCtrl_DeleteAllItems(GetHwnd()); |
907f37b3 | 751 | |
681be2ef | 752 | m_selection = wxNOT_FOUND; |
47f12f58 | 753 | |
7ec69821 WS |
754 | InvalidateBestSize(); |
755 | return true; | |
88310e2e VZ |
756 | } |
757 | ||
88310e2e | 758 | // same as AddPage() but does it at given position |
8d34bf5c | 759 | bool wxNotebook::InsertPage(size_t nPage, |
88310e2e VZ |
760 | wxNotebookPage *pPage, |
761 | const wxString& strText, | |
762 | bool bSelect, | |
763 | int imageId) | |
764 | { | |
9a83f860 | 765 | wxCHECK_MSG( pPage != NULL, false, wxT("NULL page in wxNotebook::InsertPage") ); |
b8bdaa7c | 766 | wxCHECK_MSG( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), false, |
9a83f860 | 767 | wxT("invalid index in wxNotebook::InsertPage") ); |
88310e2e | 768 | |
efa14cf2 | 769 | wxASSERT_MSG( pPage->GetParent() == this, |
9a83f860 | 770 | wxT("notebook pages must have notebook as parent") ); |
43427087 | 771 | |
22f3361e VZ |
772 | // add a new tab to the control |
773 | // ---------------------------- | |
58a8ab88 | 774 | |
22f3361e VZ |
775 | // init all fields to 0 |
776 | TC_ITEM tcItem; | |
777 | wxZeroMemory(tcItem); | |
58a8ab88 | 778 | |
22f3361e VZ |
779 | // set the image, if any |
780 | if ( imageId != -1 ) | |
781 | { | |
782 | tcItem.mask |= TCIF_IMAGE; | |
783 | tcItem.iImage = imageId; | |
784 | } | |
88310e2e | 785 | |
22f3361e | 786 | // and the text |
8b5d5223 | 787 | if ( !strText.empty() ) |
22f3361e VZ |
788 | { |
789 | tcItem.mask |= TCIF_TEXT; | |
f48a1159 | 790 | tcItem.pszText = const_cast<wxChar *>(strText.wx_str()); |
22f3361e | 791 | } |
43427087 | 792 | |
e830a6a6 RD |
793 | // hide the page: unless it is selected, it shouldn't be shown (and if it |
794 | // is selected it will be shown later) | |
795 | HWND hwnd = GetWinHwnd(pPage); | |
796 | SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_VISIBLE); | |
797 | ||
798 | // this updates internal flag too -- otherwise it would get out of sync | |
799 | // with the real state | |
800 | pPage->Show(false); | |
801 | ||
802 | ||
22f3361e VZ |
803 | // fit the notebook page to the tab control's display area: this should be |
804 | // done before adding it to the notebook or TabCtrl_InsertItem() will | |
805 | // change the notebooks size itself! | |
2015f2b3 | 806 | AdjustPageSize(pPage); |
43427087 | 807 | |
22f3361e | 808 | // finally do insert it |
01c8cbf5 | 809 | if ( TabCtrl_InsertItem(GetHwnd(), nPage, &tcItem) == -1 ) |
2015f2b3 | 810 | { |
22f3361e | 811 | wxLogError(wxT("Can't create the notebook page '%s'."), strText.c_str()); |
88310e2e | 812 | |
b8bdaa7c | 813 | return false; |
22f3361e | 814 | } |
88310e2e | 815 | |
ebd9ec29 JG |
816 | // need to update the bg brush when the first page is added |
817 | // so the first panel gets the correct themed background | |
818 | if ( m_pages.empty() ) | |
819 | { | |
11e70ae6 | 820 | #if wxUSE_UXTHEME |
ebd9ec29 | 821 | UpdateBgBrush(); |
11e70ae6 | 822 | #endif // wxUSE_UXTHEME |
ebd9ec29 JG |
823 | } |
824 | ||
22f3361e VZ |
825 | // succeeded: save the pointer to the page |
826 | m_pages.Insert(pPage, nPage); | |
42e69d6b | 827 | |
56b9925b VZ |
828 | // we may need to adjust the size again if the notebook size changed: |
829 | // normally this only happens for the first page we add (the tabs which | |
830 | // hadn't been there before are now shown) but for a multiline notebook it | |
831 | // can happen for any page at all as a new row could have been started | |
832 | if ( m_pages.GetCount() == 1 || HasFlag(wxNB_MULTILINE) ) | |
2015f2b3 VZ |
833 | { |
834 | AdjustPageSize(pPage); | |
835 | } | |
836 | ||
22f3361e VZ |
837 | // now deal with the selection |
838 | // --------------------------- | |
839 | ||
840 | // if the inserted page is before the selected one, we must update the | |
841 | // index of the selected page | |
681be2ef | 842 | if ( int(nPage) <= m_selection ) |
22f3361e VZ |
843 | { |
844 | // one extra page added | |
681be2ef | 845 | m_selection++; |
22f3361e VZ |
846 | } |
847 | ||
60d5c563 | 848 | DoSetSelectionAfterInsertion(nPage, bSelect); |
22f3361e | 849 | |
37144cf0 | 850 | InvalidateBestSize(); |
25057aba | 851 | |
b8bdaa7c | 852 | return true; |
88310e2e VZ |
853 | } |
854 | ||
e450aa69 | 855 | int wxNotebook::HitTest(const wxPoint& pt, long *flags) const |
ef094fa0 JS |
856 | { |
857 | TC_HITTESTINFO hitTestInfo; | |
858 | hitTestInfo.pt.x = pt.x; | |
859 | hitTestInfo.pt.y = pt.y; | |
e450aa69 | 860 | int item = TabCtrl_HitTest(GetHwnd(), &hitTestInfo); |
ef094fa0 | 861 | |
e450aa69 VZ |
862 | if ( flags ) |
863 | { | |
864 | *flags = 0; | |
865 | ||
866 | if ((hitTestInfo.flags & TCHT_NOWHERE) == TCHT_NOWHERE) | |
9804d540 | 867 | *flags |= wxBK_HITTEST_NOWHERE; |
e450aa69 | 868 | if ((hitTestInfo.flags & TCHT_ONITEM) == TCHT_ONITEM) |
9804d540 | 869 | *flags |= wxBK_HITTEST_ONITEM; |
e450aa69 | 870 | if ((hitTestInfo.flags & TCHT_ONITEMICON) == TCHT_ONITEMICON) |
9804d540 | 871 | *flags |= wxBK_HITTEST_ONICON; |
e450aa69 | 872 | if ((hitTestInfo.flags & TCHT_ONITEMLABEL) == TCHT_ONITEMLABEL) |
9804d540 | 873 | *flags |= wxBK_HITTEST_ONLABEL; |
22a35096 | 874 | if ( item == wxNOT_FOUND && GetPageSize().Contains(pt) ) |
9804d540 | 875 | *flags |= wxBK_HITTEST_ONPAGE; |
e450aa69 | 876 | } |
ef094fa0 JS |
877 | |
878 | return item; | |
879 | } | |
880 | ||
014ee083 VZ |
881 | // ---------------------------------------------------------------------------- |
882 | // flicker-less notebook redraw | |
883 | // ---------------------------------------------------------------------------- | |
884 | ||
885 | #if USE_NOTEBOOK_ANTIFLICKER | |
886 | ||
887 | // wnd proc for the spin button | |
888 | LRESULT APIENTRY _EXPORT wxNotebookSpinBtnWndProc(HWND hwnd, | |
889 | UINT message, | |
890 | WPARAM wParam, | |
891 | LPARAM lParam) | |
892 | { | |
893 | if ( message == WM_ERASEBKGND ) | |
894 | return 0; | |
895 | ||
896 | return ::CallWindowProc(CASTWNDPROC gs_wndprocNotebookSpinBtn, | |
897 | hwnd, message, wParam, lParam); | |
898 | } | |
899 | ||
6143d3b6 VZ |
900 | LRESULT APIENTRY _EXPORT wxNotebookWndProc(HWND hwnd, |
901 | UINT message, | |
902 | WPARAM wParam, | |
903 | LPARAM lParam) | |
904 | { | |
905 | return ::CallWindowProc(CASTWNDPROC gs_wndprocNotebook, | |
906 | hwnd, message, wParam, lParam); | |
907 | } | |
908 | ||
014ee083 VZ |
909 | void wxNotebook::OnEraseBackground(wxEraseEvent& WXUNUSED(event)) |
910 | { | |
911 | // do nothing here | |
912 | } | |
913 | ||
914 | void wxNotebook::OnPaint(wxPaintEvent& WXUNUSED(event)) | |
915 | { | |
916 | wxPaintDC dc(this); | |
917 | wxMemoryDC memdc; | |
918 | RECT rc; | |
919 | ::GetClientRect(GetHwnd(), &rc); | |
920 | wxBitmap bmp(rc.right, rc.bottom); | |
921 | memdc.SelectObject(bmp); | |
922 | ||
6614aa49 VZ |
923 | const wxLayoutDirection dir = dc.GetLayoutDirection(); |
924 | memdc.SetLayoutDirection(dir); | |
925 | ||
014ee083 | 926 | // if there is no special brush just use the solid background colour |
64c288fa | 927 | #if wxUSE_UXTHEME |
014ee083 | 928 | HBRUSH hbr = (HBRUSH)m_hbrBackground; |
64c288fa JS |
929 | #else |
930 | HBRUSH hbr = 0; | |
e4db172a | 931 | #endif |
e32703a9 | 932 | wxBrush brush; |
014ee083 | 933 | if ( !hbr ) |
e32703a9 VZ |
934 | { |
935 | brush = wxBrush(GetBackgroundColour()); | |
936 | hbr = GetHbrushOf(brush); | |
937 | } | |
014ee083 | 938 | |
888dde65 | 939 | wxMSWDCImpl *impl = (wxMSWDCImpl*) memdc.GetImpl(); |
014ee083 | 940 | |
888dde65 RR |
941 | ::FillRect(GetHdcOf(*impl), &rc, hbr); |
942 | ||
943 | MSWDefWindowProc(WM_PAINT, (WPARAM)(impl->GetHDC()), 0); | |
014ee083 | 944 | |
f4322df6 | 945 | // For some reason in RTL mode, source offset has to be -1, otherwise the |
6614aa49 VZ |
946 | // right border (physical) remains unpainted. |
947 | const wxCoord ofs = dir == wxLayout_RightToLeft ? -1 : 0; | |
948 | dc.Blit(ofs, 0, rc.right, rc.bottom, &memdc, ofs, 0); | |
014ee083 VZ |
949 | } |
950 | ||
951 | #endif // USE_NOTEBOOK_ANTIFLICKER | |
e450aa69 | 952 | |
88310e2e VZ |
953 | // ---------------------------------------------------------------------------- |
954 | // wxNotebook callbacks | |
955 | // ---------------------------------------------------------------------------- | |
956 | ||
9026ad85 | 957 | void wxNotebook::OnSize(wxSizeEvent& event) |
88310e2e | 958 | { |
7dccdf81 | 959 | if ( GetPageCount() == 0 ) |
f7eaa62f JS |
960 | { |
961 | // Prevents droppings on resize, but does cause some flicker | |
962 | // when there are no pages. | |
2aa24b60 | 963 | Refresh(); |
f7eaa62f JS |
964 | event.Skip(); |
965 | return; | |
966 | } | |
254fbd14 JS |
967 | #ifndef __WXWINCE__ |
968 | else | |
969 | { | |
970 | // Without this, we can sometimes get droppings at the edges | |
971 | // of a notebook, for example a notebook in a splitter window. | |
972 | // This needs to be reconciled with the RefreshRect calls | |
973 | // at the end of this function, which weren't enough to prevent | |
974 | // the droppings. | |
01c8cbf5 | 975 | |
254fbd14 JS |
976 | wxSize sz = GetClientSize(); |
977 | ||
978 | // Refresh right side | |
979 | wxRect rect(sz.x-4, 0, 4, sz.y); | |
980 | RefreshRect(rect); | |
01c8cbf5 | 981 | |
254fbd14 JS |
982 | // Refresh bottom side |
983 | rect = wxRect(0, sz.y-4, sz.x, 4); | |
984 | RefreshRect(rect); | |
01c8cbf5 | 985 | |
254fbd14 JS |
986 | // Refresh left side |
987 | rect = wxRect(0, 0, 4, sz.y); | |
988 | RefreshRect(rect); | |
989 | } | |
014ee083 | 990 | #endif // !__WXWINCE__ |
f7eaa62f | 991 | |
c1637c89 | 992 | // fit all the notebook pages to the tab control's display area |
56b9925b | 993 | |
c1637c89 VZ |
994 | RECT rc; |
995 | rc.left = rc.top = 0; | |
996 | GetSize((int *)&rc.right, (int *)&rc.bottom); | |
56b9925b | 997 | |
c1637c89 VZ |
998 | // save the total size, we'll use it below |
999 | int widthNbook = rc.right - rc.left, | |
1000 | heightNbook = rc.bottom - rc.top; | |
1001 | ||
1002 | // there seems to be a bug in the implementation of TabCtrl_AdjustRect(): it | |
1003 | // returns completely false values for multiline tab controls after the tabs | |
1004 | // are added but before getting the first WM_SIZE (off by ~50 pixels, see | |
1005 | // | |
1006 | // http://sf.net/tracker/index.php?func=detail&aid=645323&group_id=9863&atid=109863 | |
1007 | // | |
1008 | // and the only work around I could find was this ugly hack... without it | |
1009 | // simply toggling the "multiline" checkbox in the notebook sample resulted | |
1010 | // in a noticeable page displacement | |
1011 | if ( HasFlag(wxNB_MULTILINE) ) | |
1012 | { | |
1013 | // avoid an infinite recursion: we get another notification too! | |
1014 | static bool s_isInOnSize = false; | |
4b7f2165 | 1015 | |
c1637c89 VZ |
1016 | if ( !s_isInOnSize ) |
1017 | { | |
1018 | s_isInOnSize = true; | |
1019 | SendMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED, | |
1020 | MAKELPARAM(rc.right, rc.bottom)); | |
1021 | s_isInOnSize = false; | |
1022 | } | |
49ac39e3 VZ |
1023 | |
1024 | // The best size depends on the number of rows of tabs, which can | |
1025 | // change when the notepad is resized. | |
1026 | InvalidateBestSize(); | |
c1637c89 | 1027 | } |
b5c3b538 | 1028 | |
e2f6f8da RD |
1029 | #if wxUSE_UXTHEME |
1030 | // background bitmap size has changed, update the brush using it too | |
1031 | UpdateBgBrush(); | |
1032 | #endif // wxUSE_UXTHEME | |
1033 | ||
01c8cbf5 | 1034 | TabCtrl_AdjustRect(GetHwnd(), false, &rc); |
c1637c89 VZ |
1035 | |
1036 | int width = rc.right - rc.left, | |
1037 | height = rc.bottom - rc.top; | |
1038 | size_t nCount = m_pages.Count(); | |
1039 | for ( size_t nPage = 0; nPage < nCount; nPage++ ) { | |
1040 | wxNotebookPage *pPage = m_pages[nPage]; | |
1041 | pPage->SetSize(rc.left, rc.top, width, height); | |
1042 | } | |
1043 | ||
1044 | ||
1045 | // unless we had already repainted everything, we now need to refresh | |
1046 | if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) ) | |
1047 | { | |
1048 | // invalidate areas not covered by pages | |
1049 | RefreshRect(wxRect(0, 0, widthNbook, rc.top), false); | |
1050 | RefreshRect(wxRect(0, rc.top, rc.left, height), false); | |
1051 | RefreshRect(wxRect(0, rc.bottom, widthNbook, heightNbook - rc.bottom), | |
1052 | false); | |
3550706d | 1053 | RefreshRect(wxRect(rc.right, rc.top, widthNbook - rc.right, height), |
c1637c89 VZ |
1054 | false); |
1055 | } | |
1056 | ||
014ee083 VZ |
1057 | #if USE_NOTEBOOK_ANTIFLICKER |
1058 | // subclass the spin control used by the notebook to scroll pages to | |
1059 | // prevent it from flickering on resize | |
dfb47d83 | 1060 | if ( !m_hasSubclassedUpdown ) |
014ee083 VZ |
1061 | { |
1062 | // iterate over all child windows to find spin button | |
1063 | for ( HWND child = ::GetWindow(GetHwnd(), GW_CHILD); | |
1064 | child; | |
1065 | child = ::GetWindow(child, GW_HWNDNEXT) ) | |
1066 | { | |
1067 | wxWindow *childWindow = wxFindWinFromHandle((WXHWND)child); | |
1068 | ||
1069 | // see if it exists, if no wxWindow found then assume it's the spin | |
1070 | // btn | |
1071 | if ( !childWindow ) | |
1072 | { | |
1073 | // subclass the spin button to override WM_ERASEBKGND | |
dfb47d83 VZ |
1074 | if ( !gs_wndprocNotebookSpinBtn ) |
1075 | gs_wndprocNotebookSpinBtn = (WXFARPROC)wxGetWindowProc(child); | |
014ee083 VZ |
1076 | |
1077 | wxSetWindowProc(child, wxNotebookSpinBtnWndProc); | |
dfb47d83 | 1078 | m_hasSubclassedUpdown = true; |
014ee083 VZ |
1079 | break; |
1080 | } | |
1081 | } | |
1082 | } | |
1083 | #endif // USE_NOTEBOOK_ANTIFLICKER | |
1084 | ||
c1637c89 | 1085 | event.Skip(); |
88310e2e VZ |
1086 | } |
1087 | ||
88310e2e VZ |
1088 | void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event) |
1089 | { | |
d9506e77 VZ |
1090 | if ( event.IsWindowChange() ) { |
1091 | // change pages | |
1092 | AdvanceSelection(event.GetDirection()); | |
1093 | } | |
1094 | else { | |
b8bdaa7c | 1095 | // we get this event in 3 cases |
d9506e77 VZ |
1096 | // |
1097 | // a) one of our pages might have generated it because the user TABbed | |
1098 | // out from it in which case we should propagate the event upwards and | |
1099 | // our parent will take care of setting the focus to prev/next sibling | |
1100 | // | |
1101 | // or | |
1102 | // | |
1103 | // b) the parent panel wants to give the focus to us so that we | |
1104 | // forward it to our selected page. We can't deal with this in | |
1105 | // OnSetFocus() because we don't know which direction the focus came | |
1106 | // from in this case and so can't choose between setting the focus to | |
1107 | // first or last panel child | |
b8bdaa7c VZ |
1108 | // |
1109 | // or | |
1110 | // | |
1111 | // c) we ourselves (see MSWTranslateMessage) generated the event | |
1112 | // | |
1113 | wxWindow * const parent = GetParent(); | |
1114 | ||
3c99602b MB |
1115 | // the wxObject* casts are required to avoid MinGW GCC 2.95.3 ICE |
1116 | const bool isFromParent = event.GetEventObject() == (wxObject*) parent; | |
1117 | const bool isFromSelf = event.GetEventObject() == (wxObject*) this; | |
4a0dcc87 | 1118 | const bool isForward = event.GetDirection(); |
b8bdaa7c | 1119 | |
4a0dcc87 VS |
1120 | if ( isFromSelf && !isForward ) |
1121 | { | |
1122 | // focus is currently on notebook tab and should leave | |
1123 | // it backwards (Shift-TAB) | |
1124 | event.SetCurrentFocus(this); | |
1125 | parent->HandleWindowEvent(event); | |
1126 | } | |
1127 | else if ( isFromParent || isFromSelf ) | |
d9506e77 | 1128 | { |
b8bdaa7c | 1129 | // no, it doesn't come from child, case (b) or (c): forward to a |
4a0dcc87 VS |
1130 | // page but only if entering notebook page (i.e. direction is |
1131 | // backwards (Shift-TAB) comething from out-of-notebook, or | |
1132 | // direction is forward (TAB) from ourselves), | |
681be2ef | 1133 | if ( m_selection != wxNOT_FOUND && |
b8bdaa7c | 1134 | (!event.GetDirection() || isFromSelf) ) |
d9506e77 VZ |
1135 | { |
1136 | // so that the page knows that the event comes from it's parent | |
1137 | // and is being propagated downwards | |
1138 | event.SetEventObject(this); | |
1139 | ||
681be2ef | 1140 | wxWindow *page = m_pages[m_selection]; |
937013e0 | 1141 | if ( !page->HandleWindowEvent(event) ) |
d9506e77 VZ |
1142 | { |
1143 | page->SetFocus(); | |
1144 | } | |
1145 | //else: page manages focus inside it itself | |
1146 | } | |
b8bdaa7c | 1147 | else // otherwise set the focus to the notebook itself |
d9506e77 | 1148 | { |
d9506e77 VZ |
1149 | SetFocus(); |
1150 | } | |
1151 | } | |
1152 | else | |
1153 | { | |
b8bdaa7c VZ |
1154 | // it comes from our child, case (a), pass to the parent, but only |
1155 | // if the direction is forwards. Otherwise set the focus to the | |
1156 | // notebook itself. The notebook is always the 'first' control of a | |
1157 | // page. | |
4a0dcc87 | 1158 | if ( !isForward ) |
b8bdaa7c VZ |
1159 | { |
1160 | SetFocus(); | |
1161 | } | |
1162 | else if ( parent ) | |
1163 | { | |
d9506e77 | 1164 | event.SetCurrentFocus(this); |
937013e0 | 1165 | parent->HandleWindowEvent(event); |
d9506e77 VZ |
1166 | } |
1167 | } | |
88310e2e | 1168 | } |
88310e2e VZ |
1169 | } |
1170 | ||
caf95d2a VZ |
1171 | #if wxUSE_UXTHEME |
1172 | ||
c3732409 | 1173 | bool wxNotebook::DoDrawBackground(WXHDC hDC, wxWindow *child) |
caf95d2a | 1174 | { |
c3732409 VZ |
1175 | wxUxThemeHandle theme(child ? child : this, L"TAB"); |
1176 | if ( !theme ) | |
1177 | return false; | |
1178 | ||
1179 | // get the notebook client rect (we're not interested in drawing tabs | |
1180 | // themselves) | |
1181 | wxRect r = GetPageSize(); | |
1182 | if ( r.IsEmpty() ) | |
1183 | return false; | |
1184 | ||
c4a95f6f | 1185 | RECT rc; |
c3732409 VZ |
1186 | wxCopyRectToRECT(r, rc); |
1187 | ||
1188 | // map rect to the coords of the window we're drawing in | |
1189 | if ( child ) | |
1190 | ::MapWindowPoints(GetHwnd(), GetHwndOf(child), (POINT *)&rc, 2); | |
1191 | ||
2ff53fd3 JS |
1192 | // we have the content area (page size), but we need to draw all of the |
1193 | // background for it to be aligned correctly | |
1194 | wxUxThemeEngine::Get()->GetThemeBackgroundExtent | |
1195 | ( | |
1196 | theme, | |
1197 | (HDC) hDC, | |
1198 | 9 /* TABP_PANE */, | |
1199 | 0, | |
1200 | &rc, | |
1201 | &rc | |
1202 | ); | |
c3732409 VZ |
1203 | wxUxThemeEngine::Get()->DrawThemeBackground |
1204 | ( | |
1205 | theme, | |
92199f4c | 1206 | (HDC) hDC, |
c3732409 VZ |
1207 | 9 /* TABP_PANE */, |
1208 | 0, | |
1209 | &rc, | |
1210 | NULL | |
1211 | ); | |
1212 | ||
1213 | return true; | |
1214 | } | |
de359565 | 1215 | |
c3732409 VZ |
1216 | WXHBRUSH wxNotebook::QueryBgBitmap() |
1217 | { | |
1218 | wxRect r = GetPageSize(); | |
1219 | if ( r.IsEmpty() ) | |
1220 | return 0; | |
c4a95f6f VZ |
1221 | |
1222 | WindowHDC hDC(GetHwnd()); | |
1223 | MemoryHDC hDCMem(hDC); | |
c3732409 | 1224 | CompatibleBitmap hBmp(hDC, r.x + r.width, r.y + r.height); |
c4a95f6f VZ |
1225 | |
1226 | SelectInHDC selectBmp(hDCMem, hBmp); | |
caf95d2a | 1227 | |
c3732409 VZ |
1228 | if ( !DoDrawBackground((WXHDC)(HDC)hDCMem) ) |
1229 | return 0; | |
0f770734 | 1230 | |
de359565 | 1231 | return (WXHBRUSH)::CreatePatternBrush(hBmp); |
c4a95f6f | 1232 | } |
caf95d2a | 1233 | |
c4a95f6f VZ |
1234 | void wxNotebook::UpdateBgBrush() |
1235 | { | |
1236 | if ( m_hbrBackground ) | |
1237 | ::DeleteObject((HBRUSH)m_hbrBackground); | |
caf95d2a | 1238 | |
c4a95f6f VZ |
1239 | if ( !m_hasBgCol && wxUxThemeEngine::GetIfActive() ) |
1240 | { | |
de359565 | 1241 | m_hbrBackground = QueryBgBitmap(); |
caf95d2a | 1242 | } |
c3732409 | 1243 | else // no themes or we've got user-defined solid colour |
caf95d2a VZ |
1244 | { |
1245 | m_hbrBackground = NULL; | |
1246 | } | |
1247 | } | |
1248 | ||
b8797d96 | 1249 | WXHBRUSH wxNotebook::MSWGetBgBrushForChild(WXHDC hDC, wxWindow *child) |
caf95d2a | 1250 | { |
ebfee179 | 1251 | if ( m_hbrBackground ) |
caf95d2a VZ |
1252 | { |
1253 | // before drawing with the background brush, we need to position it | |
1254 | // correctly | |
caf95d2a | 1255 | RECT rc; |
b8797d96 | 1256 | ::GetWindowRect(GetHwndOf(child), &rc); |
caf95d2a VZ |
1257 | |
1258 | ::MapWindowPoints(NULL, GetHwnd(), (POINT *)&rc, 1); | |
1259 | ||
5c836c46 | 1260 | if ( !::SetBrushOrgEx((HDC)hDC, -rc.left, -rc.top, NULL) ) |
caf95d2a | 1261 | { |
9a83f860 | 1262 | wxLogLastError(wxT("SetBrushOrgEx(notebook bg brush)")); |
caf95d2a | 1263 | } |
c4a95f6f VZ |
1264 | |
1265 | return m_hbrBackground; | |
5c836c46 VZ |
1266 | } |
1267 | ||
b8797d96 | 1268 | return wxNotebookBase::MSWGetBgBrushForChild(hDC, child); |
5c836c46 | 1269 | } |
caf95d2a | 1270 | |
c3732409 | 1271 | bool wxNotebook::MSWPrintChild(WXHDC hDC, wxWindow *child) |
07c19327 | 1272 | { |
c3732409 VZ |
1273 | // solid background colour overrides themed background drawing |
1274 | if ( !UseBgCol() && DoDrawBackground(hDC, child) ) | |
1275 | return true; | |
de359565 | 1276 | |
4dab5279 JS |
1277 | // If we're using a solid colour (for example if we've switched off |
1278 | // theming for this notebook), paint it | |
1279 | if (UseBgCol()) | |
1280 | { | |
1281 | wxRect r = GetPageSize(); | |
1282 | if ( r.IsEmpty() ) | |
1283 | return false; | |
1284 | ||
1285 | RECT rc; | |
1286 | wxCopyRectToRECT(r, rc); | |
1287 | ||
1288 | // map rect to the coords of the window we're drawing in | |
1289 | if ( child ) | |
1290 | ::MapWindowPoints(GetHwnd(), GetHwndOf(child), (POINT *)&rc, 2); | |
1291 | ||
1292 | wxBrush brush(GetBackgroundColour()); | |
1293 | HBRUSH hbr = GetHbrushOf(brush); | |
01c8cbf5 | 1294 | |
4dab5279 JS |
1295 | ::FillRect((HDC) hDC, &rc, hbr); |
1296 | ||
1297 | return true; | |
1298 | } | |
1299 | ||
c3732409 | 1300 | return wxNotebookBase::MSWPrintChild(hDC, child); |
07c19327 VZ |
1301 | } |
1302 | ||
caf95d2a VZ |
1303 | #endif // wxUSE_UXTHEME |
1304 | ||
25057aba JS |
1305 | // Windows only: attempts to get colour for UX theme page background |
1306 | wxColour wxNotebook::GetThemeBackgroundColour() const | |
1307 | { | |
1308 | #if wxUSE_UXTHEME | |
1309 | if (wxUxThemeEngine::Get()) | |
1310 | { | |
1311 | wxUxThemeHandle hTheme((wxNotebook*) this, L"TAB"); | |
1312 | if (hTheme) | |
1313 | { | |
1314 | // This is total guesswork. | |
b380533c JS |
1315 | // See PlatformSDK\Include\Tmschema.h for values. |
1316 | // JACS: can also use 9 (TABP_PANE) | |
25057aba | 1317 | COLORREF themeColor; |
b380533c | 1318 | bool success = (S_OK == wxUxThemeEngine::Get()->GetThemeColor( |
25057aba JS |
1319 | hTheme, |
1320 | 10 /* TABP_BODY */, | |
1321 | 1 /* NORMAL */, | |
1322 | 3821 /* FILLCOLORHINT */, | |
b380533c JS |
1323 | &themeColor)); |
1324 | if (!success) | |
1325 | return GetBackgroundColour(); | |
25057aba JS |
1326 | |
1327 | /* | |
1328 | [DS] Workaround for WindowBlinds: | |
1329 | Some themes return a near black theme color using FILLCOLORHINT, | |
1330 | this makes notebook pages have an ugly black background and makes | |
1331 | text (usually black) unreadable. Retry again with FILLCOLOR. | |
1332 | ||
1333 | This workaround potentially breaks appearance of some themes, | |
1334 | but in practice it already fixes some themes. | |
1335 | */ | |
1336 | if (themeColor == 1) | |
1337 | { | |
1338 | wxUxThemeEngine::Get()->GetThemeColor( | |
1339 | hTheme, | |
1340 | 10 /* TABP_BODY */, | |
1341 | 1 /* NORMAL */, | |
1342 | 3802 /* FILLCOLOR */, | |
1343 | &themeColor); | |
1344 | } | |
1345 | ||
b380533c JS |
1346 | wxColour colour = wxRGBToColour(themeColor); |
1347 | ||
1348 | // Under Vista, the tab background colour is reported incorrectly. | |
1349 | // So for the default theme at least, hard-code the colour to something | |
1350 | // that will blend in. | |
1351 | ||
1352 | static int s_AeroStatus = -1; | |
1353 | if (s_AeroStatus == -1) | |
1354 | { | |
1355 | WCHAR szwThemeFile[1024]; | |
1356 | WCHAR szwThemeColor[256]; | |
1357 | if (S_OK == wxUxThemeEngine::Get()->GetCurrentThemeName(szwThemeFile, 1024, szwThemeColor, 256, NULL, 0)) | |
1358 | { | |
1359 | wxString themeFile(szwThemeFile), themeColor(szwThemeColor); | |
1360 | if (themeFile.Find(wxT("Aero")) != -1 && themeColor == wxT("NormalColor")) | |
1361 | s_AeroStatus = 1; | |
1362 | else | |
1363 | s_AeroStatus = 0; | |
1364 | } | |
1365 | else | |
1366 | s_AeroStatus = 0; | |
1367 | } | |
1368 | ||
1369 | if (s_AeroStatus == 1) | |
1370 | colour = wxColour(255, 255, 255); | |
1371 | ||
1372 | return colour; | |
25057aba JS |
1373 | } |
1374 | } | |
1375 | #endif // wxUSE_UXTHEME | |
1376 | ||
1377 | return GetBackgroundColour(); | |
1378 | } | |
1379 | ||
88310e2e VZ |
1380 | // ---------------------------------------------------------------------------- |
1381 | // wxNotebook base class virtuals | |
1382 | // ---------------------------------------------------------------------------- | |
b5c3b538 | 1383 | |
0b481c72 VZ |
1384 | #if wxUSE_CONSTRAINTS |
1385 | ||
b5c3b538 VZ |
1386 | // override these 2 functions to do nothing: everything is done in OnSize |
1387 | ||
4b7f2165 | 1388 | void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse)) |
b5c3b538 VZ |
1389 | { |
1390 | // don't set the sizes of the pages - their correct size is not yet known | |
b8bdaa7c | 1391 | wxControl::SetConstraintSizes(false); |
b5c3b538 VZ |
1392 | } |
1393 | ||
4b7f2165 | 1394 | bool wxNotebook::DoPhase(int WXUNUSED(nPhase)) |
b5c3b538 | 1395 | { |
b8bdaa7c | 1396 | return true; |
b5c3b538 VZ |
1397 | } |
1398 | ||
0b481c72 VZ |
1399 | #endif // wxUSE_CONSTRAINTS |
1400 | ||
0df3fbd7 VZ |
1401 | // ---------------------------------------------------------------------------- |
1402 | // wxNotebook Windows message handlers | |
1403 | // ---------------------------------------------------------------------------- | |
1404 | ||
1405 | bool wxNotebook::MSWOnScroll(int orientation, WXWORD nSBCode, | |
1406 | WXWORD pos, WXHWND control) | |
1407 | { | |
1408 | // don't generate EVT_SCROLLWIN events for the WM_SCROLLs coming from the | |
1409 | // up-down control | |
1410 | if ( control ) | |
b8bdaa7c | 1411 | return false; |
0df3fbd7 VZ |
1412 | |
1413 | return wxNotebookBase::MSWOnScroll(orientation, nSBCode, pos, control); | |
1414 | } | |
1415 | ||
a23fd0e1 | 1416 | bool wxNotebook::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result) |
88310e2e | 1417 | { |
3e97a905 | 1418 | wxBookCtrlEvent event(wxEVT_NULL, m_windowId); |
88310e2e VZ |
1419 | |
1420 | NMHDR* hdr = (NMHDR *)lParam; | |
1421 | switch ( hdr->code ) { | |
1422 | case TCN_SELCHANGE: | |
1423 | event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED); | |
1424 | break; | |
1425 | ||
1426 | case TCN_SELCHANGING: | |
1427 | event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING); | |
1428 | break; | |
1429 | ||
fd3f686c | 1430 | default: |
a23fd0e1 | 1431 | return wxControl::MSWOnNotify(idCtrl, lParam, result); |
88310e2e VZ |
1432 | } |
1433 | ||
01c8cbf5 | 1434 | event.SetSelection(TabCtrl_GetCurSel(GetHwnd())); |
681be2ef | 1435 | event.SetOldSelection(m_selection); |
88310e2e | 1436 | event.SetEventObject(this); |
a23fd0e1 | 1437 | event.SetInt(idCtrl); |
88310e2e | 1438 | |
937013e0 | 1439 | bool processed = HandleWindowEvent(event); |
409f747e VZ |
1440 | if ( hdr->code == TCN_SELCHANGE ) |
1441 | UpdateSelection(event.GetSelection()); | |
1442 | ||
fd3f686c VZ |
1443 | *result = !event.IsAllowed(); |
1444 | return processed; | |
88310e2e VZ |
1445 | } |
1446 | ||
1e6feb95 | 1447 | #endif // wxUSE_NOTEBOOK |