]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/notebook.cpp
...fixing up a previous Unicode fix.
[wxWidgets.git] / src / gtk / 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
130//-----------------------------------------------------------------------------
131// "key_press_event"
132//-----------------------------------------------------------------------------
133
f861258f 134static gint
b292e2f5
RR
135gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNotebook *notebook )
136{
acfd422a
RR
137 if (g_isIdle) wxapp_install_idle_handler();
138
b292e2f5
RR
139 if (g_blockEventsOnDrag) return FALSE;
140
a2053b27 141 if (!notebook->m_hasVMT) return FALSE;
f861258f 142
b98d804b
RR
143 /* this code makes jumping down from the handles of the notebooks
144 to the actual items in the visible notebook page possible with
145 the down-arrow key */
b292e2f5
RR
146
147 if (gdk_event->keyval != GDK_Down) return FALSE;
f861258f 148
b292e2f5 149 if (notebook != notebook->FindFocus()) return FALSE;
f861258f 150
b292e2f5 151 if (notebook->m_pages.GetCount() == 0) return FALSE;
f861258f 152
b292e2f5 153 wxNode *node = notebook->m_pages.Nth( notebook->GetSelection() );
f861258f 154
b292e2f5 155 if (!node) return FALSE;
f861258f 156
b292e2f5 157 wxNotebookPage *page = (wxNotebookPage*) node->Data();
f861258f 158
b292e2f5
RR
159 // don't let others the key event
160 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
f861258f 161
b292e2f5 162 page->m_client->SetFocus();
f861258f 163
b292e2f5 164 return TRUE;
ff7b1510 165}
caac5181 166
6ca41e57
RR
167//-----------------------------------------------------------------------------
168// InsertChild callback for wxNotebook
169//-----------------------------------------------------------------------------
170
587ce561 171static void wxInsertChildInNotebook( wxNotebook* WXUNUSED(parent), wxWindow* WXUNUSED(child) )
6ca41e57 172{
587ce561 173 /* we don't do anything here but pray */
6ca41e57
RR
174}
175
53b28675
RR
176//-----------------------------------------------------------------------------
177// wxNotebook
178//-----------------------------------------------------------------------------
179
53b28675
RR
180IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl)
181
b98d804b
RR
182BEGIN_EVENT_TABLE(wxNotebook, wxControl)
183 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
184END_EVENT_TABLE()
f861258f 185
ff829f3f 186void wxNotebook::Init()
53b28675 187{
b292e2f5
RR
188 m_imageList = (wxImageList *) NULL;
189 m_pages.DeleteContents( TRUE );
29f538ce 190 m_lastSelection = -1;
ff829f3f
VZ
191}
192
193wxNotebook::wxNotebook()
194{
b292e2f5 195 Init();
ff7b1510 196}
53b28675 197
debe6624 198wxNotebook::wxNotebook( wxWindow *parent, wxWindowID id,
53b28675 199 const wxPoint& pos, const wxSize& size,
debe6624 200 long style, const wxString& name )
53b28675 201{
b292e2f5
RR
202 Init();
203 Create( parent, id, pos, size, style, name );
ff7b1510 204}
53b28675 205
ff829f3f 206wxNotebook::~wxNotebook()
53b28675 207{
587ce561
RR
208 /* don't generate change page events any more */
209 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
210 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this );
ff829f3f 211
b292e2f5 212 DeleteAllPages();
ff7b1510 213}
53b28675 214
debe6624 215bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
53b28675 216 const wxPoint& pos, const wxSize& size,
debe6624 217 long style, const wxString& name )
53b28675 218{
b292e2f5
RR
219 m_needParent = TRUE;
220 m_acceptsFocus = TRUE;
221 m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook;
222
223 PreCreation( parent, id, pos, size, style, name );
ff829f3f 224
b292e2f5 225 m_widget = gtk_notebook_new();
53b28675 226
2e563988
RR
227#ifdef __WXDEBUG__
228 debug_focus_in( m_widget, _T("wxNotebook::m_widget"), name );
229#endif
230
b292e2f5 231 gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
caac5181 232
587ce561
RR
233 gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page",
234 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer)this );
ff829f3f 235
f03fc89f 236 m_parent->DoAddChild( this );
ef44a621 237
b292e2f5
RR
238 gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event",
239 GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this );
ff829f3f 240
b292e2f5 241 PostCreation();
ff829f3f 242
b292e2f5
RR
243 Show( TRUE );
244
245 return TRUE;
ff7b1510 246}
53b28675 247
ff829f3f 248int wxNotebook::GetSelection() const
53b28675 249{
b019151f 250 wxCHECK_MSG( m_widget != NULL, -1, _T("invalid notebook") );
53b28675 251
587ce561 252 GList *pages = GTK_NOTEBOOK(m_widget)->children;
ef44a621 253
587ce561 254 if (g_list_length(pages) == 0) return -1;
53b28675 255
587ce561
RR
256 GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);
257
29f538ce 258 if (notebook->cur_page == NULL) return m_lastSelection;
587ce561 259
29f538ce 260 return g_list_index( pages, (gpointer)(notebook->cur_page) );
ff7b1510 261}
53b28675 262
ff829f3f 263int wxNotebook::GetPageCount() const
53b28675 264{
587ce561 265 return (int) g_list_length( GTK_NOTEBOOK(m_widget)->children );
ff7b1510 266}
53b28675 267
ff829f3f 268int wxNotebook::GetRowCount() const
53b28675 269{
b292e2f5 270 return 1;
ff7b1510 271}
53b28675 272
ff829f3f 273wxString wxNotebook::GetPageText( int page ) const
53b28675 274{
b019151f 275 wxCHECK_MSG( m_widget != NULL, _T(""), _T("invalid notebook") );
ef44a621 276
b292e2f5
RR
277 wxNotebookPage* nb_page = GetNotebookPage(page);
278 if (nb_page)
279 return nb_page->m_text;
280 else
281 return "";
ff7b1510 282}
53b28675 283
ff829f3f 284int wxNotebook::GetPageImage( int page ) const
53b28675 285{
587ce561 286 wxCHECK_MSG( m_widget != NULL, -1, _T("invalid notebook") );
a81258be 287
b292e2f5
RR
288 wxNotebookPage* nb_page = GetNotebookPage(page);
289 if (nb_page)
290 return nb_page->m_image;
291 else
587ce561 292 return -1;
ff7b1510 293}
53b28675 294
587ce561 295wxNotebookPage* wxNotebook::GetNotebookPage( int page ) const
53b28675 296{
587ce561 297 wxCHECK_MSG( m_widget != NULL, (wxNotebookPage*) NULL, _T("invalid notebook") );
ff829f3f 298
587ce561
RR
299 wxCHECK_MSG( page < (int)m_pages.GetCount(), (wxNotebookPage*) NULL, _T("invalid notebook index") );
300
301 wxNode *node = m_pages.Nth( page );
302
303 return (wxNotebookPage *) node->Data();
ff7b1510 304}
53b28675 305
ff829f3f 306int wxNotebook::SetSelection( int page )
53b28675 307{
b019151f 308 wxCHECK_MSG( m_widget != NULL, -1, _T("invalid notebook") );
a81258be 309
587ce561 310 wxCHECK_MSG( page < (int)m_pages.GetCount(), -1, _T("invalid notebook index") );
ff829f3f 311
587ce561
RR
312 int selOld = GetSelection();
313
314 gtk_notebook_set_page( GTK_NOTEBOOK(m_widget), page );
ff829f3f 315
3eb78d7e 316 return selOld;
ff7b1510 317}
53b28675 318
587ce561 319void wxNotebook::AdvanceSelection( bool forward )
ff829f3f 320{
b019151f 321 wxCHECK_RET( m_widget != NULL, _T("invalid notebook") );
a81258be 322
3eb78d7e
RR
323 int sel = GetSelection();
324 int max = GetPageCount();
ff829f3f 325
587ce561 326 if (forward)
3eb78d7e
RR
327 SetSelection( sel == max ? 0 : sel + 1 );
328 else
b98d804b 329 SetSelection( sel == 0 ? max-1 : sel - 1 );
ff829f3f
VZ
330}
331
53b28675
RR
332void wxNotebook::SetImageList( wxImageList* imageList )
333{
3eb78d7e 334 m_imageList = imageList;
ff7b1510 335}
53b28675 336
ff829f3f 337bool wxNotebook::SetPageText( int page, const wxString &text )
53b28675 338{
b019151f 339 wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid notebook") );
a81258be 340
3eb78d7e 341 wxNotebookPage* nb_page = GetNotebookPage(page);
ef44a621 342
f861258f 343 wxCHECK_MSG( nb_page, FALSE, _T("SetPageText: invalid page index") );
ff829f3f 344
3eb78d7e 345 nb_page->m_text = text;
ff829f3f 346
587ce561 347 gtk_label_set( nb_page->m_label, nb_page->m_text.mbc_str() );
3eb78d7e
RR
348
349 return TRUE;
ff7b1510 350}
53b28675 351
debe6624 352bool wxNotebook::SetPageImage( int page, int image )
53b28675 353{
3eb78d7e 354 /* HvdH 28-12-98: now it works, but it's a bit of a kludge */
f861258f 355
3eb78d7e 356 wxNotebookPage* nb_page = GetNotebookPage(page);
ef44a621 357
3eb78d7e 358 if (!nb_page) return FALSE;
f861258f 359
3eb78d7e
RR
360 /* Optimization posibility: return immediately if image unchanged.
361 * Not enabled because it may break existing (stupid) code that
362 * manipulates the imagelist to cycle images */
f861258f 363
3eb78d7e 364 /* if (image == nb_page->m_image) return TRUE; */
f861258f
VZ
365
366 /* For different cases:
3eb78d7e
RR
367 1) no image -> no image
368 2) image -> no image
369 3) no image -> image
370 4) image -> image */
f861258f 371
3eb78d7e
RR
372 if (image == -1 && nb_page->m_image == -1)
373 return TRUE; /* Case 1): Nothing to do. */
f861258f 374
bbe0af5b 375 GtkWidget *pixmapwid = (GtkWidget*) NULL;
f861258f
VZ
376
377 if (nb_page->m_image != -1)
3eb78d7e
RR
378 {
379 /* Case 2) or 4). There is already an image in the gtkhbox. Let's find it */
f861258f 380
3eb78d7e
RR
381 GList *child = gtk_container_children(GTK_CONTAINER(nb_page->m_box));
382 while (child)
383 {
f861258f 384 if (GTK_IS_PIXMAP(child->data))
3eb78d7e
RR
385 {
386 pixmapwid = GTK_WIDGET(child->data);
387 break;
388 }
389 child = child->next;
390 }
f861258f 391
3eb78d7e 392 /* We should have the pixmap widget now */
f861258f
VZ
393 wxASSERT(pixmapwid != NULL);
394
395 if (image == -1)
3eb78d7e
RR
396 {
397 /* If there's no new widget, just remove the old from the box */
398 gtk_container_remove(GTK_CONTAINER(nb_page->m_box), pixmapwid);
399 nb_page->m_image = -1;
53b28675 400
3eb78d7e
RR
401 return TRUE; /* Case 2) */
402 }
403 }
f861258f 404
3eb78d7e
RR
405 /* Only cases 3) and 4) left */
406 wxASSERT( m_imageList != NULL ); /* Just in case */
f861258f 407
3eb78d7e
RR
408 /* Construct the new pixmap */
409 const wxBitmap *bmp = m_imageList->GetBitmap(image);
410 GdkPixmap *pixmap = bmp->GetPixmap();
411 GdkBitmap *mask = (GdkBitmap*) NULL;
f861258f 412 if ( bmp->GetMask() )
3eb78d7e
RR
413 {
414 mask = bmp->GetMask()->GetBitmap();
415 }
f861258f
VZ
416
417 if (pixmapwid == NULL)
3eb78d7e
RR
418 {
419 /* Case 3) No old pixmap. Create a new one and prepend it to the hbox */
420 pixmapwid = gtk_pixmap_new (pixmap, mask );
f861258f 421
3eb78d7e
RR
422 /* CHECKME: Are these pack flags okay? */
423 gtk_box_pack_start(GTK_BOX(nb_page->m_box), pixmapwid, FALSE, FALSE, 3);
424 gtk_widget_show(pixmapwid);
425 }
f861258f 426 else
3eb78d7e
RR
427 {
428 /* Case 4) Simply replace the pixmap */
429 gtk_pixmap_set(GTK_PIXMAP(pixmapwid), pixmap, mask);
430 }
f861258f 431
3eb78d7e 432 nb_page->m_image = image;
53b28675 433
3eb78d7e 434 return TRUE;
ff7b1510 435}
53b28675
RR
436
437void wxNotebook::SetPageSize( const wxSize &WXUNUSED(size) )
438{
b019151f 439 wxFAIL_MSG( _T("wxNotebook::SetPageSize not implemented") );
ff7b1510 440}
53b28675
RR
441
442void wxNotebook::SetPadding( const wxSize &WXUNUSED(padding) )
443{
b019151f 444 wxFAIL_MSG( _T("wxNotebook::SetPadding not implemented") );
ff7b1510 445}
53b28675 446
74e3313b 447void wxNotebook::SetTabSize(const wxSize& WXUNUSED(sz))
ca8b28f2 448{
b019151f 449 wxFAIL_MSG( _T("wxNotebook::SetTabSize not implemented") );
ca8b28f2
JS
450}
451
ff829f3f 452bool wxNotebook::DeleteAllPages()
53b28675 453{
b019151f 454 wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid notebook") );
a81258be 455
587ce561
RR
456 while (m_pages.GetCount() > 0)
457 DeletePage( m_pages.GetCount()-1 );
ff829f3f 458
3eb78d7e 459 return TRUE;
ff7b1510 460}
53b28675 461
ff829f3f 462bool wxNotebook::DeletePage( int page )
53b28675 463{
3eb78d7e
RR
464 wxNotebookPage* nb_page = GetNotebookPage(page);
465 if (!nb_page) return FALSE;
53b28675 466
29f538ce
RR
467 /* GTK sets GtkNotebook.cur_page to NULL before sending
468 the switvh page event */
469 m_lastSelection = GetSelection();
470
587ce561 471 nb_page->m_client->Destroy();
3eb78d7e 472 m_pages.DeleteObject( nb_page );
29f538ce
RR
473
474 m_lastSelection = -1;
fed46e72 475
3eb78d7e 476 return TRUE;
fed46e72
RR
477}
478
479bool wxNotebook::RemovePage( int page )
480{
3eb78d7e 481 wxNotebookPage* nb_page = GetNotebookPage(page);
587ce561 482
3eb78d7e 483 if (!nb_page) return FALSE;
fed46e72 484
587ce561 485 gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page );
ff829f3f 486
3eb78d7e 487 m_pages.DeleteObject( nb_page );
ff829f3f 488
3eb78d7e 489 return TRUE;
ff7b1510 490}
53b28675 491
587ce561
RR
492bool wxNotebook::InsertPage( int position, wxWindow* win, const wxString& text,
493 bool select, int imageId )
53b28675 494{
b019151f 495 wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid notebook") );
a81258be 496
587ce561
RR
497 wxCHECK_MSG( win->GetParent() == this, FALSE,
498 _T("Can't add a page whose parent is not the notebook!") );
8aadf227 499
587ce561
RR
500 /* don't receive switch page during addition */
501 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
502 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this );
503
504 GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);
53b28675 505
587ce561
RR
506 wxNotebookPage *page = new wxNotebookPage();
507
508 if (position < 0)
509 m_pages.Append( page );
510 else
511 m_pages.Insert( m_pages.Nth( position ), page );
512
513 page->m_client = win;
8aadf227 514
587ce561
RR
515 page->m_box = gtk_hbox_new( FALSE, 0 );
516 gtk_container_border_width( GTK_CONTAINER(page->m_box), 2 );
517
518 if (position < 0)
519 gtk_notebook_append_page( notebook, win->m_widget, page->m_box );
520 else
521 gtk_notebook_insert_page( notebook, win->m_widget, page->m_box, position );
522
523 page->m_page = GTK_NOTEBOOK_PAGE( g_list_last(notebook->children)->data );
ef44a621 524
587ce561
RR
525 gtk_signal_connect( GTK_OBJECT(win->m_widget), "size_allocate",
526 GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)win );
ff829f3f 527
587ce561
RR
528 /* set the label image */
529 page->m_image = imageId;
530
3eb78d7e 531 if (imageId != -1)
e4a81a2e 532 {
3eb78d7e
RR
533 wxASSERT( m_imageList != NULL );
534
535 const wxBitmap *bmp = m_imageList->GetBitmap(imageId);
536 GdkPixmap *pixmap = bmp->GetPixmap();
537 GdkBitmap *mask = (GdkBitmap*) NULL;
538 if ( bmp->GetMask() )
539 {
540 mask = bmp->GetMask()->GetBitmap();
541 }
e4a81a2e 542
3eb78d7e 543 GtkWidget *pixmapwid = gtk_pixmap_new (pixmap, mask );
24d20a8f 544
3eb78d7e 545 gtk_box_pack_start(GTK_BOX(page->m_box), pixmapwid, FALSE, FALSE, 3);
24d20a8f 546
3eb78d7e
RR
547 gtk_widget_show(pixmapwid);
548 }
24d20a8f 549
587ce561 550 /* set the label text */
3eb78d7e 551 page->m_text = text;
b019151f 552 if (page->m_text.IsEmpty()) page->m_text = _T("");
587ce561
RR
553
554 page->m_label = GTK_LABEL( gtk_label_new(page->m_text.mbc_str()) );
555 gtk_box_pack_end( GTK_BOX(page->m_box), GTK_WIDGET(page->m_label), FALSE, FALSE, 3 );
741fd203 556
587ce561
RR
557 /* show the label */
558 gtk_widget_show( GTK_WIDGET(page->m_label) );
741fd203 559
587ce561
RR
560 if (select && (m_pages.GetCount() > 1))
561 {
562 if (position < 0)
563 SetSelection( GetPageCount()-1 );
564 else
565 SetSelection( position );
566 }
741fd203 567
587ce561
RR
568 gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page",
569 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer)this );
ff829f3f 570
3eb78d7e 571 return TRUE;
ff7b1510 572}
53b28675 573
587ce561
RR
574bool wxNotebook::AddPage(wxWindow* win, const wxString& text,
575 bool select, int imageId)
576{
577 return InsertPage( -1, win, text, select, imageId );
578}
579
b98d804b
RR
580void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
581{
f861258f 582 if (event.IsWindowChange())
b98d804b 583 AdvanceSelection( event.GetDirection() );
f861258f 584 else
b98d804b
RR
585 event.Skip();
586}
587
ff829f3f 588wxWindow *wxNotebook::GetPage( int page ) const
53b28675 589{
b019151f 590 wxCHECK_MSG( m_widget != NULL, (wxWindow*) NULL, _T("invalid notebook") );
a81258be 591
b292e2f5
RR
592 wxNotebookPage* nb_page = GetNotebookPage(page);
593 if (!nb_page)
594 return (wxWindow *) NULL;
595 else
596 return nb_page->m_client;
ff7b1510 597}
53b28675 598
5a8c929e 599// override these 2 functions to do nothing: everything is done in OnSize
e3e65dac 600void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) )
5a8c929e 601{
b292e2f5
RR
602 // don't set the sizes of the pages - their correct size is not yet known
603 wxControl::SetConstraintSizes(FALSE);
5a8c929e
VZ
604}
605
e3e65dac 606bool wxNotebook::DoPhase( int WXUNUSED(nPhase) )
5a8c929e 607{
b292e2f5 608 return TRUE;
5a8c929e
VZ
609}
610
58614078 611void wxNotebook::ApplyWidgetStyle()
a81258be 612{
b292e2f5
RR
613 SetWidgetStyle();
614 gtk_widget_set_style( m_widget, m_widgetStyle );
a81258be
RR
615}
616
58d1c1ae
RR
617bool wxNotebook::IsOwnGtkWindow( GdkWindow *window )
618{
619 return ((m_widget->window == window) ||
620 (GTK_NOTEBOOK(m_widget)->panel == window));
621}
622
53b28675 623//-----------------------------------------------------------------------------
ff829f3f 624// wxNotebookEvent
53b28675
RR
625//-----------------------------------------------------------------------------
626
92976ab6 627IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
5b011451 628
dcf924a3 629#endif