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! (Part I): This sets the notebook as the parent of the child
255 // widget, and takes care of some details such as updating the state and
256 // style of the child to reflect its new location. We do this early
257 // because without it GetBestSize (which is used to set the initial size
258 // of controls if an explicit size is not given) will often report
259 // incorrect sizes since the widget's style context is not fully known.
260 // See bug #901694 for details
261 // (http://sourceforge.net/tracker/?func=detail&aid=901694&group_id=9863&atid=109863)
262 gtk_widget_set_parent(child
->m_widget
, parent
->m_widget
);
264 // NOTE: This should be considered a temporary workaround until we can
265 // work out the details and implement delaying the setting of the initial
266 // size of widgets until the size is really needed.
269 //-----------------------------------------------------------------------------
271 //-----------------------------------------------------------------------------
273 IMPLEMENT_DYNAMIC_CLASS(wxNotebook
,wxControl
)
275 BEGIN_EVENT_TABLE(wxNotebook
, wxControl
)
276 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey
)
279 void wxNotebook::Init()
282 m_inSwitchPage
= FALSE
;
284 m_imageList
= (wxImageList
*) NULL
;
286 m_themeEnabled
= TRUE
;
289 wxNotebook::wxNotebook()
294 wxNotebook::wxNotebook( wxWindow
*parent
, wxWindowID id
,
295 const wxPoint
& pos
, const wxSize
& size
,
296 long style
, const wxString
& name
)
299 Create( parent
, id
, pos
, size
, style
, name
);
302 wxNotebook::~wxNotebook()
307 bool wxNotebook::Create(wxWindow
*parent
, wxWindowID id
,
308 const wxPoint
& pos
, const wxSize
& size
,
309 long style
, const wxString
& name
)
312 m_acceptsFocus
= TRUE
;
313 m_insertCallback
= (wxInsertChildFunction
)wxInsertChildInNotebook
;
315 if (!PreCreation( parent
, pos
, size
) ||
316 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
318 wxFAIL_MSG( wxT("wxNoteBook creation failed") );
323 m_widget
= gtk_notebook_new();
325 gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget
), 1 );
327 gtk_signal_connect( GTK_OBJECT(m_widget
), "switch_page",
328 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
)this );
330 m_parent
->DoAddChild( this );
332 if (m_windowStyle
& wxNB_RIGHT
)
333 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_RIGHT
);
334 if (m_windowStyle
& wxNB_LEFT
)
335 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_LEFT
);
336 if (m_windowStyle
& wxNB_BOTTOM
)
337 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_BOTTOM
);
339 gtk_signal_connect( GTK_OBJECT(m_widget
), "key_press_event",
340 GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback
), (gpointer
)this );
344 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
345 GTK_SIGNAL_FUNC(gtk_notebook_realized_callback
), (gpointer
) this );
350 int wxNotebook::GetSelection() const
352 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid notebook") );
354 if ( m_selection
== -1 )
356 GList
*nb_pages
= GTK_NOTEBOOK(m_widget
)->children
;
358 if (g_list_length(nb_pages
) != 0)
360 GtkNotebook
*notebook
= GTK_NOTEBOOK(m_widget
);
362 gpointer cur
= notebook
->cur_page
;
365 wxConstCast(this, wxNotebook
)->m_selection
=
366 g_list_index( nb_pages
, cur
);
374 wxString
wxNotebook::GetPageText( size_t page
) const
376 wxCHECK_MSG( m_widget
!= NULL
, wxT(""), wxT("invalid notebook") );
378 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
380 return nb_page
->m_text
;
385 int wxNotebook::GetPageImage( size_t page
) const
387 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid notebook") );
389 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
391 return nb_page
->m_image
;
396 wxGtkNotebookPage
* wxNotebook::GetNotebookPage( int page
) const
398 wxCHECK_MSG( m_widget
!= NULL
, (wxGtkNotebookPage
*) NULL
, wxT("invalid notebook") );
400 wxCHECK_MSG( page
< (int)m_pagesData
.GetCount(), (wxGtkNotebookPage
*) NULL
, wxT("invalid notebook index") );
402 return m_pagesData
.Item(page
)->GetData();
405 int wxNotebook::SetSelection( size_t page
)
407 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid notebook") );
409 wxCHECK_MSG( page
< m_pagesData
.GetCount(), -1, wxT("invalid notebook index") );
411 int selOld
= GetSelection();
413 // cache the selection
415 gtk_notebook_set_page( GTK_NOTEBOOK(m_widget
), page
);
417 wxNotebookPage
*client
= GetPage(page
);
424 bool wxNotebook::SetPageText( size_t page
, const wxString
&text
)
426 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
428 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
430 wxCHECK_MSG( nb_page
, FALSE
, wxT("SetPageText: invalid page index") );
432 nb_page
->m_text
= text
;
434 gtk_label_set( nb_page
->m_label
, wxGTK_CONV( nb_page
->m_text
) );
439 bool wxNotebook::SetPageImage( size_t page
, int image
)
441 /* HvdH 28-12-98: now it works, but it's a bit of a kludge */
443 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
445 if (!nb_page
) return FALSE
;
447 /* Optimization posibility: return immediately if image unchanged.
448 * Not enabled because it may break existing (stupid) code that
449 * manipulates the imagelist to cycle images */
451 /* if (image == nb_page->m_image) return TRUE; */
453 /* For different cases:
454 1) no image -> no image
459 if (image
== -1 && nb_page
->m_image
== -1)
460 return TRUE
; /* Case 1): Nothing to do. */
462 GtkWidget
*pixmapwid
= (GtkWidget
*) NULL
;
464 if (nb_page
->m_image
!= -1)
466 /* Case 2) or 4). There is already an image in the gtkhbox. Let's find it */
468 GList
*child
= gtk_container_children(GTK_CONTAINER(nb_page
->m_box
));
471 if (GTK_IS_PIXMAP(child
->data
))
473 pixmapwid
= GTK_WIDGET(child
->data
);
479 /* We should have the pixmap widget now */
480 wxASSERT(pixmapwid
!= NULL
);
484 /* If there's no new widget, just remove the old from the box */
485 gtk_container_remove(GTK_CONTAINER(nb_page
->m_box
), pixmapwid
);
486 nb_page
->m_image
= -1;
488 return TRUE
; /* Case 2) */
492 /* Only cases 3) and 4) left */
493 wxASSERT( m_imageList
!= NULL
); /* Just in case */
495 /* Construct the new pixmap */
496 const wxBitmap
*bmp
= m_imageList
->GetBitmap(image
);
497 GdkPixmap
*pixmap
= bmp
->GetPixmap();
498 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
499 if ( bmp
->GetMask() )
501 mask
= bmp
->GetMask()->GetBitmap();
504 if (pixmapwid
== NULL
)
506 /* Case 3) No old pixmap. Create a new one and prepend it to the hbox */
507 pixmapwid
= gtk_pixmap_new (pixmap
, mask
);
509 /* CHECKME: Are these pack flags okay? */
510 gtk_box_pack_start(GTK_BOX(nb_page
->m_box
), pixmapwid
, FALSE
, FALSE
, m_padding
);
511 gtk_widget_show(pixmapwid
);
515 /* Case 4) Simply replace the pixmap */
516 gtk_pixmap_set(GTK_PIXMAP(pixmapwid
), pixmap
, mask
);
519 nb_page
->m_image
= image
;
524 void wxNotebook::SetPageSize( const wxSize
&WXUNUSED(size
) )
526 wxFAIL_MSG( wxT("wxNotebook::SetPageSize not implemented") );
529 void wxNotebook::SetPadding( const wxSize
&padding
)
531 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid notebook") );
533 m_padding
= padding
.GetWidth();
536 for (i
=0; i
<int(GetPageCount()); i
++)
538 wxGtkNotebookPage
* nb_page
= GetNotebookPage(i
);
539 wxASSERT(nb_page
!= NULL
);
541 if (nb_page
->m_image
!= -1)
543 // gtk_box_set_child_packing sets padding on BOTH sides
544 // icon provides left padding, label provides center and right
545 int image
= nb_page
->m_image
;
547 SetPageImage(i
,image
);
549 wxASSERT(nb_page
->m_label
);
550 gtk_box_set_child_packing(GTK_BOX(nb_page
->m_box
),
551 GTK_WIDGET(nb_page
->m_label
),
552 FALSE
, FALSE
, m_padding
, GTK_PACK_END
);
556 void wxNotebook::SetTabSize(const wxSize
& WXUNUSED(sz
))
558 wxFAIL_MSG( wxT("wxNotebook::SetTabSize not implemented") );
561 bool wxNotebook::DeleteAllPages()
563 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
565 while (m_pagesData
.GetCount() > 0)
566 DeletePage( m_pagesData
.GetCount()-1 );
568 wxASSERT_MSG( GetPageCount() == 0, _T("all pages must have been deleted") );
570 InvalidateBestSize();
571 return wxNotebookBase::DeleteAllPages();
574 wxNotebookPage
*wxNotebook::DoRemovePage( size_t page
)
576 if ( m_selection
!= -1 && (size_t)m_selection
>= page
)
578 // the index will become invalid after the page is deleted
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 wxInsertChildInNotebook callback
623 // why this has to be done. NOTE: using gtk_widget_unparent here does not
624 // work as it seems to undo too much and will cause errors in the
625 // gtk_notebook_insert_page below, so instead just clear the parent by
627 win
->m_widget
->parent
= NULL
;
629 // don't receive switch page during addition
630 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget
),
631 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
) this );
634 win
->SetThemeEnabled(TRUE
);
636 GtkNotebook
*notebook
= GTK_NOTEBOOK(m_widget
);
638 wxGtkNotebookPage
*nb_page
= new wxGtkNotebookPage();
640 if ( position
== GetPageCount() )
641 m_pagesData
.Append( nb_page
);
643 m_pagesData
.Insert( m_pagesData
.Item( position
), nb_page
);
645 m_pages
.Insert(win
, position
);
647 nb_page
->m_box
= gtk_hbox_new( FALSE
, 1 );
648 gtk_container_border_width( GTK_CONTAINER(nb_page
->m_box
), 2 );
650 gtk_signal_connect( GTK_OBJECT(win
->m_widget
), "size_allocate",
651 GTK_SIGNAL_FUNC(gtk_page_size_callback
), (gpointer
)win
);
654 // On VMS position is unsigned and thus always positive
656 gtk_notebook_append_page( notebook
, win
->m_widget
, nb_page
->m_box
);
659 gtk_notebook_insert_page( notebook
, win
->m_widget
, nb_page
->m_box
, position
);
661 nb_page
->m_page
= (GtkNotebookPage
*) g_list_last(notebook
->children
)->data
;
663 /* set the label image */
664 nb_page
->m_image
= imageId
;
668 wxASSERT( m_imageList
!= NULL
);
670 const wxBitmap
*bmp
= m_imageList
->GetBitmap(imageId
);
671 GdkPixmap
*pixmap
= bmp
->GetPixmap();
672 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
673 if ( bmp
->GetMask() )
675 mask
= bmp
->GetMask()->GetBitmap();
678 GtkWidget
*pixmapwid
= gtk_pixmap_new (pixmap
, mask
);
680 gtk_box_pack_start(GTK_BOX(nb_page
->m_box
), pixmapwid
, FALSE
, FALSE
, m_padding
);
682 gtk_widget_show(pixmapwid
);
685 /* set the label text */
687 nb_page
->m_text
= text
;
688 if (nb_page
->m_text
.IsEmpty()) nb_page
->m_text
= wxT("");
690 nb_page
->m_label
= GTK_LABEL( gtk_label_new(wxGTK_CONV(nb_page
->m_text
)) );
691 gtk_box_pack_end( GTK_BOX(nb_page
->m_box
), GTK_WIDGET(nb_page
->m_label
), FALSE
, FALSE
, m_padding
);
694 gtk_widget_show( GTK_WIDGET(nb_page
->m_label
) );
695 if (select
&& (m_pagesData
.GetCount() > 1))
698 // On VMS position is unsigned and thus always positive
700 SetSelection( GetPageCount()-1 );
703 SetSelection( position
);
706 gtk_signal_connect( GTK_OBJECT(m_widget
), "switch_page",
707 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
)this );
709 InvalidateBestSize();
713 // helper for HitTest(): check if the point lies inside the given widget which
714 // is the child of the notebook whose position and border size are passed as
717 IsPointInsideWidget(const wxPoint
& pt
, GtkWidget
*w
,
718 gint x
, gint y
, gint border
= 0)
721 (pt
.x
>= w
->allocation
.x
- x
- border
) &&
722 (pt
.x
<= w
->allocation
.x
- x
+ border
+ w
->allocation
.width
) &&
723 (pt
.y
>= w
->allocation
.y
- y
- border
) &&
724 (pt
.y
<= w
->allocation
.y
- y
+ border
+ w
->allocation
.height
);
727 int wxNotebook::HitTest(const wxPoint
& pt
, long *flags
) const
729 const gint x
= m_widget
->allocation
.x
;
730 const gint y
= m_widget
->allocation
.y
;
732 const size_t count
= GetPageCount();
733 for ( size_t i
= 0; i
< count
; i
++ )
735 wxGtkNotebookPage
* nb_page
= GetNotebookPage(i
);
736 GtkWidget
*box
= nb_page
->m_box
;
738 // VZ: don't know how to find the border width in GTK+ 1.2
740 const gint border
= gtk_container_get_border_width(GTK_CONTAINER(box
));
742 const gint border
= 0;
744 if ( IsPointInsideWidget(pt
, box
, x
, y
, border
) )
746 // ok, we're inside this tab -- now find out where, if needed
749 GtkWidget
*pixmap
= NULL
;
751 GList
*children
= gtk_container_children(GTK_CONTAINER(box
));
752 for ( GList
*child
= children
; child
; child
= child
->next
)
754 if ( GTK_IS_PIXMAP(child
->data
) )
756 pixmap
= GTK_WIDGET(child
->data
);
762 g_list_free(children
);
764 if ( pixmap
&& IsPointInsideWidget(pt
, pixmap
, x
, y
) )
766 *flags
= wxNB_HITTEST_ONICON
;
768 else if ( IsPointInsideWidget(pt
, GTK_WIDGET(nb_page
->m_label
), x
, y
) )
770 *flags
= wxNB_HITTEST_ONLABEL
;
774 *flags
= wxNB_HITTEST_ONITEM
;
783 *flags
= wxNB_HITTEST_NOWHERE
;
788 void wxNotebook::OnNavigationKey(wxNavigationKeyEvent
& event
)
790 if (event
.IsWindowChange())
791 AdvanceSelection( event
.GetDirection() );
796 #if wxUSE_CONSTRAINTS
798 // override these 2 functions to do nothing: everything is done in OnSize
799 void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse
) )
801 // don't set the sizes of the pages - their correct size is not yet known
802 wxControl::SetConstraintSizes(FALSE
);
805 bool wxNotebook::DoPhase( int WXUNUSED(nPhase
) )
812 void wxNotebook::DoApplyWidgetStyle(GtkRcStyle
*style
)
814 // TODO, font for labels etc
815 gtk_widget_modify_style( m_widget
, style
);
818 bool wxNotebook::IsOwnGtkWindow( GdkWindow
*window
)
820 return ((m_widget
->window
== window
) ||
821 (NOTEBOOK_PANEL(m_widget
) == window
));
824 bool wxNotebook::SetFont(const wxFont
& font
)
826 bool rc
=wxNotebookBase::SetFont(font
);
831 for (i
=0 ; i
< m_pagesData
.GetCount() ; i
++)
832 GetNotebookPage(i
)->SetFont(font
);
839 wxNotebook::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
841 return GetDefaultAttributesFromGTKWidget(gtk_notebook_new
);
844 //-----------------------------------------------------------------------------
846 //-----------------------------------------------------------------------------
848 IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent
, wxNotifyEvent
)