]> Creatis software - bbtk.git/blobdiff - packages/wx/src/bbwxRadioButton.cxx
#3496 Linux Bug
[bbtk.git] / packages / wx / src / bbwxRadioButton.cxx
index ce0f36b5c84c03f1a3c158b202b19b3f44d06c11..fed13e89d463834126593f8520968442d387db0b 100644 (file)
@@ -65,11 +65,14 @@ namespace bbwx
 
     int GetValue();
     void OnRadioButton(wxEvent& event);
+       void AddElements(std::vector<wxString> lstIn, int In, wxString title);
 
   private:
     RadioButton      *mBox;
     int                     MAX_RADIOBUTTON;
     wxRadioButton    *mwxRadioButton[10];
+
+       wxFlexGridSizer  *sizer;
   };
   
   //------------------------------------------------------------------------
@@ -86,8 +89,49 @@ namespace bbwx
     wxPanel( parent, -1) ,
     mBox(box)
   {
-    wxPanel *panel     = this;
+
+  }
+  //-------------------------------------------------------------------------
+  
+  RadioButtonWidget::~RadioButtonWidget()
+  {
+  }
+
+  //-------------------------------------------------------------------------
+  int RadioButtonWidget::GetValue()
+  { 
+    int result=-1;
+    int i;
+    for (i=0;i<MAX_RADIOBUTTON; i++)
+      {
+       if ( mwxRadioButton[i]!=NULL)
+         {
+           if (mwxRadioButton[i]->GetValue()==true)
+             {
+               result=i;
+             }
+         }
+      }
+    return result;
+  }
+
+  //--------------------------------------------------------------------------
+  void RadioButtonWidget::OnRadioButton(wxEvent& event)
+  {
+    mBox->bbSetOutputOut( GetValue() );
+    mBox->bbSetInputIn( GetValue() );
+    mBox->bbSignalOutputModification("Out");
+  }
+
+
+  //--------------------------------------------------------------------------
+  void RadioButtonWidget::AddElements( std::vector<wxString> lstIn ,int In, wxString title)
+  {
+       DestroyChildren();
+
     MAX_RADIOBUTTON = lstIn.size();
+    wxPanel *panel     = this;
     int i;
     long style=wxRB_GROUP;
     for (i=0;i<MAX_RADIOBUTTON; i++)
@@ -103,9 +147,7 @@ namespace bbwx
              if (In==i)
              {
                      mwxRadioButton[i]->SetValue(true);
-             } 
-             else 
-             {
+             } else {
                      mwxRadioButton[i]->SetValue(false);
              }
               Connect( mwxRadioButton[i]->GetId(),  
@@ -113,18 +155,20 @@ namespace bbwx
                   (wxObjectEventFunction) 
                   (void (wxPanel::*)(wxEvent&))
                   &RadioButtonWidget::OnRadioButton ); 
-          } 
-          else 
-          {
+          } else {
               mwxRadioButton[i]=NULL;
-          }
-    }
+          } // if
+    } // for 
     
     //---------------------------------------------------------------------
     // 2) Insertion of the components in the window
     
     // We use a FlexGridSizer
-    wxFlexGridSizer *sizer     = new wxFlexGridSizer(1);
+
+//EED 2018-04-18
+//    wxFlexGridSizer *sizer   = new wxFlexGridSizer(1);
+    sizer      = new wxFlexGridSizer(1);
+
     if (title!=_T(""))
     {
           sizer->Add( new wxStaticText(panel,-1, title ) ); 
@@ -139,42 +183,11 @@ namespace bbwx
     sizer->AddGrowableCol(0);
     panel->SetSizer(sizer);
 
-//    panel->SetAutoLayout(true);
-//    panel->Layout();
+    panel->SetAutoLayout(true);
+    panel->Layout();
 
   }
-  //-------------------------------------------------------------------------
-  
-  RadioButtonWidget::~RadioButtonWidget()
-  {
-  }
-
-  //-------------------------------------------------------------------------
-  int RadioButtonWidget::GetValue()
-  { 
-    int result=-1;
-    int i;
-    for (i=0;i<MAX_RADIOBUTTON; i++)
-      {
-       if ( mwxRadioButton[i]!=NULL)
-         {
-           if (mwxRadioButton[i]->GetValue()==true)
-             {
-               result=i;
-             }
-         }
-      }
-    return result;
-  }
 
-  //--------------------------------------------------------------------------
-  void RadioButtonWidget::OnRadioButton(wxEvent& event)
-  {
-    mBox->bbSetOutputOut( GetValue() );
-    mBox->bbSetInputIn( GetValue() );
-    mBox->bbSignalOutputModification("Out");
-  }
 
   //--------------------------------------------------------------------------
   //-------------------------------------------------------------------------
@@ -216,6 +229,24 @@ namespace bbwx
   { 
     bbtkDebugMessageInc("Core",9,"RadioButton::Process()"<<std::endl);
     bbtkDebugDecTab("Core",9);
+
+
+    std::vector<wxString> lstIn;
+    lstIn.push_back( bbtk::std2wx(bbGetInputIn0()) );
+    lstIn.push_back( bbtk::std2wx(bbGetInputIn1()) );
+    lstIn.push_back( bbtk::std2wx(bbGetInputIn2()) );
+    lstIn.push_back( bbtk::std2wx(bbGetInputIn3()) );
+    lstIn.push_back( bbtk::std2wx(bbGetInputIn4()) );
+    lstIn.push_back( bbtk::std2wx(bbGetInputIn5()) );
+    lstIn.push_back( bbtk::std2wx(bbGetInputIn6()) );
+    lstIn.push_back( bbtk::std2wx(bbGetInputIn7()) );
+    lstIn.push_back( bbtk::std2wx(bbGetInputIn8()) );
+    lstIn.push_back( bbtk::std2wx(bbGetInputIn9()) );
+    
+       if (bbGetOutputWidget()!=NULL) 
+       {
+               ( (RadioButtonWidget*)bbGetOutputWidget() )->AddElements(lstIn, bbGetInputIn() , bbtk::std2wx(bbGetInputTitle()) );     
+       } // if bbGetOutputWidget
   }
 
   /**
@@ -240,8 +271,7 @@ namespace bbwx
 
     RadioButtonWidget *w = new RadioButtonWidget(
                          this,
-//                         bbGetWxParent(),
-                                                       parent, 
+                                                parent,        
                          bbGetInputIn() ,
                          bbtk::std2wx(bbGetInputTitle()),
                          lstIn );