]> Creatis software - bbtk.git/commitdiff
3152 BBTK BugN ew Normal - ShareMemory, ComboBox->list
authorEduardo DAVILA <davila@localhost.localdomain>
Mon, 27 Nov 2017 11:50:03 +0000 (12:50 +0100)
committerEduardo DAVILA <davila@localhost.localdomain>
Mon, 27 Nov 2017 11:50:03 +0000 (12:50 +0100)
packages/std/src/bbstdSharedMemory.cxx
packages/std/src/bbstdSharedMemory.h
packages/wx/src/bbwxComboBox.cxx

index 75aea8742ac701d6ebfde7bd1d2f6d036a8e567a..5dfd30a6a03ee5c167766c123cd576990320da54 100644 (file)
@@ -70,7 +70,8 @@ namespace bbstd
 
   void SharedMemory::bbUserSetDefaultValues()
   {
-    mCanSet = true;
+    mCanSet    = true;
+       firsttime       = true;
   }
   void SharedMemory::bbUserInitializeProcessing() 
   { 
@@ -81,6 +82,11 @@ namespace bbstd
   void SharedMemory::DoProcess()
   { 
     mCanSet = true;
+       if (firsttime==true)
+       {
+               firsttime = false;
+           bbSetOutputOut( bbGetInputIn() );   
+       }
   }
 
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,SharedMemory);
index a981f28b3ea20d53cf5e45b56194cb2317ce5d8e..7e8c5be4f6334d823871e432b736b75bd11032b6 100644 (file)
@@ -57,7 +57,10 @@ public:                                                                      \
     public bbtk::AtomicBlackBox
   {
     BBTK_BLACK_BOX_INTERFACE(SharedMemory,bbtk::AtomicBlackBox);
+
+//    BBTK_DECLARE_INPUT(In,bbtk::Data);
     BBTK_MB_DECLARE_INPUT(In,bbtk::Data);
+
     BBTK_MB_DECLARE_INPUT(In1,bbtk::Data);
     BBTK_MB_DECLARE_INPUT(In2,bbtk::Data);
     BBTK_MB_DECLARE_INPUT(In3,bbtk::Data);
@@ -75,6 +78,7 @@ public:                                                                       \
     virtual void bbSetStatusAndPropagate(bbtk::BlackBoxInputConnector* c,
                                         bbtk::IOStatus s);
     bool mCanSet;
+    bool firsttime;
  };
   //==================================================================
   
index 5b8ab4529fd67dc9d3f18f03cab898b5fd70eae2..b11c55874b7ab4d32ebb5fb487020eb79812d5a0 100644 (file)
@@ -23,7 +23,8 @@ namespace bbwx
                     int iSelection, 
                     std::string title, 
                     std::vector< std::string > lstIn, 
-                                       int typeForm );
+                                       int typeForm, 
+                                       int sizeX, int sizeY );
        ~ComboBoxWidget();
        void OnComboBoxSelection(int iSelection);
        void OnComboBox(wxEvent& event);
@@ -32,8 +33,7 @@ namespace bbwx
   private:
     int                        mTypeForm;
     ComboBox           *mBox;
-       wxListBox               *wxlistbox;
-       wxChoice                *wxchoice;
+       wxItemContainer* itemcontainer;
   };
   
 
@@ -44,19 +44,21 @@ namespace bbwx
 
   //-------------------------------------------------------------------------
   ComboBoxWidget::ComboBoxWidget( ComboBox* box,
-               wxWindow *parent,
-               int iSelection,
-               std::string title,
-               std::vector< std::string > lstIn,
-                                       int typeForm)
+            wxWindow *parent,
+            int iSelection,
+            std::string title,
+            std::vector< std::string > lstIn,
+                       int typeForm,
+                       int sizeX, 
+                       int sizeY
+               )
     :
     wxPanel( parent, -1) ,
     mBox(box),
     mTypeForm(typeForm)
   {
        wxPanel         *panel          = this;
-       wxlistbox                               = NULL;
-       wxchoice                                = NULL;
+       itemcontainer                   = NULL;
        int i;
 
     //---------------------------------------------------------------------
@@ -70,35 +72,26 @@ namespace bbwx
     }
     sizer->AddGrowableCol(0);
     panel->SetSizer(sizer);
-               
     //---------------------------------------------------------------------
-    // 1) Creation de wxChoise widget
-
-               if (mTypeForm==1)
-               {
-
-                       wxlistbox = new wxListBox ( panel , -1 );                       
-                       Connect( wxlistbox->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); 
-               for (i=0;i<lstIn.size(); i++)
-               {
-                               wxlistbox->Append(  bbtk::std2wx( lstIn[i] )  ); 
-                       } // for i
-               wxlistbox->SetSelection(iSelection);
-                  sizer->Add( wxlistbox,1,wxGROW ); 
-
-               } else {
-
-                       wxchoice = new wxChoice ( panel , -1 );
-                       Connect( wxchoice->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); 
-               for (i=0;i<lstIn.size(); i++)
-               {
-                               wxchoice->Append(  bbtk::std2wx( lstIn[i] )  ); 
-                       } // for i
-               wxchoice->SetSelection(iSelection);
-                  sizer->Add( wxchoice,1,wxGROW ); 
-               }
-//    panel->SetAutoLayout(true);
-//    panel->Layout();
+       if (mTypeForm==1)
+       {
+               wxListBox *wxlistbox = new wxListBox ( panel , -1 , wxDefaultPosition,wxSize(sizeX,sizeY),0, NULL, wxLB_SINGLE );       
+               itemcontainer=wxlistbox;
+               sizer->Add( wxlistbox,1,wxEXPAND ); 
+               Connect( wxlistbox->GetId(), 
+                 wxEVT_COMMAND_LISTBOX_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); 
+       } else if (mTypeForm==0) {
+               wxChoice *wxchoice = new wxChoice ( panel , -1 );
+               itemcontainer=wxchoice;
+               sizer->Add( wxchoice,1,wxGROW ); 
+               Connect( wxchoice->GetId(), 
+                 wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); 
+       }
+       for (i=0;i<lstIn.size(); i++)
+       {
+               itemcontainer->Append(  bbtk::std2wx( lstIn[i] )  ); 
+       } // for i
+       itemcontainer->SetSelection(iSelection);
   }
   //-------------------------------------------------------------------------
   
@@ -110,50 +103,31 @@ namespace bbwx
   //--------------------------------------------------------------------------
   void ComboBoxWidget::OnComboBoxSelection(int iSelection)
   {
-    mBox->bbSetInputSelection( iSelection );
-    mBox->bbSetOutputOut( iSelection );
-    mBox->bbSetOutputOutString(    bbtk::wx2std( wxchoice->GetString(iSelection) )     );
-    mBox->bbSignalOutputModification("Out");
-    mBox->bbSignalOutputModification("OutString");
+       if (iSelection>=0) 
+       {
+               mBox->bbSetInputSelection( iSelection );
+               mBox->bbSetOutputOut( iSelection );
+               mBox->bbSetOutputOutString(    bbtk::wx2std( itemcontainer->GetString(iSelection) )     );
+               mBox->bbSignalOutputModification("Out");
+               mBox->bbSignalOutputModification("OutString");
+       } // if iSelection
   }
 
   //--------------------------------------------------------------------------
   void ComboBoxWidget::OnComboBox(wxEvent& event)
   {
-        int iSelection;
-        if (mTypeForm==1)
-        {
-                iSelection = wxlistbox->GetSelection();
-        } else {
-                iSelection = wxchoice->GetSelection();
-        }
-        OnComboBoxSelection(iSelection);
+       OnComboBoxSelection( itemcontainer->GetSelection() );
   }
 //--------------------------------------------------------------------------
-  void ComboBoxWidget::FillItems(
-               int iSelection,
-               std::vector< std::string > lstIn
-       )
+  void ComboBoxWidget::FillItems( int iSelection, std::vector< std::string > lstIn )
        {
                int i;
-               if (mTypeForm==1)
-               {
-                       wxlistbox->Clear();
-
-               for (i=0;i<lstIn.size(); i++)
-               {
-                               wxlistbox->Append(  bbtk::std2wx( lstIn[i] )  ); 
-                       } // for i
-
-               wxlistbox->SetSelection(iSelection);
-               } else {
-                       wxchoice->Clear();
-               for (i=0;i<lstIn.size(); i++)
-               {
-                               wxchoice->Append(  bbtk::std2wx( lstIn[i] )  ); 
-                       } // for i
-               wxchoice->SetSelection(iSelection);
-               } // if
+               itemcontainer->Clear();
+       for (i=0;i<lstIn.size(); i++)
+       {
+                       itemcontainer->Append(  bbtk::std2wx( lstIn[i] )  ); 
+               } // for i
+       itemcontainer->SetSelection(iSelection);
        } 
 
 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ComboBox)
@@ -175,8 +149,6 @@ void ComboBox::Process()
     { 
        bbSetOutputOutString( bbGetInputIn()[ iSelection ] );
     }
-//    bbSignalOutputModification("Out");
-//    bbSignalOutputModification("OutString");
 }
 
 //===== 
@@ -184,24 +156,17 @@ void ComboBox::Process()
 //===== 
 void ComboBox::CreateWidget(wxWindow* parent)
 {
-
-//   bbSetOutputWidget( new wxStaticText ( parent , -1 , _T("") ) );
-//   bbSetOutputWidget( new wxComboBox ( parent , -1 , _T("ups") ) );  
-//   bbSetOutputWidget( new wxChoice ( parent , -1 ) );  
-
     ComboBoxWidget *w = new ComboBoxWidget(
                                this,
                                                        parent,
                                bbGetInputSelection() ,
                                bbGetInputTitle(),
                                bbGetInputIn(),
-                               bbGetInputForm() );
-
+                               bbGetInputForm(),
+                                                       bbGetInputWinWidth(), bbGetInputWinHeight()  );
    bbSetOutputOut( bbGetInputSelection() );
    bbSetOutputOutString( bbGetInputIn()[ bbGetInputSelection() ] );
    bbSetOutputWidget( w );
-
-
 }
 //===== 
 // 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)
@@ -211,6 +176,8 @@ void ComboBox::bbUserSetDefaultValues()
        bbSetInputSelection(0);
        bbSetInputTitle("");
        bbSetInputForm(0);
+       bbSetInputWinWidth(100);
+       bbSetInputWinHeight(200);
 }
 //===== 
 // 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)