]> Creatis software - bbtk.git/blob - packages/wx/src/bbwxSlider.h
*** empty log message ***
[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/02/04 13:02:58 $
7   Version:   $Revision: 1.4 $
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
35 #ifdef _USE_WXWIDGETS_
36
37
38 // Prevents multiple inclusions : use symbols of the form
39 // __FILENAME_INCLUDED__ 
40 // where FILENAME must be replaced by the actual file name
41 #ifndef __bbwxSlider_h_INCLUDED__
42 #define __bbwxSlider_h_INCLUDED__
43
44 // Include wxBlackBox definition
45 #include "bbtkWxBlackBox.h"
46
47
48
49 // Namespace of the package "wx" is "bbwx" 
50 // Namespace associated to packages should be of the form :
51 // bbPACKAGENAME
52 namespace bbwx
53 {
54   
55   
56   
57
58
59
60   //--------------------------------------------------------------------------
61   // Forward declaration of the box
62   class Slider;
63   //--------------------------------------------------------------------------
64
65
66
67   
68   //--------------------------------------------------------------------------
69   // The widget created by the box 
70   class SliderWidget : public wxPanel 
71   {
72   public:
73     /// Ctor with the two first params the parent window and the creator box
74     /// which must be passed to the WxBlackBoxWidget constructor.
75     /// The other params initialize the widget 
76     SliderWidget(Slider* box, wxWindow *parent,
77                  int orientation,
78                  bool changeresolution,
79                  bool label, 
80                  wxString title,
81                  int vmin,
82                  int vmax,
83                  int value,
84        int track);
85     /// Dtor
86     ~SliderWidget();
87     /// Events callbacks
88     /// Called when the slider is moved
89     void OnSliderTrack(wxScrollEvent& event);
90     /// Called when the slider is released
91     void OnSliderRelease(wxScrollEvent& event);
92     /// Called when the little slider which controls the resolution
93     /// of the main slider is moved (if activated)
94     void OnResolutionOfSlider(wxScrollEvent& event);
95
96     // Accessors
97     int  GetValue() { return mwxSlider->GetValue(); }
98     void SetRange(int min, int max);
99     // Update the texts which display the min/max/current values of the slider
100     void RefreshLabels();
101         
102   private:
103     Slider*    mBox;
104     wxSlider   *mwxSlider;
105     wxSlider   *mResolutionOfSlider;
106     int        min;
107     int        max;
108     int        reactiveOnTrack;
109     wxStaticText        *label_vertical;
110     wxStaticText        *label_min;
111     wxStaticText        *label_max;
112   };
113   //------------------------------------------------------------------------
114   //------------------------------------------------------------------------
115   //------------------------------------------------------------------------
116
117   
118   
119   
120   //------------------------------------------------------------------------
121   // The black box
122   class /*BBTK_EXPORT*/ Slider : public bbtk::WxBlackBox
123   {
124     
125     BBTK_USER_BLACK_BOX_INTERFACE(Slider,bbtk::WxBlackBox);
126     BBTK_DECLARE_INPUT(In,int);
127     BBTK_DECLARE_INPUT(Min,int);
128     BBTK_DECLARE_INPUT(Max,int);
129     BBTK_DECLARE_INPUT(Label,bool);
130     BBTK_DECLARE_INPUT(Title,std::string);
131     BBTK_DECLARE_INPUT(Orientation,int);
132     BBTK_DECLARE_INPUT(ChangeResolution,bool);
133     BBTK_DECLARE_INPUT(ReactiveOnTrack,int);    
134     BBTK_DECLARE_OUTPUT(Out,int);
135     BBTK_PROCESS(Process);
136     BBTK_CREATE_WIDGET(CreateWidget);
137     void Process();
138     void CreateWidget();
139
140   protected:
141     virtual void bbUserConstructor();
142   };
143   //=================================================================
144  
145   //=================================================================
146   // the black box description
147   BBTK_BEGIN_DESCRIBE_BLACK_BOX(Slider,bbtk::WxBlackBox);
148   BBTK_NAME("Slider");
149   BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr");
150   BBTK_KEYWORD("wx;widget");
151   BBTK_DESCRIPTION("Slider widget (wxSlider)");
152   BBTK_INPUT(Slider,In,"Initial position of the slider (default 0)",int);
153   BBTK_INPUT(Slider,Min,"Minimum value of the slider (default 0)",int);
154   BBTK_INPUT(Slider,Max,"Maximum value of the slider (default 500)",int);
155   BBTK_INPUT(Slider,Label,"Show slider labels ? (default FALSE) ",bool);
156   BBTK_INPUT(Slider,Title,"Title shown above the slider (default '') ",
157              std::string);
158   BBTK_INPUT(Slider,Orientation,
159              "Orientation : 0=Horizontal / 1=Vertical (default 0)",int);
160   BBTK_INPUT(Slider,ChangeResolution,
161              "Can the user change the resolution of the slider ? (default FALSE) ",bool);
162   BBTK_INPUT(Slider,ReactiveOnTrack,
163              "Slider sends info when track moves (default 0 = no)",int);  
164   BBTK_OUTPUT(Slider,Out,"Current position of the slider",int);
165   BBTK_END_DESCRIBE_BLACK_BOX(Slider);
166   //=================================================================
167   
168
169
170 } //namespace bbwx
171
172 #endif  //__bbtkwxSlider_h_INCLUDED__
173
174 #endif //_USE_WXWIDGETS_