]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/notebook.cpp
compilation fix
[wxWidgets.git] / src / gtk1 / notebook.cpp
CommitLineData
53b28675
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: notebook.cpp
3// Purpose:
4// Author: Robert Roebling
a81258be 5// Id: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling, Vadim Zeitlin
ff829f3f 7// Licence: wxWindows licence
53b28675
RR
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation "notebook.h"
12#endif
13
14#include "wx/notebook.h"
dcf924a3
RR
15
16#if wxUSE_NOTEBOOK
17
53b28675
RR
18#include "wx/panel.h"
19#include "wx/utils.h"
20#include "wx/imaglist.h"
30dea054 21#include "wx/intl.h"
4bf58c62 22#include "wx/log.h"
83624f79
RR
23
24#include "gdk/gdk.h"
25#include "gtk/gtk.h"
26#include "wx/gtk/win_gtk.h"
b292e2f5
RR
27#include "gdk/gdkkeysyms.h"
28
acfd422a
RR
29//-----------------------------------------------------------------------------
30// idle system
31//-----------------------------------------------------------------------------
32
33extern void wxapp_install_idle_handler();
34extern bool g_isIdle;
35
b292e2f5
RR
36//-----------------------------------------------------------------------------
37// data
38//-----------------------------------------------------------------------------
39
40extern bool g_blockEventsOnDrag;
53b28675 41
2e563988
RR
42//-----------------------------------------------------------------------------
43// debug
44//-----------------------------------------------------------------------------
45
46#ifdef __WXDEBUG__
47
48extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window );
49
50#endif
51
219f895a
RR
52//-----------------------------------------------------------------------------
53// wxNotebookPage
54//-----------------------------------------------------------------------------
55
56class wxNotebookPage: public wxObject
57{
58public:
59 wxNotebookPage()
60 {
219f895a
RR
61 m_text = "";
62 m_image = -1;
c67daf87
UR
63 m_page = (GtkNotebookPage *) NULL;
64 m_client = (wxWindow *) NULL;
24d20a8f 65 m_box = (GtkWidget *) NULL;
ff7b1510 66 }
219f895a 67
219f895a
RR
68 wxString m_text;
69 int m_image;
70 GtkNotebookPage *m_page;
71 GtkLabel *m_label;
72 wxWindow *m_client;
24d20a8f 73 GtkWidget *m_box; // in which the label and image are packed
219f895a
RR
74};
75
ff829f3f 76//-----------------------------------------------------------------------------
5b011451 77// "switch_page"
ff829f3f
VZ
78//-----------------------------------------------------------------------------
79
219f895a
RR
80static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
81 GtkNotebookPage *WXUNUSED(page),
587ce561
RR
82 gint page,
83 wxNotebook *notebook )
ff829f3f 84{
587ce561
RR
85 if (g_isIdle)
86 wxapp_install_idle_handler();
ff829f3f 87
b292e2f5 88 int old = notebook->GetSelection();
ff829f3f 89
587ce561
RR
90 wxNotebookEvent event1( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING,
91 notebook->GetId(), page, old );
92 event1.SetEventObject( notebook );
93
94 if ((notebook->GetEventHandler()->ProcessEvent( event1 )) &&
95 !event1.IsAllowed() )
96 {
97 /* program doesn't allow the page change */
98 gtk_signal_emit_stop_by_name( GTK_OBJECT(notebook->m_widget), "switch_page" );
99 return;
100 }
ef44a621 101
587ce561
RR
102 wxNotebookEvent event2( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
103 notebook->GetId(), page, old );
104 event2.SetEventObject( notebook );
105 notebook->GetEventHandler()->ProcessEvent( event2 );
ff829f3f
VZ
106}
107
5b011451
RR
108//-----------------------------------------------------------------------------
109// "size_allocate"
110//-----------------------------------------------------------------------------
111
33d0b396 112static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
caac5181 113{
587ce561
RR
114 if (g_isIdle)
115 wxapp_install_idle_handler();
e208b369 116
a2053b27
RR
117 if ((win->m_x == alloc->x) &&
118 (win->m_y == alloc->y) &&
119 (win->m_width == alloc->width) &&
120 (win->m_height == alloc->height))
b292e2f5 121 {
58dea4b0 122 return;
b292e2f5 123 }
2b07d713 124
b292e2f5 125 win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
f861258f 126
b292e2f5
RR
127 if (win->GetAutoLayout()) win->Layout();
128}
129
6ca41e57
RR
130//-----------------------------------------------------------------------------
131// InsertChild callback for wxNotebook
132//-----------------------------------------------------------------------------
133
587ce561 134static void wxInsertChildInNotebook( wxNotebook* WXUNUSED(parent), wxWindow* WXUNUSED(child) )
6ca41e57 135{
587ce561 136 /* we don't do anything here but pray */
6ca41e57
RR
137}
138
53b28675
RR
139//-----------------------------------------------------------------------------
140// wxNotebook
141//-----------------------------------------------------------------------------
142
53b28675
RR
143IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl)
144
b98d804b
RR
145BEGIN_EVENT_TABLE(wxNotebook, wxControl)
146 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
147END_EVENT_TABLE()
f861258f 148
ff829f3f 149void wxNotebook::Init()
53b28675 150{
b292e2f5
RR
151 m_imageList = (wxImageList *) NULL;
152 m_pages.DeleteContents( TRUE );
29f538ce 153 m_lastSelection = -1;
ff829f3f
VZ
154}
155
156wxNotebook::wxNotebook()
157{
b292e2f5 158 Init();
ff7b1510 159}
53b28675 160
debe6624 161wxNotebook::wxNotebook( wxWindow *parent, wxWindowID id,
53b28675 162 const wxPoint& pos, const wxSize& size,
debe6624 163 long style, const wxString& name )
53b28675 164{
b292e2f5
RR
165 Init();
166 Create( parent, id, pos, size, style, name );
ff7b1510 167}
53b28675 168
ff829f3f 169wxNotebook::~wxNotebook()
53b28675 170{
587ce561
RR
171 /* don't generate change page events any more */
172 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
173 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this );
ff829f3f 174
b292e2f5 175 DeleteAllPages();
ff7b1510 176}
53b28675 177
debe6624 178bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
53b28675 179 const wxPoint& pos, const wxSize& size,
debe6624 180 long style, const wxString& name )
53b28675 181{
b292e2f5
RR
182 m_needParent = TRUE;
183 m_acceptsFocus = TRUE;
184 m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook;
185
4dcaf11a
RR
186 if (!PreCreation( parent, pos, size ) ||
187 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
188 {
223d09f6 189 wxFAIL_MSG( wxT("wxNoteBook creation failed") );
4dcaf11a
RR
190 return FALSE;
191 }
192
ff829f3f 193
b292e2f5 194 m_widget = gtk_notebook_new();
53b28675 195
2e563988 196#ifdef __WXDEBUG__
223d09f6 197 debug_focus_in( m_widget, wxT("wxNotebook::m_widget"), name );
2e563988
RR
198#endif
199
b292e2f5 200 gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
caac5181 201
587ce561
RR
202 gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page",
203 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer)this );
ff829f3f 204
f03fc89f 205 m_parent->DoAddChild( this );
ef44a621 206
a3a7f879
RS
207 if(m_windowStyle & wxNB_RIGHT)
208 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_RIGHT );
209 if(m_windowStyle & wxNB_LEFT)
210 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_LEFT );
211 if(m_windowStyle & wxNB_BOTTOM)
212 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_BOTTOM );
213
b292e2f5 214 PostCreation();
ff829f3f 215
b292e2f5
RR
216 Show( TRUE );
217
218 return TRUE;
ff7b1510 219}
53b28675 220
ed58dbea
RR
221void wxNotebook::SetFocus()
222{
223 if (m_pages.GetCount() == 0) return;
224
225 wxNode *node = m_pages.Nth( GetSelection() );
226
227 if (!node) return;
228
229 wxNotebookPage *page = (wxNotebookPage*) node->Data();
230
231 page->m_client->SetFocus();
232}
233
ff829f3f 234int wxNotebook::GetSelection() const
53b28675 235{
223d09f6 236 wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") );
53b28675 237
587ce561 238 GList *pages = GTK_NOTEBOOK(m_widget)->children;
ef44a621 239
587ce561 240 if (g_list_length(pages) == 0) return -1;
53b28675 241
587ce561
RR
242 GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);
243
29f538ce 244 if (notebook->cur_page == NULL) return m_lastSelection;
587ce561 245
29f538ce 246 return g_list_index( pages, (gpointer)(notebook->cur_page) );
ff7b1510 247}
53b28675 248
ff829f3f 249int wxNotebook::GetPageCount() const
53b28675 250{
587ce561 251 return (int) g_list_length( GTK_NOTEBOOK(m_widget)->children );
ff7b1510 252}
53b28675 253
ff829f3f 254int wxNotebook::GetRowCount() const
53b28675 255{
b292e2f5 256 return 1;
ff7b1510 257}
53b28675 258
ff829f3f 259wxString wxNotebook::GetPageText( int page ) const
53b28675 260{
223d09f6 261 wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid notebook") );
ef44a621 262
b292e2f5
RR
263 wxNotebookPage* nb_page = GetNotebookPage(page);
264 if (nb_page)
265 return nb_page->m_text;
266 else
223d09f6 267 return wxT("");
ff7b1510 268}
53b28675 269
ff829f3f 270int wxNotebook::GetPageImage( int page ) const
53b28675 271{
223d09f6 272 wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") );
a81258be 273
b292e2f5
RR
274 wxNotebookPage* nb_page = GetNotebookPage(page);
275 if (nb_page)
276 return nb_page->m_image;
277 else
587ce561 278 return -1;
ff7b1510 279}
53b28675 280
587ce561 281wxNotebookPage* wxNotebook::GetNotebookPage( int page ) const
53b28675 282{
223d09f6 283 wxCHECK_MSG( m_widget != NULL, (wxNotebookPage*) NULL, wxT("invalid notebook") );
ff829f3f 284
223d09f6 285 wxCHECK_MSG( page < (int)m_pages.GetCount(), (wxNotebookPage*) NULL, wxT("invalid notebook index") );
587ce561
RR
286
287 wxNode *node = m_pages.Nth( page );
288
289 return (wxNotebookPage *) node->Data();
ff7b1510 290}
53b28675 291
ff829f3f 292int wxNotebook::SetSelection( int page )
53b28675 293{
223d09f6 294 wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") );
a81258be 295
223d09f6 296 wxCHECK_MSG( page < (int)m_pages.GetCount(), -1, wxT("invalid notebook index") );
ff829f3f 297
587ce561
RR
298 int selOld = GetSelection();
299
300 gtk_notebook_set_page( GTK_NOTEBOOK(m_widget), page );
ff829f3f 301
3eb78d7e 302 return selOld;
ff7b1510 303}
53b28675 304
587ce561 305void wxNotebook::AdvanceSelection( bool forward )
ff829f3f 306{
223d09f6 307 wxCHECK_RET( m_widget != NULL, wxT("invalid notebook") );
a81258be 308
3eb78d7e
RR
309 int sel = GetSelection();
310 int max = GetPageCount();
ff829f3f 311
587ce561 312 if (forward)
3eb78d7e
RR
313 SetSelection( sel == max ? 0 : sel + 1 );
314 else
b98d804b 315 SetSelection( sel == 0 ? max-1 : sel - 1 );
ff829f3f
VZ
316}
317
53b28675
RR
318void wxNotebook::SetImageList( wxImageList* imageList )
319{
3eb78d7e 320 m_imageList = imageList;
ff7b1510 321}
53b28675 322
ff829f3f 323bool wxNotebook::SetPageText( int page, const wxString &text )
53b28675 324{
223d09f6 325 wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid notebook") );
a81258be 326
3eb78d7e 327 wxNotebookPage* nb_page = GetNotebookPage(page);
ef44a621 328
223d09f6 329 wxCHECK_MSG( nb_page, FALSE, wxT("SetPageText: invalid page index") );
ff829f3f 330
3eb78d7e 331 nb_page->m_text = text;
ff829f3f 332
587ce561 333 gtk_label_set( nb_page->m_label, nb_page->m_text.mbc_str() );
3eb78d7e
RR
334
335 return TRUE;
ff7b1510 336}
53b28675 337
debe6624 338bool wxNotebook::SetPageImage( int page, int image )
53b28675 339{
3eb78d7e 340 /* HvdH 28-12-98: now it works, but it's a bit of a kludge */
f861258f 341
3eb78d7e 342 wxNotebookPage* nb_page = GetNotebookPage(page);
ef44a621 343
3eb78d7e 344 if (!nb_page) return FALSE;
f861258f 345
3eb78d7e
RR
346 /* Optimization posibility: return immediately if image unchanged.
347 * Not enabled because it may break existing (stupid) code that
348 * manipulates the imagelist to cycle images */
f861258f 349
3eb78d7e 350 /* if (image == nb_page->m_image) return TRUE; */
f861258f
VZ
351
352 /* For different cases:
3eb78d7e
RR
353 1) no image -> no image
354 2) image -> no image
355 3) no image -> image
356 4) image -> image */
f861258f 357
3eb78d7e
RR
358 if (image == -1 && nb_page->m_image == -1)
359 return TRUE; /* Case 1): Nothing to do. */
f861258f 360
bbe0af5b 361 GtkWidget *pixmapwid = (GtkWidget*) NULL;
f861258f
VZ
362
363 if (nb_page->m_image != -1)
3eb78d7e
RR
364 {
365 /* Case 2) or 4). There is already an image in the gtkhbox. Let's find it */
f861258f 366
3eb78d7e
RR
367 GList *child = gtk_container_children(GTK_CONTAINER(nb_page->m_box));
368 while (child)
369 {
f861258f 370 if (GTK_IS_PIXMAP(child->data))
3eb78d7e
RR
371 {
372 pixmapwid = GTK_WIDGET(child->data);
373 break;
374 }
375 child = child->next;
376 }
f861258f 377
3eb78d7e 378 /* We should have the pixmap widget now */
f861258f
VZ
379 wxASSERT(pixmapwid != NULL);
380
381 if (image == -1)
3eb78d7e
RR
382 {
383 /* If there's no new widget, just remove the old from the box */
384 gtk_container_remove(GTK_CONTAINER(nb_page->m_box), pixmapwid);
385 nb_page->m_image = -1;
53b28675 386
3eb78d7e
RR
387 return TRUE; /* Case 2) */
388 }
389 }
f861258f 390
3eb78d7e
RR
391 /* Only cases 3) and 4) left */
392 wxASSERT( m_imageList != NULL ); /* Just in case */
f861258f 393
3eb78d7e
RR
394 /* Construct the new pixmap */
395 const wxBitmap *bmp = m_imageList->GetBitmap(image);
396 GdkPixmap *pixmap = bmp->GetPixmap();
397 GdkBitmap *mask = (GdkBitmap*) NULL;
f861258f 398 if ( bmp->GetMask() )
3eb78d7e
RR
399 {
400 mask = bmp->GetMask()->GetBitmap();
401 }
f861258f
VZ
402
403 if (pixmapwid == NULL)
3eb78d7e
RR
404 {
405 /* Case 3) No old pixmap. Create a new one and prepend it to the hbox */
406 pixmapwid = gtk_pixmap_new (pixmap, mask );
f861258f 407
3eb78d7e
RR
408 /* CHECKME: Are these pack flags okay? */
409 gtk_box_pack_start(GTK_BOX(nb_page->m_box), pixmapwid, FALSE, FALSE, 3);
410 gtk_widget_show(pixmapwid);
411 }
f861258f 412 else
3eb78d7e
RR
413 {
414 /* Case 4) Simply replace the pixmap */
415 gtk_pixmap_set(GTK_PIXMAP(pixmapwid), pixmap, mask);
416 }
f861258f 417
3eb78d7e 418 nb_page->m_image = image;
53b28675 419
3eb78d7e 420 return TRUE;
ff7b1510 421}
53b28675
RR
422
423void wxNotebook::SetPageSize( const wxSize &WXUNUSED(size) )
424{
223d09f6 425 wxFAIL_MSG( wxT("wxNotebook::SetPageSize not implemented") );
ff7b1510 426}
53b28675
RR
427
428void wxNotebook::SetPadding( const wxSize &WXUNUSED(padding) )
429{
223d09f6 430 wxFAIL_MSG( wxT("wxNotebook::SetPadding not implemented") );
ff7b1510 431}
53b28675 432
74e3313b 433void wxNotebook::SetTabSize(const wxSize& WXUNUSED(sz))
ca8b28f2 434{
223d09f6 435 wxFAIL_MSG( wxT("wxNotebook::SetTabSize not implemented") );
ca8b28f2
JS
436}
437
ff829f3f 438bool wxNotebook::DeleteAllPages()
53b28675 439{
223d09f6 440 wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid notebook") );
a81258be 441
587ce561
RR
442 while (m_pages.GetCount() > 0)
443 DeletePage( m_pages.GetCount()-1 );
ff829f3f 444
3eb78d7e 445 return TRUE;
ff7b1510 446}
53b28675 447
ff829f3f 448bool wxNotebook::DeletePage( int page )
53b28675 449{
3eb78d7e
RR
450 wxNotebookPage* nb_page = GetNotebookPage(page);
451 if (!nb_page) return FALSE;
53b28675 452
29f538ce
RR
453 /* GTK sets GtkNotebook.cur_page to NULL before sending
454 the switvh page event */
455 m_lastSelection = GetSelection();
456
587ce561 457 nb_page->m_client->Destroy();
3eb78d7e 458 m_pages.DeleteObject( nb_page );
29f538ce
RR
459
460 m_lastSelection = -1;
fed46e72 461
3eb78d7e 462 return TRUE;
fed46e72
RR
463}
464
465bool wxNotebook::RemovePage( int page )
466{
3eb78d7e 467 wxNotebookPage* nb_page = GetNotebookPage(page);
587ce561 468
3eb78d7e 469 if (!nb_page) return FALSE;
fed46e72 470
587ce561 471 gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page );
ff829f3f 472
3eb78d7e 473 m_pages.DeleteObject( nb_page );
ff829f3f 474
3eb78d7e 475 return TRUE;
ff7b1510 476}
53b28675 477
587ce561
RR
478bool wxNotebook::InsertPage( int position, wxWindow* win, const wxString& text,
479 bool select, int imageId )
53b28675 480{
223d09f6 481 wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid notebook") );
a81258be 482
587ce561 483 wxCHECK_MSG( win->GetParent() == this, FALSE,
223d09f6 484 wxT("Can't add a page whose parent is not the notebook!") );
8aadf227 485
587ce561
RR
486 /* don't receive switch page during addition */
487 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
488 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this );
489
490 GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);
53b28675 491
587ce561
RR
492 wxNotebookPage *page = new wxNotebookPage();
493
494 if (position < 0)
495 m_pages.Append( page );
496 else
497 m_pages.Insert( m_pages.Nth( position ), page );
498
499 page->m_client = win;
8aadf227 500
587ce561
RR
501 page->m_box = gtk_hbox_new( FALSE, 0 );
502 gtk_container_border_width( GTK_CONTAINER(page->m_box), 2 );
503
d1af991f
RR
504 gtk_signal_connect( GTK_OBJECT(win->m_widget), "size_allocate",
505 GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)win );
506
587ce561
RR
507 if (position < 0)
508 gtk_notebook_append_page( notebook, win->m_widget, page->m_box );
509 else
510 gtk_notebook_insert_page( notebook, win->m_widget, page->m_box, position );
511
c693edf3 512 page->m_page = (GtkNotebookPage*) g_list_last(notebook->children)->data;
ef44a621 513
587ce561
RR
514 /* set the label image */
515 page->m_image = imageId;
516
3eb78d7e 517 if (imageId != -1)
e4a81a2e 518 {
3eb78d7e
RR
519 wxASSERT( m_imageList != NULL );
520
521 const wxBitmap *bmp = m_imageList->GetBitmap(imageId);
522 GdkPixmap *pixmap = bmp->GetPixmap();
523 GdkBitmap *mask = (GdkBitmap*) NULL;
524 if ( bmp->GetMask() )
525 {
526 mask = bmp->GetMask()->GetBitmap();
527 }
e4a81a2e 528
3eb78d7e 529 GtkWidget *pixmapwid = gtk_pixmap_new (pixmap, mask );
24d20a8f 530
3eb78d7e 531 gtk_box_pack_start(GTK_BOX(page->m_box), pixmapwid, FALSE, FALSE, 3);
24d20a8f 532
3eb78d7e
RR
533 gtk_widget_show(pixmapwid);
534 }
24d20a8f 535
587ce561 536 /* set the label text */
3eb78d7e 537 page->m_text = text;
223d09f6 538 if (page->m_text.IsEmpty()) page->m_text = wxT("");
587ce561
RR
539
540 page->m_label = GTK_LABEL( gtk_label_new(page->m_text.mbc_str()) );
541 gtk_box_pack_end( GTK_BOX(page->m_box), GTK_WIDGET(page->m_label), FALSE, FALSE, 3 );
741fd203 542
587ce561
RR
543 /* show the label */
544 gtk_widget_show( GTK_WIDGET(page->m_label) );
741fd203 545
587ce561
RR
546 if (select && (m_pages.GetCount() > 1))
547 {
548 if (position < 0)
549 SetSelection( GetPageCount()-1 );
550 else
551 SetSelection( position );
552 }
741fd203 553
587ce561
RR
554 gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page",
555 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer)this );
ff829f3f 556
3eb78d7e 557 return TRUE;
ff7b1510 558}
53b28675 559
587ce561
RR
560bool wxNotebook::AddPage(wxWindow* win, const wxString& text,
561 bool select, int imageId)
562{
563 return InsertPage( -1, win, text, select, imageId );
564}
565
b98d804b
RR
566void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
567{
f861258f 568 if (event.IsWindowChange())
b98d804b 569 AdvanceSelection( event.GetDirection() );
f861258f 570 else
b98d804b
RR
571 event.Skip();
572}
573
ff829f3f 574wxWindow *wxNotebook::GetPage( int page ) const
53b28675 575{
223d09f6 576 wxCHECK_MSG( m_widget != NULL, (wxWindow*) NULL, wxT("invalid notebook") );
a81258be 577
b292e2f5
RR
578 wxNotebookPage* nb_page = GetNotebookPage(page);
579 if (!nb_page)
580 return (wxWindow *) NULL;
581 else
582 return nb_page->m_client;
ff7b1510 583}
53b28675 584
5a8c929e 585// override these 2 functions to do nothing: everything is done in OnSize
e3e65dac 586void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) )
5a8c929e 587{
b292e2f5
RR
588 // don't set the sizes of the pages - their correct size is not yet known
589 wxControl::SetConstraintSizes(FALSE);
5a8c929e
VZ
590}
591
e3e65dac 592bool wxNotebook::DoPhase( int WXUNUSED(nPhase) )
5a8c929e 593{
b292e2f5 594 return TRUE;
5a8c929e
VZ
595}
596
58614078 597void wxNotebook::ApplyWidgetStyle()
a81258be 598{
b292e2f5
RR
599 SetWidgetStyle();
600 gtk_widget_set_style( m_widget, m_widgetStyle );
a81258be
RR
601}
602
58d1c1ae
RR
603bool wxNotebook::IsOwnGtkWindow( GdkWindow *window )
604{
605 return ((m_widget->window == window) ||
606 (GTK_NOTEBOOK(m_widget)->panel == window));
607}
608
53b28675 609//-----------------------------------------------------------------------------
ff829f3f 610// wxNotebookEvent
53b28675
RR
611//-----------------------------------------------------------------------------
612
92976ab6 613IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
5b011451 614
a3a7f879 615#endif