2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbkwLayoutSplit.cxx,v $
32 Date: $Date: 2012/11/16 08:51:05 $
33 Version: $Revision: 1.5 $
34 =========================================================================*/
46 #include "bbkwLayoutSplit.h"
47 #include "bbkwPackage.h"
48 #include "bbtkUtilities.h"
50 #include <vtkKWSplitFrame.h>
54 BBTK_ADD_BLACK_BOX_TO_PACKAGE(kw,LayoutSplit);
55 BBTK_BLACK_BOX_IMPLEMENTATION(LayoutSplit,bbtk::KWBlackBox);
57 void LayoutSplit::bbUserConstructor()
59 bbSetInputOrientation("VERTICAL");
60 bbSetInputProportion(50);
61 bbSetInputWidget1(NULL);
62 bbSetInputWidget2(NULL);
65 void LayoutSplit::Process()
70 void LayoutSplit::CreateWidget(vtkKWFrame* parent)
72 vtkKWSplitFrame *splitframe = vtkKWSplitFrame::New();
73 bbSetOutputWidget(splitframe);
74 splitframe->SetParent(parent);
76 splitframe->SetFrame1MinimumSize(5);
77 splitframe->SetFrame2MinimumSize(5);
78 splitframe->SetExpandableFrameToBothFrames();
81 int width = parent->GetWidth();
82 int height = parent->GetHeight();
84 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"0|H|HORIZONTAL")==true)
88 else if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|V|VERTICAL")==true)
94 bbtkWarning("Unrecognized value '"<<bbGetInputOrientation()<<"' for input 'Orientation' of LayoutSplit "<<bbGetName()<<std::endl);
99 splitframe->SetOrientationToHorizontal ();
104 splitframe->SetOrientationToVertical ();
105 height = height / 2 ;
109 height = height - 5 ;
112 bbGetOutputWidget()->GetApplication()->Script("place %s -x 0 -y 0 -width %d -height %d",
113 bbGetOutputWidget()->GetWidgetName(),
115 parent->GetHeight() );
117 bbGetOutputWidget()->GetApplication()->Script
118 ("pack %s -expand yes -fill both",
119 bbGetOutputWidget()->GetWidgetName());
121 splitframe->SetReliefToGroove();
122 splitframe->SetBorderWidth(2);
125 vtkKWWidget* w1 = bbCreateWidgetOfInput("Widget1",splitframe->GetFrame1());
127 vtkKWWidget* w2 = bbCreateWidgetOfInput("Widget2",splitframe->GetFrame2());
129 splitframe->GetApplication()->Script
130 ("pack %s -expand yes -fill both",
131 w1->GetWidgetName()) ;
132 splitframe->GetApplication()->Script
133 ("pack %s -expand yes -fill both",
134 w2->GetWidgetName()) ;
137 splitframe->GetApplication()->Script("pack %s -expand yes -fill x -fill y", w2->GetWidgetName());
140 splitframe->GetApplication()->Script("place %s -x 0 -y 0 -width %d -height %d",
145 splitframe->GetApplication()->Script("place %s -x 0 -y 0 -width %d -height %d",
155 // This callback is necessary to get actual processing of the view
156 // when window is shown
158 void LayoutSplit::OnShowWidget()
160 if (bbGetOutputWidget()==0)
163 //bbtkError("LayoutSplit::OnShowWidget() : Output Widget == 0 !");
165 kwSplitterWindow* win = (kwSplitterWindow*)bbGetOutputWidget();
170 // bbtkError("LayoutSplit::OnShowWidget() : win == 0 !");
172 win->GetClientSize(&w,&h);
174 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),
175 "0|H|HORIZONTAL")==true)
177 pos = (int)(w * bbGetInputProportion() * 0.01);
181 pos = (int)(h * bbGetInputProportion() * 0.01);
183 // std::cout << "pos = "<<pos<<std::endl;
185 win->SetSashPosition(pos,true);
186 bbUserOnShowWidget("Widget1");
187 bbUserOnShowWidget("Widget2");
195 #endif // _USE_KWWIDGETS_