#include "wx/fontdlg.h"
#include "wx/textdlg.h"
#include "wx/imaglist.h"
+#include "wx/wupdlock.h"
#include "widgets.h"
// we have 2 panes: book with pages demonstrating the controls in the
// upper one and the log window with some buttons in the lower
- int style = wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN|WidgetBookStyle;
+ int style = wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN|wxBK_DEFAULT;
// Uncomment to suppress page theme (draw in solid colour)
//style |= wxNB_NOPAGETHEME;
wxID_ANY,
wxDefaultPosition,
wxDefaultSize,
- WidgetBookStyle);
+ wxBK_DEFAULT);
#endif
for ( WidgetsPageInfo *info = WidgetsPage::ms_widgetPages;
WidgetsPage *WidgetsFrame::CurrentPage()
{
+ wxWindow *page = m_book->GetCurrentPage();
+ if(!page) return NULL;
+
#if USE_TREEBOOK
- return wxStaticCast(m_book->GetCurrentPage(), WidgetsPage);
+ return wxStaticCast(page, WidgetsPage);
#else
- WidgetsBookCtrl *book = wxStaticCast(m_book->GetCurrentPage(), WidgetsBookCtrl);
- if (!book) return NULL;
- return wxStaticCast(book->GetCurrentPage(), WidgetsPage);
+ WidgetsBookCtrl *subBook = wxStaticCast(page, WidgetsBookCtrl);
+ if (!subBook) return NULL;
+ page = subBook->GetCurrentPage();
+ if(!page) return NULL;
+ return wxStaticCast(page, WidgetsPage);
#endif
}
void WidgetsFrame::OnPageChanged(WidgetsBookCtrlEvent& event)
{
+ // adjust "Page" menu selection
wxMenuItem *item = GetMenuBar()->FindItem(Widgets_GoToPage + event.GetSelection());
if (item) item->Check();
+
+ // lazy creation of the pages
+ WidgetsPage* page = CurrentPage();
+ if (page && (page->GetChildren().GetCount()==0))
+ {
+ wxWindowUpdateLocker noUpdates(page);
+ page->CreateContent();
+ 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();
}