]> Creatis software - creaImageIO.git/commitdiff
#3323 Bug with ToolBar (in wxFrame an not in wxPanel) in MacOs vtk8itk5wx3-macos
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Tue, 21 Dec 2021 16:13:07 +0000 (17:13 +0100)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Tue, 21 Dec 2021 16:13:07 +0000 (17:13 +0100)
src/creaImageIOWxGimmickFrame.h
src/creaImageIOWxGimmickPanel.cpp
src/creaImageIOWxGimmickReaderDialog.cpp
src/creaImageIOWxGimmickReaderDialog.h
src/creaImageIOWxGimmickView.cpp
src/creaImageIOWxGimmickView.h
src/creaImageIOWxSimpleDlg.cpp
src/creaImageIOWxSimpleDlg.h

index b71d152099879cb3303b7faeb453c0255ffd2975..a4753ca700df8c594785cee163ef50f08ea4249a 100644 (file)
@@ -45,7 +45,7 @@ namespace creaImageIO
   {
   public:
     WxGimmickFrame();    
-    WxGimmickFrame(wxWindow *parent, 
+    WxGimmickFrame(wxWindow *parent,
                   const wxWindowID id,
                   wxString title,
                   const wxPoint& pos, 
index 2aaa2e625a469900083b03ed96d7db80a4541a79..1ca68e89870460c1e502b057ebf2cb54df591663 100644 (file)
@@ -35,7 +35,7 @@
 namespace creaImageIO
 {
   // CTor
-  WxGimmickPanel::WxGimmickPanel(wxWindow *parent, 
+  WxGimmickPanel::WxGimmickPanel(wxWindow *parent,
                                  wxWindowID id,
                                  const wxPoint& pos,
                                  const wxSize& size,
index 3af978666b7d69615c5faf91c29cf2711c71a95a..f7af7d0a589d99594fb3da7499bd26a58ee52b34 100644 (file)
@@ -35,7 +35,7 @@
 namespace creaImageIO
 {
   // CTor
-  WxGimmickReaderDialog::WxGimmickReaderDialog(wxWindow *parent, 
+  WxGimmickReaderDialog::WxGimmickReaderDialog(wxWindow *parent,
                                               wxWindowID id,
                                               const std::string i_namedescp, 
                                               const std::string i_namedb,
@@ -46,7 +46,7 @@ namespace creaImageIO
                                               int max_dim,
                                               int output_dim,  // never used ?!? // JPR
                                               int threads)
- :   wxDialog( parent, 
+ :   wxDialog( parent,
                  id, 
                  title,
                  pos,
@@ -67,10 +67,10 @@ namespace creaImageIO
 
     try {
 
-       mGimmick = boost::shared_ptr<Gimmick>(new Gimmick());
-       mGimmick->Initialize(i_namedescp,i_namedb);
+        mGimmick = boost::shared_ptr<Gimmick>(new Gimmick());
+        mGimmick->Initialize(i_namedescp,i_namedb);
 
-       mView = new WxGimmickView(mGimmick,
+     mView = new WxGimmickView(mGimmick,
                                this,
                                TVID,
                                wxDefaultPosition,
@@ -78,24 +78,24 @@ namespace creaImageIO
                                min_dim,
                                max_dim,
                                threads);
-       mView->Initialize();
+      //EED 2021-12-17
+      mView->Initialize();
           // Connect the AddProgress callback
       mView->ConnectValidationObserver( boost::bind( &WxGimmickReaderDialog::OnValid , this, _1 ) );
     } catch (crea::Exception e) {
-               printf("EED WxGimmickReaderDialog::WxGimmickReaderDialog catch 1\n");
         e.Print();
-               printf("EED WxGimmickReaderDialog::WxGimmickReaderDialog catch 2\n");
         return;
     }
     mtopsizer->Add( mView,1,wxGROW,0);
     wxSizer* bsizer = this->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
-       /*mOkButton = new wxButton(this, wxID_OK, _T("OK"), wxPoint(170,50));
-       mCancelButton = new wxButton(this, wxID_CANCEL, _T("CANCEL"), wxPoint(210,50));
-       */      mOkButton = (wxButton*)FindWindowById(GetAffirmativeId(), this);
+       //mOkButton = new wxButton(this, wxID_OK, _T("OK"), wxPoint(170,50));
+       //mCancelButton = new wxButton(this, wxID_CANCEL, _T("CANCEL"), wxPoint(210,50));
+    mOkButton = (wxButton*)FindWindowById(GetAffirmativeId(), this);
     mCancelButton = (wxButton*)FindWindowById(GetEscapeId(),      this);
     mOkButton->Enable(false);
     mtopsizer->Add ( bsizer, 0, wxGROW );
     SetSizer( mtopsizer );
+
     Layout(); 
   }
 
index 550322ca6d84d7e43119b8f9c7870cd5f51a03bf..902eeb8dbd9827fc0d2578657a3c840918ce3840 100644 (file)
@@ -47,7 +47,7 @@ namespace creaImageIO
   {
   public:
     WxGimmickReaderDialog();
-    WxGimmickReaderDialog(wxWindow *parent,
+    WxGimmickReaderDialog(wxWindow *parent, 
                          const wxWindowID id,
                          const std::string i_namedescp , 
                          const std::string i_namedb ,
index ffb6174f8543e05ecc6df88adbfef72cf1e86527..a5650ee32978d68830327d8b0de2b66ac7c68a68 100644 (file)
@@ -138,7 +138,8 @@ namespace creaImageIO
       mProgressDialog(NULL),
       mConstructed(false)
   {
-       mViewer = NULL;
+
+    mViewer = NULL;
     GimmickDebugMessage(1,"WxGimmickView::WxGimmickView" <<std::endl);
     // Sets the current directory to the home dir
     mCurrentDirectory =  std2wx(gimmick->GetHomeDirectory());
@@ -146,16 +147,20 @@ namespace creaImageIO
      // Connect the AddProgress callback
     gimmick->ConnectAddProgressObserver( boost::bind( &WxGimmickView::OnAddProgress , this, _1 ) );
 
+
     // Create the list of icons (mIcon)
     CreateIconList();
 
+
     // Global sizer
     msizer = new wxBoxSizer(wxVERTICAL);
 
     // Create the tool bar
-    CreateToolBar(); 
+    CreateToolBar( );
     msizer->Add( mToolBar, 0, wxGROW, 0);
 
+
     // Split part below toolbar into notebook for views and panel
     // for preview, messages...
     mSplitter = new wxSplitterWindow( this , -1);
@@ -170,6 +175,7 @@ namespace creaImageIO
     mSelectionMinDimension = min_dim;
     
     // Create the views
+      
     CreateTreeViews();
 
     // Bottom panel 
@@ -188,6 +194,8 @@ namespace creaImageIO
 
 
     mbottom_sizer->Add(mViewer,1,wxGROW,1);
+      
+      
     //    mViewer->Show();
 
     mText = new wxStaticText(mBottomPanel, wxID_ANY, wxT("Welcome to Gimmick!"));
@@ -210,6 +218,7 @@ namespace creaImageIO
     mProgressDialog=NULL;
     SetSizer( msizer );     
     SetAutoLayout(true);
     Layout();
     //mListener=new Listener();
     //mListener->ConnectObserver(boost::bind( &WxGimmickView::OnDriveMount, this, _1 ) );
@@ -235,21 +244,58 @@ namespace creaImageIO
     //if(mListener->IsAlive())   {        mListener->Delete();    }
   }
   //======================================================================
-  
+
+
+
+void WxGimmickView::AddBtnTool(wxPanel *panel, wxBoxSizer *sizerH, int id, wxString label, int idBitmap, wxString tooltip )
+{
+    wxBoxSizer      *sizer;
+    wxBitmapButton  *btn;
+    wxBitmap        bitmap;
+    
+    bitmap            = mIcon->GetBitmap(idBitmap);
+    btn               = new wxBitmapButton(mToolBar, id, bitmap, wxDefaultPosition, wxSize(50,50) , wxBU_BOTTOM );
+    btn->SetToolTip( tooltip );
+    sizer             = new wxBoxSizer(wxVERTICAL);
+    sizer->Add(btn,1,wxGROW,0);
+    sizer->Add(new wxStaticText(mToolBar,-1,label) , 0, wxALL | wxALIGN_CENTER, 3);
+    sizerH->Add( sizer ,1,wxGROW,0);
+}
+
   //======================================================================
   /// Creates the tool bar
   void WxGimmickView::CreateToolBar()
   {
+      mToolBar                      = new wxPanel(this,-1, wxDefaultPosition, wxSize(80,80) );
+      wxBoxSizer *sizerH             = new wxBoxSizer(wxHORIZONTAL);
+   
+      AddBtnTool(mToolBar, sizerH, TOOL_ADDFILES_ID     , _T("Add file(s)")     , Icon_page_down        , _T("Add one or more file to database")                    );
+      AddBtnTool(mToolBar, sizerH, TOOL_ADDDIR_ID       , _T("Add folder")      , Icon_folder_down      , _T("Add the content of a folder to database")             );
+      AddBtnTool(mToolBar, sizerH, TOOL_ADDDATABASE_ID  , _T("Open database")   , Icon_database_add     , _T("Open a local or distant database")                    );
+      AddBtnTool(mToolBar, sizerH, TOOL_REMOVE_ID       , _T("Remove")          , Icon_remove           , _T("Remove selected items")                               );
+      AddBtnTool(mToolBar, sizerH, TOOL_SYNCHRONIZE_ID  , _T("Synchronize")     , Icon_synchronize      , _T("Synchronizes the database with disk")                 );
+      AddBtnTool(mToolBar, sizerH, TOOL_HELP_ID         , _T("Help")            , Icon_help             , _T("Open help window")                                    );
+      AddBtnTool(mToolBar, sizerH, TOOL_SETTINGS_ID     , _T("System settings") , Icon_settings         , _T("Allows the modification of various system settings")  );
+      AddBtnTool(mToolBar, sizerH, TOOL_TOOLS_ID        , _T("Tools")           , Icon_tools            , _T("Applies tools to images")                             );
+      AddBtnTool(mToolBar, sizerH, TOOL_CREATEDB_ID     , _T("Create database") , Icon_create_database  , _T("Create DB from an Attributes Descriptor file")        );
+  #if defined(BUILD_PACS)
+      AddBtnTool(mToolBar, sizerH, TOOL_PACS_ID         , _T("PACS Connection,"), Icon_create_database  , _T("Echo, Find and Get to a PACS")                        );
+  #endif
+      mToolBar->SetSizer( sizerH );
+      mToolBar->Layout();
+      
+/* EED 2021-12-17
+   The wxToolBar depends from wxFrame, in this code it is not the case.   In Mac Os is not working !
+   Change the mechanisme from wcToolBar to normal Buttons
     long style = wxTB_HORIZONTAL | wxNO_BORDER | wxTB_TEXT;
-    mToolBar = new wxToolBar(this,-1,wxDefaultPosition,wxDefaultSize,
-                            style);
+    mToolBar = new wxToolBar(this,-1,wxDefaultPosition,wxDefaultSize,style);
 
-    mToolAddFile = mToolBar->AddTool( TOOL_ADDFILES_ID, 
+    mToolAddFile = mToolBar->AddTool( TOOL_ADDFILES_ID,
                                      _T("Add file(s)"),
                                      mIcon->GetBitmap(Icon_page_down),
                                      _T("Add one or more file to database")
                                      );
-    mToolAddDir = mToolBar->AddTool( TOOL_ADDDIR_ID, 
+    mToolAddDir = mToolBar->AddTool( TOOL_ADDDIR_ID,
                                      _T("Add folder"),
                                      mIcon->GetBitmap(Icon_folder_down),
                                      _T("Add the content of a folder to database")
@@ -297,8 +343,9 @@ namespace creaImageIO
                                      );
 #endif
     //const wxBitmap& bitmap1, const wxString& shortHelpString = "", wxItemKind kind = wxITEM_NORMAL)
+       mToolBar->Realize();
 
-    mToolBar->Realize();
+ */
   }
   //======================================================================
 
@@ -1349,6 +1396,20 @@ namespace creaImageIO
    //=================================================
 
    //=================================================
+
+BEGIN_EVENT_TABLE(WxGimmickView, wxPanel)
+    EVT_BUTTON(TOOL_CREATEDB_ID, WxGimmickView::OnCreateDB)
+    EVT_BUTTON(TOOL_ADDFILES_ID, WxGimmickView::OnAddFiles)
+    EVT_BUTTON(TOOL_ADDDIR_ID, WxGimmickView::OnAddDir)
+    EVT_BUTTON(TOOL_ADDDATABASE_ID, WxGimmickView::OnAddDB)
+    EVT_BUTTON(TOOL_REMOVE_ID, WxGimmickView::OnRemove)
+    EVT_BUTTON(TOOL_SYNCHRONIZE_ID, WxGimmickView::OnSynchronize)
+    EVT_BUTTON(TOOL_SETTINGS_ID, WxGimmickView::OnSettings)
+    EVT_BUTTON(TOOL_TOOLS_ID, WxGimmickView::OnTools)
+END_EVENT_TABLE()
+
+
+/*
   BEGIN_EVENT_TABLE(WxGimmickView, wxPanel)
     EVT_TOOL(TOOL_CREATEDB_ID, WxGimmickView::OnCreateDB)
     EVT_TOOL(TOOL_ADDFILES_ID, WxGimmickView::OnAddFiles)
@@ -1359,6 +1420,7 @@ namespace creaImageIO
     EVT_TOOL(TOOL_SETTINGS_ID, WxGimmickView::OnSettings)
     EVT_TOOL(TOOL_TOOLS_ID, WxGimmickView::OnTools)
   END_EVENT_TABLE()
+*/
   //=================================================
 
 } // EO namespace creaImageIO
index 9e2f359523cfacfad98a36c355cba65a734afb76..7ea39f2e84b6d054a1c5425c3a742c33c90f9101 100644 (file)
@@ -142,7 +142,7 @@ namespace creaImageIO
 
   protected:
     /// Creates the tool bar
-    void CreateToolBar(); 
+    void CreateToolBar( ); 
     
     /// Create the tree view for TreeHandler provided 
     /// (overloaded from GimmickView)
@@ -157,7 +157,8 @@ namespace creaImageIO
     /// before everything is ok)
     bool                               mConstructed;
     /// The ToolBar and the tools
-    wxToolBar                  *mToolBar;
+//    wxToolBar                        *mToolBar;
+    wxPanel             *mToolBar;
     wxToolBarToolBase  *mToolAddFile;
     wxToolBarToolBase  *mToolAddDir;
     wxToolBarToolBase  *mToolRemove;
@@ -175,6 +176,8 @@ namespace creaImageIO
     /// The list of icons 
     wxImageList                *mIcon;
     void CreateIconList();
+    void AddBtnTool(wxPanel *panel, wxBoxSizer *sizerH, int id, wxString label, int idBitmap, wxString tooltip );
+
     
     boost::shared_ptr<Gimmick> mGimmick;
                
index 5ee7649e489a5758ada7efb056ca598e55318b11..239b00c0859f30a233524813449b22e02234dae2 100644 (file)
@@ -33,13 +33,13 @@ namespace creaImageIO
 
 
        ///Ctor
-   WxSimpleDlg::WxSimpleDlg(wxWindow *parent, 
+   WxSimpleDlg::WxSimpleDlg(wxWindow *parent,
                             wxString i_title,  
                             const std::string i_namedescp , 
                             const std::string i_namedb)
     : wxDialog(parent, -1,_T("SELECT IMAGE(S)"), wxDefaultPosition, wxSize(500,300))
    {
-               namedescp       = i_namedescp; 
+               namedescp       = i_namedescp;
                namedb          = i_namedb;
 
           if(!i_title.empty())
@@ -137,7 +137,7 @@ namespace creaImageIO
          void WxSimpleDlg::OnReadGimmick(wxCommandEvent &event)
          {
                  // Run Gimmick
-                  WxGimmickReaderDialog dlg(0,-1, 
+                  WxGimmickReaderDialog dlg(0,-1,
                                   namedescp,
                                   namedb, 
                                   _T("Select image(s)        - Gimmick! (c)"),
index 499e25652deab85ded4d8df35f6070192928c7e4..bd8c3b5c2cec5fd94c33693b6919b4bf30eb0fcd 100644 (file)
@@ -39,7 +39,7 @@ namespace creaImageIO
        {
        public:
                 /// Ctor
-                 WxSimpleDlg( wxWindow *parent,  
+                 WxSimpleDlg( wxWindow *parent,
                          wxString i_title =_T(""),
                          const std::string i_namedescp = "localdatabase_Descriptor.dscp",   
                          const std::string i_namedb   = "Local Database"     
@@ -75,6 +75,7 @@ namespace creaImageIO
                   std::vector<creaImageIO::OutStrGimmick> getMapInfos(){return m_resultsInfo;}
 
        private:
+        wxFrame*                                            m_parentFrame;
                bool                                                                                            bInfo;
                std::string                                                                             namedescp; 
                std::string                                                                             namedb;