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