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
);
192 //-----------------------------------------------------------------------------
194 //-----------------------------------------------------------------------------
197 static gint
gtk_notebook_key_press_callback( GtkWidget
*widget
, GdkEventKey
*gdk_event
, wxNotebook
*notebook
)
200 wxapp_install_idle_handler();
202 if (!notebook
->m_hasVMT
) return FALSE
;
203 if (g_blockEventsOnDrag
) return FALSE
;
205 /* win is a control: tab can be propagated up */
206 if ((gdk_event
->keyval
== GDK_Left
) || (gdk_event
->keyval
== GDK_Right
))
209 int nMax
= notebook
->GetPageCount();
210 if ( nMax
-- ) // decrement it to get the last valid index
212 int nSel
= notebook
->GetSelection();
214 // change selection wrapping if it becomes invalid
215 page
= (gdk_event
->keyval
!= GDK_Left
) ? nSel
== nMax
? 0
220 else // notebook is empty, no next page
225 // m_selection = page;
226 gtk_notebook_set_current_page( GTK_NOTEBOOK(widget
), page
);
228 g_signal_stop_emission_by_name (widget
, "key_press_event");
232 /* win is a control: tab can be propagated up */
233 if ((gdk_event
->keyval
== GDK_Tab
) || (gdk_event
->keyval
== GDK_ISO_Left_Tab
))
235 int sel
= notebook
->GetSelection();
238 wxGtkNotebookPage
*nb_page
= notebook
->GetNotebookPage(sel
);
239 wxCHECK_MSG( nb_page
, FALSE
, _T("invalid selection in wxNotebook") );
241 wxNavigationKeyEvent event
;
242 event
.SetEventObject( notebook
);
243 /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
244 event
.SetDirection( (gdk_event
->keyval
== GDK_Tab
) );
245 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
246 event
.SetWindowChange( (gdk_event
->state
& GDK_CONTROL_MASK
) ||
247 (gdk_event
->keyval
== GDK_Left
) || (gdk_event
->keyval
== GDK_Right
) );
248 event
.SetCurrentFocus( notebook
);
250 wxNotebookPage
*client
= notebook
->GetPage(sel
);
251 if ( !client
->GetEventHandler()->ProcessEvent( event
) )
256 g_signal_stop_emission_by_name (widget
, "key_press_event");
264 //-----------------------------------------------------------------------------
265 // InsertChild callback for wxNotebook
266 //-----------------------------------------------------------------------------
268 static void wxInsertChildInNotebook( wxNotebook
* parent
, wxWindow
* child
)
270 // Hack Alert! (Part I): This sets the notebook as the parent of the child
271 // widget, and takes care of some details such as updating the state and
272 // style of the child to reflect its new location. We do this early
273 // because without it GetBestSize (which is used to set the initial size
274 // of controls if an explicit size is not given) will often report
275 // incorrect sizes since the widget's style context is not fully known.
276 // See bug #901694 for details
277 // (http://sourceforge.net/tracker/?func=detail&aid=901694&group_id=9863&atid=109863)
278 gtk_widget_set_parent(child
->m_widget
, parent
->m_widget
);
280 // NOTE: This should be considered a temporary workaround until we can
281 // work out the details and implement delaying the setting of the initial
282 // size of widgets until the size is really needed.
285 //-----------------------------------------------------------------------------
287 //-----------------------------------------------------------------------------
289 IMPLEMENT_DYNAMIC_CLASS(wxNotebook
,wxControl
)
291 BEGIN_EVENT_TABLE(wxNotebook
, wxControl
)
292 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey
)
295 void wxNotebook::Init()
298 m_inSwitchPage
= FALSE
;
300 m_imageList
= (wxImageList
*) NULL
;
302 m_themeEnabled
= TRUE
;
305 wxNotebook::wxNotebook()
310 wxNotebook::wxNotebook( wxWindow
*parent
, wxWindowID id
,
311 const wxPoint
& pos
, const wxSize
& size
,
312 long style
, const wxString
& name
)
315 Create( parent
, id
, pos
, size
, style
, name
);
318 wxNotebook::~wxNotebook()
323 bool wxNotebook::Create(wxWindow
*parent
, wxWindowID id
,
324 const wxPoint
& pos
, const wxSize
& size
,
325 long style
, const wxString
& name
)
328 m_acceptsFocus
= TRUE
;
329 m_insertCallback
= (wxInsertChildFunction
)wxInsertChildInNotebook
;
331 if (!PreCreation( parent
, pos
, size
) ||
332 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
334 wxFAIL_MSG( wxT("wxNoteBook creation failed") );
339 m_widget
= gtk_notebook_new();
341 gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget
), 1 );
343 g_signal_connect (m_widget
, "switch_page",
344 G_CALLBACK (gtk_notebook_page_change_callback
), this);
346 m_parent
->DoAddChild( this );
348 if (m_windowStyle
& wxBK_RIGHT
)
349 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_RIGHT
);
350 if (m_windowStyle
& wxBK_LEFT
)
351 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_LEFT
);
352 if (m_windowStyle
& wxBK_BOTTOM
)
353 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_BOTTOM
);
355 g_signal_connect (m_widget
, "key_press_event",
356 G_CALLBACK (gtk_notebook_key_press_callback
), this);
360 g_signal_connect (m_widget
, "realize",
361 G_CALLBACK (gtk_notebook_realized_callback
), this);
366 int wxNotebook::GetSelection() const
368 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid notebook") );
370 if ( m_selection
== -1 )
372 GList
*nb_pages
= GTK_NOTEBOOK(m_widget
)->children
;
374 if (g_list_length(nb_pages
) != 0)
376 GtkNotebook
*notebook
= GTK_NOTEBOOK(m_widget
);
378 gpointer cur
= notebook
->cur_page
;
381 wxConstCast(this, wxNotebook
)->m_selection
=
382 g_list_index( nb_pages
, cur
);
390 wxString
wxNotebook::GetPageText( size_t page
) const
392 wxCHECK_MSG( m_widget
!= NULL
, wxT(""), wxT("invalid notebook") );
394 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
396 return nb_page
->m_text
;
401 int wxNotebook::GetPageImage( size_t page
) const
403 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid notebook") );
405 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
407 return nb_page
->m_image
;
412 wxGtkNotebookPage
* wxNotebook::GetNotebookPage( int page
) const
414 wxCHECK_MSG( m_widget
!= NULL
, (wxGtkNotebookPage
*) NULL
, wxT("invalid notebook") );
416 wxCHECK_MSG( page
< (int)m_pagesData
.GetCount(), (wxGtkNotebookPage
*) NULL
, wxT("invalid notebook index") );
418 return m_pagesData
.Item(page
)->GetData();
421 int wxNotebook::SetSelection( size_t page
)
423 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid notebook") );
425 wxCHECK_MSG( page
< m_pagesData
.GetCount(), -1, wxT("invalid notebook index") );
427 int selOld
= GetSelection();
429 // cache the selection
431 gtk_notebook_set_current_page( GTK_NOTEBOOK(m_widget
), page
);
433 wxNotebookPage
*client
= GetPage(page
);
440 bool wxNotebook::SetPageText( size_t page
, const wxString
&text
)
442 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
444 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
446 wxCHECK_MSG( nb_page
, FALSE
, wxT("SetPageText: invalid page index") );
448 nb_page
->m_text
= text
;
450 gtk_label_set_text( nb_page
->m_label
, wxGTK_CONV( nb_page
->m_text
) );
455 bool wxNotebook::SetPageImage( size_t page
, int image
)
457 /* HvdH 28-12-98: now it works, but it's a bit of a kludge */
459 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
461 if (!nb_page
) return FALSE
;
463 /* Optimization posibility: return immediately if image unchanged.
464 * Not enabled because it may break existing (stupid) code that
465 * manipulates the imagelist to cycle images */
467 /* if (image == nb_page->m_image) return TRUE; */
469 /* For different cases:
470 1) no image -> no image
475 if (image
== -1 && nb_page
->m_image
== -1)
476 return TRUE
; /* Case 1): Nothing to do. */
478 GtkWidget
*pixmapwid
= (GtkWidget
*) NULL
;
480 if (nb_page
->m_image
!= -1)
482 /* Case 2) or 4). There is already an image in the gtkhbox. Let's find it */
484 GList
*child
= gtk_container_get_children(GTK_CONTAINER(nb_page
->m_box
));
487 if (GTK_IS_PIXMAP(child
->data
))
489 pixmapwid
= GTK_WIDGET(child
->data
);
495 /* We should have the pixmap widget now */
496 wxASSERT(pixmapwid
!= NULL
);
500 /* If there's no new widget, just remove the old from the box */
501 gtk_container_remove(GTK_CONTAINER(nb_page
->m_box
), pixmapwid
);
502 nb_page
->m_image
= -1;
504 return TRUE
; /* Case 2) */
508 /* Only cases 3) and 4) left */
509 wxASSERT( m_imageList
!= NULL
); /* Just in case */
511 /* Construct the new pixmap */
512 const wxBitmap
*bmp
= m_imageList
->GetBitmapPtr(image
);
513 GdkPixmap
*pixmap
= bmp
->GetPixmap();
514 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
515 if ( bmp
->GetMask() )
517 mask
= bmp
->GetMask()->GetBitmap();
520 if (pixmapwid
== NULL
)
522 /* Case 3) No old pixmap. Create a new one and prepend it to the hbox */
523 pixmapwid
= gtk_pixmap_new (pixmap
, mask
);
525 /* CHECKME: Are these pack flags okay? */
526 gtk_box_pack_start(GTK_BOX(nb_page
->m_box
), pixmapwid
, FALSE
, FALSE
, m_padding
);
527 gtk_widget_show(pixmapwid
);
531 /* Case 4) Simply replace the pixmap */
532 gtk_pixmap_set(GTK_PIXMAP(pixmapwid
), pixmap
, mask
);
535 nb_page
->m_image
= image
;
540 void wxNotebook::SetPageSize( const wxSize
&WXUNUSED(size
) )
542 wxFAIL_MSG( wxT("wxNotebook::SetPageSize not implemented") );
545 void wxNotebook::SetPadding( const wxSize
&padding
)
547 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid notebook") );
549 m_padding
= padding
.GetWidth();
552 for (i
=0; i
<int(GetPageCount()); i
++)
554 wxGtkNotebookPage
* nb_page
= GetNotebookPage(i
);
555 wxASSERT(nb_page
!= NULL
);
557 if (nb_page
->m_image
!= -1)
559 // gtk_box_set_child_packing sets padding on BOTH sides
560 // icon provides left padding, label provides center and right
561 int image
= nb_page
->m_image
;
563 SetPageImage(i
,image
);
565 wxASSERT(nb_page
->m_label
);
566 gtk_box_set_child_packing(GTK_BOX(nb_page
->m_box
),
567 GTK_WIDGET(nb_page
->m_label
),
568 FALSE
, FALSE
, m_padding
, GTK_PACK_END
);
572 void wxNotebook::SetTabSize(const wxSize
& WXUNUSED(sz
))
574 wxFAIL_MSG( wxT("wxNotebook::SetTabSize not implemented") );
577 bool wxNotebook::DeleteAllPages()
579 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
581 while (m_pagesData
.GetCount() > 0)
582 DeletePage( m_pagesData
.GetCount()-1 );
584 wxASSERT_MSG( GetPageCount() == 0, _T("all pages must have been deleted") );
586 InvalidateBestSize();
587 return wxNotebookBase::DeleteAllPages();
590 wxNotebookPage
*wxNotebook::DoRemovePage( size_t page
)
592 if ( m_selection
!= -1 && (size_t)m_selection
>= page
)
594 // the index will become invalid after the page is deleted
598 wxNotebookPage
*client
= wxNotebookBase::DoRemovePage(page
);
602 gtk_widget_ref( client
->m_widget
);
603 gtk_widget_unrealize( client
->m_widget
);
604 gtk_widget_unparent( client
->m_widget
);
606 // gtk_notebook_remove_page() sends "switch_page" signal with some strange
607 // new page index (when deleting selected page 0, new page is 1 although,
608 // clearly, the selection should stay 0), so suppress this
609 g_signal_handlers_disconnect_by_func (m_widget
,
610 (gpointer
) gtk_notebook_page_change_callback
,
613 gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget
), page
);
615 g_signal_connect (m_widget
, "switch_page",
616 G_CALLBACK (gtk_notebook_page_change_callback
), this);
618 wxGtkNotebookPage
* p
= GetNotebookPage(page
);
619 m_pagesData
.DeleteObject(p
);
625 bool wxNotebook::InsertPage( size_t position
,
627 const wxString
& text
,
631 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
633 wxCHECK_MSG( win
->GetParent() == this, FALSE
,
634 wxT("Can't add a page whose parent is not the notebook!") );
636 wxCHECK_MSG( position
<= GetPageCount(), FALSE
,
637 _T("invalid page index in wxNotebookPage::InsertPage()") );
639 // Hack Alert! (Part II): See above in wxInsertChildInNotebook callback
640 // why this has to be done. NOTE: using gtk_widget_unparent here does not
641 // work as it seems to undo too much and will cause errors in the
642 // gtk_notebook_insert_page below, so instead just clear the parent by
644 win
->m_widget
->parent
= NULL
;
646 // don't receive switch page during addition
647 g_signal_handlers_disconnect_by_func (m_widget
,
648 (gpointer
) gtk_notebook_page_change_callback
,
652 win
->SetThemeEnabled(TRUE
);
654 GtkNotebook
*notebook
= GTK_NOTEBOOK(m_widget
);
656 wxGtkNotebookPage
*nb_page
= new wxGtkNotebookPage();
658 if ( position
== GetPageCount() )
659 m_pagesData
.Append( nb_page
);
661 m_pagesData
.Insert( position
, nb_page
);
663 m_pages
.Insert(win
, position
);
665 nb_page
->m_box
= gtk_hbox_new( FALSE
, 1 );
666 gtk_container_border_width( GTK_CONTAINER(nb_page
->m_box
), 2 );
668 g_signal_connect (win
->m_widget
, "size_allocate",
669 G_CALLBACK (gtk_page_size_callback
), win
);
671 gtk_notebook_insert_page( notebook
, win
->m_widget
, nb_page
->m_box
, position
);
673 nb_page
->m_page
= (GtkNotebookPage
*) g_list_last(notebook
->children
)->data
;
675 /* set the label image */
676 nb_page
->m_image
= imageId
;
680 wxASSERT( m_imageList
!= NULL
);
682 const wxBitmap
*bmp
= m_imageList
->GetBitmapPtr(imageId
);
683 GdkPixmap
*pixmap
= bmp
->GetPixmap();
684 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
685 if ( bmp
->GetMask() )
687 mask
= bmp
->GetMask()->GetBitmap();
690 GtkWidget
*pixmapwid
= gtk_pixmap_new (pixmap
, mask
);
692 gtk_box_pack_start(GTK_BOX(nb_page
->m_box
), pixmapwid
, FALSE
, FALSE
, m_padding
);
694 gtk_widget_show(pixmapwid
);
697 /* set the label text */
699 nb_page
->m_text
= text
;
700 if (nb_page
->m_text
.IsEmpty()) nb_page
->m_text
= wxT("");
702 nb_page
->m_label
= GTK_LABEL( gtk_label_new(wxGTK_CONV(nb_page
->m_text
)) );
703 gtk_box_pack_end( GTK_BOX(nb_page
->m_box
), GTK_WIDGET(nb_page
->m_label
), FALSE
, FALSE
, m_padding
);
705 /* apply current style */
706 GtkRcStyle
*style
= CreateWidgetStyle();
709 gtk_widget_modify_style(GTK_WIDGET(nb_page
->m_label
), style
);
710 gtk_rc_style_unref(style
);
714 gtk_widget_show( GTK_WIDGET(nb_page
->m_label
) );
715 if (select
&& (m_pagesData
.GetCount() > 1))
717 SetSelection( position
);
720 g_signal_connect (m_widget
, "switch_page",
721 G_CALLBACK (gtk_notebook_page_change_callback
), this);
723 InvalidateBestSize();
727 // helper for HitTest(): check if the point lies inside the given widget which
728 // is the child of the notebook whose position and border size are passed as
731 IsPointInsideWidget(const wxPoint
& pt
, GtkWidget
*w
,
732 gint x
, gint y
, gint border
= 0)
735 (pt
.x
>= w
->allocation
.x
- x
- border
) &&
736 (pt
.x
<= w
->allocation
.x
- x
+ border
+ w
->allocation
.width
) &&
737 (pt
.y
>= w
->allocation
.y
- y
- border
) &&
738 (pt
.y
<= w
->allocation
.y
- y
+ border
+ w
->allocation
.height
);
741 int wxNotebook::HitTest(const wxPoint
& pt
, long *flags
) const
743 const gint x
= m_widget
->allocation
.x
;
744 const gint y
= m_widget
->allocation
.y
;
746 const size_t count
= GetPageCount();
749 GtkNotebook
* notebook
= GTK_NOTEBOOK(m_widget
);
750 if (gtk_notebook_get_scrollable(notebook
));
751 i
= g_list_position( notebook
->children
, notebook
->first_tab
);
753 for ( ; i
< count
; i
++ )
755 wxGtkNotebookPage
* nb_page
= GetNotebookPage(i
);
756 GtkWidget
*box
= nb_page
->m_box
;
758 const gint border
= gtk_container_get_border_width(GTK_CONTAINER(box
));
760 if ( IsPointInsideWidget(pt
, box
, x
, y
, border
) )
762 // ok, we're inside this tab -- now find out where, if needed
765 GtkWidget
*pixmap
= NULL
;
767 GList
*children
= gtk_container_get_children(GTK_CONTAINER(box
));
768 for ( GList
*child
= children
; child
; child
= child
->next
)
770 if ( GTK_IS_PIXMAP(child
->data
) )
772 pixmap
= GTK_WIDGET(child
->data
);
778 g_list_free(children
);
780 if ( pixmap
&& IsPointInsideWidget(pt
, pixmap
, x
, y
) )
782 *flags
= wxNB_HITTEST_ONICON
;
784 else if ( IsPointInsideWidget(pt
, GTK_WIDGET(nb_page
->m_label
), x
, y
) )
786 *flags
= wxNB_HITTEST_ONLABEL
;
790 *flags
= wxNB_HITTEST_ONITEM
;
799 *flags
= wxNB_HITTEST_NOWHERE
;
804 void wxNotebook::OnNavigationKey(wxNavigationKeyEvent
& event
)
806 if (event
.IsWindowChange())
807 AdvanceSelection( event
.GetDirection() );
812 #if wxUSE_CONSTRAINTS
814 // override these 2 functions to do nothing: everything is done in OnSize
815 void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse
) )
817 // don't set the sizes of the pages - their correct size is not yet known
818 wxControl::SetConstraintSizes(FALSE
);
821 bool wxNotebook::DoPhase( int WXUNUSED(nPhase
) )
828 void wxNotebook::DoApplyWidgetStyle(GtkRcStyle
*style
)
830 gtk_widget_modify_style(m_widget
, style
);
831 size_t cnt
= m_pagesData
.GetCount();
832 for (size_t i
= 0; i
< cnt
; i
++)
833 gtk_widget_modify_style(GTK_WIDGET(GetNotebookPage(i
)->m_label
), style
);
836 bool wxNotebook::IsOwnGtkWindow( GdkWindow
*window
)
838 return ((m_widget
->window
== window
) ||
839 GTK_NOTEBOOK(m_widget
)->event_window
== window
);
844 wxNotebook::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
846 return GetDefaultAttributesFromGTKWidget(gtk_notebook_new
);
849 //-----------------------------------------------------------------------------
851 //-----------------------------------------------------------------------------
853 IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent
, wxNotifyEvent
)