]> Creatis software - bbtk.git/blob - packages/wx/src/bbwxColourSelectorButton.h
8c6dd577872f47fc979d069e3e807e2f034faf2f
[bbtk.git] / packages / wx / src / bbwxColourSelectorButton.h
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbwxColourSelectorButton.h,v $
5   Language:  C++
6   Date:      $Date: 2008/09/10 12:01:47 $
7   Version:   $Revision: 1.6 $
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 /**
20  * \file 
21  * \brief Short description in one line
22  * 
23  * Long description which 
24  * can span multiple lines
25 */
26
27 /**
28  * \class bbwx::ColourSelectorButton
29  * \brief 
30
31  * \class bbwx::wxColourPickerCtrlWidget
32  * \brief 
33  */
34
35 #ifdef _USE_WXWIDGETS_
36
37 // Prevents multiple inclusions : use symbols of the form
38 // __FILENAME_INCLUDED__ 
39 // where FILENAME must be replaced by the actual file name
40 #ifndef __bbwxColourSelectorButton_h_INCLUDED_H__
41 #define __bbwxColourSelectorButton_h_INCLUDED_H__
42
43 // Include wxBlackBox definition
44 #include "bbtkWxBlackBox.h"
45
46 #include <wx/clrpicker.h>
47
48 // Namespace of the package "wx" is "bbwx" 
49 // Namespace associated to packages should be of the form :
50 // bbPACKAGENAME
51 namespace bbwx
52 {
53
54   //=================================================================
55 class ColourSelectorButton;
56
57 class wxColourPickerCtrlWidget :public wxPanel
58 {
59
60 public:
61    wxColourPickerCtrlWidget( ColourSelectorButton* box,
62                              wxWindow *parent,
63                              unsigned char  cr,
64                              unsigned char  cg,
65                              unsigned char  cb  );
66
67    ~wxColourPickerCtrlWidget();
68    void OnColorChange(wxColourPickerEvent& e);
69    void UpdateBox();
70 private:
71    wxColourPickerCtrl *picker;
72    ColourSelectorButton *mBox;
73 };
74
75 //------------------------------------------------------------------------
76 // The black box
77   class /*BBTK_EXPORT*/ ColourSelectorButton : public bbtk::WxBlackBox
78   {
79     BBTK_BLACK_BOX_INTERFACE(ColourSelectorButton,bbtk::WxBlackBox);
80     BBTK_DECLARE_INPUT(In,std::string);
81     BBTK_DECLARE_OUTPUT(Out,std::string);
82     BBTK_PROCESS(Process);
83     BBTK_CREATE_WIDGET(CreateWidget);
84     void Process();
85     void CreateWidget();
86
87   protected:
88     virtual void bbUserConstructor();
89
90   private:
91      wxColourPickerCtrlWidget* pickerWidget;
92   };
93
94   //=================================================================
95   // UserBlackBox description
96   BBTK_BEGIN_DESCRIBE_BLACK_BOX(ColourSelectorButton,bbtk::WxBlackBox);
97   // Already inserted for any WxBlackBox  BBTK_CATEGORY("widget");
98   BBTK_NAME("ColourSelectorButton");
99   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
100   BBTK_DESCRIPTION("A button which displays a colour picker dialog when clicked");
101   BBTK_INPUT(ColourSelectorButton,In,"Initial colour",std::string,"colour");
102   BBTK_OUTPUT(ColourSelectorButton,Out,"Colour choosen in format '[0,1] [0,1] [0,1]'",std::string,"colour");
103   BBTK_END_DESCRIBE_BLACK_BOX(ColourSelectorButton);
104   //=================================================================
105
106 }//namespace bbtk
107 #endif  // __bbtkWxColourSelector_h__
108
109 #endif //_USE_WXWIDGETS_