wxObject* wxsListbook::OnBuildPreview(wxWindow* Parent,long PreviewFlags) { UpdateCurrentSelection(); wxListbook* Listbook = new wxListbook(Parent,-1,Pos(Parent),Size(Parent),Style()); if ( !GetChildCount() && !(PreviewFlags&pfExact) ) { // Adding additional empty notebook to prevent from having zero-sized notebook Listbook->AddPage( new wxPanel(Listbook,-1,wxDefaultPosition,wxSize(50,50)), _("No pages")); } AddChildrenPreview(Listbook,PreviewFlags); for ( int i=0; i<GetChildCount(); i++ ) { wxsItem* Child = GetChild(i); wxsListbookExtra* LBExtra = (wxsListbookExtra*)GetChildExtra(i); wxWindow* ChildPreview = wxDynamicCast(GetChild(i)->GetLastPreview(),wxWindow); if ( !ChildPreview ) continue; bool Selected = (Child == m_CurrentSelection); if ( PreviewFlags & pfExact ) Selected = LBExtra->m_Selected; Listbook->AddPage(ChildPreview,LBExtra->m_Label,Selected); } return Listbook; }
wxObject* wxsSashLayoutWindow::OnBuildPreview(wxWindow* Parent,long Flags) { // make a thing to display wxSashLayoutWindow* swin = new wxSashLayoutWindow(Parent,GetId(),Pos(Parent),Size(Parent),Style()); SetupWindow(swin, Flags); // for now, a sash on all edges swin->SetSashVisible(wxSASH_TOP, mTop); swin->SetSashVisible(wxSASH_BOTTOM, mBottom); swin->SetSashVisible(wxSASH_LEFT, mLeft); swin->SetSashVisible(wxSASH_RIGHT, mRight); // set the alignment if (mAlign == wxLAYOUT_TOP) swin->SetAlignment(wxLAYOUT_TOP); else if (mAlign == wxLAYOUT_BOTTOM) swin->SetAlignment(wxLAYOUT_BOTTOM); else if (mAlign == wxLAYOUT_LEFT) swin->SetAlignment(wxLAYOUT_LEFT); else if (mAlign == wxLAYOUT_RIGHT) swin->SetAlignment(wxLAYOUT_RIGHT); // orientation if (mOrient == wxLAYOUT_HORIZONTAL) swin->SetOrientation(wxLAYOUT_HORIZONTAL); else swin->SetOrientation(wxLAYOUT_VERTICAL); // don't forget the kids AddChildrenPreview(swin, Flags); // done return swin; }
wxObject* wxsScrolledWindow::OnBuildPreview(wxWindow* Parent,long Flags) { // TODO: Use grid-viewing panel when not in exact mode wxWindow* NewItem = new wxScrolledWindow( Parent,GetId(),wxDefaultPosition,wxDefaultSize,Style()); SetupWindow(NewItem,Flags); AddChildrenPreview(NewItem,Flags); return NewItem; }
wxObject* wxsPanel::OnBuildPreview(wxWindow* Parent,long Flags) { wxWindow* NewItem = 0; if ( Flags & pfExact ) { NewItem = new wxPanel(Parent,GetId(),Pos(Parent),Size(Parent),Style()); } else { NewItem = new PanelPreview(Parent,GetId(),Pos(Parent),Size(Parent),Style(),IsRootItem()); } NewItem->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); SetupWindow(NewItem,Flags); AddChildrenPreview(NewItem,Flags); return NewItem; }
wxObject* wxsImagePanel::OnBuildPreview(wxWindow* Parent, long Flags) { wxImagePanel *ap; wxsImage *image; wxBitmap bmp; // make a panel ap = new wxImagePanel(Parent, GetId(), Pos(Parent), Size(Parent), Style()); if (ap == NULL) return NULL; // get the wxsImage pointer image = (wxsImage *) wxsImageListEditorDlg::FindTool(this, mImage); // and make the preview image if (image != NULL) { bmp = ((wxsImage *) image)->GetPreview(); ap->SetBitmap(bmp); } else{ // in case we can't find the name in ImageList, we try to interpret it as a filepath // see discussion http://forums.codeblocks.org/index.php/topic,22888.0.html wxImage Img(mImage); if (Img.Ok()) { bmp = wxBitmap(Img); ap->SetBitmap(bmp); } }; // and stretch it? ap->SetStretch(mStretch); // set all decorations SetupWindow(ap, Flags); // add the children AddChildrenPreview(ap, Flags); // done return ap; }
wxObject* wxsSplitterWindow::OnBuildPreview(wxWindow* Parent,long Flags) { wxSplitterWindow* Splitter = new wxSplitterWindow(Parent,GetId(),Pos(Parent),Size(Parent),Style()); SetupWindow(Splitter,Flags); if ( MinSize != -1 ) { Splitter->SetMinimumPaneSize(MinSize); } AddChildrenPreview(Splitter,Flags); if ( GetChildCount() == 0 ) { } else if ( GetChildCount() == 1 ) { Splitter->Initialize(wxDynamicCast(GetChild(0)->GetLastPreview(),wxWindow)); } else { if ( Orientation == wxHORIZONTAL ) { Splitter->SplitHorizontally( wxDynamicCast(GetChild(0)->GetLastPreview(),wxWindow), wxDynamicCast(GetChild(1)->GetLastPreview(),wxWindow), SashPos); } else { Splitter->SplitVertically( wxDynamicCast(GetChild(0)->GetLastPreview(),wxWindow), wxDynamicCast(GetChild(1)->GetLastPreview(),wxWindow), SashPos); } Splitter->SetSashGravity(SashGravity); // Some trick to faster relayout splitter window Splitter->OnInternalIdle(); } return Splitter; }
wxObject* wxsSashWindow::OnBuildPreview(wxWindow* Parent,long Flags) { // make a thing to display wxSashWindow *swin = new wxSashWindow(Parent,GetId(),Pos(Parent),Size(Parent),Style()); SetupWindow(swin, Flags); // for now, a sash on all edges swin->SetSashVisible(wxSASH_TOP, mTop); swin->SetSashVisible(wxSASH_BOTTOM, mBottom); swin->SetSashVisible(wxSASH_LEFT, mLeft); swin->SetSashVisible(wxSASH_RIGHT, mRight); // don't forget the kids AddChildrenPreview(swin, Flags); // done return swin; }
wxObject* wxsMathPlot::OnBuildPreview(wxWindow* Parent, long Flags) { mpWindow *mp; // make a panel mp = new mpWindow(Parent, GetId(), Pos(Parent), Size(Parent), Style()); if (mp == NULL) return NULL; SetupWindow(mp, Flags); // add kids AddChildrenPreview(mp, Flags); // and update the display mp->UpdateAll(); mp->Fit(); // done return mp; }
wxObject* wxsDialog::OnBuildPreview(wxWindow* Parent,long Flags) { wxWindow* NewItem = 0; wxDialog* Dlg = 0; // In case of frame and dialog when in "Exact" mode, we do not create // new object, but use Parent and call Create for it. if ( Flags & pfExact ) { Dlg = wxDynamicCast(Parent,wxDialog); if ( Dlg ) { Dlg->Create(0,GetId(),Title,wxDefaultPosition,wxDefaultSize,Style()); Dlg->SetClientSize(Size(wxTheApp->GetTopWindow())); Dlg->Move(Pos(wxTheApp->GetTopWindow())); } NewItem = Dlg; SetupWindow(NewItem,Flags); AddChildrenPreview(NewItem,Flags); if ( Centered ) { Dlg->Centre(); } } else { NewItem = new wxsGridPanel(Parent,GetId(),wxPoint(0,0),Size(Parent),0); NewItem->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); SetupWindow(NewItem,Flags); AddChildrenPreview(NewItem,Flags); // wxPanel tends to behave very strange when it has children and no sizer, // we have to manually resize it's content if ( !GetChildCount() || GetChild(0)->GetType()!=wxsTSizer ) { wxSize NewSize = Size(Parent); if ( !NewSize.IsFullySpecified() ) { NewSize.SetDefaults(wxSize(400,450)); NewItem->SetSize(NewSize); #if wxCHECK_VERSION(2,8,0) NewItem->SetInitialSize(NewSize); #else NewItem->SetBestFittingSize(NewSize); #endif if ( GetChildCount() == 1 ) { // If there's only one child it's size gets dialog's size wxWindow* ChildPreview = wxDynamicCast(GetChild(0)->GetLastPreview(),wxWindow); if ( ChildPreview ) { ChildPreview->SetSize(0,0,NewItem->GetClientSize().GetWidth(),NewItem->GetClientSize().GetHeight()); } } } else { NewItem->SetSize(NewSize); #if wxCHECK_VERSION(2,8,0) NewItem->SetInitialSize(NewSize); #else NewItem->SetBestFittingSize(NewSize); #endif } } } return NewItem; }