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
;
77 bool SetFont(const wxFont
& font
);
81 GtkNotebookPage
*m_page
;
83 GtkWidget
*m_box
; // in which the label and image are packed
87 bool wxGtkNotebookPage::SetFont(const wxFont
& font
)
93 gtk_widget_modify_font(GTK_WIDGET(m_label
),
94 font
.GetNativeFontInfo()->description
);
96 GtkRcStyle
*style
= gtk_rc_style_new();
98 g_strdup(font
.GetNativeFontInfo()->GetXFontName().c_str());
99 gtk_widget_modify_style(GTK_WIDGET(m_label
), style
);
100 gtk_rc_style_unref(style
);
107 #include "wx/listimpl.cpp"
108 WX_DEFINE_LIST(wxGtkNotebookPagesList
);
111 //-----------------------------------------------------------------------------
113 //-----------------------------------------------------------------------------
115 static void gtk_notebook_page_change_callback(GtkNotebook
*WXUNUSED(widget
),
116 GtkNotebookPage
*WXUNUSED(page
),
118 wxNotebook
*notebook
)
120 // are you trying to call SetSelection() from a notebook event handler?
122 wxCHECK_RET( !notebook
->m_inSwitchPage
,
123 _T("gtk_notebook_page_change_callback reentered") );
125 notebook
->m_inSwitchPage
= TRUE
;
127 wxapp_install_idle_handler();
129 int old
= notebook
->GetSelection();
131 wxNotebookEvent
eventChanging( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
,
132 notebook
->GetId(), page
, old
);
133 eventChanging
.SetEventObject( notebook
);
135 if ( (notebook
->GetEventHandler()->ProcessEvent(eventChanging
)) &&
136 !eventChanging
.IsAllowed() )
138 /* program doesn't allow the page change */
139 gtk_signal_emit_stop_by_name( GTK_OBJECT(notebook
->m_widget
),
142 else // change allowed
144 // make wxNotebook::GetSelection() return the correct (i.e. consistent
145 // with wxNotebookEvent::GetSelection()) value even though the page is
146 // not really changed in GTK+
147 notebook
->m_selection
= page
;
149 wxNotebookEvent
eventChanged( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
,
150 notebook
->GetId(), page
, old
);
151 eventChanged
.SetEventObject( notebook
);
152 notebook
->GetEventHandler()->ProcessEvent( eventChanged
);
155 notebook
->m_inSwitchPage
= FALSE
;
158 //-----------------------------------------------------------------------------
160 //-----------------------------------------------------------------------------
162 static void gtk_page_size_callback( GtkWidget
*WXUNUSED(widget
), GtkAllocation
* alloc
, wxWindow
*win
)
165 wxapp_install_idle_handler();
167 if ((win
->m_x
== alloc
->x
) &&
168 (win
->m_y
== alloc
->y
) &&
169 (win
->m_width
== alloc
->width
) &&
170 (win
->m_height
== alloc
->height
))
175 win
->SetSize( alloc
->x
, alloc
->y
, alloc
->width
, alloc
->height
);
177 /* GTK 1.2 up to version 1.2.5 is broken so that we have to call allocate
178 here in order to make repositioning after resizing to take effect. */
179 if ((gtk_major_version
== 1) &&
180 (gtk_minor_version
== 2) &&
181 (gtk_micro_version
< 6) &&
183 (GTK_WIDGET_REALIZED(win
->m_wxwindow
)))
185 gtk_widget_size_allocate( win
->m_wxwindow
, alloc
);
189 //-----------------------------------------------------------------------------
190 // "realize" from m_widget
191 //-----------------------------------------------------------------------------
194 gtk_notebook_realized_callback( GtkWidget
* WXUNUSED(widget
), wxWindow
*win
)
197 wxapp_install_idle_handler();
199 /* GTK 1.2 up to version 1.2.5 is broken so that we have to call a queue_resize
200 here in order to make repositioning before showing to take effect. */
201 gtk_widget_queue_resize( win
->m_widget
);
206 //-----------------------------------------------------------------------------
208 //-----------------------------------------------------------------------------
210 static gint
gtk_notebook_key_press_callback( GtkWidget
*widget
, GdkEventKey
*gdk_event
, wxNotebook
*win
)
213 wxapp_install_idle_handler();
215 if (!win
->m_hasVMT
) return FALSE
;
216 if (g_blockEventsOnDrag
) return FALSE
;
218 /* win is a control: tab can be propagated up */
219 if ((gdk_event
->keyval
== GDK_Tab
) || (gdk_event
->keyval
== GDK_ISO_Left_Tab
))
221 int sel
= win
->GetSelection();
224 wxGtkNotebookPage
*nb_page
= win
->GetNotebookPage(sel
);
225 wxCHECK_MSG( nb_page
, FALSE
, _T("invalid selection in wxNotebook") );
227 wxNavigationKeyEvent event
;
228 event
.SetEventObject( win
);
229 /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
230 event
.SetDirection( (gdk_event
->keyval
== GDK_Tab
) );
231 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
232 event
.SetWindowChange( (gdk_event
->state
& GDK_CONTROL_MASK
) );
233 event
.SetCurrentFocus( win
);
235 wxNotebookPage
*client
= win
->GetPage(sel
);
236 if ( !client
->GetEventHandler()->ProcessEvent( event
) )
241 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "key_press_event" );
248 //-----------------------------------------------------------------------------
249 // InsertChild callback for wxNotebook
250 //-----------------------------------------------------------------------------
252 static void wxInsertChildInNotebook( wxNotebook
* parent
, wxWindow
* child
)
254 // Hack alert! We manually set the child window
255 // parent field so that GTK can query the
256 // notebook's style and font. Without that, GetBestSize could return
257 // incorrect size, see bug #901694 for details
258 // (http://sourceforge.net/tracker/?func=detail&aid=901694&group_id=9863&atid=109863)
259 child
->m_widget
->parent
= parent
->m_widget
;
262 //-----------------------------------------------------------------------------
264 //-----------------------------------------------------------------------------
266 IMPLEMENT_DYNAMIC_CLASS(wxNotebook
,wxControl
)
268 BEGIN_EVENT_TABLE(wxNotebook
, wxControl
)
269 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey
)
272 void wxNotebook::Init()
275 m_inSwitchPage
= FALSE
;
277 m_imageList
= (wxImageList
*) NULL
;
279 m_themeEnabled
= TRUE
;
282 wxNotebook::wxNotebook()
287 wxNotebook::wxNotebook( wxWindow
*parent
, wxWindowID id
,
288 const wxPoint
& pos
, const wxSize
& size
,
289 long style
, const wxString
& name
)
292 Create( parent
, id
, pos
, size
, style
, name
);
295 wxNotebook::~wxNotebook()
300 bool wxNotebook::Create(wxWindow
*parent
, wxWindowID id
,
301 const wxPoint
& pos
, const wxSize
& size
,
302 long style
, const wxString
& name
)
305 m_acceptsFocus
= TRUE
;
306 m_insertCallback
= (wxInsertChildFunction
)wxInsertChildInNotebook
;
308 if (!PreCreation( parent
, pos
, size
) ||
309 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
311 wxFAIL_MSG( wxT("wxNoteBook creation failed") );
316 m_widget
= gtk_notebook_new();
318 gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget
), 1 );
320 gtk_signal_connect( GTK_OBJECT(m_widget
), "switch_page",
321 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
)this );
323 m_parent
->DoAddChild( this );
325 if (m_windowStyle
& wxNB_RIGHT
)
326 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_RIGHT
);
327 if (m_windowStyle
& wxNB_LEFT
)
328 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_LEFT
);
329 if (m_windowStyle
& wxNB_BOTTOM
)
330 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_BOTTOM
);
332 gtk_signal_connect( GTK_OBJECT(m_widget
), "key_press_event",
333 GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback
), (gpointer
)this );
337 SetFont( parent
->GetFont() );
339 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
340 GTK_SIGNAL_FUNC(gtk_notebook_realized_callback
), (gpointer
) this );
345 int wxNotebook::GetSelection() const
347 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid notebook") );
349 if ( m_selection
== -1 )
351 GList
*nb_pages
= GTK_NOTEBOOK(m_widget
)->children
;
353 if (g_list_length(nb_pages
) != 0)
355 GtkNotebook
*notebook
= GTK_NOTEBOOK(m_widget
);
357 gpointer cur
= notebook
->cur_page
;
360 wxConstCast(this, wxNotebook
)->m_selection
=
361 g_list_index( nb_pages
, cur
);
369 wxString
wxNotebook::GetPageText( size_t page
) const
371 wxCHECK_MSG( m_widget
!= NULL
, wxT(""), wxT("invalid notebook") );
373 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
375 return nb_page
->m_text
;
380 int wxNotebook::GetPageImage( size_t page
) const
382 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid notebook") );
384 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
386 return nb_page
->m_image
;
391 wxGtkNotebookPage
* wxNotebook::GetNotebookPage( int page
) const
393 wxCHECK_MSG( m_widget
!= NULL
, (wxGtkNotebookPage
*) NULL
, wxT("invalid notebook") );
395 wxCHECK_MSG( page
< (int)m_pagesData
.GetCount(), (wxGtkNotebookPage
*) NULL
, wxT("invalid notebook index") );
397 return m_pagesData
.Item(page
)->GetData();
400 int wxNotebook::SetSelection( size_t page
)
402 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid notebook") );
404 wxCHECK_MSG( page
< m_pagesData
.GetCount(), -1, wxT("invalid notebook index") );
406 int selOld
= GetSelection();
408 // cache the selection
410 gtk_notebook_set_page( GTK_NOTEBOOK(m_widget
), page
);
412 wxNotebookPage
*client
= GetPage(page
);
419 bool wxNotebook::SetPageText( size_t page
, const wxString
&text
)
421 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
423 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
425 wxCHECK_MSG( nb_page
, FALSE
, wxT("SetPageText: invalid page index") );
427 nb_page
->m_text
= text
;
429 gtk_label_set( nb_page
->m_label
, wxGTK_CONV( nb_page
->m_text
) );
434 bool wxNotebook::SetPageImage( size_t page
, int image
)
436 /* HvdH 28-12-98: now it works, but it's a bit of a kludge */
438 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
440 if (!nb_page
) return FALSE
;
442 /* Optimization posibility: return immediately if image unchanged.
443 * Not enabled because it may break existing (stupid) code that
444 * manipulates the imagelist to cycle images */
446 /* if (image == nb_page->m_image) return TRUE; */
448 /* For different cases:
449 1) no image -> no image
454 if (image
== -1 && nb_page
->m_image
== -1)
455 return TRUE
; /* Case 1): Nothing to do. */
457 GtkWidget
*pixmapwid
= (GtkWidget
*) NULL
;
459 if (nb_page
->m_image
!= -1)
461 /* Case 2) or 4). There is already an image in the gtkhbox. Let's find it */
463 GList
*child
= gtk_container_children(GTK_CONTAINER(nb_page
->m_box
));
466 if (GTK_IS_PIXMAP(child
->data
))
468 pixmapwid
= GTK_WIDGET(child
->data
);
474 /* We should have the pixmap widget now */
475 wxASSERT(pixmapwid
!= NULL
);
479 /* If there's no new widget, just remove the old from the box */
480 gtk_container_remove(GTK_CONTAINER(nb_page
->m_box
), pixmapwid
);
481 nb_page
->m_image
= -1;
483 return TRUE
; /* Case 2) */
487 /* Only cases 3) and 4) left */
488 wxASSERT( m_imageList
!= NULL
); /* Just in case */
490 /* Construct the new pixmap */
491 const wxBitmap
*bmp
= m_imageList
->GetBitmap(image
);
492 GdkPixmap
*pixmap
= bmp
->GetPixmap();
493 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
494 if ( bmp
->GetMask() )
496 mask
= bmp
->GetMask()->GetBitmap();
499 if (pixmapwid
== NULL
)
501 /* Case 3) No old pixmap. Create a new one and prepend it to the hbox */
502 pixmapwid
= gtk_pixmap_new (pixmap
, mask
);
504 /* CHECKME: Are these pack flags okay? */
505 gtk_box_pack_start(GTK_BOX(nb_page
->m_box
), pixmapwid
, FALSE
, FALSE
, m_padding
);
506 gtk_widget_show(pixmapwid
);
510 /* Case 4) Simply replace the pixmap */
511 gtk_pixmap_set(GTK_PIXMAP(pixmapwid
), pixmap
, mask
);
514 nb_page
->m_image
= image
;
519 void wxNotebook::SetPageSize( const wxSize
&WXUNUSED(size
) )
521 wxFAIL_MSG( wxT("wxNotebook::SetPageSize not implemented") );
524 void wxNotebook::SetPadding( const wxSize
&padding
)
526 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid notebook") );
528 m_padding
= padding
.GetWidth();
531 for (i
=0; i
<int(GetPageCount()); i
++)
533 wxGtkNotebookPage
* nb_page
= GetNotebookPage(i
);
534 wxASSERT(nb_page
!= NULL
);
536 if (nb_page
->m_image
!= -1)
538 // gtk_box_set_child_packing sets padding on BOTH sides
539 // icon provides left padding, label provides center and right
540 int image
= nb_page
->m_image
;
542 SetPageImage(i
,image
);
544 wxASSERT(nb_page
->m_label
);
545 gtk_box_set_child_packing(GTK_BOX(nb_page
->m_box
),
546 GTK_WIDGET(nb_page
->m_label
),
547 FALSE
, FALSE
, m_padding
, GTK_PACK_END
);
551 void wxNotebook::SetTabSize(const wxSize
& WXUNUSED(sz
))
553 wxFAIL_MSG( wxT("wxNotebook::SetTabSize not implemented") );
556 bool wxNotebook::DeleteAllPages()
558 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
560 while (m_pagesData
.GetCount() > 0)
561 DeletePage( m_pagesData
.GetCount()-1 );
563 wxASSERT_MSG( GetPageCount() == 0, _T("all pages must have been deleted") );
565 return wxNotebookBase::DeleteAllPages();
568 bool wxNotebook::DeletePage( size_t page
)
570 if ( m_selection
== (int)m_pagesData
.GetCount() - 1 )
572 // the index will become invalid after the page is deleted
576 // it will call our DoRemovePage() to do the real work
577 return wxNotebookBase::DeletePage(page
);
580 wxNotebookPage
*wxNotebook::DoRemovePage( size_t page
)
582 wxNotebookPage
*client
= wxNotebookBase::DoRemovePage(page
);
586 gtk_widget_ref( client
->m_widget
);
587 gtk_widget_unrealize( client
->m_widget
);
588 gtk_widget_unparent( client
->m_widget
);
590 // gtk_notebook_remove_page() sends "switch_page" signal with some strange
591 // new page index (when deleting selected page 0, new page is 1 although,
592 // clearly, the selection should stay 0), so suppress this
593 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget
),
594 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
) this );
596 gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget
), page
);
598 gtk_signal_connect( GTK_OBJECT(m_widget
), "switch_page",
599 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
)this );
601 wxGtkNotebookPage
* p
= GetNotebookPage(page
);
602 m_pagesData
.DeleteObject(p
);
608 bool wxNotebook::InsertPage( size_t position
,
610 const wxString
& text
,
614 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
616 wxCHECK_MSG( win
->GetParent() == this, FALSE
,
617 wxT("Can't add a page whose parent is not the notebook!") );
619 wxCHECK_MSG( position
<= GetPageCount(), FALSE
,
620 _T("invalid page index in wxNotebookPage::InsertPage()") );
622 // Hack alert part II! See above in InsertChildInNotebook
623 // callback why this has to be done.
624 win
->m_widget
->parent
= NULL
;
626 // don't receive switch page during addition
627 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget
),
628 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
) this );
631 win
->SetThemeEnabled(TRUE
);
633 GtkNotebook
*notebook
= GTK_NOTEBOOK(m_widget
);
635 wxGtkNotebookPage
*nb_page
= new wxGtkNotebookPage();
637 if ( position
== GetPageCount() )
638 m_pagesData
.Append( nb_page
);
640 m_pagesData
.Insert( m_pagesData
.Item( position
), nb_page
);
642 m_pages
.Insert(win
, position
);
644 nb_page
->m_box
= gtk_hbox_new( FALSE
, 1 );
645 gtk_container_border_width( GTK_CONTAINER(nb_page
->m_box
), 2 );
647 gtk_signal_connect( GTK_OBJECT(win
->m_widget
), "size_allocate",
648 GTK_SIGNAL_FUNC(gtk_page_size_callback
), (gpointer
)win
);
651 // On VMS position is unsigned and thus always positive
653 gtk_notebook_append_page( notebook
, win
->m_widget
, nb_page
->m_box
);
656 gtk_notebook_insert_page( notebook
, win
->m_widget
, nb_page
->m_box
, position
);
658 nb_page
->m_page
= (GtkNotebookPage
*) g_list_last(notebook
->children
)->data
;
660 /* set the label image */
661 nb_page
->m_image
= imageId
;
665 wxASSERT( m_imageList
!= NULL
);
667 const wxBitmap
*bmp
= m_imageList
->GetBitmap(imageId
);
668 GdkPixmap
*pixmap
= bmp
->GetPixmap();
669 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
670 if ( bmp
->GetMask() )
672 mask
= bmp
->GetMask()->GetBitmap();
675 GtkWidget
*pixmapwid
= gtk_pixmap_new (pixmap
, mask
);
677 gtk_box_pack_start(GTK_BOX(nb_page
->m_box
), pixmapwid
, FALSE
, FALSE
, m_padding
);
679 gtk_widget_show(pixmapwid
);
682 /* set the label text */
684 nb_page
->m_text
= text
;
685 if (nb_page
->m_text
.IsEmpty()) nb_page
->m_text
= wxT("");
687 nb_page
->m_label
= GTK_LABEL( gtk_label_new(wxGTK_CONV(nb_page
->m_text
)) );
688 nb_page
->SetFont(GetFont());
689 gtk_box_pack_end( GTK_BOX(nb_page
->m_box
), GTK_WIDGET(nb_page
->m_label
), FALSE
, FALSE
, m_padding
);
692 gtk_widget_show( GTK_WIDGET(nb_page
->m_label
) );
693 if (select
&& (m_pagesData
.GetCount() > 1))
696 // On VMS position is unsigned and thus always positive
698 SetSelection( GetPageCount()-1 );
701 SetSelection( position
);
704 gtk_signal_connect( GTK_OBJECT(m_widget
), "switch_page",
705 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
)this );
710 // helper for HitTest(): check if the point lies inside the given widget which
711 // is the child of the notebook whose position and border size are passed as
714 IsPointInsideWidget(const wxPoint
& pt
, GtkWidget
*w
,
715 gint x
, gint y
, gint border
= 0)
718 (pt
.x
>= w
->allocation
.x
- x
- border
) &&
719 (pt
.x
<= w
->allocation
.x
- x
+ border
+ w
->allocation
.width
) &&
720 (pt
.y
>= w
->allocation
.y
- y
- border
) &&
721 (pt
.y
<= w
->allocation
.y
- y
+ border
+ w
->allocation
.height
);
724 int wxNotebook::HitTest(const wxPoint
& pt
, long *flags
) const
726 const gint x
= m_widget
->allocation
.x
;
727 const gint y
= m_widget
->allocation
.y
;
729 const size_t count
= GetPageCount();
730 for ( size_t i
= 0; i
< count
; i
++ )
732 wxGtkNotebookPage
* nb_page
= GetNotebookPage(i
);
733 GtkWidget
*box
= nb_page
->m_box
;
735 // VZ: don't know how to find the border width in GTK+ 1.2
737 const gint border
= gtk_container_get_border_width(GTK_CONTAINER(box
));
739 const gint border
= 0;
741 if ( IsPointInsideWidget(pt
, box
, x
, y
, border
) )
743 // ok, we're inside this tab -- now find out where, if needed
746 GtkWidget
*pixmap
= NULL
;
748 GList
*children
= gtk_container_children(GTK_CONTAINER(box
));
749 for ( GList
*child
= children
; child
; child
= child
->next
)
751 if ( GTK_IS_PIXMAP(child
->data
) )
753 pixmap
= GTK_WIDGET(child
->data
);
759 g_list_free(children
);
761 if ( pixmap
&& IsPointInsideWidget(pt
, pixmap
, x
, y
) )
763 *flags
= wxNB_HITTEST_ONICON
;
765 else if ( IsPointInsideWidget(pt
, GTK_WIDGET(nb_page
->m_label
), x
, y
) )
767 *flags
= wxNB_HITTEST_ONLABEL
;
771 *flags
= wxNB_HITTEST_ONITEM
;
780 *flags
= wxNB_HITTEST_NOWHERE
;
785 void wxNotebook::OnNavigationKey(wxNavigationKeyEvent
& event
)
787 if (event
.IsWindowChange())
788 AdvanceSelection( event
.GetDirection() );
793 #if wxUSE_CONSTRAINTS
795 // override these 2 functions to do nothing: everything is done in OnSize
796 void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse
) )
798 // don't set the sizes of the pages - their correct size is not yet known
799 wxControl::SetConstraintSizes(FALSE
);
802 bool wxNotebook::DoPhase( int WXUNUSED(nPhase
) )
809 void wxNotebook::DoApplyWidgetStyle(GtkRcStyle
*style
)
811 // TODO, font for labels etc
812 gtk_widget_modify_style( m_widget
, style
);
815 bool wxNotebook::IsOwnGtkWindow( GdkWindow
*window
)
817 return ((m_widget
->window
== window
) ||
818 (NOTEBOOK_PANEL(m_widget
) == window
));
821 bool wxNotebook::SetFont(const wxFont
& font
)
823 bool rc
=wxNotebookBase::SetFont(font
);
828 for (i
=0 ; i
< m_pagesData
.GetCount() ; i
++)
829 GetNotebookPage(i
)->SetFont(font
);
836 wxNotebook::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
838 return GetDefaultAttributesFromGTKWidget(gtk_notebook_new
);
841 //-----------------------------------------------------------------------------
843 //-----------------------------------------------------------------------------
845 IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent
, wxNotifyEvent
)