]> Creatis software - bbtk.git/blob - packages/kw/src/bbkwLayoutSplit.cxx
243b53e39f9ee8a8ff541f8f960df90d4d2023ab
[bbtk.git] / packages / kw / src / bbkwLayoutSplit.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbkwLayoutSplit.cxx,v $
4   Language:  C++
5   Date:      $Date: 2008/11/29 21:41:58 $
6   Version:   $Revision: 1.1 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
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.
20 *
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
25 *  liability. 
26 *
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 * ------------------------------------------------------------------------ */                                                                         
30
31 /**
32  *  \file
33  *  \brief
34  */
35
36
37 #ifdef USE_KWWIDGETS
38
39 #include "bbkwLayoutSplit.h"
40 #include "bbkwPackage.h"
41 #include "bbtkUtilities.h"
42
43 #include <vtkKWSplitFrame.h>
44
45 namespace bbkw
46 {
47   BBTK_ADD_BLACK_BOX_TO_PACKAGE(kw,LayoutSplit);
48   BBTK_BLACK_BOX_IMPLEMENTATION(LayoutSplit,bbtk::KWBlackBox);
49
50   void LayoutSplit::bbUserConstructor()
51   {
52     bbSetInputOrientation("VERTICAL");
53     bbSetInputProportion(50);
54     bbSetInputWidget1(NULL);
55     bbSetInputWidget2(NULL);
56   }
57
58   void LayoutSplit::Process()
59   {
60   }
61
62
63   void LayoutSplit::CreateWidget(vtkKWWidget* parent) 
64   {
65     vtkKWSplitFrame *splitframe = vtkKWSplitFrame::New();
66     bbSetOutputWidget(splitframe);
67     splitframe->SetParent(parent);
68     splitframe->Create();
69
70     splitframe->SetFrame1MinimumSize(5);
71     splitframe->SetFrame2MinimumSize(5);
72
73     splitframe->GetApplication()->Script("pack %s -side left -anchor c -expand y",
74                                          splitframe->GetWidgetName());
75     /*
76     splitframe->SetParent(parent);
77     splitframe->Create();
78     splitframe->SetWidth(400);
79     splitframe->SetHeight(200);
80     splitframe->SetReliefToGroove();
81     splitframe->SetBorderWidth(2);
82     splitframe->SetExpandableFrameToBothFrames();
83
84     w->SetName( bbtk::std2kw( bbGetInputWinTitle() ) );
85     */
86     bbCreateWidgetOfInput("Widget1",splitframe);
87     bbCreateWidgetOfInput("Widget2",splitframe);
88     /*
89     vtkKWWidget* w1 = bbGetInputWidget1();
90     if (w1) 
91       { 
92         w1->SetParent(splitframe);
93         w1->Create();
94       }
95     vtkKWWidget* w2 = bbGetInputWidget2();
96     if (w2) 
97       {
98         w2->SetParent(splitframe);
99         w2->Create();
100       }
101     */
102
103     /*    
104           int orientation=0;
105     if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"0|H|HORIZONTAL")==true)  { orientation=0; }
106     if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|V|VERTICAL")==true)        { orientation=1; }
107     
108
109           if (orientation==1) { w->SplitHorizontally( w1, w2, 100); }
110     else                { w->SplitVertically( w1, w2, 100);   }
111   
112     bbSetOutputWidget( w );
113     */
114   }
115
116
117   // This callback is necessary to get actual processing of the view 
118   // when window is shown
119   /*
120   void  LayoutSplit::OnShowWidget()
121   {
122     if (bbGetOutputWidget()==0)
123       {
124         return;
125         //bbtkError("LayoutSplit::OnShowWidget() : Output Widget == 0 !");
126       }
127     kwSplitterWindow* win = (kwSplitterWindow*)bbGetOutputWidget();
128     int w,h;
129     if (win==0)
130       {
131         return;
132         //      bbtkError("LayoutSplit::OnShowWidget() : win == 0 !");
133       }
134     win->GetClientSize(&w,&h);
135     int pos = 100;
136     if (bbtk::Utilities::loosematch(bbGetInputOrientation(),
137                                     "0|H|HORIZONTAL")==true)  
138       { 
139         pos = (int)(w * bbGetInputProportion() * 0.01);
140       }
141     else 
142       {
143         pos = (int)(h * bbGetInputProportion() * 0.01);
144       } 
145     //    std::cout << "pos = "<<pos<<std::endl;
146   
147     win->SetSashPosition(pos,true);
148     bbUserOnShowWidget("Widget1");
149     bbUserOnShowWidget("Widget2");
150   }
151   */
152
153
154
155 }//namespace bbkw
156
157 #endif // _USE_KWWIDGETS_
158