]> Creatis software - bbtk.git/blob - packages/wx/src/bbwxSplit.cxx
Recreated the complete cvs tree because the project architecture deeply changed
[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:02:00 $
7   Version:   $Revision: 1.1.1.1 $
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     bbtkDebugMessageInc("Core",9,"Split::Process()"<<std::endl);
114
115     if (bbGetOutputWidget()==0) 
116       {
117         
118         
119         wxSplitterWindow* w = new wxSplitterWindow(bbGetWxParent(),
120                                                    -1,
121                                                    wxDefaultPosition,
122                                                    wxDefaultSize, 
123                                                    //wxSize(400,200),
124                                                    wxSP_3D | 
125                                                    wxSP_LIVE_UPDATE );
126         wxWindow* w1 = bbGetInputWidget1();
127         wxWindow* w2 = bbGetInputWidget2();
128         //w->SetInitialSize(wxSize(100,100));
129         //    int sz =  (int)(GetParent()->GetSize().GetHeight() * prop * 0.01);
130         w1->Reparent(w);
131         w2->Reparent(w);
132         w->SplitHorizontally( w1, w2, 100);
133         //w->SetMinimumPaneSize(100);
134         // w->SetAutoLayout(true);
135         // w->Fit();
136         // w->Layout();
137         
138
139         bbSetOutputWidget( w );
140       }
141   }
142   
143   
144   /**
145    * \brief  Create wxWidget . 
146    *
147    *
148    */ 
149   /*
150   bbtk::WxBlackBoxWidget *Split::bbUserCreateWidget(wxWindow *parent)
151   {
152     //printf("EED Split::CreateWxWindow \n" );
153     bbtkDebugMessageInc("Core",9,"Split::bbUserCreateWidget("<<parent<<")"<<std::endl);
154     
155     SplitWidget *wxwidgetsplit = new SplitWidget(this, parent , 
156                                                  bbGetInputOrientation() );
157
158     OutputConnectorMapType::iterator i;
159     for (i=bbGetOutputConnectorMap().begin() ; i!=bbGetOutputConnectorMap().end(); ++i )
160       {
161         if (i->first=="WinChild")
162           {
163             const std::vector<bbtk::Connection*>& C = i->second->GetConnectionVector();
164             std::vector<bbtk::Connection*>::const_iterator j;
165             j = C.begin();
166             if (C.size()==2)
167               {
168                 wxPanel *w1 = new wxPanel(wxwidgetsplit->GetWxSplitterWindow() ,-1 );
169                 wxPanel *w2 = new wxPanel(wxwidgetsplit->GetWxSplitterWindow() ,-1 );
170                 bbtkDebugMessage("Debug",1,"Creating panel for "<<(*j)->GetFullName());
171                 bbmOutputWinChild->AddToConnectionToWindowMap(*j,w1);
172                 bbtkDebugMessage("Debug",1,"..OK"<<std::endl);
173                 j++;
174                 bbtkDebugMessage("Debug",1,"Creating panel for "<<(*j)->GetFullName());
175                 bbmOutputWinChild->AddToConnectionToWindowMap(*j,w2);
176
177                 bbtkDebugMessage("Debug",1,"..OK"<<std::endl);
178                 wxwidgetsplit->SetChilds( w1 , w2, bbGetInputProportion() );
179               } // if C
180             break;
181           }// if Child
182       }// if i
183     //
184     
185
186     bbtkDebugDecTab("Core",9);
187
188     return wxwidgetsplit;
189
190       }
191   */
192
193 }//namespace bbtk
194
195 #endif // _USE_WXWIDGETS_ 
196