comparison Framework/Widgets/LayoutWidget.cpp @ 53:c2dc924f1a63 wasm

removing threading out of the framework
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 27 Apr 2017 16:57:49 +0200
parents 25befef48c35
children 01aa453d4d5b
comparison
equal deleted inserted replaced
52:37e504582af6 53:c2dc924f1a63
80 std::auto_ptr<IWidget> widget_; 80 std::auto_ptr<IWidget> widget_;
81 int left_; 81 int left_;
82 int top_; 82 int top_;
83 unsigned int width_; 83 unsigned int width_;
84 unsigned int height_; 84 unsigned int height_;
85 bool hasUpdate_;
85 86
86 public: 87 public:
87 ChildWidget(IWidget* widget) : 88 ChildWidget(IWidget* widget) :
88 widget_(widget) 89 widget_(widget),
90 hasUpdate_(widget->HasUpdateContent())
89 { 91 {
90 assert(widget != NULL); 92 assert(widget != NULL);
91 SetEmpty(); 93 SetEmpty();
94 }
95
96 void UpdateContent()
97 {
98 if (hasUpdate_)
99 {
100 widget_->UpdateContent();
101 }
92 } 102 }
93 103
94 IWidget& GetWidget() const 104 IWidget& GetWidget() const
95 { 105 {
96 return *widget_; 106 return *widget_;
346 children_.push_back(new ChildWidget(widget)); 356 children_.push_back(new ChildWidget(widget));
347 widget->Register(*this); 357 widget->Register(*this);
348 358
349 ComputeChildrenExtents(); 359 ComputeChildrenExtents();
350 360
361 if (widget->HasUpdateContent())
362 {
363 hasUpdateContent_ = true;
364 }
365
351 return *widget; 366 return *widget;
352 } 367 }
353 368
354 369
355 void LayoutWidget::SetStatusBar(IStatusBar& statusBar) 370 void LayoutWidget::SetStatusBar(IStatusBar& statusBar)
471 for (size_t i = 0; i < children_.size(); i++) 486 for (size_t i = 0; i < children_.size(); i++)
472 { 487 {
473 children_[i]->GetWidget().KeyPressed(key, modifiers); 488 children_[i]->GetWidget().KeyPressed(key, modifiers);
474 } 489 }
475 } 490 }
491
492
493 void LayoutWidget::UpdateContent()
494 {
495 if (hasUpdateContent_)
496 {
497 for (size_t i = 0; i < children_.size(); i++)
498 {
499 children_[i]->UpdateContent();
500 }
501 }
502 else
503 {
504 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
505 }
506 }
476 } 507 }