]> Creatis software - bbtk.git/blob - packages/wx/src/bbwxSlider.h
=== MAJOR RELEASE ====
[bbtk.git] / packages / wx / src / bbwxSlider.h
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbwxSlider.h,v $
5   Language:  C++
6   Date:      $Date: 2008/04/18 12:59:53 $
7   Version:   $Revision: 1.11 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*//**
18 /**
19  * \file 
20  * \brief Short description in one line
21  * 
22  * Long description which 
23  * can span multiple lines
24 */
25
26 /**
27  * \class bbwx::Slider
28  * \brief 
29
30  * \class bbwx::SliderWidget
31  * \brief 
32  */
33
34 #ifdef _USE_WXWIDGETS_
35
36 // Prevents multiple inclusions : use symbols of the form
37 // __FILENAME_INCLUDED__ 
38 // where FILENAME must be replaced by the actual file name
39 #ifndef __bbwxSlider_h_INCLUDED__
40 #define __bbwxSlider_h_INCLUDED__
41
42 // Include wxBlackBox definition
43 #include "bbtkWxBlackBox.h"
44
45
46
47 // Namespace of the package "wx" is "bbwx" 
48 // Namespace associated to packages should be of the form :
49 // bbPACKAGENAME
50 namespace bbwx
51 {
52   
53   //--------------------------------------------------------------------------
54   // Forward declaration of the box
55   class Slider;
56   
57   //--------------------------------------------------------------------------
58   // The widget created by the box 
59   class SliderWidget : public wxPanel 
60   {
61   public:
62     /// Ctor with the two first params the parent window and the creator box
63     /// which must be passed to the WxBlackBoxWidget constructor.
64     /// The other params initialize the widget 
65     SliderWidget(Slider* box, wxWindow *parent,
66                  int orientation,
67                  bool changeresolution,
68                  bool label, 
69                  wxString title,
70                  int vmin,
71                  int vmax,
72                  int value,
73        int track);
74     /// Dtor
75     ~SliderWidget();
76     /// Events callbacks
77     /// Called when the slider is moved
78     void OnSliderTrack(wxScrollEvent& event);
79     /// Called when the slider is released
80     void OnSliderRelease(wxScrollEvent& event);
81     /// Called when the little slider which controls the resolution
82     /// of the main slider is moved (if activated)
83     void OnResolutionOfSlider(wxScrollEvent& event);
84
85     // Accessors
86     int  GetValue() { return mwxSlider->GetValue(); }
87     void SetRange(int min, int max);
88     // Update the texts which display the min/max/current values of the slider
89     void RefreshLabels();
90         
91   private:
92     Slider*    mBox;
93     wxSlider   *mwxSlider;
94     wxSlider   *mResolutionOfSlider;
95     int        min;
96     int        max;
97     int        reactiveOnTrack;
98     wxStaticText        *label_vertical;
99     wxStaticText        *label_min;
100     wxStaticText        *label_max;
101   };
102   //------------------------------------------------------------------------
103   //------------------------------------------------------------------------
104   //------------------------------------------------------------------------
105
106   
107   
108   
109   //------------------------------------------------------------------------
110   // The black box
111   class /*BBTK_EXPORT*/ Slider : public bbtk::WxBlackBox
112   {
113     
114     BBTK_BLACK_BOX_INTERFACE(Slider,bbtk::WxBlackBox);
115     BBTK_DECLARE_INPUT(In,int);
116     BBTK_DECLARE_INPUT(Min,int);
117     BBTK_DECLARE_INPUT(Max,int);
118     BBTK_DECLARE_INPUT(Label,bool);
119     BBTK_DECLARE_INPUT(Title,std::string);
120     BBTK_DECLARE_INPUT(Orientation,std::string);
121     BBTK_DECLARE_INPUT(ChangeResolution,bool);
122     BBTK_DECLARE_INPUT(ReactiveOnTrack,int);    
123     BBTK_DECLARE_OUTPUT(Out,int);
124     BBTK_PROCESS(Process);
125     BBTK_CREATE_WIDGET(CreateWidget);
126     void Process();
127     void CreateWidget();
128
129   protected:
130     virtual void bbUserConstructor();
131   };
132   //=================================================================
133  
134   //=================================================================
135   // the black box description
136   BBTK_BEGIN_DESCRIBE_BLACK_BOX(Slider,bbtk::WxBlackBox);
137   BBTK_NAME("Slider");
138   BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr");
139   // Already inserted for any WxBlackBox  BBTK_CATEGORY("widget");
140   BBTK_DESCRIPTION("Slider widget (wxSlider)");
141   BBTK_INPUT(Slider,In,"Initial position of the slider (default 0)",int,"");
142   BBTK_INPUT(Slider,Min,"Minimum value of the slider (default 0)",int,"");
143   BBTK_INPUT(Slider,Max,"Maximum value of the slider (default 500)",int,"");
144   BBTK_INPUT(Slider,Label,"Show slider labels ? (default FALSE) ",bool,"");
145   BBTK_INPUT(Slider,Title,"Title shown above the slider (default '') ", std::string,"");
146   BBTK_INPUT(Slider,Orientation, "Orientation : (default H)  0=H=HORIZONTAL, 1=V=VERTICAL ",std::string,"");
147   BBTK_INPUT(Slider,ChangeResolution, "Can the user change the resolution of the slider ? (default FALSE) ",bool,"");
148   BBTK_INPUT(Slider,ReactiveOnTrack, "Slider sends info when track moves (default 0 = no)",int,"");  
149   BBTK_OUTPUT(Slider,Out,"Current position of the slider",int,"");
150   BBTK_END_DESCRIBE_BLACK_BOX(Slider);
151   //=================================================================
152   
153
154
155 } //namespace bbwx
156
157 #endif  //__bbtkwxSlider_h_INCLUDED__
158
159 #endif //_USE_WXWIDGETS_