]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/notebook.cpp
Fix cvs conflict.
[wxWidgets.git] / src / gtk1 / notebook.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: notebook.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling, Vadim Zeitlin
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifdef __GNUG__
11 #pragma implementation "notebook.h"
12 #endif
13
14 #include "wx/notebook.h"
15
16 #if wxUSE_NOTEBOOK
17
18 #include "wx/panel.h"
19 #include "wx/utils.h"
20 #include "wx/imaglist.h"
21 #include "wx/intl.h"
22 #include "wx/log.h"
23
24 #include <gdk/gdk.h>
25 #include <gtk/gtk.h>
26 #include "wx/gtk/win_gtk.h"
27 #include <gdk/gdkkeysyms.h>
28
29 // ----------------------------------------------------------------------------
30 // events
31 // ----------------------------------------------------------------------------
32
33 DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
34 DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
35
36 //-----------------------------------------------------------------------------
37 // idle system
38 //-----------------------------------------------------------------------------
39
40 extern void wxapp_install_idle_handler();
41 extern bool g_isIdle;
42
43 //-----------------------------------------------------------------------------
44 // data
45 //-----------------------------------------------------------------------------
46
47 extern bool g_blockEventsOnDrag;
48
49 //-----------------------------------------------------------------------------
50 // debug
51 //-----------------------------------------------------------------------------
52
53 #ifdef __WXDEBUG__
54
55 extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window );
56
57 #endif
58
59 //-----------------------------------------------------------------------------
60 // wxGtkNotebookPage
61 //-----------------------------------------------------------------------------
62
63 class wxGtkNotebookPage: public wxObject
64 {
65 public:
66 wxGtkNotebookPage()
67 {
68 m_text = "";
69 m_image = -1;
70 m_page = (GtkNotebookPage *) NULL;
71 m_client = (wxNotebookPage *) NULL;
72 m_box = (GtkWidget *) NULL;
73 }
74
75 wxString m_text;
76 int m_image;
77 GtkNotebookPage *m_page;
78 GtkLabel *m_label;
79 wxNotebookPage *m_client;
80 GtkWidget *m_box; // in which the label and image are packed
81 };
82
83 //-----------------------------------------------------------------------------
84 // "switch_page"
85 //-----------------------------------------------------------------------------
86
87 static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
88 GtkNotebookPage *WXUNUSED(page),
89 gint page,
90 wxNotebook *notebook )
91 {
92 static bool s_inPageChange = FALSE;
93
94 // are you trying to call SetSelection() from a notebook event handler?
95 // you shouldn't!
96 wxCHECK_RET( !s_inPageChange,
97 _T("gtk_notebook_page_change_callback reentered") );
98
99 s_inPageChange = TRUE;
100 if (g_isIdle)
101 wxapp_install_idle_handler();
102
103 int old = notebook->GetSelection();
104
105 wxNotebookEvent eventChanging( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING,
106 notebook->GetId(), page, old );
107 eventChanging.SetEventObject( notebook );
108
109 if ( (notebook->GetEventHandler()->ProcessEvent(eventChanging)) &&
110 !eventChanging.IsAllowed() )
111 {
112 /* program doesn't allow the page change */
113 gtk_signal_emit_stop_by_name( GTK_OBJECT(notebook->m_widget),
114 "switch_page" );
115 }
116 else // change allowed
117 {
118 // make wxNotebook::GetSelection() return the correct (i.e. consistent
119 // with wxNotebookEvent::GetSelection()) value even though the page is
120 // not really changed in GTK+
121 notebook->m_selection = page;
122
123 wxNotebookEvent eventChanged( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
124 notebook->GetId(), page, old );
125 eventChanged.SetEventObject( notebook );
126 notebook->GetEventHandler()->ProcessEvent( eventChanged );
127 }
128
129 s_inPageChange = FALSE;
130 }
131
132 //-----------------------------------------------------------------------------
133 // "size_allocate"
134 //-----------------------------------------------------------------------------
135
136 static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
137 {
138 if (g_isIdle)
139 wxapp_install_idle_handler();
140
141 if ((win->m_x == alloc->x) &&
142 (win->m_y == alloc->y) &&
143 (win->m_width == alloc->width) &&
144 (win->m_height == alloc->height))
145 {
146 return;
147 }
148
149 win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
150
151 /* GTK 1.2 up to version 1.2.5 is broken so that we have to call allocate
152 here in order to make repositioning after resizing to take effect. */
153 if ((gtk_major_version == 1) &&
154 (gtk_minor_version == 2) &&
155 (gtk_micro_version < 6) &&
156 (win->m_wxwindow) &&
157 (GTK_WIDGET_REALIZED(win->m_wxwindow)))
158 {
159 gtk_widget_size_allocate( win->m_wxwindow, alloc );
160 }
161 }
162
163 //-----------------------------------------------------------------------------
164 // "realize" from m_widget
165 //-----------------------------------------------------------------------------
166
167 static gint
168 gtk_notebook_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win )
169 {
170 if (g_isIdle)
171 wxapp_install_idle_handler();
172
173 /* GTK 1.2 up to version 1.2.5 is broken so that we have to call a queue_resize
174 here in order to make repositioning before showing to take effect. */
175 gtk_widget_queue_resize( win->m_widget );
176
177 return FALSE;
178 }
179
180 //-----------------------------------------------------------------------------
181 // "key_press_event"
182 //-----------------------------------------------------------------------------
183
184 static gint gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNotebook *win )
185 {
186 if (g_isIdle)
187 wxapp_install_idle_handler();
188
189 if (!win->m_hasVMT) return FALSE;
190 if (g_blockEventsOnDrag) return FALSE;
191
192 /* win is a control: tab can be propagated up */
193 if ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab))
194 {
195 wxNode *node = win->m_pages.Nth( win->GetSelection() );
196 if (!node) return FALSE;
197
198 wxGtkNotebookPage *page = (wxGtkNotebookPage*) node->Data();
199
200 wxNavigationKeyEvent event;
201 event.SetEventObject( win );
202 /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
203 event.SetDirection( (gdk_event->keyval == GDK_Tab) );
204 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
205 event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
206 event.SetCurrentFocus( win );
207 if (!page->m_client->GetEventHandler()->ProcessEvent( event ))
208 {
209 page->m_client->SetFocus();
210 }
211
212 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
213 return TRUE;
214 }
215
216 return FALSE;
217 }
218
219 //-----------------------------------------------------------------------------
220 // InsertChild callback for wxNotebook
221 //-----------------------------------------------------------------------------
222
223 static void wxInsertChildInNotebook( wxNotebook* WXUNUSED(parent), wxWindow* WXUNUSED(child) )
224 {
225 /* we don't do anything here but pray */
226 }
227
228 //-----------------------------------------------------------------------------
229 // wxNotebook
230 //-----------------------------------------------------------------------------
231
232 IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl)
233
234 BEGIN_EVENT_TABLE(wxNotebook, wxControl)
235 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
236 END_EVENT_TABLE()
237
238 void wxNotebook::Init()
239 {
240 m_imageList = (wxImageList *) NULL;
241 m_ownsImageList = FALSE;
242 m_pages.DeleteContents( TRUE );
243 m_selection = -1;
244 m_themeEnabled = TRUE;
245 }
246
247 wxNotebook::wxNotebook()
248 {
249 Init();
250 }
251
252 wxNotebook::wxNotebook( wxWindow *parent, wxWindowID id,
253 const wxPoint& pos, const wxSize& size,
254 long style, const wxString& name )
255 {
256 Init();
257 Create( parent, id, pos, size, style, name );
258 }
259
260 wxNotebook::~wxNotebook()
261 {
262 /* don't generate change page events any more */
263 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
264 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this );
265
266 DeleteAllPages();
267 if (m_ownsImageList) delete m_imageList;
268 }
269
270 bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
271 const wxPoint& pos, const wxSize& size,
272 long style, const wxString& name )
273 {
274 m_needParent = TRUE;
275 m_acceptsFocus = TRUE;
276 m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook;
277
278 if (!PreCreation( parent, pos, size ) ||
279 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
280 {
281 wxFAIL_MSG( wxT("wxNoteBook creation failed") );
282 return FALSE;
283 }
284
285
286 m_widget = gtk_notebook_new();
287
288 #ifdef __WXDEBUG__
289 debug_focus_in( m_widget, wxT("wxNotebook::m_widget"), name );
290 #endif
291
292 gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
293
294 gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page",
295 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer)this );
296
297 m_parent->DoAddChild( this );
298
299 if (m_windowStyle & wxNB_RIGHT)
300 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_RIGHT );
301 if (m_windowStyle & wxNB_LEFT)
302 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_LEFT );
303 if (m_windowStyle & wxNB_BOTTOM)
304 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_BOTTOM );
305
306 gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event",
307 GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this );
308
309 PostCreation();
310
311 SetFont( parent->GetFont() );
312
313 gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
314 GTK_SIGNAL_FUNC(gtk_notebook_realized_callback), (gpointer) this );
315
316 Show( TRUE );
317
318 return TRUE;
319 }
320
321 int wxNotebook::GetSelection() const
322 {
323 wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") );
324
325 if ( m_selection == -1 )
326 {
327 GList *pages = GTK_NOTEBOOK(m_widget)->children;
328
329 if (g_list_length(pages) != 0)
330 {
331 GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);
332
333 gpointer cur = notebook->cur_page;
334 if ( cur != NULL )
335 {
336 wxConstCast(this, wxNotebook)->m_selection =
337 g_list_index( pages, cur );
338 }
339 }
340 }
341
342 return m_selection;
343 }
344
345 int wxNotebook::GetPageCount() const
346 {
347 return (int) g_list_length( GTK_NOTEBOOK(m_widget)->children );
348 }
349
350 int wxNotebook::GetRowCount() const
351 {
352 return 1;
353 }
354
355 wxString wxNotebook::GetPageText( int page ) const
356 {
357 wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid notebook") );
358
359 wxGtkNotebookPage* nb_page = GetNotebookPage(page);
360 if (nb_page)
361 return nb_page->m_text;
362 else
363 return wxT("");
364 }
365
366 int wxNotebook::GetPageImage( int page ) const
367 {
368 wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") );
369
370 wxGtkNotebookPage* nb_page = GetNotebookPage(page);
371 if (nb_page)
372 return nb_page->m_image;
373 else
374 return -1;
375 }
376
377 wxGtkNotebookPage* wxNotebook::GetNotebookPage( int page ) const
378 {
379 wxCHECK_MSG( m_widget != NULL, (wxGtkNotebookPage*) NULL, wxT("invalid notebook") );
380
381 wxCHECK_MSG( page < (int)m_pages.GetCount(), (wxGtkNotebookPage*) NULL, wxT("invalid notebook index") );
382
383 wxNode *node = m_pages.Nth( page );
384
385 return (wxGtkNotebookPage *) node->Data();
386 }
387
388 int wxNotebook::SetSelection( int page )
389 {
390 wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") );
391
392 wxCHECK_MSG( page < (int)m_pages.GetCount(), -1, wxT("invalid notebook index") );
393
394 int selOld = GetSelection();
395
396 // cache the selection
397 m_selection = page;
398 gtk_notebook_set_page( GTK_NOTEBOOK(m_widget), page );
399
400 wxGtkNotebookPage* g_page = GetNotebookPage( page );
401 if (g_page->m_client)
402 g_page->m_client->SetFocus();
403
404 return selOld;
405 }
406
407 void wxNotebook::AdvanceSelection( bool forward )
408 {
409 wxCHECK_RET( m_widget != NULL, wxT("invalid notebook") );
410
411 int max = GetPageCount();
412 if ( !max )
413 {
414 // nothing to do with empty notebook
415 return;
416 }
417
418 int sel = GetSelection();
419
420 if (forward)
421 SetSelection( sel == max - 1 ? 0 : sel + 1 );
422 else
423 SetSelection( sel == 0 ? max - 1 : sel - 1 );
424 }
425
426 void wxNotebook::SetImageList( wxImageList* imageList )
427 {
428 if (m_ownsImageList) delete m_imageList;
429 m_imageList = imageList;
430 m_ownsImageList = FALSE;
431 }
432
433 void wxNotebook::AssignImageList( wxImageList* imageList )
434 {
435 SetImageList(imageList);
436 m_ownsImageList = TRUE;
437 }
438
439 bool wxNotebook::SetPageText( int page, const wxString &text )
440 {
441 wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid notebook") );
442
443 wxGtkNotebookPage* nb_page = GetNotebookPage(page);
444
445 wxCHECK_MSG( nb_page, FALSE, wxT("SetPageText: invalid page index") );
446
447 nb_page->m_text = text;
448
449 gtk_label_set( nb_page->m_label, nb_page->m_text.mbc_str() );
450
451 return TRUE;
452 }
453
454 bool wxNotebook::SetPageImage( int page, int image )
455 {
456 /* HvdH 28-12-98: now it works, but it's a bit of a kludge */
457
458 wxGtkNotebookPage* nb_page = GetNotebookPage(page);
459
460 if (!nb_page) return FALSE;
461
462 /* Optimization posibility: return immediately if image unchanged.
463 * Not enabled because it may break existing (stupid) code that
464 * manipulates the imagelist to cycle images */
465
466 /* if (image == nb_page->m_image) return TRUE; */
467
468 /* For different cases:
469 1) no image -> no image
470 2) image -> no image
471 3) no image -> image
472 4) image -> image */
473
474 if (image == -1 && nb_page->m_image == -1)
475 return TRUE; /* Case 1): Nothing to do. */
476
477 GtkWidget *pixmapwid = (GtkWidget*) NULL;
478
479 if (nb_page->m_image != -1)
480 {
481 /* Case 2) or 4). There is already an image in the gtkhbox. Let's find it */
482
483 GList *child = gtk_container_children(GTK_CONTAINER(nb_page->m_box));
484 while (child)
485 {
486 if (GTK_IS_PIXMAP(child->data))
487 {
488 pixmapwid = GTK_WIDGET(child->data);
489 break;
490 }
491 child = child->next;
492 }
493
494 /* We should have the pixmap widget now */
495 wxASSERT(pixmapwid != NULL);
496
497 if (image == -1)
498 {
499 /* If there's no new widget, just remove the old from the box */
500 gtk_container_remove(GTK_CONTAINER(nb_page->m_box), pixmapwid);
501 nb_page->m_image = -1;
502
503 return TRUE; /* Case 2) */
504 }
505 }
506
507 /* Only cases 3) and 4) left */
508 wxASSERT( m_imageList != NULL ); /* Just in case */
509
510 /* Construct the new pixmap */
511 const wxBitmap *bmp = m_imageList->GetBitmap(image);
512 GdkPixmap *pixmap = bmp->GetPixmap();
513 GdkBitmap *mask = (GdkBitmap*) NULL;
514 if ( bmp->GetMask() )
515 {
516 mask = bmp->GetMask()->GetBitmap();
517 }
518
519 if (pixmapwid == NULL)
520 {
521 /* Case 3) No old pixmap. Create a new one and prepend it to the hbox */
522 pixmapwid = gtk_pixmap_new (pixmap, mask );
523
524 /* CHECKME: Are these pack flags okay? */
525 gtk_box_pack_start(GTK_BOX(nb_page->m_box), pixmapwid, FALSE, FALSE, 3);
526 gtk_widget_show(pixmapwid);
527 }
528 else
529 {
530 /* Case 4) Simply replace the pixmap */
531 gtk_pixmap_set(GTK_PIXMAP(pixmapwid), pixmap, mask);
532 }
533
534 nb_page->m_image = image;
535
536 return TRUE;
537 }
538
539 void wxNotebook::SetPageSize( const wxSize &WXUNUSED(size) )
540 {
541 wxFAIL_MSG( wxT("wxNotebook::SetPageSize not implemented") );
542 }
543
544 void wxNotebook::SetPadding( const wxSize &WXUNUSED(padding) )
545 {
546 wxFAIL_MSG( wxT("wxNotebook::SetPadding not implemented") );
547 }
548
549 void wxNotebook::SetTabSize(const wxSize& WXUNUSED(sz))
550 {
551 wxFAIL_MSG( wxT("wxNotebook::SetTabSize not implemented") );
552 }
553
554 bool wxNotebook::DeleteAllPages()
555 {
556 wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid notebook") );
557
558 while (m_pages.GetCount() > 0)
559 DeletePage( m_pages.GetCount()-1 );
560
561 return TRUE;
562 }
563
564 bool wxNotebook::DeletePage( int page )
565 {
566 wxGtkNotebookPage* nb_page = GetNotebookPage(page);
567 wxCHECK_MSG( nb_page, FALSE, _T("invalid page in wxNotebook::DeletePage") );
568
569 // GTK sets GtkNotebook.cur_page to NULL before sending the switch page
570 // event so we have to store the selection internally
571 if ( m_selection == -1 )
572 {
573 m_selection = GetSelection();
574 if ( m_selection == (int)m_pages.GetCount() - 1 )
575 {
576 // the index will become invalid after the page is deleted
577 m_selection = -1;
578 }
579 }
580
581 nb_page->m_client->Destroy();
582 m_pages.DeleteObject( nb_page );
583
584 return TRUE;
585 }
586
587 bool wxNotebook::RemovePage( int page )
588 {
589 wxGtkNotebookPage* nb_page = GetNotebookPage(page);
590
591 wxCHECK_MSG( nb_page, FALSE, _T("wxNotebook::RemovePage: invalid page") );
592
593 gtk_widget_ref( nb_page->m_client->m_widget );
594 gtk_widget_unrealize( nb_page->m_client->m_widget );
595 gtk_widget_unparent( nb_page->m_client->m_widget );
596
597 gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page );
598
599 m_pages.DeleteObject( nb_page );
600
601 return TRUE;
602 }
603
604 bool wxNotebook::InsertPage( int position, wxNotebookPage* win, const wxString& text,
605 bool select, int imageId )
606 {
607 wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid notebook") );
608
609 wxCHECK_MSG( win->GetParent() == this, FALSE,
610 wxT("Can't add a page whose parent is not the notebook!") );
611
612 /* don't receive switch page during addition */
613 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
614 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this );
615
616 if (m_themeEnabled)
617 win->SetThemeEnabled(TRUE);
618
619 GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);
620
621 wxGtkNotebookPage *page = new wxGtkNotebookPage();
622
623 if (position < 0)
624 m_pages.Append( page );
625 else
626 m_pages.Insert( m_pages.Nth( position ), page );
627
628 page->m_client = win;
629
630 page->m_box = gtk_hbox_new( FALSE, 0 );
631 gtk_container_border_width( GTK_CONTAINER(page->m_box), 2 );
632
633 gtk_signal_connect( GTK_OBJECT(win->m_widget), "size_allocate",
634 GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)win );
635
636 if (position < 0)
637 gtk_notebook_append_page( notebook, win->m_widget, page->m_box );
638 else
639 gtk_notebook_insert_page( notebook, win->m_widget, page->m_box, position );
640
641 page->m_page = (GtkNotebookPage*) g_list_last(notebook->children)->data;
642
643 /* set the label image */
644 page->m_image = imageId;
645
646 if (imageId != -1)
647 {
648 wxASSERT( m_imageList != NULL );
649
650 const wxBitmap *bmp = m_imageList->GetBitmap(imageId);
651 GdkPixmap *pixmap = bmp->GetPixmap();
652 GdkBitmap *mask = (GdkBitmap*) NULL;
653 if ( bmp->GetMask() )
654 {
655 mask = bmp->GetMask()->GetBitmap();
656 }
657
658 GtkWidget *pixmapwid = gtk_pixmap_new (pixmap, mask );
659
660 gtk_box_pack_start(GTK_BOX(page->m_box), pixmapwid, FALSE, FALSE, 3);
661
662 gtk_widget_show(pixmapwid);
663 }
664
665 /* set the label text */
666 page->m_text = text;
667 if (page->m_text.IsEmpty()) page->m_text = wxT("");
668
669 page->m_label = GTK_LABEL( gtk_label_new(page->m_text.mbc_str()) );
670 gtk_box_pack_end( GTK_BOX(page->m_box), GTK_WIDGET(page->m_label), FALSE, FALSE, 3 );
671
672 /* show the label */
673 gtk_widget_show( GTK_WIDGET(page->m_label) );
674
675 if (select && (m_pages.GetCount() > 1))
676 {
677 if (position < 0)
678 SetSelection( GetPageCount()-1 );
679 else
680 SetSelection( position );
681 }
682
683 gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page",
684 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer)this );
685
686 return TRUE;
687 }
688
689 bool wxNotebook::AddPage(wxNotebookPage* win, const wxString& text,
690 bool select, int imageId)
691 {
692 return InsertPage( -1, win, text, select, imageId );
693 }
694
695 void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
696 {
697 if (event.IsWindowChange())
698 AdvanceSelection( event.GetDirection() );
699 else
700 event.Skip();
701 }
702
703 wxNotebookPage *wxNotebook::GetPage( int page ) const
704 {
705 wxCHECK_MSG( m_widget != NULL, (wxWindow*) NULL, wxT("invalid notebook") );
706
707 wxGtkNotebookPage* nb_page = GetNotebookPage(page);
708 if (!nb_page)
709 return (wxNotebookPage *) NULL;
710 else
711 return nb_page->m_client;
712 }
713
714 #if wxUSE_CONSTRAINTS
715
716 // override these 2 functions to do nothing: everything is done in OnSize
717 void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) )
718 {
719 // don't set the sizes of the pages - their correct size is not yet known
720 wxControl::SetConstraintSizes(FALSE);
721 }
722
723 bool wxNotebook::DoPhase( int WXUNUSED(nPhase) )
724 {
725 return TRUE;
726 }
727
728 #endif
729
730 void wxNotebook::ApplyWidgetStyle()
731 {
732 // TODO, font for labels etc
733
734 SetWidgetStyle();
735 gtk_widget_set_style( m_widget, m_widgetStyle );
736 }
737
738 bool wxNotebook::IsOwnGtkWindow( GdkWindow *window )
739 {
740 return ((m_widget->window == window) ||
741 (GTK_NOTEBOOK(m_widget)->panel == window));
742 }
743
744 //-----------------------------------------------------------------------------
745 // wxNotebookEvent
746 //-----------------------------------------------------------------------------
747
748 IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
749
750 #endif