]> Creatis software - bbtk.git/blob - packages/qt/src/bbqtLayoutLine.cxx
542385f34cab53534347c32d03aab1cce792faf8
[bbtk.git] / packages / qt / src / bbqtLayoutLine.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbqtLayoutLine.cxx,v $
4   Language:  C++
5   Date:      $Date: 2009/05/28 14:22:15 $
6   Version:   $Revision: 1.3 $
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 /**
33  *  \file
34  *  \brief
35  */
36
37
38 #ifdef USE_QT
39
40 #include "bbqtLayoutLine.h"
41 #include "bbqtPackage.h"
42 #include "bbtkUtilities.h"
43
44 #include <QBoxLayout>
45
46 namespace bbqt
47 {
48   BBTK_ADD_BLACK_BOX_TO_PACKAGE(qt, LayoutLine);
49   BBTK_BLACK_BOX_IMPLEMENTATION(LayoutLine,bbtk::QtBlackBox);
50   
51   void LayoutLine::bbUserSetDefaultValues()
52   {
53     bbSetInputOrientation("VERTICAL");
54     bbSetInputWidget1(NULL);
55     bbSetInputWidget2(NULL);
56     bbSetInputWidget3(NULL);
57     bbSetInputWidget4(NULL);
58     bbSetInputWidget5(NULL);
59     bbSetInputWidget6(NULL);
60     bbSetInputWidget7(NULL);
61     bbSetInputWidget8(NULL);
62     bbSetInputWidget9(NULL);
63   }
64   
65         void LayoutLine::bbUserInitializeProcessing()
66         {
67         }
68
69         void LayoutLine::bbUserFinalizeProcessing()
70         {
71         }
72         
73         
74   void LayoutLine::Process()
75   {
76   }
77   
78
79         
80   void LayoutLine::CreateWidget(QWidget* parent)
81   {
82     QWidget *w = new QWidget(parent);
83     QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
84     sizePolicy.setHorizontalStretch(1);
85     sizePolicy.setVerticalStretch(1);
86     sizePolicy.setHeightForWidth(parent->sizePolicy().hasHeightForWidth());
87     w->setSizePolicy(sizePolicy);
88
89     QBoxLayout::Direction dir;
90     if (bbtk::Utilities::loosematch(bbGetInputOrientation(),
91                                     "0|H|HORIZONTAL")==true)  
92       { dir = QBoxLayout::LeftToRight; }
93     if (bbtk::Utilities::loosematch(bbGetInputOrientation(),
94                                     "1|V|VERTICAL")==true)      
95       {  dir = QBoxLayout::TopToBottom; }
96     QBoxLayout* l = new QBoxLayout(dir);
97     
98     QWidget* cw;
99     if ((cw=bbCreateWidgetOfInput("Widget1",w)) != 0) l->addWidget(cw);
100     if ((cw=bbCreateWidgetOfInput("Widget2",w)) != 0) l->addWidget(cw);
101     if ((cw=bbCreateWidgetOfInput("Widget3",w)) != 0) l->addWidget(cw);
102     if ((cw=bbCreateWidgetOfInput("Widget4",w)) != 0) l->addWidget(cw);
103     if ((cw=bbCreateWidgetOfInput("Widget5",w)) != 0) l->addWidget(cw);
104     if ((cw=bbCreateWidgetOfInput("Widget6",w)) != 0) l->addWidget(cw);
105     if ((cw=bbCreateWidgetOfInput("Widget7",w)) != 0) l->addWidget(cw);
106     if ((cw=bbCreateWidgetOfInput("Widget8",w)) != 0) l->addWidget(cw);
107     if ((cw=bbCreateWidgetOfInput("Widget9",w)) != 0) l->addWidget(cw);
108     
109  
110     w->setLayout(l);
111
112     
113     bbSetOutputWidget( w );
114   }
115   
116   // This callback is necessary to get actual processing of the view 
117   // when window is shown
118   void  LayoutLine::OnShowWidget()
119   {
120     /*
121     bbUserOnShowWidget("Widget1");
122     bbUserOnShowWidget("Widget2");
123     bbUserOnShowWidget("Widget3");
124     bbUserOnShowWidget("Widget4");
125     bbUserOnShowWidget("Widget5");
126     bbUserOnShowWidget("Widget6");
127     bbUserOnShowWidget("Widget7");
128     bbUserOnShowWidget("Widget8");
129     bbUserOnShowWidget("Widget9");
130     */
131   }
132
133 }//namespace bbqt
134
135 #endif // USE_QT
136