]>
Commit | Line | Data |
---|---|---|
ee6b1d97 SC |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: notebook.cpp | |
3 | // Purpose: implementation of wxNotebook | |
a31a5f85 | 4 | // Author: Stefan Csomor |
5aed9d50 | 5 | // Modified by: |
a31a5f85 | 6 | // Created: 1998-01-01 |
ee6b1d97 | 7 | // RCS-ID: $Id$ |
a31a5f85 | 8 | // Copyright: (c) Stefan Csomor |
65571936 | 9 | // Licence: wxWindows licence |
ee6b1d97 SC |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
3d1a4878 SC |
19 | #include "wx/wxprec.h" |
20 | ||
179e085f RN |
21 | #if wxUSE_NOTEBOOK |
22 | ||
799690a0 | 23 | #include "wx/app.h" |
d497dca4 GD |
24 | #include "wx/string.h" |
25 | #include "wx/log.h" | |
26 | #include "wx/imaglist.h" | |
061174e3 | 27 | #include "wx/image.h" |
d497dca4 GD |
28 | #include "wx/notebook.h" |
29 | #include "wx/mac/uma.h" | |
ee6b1d97 SC |
30 | // ---------------------------------------------------------------------------- |
31 | // macros | |
32 | // ---------------------------------------------------------------------------- | |
33 | ||
34 | // check that the page index is valid | |
19c43a77 | 35 | #define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount()) |
ee6b1d97 | 36 | |
ee6b1d97 SC |
37 | |
38 | // ---------------------------------------------------------------------------- | |
39 | // event table | |
40 | // ---------------------------------------------------------------------------- | |
41 | ||
5b781a67 SC |
42 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED) |
43 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING) | |
44 | ||
ee6b1d97 | 45 | BEGIN_EVENT_TABLE(wxNotebook, wxControl) |
461fe6e2 | 46 | EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange) |
e40298d5 | 47 | |
461fe6e2 SC |
48 | EVT_SIZE(wxNotebook::OnSize) |
49 | EVT_SET_FOCUS(wxNotebook::OnSetFocus) | |
50 | EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) | |
ee6b1d97 SC |
51 | END_EVENT_TABLE() |
52 | ||
53 | IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl) | |
54 | IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent) | |
ee6b1d97 SC |
55 | |
56 | // ============================================================================ | |
57 | // implementation | |
58 | // ============================================================================ | |
59 | ||
5aed9d50 RD |
60 | // ---------------------------------------------------------------------------- |
61 | // wxNotebook construction | |
62 | // ---------------------------------------------------------------------------- | |
63 | ||
64 | // common part of all ctors | |
65 | void wxNotebook::Init() | |
66 | { | |
ee6b1d97 SC |
67 | m_nSelection = -1; |
68 | } | |
69 | ||
70 | // default for dynamic class | |
71 | wxNotebook::wxNotebook() | |
72 | { | |
73 | Init(); | |
74 | } | |
75 | ||
76 | // the same arguments as for wxControl | |
77 | wxNotebook::wxNotebook(wxWindow *parent, | |
78 | wxWindowID id, | |
79 | const wxPoint& pos, | |
80 | const wxSize& size, | |
81 | long style, | |
82 | const wxString& name) | |
83 | { | |
84 | Init(); | |
5aed9d50 | 85 | |
ee6b1d97 SC |
86 | Create(parent, id, pos, size, style, name); |
87 | } | |
88 | ||
89 | // Create() function | |
90 | bool wxNotebook::Create(wxWindow *parent, | |
91 | wxWindowID id, | |
92 | const wxPoint& pos, | |
93 | const wxSize& size, | |
94 | long style, | |
95 | const wxString& name) | |
96 | { | |
facd6764 SC |
97 | m_macIsUserPane = FALSE ; |
98 | ||
b45ed7a2 VZ |
99 | if ( !wxNotebookBase::Create(parent, id, pos, size, style, name) ) |
100 | return false; | |
101 | ||
facd6764 | 102 | Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; |
5aed9d50 | 103 | |
facd6764 SC |
104 | if( bounds.right <= bounds.left ) |
105 | bounds.right = bounds.left + 100 ; | |
106 | if ( bounds.bottom <= bounds.top ) | |
107 | bounds.bottom = bounds.top + 100 ; | |
5aed9d50 | 108 | |
facd6764 | 109 | UInt16 tabstyle = kControlTabDirectionNorth ; |
e40298d5 | 110 | if ( HasFlag(wxNB_LEFT) ) |
facd6764 | 111 | tabstyle = kControlTabDirectionWest ; |
e40298d5 | 112 | else if ( HasFlag( wxNB_RIGHT ) ) |
facd6764 | 113 | tabstyle = kControlTabDirectionEast ; |
e40298d5 | 114 | else if ( HasFlag( wxNB_BOTTOM ) ) |
facd6764 SC |
115 | tabstyle = kControlTabDirectionSouth ; |
116 | ||
117 | ControlTabSize tabsize = kControlTabSizeLarge ; | |
118 | if ( GetWindowVariant() == wxWINDOW_VARIANT_SMALL ) | |
119 | tabsize = kControlTabSizeSmall ; | |
120 | else if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI ) | |
121 | { | |
122 | if (UMAGetSystemVersion() >= 0x1030 ) | |
123 | tabsize = 3 ; | |
124 | else | |
125 | tabsize = kControlSizeSmall; | |
126 | } | |
5aed9d50 | 127 | |
b905d6cc | 128 | m_peer = new wxMacControl(this) ; |
4c37f124 | 129 | verify_noerr ( CreateTabsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , |
5ca0d812 | 130 | tabsize , tabstyle, 0, NULL, m_peer->GetControlRefAddr() ) ); |
21fd5529 | 131 | |
facd6764 SC |
132 | |
133 | MacPostControlCreate(pos,size) ; | |
e40298d5 | 134 | return TRUE ; |
ee6b1d97 SC |
135 | } |
136 | ||
137 | // dtor | |
138 | wxNotebook::~wxNotebook() | |
139 | { | |
ee6b1d97 SC |
140 | } |
141 | ||
142 | // ---------------------------------------------------------------------------- | |
143 | // wxNotebook accessors | |
144 | // ---------------------------------------------------------------------------- | |
90b959ae SC |
145 | |
146 | void wxNotebook::SetPadding(const wxSize& padding) | |
147 | { | |
63ff6f53 | 148 | // unsupported by OS |
90b959ae SC |
149 | } |
150 | ||
151 | void wxNotebook::SetTabSize(const wxSize& sz) | |
ee6b1d97 | 152 | { |
63ff6f53 | 153 | // unsupported by OS |
ee6b1d97 SC |
154 | } |
155 | ||
90b959ae | 156 | void wxNotebook::SetPageSize(const wxSize& size) |
ee6b1d97 | 157 | { |
63ff6f53 SC |
158 | SetSize( CalcSizeFromPage( size ) ); |
159 | } | |
160 | ||
161 | wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const | |
162 | { | |
facd6764 | 163 | return DoGetSizeFromClientSize( sizePage ) ; |
63ff6f53 SC |
164 | } |
165 | ||
8f83dfee | 166 | int wxNotebook::SetSelection(size_t nPage) |
ee6b1d97 | 167 | { |
461fe6e2 | 168 | wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") ); |
5aed9d50 | 169 | |
461fe6e2 SC |
170 | if ( int(nPage) != m_nSelection ) |
171 | { | |
172 | wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId); | |
173 | event.SetSelection(nPage); | |
174 | event.SetOldSelection(m_nSelection); | |
175 | event.SetEventObject(this); | |
176 | if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() ) | |
177 | { | |
178 | // program allows the page change | |
179 | event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED); | |
180 | (void)GetEventHandler()->ProcessEvent(event); | |
181 | ||
182 | ChangePage(m_nSelection, nPage); | |
183 | } | |
184 | } | |
5aed9d50 | 185 | |
ee6b1d97 SC |
186 | return m_nSelection; |
187 | } | |
188 | ||
8f83dfee | 189 | bool wxNotebook::SetPageText(size_t nPage, const wxString& strText) |
ee6b1d97 SC |
190 | { |
191 | wxASSERT( IS_VALID_PAGE(nPage) ); | |
5aed9d50 | 192 | |
90b959ae | 193 | wxNotebookPage *page = m_pages[nPage]; |
c854c7d9 GD |
194 | page->SetLabel(strText); |
195 | MacSetupTabs(); | |
5aed9d50 | 196 | |
c854c7d9 | 197 | return true; |
ee6b1d97 SC |
198 | } |
199 | ||
8f83dfee | 200 | wxString wxNotebook::GetPageText(size_t nPage) const |
ee6b1d97 SC |
201 | { |
202 | wxASSERT( IS_VALID_PAGE(nPage) ); | |
5aed9d50 | 203 | |
90b959ae | 204 | wxNotebookPage *page = m_pages[nPage]; |
c854c7d9 | 205 | return page->GetLabel(); |
ee6b1d97 SC |
206 | } |
207 | ||
8f83dfee | 208 | int wxNotebook::GetPageImage(size_t nPage) const |
ee6b1d97 | 209 | { |
fc0daf84 | 210 | wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, _T("invalid notebook page") ); |
5aed9d50 | 211 | |
2b5f62a0 | 212 | return m_images[nPage]; |
ee6b1d97 SC |
213 | } |
214 | ||
19c43a77 | 215 | bool wxNotebook::SetPageImage(size_t nPage, int nImage) |
ee6b1d97 | 216 | { |
fc0daf84 | 217 | wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("invalid notebook page") ); |
5aed9d50 | 218 | |
fc0daf84 | 219 | wxCHECK_MSG( m_imageList && nImage < m_imageList->GetImageCount(), FALSE, |
e40298d5 | 220 | _T("invalid image index in SetPageImage()") ); |
5aed9d50 | 221 | |
2b5f62a0 VZ |
222 | if ( nImage != m_images[nPage] ) |
223 | { | |
224 | // if the item didn't have an icon before or, on the contrary, did have | |
225 | // it but has lost it now, its size will change - but if the icon just | |
226 | // changes, it won't | |
227 | m_images[nPage] = nImage; | |
5aed9d50 | 228 | |
e40298d5 | 229 | MacSetupTabs() ; |
2b5f62a0 | 230 | } |
5aed9d50 | 231 | |
2b5f62a0 | 232 | return TRUE; |
ee6b1d97 SC |
233 | } |
234 | ||
ee6b1d97 SC |
235 | // ---------------------------------------------------------------------------- |
236 | // wxNotebook operations | |
237 | // ---------------------------------------------------------------------------- | |
238 | ||
90b959ae | 239 | // remove one page from the notebook, without deleting the window |
8f83dfee | 240 | wxNotebookPage* wxNotebook::DoRemovePage(size_t nPage) |
ee6b1d97 | 241 | { |
90b959ae SC |
242 | wxCHECK( IS_VALID_PAGE(nPage), NULL ); |
243 | wxNotebookPage* page = m_pages[nPage] ; | |
3ef585df | 244 | m_pages.RemoveAt(nPage); |
5aed9d50 | 245 | |
c854c7d9 | 246 | MacSetupTabs(); |
5aed9d50 | 247 | |
19c43a77 | 248 | if(m_nSelection >= (int)GetPageCount()) { |
c854c7d9 GD |
249 | m_nSelection = GetPageCount() - 1; |
250 | } | |
251 | if(m_nSelection >= 0) { | |
90b959ae | 252 | m_pages[m_nSelection]->Show(true); |
c854c7d9 | 253 | } |
37144cf0 | 254 | InvalidateBestSize(); |
90b959ae | 255 | return page; |
ee6b1d97 SC |
256 | } |
257 | ||
258 | // remove all pages | |
259 | bool wxNotebook::DeleteAllPages() | |
260 | { | |
90b959ae | 261 | WX_CLEAR_ARRAY(m_pages) ; |
c854c7d9 | 262 | MacSetupTabs(); |
061174e3 | 263 | m_nSelection = -1 ; |
37144cf0 | 264 | InvalidateBestSize(); |
ee6b1d97 SC |
265 | return TRUE; |
266 | } | |
267 | ||
ee6b1d97 SC |
268 | |
269 | // same as AddPage() but does it at given position | |
8f83dfee | 270 | bool wxNotebook::InsertPage(size_t nPage, |
ee6b1d97 SC |
271 | wxNotebookPage *pPage, |
272 | const wxString& strText, | |
273 | bool bSelect, | |
274 | int imageId) | |
275 | { | |
19c43a77 VZ |
276 | if ( !wxNotebookBase::InsertPage(nPage, pPage, strText, bSelect, imageId) ) |
277 | return false; | |
5aed9d50 | 278 | |
461fe6e2 SC |
279 | wxASSERT_MSG( pPage->GetParent() == this, |
280 | _T("notebook pages must have notebook as parent") ); | |
281 | ||
282 | // don't show pages by default (we'll need to adjust their size first) | |
283 | pPage->Show( false ) ; | |
284 | ||
c854c7d9 | 285 | pPage->SetLabel(strText); |
5aed9d50 | 286 | |
2b5f62a0 | 287 | m_images.Insert(imageId, nPage); |
5aed9d50 | 288 | |
c854c7d9 | 289 | MacSetupTabs(); |
5aed9d50 | 290 | |
63ff6f53 SC |
291 | wxRect rect = GetPageRect() ; |
292 | pPage->SetSize(rect); | |
c854c7d9 GD |
293 | if ( pPage->GetAutoLayout() ) { |
294 | pPage->Layout(); | |
295 | } | |
5aed9d50 | 296 | |
461fe6e2 SC |
297 | |
298 | // now deal with the selection | |
299 | // --------------------------- | |
300 | ||
301 | // if the inserted page is before the selected one, we must update the | |
302 | // index of the selected page | |
303 | ||
304 | if ( int(nPage) <= m_nSelection ) | |
305 | { | |
306 | m_nSelection++; | |
307 | // while this still is the same page showing, we need to update the tabs | |
5ca0d812 | 308 | m_peer->SetValue( m_nSelection + 1 ) ; |
461fe6e2 SC |
309 | } |
310 | ||
311 | // some page should be selected: either this one or the first one if there | |
312 | // is still no selection | |
313 | int selNew = -1; | |
314 | if ( bSelect ) | |
315 | selNew = nPage; | |
316 | else if ( m_nSelection == -1 ) | |
317 | selNew = 0; | |
318 | ||
319 | if ( selNew != -1 ) | |
320 | SetSelection(selNew); | |
321 | ||
37144cf0 | 322 | InvalidateBestSize(); |
c854c7d9 GD |
323 | return true; |
324 | } | |
325 | ||
326 | /* Added by Mark Newsam | |
e40298d5 | 327 | * When a page is added or deleted to the notebook this function updates |
21fd5529 | 328 | * information held in the control so that it matches the order |
e40298d5 JS |
329 | * the user would expect. |
330 | */ | |
c854c7d9 GD |
331 | void wxNotebook::MacSetupTabs() |
332 | { | |
5ca0d812 | 333 | m_peer->SetMaximum( GetPageCount() ) ; |
5aed9d50 | 334 | |
c854c7d9 | 335 | wxNotebookPage *page; |
5324268e | 336 | ControlTabInfoRecV1 info; |
5aed9d50 | 337 | |
19c43a77 VZ |
338 | const size_t countPages = GetPageCount(); |
339 | for(size_t ii = 0; ii < countPages; ii++) | |
c854c7d9 | 340 | { |
90b959ae | 341 | page = m_pages[ii]; |
5324268e | 342 | info.version = kControlTabInfoVersionOne; |
c854c7d9 | 343 | info.iconSuiteID = 0; |
5324268e SC |
344 | wxMacCFStringHolder cflabel( page->GetLabel() , m_font.GetEncoding() ) ; |
345 | info.name = cflabel ; | |
346 | m_peer->SetData<ControlTabInfoRecV1>( ii+1, kControlTabInfoTag, &info ) ; | |
20b69855 | 347 | |
2b5f62a0 VZ |
348 | if ( GetImageList() && GetPageImage(ii) >= 0 && UMAGetSystemVersion() >= 0x1020 ) |
349 | { | |
b337acd7 SC |
350 | const wxBitmap bmap = GetImageList()->GetBitmap( GetPageImage(ii ) ) ; |
351 | if ( bmap.Ok() ) | |
061174e3 | 352 | { |
061174e3 | 353 | ControlButtonContentInfo info ; |
20b69855 | 354 | |
b337acd7 | 355 | wxMacCreateBitmapButton( &info , bmap ) ; |
81e2cbc6 VZ |
356 | #ifdef __WXDEBUG__ |
357 | OSStatus err = | |
358 | #endif // __WXDEBUG__ | |
359 | m_peer->SetData<ControlButtonContentInfo>( ii+1,kControlTabImageContentTag, &info ); | |
061174e3 | 360 | wxASSERT_MSG( err == noErr , wxT("Error when setting icon on tab") ) ; |
20b69855 | 361 | wxMacReleaseBitmapButton( &info ) ; |
061174e3 | 362 | } |
2b5f62a0 | 363 | } |
5324268e | 364 | m_peer->SetTabEnabled( ii + 1 , true ) ; |
c854c7d9 GD |
365 | } |
366 | Rect bounds; | |
5ca0d812 | 367 | m_peer->GetRectInWindowCoords( &bounds ) ; |
facd6764 | 368 | InvalWindowRect((WindowRef)MacGetTopLevelWindowRef(), &bounds); |
ee6b1d97 SC |
369 | } |
370 | ||
63ff6f53 SC |
371 | wxRect wxNotebook::GetPageRect() const |
372 | { | |
facd6764 SC |
373 | wxSize size = GetClientSize() ; |
374 | return wxRect( 0 , 0 , size.x , size.y ) ; | |
63ff6f53 | 375 | } |
ee6b1d97 SC |
376 | // ---------------------------------------------------------------------------- |
377 | // wxNotebook callbacks | |
378 | // ---------------------------------------------------------------------------- | |
379 | ||
380 | // @@@ OnSize() is used for setting the font when it's called for the first | |
381 | // time because doing it in ::Create() doesn't work (for unknown reasons) | |
382 | void wxNotebook::OnSize(wxSizeEvent& event) | |
383 | { | |
5aed9d50 | 384 | |
90b959ae | 385 | unsigned int nCount = m_pages.Count(); |
63ff6f53 | 386 | wxRect rect = GetPageRect() ; |
ee6b1d97 | 387 | for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) { |
90b959ae | 388 | wxNotebookPage *pPage = m_pages[nPage]; |
63ff6f53 | 389 | pPage->SetSize(rect); |
c854c7d9 | 390 | if ( pPage->GetAutoLayout() ) { |
ee6b1d97 | 391 | pPage->Layout(); |
c854c7d9 | 392 | } |
ee6b1d97 | 393 | } |
5aed9d50 | 394 | |
ee6b1d97 SC |
395 | // Processing continues to next OnSize |
396 | event.Skip(); | |
397 | } | |
398 | ||
399 | void wxNotebook::OnSelChange(wxNotebookEvent& event) | |
400 | { | |
401 | // is it our tab control? | |
402 | if ( event.GetEventObject() == this ) | |
403 | ChangePage(event.GetOldSelection(), event.GetSelection()); | |
5aed9d50 | 404 | |
ee6b1d97 SC |
405 | // we want to give others a chance to process this message as well |
406 | event.Skip(); | |
407 | } | |
408 | ||
409 | void wxNotebook::OnSetFocus(wxFocusEvent& event) | |
410 | { | |
411 | // set focus to the currently selected page if any | |
412 | if ( m_nSelection != -1 ) | |
90b959ae | 413 | m_pages[m_nSelection]->SetFocus(); |
5aed9d50 | 414 | |
ee6b1d97 SC |
415 | event.Skip(); |
416 | } | |
417 | ||
418 | void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event) | |
419 | { | |
420 | if ( event.IsWindowChange() ) { | |
421 | // change pages | |
422 | AdvanceSelection(event.GetDirection()); | |
423 | } | |
424 | else { | |
461fe6e2 SC |
425 | // we get this event in 2 cases |
426 | // | |
427 | // a) one of our pages might have generated it because the user TABbed | |
428 | // out from it in which case we should propagate the event upwards and | |
429 | // our parent will take care of setting the focus to prev/next sibling | |
430 | // | |
431 | // or | |
432 | // | |
433 | // b) the parent panel wants to give the focus to us so that we | |
434 | // forward it to our selected page. We can't deal with this in | |
435 | // OnSetFocus() because we don't know which direction the focus came | |
436 | // from in this case and so can't choose between setting the focus to | |
437 | // first or last panel child | |
438 | wxWindow *parent = GetParent(); | |
439 | // the cast is here to fic a GCC ICE | |
440 | if ( ((wxWindow*)event.GetEventObject()) == parent ) | |
441 | { | |
442 | // no, it doesn't come from child, case (b): forward to a page | |
443 | if ( m_nSelection != -1 ) | |
444 | { | |
445 | // so that the page knows that the event comes from it's parent | |
446 | // and is being propagated downwards | |
447 | event.SetEventObject(this); | |
448 | ||
449 | wxWindow *page = m_pages[m_nSelection]; | |
450 | if ( !page->GetEventHandler()->ProcessEvent(event) ) | |
451 | { | |
452 | page->SetFocus(); | |
453 | } | |
454 | //else: page manages focus inside it itself | |
455 | } | |
456 | else | |
457 | { | |
458 | // we have no pages - still have to give focus to _something_ | |
459 | SetFocus(); | |
460 | } | |
461 | } | |
462 | else | |
463 | { | |
464 | // it comes from our child, case (a), pass to the parent | |
465 | if ( parent ) { | |
466 | event.SetCurrentFocus(this); | |
467 | parent->GetEventHandler()->ProcessEvent(event); | |
468 | } | |
ee6b1d97 SC |
469 | } |
470 | } | |
471 | } | |
472 | ||
473 | // ---------------------------------------------------------------------------- | |
474 | // wxNotebook base class virtuals | |
475 | // ---------------------------------------------------------------------------- | |
476 | ||
461fe6e2 SC |
477 | #if wxUSE_CONSTRAINTS |
478 | ||
ee6b1d97 SC |
479 | // override these 2 functions to do nothing: everything is done in OnSize |
480 | ||
461fe6e2 | 481 | void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse)) |
ee6b1d97 | 482 | { |
461fe6e2 SC |
483 | // don't set the sizes of the pages - their correct size is not yet known |
484 | wxControl::SetConstraintSizes(FALSE); | |
ee6b1d97 SC |
485 | } |
486 | ||
461fe6e2 | 487 | bool wxNotebook::DoPhase(int WXUNUSED(nPhase)) |
ee6b1d97 | 488 | { |
461fe6e2 | 489 | return TRUE; |
ee6b1d97 SC |
490 | } |
491 | ||
461fe6e2 SC |
492 | #endif // wxUSE_CONSTRAINTS |
493 | ||
ee6b1d97 SC |
494 | void wxNotebook::Command(wxCommandEvent& event) |
495 | { | |
427ff662 | 496 | wxFAIL_MSG(wxT("wxNotebook::Command not implemented")); |
ee6b1d97 SC |
497 | } |
498 | ||
499 | // ---------------------------------------------------------------------------- | |
500 | // wxNotebook helper functions | |
501 | // ---------------------------------------------------------------------------- | |
502 | ||
503 | // hide the currently active panel and show the new one | |
504 | void wxNotebook::ChangePage(int nOldSel, int nSel) | |
505 | { | |
461fe6e2 SC |
506 | if ( nOldSel != -1 ) |
507 | { | |
508 | m_pages[nOldSel]->Show(FALSE); | |
509 | } | |
510 | ||
511 | if ( nSel != -1 ) | |
c854c7d9 | 512 | { |
90b959ae | 513 | wxNotebookPage *pPage = m_pages[nSel]; |
c854c7d9 GD |
514 | pPage->Show(TRUE); |
515 | pPage->SetFocus(); | |
c854c7d9 | 516 | } |
461fe6e2 | 517 | |
ee6b1d97 | 518 | m_nSelection = nSel; |
5ca0d812 | 519 | m_peer->SetValue( m_nSelection + 1 ) ; |
ee6b1d97 SC |
520 | } |
521 | ||
4c37f124 | 522 | wxInt32 wxNotebook::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) ) |
799690a0 | 523 | { |
4c37f124 SC |
524 | OSStatus status = eventNotHandledErr ; |
525 | ||
5ca0d812 | 526 | SInt32 newSel = m_peer->GetValue() - 1 ; |
4c37f124 | 527 | if ( newSel != m_nSelection ) |
e40298d5 | 528 | { |
4c37f124 SC |
529 | wxNotebookEvent changing(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId, |
530 | newSel , m_nSelection); | |
531 | changing.SetEventObject(this); | |
532 | GetEventHandler()->ProcessEvent(changing); | |
5aed9d50 | 533 | |
4c37f124 | 534 | if(changing.IsAllowed()) |
e40298d5 | 535 | { |
4c37f124 SC |
536 | wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId, |
537 | newSel, m_nSelection); | |
538 | event.SetEventObject(this); | |
5aed9d50 | 539 | |
4c37f124 SC |
540 | GetEventHandler()->ProcessEvent(event); |
541 | } | |
542 | else | |
543 | { | |
5ca0d812 | 544 | m_peer->SetValue( m_nSelection + 1 ) ; |
e40298d5 | 545 | } |
4c37f124 | 546 | status = noErr ; |
e40298d5 | 547 | } |
4c37f124 | 548 | return status ; |
ee6b1d97 SC |
549 | } |
550 | ||
179e085f RN |
551 | #endif |
552 |