2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbwxLayoutTab.cxx,v $
32 Date: $Date: 2012/11/16 08:52:14 $
33 Version: $Revision: 1.12 $
34 =========================================================================*/
42 #ifdef _USE_WXWIDGETS_
45 #include "bbwxLayoutTab.h"
46 #include "bbwxPackage.h"
47 #include "bbtkUtilities.h"
48 #include "bbtkBlackBoxInputConnector.h"
54 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx , LayoutTab);
57 BBTK_BLACK_BOX_IMPLEMENTATION(LayoutTab,bbtk::WxBlackBox);
59 //-----------------------------------------------------------------
60 void LayoutTab::bbUserSetDefaultValues()
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);
74 //-----------------------------------------------------------------
75 void LayoutTab::bbUserInitializeProcessing()
79 //-----------------------------------------------------------------
80 void LayoutTab::bbUserFinalizeProcessing()
84 //-----------------------------------------------------------------
85 void LayoutTab::TryInsertWindow(wxNotebook *book, const std::string& input )
87 wxWindow* w = bbCreateWidgetOfInput(input,book); //panel);
90 book->AddPage(w,w->GetName());
95 void LayoutTab::SetTitleTabs()
98 std::vector<std::string> vecTitle;
99 std::vector<std::string> vecInputNameWidget;
100 vecInputNameWidget.push_back("Widget1");
101 vecInputNameWidget.push_back("Widget2");
102 vecInputNameWidget.push_back("Widget3");
103 vecInputNameWidget.push_back("Widget4");
104 vecInputNameWidget.push_back("Widget5");
105 vecInputNameWidget.push_back("Widget6");
106 vecInputNameWidget.push_back("Widget7");
107 vecInputNameWidget.push_back("Widget8");
108 vecInputNameWidget.push_back("Widget9");
109 int iWidget,sizeVecInputNameWidget= vecInputNameWidget.size();
110 for (iWidget=0; iWidget<sizeVecInputNameWidget; iWidget++)
112 bbtk::BlackBoxInputConnector* c = bbGetInputConnectorMap().find( vecInputNameWidget[iWidget] )->second ;
113 if ( c->IsConnected() )
115 // Get black box from
116 BlackBox::Pointer from = c->GetConnection()->GetBlackBoxFrom();
117 bbtk::WidgetBlackBox<wxWindow>::Pointer wfrom = boost::dynamic_pointer_cast<bbtk::WidgetBlackBox<wxWindow> >(from);
118 vecTitle.push_back( wfrom->bbGetInputWinTitle() );
123 wxNotebook* w = (wxNotebook*)bbGetOutputWidget();
126 int i,size=vecTitle.size();
127 for (i=0; i<size; i++)
129 w->SetPageText(i, wxString( vecTitle[i].c_str(),wxConvUTF8 ) );
135 void LayoutTab::Process()
142 void LayoutTab::CreateWidget(wxWindow* parent)
144 long style = wxNB_TOP;
145 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"0|T|TOP")==true)
147 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|R|RIGHT")==true)
148 { style=wxNB_RIGHT; }
149 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"2|B|BOTTOM")==true)
150 { style=wxNB_BOTTOM; }
151 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"3|L|LEFT")==true)
153 wxNotebook *w = new wxNotebook(parent, //bbGetWxParent(),
158 w->SetName( bbtk::std2wx( bbGetInputWinTitle() ) );
160 TryInsertWindow(w,"Widget1");
161 TryInsertWindow(w,"Widget2");
162 TryInsertWindow(w,"Widget3");
163 TryInsertWindow(w,"Widget4");
164 TryInsertWindow(w,"Widget5");
165 TryInsertWindow(w,"Widget6");
166 TryInsertWindow(w,"Widget7");
167 TryInsertWindow(w,"Widget8");
168 TryInsertWindow(w,"Widget9");
170 bbSetOutputWidget( w );
174 // This callback is necessary to get actual processing of the view
175 // when window is shown
176 void LayoutTab::OnShowWidget()
178 wxNotebook* w = (wxNotebook*)bbGetOutputWidget();
181 if (w->GetPageCount()>0)
184 for (unsigned int i=0; i<w->GetPageCount(); ++i) w->AdvanceSelection();