]> Creatis software - bbtk.git/blobdiff - packages/wx/src/bbwxBitmapButton.h
Feature #2006 Black Box for BitmapButtons
[bbtk.git] / packages / wx / src / bbwxBitmapButton.h
diff --git a/packages/wx/src/bbwxBitmapButton.h b/packages/wx/src/bbwxBitmapButton.h
new file mode 100644 (file)
index 0000000..a1bdb26
--- /dev/null
@@ -0,0 +1,76 @@
+//===== 
+// 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)
+//===== 
+#ifdef _USE_WXWIDGETS_
+#ifndef __bbwxBitmapButton_h_INCLUDED__
+#define __bbwxBitmapButton_h_INCLUDED__
+#include "bbwx_EXPORT.h"
+#include "bbtkWxBlackBox.h"
+
+namespace bbwx
+{
+  class bbwx_EXPORT BitmapButton : public bbtk::WxBlackBox
+  {
+    friend class BitmapButtonWidget;
+
+    BBTK_BLACK_BOX_INTERFACE(BitmapButton,bbtk::WxBlackBox);
+
+    BBTK_DECLARE_INPUT(In, std::string );   
+    BBTK_DECLARE_INPUT(Bitmap, wxBitmap* ); 
+    BBTK_DECLARE_INPUT(Label, std::string ); 
+    BBTK_DECLARE_INPUT(Colour, std::vector<double> );
+
+
+    BBTK_PROCESS(Process);
+    void Process();
+    BBTK_CREATE_WIDGET(CreateWidget);
+    void CreateWidget(wxWindow*);
+    void UpdateColour();
+    void UpdateLabel();
+    void UpdateIcon();
+
+  };
+
+  class BitmapButtonWidget : public wxPanel
+  {
+  public:
+    BitmapButtonWidget(
+      BitmapButton* box, 
+      wxWindow *parent, 
+      wxBitmap* bitmap = NULL,
+      wxString title = wxT("")
+    );
+    ~BitmapButtonWidget();
+    void OnClick( wxEvent& );
+    void SetLabel(wxString title);
+    void SetColour(wxColour color);
+    void SetIcon( wxBitmap* bitmap);
+  
+  private:
+    BitmapButton* box;
+    wxBoxSizer* sizer;
+    wxButton  * button;
+  };
+
+  typedef std::vector<double> colorVector; 
+
+  BBTK_BEGIN_DESCRIBE_BLACK_BOX(BitmapButton,bbtk::WxBlackBox);
+  BBTK_NAME("BitmapButton");
+  BBTK_AUTHOR("daniel.gonzalez@creatis.insa-lyon.fr");
+  BBTK_DESCRIPTION("A bitmap button is a control that contains a bitmap. If no bitmap is provided, then a label is used instead.");
+  //BBTK_CATEGORY("widget");
+  BBTK_INPUT(BitmapButton,In,"Commands to be executed separated by commas (;). Each single quote (') is replaced by a double quote (\").",std::string,"");   
+  BBTK_INPUT(BitmapButton,Bitmap,"Bitmap image of the button",wxBitmap*,""); 
+  BBTK_INPUT(BitmapButton,Label,"Label of the button",std::string,""); 
+  BBTK_INPUT(BitmapButton,Colour,"Button background color. By default (-1, -1, -1)",colorVector,"color"); 
+  BBTK_END_DESCRIBE_BLACK_BOX(BitmapButton);
+//===== 
+// 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)
+//===== 
+}
+// EO namespace bbwx
+
+#endif // __bbwxBitmapButton_h_INCLUDED__
+#endif // _USE_WXWIDGETS_
+