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