fw4spl
LineLayoutManagerBase.cpp
Go to the documentation of this file.
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
13 #include <boost/lexical_cast.hpp>
14 
15 #include <fwCore/base.hpp>
16 
17 #include "fwGui/layoutManager/LineLayoutManagerBase.hpp"
18 
19 namespace fwGui
20 {
21 
22 namespace layoutManager
23 {
24 //-----------------------------------------------------------------------------
25 
26 const LineLayoutManagerBase::RegistryKeyType LineLayoutManagerBase::REGISTRY_KEY = "::fwGui::LineLayoutManager";
27 
28 //-----------------------------------------------------------------------------
29 
31 {
32 }
33 
34 //-----------------------------------------------------------------------------
35 
37 {
38 }
39 
40 //-----------------------------------------------------------------------------
41 
42 void LineLayoutManagerBase::initialize( ConfigurationType configuration)
43 {
44  OSLM_ASSERT("Bad configuration name "<<configuration->getName()<< ", must be layout",
45  configuration->getName() == "layout");
46 
47  std::vector < ConfigurationType > vectOrientation = configuration->find("orientation");
48 
49  SLM_FATAL_IF( "missing orientation configuration", vectOrientation.empty() );
50  SLM_ASSERT("<orientation> tag must have value attribute", vectOrientation.at(0)->hasAttribute("value"));
51  std::string orientation = vectOrientation.at(0)->getExistingAttributeValue("value");
52  SLM_ASSERT("Wrong value '"<< orientation <<"' for 'orientation' attribute (require vertical or horizontal)",
53  orientation == "vertical" || orientation == "horizontal");
54  m_orientation = (orientation == "vertical") ? VERTICAL : HORIZONTAL;
55 
56  m_views.clear();
57  for (ConfigurationType view : configuration->getElements())
58  {
59  if( view->getName() == "spacer" )
60  {
61  ViewInfo vi;
62  vi.m_isSpacer = true;
63  m_views.push_back(vi);
64  }
65  else if( view->getName() == "view" )
66  {
67  ViewInfo vi;
68  if( view->hasAttribute("proportion") )
69  {
70  std::string proportion = view->getExistingAttributeValue("proportion");
71  vi.m_proportion = ::boost::lexical_cast< int >(proportion);
72  }
73  if( view->hasAttribute("border") )
74  {
75  std::string border = view->getExistingAttributeValue("border");
76  vi.m_border = ::boost::lexical_cast< int >(border);
77  }
78  if( view->hasAttribute("caption") )
79  {
80  vi.m_caption.first = true;
81  vi.m_caption.second = view->getExistingAttributeValue("caption");
82  }
83  if( view->hasAttribute("minWidth") )
84  {
85  std::string width = view->getExistingAttributeValue("minWidth");
86  vi.m_minSize.first = ::boost::lexical_cast< int >(width);
87  }
88  if( view->hasAttribute("minHeight") )
89  {
90  std::string height = view->getExistingAttributeValue("minHeight");
91  vi.m_minSize.second = ::boost::lexical_cast< int >(height);
92  }
93  if( view->hasAttribute("visible") )
94  {
95  std::string visible = view->getExistingAttributeValue("visible");
96  OSLM_ASSERT("Incorrect value for \"visible\" attribute "<<visible,
97  (visible == "true") || (visible == "false") ||
98  (visible == "yes") || (visible == "no"));
99  vi.m_visible = ((visible == "true") || (visible == "yes"));
100  }
101  if( view->hasAttribute("useScrollBar") )
102  {
103  std::string useScrollBar = view->getExistingAttributeValue("useScrollBar");
104  OSLM_ASSERT("Incorrect value for \"useScrollBar\" attribute "<<useScrollBar,
105  (useScrollBar == "yes") || (useScrollBar == "no"));
106  vi.m_useScrollBar = (useScrollBar=="yes");
107  }
108  m_views.push_back(vi);
109  }
110  }
111 }
112 
113 //-----------------------------------------------------------------------------
114 
115 } // namespace layoutManager
116 } // namespace fwGui
117 
118 
119 
virtual FWGUI_API ~LineLayoutManagerBase()
Destructor. Do nothing.
#define OSLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:310
The namespace fwGui contains the base interface for IHM services.
Definition: SJobBar.hpp:23
FWGUI_API LineLayoutManagerBase()
Constructor. Do nothing.
#define SLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:308
#define SLM_FATAL_IF(message, cond)
Definition: spyLog.hpp:287
virtual FWGUI_API void initialize(ConfigurationType configuration) override
Initialize Line layout manager before the creation of layout.