1 /*=========================================================================
4 Module: $RCSfile: bbwxSplit.cxx,v $
6 Date: $Date: 2008/01/22 15:41:35 $
7 Version: $Revision: 1.2 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
24 #ifdef _USE_WXWIDGETS_
26 #include "bbwxSplit.h"
27 #include "bbwxPackage.h"
33 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,Split);
35 //-------------------------------------------------------------------------
36 SplitWidget::SplitWidget(Split* box,
40 WxBlackBoxWidgetPanel(box,parent),
41 mOrientation(orientation)
42 //( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
44 wxPanel *panel = this->GetPanel();
45 mwxSplitterWindow = new wxSplitterWindow(panel,-1,
51 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
52 sizer -> Add(mwxSplitterWindow, 1, wxGROW, 0);
54 //mwxSplitterWindow -> SetMinimumPaneSize(25);
56 mwxSplitterWindow -> SetMinimumPaneSize(25);
57 #endif // defined(_WIN32)
59 panel -> SetSizer(sizer);
60 panel -> SetAutoLayout(true);
63 //-------------------------------------------------------------------------
65 //-------------------------------------------------------------------------
66 void SplitWidget::SetChilds(wxWindow* child1,wxWindow* child2,
69 if (mwxSplitterWindow->IsSplit()) return;
72 int sz = (int)(GetParent()->GetSize().GetHeight() * prop * 0.01);
73 mwxSplitterWindow->SplitHorizontally( child1 , child2, sz);
77 int sz = (int)(GetParent()->GetSize().GetWidth() * prop * 0.01);
78 mwxSplitterWindow->SplitVertically( child1 , child2, sz );
84 SplitWidget::~SplitWidget()
89 //-------------------------------------------------------------------------
90 wxSplitterWindow *SplitWidget::GetWxSplitterWindow()
92 return mwxSplitterWindow;
96 //--------------------------------------------------------------------------
97 //-------------------------------------------------------------------------
98 //--------------------------------------------------------------------------
99 //--------------------------------------------------------------------------
102 BBTK_USER_BLACK_BOX_IMPLEMENTATION(Split,bbtk::WxBlackBox);
105 void Split::bbUserConstructor()
107 bbSetInputOrientation(0);
108 bbSetInputProportion(50);
111 void Split::Process()
115 void Split::CreateWidget()
117 wxSplitterWindow* w = new wxSplitterWindow(bbGetWxParent(),
124 wxWindow* w1 = bbGetInputWidget1();
125 wxWindow* w2 = bbGetInputWidget2();
126 //w->SetInitialSize(wxSize(100,100));
127 // int sz = (int)(GetParent()->GetSize().GetHeight() * prop * 0.01);
130 w->SplitHorizontally( w1, w2, 100);
131 //w->SetMinimumPaneSize(100);
132 // w->SetAutoLayout(true);
137 bbSetOutputWidget( w );
142 * \brief Create wxWidget .
147 bbtk::WxBlackBoxWidget *Split::bbUserCreateWidget(wxWindow *parent)
149 //printf("EED Split::CreateWxWindow \n" );
150 bbtkDebugMessageInc("Core",9,"Split::bbUserCreateWidget("<<parent<<")"<<std::endl);
152 SplitWidget *wxwidgetsplit = new SplitWidget(this, parent ,
153 bbGetInputOrientation() );
155 OutputConnectorMapType::iterator i;
156 for (i=bbGetOutputConnectorMap().begin() ; i!=bbGetOutputConnectorMap().end(); ++i )
158 if (i->first=="WinChild")
160 const std::vector<bbtk::Connection*>& C = i->second->GetConnectionVector();
161 std::vector<bbtk::Connection*>::const_iterator j;
165 wxPanel *w1 = new wxPanel(wxwidgetsplit->GetWxSplitterWindow() ,-1 );
166 wxPanel *w2 = new wxPanel(wxwidgetsplit->GetWxSplitterWindow() ,-1 );
167 bbtkDebugMessage("Debug",1,"Creating panel for "<<(*j)->GetFullName());
168 bbmOutputWinChild->AddToConnectionToWindowMap(*j,w1);
169 bbtkDebugMessage("Debug",1,"..OK"<<std::endl);
171 bbtkDebugMessage("Debug",1,"Creating panel for "<<(*j)->GetFullName());
172 bbmOutputWinChild->AddToConnectionToWindowMap(*j,w2);
174 bbtkDebugMessage("Debug",1,"..OK"<<std::endl);
175 wxwidgetsplit->SetChilds( w1 , w2, bbGetInputProportion() );
183 bbtkDebugDecTab("Core",9);
185 return wxwidgetsplit;
192 #endif // _USE_WXWIDGETS_