]> Creatis software - bbtk.git/commitdiff
#3514 Layout
authordavila <davila@localhost.localdomain>
Tue, 2 Apr 2024 11:54:13 +0000 (13:54 +0200)
committerdavila <davila@localhost.localdomain>
Tue, 2 Apr 2024 11:54:13 +0000 (13:54 +0200)
packages/wx/src/bbwxLayoutLine.cxx
packages/wx/src/bbwxLayoutSplit.cxx
packages/wx/src/bbwxLayoutSplit.h
packages/wx/src/bbwxLayoutTab.cxx

index 961218b5888125e3ffce94559a0cac5603c71e76..9474ae5e4bf29e686d72532ed154e1bf0bbe06d5 100644 (file)
@@ -98,7 +98,7 @@ void LayoutLine::Process()
   void LayoutLine::CreateWidget(wxWindow* parent)
   {
     wxBoxSizer *sizer;
-    wxPanel *w=new wxPanel(parent, -1, wxDefaultPosition, wxSize(20,20) );
+    wxPanel *w=new wxPanel(parent, -1, wxDefaultPosition, wxSize(40,40) );
     w->SetName( bbtk::std2wx( bbGetInputWinTitle() ) );
     
     int style=0;
@@ -150,6 +150,7 @@ void LayoutLine::Process()
     TryInsertWindow(w,bbGetInputWidget8(),sizer);
     TryInsertWindow(w,bbGetInputWidget9(),sizer);
     */
+    w -> SetAutoLayout(true);
     w  -> SetSizer(sizer);
     bbSetOutputWidget( w );
   }
index de0a432657279451d5f5931d6b037571e77ee65d..e632f95ef453afc75e6c0222e4b818dd3f58098e 100644 (file)
@@ -57,7 +57,8 @@ namespace bbwx
                bbSetInputOrientation("VERTICAL");
                bbSetInputProportion(50);
                bbSetInputWidget1(NULL);
-               bbSetInputWidget2(NULL);                
+               bbSetInputWidget2(NULL);
+               w=NULL; 
        }
        
        //-----------------------------------------------------------------     
@@ -77,14 +78,17 @@ namespace bbwx
 
   void LayoutSplit::CreateWidget(wxWindow* parent)
   {
-    wxSplitterWindow* w = new wxSplitterWindow(parent, //bbGetWxParent(),
-                                              -1,
-                                              wxDefaultPosition,
-                                              wxDefaultSize,
-                                              //wxSize(400,200),
-                           wxSP_3DSASH |
-                                              wxSP_LIVE_UPDATE );
-    w->SetName( bbtk::std2wx( bbGetInputWinTitle() ) );
+    wxPanel            *splitterWindowPanel    = new wxPanel(parent, -1, wxDefaultPosition, wxSize(40,40) );
+
+ //   wxSplitterWindow *w
+                       w                       = new wxSplitterWindow( splitterWindowPanel, //bbGetWxParent(),
+                                                                       -1,
+                                                                       wxDefaultPosition,
+                                                                       wxDefaultSize,
+//                                                                     wxSize(400,200),
+                                                                       wxSP_3DSASH |
+                                                                       wxSP_LIVE_UPDATE );
+       w->SetName( bbtk::std2wx( bbGetInputWinTitle() ) );
        w->SetMinimumPaneSize(15);
        //RaC Nov2012 Correctly resize internal panels with the window resize event
        w->SetSashGravity(0.5);
@@ -100,18 +104,26 @@ namespace bbwx
 
          wxWindow* w1 = bbCreateWidgetOfInput("Widget1",w);
          wxWindow* w2 = bbCreateWidgetOfInput("Widget2",w);
-         if (w1==NULL) { w1=new wxPanel(parent); }
-         if (w2==NULL) { w2=new wxPanel(parent); }
+         if (w1==NULL) { w1=new wxPanel(splitterWindowPanel); }
+         if (w2==NULL) { w2=new wxPanel(splitterWindowPanel); }
          
          int orientation=0;
-    if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"0|H|HORIZONTAL")==true)  { orientation=0; }
-    if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|V|VERTICAL")==true)    { orientation=1; }
+    if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"0|H|h|horizontal|Horizontal|HORIZONTAL")==true)  { orientation=0; }
+    if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|V|v|vertical|Vertical|VERTICAL")==true)    { orientation=1; }
     
 
     if (orientation==1) { w->SplitHorizontally( w1, w2, 100); }
     else                { w->SplitVertically( w1, w2, 100);   }
-  
-    bbSetOutputWidget( w );
+
+//EED 2024-03-30  
+    wxBoxSizer *sizer  = new wxBoxSizer(wxVERTICAL);
+    sizer->Add( w , 1, wxGROW, 0 );
+    splitterWindowPanel->SetSizer( sizer );
+    splitterWindowPanel->SetAutoLayout(true);
+    splitterWindowPanel->Layout();
+    bbSetOutputWidget( splitterWindowPanel );
+//    bbSetOutputWidget( w );
+
   }
 
 
@@ -120,34 +132,35 @@ namespace bbwx
   void  LayoutSplit::OnShowWidget()
   {
     //    std::cout << "LayoutSplit::OnShowWidget()" << std::endl;
-    if (bbGetOutputWidget()==0)
+    if (bbGetOutputWidget()==NULL)
       {
        return;
        //bbtkError("LayoutSplit::OnShowWidget() : Output Widget == 0 !");
       }
-    wxSplitterWindow* win = (wxSplitterWindow*)bbGetOutputWidget();
-    int w,h;
-    if (win==0)
+//    wxSplitterWindow* win = (wxSplitterWindow*)bbGetOutputWidget();
+    int width,height;
+    if (w==NULL)
       {
        return;
        //      bbtkError("LayoutSplit::OnShowWidget() : win == 0 !");
       }
-    win->GetClientSize(&w,&h);
-    int pos = 100;
+    w->GetParent()->GetParent()->GetClientSize(&width,&height);
+    int    pos = 100;
+    double ww  = width;
+    double hh  = height;
+    double proportion = bbGetInputProportion();
     if (bbtk::Utilities::loosematch(bbGetInputOrientation(),
-                                   "0|H|HORIZONTAL")==true)  
+                                   "0|H|h|horizontal|Horizontal|HORIZONTAL")==true)  
       { 
-       pos = (int)(w * bbGetInputProportion() * 0.01);
-      }
-    else 
-      {
-       pos = (int)(h * bbGetInputProportion() * 0.01);
+       pos = (int)(ww * proportion * 0.01);
+      }    else {
+       pos = (int)(hh * proportion * 0.01);
       } 
-    //    std::cout << "pos = "<<pos<<std::endl;
   
-    win->SetSashPosition(pos,true);
+       printf("EED LayoutSplit::OnShowWidget  width=%d   height=%d  proportion=%d pos=%d box=%s\n", width,height,bbGetInputProportion(),pos, bbGetFullName().c_str() );        
+    w->SetSashPosition(pos,true);
     //RaC Nov2012 Correctly resize internal panels with the window resize event
-    win->SetSashGravity(0.5);
+    w->SetSashGravity(0.5);
 
   }
 
index e7ca2e3e5ee025650ef56dd71229749ae7b4a541..02ac02c5c0dbe09faed7d3f9dc3d96721d140298 100644 (file)
@@ -59,9 +59,6 @@
 namespace bbwx
 {
   
-  
-  
-  
   //=================================================================
   class bbwx_EXPORT LayoutSplit : public bbtk::WxBlackBox
   {
@@ -80,6 +77,7 @@ namespace bbwx
     void OnShowWidget();
 
   protected:
+       wxSplitterWindow *w;
 
   };
   //=================================================================
@@ -94,8 +92,8 @@ namespace bbwx
   // Already inserted for any WxBlackBox  BBTK_CATEGORY("widget");
   BBTK_INPUT(LayoutSplit,Widget1,"Upper or left widget",wxWindow*,"");
   BBTK_INPUT(LayoutSplit,Widget2,"Lower or right widget",wxWindow*,"");
-  BBTK_INPUT(LayoutSplit,Orientation,"Orientation (default H), 0=H=HORIZONTAL , 1=V=VERTICAL",std::string,"");
-  BBTK_INPUT(LayoutSplit,Proportion,"Proportion (in percent) of the first children in the window",int,"");
+  BBTK_INPUT(LayoutSplit,Orientation,"(default VERTICAL) Orientation  0=H=HORIZONTAL , 1=V=VERTICAL",std::string,"");
+  BBTK_INPUT(LayoutSplit,Proportion,"(default 50) Proportion (in percent) of the first children in the window",int,"");
   BBTK_END_DESCRIBE_BLACK_BOX(LayoutSplit);
   //=================================================================
 }
index fac1678d5f3cceb919cd1f0c05ab8caa012056b5..85a07582038538600fb93239613d238f2ef161ec 100644 (file)
@@ -67,8 +67,7 @@ namespace bbwx
   }; 
 
 
-  TabWidget::TabWidget(LayoutTab* box,
-                                          wxWindow *parent,long style )
+  TabWidget::TabWidget(LayoutTab* box, wxWindow *parent,long style )
     : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
       mBox(box)
   { 
@@ -77,14 +76,14 @@ namespace bbwx
                                   -1, 
                                   wxDefaultPosition,
 //                                wxDefaultSize,
-                                     wxSize(50,50),
+                                   wxSize(20,20),
                                   style );
     Connect( mwxNotebook->GetId(),   wxEVT_NOTEBOOK_PAGE_CHANGED , 
             (wxObjectEventFunction) 
             (void (wxPanel::*)(wxEvent&))
             &TabWidget::OnTabChange ); 
     wxBoxSizer *sizer  = new wxBoxSizer(wxHORIZONTAL);
-    sizer -> Add( mwxNotebook,1,wxGROW,0 ); 
+    sizer      -> Add( mwxNotebook,1,wxGROW,0 ); 
     panel      -> SetSizer(sizer);
     panel      -> SetAutoLayout(true);
     panel      -> Layout();