]> Creatis software - bbtk.git/blobdiff - packages/wx/src/bbwxColourSelectorButton.cxx
Works with visual studio 2009
[bbtk.git] / packages / wx / src / bbwxColourSelectorButton.cxx
index 9a4cafd2bc5a913cc45d76f719222763db40a42c..042b494e5ba26aff2b61eefc6af321e638250c3e 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxColourSelectorButton.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/11/25 11:17:25 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2009/05/15 14:58:03 $
+  Version:   $Revision: 1.10 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
 #include "bbwxColourSelectorButton.h"
 #include "bbwxPackage.h"
 
+#include <wx/clrpicker.h>
 
 namespace bbwx
 {
+//-------------------------------------------------------------------------
+class wxColourPickerCtrlWidget :public wxPanel
+{
+
+public:
+   wxColourPickerCtrlWidget( ColourSelectorButton* box,
+                             wxWindow *parent,
+                             unsigned char  cr,
+                             unsigned char  cg,
+                             unsigned char  cb  );
+
+   ~wxColourPickerCtrlWidget();
+   void OnColorChange(wxColourPickerEvent& e);
+   void UpdateBox();
+private:
+   wxColourPickerCtrl *picker;
+   ColourSelectorButton *mBox;
+};
+//-------------------------------------------------------------------------
 
 //-------------------------------------------------------------------------
 wxColourPickerCtrlWidget::wxColourPickerCtrlWidget(    ColourSelectorButton* box,
@@ -116,16 +136,30 @@ void wxColourPickerCtrlWidget::UpdateBox()
   BBTK_BLACK_BOX_IMPLEMENTATION(ColourSelectorButton,bbtk::WxBlackBox);
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ColourSelectorButton);
   
-  void ColourSelectorButton::bbUserConstructor() 
-  { 
-    bbSetInputIn("1 1 1");
-    bbSetOutputOut("1 1 1");
-    bbSetOutputWidget(0);
-  }
-
+       //-----------------------------------------------------------------     
+       void ColourSelectorButton::bbUserSetDefaultValues()
+       {
+               // Default input value
+               bbSetInputIn("1 1 1");
+               // Initial output value = the same than input
+               bbSetOutputOut("1 1 1");
+               // IMPORTANT : Initialize output widget to null pointer to test it after 
+               bbSetOutputWidget(0);
+       }
+       
+       //-----------------------------------------------------------------     
+       void ColourSelectorButton::bbUserInitializeProcessing()
+       {
+       }
+       
+       //-----------------------------------------------------------------     
+       void ColourSelectorButton::bbUserFinalizeProcessing()
+       {
+       }       
 
   void ColourSelectorButton::Process() 
   { 
+  // The widget may not be created : have to test it before using it
     wxColourPickerCtrlWidget* w = ( wxColourPickerCtrlWidget* )bbGetOutputWidget();
     if (w) 
       {
@@ -133,6 +167,8 @@ void wxColourPickerCtrlWidget::UpdateBox()
       }
     else 
       {
+      // If widget does not exist yet you have to update the output value according 
+      // to the input (which may have changed if the user set it)
        bbSetOutputOut(bbGetInputIn());
       }
   }
@@ -154,8 +190,8 @@ void wxColourPickerCtrlWidget::UpdateBox()
     cb = (unsigned char)(255.*b);
 
     wxColourPickerCtrlWidget* w = new wxColourPickerCtrlWidget(this, //bbGetWxParent() , 
-                                                                                               parent,
-                                                                                               cr , cg , cb );    
+                                                               parent,
+                                                               cr , cg , cb );    
     
     bbSetOutputWidget( w );
   }