]> Creatis software - bbtk.git/blob - packages/wx/src/bbwxBitmapButton.h
Feature #2006 Black Box for BitmapButtons
[bbtk.git] / packages / wx / src / bbwxBitmapButton.h
1 //===== 
2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
3 //===== 
4 #ifdef _USE_WXWIDGETS_
5 #ifndef __bbwxBitmapButton_h_INCLUDED__
6 #define __bbwxBitmapButton_h_INCLUDED__
7 #include "bbwx_EXPORT.h"
8 #include "bbtkWxBlackBox.h"
9
10 namespace bbwx
11 {
12   class bbwx_EXPORT BitmapButton : public bbtk::WxBlackBox
13   {
14     friend class BitmapButtonWidget;
15
16     BBTK_BLACK_BOX_INTERFACE(BitmapButton,bbtk::WxBlackBox);
17
18     BBTK_DECLARE_INPUT(In, std::string );   
19     BBTK_DECLARE_INPUT(Bitmap, wxBitmap* ); 
20     BBTK_DECLARE_INPUT(Label, std::string ); 
21     BBTK_DECLARE_INPUT(Colour, std::vector<double> );
22
23
24     BBTK_PROCESS(Process);
25     void Process();
26     BBTK_CREATE_WIDGET(CreateWidget);
27     void CreateWidget(wxWindow*);
28  
29     void UpdateColour();
30     void UpdateLabel();
31     void UpdateIcon();
32
33   };
34
35   class BitmapButtonWidget : public wxPanel
36   {
37   public:
38     BitmapButtonWidget(
39       BitmapButton* box, 
40       wxWindow *parent, 
41       wxBitmap* bitmap = NULL,
42       wxString title = wxT("")
43     );
44     ~BitmapButtonWidget();
45     void OnClick( wxEvent& );
46     void SetLabel(wxString title);
47     void SetColour(wxColour color);
48     void SetIcon( wxBitmap* bitmap);
49   
50   private:
51     BitmapButton* box;
52     wxBoxSizer* sizer;
53     wxButton  * button;
54     wxString title;
55   };
56
57   typedef std::vector<double> colorVector; 
58
59   BBTK_BEGIN_DESCRIBE_BLACK_BOX(BitmapButton,bbtk::WxBlackBox);
60   BBTK_NAME("BitmapButton");
61   BBTK_AUTHOR("daniel.gonzalez@creatis.insa-lyon.fr");
62   BBTK_DESCRIPTION("A bitmap button is a control that contains a bitmap. If no bitmap is provided, then a label is used instead.");
63   //BBTK_CATEGORY("widget");
64   BBTK_INPUT(BitmapButton,In,"Commands to be executed separated by commas (;). Each single quote (') is replaced by a double quote (\").",std::string,"");   
65   BBTK_INPUT(BitmapButton,Bitmap,"Bitmap image of the button",wxBitmap*,""); 
66   BBTK_INPUT(BitmapButton,Label,"Label of the button",std::string,""); 
67   BBTK_INPUT(BitmapButton,Colour,"Button background color. By default (-1, -1, -1)",colorVector,"color"); 
68   BBTK_END_DESCRIBE_BLACK_BOX(BitmapButton);
69 //===== 
70 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
71 //===== 
72 }
73 // EO namespace bbwx
74
75 #endif // __bbwxBitmapButton_h_INCLUDED__
76 #endif // _USE_WXWIDGETS_
77