1 /*=========================================================================
3 Module: $RCSfile: bbkwLayoutSplit.cxx,v $
5 Date: $Date: 2008/12/18 11:54:57 $
6 Version: $Revision: 1.4 $
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 * ------------------------------------------------------------------------ */
39 #include "bbkwLayoutSplit.h"
40 #include "bbkwPackage.h"
41 #include "bbtkUtilities.h"
43 #include <vtkKWSplitFrame.h>
47 BBTK_ADD_BLACK_BOX_TO_PACKAGE(kw,LayoutSplit);
48 BBTK_BLACK_BOX_IMPLEMENTATION(LayoutSplit,bbtk::KWBlackBox);
50 void LayoutSplit::bbUserConstructor()
52 bbSetInputOrientation("VERTICAL");
53 bbSetInputProportion(50);
54 bbSetInputWidget1(NULL);
55 bbSetInputWidget2(NULL);
58 void LayoutSplit::Process()
63 void LayoutSplit::CreateWidget(vtkKWFrame* parent)
65 vtkKWSplitFrame *splitframe = vtkKWSplitFrame::New();
66 bbSetOutputWidget(splitframe);
67 splitframe->SetParent(parent);
69 splitframe->SetFrame1MinimumSize(5);
70 splitframe->SetFrame2MinimumSize(5);
71 splitframe->SetExpandableFrameToBothFrames();
74 int width = parent->GetWidth();
75 int height = parent->GetHeight();
77 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"0|H|HORIZONTAL")==true)
81 else if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|V|VERTICAL")==true)
87 bbtkWarning("Unrecognized value '"<<bbGetInputOrientation()<<"' for input 'Orientation' of LayoutSplit "<<bbGetName()<<std::endl);
92 splitframe->SetOrientationToHorizontal ();
97 splitframe->SetOrientationToVertical ();
102 height = height - 5 ;
105 bbGetOutputWidget()->GetApplication()->Script("place %s -x 0 -y 0 -width %d -height %d",
106 bbGetOutputWidget()->GetWidgetName(),
108 parent->GetHeight() );
110 bbGetOutputWidget()->GetApplication()->Script
111 ("pack %s -expand yes -fill both",
112 bbGetOutputWidget()->GetWidgetName());
114 splitframe->SetReliefToGroove();
115 splitframe->SetBorderWidth(2);
118 vtkKWWidget* w1 = bbCreateWidgetOfInput("Widget1",splitframe->GetFrame1());
120 vtkKWWidget* w2 = bbCreateWidgetOfInput("Widget2",splitframe->GetFrame2());
122 splitframe->GetApplication()->Script
123 ("pack %s -expand yes -fill both",
124 w1->GetWidgetName()) ;
125 splitframe->GetApplication()->Script
126 ("pack %s -expand yes -fill both",
127 w2->GetWidgetName()) ;
130 splitframe->GetApplication()->Script("pack %s -expand yes -fill x -fill y", w2->GetWidgetName());
133 splitframe->GetApplication()->Script("place %s -x 0 -y 0 -width %d -height %d",
138 splitframe->GetApplication()->Script("place %s -x 0 -y 0 -width %d -height %d",
148 // This callback is necessary to get actual processing of the view
149 // when window is shown
151 void LayoutSplit::OnShowWidget()
153 if (bbGetOutputWidget()==0)
156 //bbtkError("LayoutSplit::OnShowWidget() : Output Widget == 0 !");
158 kwSplitterWindow* win = (kwSplitterWindow*)bbGetOutputWidget();
163 // bbtkError("LayoutSplit::OnShowWidget() : win == 0 !");
165 win->GetClientSize(&w,&h);
167 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),
168 "0|H|HORIZONTAL")==true)
170 pos = (int)(w * bbGetInputProportion() * 0.01);
174 pos = (int)(h * bbGetInputProportion() * 0.01);
176 // std::cout << "pos = "<<pos<<std::endl;
178 win->SetSashPosition(pos,true);
179 bbUserOnShowWidget("Widget1");
180 bbUserOnShowWidget("Widget2");
188 #endif // _USE_KWWIDGETS_