1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/notebook.cpp
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling, Vadim Zeitlin
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
14 #include "wx/notebook.h"
21 #include "wx/msgdlg.h"
22 #include "wx/bitmap.h"
25 #include "wx/imaglist.h"
26 #include "wx/fontutil.h"
28 #include "wx/gtk1/private.h"
29 #include "wx/gtk1/win_gtk.h"
31 #include <gdk/gdkkeysyms.h>
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
37 extern void wxapp_install_idle_handler();
40 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
44 extern bool g_blockEventsOnDrag
;
46 //-----------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------
50 // VZ: this is rather ugly as we keep the pages themselves in an array (it
51 // allows us to have quite a few functions implemented in the base class)
52 // but the page data is kept in a separate list, so we must maintain them
53 // in sync manually... of course, the list had been there before the base
54 // class which explains it but it still would be nice to do something
57 class wxGtkNotebookPage
: public wxObject
69 GtkNotebookPage
*m_page
;
71 GtkWidget
*m_box
; // in which the label and image are packed
75 #include "wx/listimpl.cpp"
76 WX_DEFINE_LIST(wxGtkNotebookPagesList
)
79 //-----------------------------------------------------------------------------
81 //-----------------------------------------------------------------------------
84 static void gtk_notebook_page_change_callback(GtkNotebook
*WXUNUSED(widget
),
85 GtkNotebookPage
*WXUNUSED(page
),
87 wxNotebook
*notebook
)
89 // are you trying to call SetSelection() from a notebook event handler?
91 wxCHECK_RET( !notebook
->m_inSwitchPage
,
92 wxT("gtk_notebook_page_change_callback reentered") );
94 notebook
->m_inSwitchPage
= true;
96 wxapp_install_idle_handler();
98 int old
= notebook
->GetSelection();
100 if (notebook
->m_skipNextPageChangeEvent
)
102 // this event was programmatically generated by ChangeSelection() and thus must
104 notebook
->m_skipNextPageChangeEvent
= false;
106 // make wxNotebook::GetSelection() return the correct (i.e. consistent
107 // with wxBookCtrlEvent::GetSelection()) value even though the page is
108 // not really changed in GTK+
109 notebook
->SetSelection(page
);
113 if ( !notebook
->SendPageChangingEvent(page
) )
115 // program doesn't allow the page change
116 gtk_signal_emit_stop_by_name(GTK_OBJECT(notebook
->m_widget
), "switch_page");
118 else // change allowed
120 // make wxNotebook::GetSelection() return the correct (i.e. consistent
121 // with wxBookCtrlEvent::GetSelection()) value even though the page is
122 // not really changed in GTK+
123 notebook
->SetSelection(page
);
125 notebook
->SendPageChangedEvent(old
);
129 notebook
->m_inSwitchPage
= FALSE
;
133 //-----------------------------------------------------------------------------
135 //-----------------------------------------------------------------------------
138 static void gtk_page_size_callback( GtkWidget
*WXUNUSED(widget
), GtkAllocation
* alloc
, wxWindow
*win
)
141 wxapp_install_idle_handler();
143 if ((win
->m_x
== alloc
->x
) &&
144 (win
->m_y
== alloc
->y
) &&
145 (win
->m_width
== alloc
->width
) &&
146 (win
->m_height
== alloc
->height
))
151 win
->SetSize( alloc
->x
, alloc
->y
, alloc
->width
, alloc
->height
);
153 /* GTK 1.2 up to version 1.2.5 is broken so that we have to call allocate
154 here in order to make repositioning after resizing to take effect. */
155 if ((gtk_major_version
== 1) &&
156 (gtk_minor_version
== 2) &&
157 (gtk_micro_version
< 6) &&
159 (GTK_WIDGET_REALIZED(win
->m_wxwindow
)))
161 gtk_widget_size_allocate( win
->m_wxwindow
, alloc
);
166 //-----------------------------------------------------------------------------
167 // "realize" from m_widget
168 //-----------------------------------------------------------------------------
172 gtk_notebook_realized_callback( GtkWidget
* WXUNUSED(widget
), wxWindow
*win
)
175 wxapp_install_idle_handler();
177 /* GTK 1.2 up to version 1.2.5 is broken so that we have to call a queue_resize
178 here in order to make repositioning before showing to take effect. */
179 gtk_widget_queue_resize( win
->m_widget
);
185 //-----------------------------------------------------------------------------
187 //-----------------------------------------------------------------------------
190 static gint
gtk_notebook_key_press_callback( GtkWidget
*widget
, GdkEventKey
*gdk_event
, wxNotebook
*notebook
)
193 wxapp_install_idle_handler();
195 if (!notebook
->m_hasVMT
) return FALSE
;
196 if (g_blockEventsOnDrag
) return FALSE
;
198 /* win is a control: tab can be propagated up */
199 if ((gdk_event
->keyval
== GDK_Left
) || (gdk_event
->keyval
== GDK_Right
))
202 int nMax
= notebook
->GetPageCount();
203 if ( nMax
-- ) // decrement it to get the last valid index
205 int nSel
= notebook
->GetSelection();
207 // change selection wrapping if it becomes invalid
208 page
= (gdk_event
->keyval
!= GDK_Left
) ? nSel
== nMax
? 0
213 else // notebook is empty, no next page
218 // m_selection = page;
219 gtk_notebook_set_page( GTK_NOTEBOOK(widget
), page
);
221 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "key_press_event" );
225 /* win is a control: tab can be propagated up */
226 if ((gdk_event
->keyval
== GDK_Tab
) || (gdk_event
->keyval
== GDK_ISO_Left_Tab
))
228 int sel
= notebook
->GetSelection();
229 if (sel
== wxNOT_FOUND
)
231 wxGtkNotebookPage
*nb_page
= notebook
->GetNotebookPage(sel
);
232 wxCHECK_MSG( nb_page
, FALSE
, wxT("invalid selection in wxNotebook") );
234 wxNavigationKeyEvent event
;
235 event
.SetEventObject( notebook
);
236 /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
237 event
.SetDirection( (gdk_event
->keyval
== GDK_Tab
) );
238 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
239 event
.SetWindowChange( (gdk_event
->state
& GDK_CONTROL_MASK
) ||
240 (gdk_event
->keyval
== GDK_Left
) || (gdk_event
->keyval
== GDK_Right
) );
241 event
.SetCurrentFocus( notebook
);
243 wxNotebookPage
*client
= notebook
->GetPage(sel
);
244 if ( !client
->HandleWindowEvent( event
) )
249 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "key_press_event" );
257 //-----------------------------------------------------------------------------
258 // InsertChild callback for wxNotebook
259 //-----------------------------------------------------------------------------
261 static void wxInsertChildInNotebook( wxNotebook
* parent
, wxWindow
* child
)
263 // Hack Alert! (Part I): This sets the notebook as the parent of the child
264 // widget, and takes care of some details such as updating the state and
265 // style of the child to reflect its new location. We do this early
266 // because without it GetBestSize (which is used to set the initial size
267 // of controls if an explicit size is not given) will often report
268 // incorrect sizes since the widget's style context is not fully known.
269 // See bug #901694 for details
270 // (http://sourceforge.net/tracker/?func=detail&aid=901694&group_id=9863&atid=109863)
271 gtk_widget_set_parent(child
->m_widget
, parent
->m_widget
);
273 // NOTE: This should be considered a temporary workaround until we can
274 // work out the details and implement delaying the setting of the initial
275 // size of widgets until the size is really needed.
278 //-----------------------------------------------------------------------------
280 //-----------------------------------------------------------------------------
282 BEGIN_EVENT_TABLE(wxNotebook
, wxBookCtrlBase
)
283 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey
)
286 void wxNotebook::Init()
289 m_inSwitchPage
= false;
291 m_themeEnabled
= true;
294 wxNotebook::wxNotebook()
299 wxNotebook::wxNotebook( wxWindow
*parent
, wxWindowID id
,
300 const wxPoint
& pos
, const wxSize
& size
,
301 long style
, const wxString
& name
)
304 Create( parent
, id
, pos
, size
, style
, name
);
307 wxNotebook::~wxNotebook()
312 bool wxNotebook::Create(wxWindow
*parent
, wxWindowID id
,
313 const wxPoint
& pos
, const wxSize
& size
,
314 long style
, const wxString
& name
)
317 m_acceptsFocus
= true;
318 m_insertCallback
= (wxInsertChildFunction
)wxInsertChildInNotebook
;
320 if ( (style
& wxBK_ALIGN_MASK
) == wxBK_DEFAULT
)
323 if (!PreCreation( parent
, pos
, size
) ||
324 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
326 wxFAIL_MSG( wxT("wxNoteBook creation failed") );
331 m_widget
= gtk_notebook_new();
333 gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget
), 1 );
335 gtk_signal_connect( GTK_OBJECT(m_widget
), "switch_page",
336 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
)this );
338 m_parent
->DoAddChild( this );
340 if (m_windowStyle
& wxBK_RIGHT
)
341 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_RIGHT
);
342 if (m_windowStyle
& wxBK_LEFT
)
343 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_LEFT
);
344 if (m_windowStyle
& wxBK_BOTTOM
)
345 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget
), GTK_POS_BOTTOM
);
347 gtk_signal_connect( GTK_OBJECT(m_widget
), "key_press_event",
348 GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback
), (gpointer
)this );
352 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
353 GTK_SIGNAL_FUNC(gtk_notebook_realized_callback
), (gpointer
) this );
358 int wxNotebook::GetSelection() const
360 wxCHECK_MSG( m_widget
!= NULL
, wxNOT_FOUND
, wxT("invalid notebook") );
362 if ( m_selection
== wxNOT_FOUND
)
364 GList
*nb_pages
= GTK_NOTEBOOK(m_widget
)->children
;
366 if (g_list_length(nb_pages
) != 0)
368 GtkNotebook
*notebook
= GTK_NOTEBOOK(m_widget
);
370 gpointer cur
= notebook
->cur_page
;
373 const_cast<wxNotebook
*>(this)->
374 SetSelection(g_list_index( nb_pages
, cur
));
382 wxString
wxNotebook::GetPageText( size_t page
) const
384 wxCHECK_MSG( m_widget
!= NULL
, wxEmptyString
, wxT("invalid notebook") );
386 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
388 return nb_page
->m_text
;
390 return wxEmptyString
;
393 int wxNotebook::GetPageImage( size_t page
) const
395 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid notebook") );
397 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
399 return nb_page
->m_image
;
404 wxGtkNotebookPage
* wxNotebook::GetNotebookPage( int page
) const
406 wxCHECK_MSG( m_widget
!= NULL
, NULL
, wxT("invalid notebook") );
408 wxCHECK_MSG( page
< (int)m_pagesData
.GetCount(), NULL
, wxT("invalid notebook index") );
410 return m_pagesData
.Item(page
)->GetData();
413 int wxNotebook::DoSetSelection( size_t page
, int flags
)
415 wxCHECK_MSG( m_widget
!= NULL
, wxNOT_FOUND
, wxT("invalid notebook") );
417 wxCHECK_MSG( page
< m_pagesData
.GetCount(), -1, wxT("invalid notebook index") );
419 int selOld
= GetSelection();
421 if ( !(flags
& SetSelection_SendEvent
) )
422 m_skipNextPageChangeEvent
= true;
424 // cache the selection
426 gtk_notebook_set_page( GTK_NOTEBOOK(m_widget
), page
);
428 // gtk_notebook_set_current_page is supposed to emit the switch-page signal
429 // which should be caught by our gtk_notebook_page_change_callback which
430 // should have reset the flag to false, check it:
431 wxASSERT_LEVEL_2_MSG(
432 (flags
& SetSelection_SendEvent
) || !m_skipNextPageChangeEvent
,
433 "internal error in selection events generation"
436 wxNotebookPage
*client
= GetPage(page
);
443 bool wxNotebook::SetPageText( size_t page
, const wxString
&text
)
445 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
447 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
449 wxCHECK_MSG( nb_page
, FALSE
, wxT("SetPageText: invalid page index") );
451 nb_page
->m_text
= text
;
453 gtk_label_set( nb_page
->m_label
, wxGTK_CONV( nb_page
->m_text
) );
458 bool wxNotebook::SetPageImage( size_t page
, int image
)
460 /* HvdH 28-12-98: now it works, but it's a bit of a kludge */
462 wxGtkNotebookPage
* nb_page
= GetNotebookPage(page
);
464 if (!nb_page
) return FALSE
;
466 /* Optimization posibility: return immediately if image unchanged.
467 * Not enabled because it may break existing (stupid) code that
468 * manipulates the imagelist to cycle images */
470 /* if (image == nb_page->m_image) return true; */
472 /* For different cases:
473 1) no image -> no image
478 if (image
== -1 && nb_page
->m_image
== -1)
479 return true; /* Case 1): Nothing to do. */
481 GtkWidget
*pixmapwid
= NULL
;
483 if (nb_page
->m_image
!= -1)
485 /* Case 2) or 4). There is already an image in the gtkhbox. Let's find it */
487 GList
*child
= gtk_container_children(GTK_CONTAINER(nb_page
->m_box
));
490 if (GTK_IS_PIXMAP(child
->data
))
492 pixmapwid
= GTK_WIDGET(child
->data
);
498 /* We should have the pixmap widget now */
499 wxASSERT(pixmapwid
!= NULL
);
503 /* If there's no new widget, just remove the old from the box */
504 gtk_container_remove(GTK_CONTAINER(nb_page
->m_box
), pixmapwid
);
505 nb_page
->m_image
= -1;
507 return true; /* Case 2) */
511 /* Only cases 3) and 4) left */
512 wxASSERT( HasImageList() ); /* Just in case */
514 /* Construct the new pixmap */
515 const wxBitmap
*bmp
= GetImageList()->GetBitmapPtr(image
);
516 GdkPixmap
*pixmap
= bmp
->GetPixmap();
517 GdkBitmap
*mask
= NULL
;
518 if ( bmp
->GetMask() )
520 mask
= bmp
->GetMask()->GetBitmap();
523 if (pixmapwid
== NULL
)
525 /* Case 3) No old pixmap. Create a new one and prepend it to the hbox */
526 pixmapwid
= gtk_pixmap_new (pixmap
, mask
);
528 /* CHECKME: Are these pack flags okay? */
529 gtk_box_pack_start(GTK_BOX(nb_page
->m_box
), pixmapwid
, FALSE
, FALSE
, m_padding
);
530 gtk_widget_show(pixmapwid
);
534 /* Case 4) Simply replace the pixmap */
535 gtk_pixmap_set(GTK_PIXMAP(pixmapwid
), pixmap
, mask
);
538 nb_page
->m_image
= image
;
543 void wxNotebook::SetPageSize( const wxSize
&WXUNUSED(size
) )
545 wxFAIL_MSG( wxT("wxNotebook::SetPageSize not implemented") );
548 void wxNotebook::SetPadding( const wxSize
&padding
)
550 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid notebook") );
552 m_padding
= padding
.GetWidth();
555 for (i
=0; i
<int(GetPageCount()); i
++)
557 wxGtkNotebookPage
* nb_page
= GetNotebookPage(i
);
558 wxASSERT(nb_page
!= NULL
);
560 if (nb_page
->m_image
!= -1)
562 // gtk_box_set_child_packing sets padding on BOTH sides
563 // icon provides left padding, label provides center and right
564 int image
= nb_page
->m_image
;
566 SetPageImage(i
,image
);
568 wxASSERT(nb_page
->m_label
);
569 gtk_box_set_child_packing(GTK_BOX(nb_page
->m_box
),
570 GTK_WIDGET(nb_page
->m_label
),
571 FALSE
, FALSE
, m_padding
, GTK_PACK_END
);
575 void wxNotebook::SetTabSize(const wxSize
& WXUNUSED(sz
))
577 wxFAIL_MSG( wxT("wxNotebook::SetTabSize not implemented") );
580 bool wxNotebook::DeleteAllPages()
582 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
584 while (m_pagesData
.GetCount() > 0)
585 DeletePage( m_pagesData
.GetCount()-1 );
587 wxASSERT_MSG( GetPageCount() == 0, wxT("all pages must have been deleted") );
589 InvalidateBestSize();
590 return wxNotebookBase::DeleteAllPages();
593 wxNotebookPage
*wxNotebook::DoRemovePage( size_t page
)
595 if ( m_selection
!= wxNOT_FOUND
&& (size_t)m_selection
>= page
)
597 // the index will become invalid after the page is deleted
598 m_selection
= wxNOT_FOUND
;
601 wxNotebookPage
*client
= wxNotebookBase::DoRemovePage(page
);
605 gtk_widget_ref( client
->m_widget
);
606 gtk_widget_unrealize( client
->m_widget
);
607 gtk_widget_unparent( client
->m_widget
);
609 // gtk_notebook_remove_page() sends "switch_page" signal with some strange
610 // new page index (when deleting selected page 0, new page is 1 although,
611 // clearly, the selection should stay 0), so suppress this
612 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget
),
613 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
) this );
615 gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget
), page
);
617 gtk_signal_connect( GTK_OBJECT(m_widget
), "switch_page",
618 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
)this );
620 wxGtkNotebookPage
* p
= GetNotebookPage(page
);
621 m_pagesData
.DeleteObject(p
);
627 bool wxNotebook::InsertPage( size_t position
,
629 const wxString
& text
,
633 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, wxT("invalid notebook") );
635 wxCHECK_MSG( win
->GetParent() == this, FALSE
,
636 wxT("Can't add a page whose parent is not the notebook!") );
638 wxCHECK_MSG( position
<= GetPageCount(), FALSE
,
639 wxT("invalid page index in wxNotebookPage::InsertPage()") );
641 // Hack Alert! (Part II): See above in wxInsertChildInNotebook callback
642 // why this has to be done. NOTE: using gtk_widget_unparent here does not
643 // work as it seems to undo too much and will cause errors in the
644 // gtk_notebook_insert_page below, so instead just clear the parent by
646 win
->m_widget
->parent
= NULL
;
648 // don't receive switch page during addition
649 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget
),
650 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
) this );
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 gtk_signal_connect( GTK_OBJECT(win
->m_widget
), "size_allocate",
670 GTK_SIGNAL_FUNC(gtk_page_size_callback
), (gpointer
)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( HasImageList() );
683 const wxBitmap
*bmp
= GetImageList()->GetBitmapPtr(imageId
);
684 GdkPixmap
*pixmap
= bmp
->GetPixmap();
685 GdkBitmap
*mask
= 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
.empty()) nb_page
->m_text
= wxEmptyString
;
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 gtk_signal_connect( GTK_OBJECT(m_widget
), "switch_page",
722 GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback
), (gpointer
)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 // MR: Code to fix HitTest index return when tabs are scrolled.
751 // No idea if it would work for GTK1
753 GtkNotebook
* notebook
= GTK_NOTEBOOK(m_widget
);
754 if (gtk_notebook_get_scrollable(notebook
));
755 i
= g_list_position( notebook
->children
, notebook
->first_tab
);
758 for ( ; i
< count
; i
++ )
760 wxGtkNotebookPage
* nb_page
= GetNotebookPage(i
);
761 GtkWidget
*box
= nb_page
->m_box
;
763 // VZ: don't know how to find the border width in GTK+ 1.2
764 const gint border
= 0;
765 if ( IsPointInsideWidget(pt
, box
, x
, y
, border
) )
767 // ok, we're inside this tab -- now find out where, if needed
770 GtkWidget
*pixmap
= NULL
;
772 GList
*children
= gtk_container_children(GTK_CONTAINER(box
));
773 for ( GList
*child
= children
; child
; child
= child
->next
)
775 if ( GTK_IS_PIXMAP(child
->data
) )
777 pixmap
= GTK_WIDGET(child
->data
);
783 g_list_free(children
);
785 if ( pixmap
&& IsPointInsideWidget(pt
, pixmap
, x
, y
) )
787 *flags
= wxBK_HITTEST_ONICON
;
789 else if ( IsPointInsideWidget(pt
, GTK_WIDGET(nb_page
->m_label
), x
, y
) )
791 *flags
= wxBK_HITTEST_ONLABEL
;
795 *flags
= wxBK_HITTEST_ONITEM
;
804 *flags
= wxBK_HITTEST_NOWHERE
;
809 void wxNotebook::OnNavigationKey(wxNavigationKeyEvent
& event
)
811 if (event
.IsWindowChange())
812 AdvanceSelection( event
.GetDirection() );
817 #if wxUSE_CONSTRAINTS
819 // override these 2 functions to do nothing: everything is done in OnSize
820 void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse
) )
822 // don't set the sizes of the pages - their correct size is not yet known
823 wxControl::SetConstraintSizes(FALSE
);
826 bool wxNotebook::DoPhase( int WXUNUSED(nPhase
) )
833 void wxNotebook::DoApplyWidgetStyle(GtkRcStyle
*style
)
835 gtk_widget_modify_style(m_widget
, style
);
836 size_t cnt
= m_pagesData
.GetCount();
837 for (size_t i
= 0; i
< cnt
; i
++)
838 gtk_widget_modify_style(GTK_WIDGET(GetNotebookPage(i
)->m_label
), style
);
841 bool wxNotebook::IsOwnGtkWindow( GdkWindow
*window
)
843 return ((m_widget
->window
== window
) ||
844 (NOTEBOOK_PANEL(m_widget
) == window
));
849 wxNotebook::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
851 return GetDefaultAttributesFromGTKWidget(gtk_notebook_new
);