]> Creatis software - bbtk.git/commitdiff
#3416 BBTK Feature New Normal - Patch combobox to show the end of the string item
authorEduardo DAVILA <davila@localhost.localdomain>
Wed, 29 Apr 2020 15:52:40 +0000 (17:52 +0200)
committerEduardo DAVILA <davila@localhost.localdomain>
Wed, 29 Apr 2020 15:52:40 +0000 (17:52 +0200)
packages/wx/src/bbwxComboBox.cxx

index 06ec5912e0d115e929e31be9711424aab6d10a51..05f3a33f5728a826ebd8829fb76bab92f10581d7 100644 (file)
@@ -88,10 +88,14 @@ namespace bbwx
     sizer->AddGrowableCol(0);
     panel->SetSizer(sizer);
        
-       for (i=0;i<lstIn.size(); i++)
-       {
-               itemcontainer->Append(  bbtk::std2wx( lstIn[i] )  ); 
-       } // for i
+
+
+       FillItems( iSelection,lstIn );
+       
+//     for (i=0;i<lstIn.size(); i++)
+//     {
+//             itemcontainer->Append(  bbtk::std2wx( lstIn[i] )  ); 
+//     } // for i
 //     itemcontainer->SetSelection(iSelection);
   }
 
@@ -119,7 +123,13 @@ namespace bbwx
        {
                mBox->bbSetInputSelection( iSelection );
                mBox->bbSetOutputOut( iSelection );
-               mBox->bbSetOutputOutString(    bbtk::wx2std( itemcontainer->GetString(iSelection) )     );
+
+// Patch to clean the spaces at the begining 
+               std::string tmpStr = bbtk::wx2std( itemcontainer->GetString(iSelection) );
+               if (tmpStr.length()>0) { while(tmpStr[0]==' ') tmpStr.erase(0,1); }
+               mBox->bbSetOutputOutString(   tmpStr   );
+//             mBox->bbSetOutputOutString(   bbtk::wx2std( itemcontainer->GetString(iSelection) )   );
+
                mBox->bbSignalOutputModification();
                VerifyDeselect(iSelection);
                if (mTypeForm==0) 
@@ -143,13 +153,38 @@ void ComboBoxWidget::OnComboBox(wxEvent& event)
 //--------------------------------------------------------------------------
 void ComboBoxWidget::FillItems( int iSelection, std::vector< std::string > lstIn )
 {
-       int i;
+       int i,size=lstIn.size();
+
+// Patch to put spaces at the beginin
+       int strLength=-1;
+       // Looking for the longest string
+       for (i=0 ;i<size; i++)
+       {       
+               if ( strLength < (int) lstIn[i].length() ) { strLength=lstIn[i].length();  }
+       }       // for
+       // Adding spaces at the bigining to the others strings in the list to have the same size
+       int ii,len2;
+       for (i=0 ;i<size; i++)
+       {       
+               len2 = strLength - lstIn[i].length();
+               for (ii=0;ii<len2;ii++)
+               {       
+                       lstIn[i]="   "+lstIn[i];  // 3 space characters
+               } // for ii
+       } // for i
+       
        itemcontainer->Clear();
-       for (i=0;i<lstIn.size(); i++)
+       for (i=0;i<size; i++)
        {
                itemcontainer->Append(  bbtk::std2wx( lstIn[i] )  ); 
        } // for i
        if (iSelection>=0) itemcontainer->SetSelection(iSelection);
+
+       if (mTypeForm==0) 
+       { 
+               ((wxChoice*)itemcontainer)->SetAutoLayout( true ); 
+               ((wxChoice*)itemcontainer)->Layout( ); 
+       } // if mTypeForm       
 } 
 
 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ComboBox)