]> Creatis software - bbtk.git/blob - packages/wx/src/bbwxLayoutTab.cxx
.
[bbtk.git] / packages / wx / src / bbwxLayoutTab.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbwxLayoutTab.cxx,v $
4   Language:  C++
5   Date:      $Date: 2009/05/15 14:58:03 $
6   Version:   $Revision: 1.10 $
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_WXWIDGETS_
38
39
40 #include "bbwxLayoutTab.h"
41 #include "bbwxPackage.h"
42 #include "bbtkUtilities.h"
43
44
45
46
47 namespace bbwx
48 {
49   BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx , LayoutTab);
50   
51
52   BBTK_BLACK_BOX_IMPLEMENTATION(LayoutTab,bbtk::WxBlackBox);
53   
54         //-----------------------------------------------------------------     
55         void LayoutTab::bbUserSetDefaultValues()
56         {
57                 bbSetInputOrientation("TOP");
58                 bbSetInputWidget1(NULL);
59                 bbSetInputWidget2(NULL);
60                 bbSetInputWidget3(NULL);
61                 bbSetInputWidget4(NULL);
62                 bbSetInputWidget5(NULL);
63                 bbSetInputWidget6(NULL);
64                 bbSetInputWidget7(NULL);
65                 bbSetInputWidget8(NULL);
66                 bbSetInputWidget9(NULL);
67         }
68         
69         //-----------------------------------------------------------------     
70         void LayoutTab::bbUserInitializeProcessing()
71         {
72         }
73         
74         //-----------------------------------------------------------------     
75         void LayoutTab::bbUserFinalizeProcessing()
76         {
77         }
78         
79         
80         //-----------------------------------------------------------------     
81   void LayoutTab::TryInsertWindow(wxNotebook *book, const std::string& input )
82   {
83     wxWindow* w = bbCreateWidgetOfInput(input,book); //panel);
84     if (w!=NULL)
85       {
86         book->AddPage(w,w->GetName());
87       }
88   }
89
90   void LayoutTab::Process() 
91   { 
92   }
93   
94   
95   void LayoutTab::CreateWidget(wxWindow* parent) 
96   { 
97     long style = wxNB_TOP;
98     if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"0|T|TOP")==true) 
99       { style=wxNB_TOP; }
100     if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|R|RIGHT")==true)
101       { style=wxNB_RIGHT; }
102     if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"2|B|BOTTOM")==true)
103       { style=wxNB_BOTTOM; }
104     if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"3|L|LEFT")==true)
105       { style=wxNB_LEFT; }
106     wxNotebook *w = new wxNotebook(parent, //bbGetWxParent(),
107                                    -1, 
108                                    wxDefaultPosition,
109                                    wxDefaultSize,
110                                    style );
111     w->SetName( bbtk::std2wx( bbGetInputWinTitle() ) );
112     
113     TryInsertWindow(w,"Widget1");
114     TryInsertWindow(w,"Widget2");
115     TryInsertWindow(w,"Widget3");
116     TryInsertWindow(w,"Widget4");
117     TryInsertWindow(w,"Widget5");
118     TryInsertWindow(w,"Widget6");
119     TryInsertWindow(w,"Widget7");
120     TryInsertWindow(w,"Widget8");
121     TryInsertWindow(w,"Widget9");
122     
123     bbSetOutputWidget( w );
124   }
125   
126   
127   // This callback is necessary to get actual processing of the view 
128   // when window is shown
129   void  LayoutTab::OnShowWidget()
130   {
131     //bbGetOutputWidget()->Show();
132     wxNotebook* w = (wxNotebook*)bbGetOutputWidget();
133     if (w) 
134       {
135         if (w->GetPageCount()>0)
136           {
137             w->SetSelection(0);
138             for (unsigned int i=0; i<w->GetPageCount(); ++i)  w->AdvanceSelection();
139           }
140         bbUserOnShowWidget("Widget1");
141         bbUserOnShowWidget("Widget2");
142         bbUserOnShowWidget("Widget3");
143         bbUserOnShowWidget("Widget4");
144         bbUserOnShowWidget("Widget5");
145         bbUserOnShowWidget("Widget6");
146         bbUserOnShowWidget("Widget7");
147         bbUserOnShowWidget("Widget8");
148         bbUserOnShowWidget("Widget9");
149       }
150     
151    
152   }
153
154
155 }//namespace bbwx
156
157 #endif
158