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