]> Creatis software - bbtk.git/blob - packages/wx/src/bbwxSplit.cxx
*** empty log message ***
[bbtk.git] / packages / wx / src / bbwxSplit.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbwxSplit.cxx,v $
5   Language:  C++
6   Date:      $Date: 2008/01/22 15:41:35 $
7   Version:   $Revision: 1.2 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18 /**
19  *  \file 
20  *  \brief 
21  */
22
23
24 #ifdef _USE_WXWIDGETS_
25
26 #include "bbwxSplit.h"
27 #include "bbwxPackage.h"
28
29 //#include "bbtk
30
31 namespace bbwx
32 {
33   BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,Split);
34   /*
35   //-------------------------------------------------------------------------
36   SplitWidget::SplitWidget(Split* box,
37                            wxWindow *parent,
38                            int orientation)
39     :
40     WxBlackBoxWidgetPanel(box,parent), 
41     mOrientation(orientation)
42     //( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
43   {
44     wxPanel     *panel                  = this->GetPanel();
45     mwxSplitterWindow           = new wxSplitterWindow(panel,-1,
46                                                        wxDefaultPosition,
47                                                        wxDefaultSize, 
48                                                        wxSP_3D | 
49                                                        wxSP_LIVE_UPDATE );
50     
51     wxBoxSizer *sizer           = new wxBoxSizer(wxVERTICAL);
52     sizer       ->      Add(mwxSplitterWindow, 1, wxGROW, 0);
53 #if defined(_WIN32)
54  //mwxSplitterWindow -> SetMinimumPaneSize(25);
55 #else
56    mwxSplitterWindow -> SetMinimumPaneSize(25);
57 #endif // defined(_WIN32) 
58
59     panel       ->      SetSizer(sizer);
60     panel       ->      SetAutoLayout(true);
61     panel       ->      Layout();
62   }
63   //-------------------------------------------------------------------------
64
65   //-------------------------------------------------------------------------
66   void  SplitWidget::SetChilds(wxWindow* child1,wxWindow* child2,
67                                  int prop)
68   {
69     if (mwxSplitterWindow->IsSplit()) return;
70     if (mOrientation==0)
71       {
72         int sz =  (int)(GetParent()->GetSize().GetHeight() * prop * 0.01);
73         mwxSplitterWindow->SplitHorizontally( child1 , child2, sz);
74       } 
75     else 
76       {
77         int sz =  (int)(GetParent()->GetSize().GetWidth() * prop * 0.01);
78         mwxSplitterWindow->SplitVertically( child1 , child2, sz );
79       }
80
81
82   }
83   
84   SplitWidget::~SplitWidget()
85   {
86   }
87   
88
89   //-------------------------------------------------------------------------
90   wxSplitterWindow *SplitWidget::GetWxSplitterWindow()
91   {
92     return mwxSplitterWindow;
93   }
94   
95   */
96   //--------------------------------------------------------------------------
97   //-------------------------------------------------------------------------
98   //--------------------------------------------------------------------------
99   //--------------------------------------------------------------------------
100
101
102   BBTK_USER_BLACK_BOX_IMPLEMENTATION(Split,bbtk::WxBlackBox);
103   
104
105   void Split::bbUserConstructor() 
106   { 
107     bbSetInputOrientation(0);
108     bbSetInputProportion(50);
109   }
110
111   void Split::Process() 
112   { 
113   }
114
115   void Split::CreateWidget() 
116   { 
117     wxSplitterWindow* w = new wxSplitterWindow(bbGetWxParent(),
118                                                -1,
119                                                wxDefaultPosition,
120                                                wxDefaultSize, 
121                                                //wxSize(400,200),
122                                                wxSP_3D | 
123                                                wxSP_LIVE_UPDATE );
124     wxWindow* w1 = bbGetInputWidget1();
125     wxWindow* w2 = bbGetInputWidget2();
126     //w->SetInitialSize(wxSize(100,100));
127     //    int sz =  (int)(GetParent()->GetSize().GetHeight() * prop * 0.01);
128     w1->Reparent(w);
129     w2->Reparent(w);
130     w->SplitHorizontally( w1, w2, 100);
131     //w->SetMinimumPaneSize(100);
132     // w->SetAutoLayout(true);
133     // w->Fit();
134     // w->Layout();
135     
136     
137     bbSetOutputWidget( w );
138   }
139   
140   
141   /**
142    * \brief  Create wxWidget . 
143    *
144    *
145    */ 
146   /*
147   bbtk::WxBlackBoxWidget *Split::bbUserCreateWidget(wxWindow *parent)
148   {
149     //printf("EED Split::CreateWxWindow \n" );
150     bbtkDebugMessageInc("Core",9,"Split::bbUserCreateWidget("<<parent<<")"<<std::endl);
151     
152     SplitWidget *wxwidgetsplit = new SplitWidget(this, parent , 
153                                                  bbGetInputOrientation() );
154
155     OutputConnectorMapType::iterator i;
156     for (i=bbGetOutputConnectorMap().begin() ; i!=bbGetOutputConnectorMap().end(); ++i )
157       {
158         if (i->first=="WinChild")
159           {
160             const std::vector<bbtk::Connection*>& C = i->second->GetConnectionVector();
161             std::vector<bbtk::Connection*>::const_iterator j;
162             j = C.begin();
163             if (C.size()==2)
164               {
165                 wxPanel *w1 = new wxPanel(wxwidgetsplit->GetWxSplitterWindow() ,-1 );
166                 wxPanel *w2 = new wxPanel(wxwidgetsplit->GetWxSplitterWindow() ,-1 );
167                 bbtkDebugMessage("Debug",1,"Creating panel for "<<(*j)->GetFullName());
168                 bbmOutputWinChild->AddToConnectionToWindowMap(*j,w1);
169                 bbtkDebugMessage("Debug",1,"..OK"<<std::endl);
170                 j++;
171                 bbtkDebugMessage("Debug",1,"Creating panel for "<<(*j)->GetFullName());
172                 bbmOutputWinChild->AddToConnectionToWindowMap(*j,w2);
173
174                 bbtkDebugMessage("Debug",1,"..OK"<<std::endl);
175                 wxwidgetsplit->SetChilds( w1 , w2, bbGetInputProportion() );
176               } // if C
177             break;
178           }// if Child
179       }// if i
180     //
181     
182
183     bbtkDebugDecTab("Core",9);
184
185     return wxwidgetsplit;
186
187       }
188   */
189
190 }//namespace bbtk
191
192 #endif // _USE_WXWIDGETS_ 
193