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