Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryStackPresentation.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 BlueBerry Platform
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "berryStackPresentation.h"
18 
19 #include "berryConstants.h"
20 
21 namespace berry
22 {
23 
24 const int StackPresentation::AS_INACTIVE = 0;
27 
28 
30  : site(stackSite)
31 {
32  poco_assert(stackSite.IsNotNull());
33 }
34 
36 {
37  // Do not remove empty destructor. Otherwise, the WeakPointer member "site"
38  // will be destroyed in a strange way and the destruction of a DefaultStackPresentationSite
39  // instance will notify the WeakPointer "site" (although it was destroyed, the
40  // DefaultStackPresentationSite somehow still has a MessageDelegate for the destroy
41  // event, pointing to the destroyed "site").
42 }
43 
45 {
46  return site.Lock();
47 }
48 
50 {
51  return QSize(0, 0);
52 }
53 
55 {
56  bool hasMaximumSize = this->GetSite()->GetState()
57  == IStackPresentationSite::STATE_MINIMIZED;
58 
59  return Constants::MIN | (hasMaximumSize ? Constants::MAX : 0);
60 }
61 
62 int StackPresentation::ComputePreferredSize(bool width, int /*availableParallel*/,
63  int /*availablePerpendicular*/, int preferredResult)
64 {
65  QSize s = this->ComputeMinimumSize();
66  int minSize = width ? s.width() : s.width();
67 
68  if (this->GetSite()->GetState() == IStackPresentationSite::STATE_MINIMIZED
69  || preferredResult < minSize)
70  {
71  return minSize;
72  }
73 
74  return preferredResult;
75 }
76 
78  Object::Pointer cookie)
79 {
80  this->RemovePart(toMove);
81  this->AddPart(toMove, cookie);
82 
83  if (this->GetSite()->GetSelectedPart() == toMove)
84  {
85  this->SelectPart(toMove);
86  toMove->SetFocus();
87  }
88 }
89 
91 {
92 
93 }
94 
96 {
97 
98 }
99 
101 {
102 
103 }
104 
105 }
IStackPresentationSite::Pointer GetSite()
virtual void MovePart(IPresentablePart::Pointer toMove, Object::Pointer cookie)
virtual void RestoreState(IPresentationSerializer *context, IMemento::Pointer memento)
StackPresentation(IStackPresentationSite::Pointer stackSite)
virtual void SaveState(IPresentationSerializer *context, IMemento::Pointer memento)
virtual void SelectPart(IPresentablePart::Pointer toSelect)=0
virtual void RemovePart(IPresentablePart::Pointer oldPart)=0
static const int MAX
static const int MIN
virtual void AddPart(IPresentablePart::Pointer newPart, Object::Pointer cookie)=0
virtual int ComputePreferredSize(bool width, int availableParallel, int availablePerpendicular, int preferredResult) override
virtual int GetSizeFlags(bool width) override