1 /*=========================================================================
3 Module: $RCSfile: bbwxLayoutSplit.cxx,v $
5 Date: $Date: 2009/05/28 08:12:17 $
6 Version: $Revision: 1.12 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
37 #ifdef _USE_WXWIDGETS_
39 #include "bbwxLayoutSplit.h"
40 #include "bbwxPackage.h"
41 #include "bbtkUtilities.h"
46 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,LayoutSplit);
47 BBTK_BLACK_BOX_IMPLEMENTATION(LayoutSplit,bbtk::WxBlackBox);
49 //-----------------------------------------------------------------
50 void LayoutSplit::bbUserSetDefaultValues()
52 bbSetInputOrientation("VERTICAL");
53 bbSetInputProportion(50);
54 bbSetInputWidget1(NULL);
55 bbSetInputWidget2(NULL);
58 //-----------------------------------------------------------------
59 void LayoutSplit::bbUserInitializeProcessing()
63 //-----------------------------------------------------------------
64 void LayoutSplit::bbUserFinalizeProcessing()
68 void LayoutSplit::Process()
72 void LayoutSplit::CreateWidget(wxWindow* parent)
74 wxSplitterWindow* w = new wxSplitterWindow(parent, //bbGetWxParent(),
81 w->SetName( bbtk::std2wx( bbGetInputWinTitle() ) );
82 w->SetMinimumPaneSize(2);
84 wxWindow* w1 = bbGetInputWidget1();
85 wxWindow* w2 = bbGetInputWidget2();
87 if (w1==NULL) { w1=new wxPanel(bbGetWxParent()); }
88 if (w2==NULL) { w2=new wxPanel(bbGetWxParent()); }
93 wxWindow* w1 = bbCreateWidgetOfInput("Widget1",w);
94 wxWindow* w2 = bbCreateWidgetOfInput("Widget2",w);
95 if (w1==NULL) { w1=new wxPanel(parent); }
96 if (w2==NULL) { w2=new wxPanel(parent); }
99 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"0|H|HORIZONTAL")==true) { orientation=0; }
100 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|V|VERTICAL")==true) { orientation=1; }
103 if (orientation==1) { w->SplitHorizontally( w1, w2, 100); }
104 else { w->SplitVertically( w1, w2, 100); }
106 bbSetOutputWidget( w );
110 // This callback is necessary to get actual processing of the view
111 // when window is shown
112 void LayoutSplit::OnShowWidget()
114 // std::cout << "LayoutSplit::OnShowWidget()" << std::endl;
115 if (bbGetOutputWidget()==0)
118 //bbtkError("LayoutSplit::OnShowWidget() : Output Widget == 0 !");
120 wxSplitterWindow* win = (wxSplitterWindow*)bbGetOutputWidget();
125 // bbtkError("LayoutSplit::OnShowWidget() : win == 0 !");
127 win->GetClientSize(&w,&h);
129 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),
130 "0|H|HORIZONTAL")==true)
132 pos = (int)(w * bbGetInputProportion() * 0.01);
136 pos = (int)(h * bbGetInputProportion() * 0.01);
138 // std::cout << "pos = "<<pos<<std::endl;
140 win->SetSashPosition(pos,true);
148 #endif // _USE_WXWIDGETS_