]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: msw/notebook.cpp | |
3 | // Purpose: implementation of wxNotebook | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 11.06.98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "notebook.h" | |
14 | #endif | |
15 | ||
16 | // For compilers that support precompilation, includes "wx.h". | |
17 | #include "wx/wxprec.h" | |
18 | ||
19 | #ifdef __BORLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #if wxUSE_NOTEBOOK | |
24 | ||
25 | // wxWindows | |
26 | #ifndef WX_PRECOMP | |
27 | #include "wx/string.h" | |
28 | #endif // WX_PRECOMP | |
29 | ||
30 | #include "wx/log.h" | |
31 | #include "wx/imaglist.h" | |
32 | #include "wx/event.h" | |
33 | #include "wx/control.h" | |
34 | #include "wx/notebook.h" | |
35 | ||
36 | #include "wx/msw/private.h" | |
37 | ||
38 | // Windows standard headers | |
39 | #ifndef __WIN95__ | |
40 | #error "wxNotebook is only supported Windows 95 and above" | |
41 | #endif //Win95 | |
42 | ||
43 | #include <windowsx.h> // for SetWindowFont | |
44 | ||
45 | #ifndef __TWIN32__ | |
46 | #ifdef __GNUWIN32_OLD__ | |
47 | #include "wx/msw/gnuwin32/extra.h" | |
48 | #endif | |
49 | #endif | |
50 | ||
51 | #if defined(__WIN95__) && !((defined(__GNUWIN32_OLD__) || defined(__TWIN32__)) && !defined(__CYGWIN10__)) | |
52 | #include <commctrl.h> | |
53 | #endif | |
54 | ||
55 | // ---------------------------------------------------------------------------- | |
56 | // macros | |
57 | // ---------------------------------------------------------------------------- | |
58 | ||
59 | // check that the page index is valid | |
60 | #define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((nPage) < GetPageCount())) | |
61 | ||
62 | // hide the ugly cast | |
63 | #define m_hwnd (HWND)GetHWND() | |
64 | ||
65 | // ---------------------------------------------------------------------------- | |
66 | // constants | |
67 | // ---------------------------------------------------------------------------- | |
68 | ||
69 | // This is a work-around for missing defines in gcc-2.95 headers | |
70 | #ifndef TCS_RIGHT | |
71 | #define TCS_RIGHT 0x0002 | |
72 | #endif | |
73 | ||
74 | #ifndef TCS_VERTICAL | |
75 | #define TCS_VERTICAL 0x0080 | |
76 | #endif | |
77 | ||
78 | #ifndef TCS_BOTTOM | |
79 | #define TCS_BOTTOM TCS_RIGHT | |
80 | #endif | |
81 | ||
82 | // ---------------------------------------------------------------------------- | |
83 | // event table | |
84 | // ---------------------------------------------------------------------------- | |
85 | ||
86 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED) | |
87 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING) | |
88 | ||
89 | BEGIN_EVENT_TABLE(wxNotebook, wxControl) | |
90 | EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange) | |
91 | ||
92 | EVT_SIZE(wxNotebook::OnSize) | |
93 | ||
94 | EVT_SET_FOCUS(wxNotebook::OnSetFocus) | |
95 | ||
96 | EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) | |
97 | END_EVENT_TABLE() | |
98 | ||
99 | IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl) | |
100 | IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent) | |
101 | ||
102 | // ============================================================================ | |
103 | // implementation | |
104 | // ============================================================================ | |
105 | ||
106 | // ---------------------------------------------------------------------------- | |
107 | // wxNotebook construction | |
108 | // ---------------------------------------------------------------------------- | |
109 | ||
110 | // common part of all ctors | |
111 | void wxNotebook::Init() | |
112 | { | |
113 | m_imageList = NULL; | |
114 | m_nSelection = -1; | |
115 | } | |
116 | ||
117 | // default for dynamic class | |
118 | wxNotebook::wxNotebook() | |
119 | { | |
120 | Init(); | |
121 | } | |
122 | ||
123 | // the same arguments as for wxControl | |
124 | wxNotebook::wxNotebook(wxWindow *parent, | |
125 | wxWindowID id, | |
126 | const wxPoint& pos, | |
127 | const wxSize& size, | |
128 | long style, | |
129 | const wxString& name) | |
130 | { | |
131 | Init(); | |
132 | ||
133 | Create(parent, id, pos, size, style, name); | |
134 | } | |
135 | ||
136 | // Create() function | |
137 | bool wxNotebook::Create(wxWindow *parent, | |
138 | wxWindowID id, | |
139 | const wxPoint& pos, | |
140 | const wxSize& size, | |
141 | long style, | |
142 | const wxString& name) | |
143 | { | |
144 | // base init | |
145 | if ( !CreateControl(parent, id, pos, size, style | wxTAB_TRAVERSAL, | |
146 | wxDefaultValidator, name) ) | |
147 | return FALSE; | |
148 | ||
149 | if ( !MSWCreateControl(WC_TABCONTROL, _T(""), pos, size) ) | |
150 | return FALSE; | |
151 | ||
152 | SetBackgroundColour(wxColour(::GetSysColor(COLOR_BTNFACE))); | |
153 | ||
154 | return TRUE; | |
155 | } | |
156 | ||
157 | WXDWORD wxNotebook::MSWGetStyle(long style, WXDWORD *exstyle) const | |
158 | { | |
159 | WXDWORD tabStyle = wxControl::MSWGetStyle(style, exstyle); | |
160 | ||
161 | tabStyle |= WS_TABSTOP | TCS_TABS; | |
162 | ||
163 | if ( style & wxNB_MULTILINE ) | |
164 | tabStyle |= TCS_MULTILINE; | |
165 | if ( style & wxNB_FIXEDWIDTH ) | |
166 | tabStyle |= TCS_FIXEDWIDTH; | |
167 | ||
168 | if ( style & wxNB_BOTTOM ) | |
169 | tabStyle |= TCS_RIGHT; | |
170 | else if ( style & wxNB_LEFT ) | |
171 | tabStyle |= TCS_VERTICAL; | |
172 | else if ( style & wxNB_RIGHT ) | |
173 | tabStyle |= TCS_VERTICAL | TCS_RIGHT; | |
174 | ||
175 | // ex style | |
176 | if ( exstyle ) | |
177 | { | |
178 | // note that we never want to have the default WS_EX_CLIENTEDGE style | |
179 | // as it looks too ugly for the notebooks | |
180 | *exstyle = 0; | |
181 | } | |
182 | ||
183 | return tabStyle; | |
184 | } | |
185 | ||
186 | // ---------------------------------------------------------------------------- | |
187 | // wxNotebook accessors | |
188 | // ---------------------------------------------------------------------------- | |
189 | ||
190 | int wxNotebook::GetPageCount() const | |
191 | { | |
192 | // consistency check | |
193 | wxASSERT( (int)m_pages.Count() == TabCtrl_GetItemCount(m_hwnd) ); | |
194 | ||
195 | return m_pages.Count(); | |
196 | } | |
197 | ||
198 | int wxNotebook::GetRowCount() const | |
199 | { | |
200 | return TabCtrl_GetRowCount(m_hwnd); | |
201 | } | |
202 | ||
203 | int wxNotebook::SetSelection(int nPage) | |
204 | { | |
205 | wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") ); | |
206 | ||
207 | if ( nPage != m_nSelection ) | |
208 | { | |
209 | wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId); | |
210 | event.SetSelection(nPage); | |
211 | event.SetOldSelection(m_nSelection); | |
212 | event.SetEventObject(this); | |
213 | if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() ) | |
214 | { | |
215 | // program allows the page change | |
216 | event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED); | |
217 | (void)GetEventHandler()->ProcessEvent(event); | |
218 | ||
219 | TabCtrl_SetCurSel(m_hwnd, nPage); | |
220 | } | |
221 | } | |
222 | ||
223 | return m_nSelection; | |
224 | } | |
225 | ||
226 | bool wxNotebook::SetPageText(int nPage, const wxString& strText) | |
227 | { | |
228 | wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") ); | |
229 | ||
230 | TC_ITEM tcItem; | |
231 | tcItem.mask = TCIF_TEXT; | |
232 | tcItem.pszText = (wxChar *)strText.c_str(); | |
233 | ||
234 | return TabCtrl_SetItem(m_hwnd, nPage, &tcItem) != 0; | |
235 | } | |
236 | ||
237 | wxString wxNotebook::GetPageText(int nPage) const | |
238 | { | |
239 | wxCHECK_MSG( IS_VALID_PAGE(nPage), wxT(""), wxT("notebook page out of range") ); | |
240 | ||
241 | wxChar buf[256]; | |
242 | TC_ITEM tcItem; | |
243 | tcItem.mask = TCIF_TEXT; | |
244 | tcItem.pszText = buf; | |
245 | tcItem.cchTextMax = WXSIZEOF(buf); | |
246 | ||
247 | wxString str; | |
248 | if ( TabCtrl_GetItem(m_hwnd, nPage, &tcItem) ) | |
249 | str = tcItem.pszText; | |
250 | ||
251 | return str; | |
252 | } | |
253 | ||
254 | int wxNotebook::GetPageImage(int nPage) const | |
255 | { | |
256 | wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") ); | |
257 | ||
258 | TC_ITEM tcItem; | |
259 | tcItem.mask = TCIF_IMAGE; | |
260 | ||
261 | return TabCtrl_GetItem(m_hwnd, nPage, &tcItem) ? tcItem.iImage : -1; | |
262 | } | |
263 | ||
264 | bool wxNotebook::SetPageImage(int nPage, int nImage) | |
265 | { | |
266 | wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") ); | |
267 | ||
268 | TC_ITEM tcItem; | |
269 | tcItem.mask = TCIF_IMAGE; | |
270 | tcItem.iImage = nImage; | |
271 | ||
272 | return TabCtrl_SetItem(m_hwnd, nPage, &tcItem) != 0; | |
273 | } | |
274 | ||
275 | void wxNotebook::SetImageList(wxImageList* imageList) | |
276 | { | |
277 | wxNotebookBase::SetImageList(imageList); | |
278 | ||
279 | if ( imageList ) | |
280 | { | |
281 | TabCtrl_SetImageList(m_hwnd, (HIMAGELIST)imageList->GetHIMAGELIST()); | |
282 | } | |
283 | } | |
284 | ||
285 | // ---------------------------------------------------------------------------- | |
286 | // wxNotebook size settings | |
287 | // ---------------------------------------------------------------------------- | |
288 | ||
289 | void wxNotebook::SetPageSize(const wxSize& size) | |
290 | { | |
291 | // transform the page size into the notebook size | |
292 | RECT rc; | |
293 | rc.left = | |
294 | rc.top = 0; | |
295 | rc.right = size.x; | |
296 | rc.bottom = size.y; | |
297 | ||
298 | TabCtrl_AdjustRect(GetHwnd(), TRUE, &rc); | |
299 | ||
300 | // and now set it | |
301 | SetSize(rc.right - rc.left, rc.bottom - rc.top); | |
302 | } | |
303 | ||
304 | void wxNotebook::SetPadding(const wxSize& padding) | |
305 | { | |
306 | TabCtrl_SetPadding(GetHwnd(), padding.x, padding.y); | |
307 | } | |
308 | ||
309 | // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH | |
310 | // style. | |
311 | void wxNotebook::SetTabSize(const wxSize& sz) | |
312 | { | |
313 | ::SendMessage(GetHwnd(), TCM_SETITEMSIZE, 0, MAKELPARAM(sz.x, sz.y)); | |
314 | } | |
315 | ||
316 | // ---------------------------------------------------------------------------- | |
317 | // wxNotebook operations | |
318 | // ---------------------------------------------------------------------------- | |
319 | ||
320 | // remove one page from the notebook, without deleting | |
321 | wxNotebookPage *wxNotebook::DoRemovePage(int nPage) | |
322 | { | |
323 | wxNotebookPage *pageRemoved = wxNotebookBase::DoRemovePage(nPage); | |
324 | if ( !pageRemoved ) | |
325 | return NULL; | |
326 | ||
327 | TabCtrl_DeleteItem(m_hwnd, nPage); | |
328 | ||
329 | if ( m_pages.IsEmpty() ) | |
330 | { | |
331 | // no selection any more, the notebook becamse empty | |
332 | m_nSelection = -1; | |
333 | } | |
334 | else // notebook still not empty | |
335 | { | |
336 | // change the selected page if it was deleted or became invalid | |
337 | int selNew; | |
338 | if ( m_nSelection == GetPageCount() ) | |
339 | { | |
340 | // last page deleted, make the new last page the new selection | |
341 | selNew = m_nSelection - 1; | |
342 | } | |
343 | else if ( nPage <= m_nSelection ) | |
344 | { | |
345 | // we must show another page, even if it has the same index | |
346 | selNew = m_nSelection; | |
347 | } | |
348 | else // nothing changes for the currently selected page | |
349 | { | |
350 | selNew = -1; | |
351 | ||
352 | // we still must refresh the current page: this needs to be done | |
353 | // for some unknown reason if the tab control shows the up-down | |
354 | // control (i.e. when there are too many pages) -- otherwise after | |
355 | // deleting a page nothing at all is shown | |
356 | m_pages[m_nSelection]->Refresh(); | |
357 | } | |
358 | ||
359 | if ( selNew != -1 ) | |
360 | { | |
361 | // m_nSelection must be always valid so reset it before calling | |
362 | // SetSelection() | |
363 | m_nSelection = -1; | |
364 | SetSelection(selNew); | |
365 | } | |
366 | } | |
367 | ||
368 | return pageRemoved; | |
369 | } | |
370 | ||
371 | // remove all pages | |
372 | bool wxNotebook::DeleteAllPages() | |
373 | { | |
374 | int nPageCount = GetPageCount(); | |
375 | int nPage; | |
376 | for ( nPage = 0; nPage < nPageCount; nPage++ ) | |
377 | delete m_pages[nPage]; | |
378 | ||
379 | m_pages.Clear(); | |
380 | ||
381 | TabCtrl_DeleteAllItems(m_hwnd); | |
382 | ||
383 | m_nSelection = -1; | |
384 | ||
385 | return TRUE; | |
386 | } | |
387 | ||
388 | // same as AddPage() but does it at given position | |
389 | bool wxNotebook::InsertPage(int nPage, | |
390 | wxNotebookPage *pPage, | |
391 | const wxString& strText, | |
392 | bool bSelect, | |
393 | int imageId) | |
394 | { | |
395 | wxCHECK_MSG( pPage != NULL, FALSE, _T("NULL page in wxNotebook::InsertPage") ); | |
396 | wxCHECK_MSG( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE, | |
397 | _T("invalid index in wxNotebook::InsertPage") ); | |
398 | ||
399 | wxASSERT_MSG( pPage->GetParent() == this, | |
400 | _T("notebook pages must have notebook as parent") ); | |
401 | ||
402 | // add a new tab to the control | |
403 | // ---------------------------- | |
404 | ||
405 | // init all fields to 0 | |
406 | TC_ITEM tcItem; | |
407 | wxZeroMemory(tcItem); | |
408 | ||
409 | // set the image, if any | |
410 | if ( imageId != -1 ) | |
411 | { | |
412 | tcItem.mask |= TCIF_IMAGE; | |
413 | tcItem.iImage = imageId; | |
414 | } | |
415 | ||
416 | // and the text | |
417 | if ( !strText.IsEmpty() ) | |
418 | { | |
419 | tcItem.mask |= TCIF_TEXT; | |
420 | tcItem.pszText = (wxChar *)strText.c_str(); // const_cast | |
421 | } | |
422 | ||
423 | // fit the notebook page to the tab control's display area: this should be | |
424 | // done before adding it to the notebook or TabCtrl_InsertItem() will | |
425 | // change the notebooks size itself! | |
426 | RECT rc; | |
427 | rc.left = rc.top = 0; | |
428 | GetSize((int *)&rc.right, (int *)&rc.bottom); | |
429 | TabCtrl_AdjustRect(m_hwnd, FALSE, &rc); | |
430 | pPage->SetSize(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); | |
431 | ||
432 | ||
433 | // finally do insert it | |
434 | if ( TabCtrl_InsertItem(m_hwnd, nPage, &tcItem) == -1 ) { | |
435 | wxLogError(wxT("Can't create the notebook page '%s'."), strText.c_str()); | |
436 | ||
437 | return FALSE; | |
438 | } | |
439 | ||
440 | // succeeded: save the pointer to the page | |
441 | m_pages.Insert(pPage, nPage); | |
442 | ||
443 | // hide the page: unless it is selected, it shouldn't be shown (and if it | |
444 | // is selected it will be shown later) | |
445 | HWND hwnd = GetWinHwnd(pPage); | |
446 | SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_VISIBLE); | |
447 | ||
448 | // this updates internal flag too -- otherwise it would get out of sync | |
449 | // with the real state | |
450 | pPage->Show(FALSE); | |
451 | ||
452 | ||
453 | // now deal with the selection | |
454 | // --------------------------- | |
455 | ||
456 | // if the inserted page is before the selected one, we must update the | |
457 | // index of the selected page | |
458 | if ( nPage <= m_nSelection ) | |
459 | { | |
460 | // one extra page added | |
461 | m_nSelection++; | |
462 | } | |
463 | ||
464 | // some page should be selected: either this one or the first one if there | |
465 | // is still no selection | |
466 | int selNew = -1; | |
467 | if ( bSelect ) | |
468 | selNew = nPage; | |
469 | else if ( m_nSelection == -1 ) | |
470 | selNew = 0; | |
471 | ||
472 | if ( selNew != -1 ) | |
473 | SetSelection(selNew); | |
474 | ||
475 | return TRUE; | |
476 | } | |
477 | ||
478 | // ---------------------------------------------------------------------------- | |
479 | // wxNotebook callbacks | |
480 | // ---------------------------------------------------------------------------- | |
481 | ||
482 | void wxNotebook::OnSize(wxSizeEvent& event) | |
483 | { | |
484 | // fit the notebook page to the tab control's display area | |
485 | RECT rc; | |
486 | rc.left = rc.top = 0; | |
487 | GetSize((int *)&rc.right, (int *)&rc.bottom); | |
488 | ||
489 | TabCtrl_AdjustRect(m_hwnd, FALSE, &rc); | |
490 | ||
491 | int width = rc.right - rc.left, | |
492 | height = rc.bottom - rc.top; | |
493 | size_t nCount = m_pages.Count(); | |
494 | for ( size_t nPage = 0; nPage < nCount; nPage++ ) { | |
495 | wxNotebookPage *pPage = m_pages[nPage]; | |
496 | pPage->SetSize(rc.left, rc.top, width, height); | |
497 | } | |
498 | ||
499 | event.Skip(); | |
500 | } | |
501 | ||
502 | void wxNotebook::OnSelChange(wxNotebookEvent& event) | |
503 | { | |
504 | // is it our tab control? | |
505 | if ( event.GetEventObject() == this ) | |
506 | { | |
507 | int sel = event.GetOldSelection(); | |
508 | if ( sel != -1 ) | |
509 | m_pages[sel]->Show(FALSE); | |
510 | ||
511 | sel = event.GetSelection(); | |
512 | if ( sel != -1 ) | |
513 | { | |
514 | wxNotebookPage *pPage = m_pages[sel]; | |
515 | pPage->Show(TRUE); | |
516 | pPage->SetFocus(); | |
517 | } | |
518 | ||
519 | m_nSelection = sel; | |
520 | } | |
521 | ||
522 | // we want to give others a chance to process this message as well | |
523 | event.Skip(); | |
524 | } | |
525 | ||
526 | void wxNotebook::OnSetFocus(wxFocusEvent& event) | |
527 | { | |
528 | // this function is only called when the focus is explicitly set (i.e. from | |
529 | // the program) to the notebook - in this case we don't need the | |
530 | // complicated OnNavigationKey() logic because the programmer knows better | |
531 | // what [s]he wants | |
532 | ||
533 | // set focus to the currently selected page if any | |
534 | if ( m_nSelection != -1 ) | |
535 | m_pages[m_nSelection]->SetFocus(); | |
536 | ||
537 | event.Skip(); | |
538 | } | |
539 | ||
540 | void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event) | |
541 | { | |
542 | if ( event.IsWindowChange() ) { | |
543 | // change pages | |
544 | AdvanceSelection(event.GetDirection()); | |
545 | } | |
546 | else { | |
547 | // we get this event in 2 cases | |
548 | // | |
549 | // a) one of our pages might have generated it because the user TABbed | |
550 | // out from it in which case we should propagate the event upwards and | |
551 | // our parent will take care of setting the focus to prev/next sibling | |
552 | // | |
553 | // or | |
554 | // | |
555 | // b) the parent panel wants to give the focus to us so that we | |
556 | // forward it to our selected page. We can't deal with this in | |
557 | // OnSetFocus() because we don't know which direction the focus came | |
558 | // from in this case and so can't choose between setting the focus to | |
559 | // first or last panel child | |
560 | ||
561 | wxWindow *parent = GetParent(); | |
562 | if ( event.GetEventObject() == parent ) | |
563 | { | |
564 | // no, it doesn't come from child, case (b): forward to a page | |
565 | if ( m_nSelection != -1 ) | |
566 | { | |
567 | // so that the page knows that the event comes from it's parent | |
568 | // and is being propagated downwards | |
569 | event.SetEventObject(this); | |
570 | ||
571 | wxWindow *page = m_pages[m_nSelection]; | |
572 | if ( !page->GetEventHandler()->ProcessEvent(event) ) | |
573 | { | |
574 | page->SetFocus(); | |
575 | } | |
576 | //else: page manages focus inside it itself | |
577 | } | |
578 | else | |
579 | { | |
580 | // we have no pages - still have to give focus to _something_ | |
581 | SetFocus(); | |
582 | } | |
583 | } | |
584 | else | |
585 | { | |
586 | // it comes from our child, case (a), pass to the parent | |
587 | if ( parent ) { | |
588 | event.SetCurrentFocus(this); | |
589 | parent->GetEventHandler()->ProcessEvent(event); | |
590 | } | |
591 | } | |
592 | } | |
593 | } | |
594 | ||
595 | // ---------------------------------------------------------------------------- | |
596 | // wxNotebook base class virtuals | |
597 | // ---------------------------------------------------------------------------- | |
598 | ||
599 | #if wxUSE_CONSTRAINTS | |
600 | ||
601 | // override these 2 functions to do nothing: everything is done in OnSize | |
602 | ||
603 | void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse)) | |
604 | { | |
605 | // don't set the sizes of the pages - their correct size is not yet known | |
606 | wxControl::SetConstraintSizes(FALSE); | |
607 | } | |
608 | ||
609 | bool wxNotebook::DoPhase(int WXUNUSED(nPhase)) | |
610 | { | |
611 | return TRUE; | |
612 | } | |
613 | ||
614 | #endif // wxUSE_CONSTRAINTS | |
615 | ||
616 | // ---------------------------------------------------------------------------- | |
617 | // wxNotebook Windows message handlers | |
618 | // ---------------------------------------------------------------------------- | |
619 | ||
620 | bool wxNotebook::MSWOnScroll(int orientation, WXWORD nSBCode, | |
621 | WXWORD pos, WXHWND control) | |
622 | { | |
623 | // don't generate EVT_SCROLLWIN events for the WM_SCROLLs coming from the | |
624 | // up-down control | |
625 | if ( control ) | |
626 | return FALSE; | |
627 | ||
628 | return wxNotebookBase::MSWOnScroll(orientation, nSBCode, pos, control); | |
629 | } | |
630 | ||
631 | bool wxNotebook::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result) | |
632 | { | |
633 | wxNotebookEvent event(wxEVT_NULL, m_windowId); | |
634 | ||
635 | NMHDR* hdr = (NMHDR *)lParam; | |
636 | switch ( hdr->code ) { | |
637 | case TCN_SELCHANGE: | |
638 | event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED); | |
639 | break; | |
640 | ||
641 | case TCN_SELCHANGING: | |
642 | event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING); | |
643 | break; | |
644 | ||
645 | default: | |
646 | return wxControl::MSWOnNotify(idCtrl, lParam, result); | |
647 | } | |
648 | ||
649 | event.SetSelection(TabCtrl_GetCurSel(m_hwnd)); | |
650 | event.SetOldSelection(m_nSelection); | |
651 | event.SetEventObject(this); | |
652 | event.SetInt(idCtrl); | |
653 | ||
654 | bool processed = GetEventHandler()->ProcessEvent(event); | |
655 | *result = !event.IsAllowed(); | |
656 | return processed; | |
657 | } | |
658 | ||
659 | #endif // wxUSE_NOTEBOOK |