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 #include <bbwxSlider.h>
29 #include <bbwxLayoutLine.h>
31 //=========================================================================
32 // Illustrates how to insert a WxBlackBox into his own wxFrame
33 //=========================================================================
35 //==========================================================================
36 // A custom wxFrame which own a bbwx::Slider widget
37 class Frame : public wxFrame
42 void OnSlider( bbtk::BlackBox::Pointer p, const std::string& o,
45 bbwx::Slider::Pointer mSlider;
48 //==========================================================================
50 //==========================================================================
52 wxFrame((wxFrame *)0, -1, _T("A frame which contains a bbwx::Slider"),
53 wxDefaultPosition, wxDefaultSize)
55 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
57 //========================================
58 // 1) Create the WxBlackBox
59 mSlider = bbwx::Slider::New("slider");
60 // 2) Create the widget giving it the parent
61 mSlider->bbUserCreateWidget(this);
62 // 3) Add an observer to process output modifications
63 mSlider->bbAddOutputObserver ( "Out",
64 BBTK_MAKE_OUTPUT_OBSERVER ( this,
66 // 4) Add the created widget in the sizer
67 sizer->Add(mSlider->bbGetOutputWidget(),1,wxGROW);
68 //=========================================
70 //=========================================
71 // Create the static text as usual
72 mText = new wxStaticText ( this, -1 , _T("") );
73 sizer->Add(mText,1,wxGROW);
74 //=========================================
80 //==========================================================================
82 //==========================================================================
83 void Frame::OnSlider( bbtk::BlackBox::Pointer p, const std::string& o,
86 std::cout << "New slider value = " << mSlider->bbGetOutputOut() << std::endl;
87 std::ostringstream val;
88 val << mSlider->bbGetOutputOut();
89 mText->SetLabel( bbtk::std2wx ( val.str() ) );
91 //==========================================================================
93 //==========================================================================
94 class App : public wxApp
98 int OnExit() { return true; }
100 //==========================================================================
102 //==========================================================================
103 // The `main program' equivalent, creating the windows and returning the
109 //See http://www.wxwindows.org/faqgtk.htm#locale
110 setlocale(LC_NUMERIC, "C");
112 Frame* I = new Frame();
116 //=========================================================================
118 //=========================================================================
120 CREA_WXMAIN_WITH_CONSOLE;
121 //=========================================================================