Mercurial > hg > orthanc-stone
comparison 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 |
comparison
equal
deleted
inserted
replaced
60:288c948199e5 | 61:ca644004d2ee |
---|---|
267 } | 267 } |
268 | 268 |
269 | 269 |
270 LayoutWidget::LayoutWidget() : | 270 LayoutWidget::LayoutWidget() : |
271 isHorizontal_(true), | 271 isHorizontal_(true), |
272 started_(false), | |
273 width_(0), | 272 width_(0), |
274 height_(0), | 273 height_(0), |
275 paddingLeft_(0), | 274 paddingLeft_(0), |
276 paddingTop_(0), | 275 paddingTop_(0), |
277 paddingRight_(0), | 276 paddingRight_(0), |
283 | 282 |
284 LayoutWidget::~LayoutWidget() | 283 LayoutWidget::~LayoutWidget() |
285 { | 284 { |
286 for (size_t i = 0; i < children_.size(); i++) | 285 for (size_t i = 0; i < children_.size(); i++) |
287 { | 286 { |
288 children_[i]->GetWidget().Unregister(*this); | |
289 delete children_[i]; | 287 delete children_[i]; |
290 } | 288 } |
291 } | 289 } |
292 | 290 |
291 | |
292 void LayoutWidget::SetDefaultView() | |
293 { | |
294 for (size_t i = 0; i < children_.size(); i++) | |
295 { | |
296 children_[i]->GetWidget().SetDefaultView(); | |
297 } | |
298 } | |
299 | |
293 | 300 |
294 void LayoutWidget::NotifyChange(const IWidget& widget) | 301 void LayoutWidget::NotifyChange(const IWidget& widget) |
295 { | 302 { |
296 // One of the children has changed | 303 // One of the children has changed |
297 WidgetBase::NotifyChange(); | 304 WidgetBase::NotifyChange(); |
336 } | 343 } |
337 | 344 |
338 | 345 |
339 IWidget& LayoutWidget::AddWidget(IWidget* widget) // Takes ownership | 346 IWidget& LayoutWidget::AddWidget(IWidget* widget) // Takes ownership |
340 { | 347 { |
341 if (started_) | |
342 { | |
343 LOG(ERROR) << "Cannot add child once Start() has been invoked"; | |
344 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
345 } | |
346 | |
347 if (widget == NULL) | 348 if (widget == NULL) |
348 { | 349 { |
349 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 350 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
350 } | 351 } |
351 | 352 |
352 if (GetStatusBar() != NULL) | 353 if (GetStatusBar() != NULL) |
353 { | 354 { |
354 widget->SetStatusBar(*GetStatusBar()); | 355 widget->SetStatusBar(*GetStatusBar()); |
355 } | 356 } |
356 else | |
357 { | |
358 widget->ResetStatusBar(); | |
359 } | |
360 | 357 |
361 children_.push_back(new ChildWidget(widget)); | 358 children_.push_back(new ChildWidget(widget)); |
362 widget->Register(*this); | 359 widget->SetParent(*this); |
363 | 360 |
364 ComputeChildrenExtents(); | 361 ComputeChildrenExtents(); |
365 | 362 |
366 if (widget->HasUpdateContent()) | 363 if (widget->HasUpdateContent()) |
367 { | 364 { |
377 WidgetBase::SetStatusBar(statusBar); | 374 WidgetBase::SetStatusBar(statusBar); |
378 | 375 |
379 for (size_t i = 0; i < children_.size(); i++) | 376 for (size_t i = 0; i < children_.size(); i++) |
380 { | 377 { |
381 children_[i]->GetWidget().SetStatusBar(statusBar); | 378 children_[i]->GetWidget().SetStatusBar(statusBar); |
382 } | |
383 } | |
384 | |
385 | |
386 void LayoutWidget::ResetStatusBar() | |
387 { | |
388 WidgetBase::ResetStatusBar(); | |
389 | |
390 for (size_t i = 0; i < children_.size(); i++) | |
391 { | |
392 children_[i]->GetWidget().ResetStatusBar(); | |
393 } | |
394 } | |
395 | |
396 | |
397 void LayoutWidget::Start() | |
398 { | |
399 for (size_t i = 0; i < children_.size(); i++) | |
400 { | |
401 children_[i]->GetWidget().Start(); | |
402 } | |
403 | |
404 WidgetBase::Start(); | |
405 } | |
406 | |
407 | |
408 void LayoutWidget::Stop() | |
409 { | |
410 WidgetBase::Stop(); | |
411 | |
412 for (size_t i = 0; i < children_.size(); i++) | |
413 { | |
414 children_[i]->GetWidget().Stop(); | |
415 } | 379 } |
416 } | 380 } |
417 | 381 |
418 | 382 |
419 void LayoutWidget::SetSize(unsigned int width, | 383 void LayoutWidget::SetSize(unsigned int width, |