]> Creatis software - bbtk.git/blob - packages/wx/src/bbwxLayoutSplit.cxx
#3073 BBTK Bug New Normal - message documentation in boxes
[bbtk.git] / packages / wx / src / bbwxLayoutSplit.cxx
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
6  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9  #
10  #  This software is governed by the CeCILL-B license under French law and
11  #  abiding by the rules of distribution of free software. You can  use,
12  #  modify and/ or redistribute the software under the terms of the CeCILL-B
13  #  license as circulated by CEA, CNRS and INRIA at the following URL
14  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15  #  or in the file LICENSE.txt.
16  #
17  #  As a counterpart to the access to the source code and  rights to copy,
18  #  modify and redistribute granted by the license, users are provided only
19  #  with a limited warranty  and the software's author,  the holder of the
20  #  economic rights,  and the successive licensors  have only  limited
21  #  liability.
22  #
23  #  The fact that you are presently reading this means that you have had
24  #  knowledge of the CeCILL-B license and that you accept its terms.
25  # ------------------------------------------------------------------------ */
26
27
28 /*=========================================================================
29   Program:   bbtk
30   Module:    $RCSfile: bbwxLayoutSplit.cxx,v $
31   Language:  C++
32   Date:      $Date: 2012/11/16 08:52:14 $
33   Version:   $Revision: 1.14 $
34 =========================================================================*/
35
36 /**
37  *  \file
38  *  \brief
39  */
40
41
42 #ifdef _USE_WXWIDGETS_
43
44 #include "bbwxLayoutSplit.h"
45 #include "bbwxPackage.h"
46 #include "bbtkUtilities.h"
47
48
49 namespace bbwx
50 {
51   BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,LayoutSplit);
52   BBTK_BLACK_BOX_IMPLEMENTATION(LayoutSplit,bbtk::WxBlackBox);
53
54         //-----------------------------------------------------------------     
55         void LayoutSplit::bbUserSetDefaultValues()
56         {
57                 bbSetInputOrientation("VERTICAL");
58                 bbSetInputProportion(50);
59                 bbSetInputWidget1(NULL);
60                 bbSetInputWidget2(NULL);                
61         }
62         
63         //-----------------------------------------------------------------     
64         void LayoutSplit::bbUserInitializeProcessing()
65         {
66         }
67         
68         //-----------------------------------------------------------------     
69         void LayoutSplit::bbUserFinalizeProcessing()
70         {
71         }       
72         
73         void LayoutSplit::Process()
74         {
75                 PutWinTitle();
76         }
77
78   void LayoutSplit::CreateWidget(wxWindow* parent)
79   {
80     wxSplitterWindow* w = new wxSplitterWindow(parent, //bbGetWxParent(),
81                                                -1,
82                                                wxDefaultPosition,
83                                                wxDefaultSize,
84                                                //wxSize(400,200),
85                                                wxSP_3D |
86                                                wxSP_LIVE_UPDATE );
87     w->SetName( bbtk::std2wx( bbGetInputWinTitle() ) );
88         w->SetMinimumPaneSize(2);
89         //RaC Nov2012 Correctly resize internal panels with the window resize event
90         w->SetSashGravity(0.5);
91 /*
92           wxWindow* w1 = bbGetInputWidget1();
93     wxWindow* w2 = bbGetInputWidget2();
94
95     if (w1==NULL) { w1=new wxPanel(bbGetWxParent()); }
96     if (w2==NULL) { w2=new wxPanel(bbGetWxParent()); }
97     w1->Reparent(w);
98     w2->Reparent(w);
99  */ 
100
101           wxWindow* w1 = bbCreateWidgetOfInput("Widget1",w);
102           wxWindow* w2 = bbCreateWidgetOfInput("Widget2",w);
103           if (w1==NULL) { w1=new wxPanel(parent); }
104           if (w2==NULL) { w2=new wxPanel(parent); }
105           
106           int orientation=0;
107     if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"0|H|HORIZONTAL")==true)  { orientation=0; }
108     if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|V|VERTICAL")==true)    { orientation=1; }
109     
110
111     if (orientation==1) { w->SplitHorizontally( w1, w2, 100); }
112     else                { w->SplitVertically( w1, w2, 100);   }
113   
114     bbSetOutputWidget( w );
115   }
116
117
118   // This callback is necessary to get actual processing of the view 
119   // when window is shown
120   void  LayoutSplit::OnShowWidget()
121   {
122     //    std::cout << "LayoutSplit::OnShowWidget()" << std::endl;
123     if (bbGetOutputWidget()==0)
124       {
125         return;
126         //bbtkError("LayoutSplit::OnShowWidget() : Output Widget == 0 !");
127       }
128     wxSplitterWindow* win = (wxSplitterWindow*)bbGetOutputWidget();
129     int w,h;
130     if (win==0)
131       {
132         return;
133         //      bbtkError("LayoutSplit::OnShowWidget() : win == 0 !");
134       }
135     win->GetClientSize(&w,&h);
136     int pos = 100;
137     if (bbtk::Utilities::loosematch(bbGetInputOrientation(),
138                                     "0|H|HORIZONTAL")==true)  
139       { 
140         pos = (int)(w * bbGetInputProportion() * 0.01);
141       }
142     else 
143       {
144         pos = (int)(h * bbGetInputProportion() * 0.01);
145       } 
146     //    std::cout << "pos = "<<pos<<std::endl;
147   
148     win->SetSashPosition(pos,true);
149     //RaC Nov2012 Correctly resize internal panels with the window resize event
150     win->SetSashGravity(0.5);
151
152   }
153
154
155
156 }//namespace bbwx
157
158 #endif // _USE_WXWIDGETS_
159