]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/notebook.cpp
Corrected memory.cpp checkpoint bug; added Tex2RTF
[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"
15#include "wx/panel.h"
16#include "wx/utils.h"
17#include "wx/imaglist.h"
30dea054 18#include "wx/intl.h"
4bf58c62 19#include "wx/log.h"
b292e2f5
RR
20#include "gdk/gdkkeysyms.h"
21
22//-----------------------------------------------------------------------------
23// data
24//-----------------------------------------------------------------------------
25
26extern bool g_blockEventsOnDrag;
53b28675 27
219f895a
RR
28//-----------------------------------------------------------------------------
29// wxNotebookPage
30//-----------------------------------------------------------------------------
31
32class wxNotebookPage: public wxObject
33{
34public:
35 wxNotebookPage()
36 {
37 m_id = -1;
38 m_text = "";
39 m_image = -1;
c67daf87
UR
40 m_page = (GtkNotebookPage *) NULL;
41 m_client = (wxWindow *) NULL;
42 m_parent = (GtkNotebook *) NULL;
24d20a8f 43 m_box = (GtkWidget *) NULL;
ef44a621 44 m_added = FALSE;
ff7b1510 45 }
219f895a 46
3eb78d7e
RR
47 /*
48 mark page as "added' to the notebook, return FALSE if the page was
49 already added
50 */
51
ef44a621
VZ
52 bool Add()
53 {
54 if ( WasAdded() )
55 return FALSE;
56
57 m_added = TRUE;
58 return TRUE;
59 }
60
61 bool WasAdded() const { return m_added; }
62
219f895a
RR
63 int m_id;
64 wxString m_text;
65 int m_image;
66 GtkNotebookPage *m_page;
67 GtkLabel *m_label;
68 wxWindow *m_client;
69 GtkNotebook *m_parent;
24d20a8f 70 GtkWidget *m_box; // in which the label and image are packed
ef44a621
VZ
71
72private:
73 bool m_added;
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),
ff829f3f
VZ
82 gint nPage,
83 gpointer data)
84{
b292e2f5 85 wxNotebook *notebook = (wxNotebook *)data;
ff829f3f 86
b292e2f5 87 int old = notebook->GetSelection();
ff829f3f 88
b292e2f5 89 // TODO: emulate PAGE_CHANGING event
ef44a621 90
b292e2f5
RR
91 wxNotebookEvent event( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
92 notebook->GetId(), nPage, old );
93 event.SetEventObject( notebook );
94 notebook->GetEventHandler()->ProcessEvent( event );
ff829f3f
VZ
95}
96
5b011451
RR
97//-----------------------------------------------------------------------------
98// "size_allocate"
99//-----------------------------------------------------------------------------
100
33d0b396 101static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
caac5181 102{
b292e2f5
RR
103 if ((win->m_x == alloc->x) &&
104 (win->m_y == alloc->y) &&
105 (win->m_width == alloc->width) &&
106 (win->m_height == alloc->height))
107 {
108 return;
109 }
ef44a621 110
b292e2f5 111 win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
435fe83e 112
b292e2f5
RR
113 if (win->GetAutoLayout()) win->Layout();
114}
115
116//-----------------------------------------------------------------------------
117// "key_press_event"
118//-----------------------------------------------------------------------------
119
120static gint
121gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNotebook *notebook )
122{
123 if (g_blockEventsOnDrag) return FALSE;
124
125 if (!notebook->HasVMT()) return FALSE;
126
127 if (gdk_event->keyval != GDK_Down) return FALSE;
128
129 if (notebook != notebook->FindFocus()) return FALSE;
130
131 if (notebook->m_pages.GetCount() == 0) return FALSE;
132
133 wxNode *node = notebook->m_pages.Nth( notebook->GetSelection() );
134
135 if (!node) return FALSE;
136
137 wxNotebookPage *page = (wxNotebookPage*) node->Data();
138
139 // don't let others the key event
140 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
141
142 page->m_client->SetFocus();
143
144 return TRUE;
ff7b1510 145}
caac5181 146
6ca41e57
RR
147//-----------------------------------------------------------------------------
148// InsertChild callback for wxNotebook
149//-----------------------------------------------------------------------------
150
151static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* child )
152{
b292e2f5 153 wxNotebookPage *page = new wxNotebookPage();
6ca41e57 154
b292e2f5 155 page->m_id = parent->GetPageCount();
6ca41e57 156
b292e2f5
RR
157 page->m_box = gtk_hbox_new (FALSE, 0);
158 gtk_container_border_width(GTK_CONTAINER(page->m_box), 2);
6ca41e57 159
b292e2f5 160 GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget);
ef44a621 161
b292e2f5
RR
162 page->m_client = child;
163 gtk_notebook_append_page( notebook, child->m_widget, page->m_box );
6ca41e57 164
b292e2f5 165 page->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data);
6ca41e57 166
b292e2f5 167 page->m_parent = notebook;
6ca41e57 168
b292e2f5
RR
169 gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate",
170 GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child );
6ca41e57 171
b292e2f5 172 wxASSERT_MSG( page->m_page, "Notebook page creation error" );
6ca41e57 173
b292e2f5 174 parent->m_pages.Append( page );
6ca41e57
RR
175}
176
53b28675
RR
177//-----------------------------------------------------------------------------
178// wxNotebook
179//-----------------------------------------------------------------------------
180
53b28675
RR
181IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl)
182
ff829f3f 183void wxNotebook::Init()
53b28675 184{
b292e2f5
RR
185 m_imageList = (wxImageList *) NULL;
186 m_pages.DeleteContents( TRUE );
187 m_idHandler = 0;
ff829f3f
VZ
188}
189
190wxNotebook::wxNotebook()
191{
b292e2f5 192 Init();
ff7b1510 193}
53b28675 194
debe6624 195wxNotebook::wxNotebook( wxWindow *parent, wxWindowID id,
53b28675 196 const wxPoint& pos, const wxSize& size,
debe6624 197 long style, const wxString& name )
53b28675 198{
b292e2f5
RR
199 Init();
200 Create( parent, id, pos, size, style, name );
ff7b1510 201}
53b28675 202
ff829f3f 203wxNotebook::~wxNotebook()
53b28675 204{
b292e2f5
RR
205 // don't generate change page events any more
206 if (m_idHandler != 0)
207 gtk_signal_disconnect(GTK_OBJECT(m_widget), m_idHandler);
ff829f3f 208
b292e2f5 209 DeleteAllPages();
ff7b1510 210}
53b28675 211
debe6624 212bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
53b28675 213 const wxPoint& pos, const wxSize& size,
debe6624 214 long style, const wxString& name )
53b28675 215{
b292e2f5
RR
216 m_needParent = TRUE;
217 m_acceptsFocus = TRUE;
218 m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook;
219
220 PreCreation( parent, id, pos, size, style, name );
ff829f3f 221
b292e2f5 222 m_widget = gtk_notebook_new();
53b28675 223
b292e2f5
RR
224#ifdef __WXDEBUG__
225 debug_focus_in( m_widget, "wxNotebook::m_widget", name );
226#endif
caac5181 227
b292e2f5 228 gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
caac5181 229
b292e2f5 230 m_idHandler = gtk_signal_connect (
ff829f3f
VZ
231 GTK_OBJECT(m_widget), "switch_page",
232 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback),
ba4e3652 233 (gpointer)this );
ff829f3f 234
b292e2f5 235 m_parent->AddChild( this );
6ca41e57 236
b292e2f5 237 (m_parent->m_insertCallback)( m_parent, this );
ef44a621 238
b292e2f5
RR
239 gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event",
240 GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this );
ff829f3f 241
b292e2f5 242 PostCreation();
ff829f3f 243
b292e2f5
RR
244 Show( TRUE );
245
246 return TRUE;
ff7b1510 247}
53b28675 248
ff829f3f 249int wxNotebook::GetSelection() const
53b28675 250{
b292e2f5 251 wxCHECK_MSG( m_widget != NULL, -1, "invalid notebook" );
53b28675 252
b292e2f5 253 if (m_pages.Number() == 0) return -1;
ff829f3f 254
b292e2f5
RR
255 GtkNotebookPage *g_page = GTK_NOTEBOOK(m_widget)->cur_page;
256 if (!g_page) return -1;
53b28675 257
b292e2f5 258 wxNotebookPage *page = (wxNotebookPage *) NULL;
ef44a621 259
b292e2f5
RR
260 wxNode *node = m_pages.First();
261 while (node)
ba4e3652 262 {
b292e2f5
RR
263 page = (wxNotebookPage*)node->Data();
264
265 if ((page->m_page == g_page) || (page->m_page == (GtkNotebookPage*)NULL))
266 {
267 // page->m_page is NULL directly after gtk_notebook_append. gtk emits
268 // "switch_page" then and we ask for GetSelection() in the handler for
269 // "switch_page". otherwise m_page should never be NULL. all this
270 // might also be wrong.
271 break;
272 }
273 node = node->Next();
ba4e3652 274 }
53b28675 275
b292e2f5 276 wxCHECK_MSG( node != NULL, -1, "wxNotebook: no selection?" );
ff829f3f 277
b292e2f5 278 return page->m_id;
ff7b1510 279}
53b28675 280
ff829f3f 281int wxNotebook::GetPageCount() const
53b28675 282{
b292e2f5
RR
283 // count only the pages which were already added to the notebook for MSW
284 // compatibility (and, in fact, this behaviour makes more sense anyhow
285 // because only the added pages are shown)
286
287 int n = 0;
288 for ( wxNode *node = m_pages.First(); node; node = node->Next() )
289 {
290 wxNotebookPage *page = (wxNotebookPage*)node->Data();
291
292 if (page->WasAdded()) n++;
293 }
ef44a621 294
b292e2f5 295 return n;
ff7b1510 296}
53b28675 297
ff829f3f 298int wxNotebook::GetRowCount() const
53b28675 299{
b292e2f5 300 return 1;
ff7b1510 301}
53b28675 302
ff829f3f 303wxString wxNotebook::GetPageText( int page ) const
53b28675 304{
b292e2f5 305 wxCHECK_MSG( m_widget != NULL, "", "invalid notebook" );
ef44a621 306
b292e2f5
RR
307 wxNotebookPage* nb_page = GetNotebookPage(page);
308 if (nb_page)
309 return nb_page->m_text;
310 else
311 return "";
ff7b1510 312}
53b28675 313
ff829f3f 314int wxNotebook::GetPageImage( int page ) const
53b28675 315{
b292e2f5 316 wxCHECK_MSG( m_widget != NULL, 0, "invalid notebook" );
a81258be 317
b292e2f5
RR
318 wxNotebookPage* nb_page = GetNotebookPage(page);
319 if (nb_page)
320 return nb_page->m_image;
321 else
322 return 0;
ff7b1510 323}
53b28675 324
8aadf227 325wxNotebookPage* wxNotebook::GetNotebookPage(int page) const
53b28675 326{
b292e2f5 327 wxCHECK_MSG( m_widget != NULL, (wxNotebookPage*)NULL, "invalid notebook" );
a81258be 328
b292e2f5 329 wxNotebookPage *nb_page = (wxNotebookPage *) NULL;
53b28675 330
b292e2f5
RR
331 wxNode *node = m_pages.First();
332 while (node)
333 {
334 nb_page = (wxNotebookPage*)node->Data();
335 if (nb_page->m_id == page)
336 return nb_page;
337 node = node->Next();
338 }
ff829f3f 339
b292e2f5 340 wxFAIL_MSG( "Notebook page not found!" );
ff829f3f 341
b292e2f5 342 return (wxNotebookPage *) NULL;
ff7b1510 343}
53b28675 344
ff829f3f 345int wxNotebook::SetSelection( int page )
53b28675 346{
3eb78d7e 347 wxCHECK_MSG( m_widget != NULL, -1, "invalid notebook" );
a81258be 348
3eb78d7e
RR
349 int selOld = GetSelection();
350 wxNotebookPage* nb_page = GetNotebookPage(page);
ef44a621 351
3eb78d7e 352 if (!nb_page) return -1;
ff829f3f 353
3eb78d7e
RR
354 int page_num = 0;
355 GList *child = GTK_NOTEBOOK(m_widget)->children;
356 while (child)
357 {
358 if (nb_page->m_page == (GtkNotebookPage*)child->data) break;
359 page_num++;
360 child = child->next;
361 }
ff829f3f 362
3eb78d7e 363 if (!child) return -1;
ff829f3f 364
3eb78d7e 365 gtk_notebook_set_page( GTK_NOTEBOOK(m_widget), page_num );
ff829f3f 366
3eb78d7e 367 return selOld;
ff7b1510 368}
53b28675 369
5b011451 370void wxNotebook::AdvanceSelection( bool bForward )
ff829f3f 371{
3eb78d7e 372 wxCHECK_RET( m_widget != NULL, "invalid notebook" );
a81258be 373
3eb78d7e
RR
374 int sel = GetSelection();
375 int max = GetPageCount();
ff829f3f 376
3eb78d7e
RR
377 if (bForward)
378 SetSelection( sel == max ? 0 : sel + 1 );
379 else
380 SetSelection( sel == 0 ? max : sel - 1 );
ff829f3f
VZ
381}
382
53b28675
RR
383void wxNotebook::SetImageList( wxImageList* imageList )
384{
3eb78d7e 385 m_imageList = imageList;
ff7b1510 386}
53b28675 387
ff829f3f 388bool wxNotebook::SetPageText( int page, const wxString &text )
53b28675 389{
3eb78d7e 390 wxCHECK_MSG( m_widget != NULL, FALSE, "invalid notebook" );
a81258be 391
3eb78d7e 392 wxNotebookPage* nb_page = GetNotebookPage(page);
ef44a621 393
3eb78d7e 394 if (!nb_page) return FALSE;
ff829f3f 395
3eb78d7e 396 nb_page->m_text = text;
ff829f3f 397
3eb78d7e
RR
398 if (nb_page->m_text.IsEmpty()) nb_page->m_text = "";
399
400 gtk_label_set(nb_page->m_label, nb_page->m_text);
401
402 return TRUE;
ff7b1510 403}
53b28675 404
debe6624 405bool wxNotebook::SetPageImage( int page, int image )
53b28675 406{
3eb78d7e
RR
407 /* HvdH 28-12-98: now it works, but it's a bit of a kludge */
408
409 wxNotebookPage* nb_page = GetNotebookPage(page);
ef44a621 410
3eb78d7e
RR
411 if (!nb_page) return FALSE;
412
413 /* Optimization posibility: return immediately if image unchanged.
414 * Not enabled because it may break existing (stupid) code that
415 * manipulates the imagelist to cycle images */
416
417 /* if (image == nb_page->m_image) return TRUE; */
418
419 /* For different cases:
420 1) no image -> no image
421 2) image -> no image
422 3) no image -> image
423 4) image -> image */
424
425 if (image == -1 && nb_page->m_image == -1)
426 return TRUE; /* Case 1): Nothing to do. */
427
428 GtkWidget *pixmapwid = NULL;
429
430 if (nb_page->m_image != -1)
431 {
432 /* Case 2) or 4). There is already an image in the gtkhbox. Let's find it */
433
434 GList *child = gtk_container_children(GTK_CONTAINER(nb_page->m_box));
435 while (child)
436 {
437 if (GTK_IS_PIXMAP(child->data))
438 {
439 pixmapwid = GTK_WIDGET(child->data);
440 break;
441 }
442 child = child->next;
443 }
444
445 /* We should have the pixmap widget now */
446 wxASSERT(pixmapwid != NULL);
447
448 if (image == -1)
449 {
450 /* If there's no new widget, just remove the old from the box */
451 gtk_container_remove(GTK_CONTAINER(nb_page->m_box), pixmapwid);
452 nb_page->m_image = -1;
53b28675 453
3eb78d7e
RR
454 return TRUE; /* Case 2) */
455 }
456 }
457
458 /* Only cases 3) and 4) left */
459 wxASSERT( m_imageList != NULL ); /* Just in case */
460
461 /* Construct the new pixmap */
462 const wxBitmap *bmp = m_imageList->GetBitmap(image);
463 GdkPixmap *pixmap = bmp->GetPixmap();
464 GdkBitmap *mask = (GdkBitmap*) NULL;
465 if ( bmp->GetMask() )
466 {
467 mask = bmp->GetMask()->GetBitmap();
468 }
469
470 if (pixmapwid == NULL)
471 {
472 /* Case 3) No old pixmap. Create a new one and prepend it to the hbox */
473 pixmapwid = gtk_pixmap_new (pixmap, mask );
474
475 /* CHECKME: Are these pack flags okay? */
476 gtk_box_pack_start(GTK_BOX(nb_page->m_box), pixmapwid, FALSE, FALSE, 3);
477 gtk_widget_show(pixmapwid);
478 }
479 else
480 {
481 /* Case 4) Simply replace the pixmap */
482 gtk_pixmap_set(GTK_PIXMAP(pixmapwid), pixmap, mask);
483 }
484
485 nb_page->m_image = image;
53b28675 486
3eb78d7e 487 return TRUE;
ff7b1510 488}
53b28675
RR
489
490void wxNotebook::SetPageSize( const wxSize &WXUNUSED(size) )
491{
3eb78d7e 492 wxFAIL_MSG( "wxNotebook::SetPageSize not implemented" );
ff7b1510 493}
53b28675
RR
494
495void wxNotebook::SetPadding( const wxSize &WXUNUSED(padding) )
496{
3eb78d7e 497 wxFAIL_MSG( "wxNotebook::SetPadding not implemented" );
ff7b1510 498}
53b28675 499
ff829f3f 500bool wxNotebook::DeleteAllPages()
53b28675 501{
3eb78d7e 502 wxCHECK_MSG( m_widget != NULL, FALSE, "invalid notebook" );
a81258be 503
3eb78d7e
RR
504 wxNode *page_node = m_pages.First();
505 while (page_node)
506 {
507 wxNotebookPage *page = (wxNotebookPage*)page_node->Data();
ff829f3f 508
3eb78d7e 509 DeletePage( page->m_id );
ff829f3f 510
3eb78d7e
RR
511 page_node = m_pages.First();
512 }
ff829f3f 513
3eb78d7e 514 return TRUE;
ff7b1510 515}
53b28675 516
ff829f3f 517bool wxNotebook::DeletePage( int page )
53b28675 518{
3eb78d7e
RR
519 wxNotebookPage* nb_page = GetNotebookPage(page);
520 if (!nb_page) return FALSE;
53b28675 521
3eb78d7e
RR
522 int page_num = 0;
523 GList *child = GTK_NOTEBOOK(m_widget)->children;
524 while (child)
525 {
526 if (nb_page->m_page == (GtkNotebookPage*)child->data) break;
527 page_num++;
528 child = child->next;
529 }
53010e52 530
3eb78d7e 531 wxCHECK_MSG( child != NULL, FALSE, "illegal notebook index" );
ff829f3f 532
3eb78d7e 533 delete nb_page->m_client;
ff829f3f 534
3eb78d7e 535 m_pages.DeleteObject( nb_page );
fed46e72 536
3eb78d7e 537 return TRUE;
fed46e72
RR
538}
539
540bool wxNotebook::RemovePage( int page )
541{
3eb78d7e
RR
542 wxNotebookPage* nb_page = GetNotebookPage(page);
543 if (!nb_page) return FALSE;
fed46e72 544
3eb78d7e
RR
545 int page_num = 0;
546 GList *child = GTK_NOTEBOOK(m_widget)->children;
547 while (child)
548 {
549 if (nb_page->m_page == (GtkNotebookPage*)child->data) break;
550 page_num++;
551 child = child->next;
552 }
fed46e72 553
3eb78d7e 554 wxCHECK_MSG( child != NULL, FALSE, "illegal notebook index" );
fed46e72 555
3eb78d7e 556 gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page_num );
ff829f3f 557
3eb78d7e 558 m_pages.DeleteObject( nb_page );
ff829f3f 559
3eb78d7e 560 return TRUE;
ff7b1510 561}
53b28675 562
ff829f3f 563bool wxNotebook::AddPage(wxWindow* win, const wxString& text,
b292e2f5 564 bool select, int imageId)
53b28675 565{
3eb78d7e 566 wxCHECK_MSG( m_widget != NULL, FALSE, "invalid notebook" );
a81258be 567
3eb78d7e
RR
568 /* we've created the notebook page in AddChild(). Now we just have to set
569 the caption for the page and set the others parameters. */
8aadf227 570
3eb78d7e 571 wxNotebookPage *page = (wxNotebookPage *) NULL;
53b28675 572
3eb78d7e
RR
573 wxNode *node = m_pages.First();
574 while (node)
575 {
576 page = (wxNotebookPage*)node->Data();
577 if ( page->m_client == win ) break;
578 node = node->Next();
579 }
8aadf227 580
3eb78d7e 581 wxCHECK_MSG( page != NULL, FALSE,
ef44a621
VZ
582 "Can't add a page whose parent is not the notebook!" );
583
3eb78d7e 584 wxCHECK_MSG( page->Add(), FALSE,
ef44a621 585 "Can't add the same page twice to a notebook." );
ff829f3f 586
3eb78d7e 587 if (imageId != -1)
e4a81a2e 588 {
3eb78d7e
RR
589 wxASSERT( m_imageList != NULL );
590
591 const wxBitmap *bmp = m_imageList->GetBitmap(imageId);
592 GdkPixmap *pixmap = bmp->GetPixmap();
593 GdkBitmap *mask = (GdkBitmap*) NULL;
594 if ( bmp->GetMask() )
595 {
596 mask = bmp->GetMask()->GetBitmap();
597 }
e4a81a2e 598
3eb78d7e 599 GtkWidget *pixmapwid = gtk_pixmap_new (pixmap, mask );
24d20a8f 600
3eb78d7e 601 gtk_box_pack_start(GTK_BOX(page->m_box), pixmapwid, FALSE, FALSE, 3);
24d20a8f 602
3eb78d7e
RR
603 gtk_widget_show(pixmapwid);
604 }
24d20a8f 605
3eb78d7e
RR
606 /* then set the attributes */
607 page->m_text = text;
608 if (page->m_text.IsEmpty()) page->m_text = "";
609 page->m_image = imageId;
610 page->m_label = (GtkLabel *)gtk_label_new(page->m_text);
611 gtk_box_pack_end( GTK_BOX(page->m_box), (GtkWidget *)page->m_label, FALSE, FALSE, 3);
741fd203 612
3eb78d7e
RR
613 /* @@@: what does this do? do we still need it?
614 gtk_misc_set_alignment(GTK_MISC(page->m_label), 0.0, 0.5); */
741fd203 615
3eb78d7e 616 gtk_widget_show((GtkWidget *)page->m_label);
741fd203 617
3eb78d7e 618 if (select) SetSelection( GetPageCount()-1 );
ff829f3f 619
3eb78d7e 620 return TRUE;
ff7b1510 621}
53b28675 622
ff829f3f 623wxWindow *wxNotebook::GetPage( int page ) const
53b28675 624{
b292e2f5 625 wxCHECK_MSG( m_widget != NULL, (wxWindow*) NULL, "invalid notebook" );
a81258be 626
b292e2f5
RR
627 wxNotebookPage* nb_page = GetNotebookPage(page);
628 if (!nb_page)
629 return (wxWindow *) NULL;
630 else
631 return nb_page->m_client;
ff7b1510 632}
53b28675 633
5a8c929e 634// override these 2 functions to do nothing: everything is done in OnSize
e3e65dac 635void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) )
5a8c929e 636{
b292e2f5
RR
637 // don't set the sizes of the pages - their correct size is not yet known
638 wxControl::SetConstraintSizes(FALSE);
5a8c929e
VZ
639}
640
e3e65dac 641bool wxNotebook::DoPhase( int WXUNUSED(nPhase) )
5a8c929e 642{
b292e2f5 643 return TRUE;
5a8c929e
VZ
644}
645
58614078 646void wxNotebook::ApplyWidgetStyle()
a81258be 647{
b292e2f5
RR
648 SetWidgetStyle();
649 gtk_widget_set_style( m_widget, m_widgetStyle );
a81258be
RR
650}
651
53b28675 652//-----------------------------------------------------------------------------
ff829f3f 653// wxNotebookEvent
53b28675
RR
654//-----------------------------------------------------------------------------
655
92976ab6 656IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
5b011451 657