1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling, Vadim Zeitlin
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11 #pragma implementation "notebook.h"
14 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
17 #include "wx/notebook.h"
23 #include "wx/imaglist.h"
26 #include "wx/bitmap.h"
27 #include "wx/fontutil.h"
29 #include "wx/gtk/private.h"
30 #include "wx/gtk/win_gtk.h"
32 #include <gdk/gdkkeysyms.h>
34 #include "wx/msgdlg.h"
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
)
41 DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
)
43 //-----------------------------------------------------------------------------
45 //-----------------------------------------------------------------------------
47 extern void wxapp_install_idle_handler();
50 //-----------------------------------------------------------------------------
52 //-----------------------------------------------------------------------------
54 extern bool g_blockEventsOnDrag
;
56 //-----------------------------------------------------------------------------
58 //-----------------------------------------------------------------------------
60 // VZ: this is rather ugly as we keep the pages themselves in an array (it
61 // allows us to have quite a few functions implemented in the base class)
62 // but the page data is kept in a separate list, so we must maintain them
63 // in sync manually... of course, the list had been there before the base
64 // class which explains it but it still would be nice to do something
67 class wxGtkNotebookPage
: public wxObject
73 m_page
= (GtkNotebookPage
*) NULL
;
74 m_box
= (GtkWidget
*) NULL
;
75 m_labelStyle
= (GtkStyle
*) NULL
;
81 gtk_style_unref( m_labelStyle
);
84 bool SetFont(const wxFont
& font
);
88 GtkNotebookPage
*m_page
;
90 GtkWidget
*m_box
; // in which the label and image are packed
91 GtkStyle
*m_labelStyle
;
95 bool wxGtkNotebookPage::SetFont(const wxFont
& font
)
102 GtkStyle
*remake
= gtk_style_copy( m_labelStyle
);
105 remake
->klass
= m_labelStyle
->klass
;
108 gtk_style_unref( m_labelStyle
);
109 m_labelStyle
= remake
;
113 GtkStyle
*def
= gtk_rc_get_style( GTK_WIDGET(m_label
) );
116 def
= gtk_widget_get_default_style();
118 m_labelStyle
= gtk_style_copy( def
);
120 // FIXME: no more klass in 2.0
122 m_labelStyle
->klass
= def
->klass
;
127 pango_font_description_free( m_labelStyle
->font_desc
);
128 m_labelStyle
->font_desc
= pango_font_description_copy( font
.GetNativeFontInfo()->description
);
130 gdk_font_unref( m_labelStyle
->font
);
131 m_labelStyle
->font
= gdk_font_ref( font
.GetInternalFont( 1.0 ) );
134 gtk_widget_set_style( GTK_WIDGET(m_label
), m_labelStyle
);
140 #include "wx/listimpl.cpp"
141 WX_DEFINE_LIST(wxGtkNotebookPagesList
);
144 //-----------------------------------------------------------------------------
146 //-----------------------------------------------------------------------------
148 static void gtk_notebook_page_change_callback(GtkNotebook
*WXUNUSED(widget
),
149 GtkNotebookPage
*WXUNUSED(page
),
151 wxNotebook
*notebook
)
153 // are you trying to call SetSelection() from a notebook event handler?
155 wxCHECK_RET( !notebook
->m_inSwitchPage
,
156 _T("gtk_notebook_page_change_callback reentered") );
158 notebook
->m_inSwitchPage
= TRUE
;
160 wxapp_install_idle_handler();
162 int old
= notebook
->GetSelection();
164 wxNotebookEvent
eventChanging( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
,
165 notebook
->GetId(), page
, old
);
166 eventChanging
.SetEventObject( notebook
);
168 if ( (notebook
->GetEventHandler()->ProcessEvent(eventChanging
)) &&
169 !eventChanging
.IsAllowed() )
171 /* program doesn't allow the page change */
172 gtk_signal_emit_stop_by_name( GTK_OBJECT(notebook
->m_widget
),
175 else // change allowed
177 // make wxNotebook::GetSelection() return the correct (i.e. consistent
178 // with wxNotebookEvent::GetSelection()) value even though the page is
179 // not really changed in GTK+
180 notebook
->m_selection
= page
;
182 wxNotebookEvent
eventChanged( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
,
183 notebook
->GetId(), page
, old
);
184 eventChanged
.SetEventObject( notebook
);
185 notebook
->GetEventHandler()->ProcessEvent( eventChanged
);
188 notebook
->m_inSwitchPage
= FALSE
;
191 //-----------------------------------------------------------------------------
193 //-----------------------------------------------------------------------------
195 static void gtk_page_size_callback( GtkWidget
*WXUNUSED(widget
), GtkAllocation
* alloc
, wxWindow
*win
)
198 wxapp_install_idle_handler();
200 if ((win
->m_x
== alloc
->x
) &&
201 (win
->m_y
== alloc
->y
) &&
202 (win
->m_width
== alloc
->width
) &&
203 (win
->m_height
== alloc
->height
))
208 win
->SetSize( alloc
->x
, alloc
->y
, alloc
->width
, alloc
->height
);
210 /* GTK 1.2 up to version 1.2.5 is broken so that we have to call allocate
211 here in order to make repositioning after resizing to take effect. */
212 if ((gtk_major_version
== 1) &&
213 (gtk_minor_version
== 2) &&
214 (gtk_micro_version
< 6) &&
216 (GTK_WIDGET_REALIZED(win
->m_wxwindow
)))
218 gtk_widget_size_allocate( win
->m_wxwindow
, alloc
);
222 //-----------------------------------------------------------------------------
223 // "realize" from m_widget
224 //-----------------------------------------------------------------------------
227 gtk_notebook_realized_callback( GtkWidget
* WXUNUSED(widget
), wxWindow
*win
)
230 wxapp_install_idle_handler();
232 /* GTK 1.2 up to version 1.2.5 is broken so that we have to call a queue_resize
233 here in order to make repositioning before showing to take effect. */
234 gtk_widget_queue_resize( win
->m_widget
);
239 //-----------------------------------------------------------------------------
241 //-----------------------------------------------------------------------------
243 static gint
gtk_notebook_key_press_callback( GtkWidget
*widget
, GdkEventKey
*gdk_event
, wxNotebook
*win
)
246 wxapp_install_idle_handler();
248 if (!win
->m_hasVMT
) return FALSE
;
249 if (g_blockEventsOnDrag
) return FALSE
;
251 /* win is a control: tab can be propagated up */
252 if ((gdk_event
->keyval
== GDK_Tab
) || (gdk_event
->keyval
== GDK_ISO_Left_Tab
))
254 int sel
= win
->GetSelection();
257 wxGtkNotebookPage
*nb_page
= win
->GetNotebookPage(sel
);
258 wxCHECK_MSG( nb_page
, FALSE
, _T("invalid selection in wxNotebook") );
260 wxNavigationKeyEvent event
;
261 event
.SetEventObject( win
);
262 /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
263 event
.SetDirection( (gdk_event
->keyval
== GDK_Tab
) );
264 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
265 event
.SetWindowChange( (gdk_event
->state
& GDK_CONTROL_MASK
) );
266 event
.SetCurrentFocus( win
);
268 wxNotebookPage
*client
= win
->GetPage(sel
);
269 if ( !client
->GetEventHandler()->ProcessEvent( event
) )
274 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "key_press_event" );
281 //-----------------------------------------------------------------------------
282 // InsertChild callback for wxNotebook
283 //-----------------------------------------------------------------------------
285 static void wxInsertChildInNotebook( wxNotebook
* parent
, wxWindow
* child
)
287 // Hack alert! We manually set the child window
288 // parent field so that GTK can query the
289 // notebook's style and font. Without that, GetBestSize could return
290 // incorrect size, see bug #901694 for details
291 // (http://sourceforge.net/tracker/?func=detail&aid=901694&group_id=9863&atid=109863)
292 child
->m_widget
->parent
= parent
->m_widget
;
295 //-----------------------------------------------------------------------------
297 //-----------------------------------------------------------------------------
299 IMPLEMENT_DYNAMIC_CLASS(wxNotebook
,wxControl
)
301 BEGIN_EVENT_TABLE(wxNotebook
, wxControl
)
302 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey
)
305 void wxNotebook::Init()
308 m_inSwitchPage
= FALSE
;
310 m_imageList
= (wxImageList
*) NULL
;
312 m_themeEnabled
= TRUE
;
315 wxNotebook::wxNotebook()
320 wxNotebook::wxNotebook( wxWindow
*parent
, wxWindowID id
,
321 const wxPoint
& pos
, const wxSize
& size
,
322 long style
, const wxString
& name
)
325 Create( parent
, id
, pos
, size
, style
, name
);
328 wxNotebook::~wxNotebook()
333 bool wxNotebook::Create(wxWindow
*parent
, wxWindowID id
,
334 const wxPoint
& pos
, const wxSize
& size
,
335 long style
, const wxString
& name
)
338 m_acceptsFocus
= TRUE
;
339 m_insertCallback
= (wxInsertChildFunction
)wxInsertChildInNotebook
;
341 if (!PreCreation( parent
, pos
, size
) ||
342 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
344 wxFAIL_MSG( wxT("wxNoteBook creation failed") );
349 m_widget
= gtk_notebook_new();
351 gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget
), 1 );
353 gtk_signal_connect( GTK_OBJECT(m_widget
), "switch_page",
354 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
)this );
356 m_parent
->DoAddChild( this );
358 if (m_windowStyle
& wxNB_RIGHT
)
359 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_RIGHT
);
360 if (m_windowStyle
& wxNB_LEFT
)
361 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_LEFT
);
362 if (m_windowStyle
& wxNB_BOTTOM
)
363 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_BOTTOM
);
365 gtk_signal_connect( GTK_OBJECT(m_widget
), "key_press_event",
366 GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback
), (gpointer
)this );
370 SetFont( parent
->GetFont() );
372 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
373 GTK_SIGNAL_FUNC(gtk_notebook_realized_callback
), (gpointer
) this );
380 int wxNotebook::GetSelection() const
382 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid notebook") );
384 if ( m_selection
== -1 )
386 GList
*nb_pages
= GTK_NOTEBOOK(m_widget
)->children
;
388 if (g_list_length(nb_pages
) != 0)
390 GtkNotebook
*notebook
= GTK_NOTEBOOK(m_widget
);
392 gpointer cur
= notebook
->cur_page
;
395 wxConstCast(this, wxNotebook
)->m_selection
=
396 g_list_index( nb_pages
, cur
);
404 wxString
wxNotebook::GetPageText( size_t page
) const
406 wxCHECK_MSG( m_widget
!= NULL
, wxT(""), wxT("invalid notebook") );
408 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
410 return nb_page
->m_text
;
415 int wxNotebook::GetPageImage( size_t page
) const
417 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid notebook") );
419 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
421 return nb_page
->m_image
;
426 wxGtkNotebookPage
* wxNotebook::GetNotebookPage( int page
) const
428 wxCHECK_MSG( m_widget
!= NULL
, (wxGtkNotebookPage
*) NULL
, wxT("invalid notebook") );
430 wxCHECK_MSG( page
< (int)m_pagesData
.GetCount(), (wxGtkNotebookPage
*) NULL
, wxT("invalid notebook index") );
432 return m_pagesData
.Item(page
)->GetData();
435 int wxNotebook::SetSelection( size_t page
)
437 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid notebook") );
439 wxCHECK_MSG( page
< m_pagesData
.GetCount(), -1, wxT("invalid notebook index") );
441 int selOld
= GetSelection();
443 // cache the selection
445 gtk_notebook_set_page( GTK_NOTEBOOK(m_widget
), page
);
447 wxNotebookPage
*client
= GetPage(page
);
454 bool wxNotebook::SetPageText( size_t page
, const wxString
&text
)
456 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
458 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
460 wxCHECK_MSG( nb_page
, FALSE
, wxT("SetPageText: invalid page index") );
462 nb_page
->m_text
= text
;
464 gtk_label_set( nb_page
->m_label
, wxGTK_CONV( nb_page
->m_text
) );
469 bool wxNotebook::SetPageImage( size_t page
, int image
)
471 /* HvdH 28-12-98: now it works, but it's a bit of a kludge */
473 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
475 if (!nb_page
) return FALSE
;
477 /* Optimization posibility: return immediately if image unchanged.
478 * Not enabled because it may break existing (stupid) code that
479 * manipulates the imagelist to cycle images */
481 /* if (image == nb_page->m_image) return TRUE; */
483 /* For different cases:
484 1) no image -> no image
489 if (image
== -1 && nb_page
->m_image
== -1)
490 return TRUE
; /* Case 1): Nothing to do. */
492 GtkWidget
*pixmapwid
= (GtkWidget
*) NULL
;
494 if (nb_page
->m_image
!= -1)
496 /* Case 2) or 4). There is already an image in the gtkhbox. Let's find it */
498 GList
*child
= gtk_container_children(GTK_CONTAINER(nb_page
->m_box
));
501 if (GTK_IS_PIXMAP(child
->data
))
503 pixmapwid
= GTK_WIDGET(child
->data
);
509 /* We should have the pixmap widget now */
510 wxASSERT(pixmapwid
!= NULL
);
514 /* If there's no new widget, just remove the old from the box */
515 gtk_container_remove(GTK_CONTAINER(nb_page
->m_box
), pixmapwid
);
516 nb_page
->m_image
= -1;
518 return TRUE
; /* Case 2) */
522 /* Only cases 3) and 4) left */
523 wxASSERT( m_imageList
!= NULL
); /* Just in case */
525 /* Construct the new pixmap */
526 const wxBitmap
*bmp
= m_imageList
->GetBitmap(image
);
527 GdkPixmap
*pixmap
= bmp
->GetPixmap();
528 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
529 if ( bmp
->GetMask() )
531 mask
= bmp
->GetMask()->GetBitmap();
534 if (pixmapwid
== NULL
)
536 /* Case 3) No old pixmap. Create a new one and prepend it to the hbox */
537 pixmapwid
= gtk_pixmap_new (pixmap
, mask
);
539 /* CHECKME: Are these pack flags okay? */
540 gtk_box_pack_start(GTK_BOX(nb_page
->m_box
), pixmapwid
, FALSE
, FALSE
, m_padding
);
541 gtk_widget_show(pixmapwid
);
545 /* Case 4) Simply replace the pixmap */
546 gtk_pixmap_set(GTK_PIXMAP(pixmapwid
), pixmap
, mask
);
549 nb_page
->m_image
= image
;
554 void wxNotebook::SetPageSize( const wxSize
&WXUNUSED(size
) )
556 wxFAIL_MSG( wxT("wxNotebook::SetPageSize not implemented") );
559 void wxNotebook::SetPadding( const wxSize
&padding
)
561 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid notebook") );
563 m_padding
= padding
.GetWidth();
566 for (i
=0; i
<int(GetPageCount()); i
++)
568 wxGtkNotebookPage
* nb_page
= GetNotebookPage(i
);
569 wxASSERT(nb_page
!= NULL
);
571 if (nb_page
->m_image
!= -1)
573 // gtk_box_set_child_packing sets padding on BOTH sides
574 // icon provides left padding, label provides center and right
575 int image
= nb_page
->m_image
;
577 SetPageImage(i
,image
);
579 wxASSERT(nb_page
->m_label
);
580 gtk_box_set_child_packing(GTK_BOX(nb_page
->m_box
),
581 GTK_WIDGET(nb_page
->m_label
),
582 FALSE
, FALSE
, m_padding
, GTK_PACK_END
);
586 void wxNotebook::SetTabSize(const wxSize
& WXUNUSED(sz
))
588 wxFAIL_MSG( wxT("wxNotebook::SetTabSize not implemented") );
591 bool wxNotebook::DeleteAllPages()
593 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
595 while (m_pagesData
.GetCount() > 0)
596 DeletePage( m_pagesData
.GetCount()-1 );
598 wxASSERT_MSG( GetPageCount() == 0, _T("all pages must have been deleted") );
600 return wxNotebookBase::DeleteAllPages();
603 bool wxNotebook::DeletePage( size_t page
)
605 if ( m_selection
== (int)m_pagesData
.GetCount() - 1 )
607 // the index will become invalid after the page is deleted
611 // it will call our DoRemovePage() to do the real work
612 return wxNotebookBase::DeletePage(page
);
615 wxNotebookPage
*wxNotebook::DoRemovePage( size_t page
)
617 wxNotebookPage
*client
= wxNotebookBase::DoRemovePage(page
);
621 gtk_widget_ref( client
->m_widget
);
622 gtk_widget_unrealize( client
->m_widget
);
623 gtk_widget_unparent( client
->m_widget
);
625 // gtk_notebook_remove_page() sends "switch_page" signal with some strange
626 // new page index (when deleting selected page 0, new page is 1 although,
627 // clearly, the selection should stay 0), so suppress this
628 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget
),
629 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
) this );
631 gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget
), page
);
633 gtk_signal_connect( GTK_OBJECT(m_widget
), "switch_page",
634 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
)this );
636 wxGtkNotebookPage
* p
= GetNotebookPage(page
);
637 m_pagesData
.DeleteObject(p
);
643 bool wxNotebook::InsertPage( size_t position
,
645 const wxString
& text
,
649 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
651 wxCHECK_MSG( win
->GetParent() == this, FALSE
,
652 wxT("Can't add a page whose parent is not the notebook!") );
654 wxCHECK_MSG( position
<= GetPageCount(), FALSE
,
655 _T("invalid page index in wxNotebookPage::InsertPage()") );
657 // Hack alert part II! See above in InsertChildInNotebook
658 // callback why this has to be done.
659 win
->m_widget
->parent
= NULL
;
661 // don't receive switch page during addition
662 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget
),
663 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
) this );
666 win
->SetThemeEnabled(TRUE
);
668 GtkNotebook
*notebook
= GTK_NOTEBOOK(m_widget
);
670 wxGtkNotebookPage
*nb_page
= new wxGtkNotebookPage();
672 if ( position
== GetPageCount() )
673 m_pagesData
.Append( nb_page
);
675 m_pagesData
.Insert( m_pagesData
.Item( position
), nb_page
);
677 m_pages
.Insert(win
, position
);
679 nb_page
->m_box
= gtk_hbox_new( FALSE
, 1 );
680 gtk_container_border_width( GTK_CONTAINER(nb_page
->m_box
), 2 );
682 gtk_signal_connect( GTK_OBJECT(win
->m_widget
), "size_allocate",
683 GTK_SIGNAL_FUNC(gtk_page_size_callback
), (gpointer
)win
);
686 // On VMS position is unsigned and thus always positive
688 gtk_notebook_append_page( notebook
, win
->m_widget
, nb_page
->m_box
);
691 gtk_notebook_insert_page( notebook
, win
->m_widget
, nb_page
->m_box
, position
);
693 nb_page
->m_page
= (GtkNotebookPage
*) g_list_last(notebook
->children
)->data
;
695 /* set the label image */
696 nb_page
->m_image
= imageId
;
700 wxASSERT( m_imageList
!= NULL
);
702 const wxBitmap
*bmp
= m_imageList
->GetBitmap(imageId
);
703 GdkPixmap
*pixmap
= bmp
->GetPixmap();
704 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
705 if ( bmp
->GetMask() )
707 mask
= bmp
->GetMask()->GetBitmap();
710 GtkWidget
*pixmapwid
= gtk_pixmap_new (pixmap
, mask
);
712 gtk_box_pack_start(GTK_BOX(nb_page
->m_box
), pixmapwid
, FALSE
, FALSE
, m_padding
);
714 gtk_widget_show(pixmapwid
);
717 /* set the label text */
719 nb_page
->m_text
= text
;
720 if (nb_page
->m_text
.IsEmpty()) nb_page
->m_text
= wxT("");
722 nb_page
->m_label
= GTK_LABEL( gtk_label_new(wxGTK_CONV(nb_page
->m_text
)) );
723 nb_page
->SetFont(GetFont());
724 gtk_box_pack_end( GTK_BOX(nb_page
->m_box
), GTK_WIDGET(nb_page
->m_label
), FALSE
, FALSE
, m_padding
);
727 gtk_widget_show( GTK_WIDGET(nb_page
->m_label
) );
728 if (select
&& (m_pagesData
.GetCount() > 1))
731 // On VMS position is unsigned and thus always positive
733 SetSelection( GetPageCount()-1 );
736 SetSelection( position
);
739 gtk_signal_connect( GTK_OBJECT(m_widget
), "switch_page",
740 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
)this );
745 // helper for HitTest(): check if the point lies inside the given widget which
746 // is the child of the notebook whose position and border size are passed as
749 IsPointInsideWidget(const wxPoint
& pt
, GtkWidget
*w
,
750 gint x
, gint y
, gint border
= 0)
753 (pt
.x
>= w
->allocation
.x
- x
- border
) &&
754 (pt
.x
<= w
->allocation
.x
- x
+ border
+ w
->allocation
.width
) &&
755 (pt
.y
>= w
->allocation
.y
- y
- border
) &&
756 (pt
.y
<= w
->allocation
.y
- y
+ border
+ w
->allocation
.height
);
759 int wxNotebook::HitTest(const wxPoint
& pt
, long *flags
) const
761 const gint x
= m_widget
->allocation
.x
;
762 const gint y
= m_widget
->allocation
.y
;
764 const size_t count
= GetPageCount();
765 for ( size_t i
= 0; i
< count
; i
++ )
767 wxGtkNotebookPage
* nb_page
= GetNotebookPage(i
);
768 GtkWidget
*box
= nb_page
->m_box
;
770 // VZ: don't know how to find the border width in GTK+ 1.2
772 const gint border
= gtk_container_get_border_width(GTK_CONTAINER(box
));
774 const gint border
= 0;
776 if ( IsPointInsideWidget(pt
, box
, x
, y
, border
) )
778 // ok, we're inside this tab -- now find out where, if needed
781 GtkWidget
*pixmap
= NULL
;
783 GList
*children
= gtk_container_children(GTK_CONTAINER(box
));
784 for ( GList
*child
= children
; child
; child
= child
->next
)
786 if ( GTK_IS_PIXMAP(child
->data
) )
788 pixmap
= GTK_WIDGET(child
->data
);
794 g_list_free(children
);
796 if ( pixmap
&& IsPointInsideWidget(pt
, pixmap
, x
, y
) )
798 *flags
= wxNB_HITTEST_ONICON
;
800 else if ( IsPointInsideWidget(pt
, GTK_WIDGET(nb_page
->m_label
), x
, y
) )
802 *flags
= wxNB_HITTEST_ONLABEL
;
806 *flags
= wxNB_HITTEST_ONITEM
;
815 *flags
= wxNB_HITTEST_NOWHERE
;
820 void wxNotebook::OnNavigationKey(wxNavigationKeyEvent
& event
)
822 if (event
.IsWindowChange())
823 AdvanceSelection( event
.GetDirection() );
828 #if wxUSE_CONSTRAINTS
830 // override these 2 functions to do nothing: everything is done in OnSize
831 void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse
) )
833 // don't set the sizes of the pages - their correct size is not yet known
834 wxControl::SetConstraintSizes(FALSE
);
837 bool wxNotebook::DoPhase( int WXUNUSED(nPhase
) )
844 void wxNotebook::ApplyWidgetStyle()
846 // TODO, font for labels etc
849 gtk_widget_set_style( m_widget
, m_widgetStyle
);
852 bool wxNotebook::IsOwnGtkWindow( GdkWindow
*window
)
854 return ((m_widget
->window
== window
) ||
855 (NOTEBOOK_PANEL(m_widget
) == window
));
858 bool wxNotebook::SetFont(const wxFont
& font
)
860 bool rc
=wxNotebookBase::SetFont(font
);
865 for (i
=0 ; i
< m_pagesData
.GetCount() ; i
++)
866 GetNotebookPage(i
)->SetFont(font
);
871 //-----------------------------------------------------------------------------
873 //-----------------------------------------------------------------------------
875 IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent
, wxNotifyEvent
)