]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/notebook.cpp
Avoid overflowing the wake up when handling events in Unix console apps.
[wxWidgets.git] / src / gtk / notebook.cpp
CommitLineData
53b28675 1/////////////////////////////////////////////////////////////////////////////
88a7a4e1 2// Name: src/gtk/notebook.cpp
53b28675
RR
3// Purpose:
4// Author: Robert Roebling
a81258be 5// Id: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling, Vadim Zeitlin
65571936 7// Licence: wxWindows licence
53b28675
RR
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2
VS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
88a7a4e1
WS
13#if wxUSE_NOTEBOOK
14
53b28675 15#include "wx/notebook.h"
dcf924a3 16
88a7a4e1
WS
17#ifndef WX_PRECOMP
18 #include "wx/intl.h"
e4db172a 19 #include "wx/log.h"
de6185e2 20 #include "wx/utils.h"
246c5004 21 #include "wx/msgdlg.h"
0bca0373 22 #include "wx/bitmap.h"
88a7a4e1 23#endif
dcf924a3 24
53b28675 25#include "wx/imaglist.h"
c077ee94 26#include "wx/fontutil.h"
83624f79 27
9e691f46 28#include "wx/gtk/private.h"
9e691f46 29
219f895a 30//-----------------------------------------------------------------------------
80a58c99 31// wxGtkNotebookPage
219f895a
RR
32//-----------------------------------------------------------------------------
33
07b8d7ec
VZ
34// VZ: this is rather ugly as we keep the pages themselves in an array (it
35// allows us to have quite a few functions implemented in the base class)
36// but the page data is kept in a separate list, so we must maintain them
37// in sync manually... of course, the list had been there before the base
38// class which explains it but it still would be nice to do something
39// about this one day
40
80a58c99 41class wxGtkNotebookPage: public wxObject
219f895a
RR
42{
43public:
c58d2238
PC
44 GtkWidget* m_box;
45 GtkWidget* m_label;
46 GtkWidget* m_image;
47 int m_imageIndex;
219f895a
RR
48};
49
c077ee94 50
07b8d7ec 51#include "wx/listimpl.cpp"
28c91b7d 52WX_DEFINE_LIST(wxGtkNotebookPagesList)
07b8d7ec 53
75c6febf
PC
54extern "C" {
55static void event_after(GtkNotebook*, GdkEvent*, wxNotebook*);
56}
c077ee94 57
ff829f3f 58//-----------------------------------------------------------------------------
5b011451 59// "switch_page"
ff829f3f
VZ
60//-----------------------------------------------------------------------------
61
865bb325 62extern "C" {
75c6febf 63static void
681be2ef 64switch_page_after(GtkNotebook* widget, GtkNotebookPage*, guint, wxNotebook* win)
ff829f3f 65{
75c6febf 66 g_signal_handlers_block_by_func(widget, (void*)switch_page_after, win);
681be2ef
VZ
67
68 win->GTKOnPageChanged();
75c6febf
PC
69}
70}
36202885 71
75c6febf
PC
72extern "C" {
73static void
74switch_page(GtkNotebook* widget, GtkNotebookPage*, int page, wxNotebook* win)
75{
76 win->m_oldSelection = gtk_notebook_get_current_page(widget);
77
78 if (win->SendPageChangingEvent(page))
79 // allow change, unblock handler for changed event
80 g_signal_handlers_unblock_by_func(widget, (void*)switch_page_after, win);
1d6fcbcc 81 else
75c6febf
PC
82 // change vetoed, unblock handler to set selection back
83 g_signal_handlers_unblock_by_func(widget, (void*)event_after, win);
c9882624
RR
84}
85}
ef44a621 86
75c6febf
PC
87//-----------------------------------------------------------------------------
88// "event_after" from m_widget
89//-----------------------------------------------------------------------------
90
c9882624 91extern "C" {
75c6febf 92static void event_after(GtkNotebook* widget, GdkEvent*, wxNotebook* win)
c9882624 93{
75c6febf
PC
94 g_signal_handlers_block_by_func(widget, (void*)event_after, win);
95 g_signal_handlers_block_by_func(widget, (void*)switch_page, win);
96
97 // restore previous selection
98 gtk_notebook_set_current_page(widget, win->m_oldSelection);
99
100 g_signal_handlers_unblock_by_func(widget, (void*)switch_page, win);
ff829f3f 101}
865bb325 102}
ff829f3f 103
6ca41e57
RR
104//-----------------------------------------------------------------------------
105// InsertChild callback for wxNotebook
106//-----------------------------------------------------------------------------
107
48200154 108void wxNotebook::AddChildGTK(wxWindowGTK* child)
6ca41e57 109{
fff8475e
RD
110 // Hack Alert! (Part I): This sets the notebook as the parent of the child
111 // widget, and takes care of some details such as updating the state and
112 // style of the child to reflect its new location. We do this early
113 // because without it GetBestSize (which is used to set the initial size
114 // of controls if an explicit size is not given) will often report
115 // incorrect sizes since the widget's style context is not fully known.
116 // See bug #901694 for details
2ded391d 117 // (http://sourceforge.net/tracker/?func=detail&aid=901694&group_id=9863&atid=109863)
48200154 118 gtk_widget_set_parent(child->m_widget, m_widget);
fff8475e
RD
119
120 // NOTE: This should be considered a temporary workaround until we can
121 // work out the details and implement delaying the setting of the initial
122 // size of widgets until the size is really needed.
6ca41e57
RR
123}
124
53b28675
RR
125//-----------------------------------------------------------------------------
126// wxNotebook
127//-----------------------------------------------------------------------------
128
8dba4c72 129BEGIN_EVENT_TABLE(wxNotebook, wxBookCtrlBase)
b98d804b
RR
130 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
131END_EVENT_TABLE()
f861258f 132
ff829f3f 133void wxNotebook::Init()
53b28675 134{
b318dc42 135 m_padding = 0;
c9882624 136 m_oldSelection = -1;
de6185e2 137 m_themeEnabled = true;
ff829f3f
VZ
138}
139
140wxNotebook::wxNotebook()
141{
b292e2f5 142 Init();
ff7b1510 143}
53b28675 144
debe6624 145wxNotebook::wxNotebook( wxWindow *parent, wxWindowID id,
53b28675 146 const wxPoint& pos, const wxSize& size,
debe6624 147 long style, const wxString& name )
53b28675 148{
b292e2f5
RR
149 Init();
150 Create( parent, id, pos, size, style, name );
ff7b1510 151}
53b28675 152
ff829f3f 153wxNotebook::~wxNotebook()
53b28675 154{
b292e2f5 155 DeleteAllPages();
ff7b1510 156}
53b28675 157
debe6624 158bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
07b8d7ec
VZ
159 const wxPoint& pos, const wxSize& size,
160 long style, const wxString& name )
53b28675 161{
90f9b8ef
JS
162 if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
163 style |= wxBK_TOP;
164
4dcaf11a
RR
165 if (!PreCreation( parent, pos, size ) ||
166 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
167 {
223d09f6 168 wxFAIL_MSG( wxT("wxNoteBook creation failed") );
de6185e2 169 return false;
4dcaf11a
RR
170 }
171
ff829f3f 172
b292e2f5 173 m_widget = gtk_notebook_new();
9ff9d30c 174 g_object_ref(m_widget);
53b28675 175
b292e2f5 176 gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
caac5181 177
9fa72bd2 178 g_signal_connect (m_widget, "switch_page",
75c6febf 179 G_CALLBACK(switch_page), this);
c9882624
RR
180
181 g_signal_connect_after (m_widget, "switch_page",
75c6febf
PC
182 G_CALLBACK(switch_page_after), this);
183 g_signal_handlers_block_by_func(m_widget, (void*)switch_page_after, this);
184
185 g_signal_connect(m_widget, "event_after", G_CALLBACK(event_after), this);
186 g_signal_handlers_block_by_func(m_widget, (void*)event_after, this);
ff829f3f 187
f03fc89f 188 m_parent->DoAddChild( this );
ef44a621 189
df034cc6 190 if (m_windowStyle & wxBK_RIGHT)
8712c6e7 191 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_RIGHT );
df034cc6 192 if (m_windowStyle & wxBK_LEFT)
8712c6e7 193 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_LEFT );
df034cc6 194 if (m_windowStyle & wxBK_BOTTOM)
8712c6e7 195 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_BOTTOM );
a3a7f879 196
abdeb9e7 197 PostCreation(size);
ff829f3f 198
de6185e2 199 return true;
ff7b1510 200}
53b28675 201
ff829f3f 202int wxNotebook::GetSelection() const
53b28675 203{
7e837615 204 wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid notebook") );
53b28675 205
c9882624 206 return gtk_notebook_get_current_page( GTK_NOTEBOOK(m_widget) );
ff7b1510 207}
53b28675 208
789d0a3d 209wxString wxNotebook::GetPageText( size_t page ) const
53b28675 210{
c58d2238 211 wxCHECK_MSG(page < GetPageCount(), wxEmptyString, "invalid notebook index");
ef44a621 212
c58d2238
PC
213 GtkLabel* label = GTK_LABEL(GetNotebookPage(page)->m_label);
214 return wxGTK_CONV_BACK(gtk_label_get_text(label));
ff7b1510 215}
53b28675 216
789d0a3d 217int wxNotebook::GetPageImage( size_t page ) const
53b28675 218{
7e837615 219 wxCHECK_MSG(page < GetPageCount(), wxNOT_FOUND, "invalid notebook index");
a81258be 220
c58d2238 221 return GetNotebookPage(page)->m_imageIndex;
ff7b1510 222}
53b28675 223
80a58c99 224wxGtkNotebookPage* wxNotebook::GetNotebookPage( int page ) const
53b28675 225{
07b8d7ec 226 return m_pagesData.Item(page)->GetData();
ff7b1510 227}
53b28675 228
1d6fcbcc 229int wxNotebook::DoSetSelection( size_t page, int flags )
53b28675 230{
7e837615 231 wxCHECK_MSG(page < GetPageCount(), wxNOT_FOUND, "invalid notebook index");
ff829f3f 232
587ce561 233 int selOld = GetSelection();
a6aa9b1e 234
1d6fcbcc 235 if ( !(flags & SetSelection_SendEvent) )
c9882624 236 {
75c6febf 237 g_signal_handlers_block_by_func(m_widget, (void*)switch_page, this);
c9882624 238 }
1d6fcbcc 239
38f1df7c 240 gtk_notebook_set_current_page( GTK_NOTEBOOK(m_widget), page );
ff829f3f 241
1d6fcbcc
VZ
242 if ( !(flags & SetSelection_SendEvent) )
243 {
75c6febf 244 g_signal_handlers_unblock_by_func(m_widget, (void*)switch_page, this);
1d6fcbcc 245 }
1d6fcbcc 246
681be2ef
VZ
247 m_selection = page;
248
07b8d7ec
VZ
249 wxNotebookPage *client = GetPage(page);
250 if ( client )
251 client->SetFocus();
b656febd 252
07b8d7ec 253 return selOld;
ff7b1510 254}
53b28675 255
681be2ef
VZ
256void wxNotebook::GTKOnPageChanged()
257{
258 m_selection = gtk_notebook_get_current_page(GTK_NOTEBOOK(m_widget));
259
260 SendPageChangedEvent(m_oldSelection);
261}
262
789d0a3d 263bool wxNotebook::SetPageText( size_t page, const wxString &text )
53b28675 264{
c58d2238 265 wxCHECK_MSG(page < GetPageCount(), false, "invalid notebook index");
ff829f3f 266
c58d2238
PC
267 GtkLabel* label = GTK_LABEL(GetNotebookPage(page)->m_label);
268 gtk_label_set_text(label, wxGTK_CONV(text));
a6aa9b1e 269
de6185e2 270 return true;
ff7b1510 271}
53b28675 272
789d0a3d 273bool wxNotebook::SetPageImage( size_t page, int image )
53b28675 274{
c58d2238 275 wxCHECK_MSG(page < GetPageCount(), false, "invalid notebook index");
f861258f 276
c58d2238
PC
277 wxGtkNotebookPage* pageData = GetNotebookPage(page);
278 if (image >= 0)
3eb78d7e 279 {
abfdefed
VZ
280 wxCHECK_MSG(HasImageList(), false, "invalid notebook imagelist");
281 const wxBitmap* bitmap = GetImageList()->GetBitmapPtr(image);
c58d2238
PC
282 if (bitmap == NULL)
283 return false;
284 if (pageData->m_image)
8712c6e7 285 {
c58d2238
PC
286 gtk_image_set_from_pixbuf(
287 GTK_IMAGE(pageData->m_image), bitmap->GetPixbuf());
8712c6e7 288 }
c58d2238 289 else
8712c6e7 290 {
c58d2238
PC
291 pageData->m_image = gtk_image_new_from_pixbuf(bitmap->GetPixbuf());
292 gtk_widget_show(pageData->m_image);
293 gtk_box_pack_start(GTK_BOX(pageData->m_box),
294 pageData->m_image, false, false, m_padding);
3eb78d7e
RR
295 }
296 }
c58d2238 297 else if (pageData->m_image)
3eb78d7e 298 {
c58d2238
PC
299 gtk_widget_destroy(pageData->m_image);
300 pageData->m_image = NULL;
3eb78d7e 301 }
c58d2238 302 pageData->m_imageIndex = image;
53b28675 303
de6185e2 304 return true;
ff7b1510 305}
53b28675 306
864181f4 307wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
53b28675 308{
864181f4
VZ
309 // Compute the max size of the tab labels.
310 wxSize sizeTabMax;
311 const size_t pageCount = GetPageCount();
312 for ( size_t n = 0; n < pageCount; n++ )
313 {
314 GtkRequisition req;
315 gtk_widget_size_request(GetNotebookPage(n)->m_box, &req);
316 sizeTabMax.IncTo(wxSize(req.width, req.height));
317 }
318
319 // Unfortunately this doesn't account for the real tab size and I don't
320 // know how to find it, e.g. where do the margins below come from.
321 const int PAGE_MARGIN = 3;
322 const int TAB_MARGIN = 4;
323
324 sizeTabMax.IncBy(3*TAB_MARGIN);
325
326 wxSize sizeFull(sizePage);
327 if ( IsVertical() )
328 sizeFull.y += sizeTabMax.y;
329 else
330 sizeFull.x += sizeTabMax.x;
331
332 sizeFull.IncBy(2*PAGE_MARGIN);
333
334 return sizeFull;
ff7b1510 335}
53b28675 336
b318dc42 337void wxNotebook::SetPadding( const wxSize &padding )
53b28675 338{
b318dc42
JS
339 wxCHECK_RET( m_widget != NULL, wxT("invalid notebook") );
340
341 m_padding = padding.GetWidth();
342
c58d2238 343 for (size_t i = GetPageCount(); i--;)
b318dc42 344 {
c58d2238
PC
345 wxGtkNotebookPage* pageData = GetNotebookPage(i);
346 if (pageData->m_image)
b318dc42 347 {
c58d2238
PC
348 gtk_box_set_child_packing(GTK_BOX(pageData->m_box),
349 pageData->m_image, false, false, m_padding, GTK_PACK_START);
b318dc42 350 }
c58d2238
PC
351 gtk_box_set_child_packing(GTK_BOX(pageData->m_box),
352 pageData->m_label, false, false, m_padding, GTK_PACK_END);
b318dc42 353 }
ff7b1510 354}
53b28675 355
74e3313b 356void wxNotebook::SetTabSize(const wxSize& WXUNUSED(sz))
ca8b28f2 357{
223d09f6 358 wxFAIL_MSG( wxT("wxNotebook::SetTabSize not implemented") );
ca8b28f2
JS
359}
360
ff829f3f 361bool wxNotebook::DeleteAllPages()
53b28675 362{
c58d2238
PC
363 for (size_t i = GetPageCount(); i--;)
364 DeletePage(i);
a81258be 365
10199e27 366 return wxNotebookBase::DeleteAllPages();
ff7b1510 367}
53b28675 368
acb69c13 369wxNotebookPage *wxNotebook::DoRemovePage( size_t page )
53b28675 370{
a27555e4
RR
371 // We cannot remove the page yet, as GTK sends the "switch_page"
372 // signal before it has removed the notebook-page from its
373 // corresponding list. Thus, if we were to remove the page from
374 // m_pages at this point, the two lists of pages would be out
375 // of sync during the PAGE_CHANGING/PAGE_CHANGED events.
376 wxNotebookPage *client = GetPage(page);
10199e27
VZ
377 if ( !client )
378 return NULL;
fed46e72 379
9c862cfb
RR
380 // we don't need to unparent the client->m_widget; GTK+ will do
381 // that for us (and will throw a warning if we do it!)
587ce561 382 gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page );
ff829f3f 383
a27555e4
RR
384 // It's safe to remove the page now.
385 wxASSERT_MSG(GetPage(page) == client, wxT("pages changed during delete"));
386 wxNotebookBase::DoRemovePage(page);
387
222ed1d6
MB
388 wxGtkNotebookPage* p = GetNotebookPage(page);
389 m_pagesData.DeleteObject(p);
390 delete p;
03647350 391
07b8d7ec 392 return client;
ff7b1510 393}
53b28675 394
789d0a3d 395bool wxNotebook::InsertPage( size_t position,
07b8d7ec
VZ
396 wxNotebookPage* win,
397 const wxString& text,
398 bool select,
399 int imageId )
53b28675 400{
de6185e2 401 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid notebook") );
a81258be 402
de6185e2 403 wxCHECK_MSG( win->GetParent() == this, false,
223d09f6 404 wxT("Can't add a page whose parent is not the notebook!") );
8aadf227 405
de6185e2 406 wxCHECK_MSG( position <= GetPageCount(), false,
9a83f860 407 wxT("invalid page index in wxNotebookPage::InsertPage()") );
07b8d7ec 408
48200154 409 // Hack Alert! (Part II): See above in wxNotebook::AddChildGTK
9ff9d30c
PC
410 // why this has to be done.
411 gtk_widget_unparent(win->m_widget);
d7f1759a 412
a2d93e73 413 if (m_themeEnabled)
de6185e2 414 win->SetThemeEnabled(true);
a2d93e73 415
587ce561 416 GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);
53b28675 417
c58d2238 418 wxGtkNotebookPage* pageData = new wxGtkNotebookPage;
a6aa9b1e 419
07b8d7ec 420 m_pages.Insert(win, position);
c58d2238 421 m_pagesData.Insert(position, pageData);
8aadf227 422
f986fe76
VZ
423 // set the label image and text
424 // this must be done before adding the page, as GetPageText
425 // and GetPageImage will otherwise return wrong values in
426 // the page-changed event that results from inserting the
427 // first page.
c58d2238 428 pageData->m_imageIndex = imageId;
f986fe76 429
c58d2238
PC
430 pageData->m_box = gtk_hbox_new(false, 1);
431 gtk_container_set_border_width(GTK_CONTAINER(pageData->m_box), 2);
a6aa9b1e 432
c58d2238 433 pageData->m_image = NULL;
3eb78d7e 434 if (imageId != -1)
e4a81a2e 435 {
abfdefed 436 if (HasImageList())
c58d2238 437 {
abfdefed 438 const wxBitmap* bitmap = GetImageList()->GetBitmapPtr(imageId);
c58d2238
PC
439 pageData->m_image = gtk_image_new_from_pixbuf(bitmap->GetPixbuf());
440 gtk_box_pack_start(GTK_BOX(pageData->m_box),
441 pageData->m_image, false, false, m_padding);
442 }
443 else
4c2ea599 444 {
c58d2238 445 wxFAIL_MSG("invalid notebook imagelist");
4c2ea599 446 }
3eb78d7e 447 }
24d20a8f 448
587ce561 449 /* set the label text */
c58d2238
PC
450 pageData->m_label = gtk_label_new(wxGTK_CONV(wxStripMenuCodes(text)));
451 gtk_box_pack_end(GTK_BOX(pageData->m_box),
452 pageData->m_label, false, false, m_padding);
453
454 gtk_widget_show_all(pageData->m_box);
455 gtk_notebook_insert_page(notebook, win->m_widget, pageData->m_box, position);
279b5e2e 456
97357eec 457 /* apply current style */
496e7ec6 458 GtkRcStyle *style = GTKCreateWidgetStyle();
97357eec
VS
459 if ( style )
460 {
c58d2238 461 gtk_widget_modify_style(pageData->m_label, style);
385e8575 462 g_object_unref(style);
88d19775
MR
463 }
464
c58d2238 465 if (select && GetPageCount() > 1)
587ce561 466 {
c9882624 467 SetSelection( position );
587ce561 468 }
741fd203 469
37144cf0 470 InvalidateBestSize();
de6185e2 471 return true;
ff7b1510 472}
53b28675 473
279b5e2e
VZ
474// helper for HitTest(): check if the point lies inside the given widget which
475// is the child of the notebook whose position and border size are passed as
476// parameters
477static bool
478IsPointInsideWidget(const wxPoint& pt, GtkWidget *w,
479 gint x, gint y, gint border = 0)
480{
385e8575
PC
481 GtkAllocation a;
482 gtk_widget_get_allocation(w, &a);
279b5e2e 483 return
385e8575
PC
484 (pt.x >= a.x - x - border) &&
485 (pt.x <= a.x - x + border + a.width) &&
486 (pt.y >= a.y - y - border) &&
487 (pt.y <= a.y - y + border + a.height);
279b5e2e
VZ
488}
489
490int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
491{
385e8575
PC
492 GtkAllocation a;
493 gtk_widget_get_allocation(m_widget, &a);
494 const int x = a.x;
495 const int y = a.y;
279b5e2e
VZ
496
497 const size_t count = GetPageCount();
f660b206
MR
498 size_t i = 0;
499
385e8575 500#if !GTK_CHECK_VERSION(3,0,0) && !defined(GSEAL_ENABLE)
f660b206 501 GtkNotebook * notebook = GTK_NOTEBOOK(m_widget);
a5bb4f82 502 if (gtk_notebook_get_scrollable(notebook))
f660b206 503 i = g_list_position( notebook->children, notebook->first_tab );
385e8575 504#endif
f660b206
MR
505
506 for ( ; i < count; i++ )
279b5e2e 507 {
c58d2238
PC
508 wxGtkNotebookPage* pageData = GetNotebookPage(i);
509 GtkWidget* box = pageData->m_box;
279b5e2e 510
279b5e2e 511 const gint border = gtk_container_get_border_width(GTK_CONTAINER(box));
68567a96 512
279b5e2e
VZ
513 if ( IsPointInsideWidget(pt, box, x, y, border) )
514 {
515 // ok, we're inside this tab -- now find out where, if needed
516 if ( flags )
517 {
c58d2238 518 if (pageData->m_image && IsPointInsideWidget(pt, pageData->m_image, x, y))
279b5e2e 519 {
9804d540 520 *flags = wxBK_HITTEST_ONICON;
279b5e2e 521 }
c58d2238 522 else if (IsPointInsideWidget(pt, pageData->m_label, x, y))
279b5e2e 523 {
9804d540 524 *flags = wxBK_HITTEST_ONLABEL;
279b5e2e
VZ
525 }
526 else
527 {
9804d540 528 *flags = wxBK_HITTEST_ONITEM;
279b5e2e
VZ
529 }
530 }
531
532 return i;
533 }
534 }
535
536 if ( flags )
d0a84b63 537 {
9804d540 538 *flags = wxBK_HITTEST_NOWHERE;
d0a84b63
VZ
539 wxWindowBase * page = GetCurrentPage();
540 if ( page )
541 {
542 // rect origin is in notebook's parent coordinates
543 wxRect rect = page->GetRect();
544
545 // adjust it to the notebook's coordinates
546 wxPoint pos = GetPosition();
547 rect.x -= pos.x;
548 rect.y -= pos.y;
22a35096 549 if ( rect.Contains( pt ) )
9804d540 550 *flags |= wxBK_HITTEST_ONPAGE;
d0a84b63
VZ
551 }
552 }
279b5e2e
VZ
553
554 return wxNOT_FOUND;
555}
556
b98d804b
RR
557void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
558{
f861258f 559 if (event.IsWindowChange())
b98d804b 560 AdvanceSelection( event.GetDirection() );
f861258f 561 else
b98d804b
RR
562 event.Skip();
563}
564
93d38175
VS
565#if wxUSE_CONSTRAINTS
566
5a8c929e 567// override these 2 functions to do nothing: everything is done in OnSize
e3e65dac 568void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) )
5a8c929e 569{
b292e2f5 570 // don't set the sizes of the pages - their correct size is not yet known
de6185e2 571 wxControl::SetConstraintSizes(false);
5a8c929e
VZ
572}
573
e3e65dac 574bool wxNotebook::DoPhase( int WXUNUSED(nPhase) )
5a8c929e 575{
de6185e2 576 return true;
5a8c929e
VZ
577}
578
93d38175
VS
579#endif
580
f40fdaa3 581void wxNotebook::DoApplyWidgetStyle(GtkRcStyle *style)
a81258be 582{
97357eec 583 gtk_widget_modify_style(m_widget, style);
c58d2238
PC
584 for (size_t i = GetPageCount(); i--;)
585 gtk_widget_modify_style(GetNotebookPage(i)->m_label, style);
a81258be
RR
586}
587
ef5c70f9 588GdkWindow *wxNotebook::GTKGetWindow(wxArrayGdkWindows& windows) const
58d1c1ae 589{
385e8575 590 windows.push_back(gtk_widget_get_window(m_widget));
ef5c70f9
VZ
591 windows.push_back(GTK_NOTEBOOK(m_widget)->event_window);
592
593 return NULL;
58d1c1ae
RR
594}
595
9d522606
RD
596// static
597wxVisualAttributes
598wxNotebook::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
599{
600 return GetDefaultAttributesFromGTKWidget(gtk_notebook_new);
601}
602
a3a7f879 603#endif