/*========================================================================= Program: bbtk Module: $RCSfile: bbwxLayoutSplit.cxx,v $ Language: C++ Date: $Date: 2008/10/14 10:11:15 $ Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ /** * \file * \brief */ #ifdef _USE_WXWIDGETS_ #include "bbwxLayoutSplit.h" #include "bbwxPackage.h" #include "bbtkUtilities.h" namespace bbwx { BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,LayoutSplit); BBTK_BLACK_BOX_IMPLEMENTATION(LayoutSplit,bbtk::WxBlackBox); void LayoutSplit::bbUserConstructor() { bbSetInputOrientation("VERTICAL"); bbSetInputProportion(50); bbSetInputWidget1(NULL); bbSetInputWidget2(NULL); } void LayoutSplit::Process() { } void LayoutSplit::CreateWidget() { wxSplitterWindow* w = new wxSplitterWindow(bbGetWxParent(), -1, wxDefaultPosition, wxDefaultSize, //wxSize(400,200), wxSP_3D | wxSP_LIVE_UPDATE ); w->SetName( bbtk::std2wx( bbGetInputWinTitle() ) ); wxWindow* w1 = bbGetInputWidget1(); wxWindow* w2 = bbGetInputWidget2(); if (w1==NULL) { w1=new wxPanel(bbGetWxParent()); } if (w2==NULL) { w2=new wxPanel(bbGetWxParent()); } w1->Reparent(w); w2->Reparent(w); int orientation=0; if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"0|H|HORIZONTAL")==true) { orientation=0; } if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|V|VERTICAL")==true) { orientation=1; } if (orientation==1) { w->SplitHorizontally( w1, w2, 100); } else { w->SplitVertically( w1, w2, 100); } bbSetOutputWidget( w ); } // This callback is necessary to get actual processing of the view // when window is shown void LayoutSplit::bbUserOnShow() { wxSplitterWindow* win = (wxSplitterWindow*)bbGetOutputWidget(); int w,h; win->GetClientSize(&w,&h); int pos = 100; if (bbtk::Utilities::loosematch(bbGetInputOrientation(), "0|H|HORIZONTAL")==true) { pos = (int)(w * bbGetInputProportion() * 0.01); } else { pos = (int)(h * bbGetInputProportion() * 0.01); } win->SetSashPosition(pos,true); bbUserOnShowWidget("Widget1"); bbUserOnShowWidget("Widget2"); } }//namespace bbwx #endif // _USE_WXWIDGETS_