]> Creatis software - bbtk.git/blob - samples/SampleWidgetsBase/bbtkSampleWidgetsBase.cxx
*** empty log message ***
[bbtk.git] / samples / SampleWidgetsBase / bbtkSampleWidgetsBase.cxx
1 #include <bbwxSlider.h>
2 #include <bbwxOutputText.h>
3
4 //=========================================================================
5 // Different examples of using black boxes in C++
6 // Here we do not use wxWidgets however WxBlackBox es work in **Dialog** mode 
7 //=========================================================================
8
9 //=========================================================================
10 void SimpleSliderDialog()
11 {
12   std::cout << "============== Simple Slider dialog" 
13             << std::endl;
14    try
15     {
16       bbwx::Slider::Pointer slider = bbwx::Slider::New("slider");
17       //      slider->bbGetHelp();
18       slider->bbSetInputWinDialog(true);  // mandatory
19       slider->bbExecute();
20       std::cout << "Slider Output = "<< slider->bbGetOutputOut() << std::endl;
21     }
22   catch (bbtk::Exception e)
23     {
24       e.Print();
25     } 
26 }
27 //=========================================================================
28
29 //=========================================================================
30 void SliderOutputTextWithoutFactory()
31 {
32   std::cout << "============== Slider->OutputText without Factory" 
33             << std::endl;
34   try
35     {
36       bbwx::Slider::Pointer slider = bbwx::Slider::New("slider");
37       bbwx::OutputText::Pointer text = bbwx::OutputText::New("text");
38       bbtk::Connection::Pointer s2t = bbtk::Connection::New(slider,"Out",
39                                                             text,"In");
40       text->bbExecute();
41     }
42   catch (bbtk::Exception e)
43     {
44       bbtk::MessageManager::SetMessageLevel("Error",1);
45       e.Print();
46     }
47 }
48 //=========================================================================
49
50
51 //=========================================================================
52 #include <bbtkFactory.h>
53 #include <bbwxLayoutLine.h>
54 void SliderOutputTextWithFactory()
55 {
56   std::cout << "============== Slider->OutputText **WITH** Factory" 
57             << std::endl;
58   try
59     {
60       bbtk::Factory::Pointer factory = bbtk::Factory::New();
61   
62       factory->LoadPackage("std");
63
64       bbwx::Slider::Pointer     slider   = bbwx::Slider::New("slider");
65       bbwx::OutputText::Pointer text     = bbwx::OutputText::New("text");
66       bbtk::Connection::Pointer s2t      = bbtk::Connection::New(slider,"Out",
67                                                             text,"In",
68                                                             factory);
69       bbwx::LayoutLine::Pointer layout   = bbwx::LayoutLine::New("layout");
70       bbtk::Connection::Pointer c1       = bbtk::Connection::New(slider,"Widget",
71                                                            layout,"Widget1");
72       bbtk::Connection::Pointer c2       = bbtk::Connection::New(text,"Widget",
73                                                            layout,"Widget2");
74                                                            
75       bbtk::Connection::Pointer c3       = bbtk::Connection::New(slider,"BoxChange",
76                                                            text,"BoxExecute");
77       // OR 
78       //      text->bbSetInputBoxProcessMode("Reactive");
79       
80       layout->bbSetInputWinDialog(true);
81       layout->bbExecute();
82     }
83   catch (bbtk::Exception e)
84     {
85       bbtk::MessageManager::SetMessageLevel("Error",1);
86       e.Print();
87     }
88 }
89 //=========================================================================
90
91 //=========================================================================
92 int main(int argv, char* argc[])
93 {
94   // To track all ...
95   //  bbtk::MessageManager::SetMessageLevel("all",9);
96   
97   SimpleSliderDialog();
98   SliderOutputTextWithoutFactory();
99   SliderOutputTextWithFactory();
100
101   // To get the list of bbtk object still allocated after main ends
102   // bbtk::StaticInitTime::PrintObjectListInfo = true;
103   // bbtk::MessageManager::SetMessageLevel("object",1);
104 }
105 //=========================================================================