fw4spl
ToolboxLayoutManagerBase.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 "fwGui/layoutManager/ToolboxLayoutManagerBase.hpp"
14 
15 #include <fwCore/base.hpp>
16 
17 #include <boost/lexical_cast.hpp>
18 
19 
20 namespace fwGui
21 {
22 
23 namespace layoutManager
24 {
25 //-----------------------------------------------------------------------------
26 
27 const ToolboxLayoutManagerBase::RegistryKeyType ToolboxLayoutManagerBase::REGISTRY_KEY =
28  "::fwGui::ToolboxLayoutManager";
29 
30 //-----------------------------------------------------------------------------
31 
33 {
34 }
35 
36 //-----------------------------------------------------------------------------
37 
39 {
40 }
41 
42 //-----------------------------------------------------------------------------
43 
44 void ToolboxLayoutManagerBase::initialize( ConfigurationType configuration)
45 {
46  OSLM_ASSERT("Bad configuration name "<<configuration->getName()<< ", must be layout",
47  configuration->getName() == "layout");
48  m_views.clear();
49  for (ConfigurationType view : configuration->getElements())
50  {
51  if( view->getName() == "view" )
52  {
53  ViewInfo vi;
54  if( view->hasAttribute("border") )
55  {
56  std::string border = view->getExistingAttributeValue("border");
57  vi.m_border = ::boost::lexical_cast< int >(border);
58  }
59  if( view->hasAttribute("caption") )
60  {
61  vi.m_caption = view->getExistingAttributeValue("caption");
62  }
63  if( view->hasAttribute("minWidth") )
64  {
65  std::string width = view->getExistingAttributeValue("minWidth");
66  vi.m_minSize.first = ::boost::lexical_cast< int >(width);
67  }
68  if( view->hasAttribute("minHeight") )
69  {
70  std::string height = view->getExistingAttributeValue("minHeight");
71  vi.m_minSize.second = ::boost::lexical_cast< int >(height);
72  }
73  if( view->hasAttribute("visible") )
74  {
75  std::string visible = view->getExistingAttributeValue("visible");
76  OSLM_ASSERT("Incorrect value for \"visible\" attribute "<<visible,
77  (visible == "true") || (visible == "false") ||
78  (visible == "yes") || (visible == "no"));
79  vi.m_visible = ((visible == "true") || (visible == "yes"));
80  }
81  if( view->hasAttribute("expanded") )
82  {
83  std::string expanded = view->getExistingAttributeValue("expanded");
84  OSLM_ASSERT("Incorrect value for \"expanded\" attribute "<<expanded,
85  (expanded == "true") || (expanded == "false") ||
86  (expanded == "yes") || (expanded == "no"));
87  vi.m_expanded = ((expanded == "true") || (expanded == "yes"));
88  }
89  if( view->hasAttribute("useScrollBar") )
90  {
91  std::string useScrollBar = view->getExistingAttributeValue("useScrollBar");
92  OSLM_ASSERT("Incorrect value for \"useScrollBar\" attribute "<<useScrollBar,
93  (useScrollBar == "yes") || (useScrollBar == "no"));
94  vi.m_useScrollBar = (useScrollBar=="yes");
95  }
96  m_views.push_back(vi);
97  }
98  }
99 }
100 
101 //-----------------------------------------------------------------------------
102 
103 } // namespace layoutManager
104 } // namespace fwGui
105 
106 
107 
#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 ToolboxLayoutManagerBase()
Constructor. Do nothing.
virtual FWGUI_API void initialize(ConfigurationType configuration) override
Initialize Line layout manager before the creation of layout.
virtual FWGUI_API ~ToolboxLayoutManagerBase()
Destructor. Do nothing.