1 #include <bbwxSlider.h>
2 #include <bbwxLayoutLine.h>
4 //=========================================================================
5 // Illustrates how to insert a WxBlackBox into his own wxFrame
6 //=========================================================================
8 //==========================================================================
9 // A custom wxFrame which own a bbwx::Slider widget
10 class Frame : public wxFrame
15 void OnSlider( bbtk::BlackBox::Pointer p, const std::string& o,
18 bbwx::Slider::Pointer mSlider;
21 //==========================================================================
23 //==========================================================================
25 wxFrame((wxFrame *)0, -1, _T("A frame which contains a bbwx::Slider"),
26 wxDefaultPosition, wxDefaultSize)
28 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
30 //========================================
31 // 1) Create the WxBlackBox
32 mSlider = bbwx::Slider::New("slider");
33 // 2) Create the widget giving it the parent
34 mSlider->bbUserCreateWidget(this);
35 // 3) Add an observer to process output modifications
36 mSlider->bbAddOutputObserver ( "Out",
37 BBTK_MAKE_OUTPUT_OBSERVER ( this,
39 // 4) Add the created widget in the sizer
40 sizer->Add(mSlider->bbGetOutputWidget(),1,wxGROW);
41 //=========================================
43 //=========================================
44 // Create the static text as usual
45 mText = new wxStaticText ( this, -1 , _T("") );
46 sizer->Add(mText,1,wxGROW);
47 //=========================================
53 //==========================================================================
55 //==========================================================================
56 void Frame::OnSlider( bbtk::BlackBox::Pointer p, const std::string& o,
59 std::cout << "New slider value = " << mSlider->bbGetOutputOut() << std::endl;
60 std::ostringstream val;
61 val << mSlider->bbGetOutputOut();
62 mText->SetLabel( bbtk::std2wx ( val.str() ) );
64 //==========================================================================
66 //==========================================================================
67 class App : public wxApp
71 int OnExit() { return true; }
73 //==========================================================================
75 //==========================================================================
76 // The `main program' equivalent, creating the windows and returning the
82 //See http://www.wxwindows.org/faqgtk.htm#locale
83 setlocale(LC_NUMERIC, "C");
85 Frame* I = new Frame();
89 //=========================================================================
91 //=========================================================================
93 CREA_WXMAIN_WITH_CONSOLE;
94 //=========================================================================