]> Creatis software - bbtk.git/blobdiff - packages/wx/src/bbwxSplit.cxx
cosmetics
[bbtk.git] / packages / wx / src / bbwxSplit.cxx
index bf8dbeae286930856caa60ad0d8cdfcb1a140443..0b5a71f41ae4158db41f0c49bac2d856a3572fbe 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxSplit.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/05 13:23:47 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2008/02/14 20:55:52 $
+  Version:   $Revision: 1.7 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -16,8 +16,8 @@
                                                                                 
 =========================================================================*/
 /**
- *  \file 
- *  \brief 
+ *  \file
+ *  \brief
  */
 
 
 
 #include "bbwxSplit.h"
 #include "bbwxPackage.h"
+#include "bbtkUtilities.h"
 
-//#include "bbtk
 
 namespace bbwx
 {
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,Split);
-  /*
-  //-------------------------------------------------------------------------
-  SplitWidget::SplitWidget(Split* box,
-                          wxWindow *parent,
-                          int orientation)
-    :
-    WxBlackBoxWidgetPanel(box,parent), 
-    mOrientation(orientation)
-    //( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
-  {
-    wxPanel    *panel                  = this->GetPanel();
-    mwxSplitterWindow          = new wxSplitterWindow(panel,-1,
-                                                      wxDefaultPosition,
-                                                      wxDefaultSize, 
-                                                      wxSP_3D | 
-                                                      wxSP_LIVE_UPDATE );
-    
-    wxBoxSizer *sizer          = new wxBoxSizer(wxVERTICAL);
-    sizer      ->      Add(mwxSplitterWindow, 1, wxGROW, 0);
-#if defined(_WIN32)
- //mwxSplitterWindow -> SetMinimumPaneSize(25);
-#else
-   mwxSplitterWindow -> SetMinimumPaneSize(25);
-#endif // defined(_WIN32) 
-
-    panel      ->      SetSizer(sizer);
-    panel      ->      SetAutoLayout(true);
-    panel      ->      Layout();
-  }
-  //-------------------------------------------------------------------------
-
-  //-------------------------------------------------------------------------
-  void  SplitWidget::SetChilds(wxWindow* child1,wxWindow* child2,
-                                int prop)
-  {
-    if (mwxSplitterWindow->IsSplit()) return;
-    if (mOrientation==0)
-      {
-       int sz =  (int)(GetParent()->GetSize().GetHeight() * prop * 0.01);
-       mwxSplitterWindow->SplitHorizontally( child1 , child2, sz);
-      } 
-    else 
-      {
-       int sz =  (int)(GetParent()->GetSize().GetWidth() * prop * 0.01);
-       mwxSplitterWindow->SplitVertically( child1 , child2, sz );
-      }
-
-
-  }
-  
-  SplitWidget::~SplitWidget()
-  {
-  }
-  
-
-  //-------------------------------------------------------------------------
-  wxSplitterWindow *SplitWidget::GetWxSplitterWindow()
-  {
-    return mwxSplitterWindow;
-  }
-  
-  */
-  //--------------------------------------------------------------------------
-  //-------------------------------------------------------------------------
-  //--------------------------------------------------------------------------
-  //--------------------------------------------------------------------------
-
-
   BBTK_USER_BLACK_BOX_IMPLEMENTATION(Split,bbtk::WxBlackBox);
-  
 
-  void Split::bbUserConstructor() 
-  { 
-    bbSetInputOrientation(0);
+  void Split::bbUserConstructor()
+  {
+       bbSetInputWinTitle("Split");
+    bbSetInputOrientation("HORIZONTAL");
     bbSetInputProportion(50);
+    bbSetInputWidget1(NULL);
+    bbSetInputWidget2(NULL);
   }
 
-  void Split::Process() 
-  { 
+  void Split::Process()
+  {
   }
 
-  void Split::CreateWidget() 
-  { 
+  void Split::CreateWidget()
+  {
     wxSplitterWindow* w = new wxSplitterWindow(bbGetWxParent(),
                                               -1,
                                               wxDefaultPosition,
-                                              wxDefaultSize, 
+                                              wxDefaultSize,
                                               //wxSize(400,200),
-                                              wxSP_3D | 
+                                              wxSP_3D |
                                               wxSP_LIVE_UPDATE );
+       w->SetName( bbtk::std2wx( bbGetInputWinTitle() ) );
     wxWindow* w1 = bbGetInputWidget1();
     wxWindow* w2 = bbGetInputWidget2();
-    //w->SetInitialSize(wxSize(100,100));
-    //    int sz =  (int)(GetParent()->GetSize().GetHeight() * prop * 0.01);
+
+    if (w1==NULL) { w1=new wxPanel(bbGetWxParent()); }
+    if (w2==NULL) { w2=new wxPanel(bbGetWxParent()); }
     w1->Reparent(w);
     w2->Reparent(w);
-    w->SplitHorizontally( w1, w2, 100);
-    //w->SetMinimumPaneSize(100);
-    // w->SetAutoLayout(true);
-    // w->Fit();
-    // w->Layout();
-    
-    
-    bbSetOutputWidget( w );
-  }
-  
-  
-  /**
-   * \brief  Create wxWidget . 
-   *
-   *
-   */ 
-  /*
-  bbtk::WxBlackBoxWidget *Split::bbUserCreateWidget(wxWindow *parent)
-  {
-    //printf("EED Split::CreateWxWindow \n" );
-    bbtkDebugMessageInc("Kernel",9,"Split::bbUserCreateWidget("<<parent<<")"<<std::endl);
-    
-    SplitWidget *wxwidgetsplit = new SplitWidget(this, parent , 
-                                                bbGetInputOrientation() );
-
-    OutputConnectorMapType::iterator i;
-    for (i=bbGetOutputConnectorMap().begin() ; i!=bbGetOutputConnectorMap().end(); ++i )
-      {
-       if (i->first=="WinChild")
-         {
-           const std::vector<bbtk::Connection*>& C = i->second->GetConnectionVector();
-           std::vector<bbtk::Connection*>::const_iterator j;
-           j = C.begin();
-           if (C.size()==2)
-             {
-               wxPanel *w1 = new wxPanel(wxwidgetsplit->GetWxSplitterWindow() ,-1 );
-               wxPanel *w2 = new wxPanel(wxwidgetsplit->GetWxSplitterWindow() ,-1 );
-               bbtkDebugMessage("Debug",1,"Creating panel for "<<(*j)->GetFullName());
-               bbmOutputWinChild->AddToConnectionToWindowMap(*j,w1);
-               bbtkDebugMessage("Debug",1,"..OK"<<std::endl);
-               j++;
-               bbtkDebugMessage("Debug",1,"Creating panel for "<<(*j)->GetFullName());
-               bbmOutputWinChild->AddToConnectionToWindowMap(*j,w2);
-
-               bbtkDebugMessage("Debug",1,"..OK"<<std::endl);
-               wxwidgetsplit->SetChilds( w1 , w2, bbGetInputProportion() );
-             } // if C
-           break;
-         }// if Child
-      }// if i
-    //
-    
+    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; }
 
-    bbtkDebugDecTab("Kernel",9);
+       if (orientation==0) { w->SplitHorizontally( w1, w2, 100); }
+       else                { w->SplitVertically( w1, w2, 100);   }
 
-    return wxwidgetsplit;
-
-      }
-  */
+    bbSetOutputWidget( w );
+  }
 
-}//namespace bbtk
+}//namespace bbwx
 
-#endif // _USE_WXWIDGETS_ 
+#endif // _USE_WXWIDGETS_