diff Framework/Widgets/LayoutWidget.cpp @ 61:ca644004d2ee wasm

MAJOR - removal of Start/Stop and observers in IWidget
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 May 2017 17:55:13 +0200
parents f0f354a97581
children 2eca030792aa
line wrap: on
line diff
--- a/Framework/Widgets/LayoutWidget.cpp	Wed May 10 16:10:47 2017 +0200
+++ b/Framework/Widgets/LayoutWidget.cpp	Wed May 10 17:55:13 2017 +0200
@@ -269,7 +269,6 @@
 
   LayoutWidget::LayoutWidget() :
     isHorizontal_(true),
-    started_(false),
     width_(0),
     height_(0),
     paddingLeft_(0),
@@ -285,12 +284,20 @@
   {
     for (size_t i = 0; i < children_.size(); i++)
     {
-      children_[i]->GetWidget().Unregister(*this);
       delete children_[i];
     }
   }
 
 
+  void LayoutWidget::SetDefaultView()
+  {
+    for (size_t i = 0; i < children_.size(); i++)
+    {
+      children_[i]->GetWidget().SetDefaultView();
+    }
+  }
+  
+
   void LayoutWidget::NotifyChange(const IWidget& widget)
   {
     // One of the children has changed
@@ -338,12 +345,6 @@
 
   IWidget& LayoutWidget::AddWidget(IWidget* widget)  // Takes ownership
   {
-    if (started_)
-    {
-      LOG(ERROR) << "Cannot add child once Start() has been invoked";
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
-    }
-
     if (widget == NULL)
     {
       throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
@@ -353,13 +354,9 @@
     {
       widget->SetStatusBar(*GetStatusBar());
     }
-    else
-    {
-      widget->ResetStatusBar();
-    }
 
     children_.push_back(new ChildWidget(widget));
-    widget->Register(*this);
+    widget->SetParent(*this);
 
     ComputeChildrenExtents();
 
@@ -383,39 +380,6 @@
   }
 
 
-  void LayoutWidget::ResetStatusBar()
-  {
-    WidgetBase::ResetStatusBar();
-
-    for (size_t i = 0; i < children_.size(); i++)
-    {
-      children_[i]->GetWidget().ResetStatusBar();
-    }
-  }  
-
-
-  void LayoutWidget::Start()
-  {
-    for (size_t i = 0; i < children_.size(); i++)
-    {
-      children_[i]->GetWidget().Start();
-    }
-
-    WidgetBase::Start();
-  }
-
-
-  void LayoutWidget::Stop()
-  {
-    WidgetBase::Stop();
-
-    for (size_t i = 0; i < children_.size(); i++)
-    {
-      children_[i]->GetWidget().Stop();
-    }
-  }
-
-
   void LayoutWidget::SetSize(unsigned int width,
                              unsigned int height)
   {