+void WidgetsFrame::OnPageChanging(WidgetsBookCtrlEvent& event)
+{
+#if USE_TREEBOOK
+ // don't allow selection of entries without pages (categories)
+ if ( !m_book->GetPage(event.GetSelection()) )
+ event.Veto();
+#else
+ wxUnusedVar(event);
+#endif
+}
+
+void WidgetsFrame::OnPageChanged(WidgetsBookCtrlEvent& event)
+{
+ const int sel = event.GetSelection();
+
+ // adjust "Page" menu selection
+ wxMenuItem *item = GetMenuBar()->FindItem(Widgets_GoToPage + sel);
+ if ( item )
+ item->Check();
+
+ GetMenuBar()->Check(Widgets_BusyCursor, false);
+
+ // create the pages on demand, otherwise the sample startup is too slow as
+ // it creates hundreds of controls
+ WidgetsPage *page = CurrentPage();
+ if ( page->GetChildren().empty() )
+ {
+ wxWindowUpdateLocker noUpdates(page);
+ page->CreateContent();
+ //page->Layout();
+ page->GetSizer()->Fit(page);
+
+ WidgetsBookCtrl *book = wxStaticCast(page->GetParent(), WidgetsBookCtrl);
+ wxSize size;
+ for ( size_t i = 0; i < book->GetPageCount(); ++i )
+ {
+ wxWindow *page = book->GetPage(i);
+ if ( page )
+ {
+ size.IncTo(page->GetSize());
+ }
+ }
+ page->SetSize(size);
+ }
+
+ event.Skip();
+}
+
+void WidgetsFrame::OnGoToPage(wxCommandEvent& event)
+{
+#if USE_TREEBOOK
+ m_book->SetSelection(event.GetId() - Widgets_GoToPage);
+#else
+ m_book->SetSelection(m_book->GetPageCount()-1);
+ WidgetsBookCtrl *book = wxStaticCast(m_book->GetCurrentPage(), WidgetsBookCtrl);
+ book->SetSelection(event.GetId() - Widgets_GoToPage);
+#endif
+}
+
+#if wxUSE_TOOLTIPS
+
+void WidgetsFrame::OnSetTooltip(wxCommandEvent& WXUNUSED(event))
+{
+ static wxString s_tip = _T("This is a tooltip");
+
+ wxTextEntryDialog dialog
+ (
+ this,
+ _T("Tooltip text (may use \\n, leave empty to remove): "),
+ _T("Widgets sample"),
+ s_tip
+ );
+
+ if ( dialog.ShowModal() != wxID_OK )
+ return;
+
+ s_tip = dialog.GetValue();
+ s_tip.Replace(_T("\\n"), _T("\n"));
+
+ WidgetsPage *page = CurrentPage();
+
+ page->GetWidget()->SetToolTip(s_tip);
+
+ wxControl *ctrl2 = page->GetWidget2();
+ if ( ctrl2 )
+ ctrl2->SetToolTip(s_tip);
+}
+
+#endif // wxUSE_TOOLTIPS
+