1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling, Vadim Zeitlin
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
13 #include "wx/notebook.h"
19 #include "wx/imaglist.h"
22 #include "wx/bitmap.h"
23 #include "wx/fontutil.h"
25 // FIXME: Use GtkImage instead of GtkPixmap. Don't use gtk_container_border_width
26 #include <gtk/gtkversion.h>
27 #ifdef GTK_DISABLE_DEPRECATED
28 #undef GTK_DISABLE_DEPRECATED
31 #include "wx/gtk/private.h"
32 #include "wx/gtk/win_gtk.h"
34 #include <gdk/gdkkeysyms.h>
36 #include "wx/msgdlg.h"
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
)
43 DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
)
45 //-----------------------------------------------------------------------------
47 //-----------------------------------------------------------------------------
49 extern void wxapp_install_idle_handler();
52 //-----------------------------------------------------------------------------
54 //-----------------------------------------------------------------------------
56 extern bool g_blockEventsOnDrag
;
58 //-----------------------------------------------------------------------------
60 //-----------------------------------------------------------------------------
62 // VZ: this is rather ugly as we keep the pages themselves in an array (it
63 // allows us to have quite a few functions implemented in the base class)
64 // but the page data is kept in a separate list, so we must maintain them
65 // in sync manually... of course, the list had been there before the base
66 // class which explains it but it still would be nice to do something
69 class wxGtkNotebookPage
: public wxObject
75 m_page
= (GtkNotebookPage
*) NULL
;
76 m_box
= (GtkWidget
*) NULL
;
81 GtkNotebookPage
*m_page
;
83 GtkWidget
*m_box
; // in which the label and image are packed
87 #include "wx/listimpl.cpp"
88 WX_DEFINE_LIST(wxGtkNotebookPagesList
)
91 //-----------------------------------------------------------------------------
93 //-----------------------------------------------------------------------------
96 static void gtk_notebook_page_change_callback(GtkNotebook
*WXUNUSED(widget
),
97 GtkNotebookPage
*WXUNUSED(page
),
99 wxNotebook
*notebook
)
101 // are you trying to call SetSelection() from a notebook event handler?
103 wxCHECK_RET( !notebook
->m_inSwitchPage
,
104 _T("gtk_notebook_page_change_callback reentered") );
106 notebook
->m_inSwitchPage
= TRUE
;
108 wxapp_install_idle_handler();
110 int old
= notebook
->GetSelection();
112 wxNotebookEvent
eventChanging( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
,
113 notebook
->GetId(), page
, old
);
114 eventChanging
.SetEventObject( notebook
);
116 if ( (notebook
->GetEventHandler()->ProcessEvent(eventChanging
)) &&
117 !eventChanging
.IsAllowed() )
119 /* program doesn't allow the page change */
120 g_signal_stop_emission_by_name (notebook
->m_widget
,
123 else // change allowed
125 // make wxNotebook::GetSelection() return the correct (i.e. consistent
126 // with wxNotebookEvent::GetSelection()) value even though the page is
127 // not really changed in GTK+
128 notebook
->m_selection
= page
;
130 wxNotebookEvent
eventChanged( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
,
131 notebook
->GetId(), page
, old
);
132 eventChanged
.SetEventObject( notebook
);
133 notebook
->GetEventHandler()->ProcessEvent( eventChanged
);
136 notebook
->m_inSwitchPage
= FALSE
;
140 //-----------------------------------------------------------------------------
142 //-----------------------------------------------------------------------------
145 static void gtk_page_size_callback( GtkWidget
*WXUNUSED(widget
), GtkAllocation
* alloc
, wxWindow
*win
)
148 wxapp_install_idle_handler();
150 if ((win
->m_x
== alloc
->x
) &&
151 (win
->m_y
== alloc
->y
) &&
152 (win
->m_width
== alloc
->width
) &&
153 (win
->m_height
== alloc
->height
))
158 win
->SetSize( alloc
->x
, alloc
->y
, alloc
->width
, alloc
->height
);
160 /* GTK 1.2 up to version 1.2.5 is broken so that we have to call allocate
161 here in order to make repositioning after resizing to take effect. */
162 if ((gtk_major_version
== 1) &&
163 (gtk_minor_version
== 2) &&
164 (gtk_micro_version
< 6) &&
166 (GTK_WIDGET_REALIZED(win
->m_wxwindow
)))
168 gtk_widget_size_allocate( win
->m_wxwindow
, alloc
);
173 //-----------------------------------------------------------------------------
174 // "realize" from m_widget
175 //-----------------------------------------------------------------------------
179 gtk_notebook_realized_callback( GtkWidget
* WXUNUSED(widget
), wxWindow
*win
)
182 wxapp_install_idle_handler();
184 /* GTK 1.2 up to version 1.2.5 is broken so that we have to call a queue_resize
185 here in order to make repositioning before showing to take effect. */
186 gtk_widget_queue_resize( win
->m_widget
);
190 //-----------------------------------------------------------------------------
192 //-----------------------------------------------------------------------------
196 gtk_notebook_key_press_callback( GtkWidget
*widget
,
197 GdkEventKey
*gdk_event
,
198 wxNotebook
*notebook
)
201 wxapp_install_idle_handler();
203 if (!notebook
->m_hasVMT
) return FALSE
;
204 if (g_blockEventsOnDrag
) return FALSE
;
206 /* win is a control: tab can be propagated up */
207 if ((gdk_event
->keyval
== GDK_Left
) || (gdk_event
->keyval
== GDK_Right
))
210 int nMax
= notebook
->GetPageCount();
211 if ( nMax
-- ) // decrement it to get the last valid index
213 int nSel
= notebook
->GetSelection();
215 // change selection wrapping if it becomes invalid
216 page
= (gdk_event
->keyval
!= GDK_Left
) ? nSel
== nMax
? 0
221 else // notebook is empty, no next page
226 // m_selection = page;
227 gtk_notebook_set_current_page( GTK_NOTEBOOK(widget
), page
);
229 g_signal_stop_emission_by_name (widget
, "key_press_event");
233 /* win is a control: tab can be propagated up */
234 if ((gdk_event
->keyval
== GDK_Tab
) || (gdk_event
->keyval
== GDK_ISO_Left_Tab
))
236 int sel
= notebook
->GetSelection();
239 wxGtkNotebookPage
*nb_page
= notebook
->GetNotebookPage(sel
);
240 wxCHECK_MSG( nb_page
, FALSE
, _T("invalid selection in wxNotebook") );
242 wxNavigationKeyEvent event
;
243 event
.SetEventObject( notebook
);
244 /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
245 event
.SetDirection( (gdk_event
->keyval
== GDK_Tab
) );
246 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
247 event
.SetWindowChange( (gdk_event
->state
& GDK_CONTROL_MASK
) ||
248 (gdk_event
->keyval
== GDK_Left
) || (gdk_event
->keyval
== GDK_Right
) );
249 event
.SetCurrentFocus( notebook
);
251 wxNotebookPage
*client
= notebook
->GetPage(sel
);
252 if ( !client
->GetEventHandler()->ProcessEvent( event
) )
257 g_signal_stop_emission_by_name (widget
, "key_press_event");
265 //-----------------------------------------------------------------------------
266 // InsertChild callback for wxNotebook
267 //-----------------------------------------------------------------------------
269 static void wxInsertChildInNotebook( wxNotebook
* parent
, wxWindow
* child
)
271 // Hack Alert! (Part I): This sets the notebook as the parent of the child
272 // widget, and takes care of some details such as updating the state and
273 // style of the child to reflect its new location. We do this early
274 // because without it GetBestSize (which is used to set the initial size
275 // of controls if an explicit size is not given) will often report
276 // incorrect sizes since the widget's style context is not fully known.
277 // See bug #901694 for details
278 // (http://sourceforge.net/tracker/?func=detail&aid=901694&group_id=9863&atid=109863)
279 gtk_widget_set_parent(child
->m_widget
, parent
->m_widget
);
281 // NOTE: This should be considered a temporary workaround until we can
282 // work out the details and implement delaying the setting of the initial
283 // size of widgets until the size is really needed.
286 //-----------------------------------------------------------------------------
288 //-----------------------------------------------------------------------------
290 IMPLEMENT_DYNAMIC_CLASS(wxNotebook
,wxControl
)
292 BEGIN_EVENT_TABLE(wxNotebook
, wxControl
)
293 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey
)
296 void wxNotebook::Init()
299 m_inSwitchPage
= FALSE
;
301 m_imageList
= (wxImageList
*) NULL
;
303 m_themeEnabled
= TRUE
;
306 wxNotebook::wxNotebook()
311 wxNotebook::wxNotebook( wxWindow
*parent
, wxWindowID id
,
312 const wxPoint
& pos
, const wxSize
& size
,
313 long style
, const wxString
& name
)
316 Create( parent
, id
, pos
, size
, style
, name
);
319 wxNotebook::~wxNotebook()
324 bool wxNotebook::Create(wxWindow
*parent
, wxWindowID id
,
325 const wxPoint
& pos
, const wxSize
& size
,
326 long style
, const wxString
& name
)
329 m_acceptsFocus
= TRUE
;
330 m_insertCallback
= (wxInsertChildFunction
)wxInsertChildInNotebook
;
332 if (!PreCreation( parent
, pos
, size
) ||
333 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
335 wxFAIL_MSG( wxT("wxNoteBook creation failed") );
340 m_widget
= gtk_notebook_new();
342 gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget
), 1 );
344 g_signal_connect (m_widget
, "switch_page",
345 G_CALLBACK (gtk_notebook_page_change_callback
), this);
347 m_parent
->DoAddChild( this );
349 if (m_windowStyle
& wxBK_RIGHT
)
350 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_RIGHT
);
351 if (m_windowStyle
& wxBK_LEFT
)
352 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_LEFT
);
353 if (m_windowStyle
& wxBK_BOTTOM
)
354 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_BOTTOM
);
356 g_signal_connect (m_widget
, "key_press_event",
357 G_CALLBACK (gtk_notebook_key_press_callback
), this);
361 g_signal_connect (m_widget
, "realize",
362 G_CALLBACK (gtk_notebook_realized_callback
), this);
367 int wxNotebook::GetSelection() const
369 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid notebook") );
371 if ( m_selection
== -1 )
373 GList
*nb_pages
= GTK_NOTEBOOK(m_widget
)->children
;
375 if (g_list_length(nb_pages
) != 0)
377 GtkNotebook
*notebook
= GTK_NOTEBOOK(m_widget
);
379 gpointer cur
= notebook
->cur_page
;
382 wxConstCast(this, wxNotebook
)->m_selection
=
383 g_list_index( nb_pages
, cur
);
391 wxString
wxNotebook::GetPageText( size_t page
) const
393 wxCHECK_MSG( m_widget
!= NULL
, wxT(""), wxT("invalid notebook") );
395 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
397 return nb_page
->m_text
;
402 int wxNotebook::GetPageImage( size_t page
) const
404 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid notebook") );
406 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
408 return nb_page
->m_image
;
413 wxGtkNotebookPage
* wxNotebook::GetNotebookPage( int page
) const
415 wxCHECK_MSG( m_widget
!= NULL
, (wxGtkNotebookPage
*) NULL
, wxT("invalid notebook") );
417 wxCHECK_MSG( page
< (int)m_pagesData
.GetCount(), (wxGtkNotebookPage
*) NULL
, wxT("invalid notebook index") );
419 return m_pagesData
.Item(page
)->GetData();
422 int wxNotebook::SetSelection( size_t page
)
424 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid notebook") );
426 wxCHECK_MSG( page
< m_pagesData
.GetCount(), -1, wxT("invalid notebook index") );
428 int selOld
= GetSelection();
430 // cache the selection
432 gtk_notebook_set_current_page( GTK_NOTEBOOK(m_widget
), page
);
434 wxNotebookPage
*client
= GetPage(page
);
441 bool wxNotebook::SetPageText( size_t page
, const wxString
&text
)
443 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
445 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
447 wxCHECK_MSG( nb_page
, FALSE
, wxT("SetPageText: invalid page index") );
449 nb_page
->m_text
= text
;
451 gtk_label_set_text( nb_page
->m_label
, wxGTK_CONV( nb_page
->m_text
) );
456 bool wxNotebook::SetPageImage( size_t page
, int image
)
458 /* HvdH 28-12-98: now it works, but it's a bit of a kludge */
460 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
462 if (!nb_page
) return FALSE
;
464 /* Optimization posibility: return immediately if image unchanged.
465 * Not enabled because it may break existing (stupid) code that
466 * manipulates the imagelist to cycle images */
468 /* if (image == nb_page->m_image) return TRUE; */
470 /* For different cases:
471 1) no image -> no image
476 if (image
== -1 && nb_page
->m_image
== -1)
477 return TRUE
; /* Case 1): Nothing to do. */
479 GtkWidget
*pixmapwid
= (GtkWidget
*) NULL
;
481 if (nb_page
->m_image
!= -1)
483 /* Case 2) or 4). There is already an image in the gtkhbox. Let's find it */
485 GList
*child
= gtk_container_get_children(GTK_CONTAINER(nb_page
->m_box
));
488 if (GTK_IS_PIXMAP(child
->data
))
490 pixmapwid
= GTK_WIDGET(child
->data
);
496 /* We should have the pixmap widget now */
497 wxASSERT(pixmapwid
!= NULL
);
501 /* If there's no new widget, just remove the old from the box */
502 gtk_container_remove(GTK_CONTAINER(nb_page
->m_box
), pixmapwid
);
503 nb_page
->m_image
= -1;
505 return TRUE
; /* Case 2) */
509 /* Only cases 3) and 4) left */
510 wxASSERT( m_imageList
!= NULL
); /* Just in case */
512 /* Construct the new pixmap */
513 const wxBitmap
*bmp
= m_imageList
->GetBitmapPtr(image
);
514 GdkPixmap
*pixmap
= bmp
->GetPixmap();
515 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
516 if ( bmp
->GetMask() )
518 mask
= bmp
->GetMask()->GetBitmap();
521 if (pixmapwid
== NULL
)
523 /* Case 3) No old pixmap. Create a new one and prepend it to the hbox */
524 pixmapwid
= gtk_pixmap_new (pixmap
, mask
);
526 /* CHECKME: Are these pack flags okay? */
527 gtk_box_pack_start(GTK_BOX(nb_page
->m_box
), pixmapwid
, FALSE
, FALSE
, m_padding
);
528 gtk_widget_show(pixmapwid
);
532 /* Case 4) Simply replace the pixmap */
533 gtk_pixmap_set(GTK_PIXMAP(pixmapwid
), pixmap
, mask
);
536 nb_page
->m_image
= image
;
541 void wxNotebook::SetPageSize( const wxSize
&WXUNUSED(size
) )
543 wxFAIL_MSG( wxT("wxNotebook::SetPageSize not implemented") );
546 void wxNotebook::SetPadding( const wxSize
&padding
)
548 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid notebook") );
550 m_padding
= padding
.GetWidth();
553 for (i
=0; i
<int(GetPageCount()); i
++)
555 wxGtkNotebookPage
* nb_page
= GetNotebookPage(i
);
556 wxASSERT(nb_page
!= NULL
);
558 if (nb_page
->m_image
!= -1)
560 // gtk_box_set_child_packing sets padding on BOTH sides
561 // icon provides left padding, label provides center and right
562 int image
= nb_page
->m_image
;
564 SetPageImage(i
,image
);
566 wxASSERT(nb_page
->m_label
);
567 gtk_box_set_child_packing(GTK_BOX(nb_page
->m_box
),
568 GTK_WIDGET(nb_page
->m_label
),
569 FALSE
, FALSE
, m_padding
, GTK_PACK_END
);
573 void wxNotebook::SetTabSize(const wxSize
& WXUNUSED(sz
))
575 wxFAIL_MSG( wxT("wxNotebook::SetTabSize not implemented") );
578 bool wxNotebook::DeleteAllPages()
580 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
582 while (m_pagesData
.GetCount() > 0)
583 DeletePage( m_pagesData
.GetCount()-1 );
585 wxASSERT_MSG( GetPageCount() == 0, _T("all pages must have been deleted") );
587 InvalidateBestSize();
588 return wxNotebookBase::DeleteAllPages();
591 wxNotebookPage
*wxNotebook::DoRemovePage( size_t page
)
593 if ( m_selection
!= -1 && (size_t)m_selection
>= page
)
595 // the index will become invalid after the page is deleted
599 wxNotebookPage
*client
= wxNotebookBase::DoRemovePage(page
);
603 gtk_widget_ref( client
->m_widget
);
604 gtk_widget_unrealize( client
->m_widget
);
605 gtk_widget_unparent( client
->m_widget
);
607 // gtk_notebook_remove_page() sends "switch_page" signal with some strange
608 // new page index (when deleting selected page 0, new page is 1 although,
609 // clearly, the selection should stay 0), so suppress this
610 g_signal_handlers_disconnect_by_func (m_widget
,
611 (gpointer
) gtk_notebook_page_change_callback
,
614 gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget
), page
);
616 g_signal_connect (m_widget
, "switch_page",
617 G_CALLBACK (gtk_notebook_page_change_callback
), this);
619 wxGtkNotebookPage
* p
= GetNotebookPage(page
);
620 m_pagesData
.DeleteObject(p
);
626 bool wxNotebook::InsertPage( size_t position
,
628 const wxString
& text
,
632 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
634 wxCHECK_MSG( win
->GetParent() == this, FALSE
,
635 wxT("Can't add a page whose parent is not the notebook!") );
637 wxCHECK_MSG( position
<= GetPageCount(), FALSE
,
638 _T("invalid page index in wxNotebookPage::InsertPage()") );
640 // Hack Alert! (Part II): See above in wxInsertChildInNotebook callback
641 // why this has to be done. NOTE: using gtk_widget_unparent here does not
642 // work as it seems to undo too much and will cause errors in the
643 // gtk_notebook_insert_page below, so instead just clear the parent by
645 win
->m_widget
->parent
= NULL
;
647 // don't receive switch page during addition
648 g_signal_handlers_disconnect_by_func (m_widget
,
649 (gpointer
) gtk_notebook_page_change_callback
,
653 win
->SetThemeEnabled(TRUE
);
655 GtkNotebook
*notebook
= GTK_NOTEBOOK(m_widget
);
657 wxGtkNotebookPage
*nb_page
= new wxGtkNotebookPage();
659 if ( position
== GetPageCount() )
660 m_pagesData
.Append( nb_page
);
662 m_pagesData
.Insert( position
, nb_page
);
664 m_pages
.Insert(win
, position
);
666 nb_page
->m_box
= gtk_hbox_new( FALSE
, 1 );
667 gtk_container_border_width( GTK_CONTAINER(nb_page
->m_box
), 2 );
669 g_signal_connect (win
->m_widget
, "size_allocate",
670 G_CALLBACK (gtk_page_size_callback
), win
);
672 gtk_notebook_insert_page( notebook
, win
->m_widget
, nb_page
->m_box
, position
);
674 nb_page
->m_page
= (GtkNotebookPage
*) g_list_last(notebook
->children
)->data
;
676 /* set the label image */
677 nb_page
->m_image
= imageId
;
681 wxASSERT( m_imageList
!= NULL
);
683 const wxBitmap
*bmp
= m_imageList
->GetBitmapPtr(imageId
);
684 GdkPixmap
*pixmap
= bmp
->GetPixmap();
685 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
686 if ( bmp
->GetMask() )
688 mask
= bmp
->GetMask()->GetBitmap();
691 GtkWidget
*pixmapwid
= gtk_pixmap_new (pixmap
, mask
);
693 gtk_box_pack_start(GTK_BOX(nb_page
->m_box
), pixmapwid
, FALSE
, FALSE
, m_padding
);
695 gtk_widget_show(pixmapwid
);
698 /* set the label text */
700 nb_page
->m_text
= text
;
701 if (nb_page
->m_text
.IsEmpty()) nb_page
->m_text
= wxT("");
703 nb_page
->m_label
= GTK_LABEL( gtk_label_new(wxGTK_CONV(nb_page
->m_text
)) );
704 gtk_box_pack_end( GTK_BOX(nb_page
->m_box
), GTK_WIDGET(nb_page
->m_label
), FALSE
, FALSE
, m_padding
);
706 /* apply current style */
707 GtkRcStyle
*style
= CreateWidgetStyle();
710 gtk_widget_modify_style(GTK_WIDGET(nb_page
->m_label
), style
);
711 gtk_rc_style_unref(style
);
715 gtk_widget_show( GTK_WIDGET(nb_page
->m_label
) );
716 if (select
&& (m_pagesData
.GetCount() > 1))
718 SetSelection( position
);
721 g_signal_connect (m_widget
, "switch_page",
722 G_CALLBACK (gtk_notebook_page_change_callback
), this);
724 InvalidateBestSize();
728 // helper for HitTest(): check if the point lies inside the given widget which
729 // is the child of the notebook whose position and border size are passed as
732 IsPointInsideWidget(const wxPoint
& pt
, GtkWidget
*w
,
733 gint x
, gint y
, gint border
= 0)
736 (pt
.x
>= w
->allocation
.x
- x
- border
) &&
737 (pt
.x
<= w
->allocation
.x
- x
+ border
+ w
->allocation
.width
) &&
738 (pt
.y
>= w
->allocation
.y
- y
- border
) &&
739 (pt
.y
<= w
->allocation
.y
- y
+ border
+ w
->allocation
.height
);
742 int wxNotebook::HitTest(const wxPoint
& pt
, long *flags
) const
744 const gint x
= m_widget
->allocation
.x
;
745 const gint y
= m_widget
->allocation
.y
;
747 const size_t count
= GetPageCount();
750 GtkNotebook
* notebook
= GTK_NOTEBOOK(m_widget
);
751 if (gtk_notebook_get_scrollable(notebook
))
752 i
= g_list_position( notebook
->children
, notebook
->first_tab
);
754 for ( ; i
< count
; i
++ )
756 wxGtkNotebookPage
* nb_page
= GetNotebookPage(i
);
757 GtkWidget
*box
= nb_page
->m_box
;
759 const gint border
= gtk_container_get_border_width(GTK_CONTAINER(box
));
761 if ( IsPointInsideWidget(pt
, box
, x
, y
, border
) )
763 // ok, we're inside this tab -- now find out where, if needed
766 GtkWidget
*pixmap
= NULL
;
768 GList
*children
= gtk_container_get_children(GTK_CONTAINER(box
));
769 for ( GList
*child
= children
; child
; child
= child
->next
)
771 if ( GTK_IS_PIXMAP(child
->data
) )
773 pixmap
= GTK_WIDGET(child
->data
);
779 g_list_free(children
);
781 if ( pixmap
&& IsPointInsideWidget(pt
, pixmap
, x
, y
) )
783 *flags
= wxNB_HITTEST_ONICON
;
785 else if ( IsPointInsideWidget(pt
, GTK_WIDGET(nb_page
->m_label
), x
, y
) )
787 *flags
= wxNB_HITTEST_ONLABEL
;
791 *flags
= wxNB_HITTEST_ONITEM
;
800 *flags
= wxNB_HITTEST_NOWHERE
;
805 void wxNotebook::OnNavigationKey(wxNavigationKeyEvent
& event
)
807 if (event
.IsWindowChange())
808 AdvanceSelection( event
.GetDirection() );
813 #if wxUSE_CONSTRAINTS
815 // override these 2 functions to do nothing: everything is done in OnSize
816 void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse
) )
818 // don't set the sizes of the pages - their correct size is not yet known
819 wxControl::SetConstraintSizes(FALSE
);
822 bool wxNotebook::DoPhase( int WXUNUSED(nPhase
) )
829 void wxNotebook::DoApplyWidgetStyle(GtkRcStyle
*style
)
831 gtk_widget_modify_style(m_widget
, style
);
832 size_t cnt
= m_pagesData
.GetCount();
833 for (size_t i
= 0; i
< cnt
; i
++)
834 gtk_widget_modify_style(GTK_WIDGET(GetNotebookPage(i
)->m_label
), style
);
837 bool wxNotebook::IsOwnGtkWindow( GdkWindow
*window
)
839 return ((m_widget
->window
== window
) ||
840 GTK_NOTEBOOK(m_widget
)->event_window
== window
);
845 wxNotebook::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
847 return GetDefaultAttributesFromGTKWidget(gtk_notebook_new
);
850 //-----------------------------------------------------------------------------
852 //-----------------------------------------------------------------------------
854 IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent
, wxNotifyEvent
)