From c2e663cbf317393fd60d00101f9e40b6d83c0d22 Mon Sep 17 00:00:00 2001
From: "eduardo.davila@creatis.insa-lyon.fr"
 <eduardo.davila@creatis.insa-lyon.fr>
Date: Tue, 28 Jan 2025 15:13:45 +0100
Subject: [PATCH] #3532 Maximized main wxFrame

---
 kernel/src/bbtkBlackBox.h           |  3 ---
 kernel/src/bbtkWidgetBlackBox.h     | 31 ++++++---------------
 kernel/src/bbtkWidgetBlackBox.txx   |  6 +----
 kernel/src/bbtkWtBlackBox.cxx       | 42 +++++++++++++----------------
 kernel/src/bbtkWxBlackBox.cxx       | 18 +++++--------
 kernel/src/bbtkWxBlackBox.h         | 17 ------------
 packages/qt/src/bbqtLayoutLine.cxx  |  4 ---
 packages/vtk/src/bbvtkTransform.cxx |  2 +-
 packages/wx/src/bbwxLayoutLine.cxx  | 41 +++++++++++++++++-----------
 packages/wx/src/bbwxLayoutLine.h    | 20 +-------------
 packages/wx/src/bbwxLayoutTab.cxx   |  9 -------
 11 files changed, 61 insertions(+), 132 deletions(-)

diff --git a/kernel/src/bbtkBlackBox.h b/kernel/src/bbtkBlackBox.h
index 2bd1bbd..77ebcab 100644
--- a/kernel/src/bbtkBlackBox.h
+++ b/kernel/src/bbtkBlackBox.h
@@ -33,8 +33,6 @@
   Version:   $Revision: 1.34 $
 =========================================================================*/
 
-
-
 /**
  *  \file
  *  \brief Class bbtk::BlackBox : abstract black-box interface.
@@ -59,7 +57,6 @@
 #include <boost/bind.hpp>
 #include <boost/signals2/signal.hpp>
 
-
 #define bbtkBlackBoxMessage(key,level,mess) \
   bbtkMessage(key,level,"["<<bbGetTypeName()<<":"<<bbGetName()<<"] "<<mess)
 #define bbtkBlackBoxDebugMessage(key,level,mess)	\
diff --git a/kernel/src/bbtkWidgetBlackBox.h b/kernel/src/bbtkWidgetBlackBox.h
index b0333a6..7e3db1a 100644
--- a/kernel/src/bbtkWidgetBlackBox.h
+++ b/kernel/src/bbtkWidgetBlackBox.h
@@ -82,6 +82,7 @@ namespace bbtk
     BBTK_DECLARE_INPUT(WinWidth,int);
     BBTK_DECLARE_INPUT(WinHeight,int);
     BBTK_DECLARE_INPUT(WinDialog,bool);
+    BBTK_DECLARE_INPUT(WinMaximized,bool);
     BBTK_DECLARE_INPUT(WinHide,Void);
     BBTK_DECLARE_INPUT(WinClose,Void);
     BBTK_DECLARE_OUTPUT(Widget,Widget*);
@@ -107,7 +108,6 @@ namespace bbtk
     bool bbIsShown();
     //==================================================================    
  
-   
     //==================================================================    
     /// User callback for creating the widget associated to the box
     /// ** Must be defined ** in user classes
@@ -117,7 +117,6 @@ namespace bbtk
     }
     //==================================================================    
 
-	  
   protected:
     
     void bbSetShown(bool);
@@ -211,32 +210,18 @@ namespace bbtk
   BBTK_NAME("WidgetBlackBox_"+HumanTypeName<T>());
   // BBTK_DESCRIPTION("Widget box. The inputs marked with (*) are only used if the widget is not inserted in another widget.\n");
   BBTK_CATEGORY("widget");
-  BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinTitle,
-	     "Title of the window (*)",
-	     std::string);
-  BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinWidth,
-	     "Width of the window (* : only used if the widget is not connected to a Layout box)",int);
-  BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinHeight,
-	     "Height of the window (*)",int);
-  BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinDialog,
-	     "Set to 'true' to create a dialog window, i.e. which blocks the pipeline until it is closed (modal) (*)",bool);
-  BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinHide,
-	     "Any signal received hides the window (*)",Void);
-  BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinClose,
-	     "Any signal received closes the window (*)",Void);
+  BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinTitle,"Title of the window (*)",std::string);
+  BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinWidth,"Width of the window (* : only used if the widget is not connected to a Layout box)",int);
+  BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinHeight,"Height of the window (*)",int);
+  BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinDialog,"Set to 'true' to create a dialog window, i.e. which blocks the pipeline until it is closed (modal) (*)",bool);
+  BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinHide,"Any signal received hides the window (*)",Void);
+  BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinClose,"Any signal received closes the window (*)",Void);
+  BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinMaximized,"Start Application Maximazed",bool);
   typedef typename WidgetBlackBox<T>::WidgetPointer WidgetPointer;
   BBTK_TEMPLATE_OUTPUT(WidgetBlackBox,Widget,"Output widget",WidgetPointer);
   BBTK_END_DESCRIBE_BLACK_BOX(WidgetBlackBox);
   //=================================================================
 
-
-
-
-
-
-
-
-
 } //namespace bbtk
 
 // template code inclusion
diff --git a/kernel/src/bbtkWidgetBlackBox.txx b/kernel/src/bbtkWidgetBlackBox.txx
index 0c2a7a1..3f1c7b2 100644
--- a/kernel/src/bbtkWidgetBlackBox.txx
+++ b/kernel/src/bbtkWidgetBlackBox.txx
@@ -33,19 +33,14 @@
   Version:   $Revision: 1.7 $
 =========================================================================*/
 
-
-
 /**
  *  \file 
  *  \brief 
  */
-
-
  
 //#include "bbtkWidgetBlackBoxWindow.h"
 #include "bbtkBlackBoxOutputConnector.h"
 
-
 namespace bbtk
 {
 
@@ -69,6 +64,7 @@ namespace bbtk
     bbSetInputWinTitle(bbGetName());
     bbSetInputWinWidth(800);
     bbSetInputWinHeight(800);
+    bbSetInputWinMaximized(false);
     bbSetInputWinDialog(false);
     bbSetOutputWidget(0);
   }
diff --git a/kernel/src/bbtkWtBlackBox.cxx b/kernel/src/bbtkWtBlackBox.cxx
index a3cb0db..fa8d51e 100644
--- a/kernel/src/bbtkWtBlackBox.cxx
+++ b/kernel/src/bbtkWtBlackBox.cxx
@@ -405,32 +405,26 @@ int argc=2;
 
   //==================================================================
   void WtBlackBox::bbShowWindow()
-  {
-    if ((bbmWindow) && (!bbIsShown()))
+{
+      if ((bbmWindow) && (!bbIsShown()))
       {
-	bbtkBlackBoxDebugMessage("widget",3,"==> WtBlackBox::bbShowWindow()"
-			 <<std::endl);
- 	if (bbGetInputWinDialog()) 
-	  {
-	  //  ((WxDialog*)bbmWindow)->ShowModal();
-	  }
-	else
-	  {
-		// There is not such a thing like show becouse it is a webapp
-	   // bbGetWindow()->Show();
-	  //  WWt::CreateWtAppIfNeeded();
-
-
-		Wt::WRun(WtBlackBox::wtServerData::argc,
-                         WtBlackBox::wtServerData::argv,
-                         &createApplication);	
-
-
-	    bbSetShown(true);
-	  } 
-      }
+          bbtkBlackBoxDebugMessage("widget",3,"==> WtBlackBox::bbShowWindow()"
+                                   <<std::endl);
+          if (bbGetInputWinDialog())
+          {
+              //  ((WxDialog*)bbmWindow)->ShowModal();
+          } else {
+              // There is not such a thing like show becouse it is a webapp
+              // bbGetWindow()->Show();
+              //  WWt::CreateWtAppIfNeeded();
+              Wt::WRun(WtBlackBox::wtServerData::argc,
+                       WtBlackBox::wtServerData::argv,
+                       &createApplication);
+              bbSetShown(true);
+          }  // if WinDialog
+      } // if bbmWindow && !bbIsShown
   }
-  //==================================================================    
+  //==================================================================
 
   //==================================================================    
   void WtBlackBox::bbDestroyWindow()
diff --git a/kernel/src/bbtkWxBlackBox.cxx b/kernel/src/bbtkWxBlackBox.cxx
index ffe21f5..f1b9544 100644
--- a/kernel/src/bbtkWxBlackBox.cxx
+++ b/kernel/src/bbtkWxBlackBox.cxx
@@ -33,8 +33,6 @@
   Version:   $Revision: 1.45 $
 =========================================================================*/
 
-
-
 #ifdef _USE_WXWIDGETS_
 
 /**
@@ -68,7 +66,6 @@ namespace bbtk
     ~WxFrame();
     void OnCloseWindow(wxCloseEvent& event);
 
-
     WxBlackBox::WeakPointer mBox;      
     DECLARE_EVENT_TABLE();
     
@@ -94,7 +91,7 @@ namespace bbtk
 	     wxSYSTEM_MENU  |
 	     wxCLOSE_BOX |
 	     wxMAXIMIZE_BOX | 
-	     wxMINIMIZE_BOX | 
+	     wxMINIMIZE_BOX |  wxFRAME_FLOAT_ON_PARENT  |
 	     wxCAPTION
         ),
     mBox(b)
@@ -112,12 +109,11 @@ namespace bbtk
     Layout();
   }
   //==================================================================
+
   //==================================================================
   WxFrame::~WxFrame() 
-    { 
-	
-printf("EED WxFrame::~WxFrame\n");	
-	
+    {
+printf("EED WxFrame::~WxFrame\n");
       if (mBox.lock())
 	  {
 		bbtkDebugMessage("widget",9,"["<<mBox.lock()->bbGetName()
@@ -167,8 +163,6 @@ printf("EED WxFrame::~WxFrame\n");
 		     wxSize size);
     ~WxDialog();
     void OnCloseWindow(wxCloseEvent& event);
-
-
     WxBlackBox::WeakPointer mBox;      
     DECLARE_EVENT_TABLE();
     
@@ -194,8 +188,8 @@ printf("EED WxFrame::~WxFrame\n");
 		wxSYSTEM_MENU  |
 		wxCLOSE_BOX |
 		wxMAXIMIZE_BOX | 
-		wxMINIMIZE_BOX | 
-		wxCAPTION  
+		wxMINIMIZE_BOX | wxSTAY_ON_TOP |
+		wxCAPTION
 	      ),
     mBox(b)
   {
diff --git a/kernel/src/bbtkWxBlackBox.h b/kernel/src/bbtkWxBlackBox.h
index e5e529b..cb160fc 100644
--- a/kernel/src/bbtkWxBlackBox.h
+++ b/kernel/src/bbtkWxBlackBox.h
@@ -33,8 +33,6 @@
   Version:   $Revision: 1.33 $
 ========================================================================*/
 
-
-
 /**
  * \brief Short description in one line
  * 
@@ -50,24 +48,17 @@
  * \brief 
  */
 
-
 #ifdef USE_WXWIDGETS
 
-
 #ifndef __bbtkWxBlackBox_h__
 #define __bbtkWxBlackBox_h__
 
-
-
 #include "bbtkWidgetBlackBox.h"
 #include "bbtkWx.h"
 
-
 namespace bbtk
 {
 
- 
-
   //==================================================================
   /// Widget black boxes
 //EED 10/06/2009 /*BBTK_EXPORT*/
@@ -76,9 +67,7 @@ namespace bbtk
   public:
     BBTK_BLACK_BOX_INTERFACE(WxBlackBox,bbtk::WidgetBlackBox<wxWindow>);
 
- 	  
     //  protected:
-    
   public:
   
    //==================================================================    
@@ -93,14 +82,12 @@ namespace bbtk
     virtual void bbCreateFrameWindow();
     //==================================================================    
 
-     
     //==================================================================    
     wxWindow* bbGetWindow() { return bbmWindow; }
     void bbSetWindow(wxWindow*) ;
     bool bbWindowIsCreated() { return (bbGetWindow() != 0); }
     //==================================================================    
 
-
     //==================================================================    
     virtual void bbShowWindow();
     //==================================================================   
@@ -116,13 +103,10 @@ namespace bbtk
   	virtual std::string ConstructWinTitle();
 
   private:
-
     wxWindow* bbmWindow;
- 
   };
   //=================================================================
  
-
   //=================================================================
   // WxBlackBoxDescriptor declaration
   class WxBlackBoxDescriptor : public WidgetBlackBoxDescriptor<wxWindow>
@@ -131,7 +115,6 @@ namespace bbtk
   BBTK_END_DESCRIBE_BLACK_BOX(WxBlackBox);
   //=================================================================
 
-
 } //namespace bbtk
 
 #endif  //__bbtkWxBlackBox_h__
diff --git a/packages/qt/src/bbqtLayoutLine.cxx b/packages/qt/src/bbqtLayoutLine.cxx
index d7925c1..065720c 100644
--- a/packages/qt/src/bbqtLayoutLine.cxx
+++ b/packages/qt/src/bbqtLayoutLine.cxx
@@ -33,15 +33,11 @@
   Version:   $Revision: 1.4 $
 =========================================================================*/
 
-
-    
-
 /**
  *  \file
  *  \brief
  */
 
-
 #ifdef USE_QT
 
 #include "bbqtLayoutLine.h"
diff --git a/packages/vtk/src/bbvtkTransform.cxx b/packages/vtk/src/bbvtkTransform.cxx
index 1b29f8b..88cc6ac 100644
--- a/packages/vtk/src/bbvtkTransform.cxx
+++ b/packages/vtk/src/bbvtkTransform.cxx
@@ -142,7 +142,7 @@ namespace bbvtk
           {
               for (i=0;i<4;i++)
               {
-                  m->SetElement(i,j,manaulMatrixIn[ii]);
+                  m->SetElement(j,i,manaulMatrixIn[ii]);
                   ii++;
               }// for i
           } // for j
diff --git a/packages/wx/src/bbwxLayoutLine.cxx b/packages/wx/src/bbwxLayoutLine.cxx
index af131a2..3b25439 100644
--- a/packages/wx/src/bbwxLayoutLine.cxx
+++ b/packages/wx/src/bbwxLayoutLine.cxx
@@ -33,20 +33,17 @@
   Version:   $Revision: 1.10 $
 =========================================================================*/
 
-
 /**
  *  \file
  *  \brief
  */
 
-
 #ifdef _USE_WXWIDGETS_
 
 #include "bbwxLayoutLine.h"
 #include "bbwxPackage.h"
 #include "bbtkUtilities.h"
 
-
 namespace bbwx
 {
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx, LayoutLine);
@@ -67,23 +64,36 @@ namespace bbwx
 		bbSetInputWidget9(NULL);
 	}
 	
-	//-----------------------------------------------------------------	
-	void LayoutLine::bbUserInitializeProcessing()
-	{
-	}
-	
-	//-----------------------------------------------------------------	
-	void LayoutLine::bbUserFinalizeProcessing()
-	{
-	}	
+//-----------------------------------------------------------------
+void LayoutLine::bbUserInitializeProcessing()
+{
+}
 	
+//-----------------------------------------------------------------
+void LayoutLine::bbUserFinalizeProcessing()
+{
+}
 	
 void LayoutLine::Process()
 {
-	PutWinTitle();
+    PutWinTitle();
+    
+    if (bbGetInputWinMaximized()==true)
+    {
+        wxWindow *ww = bbGetOutputWidget();
+        while (ww->GetParent()!=NULL)
+        {
+            ww = ww->GetParent();
+        } // while
+        wxFrame *f = (wxFrame*)ww;
+        f->Iconize(false);
+        f->Maximize(true);
+        f->Raise();
+        f->Show(true);
+        f->SetFocus();
+    }// if
 }
-  
-	
+  	
 /*
   void LayoutLine::TryInsertWindow(wxWindow *parent, wxWindow *w,wxBoxSizer *sizer)
   {
@@ -152,6 +162,7 @@ void LayoutLine::Process()
     w -> SetAutoLayout(true);
     w -> Layout();
     bbSetOutputWidget( w );
+      
   }
   
   // This callback is necessary to get actual processing of the view 
diff --git a/packages/wx/src/bbwxLayoutLine.h b/packages/wx/src/bbwxLayoutLine.h
index 1992f32..9599c03 100644
--- a/packages/wx/src/bbwxLayoutLine.h
+++ b/packages/wx/src/bbwxLayoutLine.h
@@ -48,27 +48,19 @@
  * \class bbtk::NodePatern 
  * \brief Pattern for the definition of a new type of Node 
  */
-
-
 #ifdef USE_WXWIDGETS
 
-
 #ifndef __bbWxLayoutLine_h__
 #define __bbWxLayoutLine_h__
 
 #include "bbtkWxBlackBox.h"
 #include "bbwx_EXPORT.h"
 
-
 namespace bbwx
 {
-  
-
-  
   //===========================================================
   class bbwx_EXPORT LayoutLine : public bbtk::WxBlackBox
   {
-    
     BBTK_BLACK_BOX_INTERFACE(LayoutLine,bbtk::WxBlackBox);
     BBTK_DECLARE_INPUT(Widget1,wxWindow*);
     BBTK_DECLARE_INPUT(Widget2,wxWindow*);
@@ -83,18 +75,14 @@ namespace bbwx
     BBTK_PROCESS(Process);
     BBTK_CREATE_WIDGET(CreateWidget);
     BBTK_ON_SHOW_WIDGET(OnShowWidget);
- 
     void Process();
     void CreateWidget(wxWindow*);
     void OnShowWidget();
-    
   protected:
 	void TryInsertWindow(wxWindow *parent, wxWindow *w,wxBoxSizer *sizer);
-
   };
   //===========================================================
-  
- 
+
   //=================================================================
   // BlackBox description
   BBTK_BEGIN_DESCRIBE_BLACK_BOX(LayoutLine,bbtk::WxBlackBox);
@@ -114,13 +102,7 @@ namespace bbwx
   BBTK_INPUT(LayoutLine,Orientation,"Orientation (default V), 0=H=HORIZONTAL , 1=V=VERTICAL",std::string,"");
   BBTK_END_DESCRIBE_BLACK_BOX(LayoutLine);
   //=================================================================
-  
-  
-  
 }
-
-
-
 //namespace bbtk
 #endif  //__bbtkWxLayoutLine_h__
 
diff --git a/packages/wx/src/bbwxLayoutTab.cxx b/packages/wx/src/bbwxLayoutTab.cxx
index 6b529d4..1aad1fd 100644
--- a/packages/wx/src/bbwxLayoutTab.cxx
+++ b/packages/wx/src/bbwxLayoutTab.cxx
@@ -32,27 +32,19 @@
   Date:      $Date: 2012/11/16 08:52:14 $
   Version:   $Revision: 1.12 $
 =========================================================================*/
-
 /**
  *  \file 
  *  \brief 
  */
-
-
 #ifdef _USE_WXWIDGETS_
 
-
 #include "bbwxLayoutTab.h"
 #include "bbwxPackage.h"
 #include "bbtkUtilities.h"
 #include "bbtkBlackBoxInputConnector.h"
 
-
-
 namespace bbwx
 {
-
-
    //--------------------------------------------------------------------------
   class TabWidget : public wxPanel
   {
@@ -66,7 +58,6 @@ namespace bbwx
     wxNotebook	*mwxNotebook;
   }; 
 
-
   TabWidget::TabWidget(LayoutTab* box, wxWindow *parent,long style )
     : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
       mBox(box)
-- 
2.49.0