Medical Imaging Interaction Toolkit  2018.04.99-3ec0dd08
Medical Imaging Interaction Toolkit
berry::StackPresentation Class Referenceabstract

#include <berryStackPresentation.h>

Inheritance diagram for berry::StackPresentation:
Collaboration diagram for berry::StackPresentation:

Public Member Functions

 berryObjectMacro (StackPresentation)
virtual void SetBounds (const QRect &bounds)=0
virtual QSize ComputeMinimumSize ()
int GetSizeFlags (bool width) override
int ComputePreferredSize (bool width, int availableParallel, int availablePerpendicular, int preferredResult) override
virtual void SetActive (int newState)=0
virtual void SetVisible (bool isVisible)=0
virtual void SetState (int state)=0
virtual QWidget * GetControl ()=0
virtual void AddPart (IPresentablePart::Pointer newPart, Object::Pointer cookie)=0
virtual void RemovePart (IPresentablePart::Pointer oldPart)=0
virtual void MovePart (IPresentablePart::Pointer toMove, Object::Pointer cookie)
virtual void SelectPart (IPresentablePart::Pointer toSelect)=0
virtual StackDropResult::Pointer DragOver (QWidget *currentControl, const QPoint &location)=0
virtual void ShowPartList ()
virtual void SaveState (IPresentationSerializer *context, IMemento::Pointer memento)
virtual void RestoreState (IPresentationSerializer *context, IMemento::Pointer memento)
virtual QList< QWidget * > GetTabList (IPresentablePart::Pointer part)=0
- Public Member Functions inherited from berry::Object
virtual QString GetClassName () const
virtual Reflection::TypeInfo GetTypeInfo () const
virtual QList< Reflection::TypeInfoGetSuperclasses () const
virtual void Delete ()
QDebug Print (QDebug os, Indent Indent=0) const
virtual QString ToString () const
virtual uint HashCode () const
virtual bool operator< (const Object *) const
void Register () const
void UnRegister (bool del=true) const
int GetReferenceCount () const
void SetReferenceCount (int)
void AddDestroyListener (const MessageAbstractDelegate<> &delegate) const
void RemoveDestroyListener (const MessageAbstractDelegate<> &delegate) const
virtual bool operator== (const Object *) const
- Public Member Functions inherited from berry::ISizeProvider
virtual ~ISizeProvider ()

Static Public Attributes

static const int AS_INACTIVE
static const int AS_ACTIVE_FOCUS
static const int AS_ACTIVE_NOFOCUS
- Static Public Attributes inherited from berry::ISizeProvider
static const int INF

Protected Member Functions

 StackPresentation (IStackPresentationSite::Pointer stackSite)
 ~StackPresentation () override
IStackPresentationSite::Pointer GetSite ()
- Protected Member Functions inherited from berry::Object
 Object ()
virtual ~Object ()
virtual QDebug PrintSelf (QDebug os, Indent indent) const
virtual QDebug PrintHeader (QDebug os, Indent indent) const
virtual QDebug PrintTrailer (QDebug os, Indent indent) const

Additional Inherited Members

- Public Types inherited from berry::Object
typedef Object Self
typedef berry::SmartPointer< SelfPointer
typedef berry::SmartPointer< const SelfConstPointer
typedef berry::WeakPointer< SelfWeakPtr
typedef berry::WeakPointer< const SelfConstWeakPtr
- Static Public Member Functions inherited from berry::Object
static const char * GetStaticClassName ()
static Reflection::TypeInfo GetStaticTypeInfo ()
static QList< Reflection::TypeInfoGetStaticSuperclasses ()
- Protected Attributes inherited from berry::Object
QAtomicInt m_ReferenceCount
QMutex m_ReferenceCountLock

Detailed Description

This represents an object that can supply trim around a IPresentablePart. Clients can implement subclasses to provide the appearance for editor workbooks, view folders, fast views, and detached windows.

StackPresentations do not store any persistent state and cannot directly make changes to the workbench. They are given an IStackPresentationSite reference on creation, which allows them to send events and requests to the workbench. However, the workbench is free to ignore these requests. The workbench will call one of the public methods on StackPresentation when (and if) the presentation is expected to change state.

For example, if the user clicks a button that is intended to close a part, the StackPresentation will send a close request to its site, but should not assume that the part has been closed until the workbench responds with a call StackPresentation.remove.


Definition at line 52 of file berryStackPresentation.h.

Constructor & Destructor Documentation

◆ StackPresentation()

berry::StackPresentation::StackPresentation ( IStackPresentationSite::Pointer  stackSite)

Constructs a new stack presentation with the given site.

stackSitethe stack site

◆ ~StackPresentation()

berry::StackPresentation::~StackPresentation ( )

Member Function Documentation

◆ AddPart()

virtual void berry::StackPresentation::AddPart ( IPresentablePart::Pointer  newPart,
Object::Pointer  cookie 
pure virtual

Adds the given part to the stack. The presentation is free to determine where the part should be inserted. If the part is being inserted as the result of a drag/drop operation, it will be given a cookie identifying the drop location. Has no effect if an identical part is already in the presentation.

newPartthe new part to add (not null)
cookiean identifier for a drop location, or null. When the presentation attaches a cookie to a StackDropResult, that cookie is passed back into addPart when a part is actually dropped in that location.

◆ berryObjectMacro()

berry::StackPresentation::berryObjectMacro ( StackPresentation  )

◆ ComputeMinimumSize()

virtual QSize berry::StackPresentation::ComputeMinimumSize ( )

Returns the minimum size for this stack. The stack is prevented from being resized smaller than this amount, and this is used as the default size for the stack when it is minimized. Typically, this is the amount of space required to fit the minimize, close, and maximize buttons and one tab.

the minimum size for this stack (not null)
replaced by computePreferredSize

◆ ComputePreferredSize()

int berry::StackPresentation::ComputePreferredSize ( bool  width,
int  availableParallel,
int  availablePerpendicular,
int  preferredResult 

Returns the best size for this part, given the available width and height and the workbench's preferred size for the part. Parts can overload this to enforce a minimum size, maximum size, or a quantized set of preferred sizes. If width == true, this method computes a width in pixels. If width == false, this method computes a height. availableParallel and availablePerpendicular contain the space available, and preferredParallel contains the preferred result.

This method returns an answer that is less than or equal to availableParallel and as close to preferredParallel as possible. Return values larger than availableParallel will be truncated.

Most presentations will define a minimum size at all times, and a maximum size that only applies when maximized.

The getSizeFlags method controls how frequently this method will be called and what information will be available when it is. Any subclass that specializes this method should also specialize getSizeFlags. computePreferredSize(width, INF, someSize, 0) returns the minimum size of the control (if any). computePreferredSize(width, INF, someSize, INF) returns the maximum size of the control.


  • To maintain a constant size of 100x300 pixels: {return width ? 100 : 300}, getSizeFlags(boolean) must return SWT.MIN | SWT.MAX
  • To grow without constraints: {return preferredResult;}, getSizeFlags(boolean) must return 0.
  • To enforce a width that is always a multiple of 100 pixels, to a minimum of 100 pixels: { if (width && preferredResult != INF) { int result = preferredResult - ((preferredResult + 50) % 100) + 50; result = Math.max(100, Math.min(result, availableParallel - (availableParallel % 100)));

    return result; } return preferredResult; } In this case, getSizeFlags(boolean width) must return (width ? SWT.FILL | SWT.MIN: 0)

  • To maintain a minimum area of 100000 pixels: {return availablePerpendicular < 100 ? 1000 : 100000 / availablePerpendicular;} getSizeFlags(boolean width) must return SWT.WRAP | SWT.MIN;
widthindicates whether a width (=true) or a height (=false) is being computed
availableParallelavailable space. This is a width (pixels) if width == true, and a height (pixels) if width == false. A return value larger than this will be ignored.
availablePerpendicularavailable space perpendicular to the direction being measured or INF if unbounded (pixels). This is a height if width == true, or a height if width == false. Implementations will generally ignore this argument unless they contain wrapping widgets. Note this argument will only contain meaningful information if the part returns the SWT.WRAP flag from getSizeFlags(width)
preferredResultpreferred size of the control (pixels, <= availableParallel). Set to INF if unknown or unbounded.
returns the preferred size of the control (pixels). This is a width if width == true or a height if width == false. Callers are responsible for rounding down the return value if it is larger than availableParallel. If availableParallel is INF, then a return value of INF is permitted, indicating that the preferred size of the control is unbounded.
See also

Implements berry::ISizeProvider.

◆ DragOver()

virtual StackDropResult::Pointer berry::StackPresentation::DragOver ( QWidget *  currentControl,
const QPoint &  location 
pure virtual

This method is invoked whenever a part is dragged over the stack's control. It returns a StackDropResult if and only if the part may be dropped in this location.

currentControlthe control being dragged over
locationcursor location (display coordinates)
a StackDropResult or null if the presentation does not have a drop target in this location.

◆ GetControl()

virtual QWidget* berry::StackPresentation::GetControl ( )
pure virtual

Returns the control for this presentation

the control for this presentation (not null)

◆ GetSite()

IStackPresentationSite::Pointer berry::StackPresentation::GetSite ( )

Returns the presentation site (not null).


◆ GetSizeFlags()

int berry::StackPresentation::GetSizeFlags ( bool  width)

Returns a bitwise combination of flags indicating how and when computePreferredSize should be used. When called with horizontal=true, this indicates the usage of computePreferredSize(true,...) for computing widths. When called with horizontal=false, this indicates the usage of computeSize(false,...) for computing heights. These flags are used for optimization. Each flag gives the part more control over its preferred size but slows down the layout algorithm. Parts should return the minimum set of flags necessary to specify their constraints.

If the return value of this function ever changes, the part must call flushLayout before the changes will take effect.

  • SWT.MAX: The part has a maximum size that will be returned by computePreferredSize(horizontal, INF, someWidth, INF)
  • SWT.MIN: The part has a minimum size that will be returned by computePreferredSize(horizontal, INF, someWidth, 0)
  • SWT.WRAP: Indicates that computePreferredSize makes use of the availablePerpendicular argument. If this flag is not specified, then the third argument to computePreferredSize will always be set to INF. The perpendicular size is expensive to compute, and it is usually only used for wrapping parts.
  • SWT.FILL: The part may not return the preferred size verbatim when computePreferredSize is is given a value between the minimum and maximum sizes. This is commonly used if the part wants to use a set of predetermined sizes instead of using the workbench-provided size. For example, computePreferredSize(horizontal, availableSpace, someWidth, preferredSize) may return the nearest predetermined size. Note that this flag should be used sparingly. It can prevent layout caching and cause the workbench layout algorithm to degrade to exponential worst-case runtime. If this flag is omitted, then computePreferredSize may be used to compute the minimum and maximum sizes, but not for anything in between.
widtha value of true or false determines whether the return value applies when computing widths or heights respectively. That is, getSizeFlags(true) will be used when calling computePreferredSize(true,...)
any bitwise combination of SWT.MAX, SWT.MIN, SWT.WRAP, and SWT.FILL

Implements berry::ISizeProvider.

◆ GetTabList()

virtual QList<QWidget*> berry::StackPresentation::GetTabList ( IPresentablePart::Pointer  part)
pure virtual

Returns the tab-key traversal order for the given IPresentablePart.

partthe part
the tab-key traversal order

◆ MovePart()

virtual void berry::StackPresentation::MovePart ( IPresentablePart::Pointer  toMove,
Object::Pointer  cookie 

Moves a part to a new location as the result of a drag/drop operation within this presentation.

toMovea part that already belongs to this presentation
cookiea drop cookie returned by StackPresentation::dragOver

◆ RemovePart()

virtual void berry::StackPresentation::RemovePart ( IPresentablePart::Pointer  oldPart)
pure virtual

Removes the given part from the stack.

oldPartthe part to remove (not null)

◆ RestoreState()

virtual void berry::StackPresentation::RestoreState ( IPresentationSerializer context,
IMemento::Pointer  memento 

Restores the state of this presentation to a previously saved state.

contextobject that can be used to find IPresentableParts given string IDs (this may be a temporary object - the presentation should not keep any references to it)
mementomemento where the data will be saved

◆ SaveState()

virtual void berry::StackPresentation::SaveState ( IPresentationSerializer context,
IMemento::Pointer  memento 

Saves the state of this presentation to the given memento.

contextobject that can be used to generate unique IDs for IPresentableParts (this may be a temporary object - the presentation should not keep any references to it)
mementomemento where the data will be saved

◆ SelectPart()

virtual void berry::StackPresentation::SelectPart ( IPresentablePart::Pointer  toSelect)
pure virtual

Brings the specified part to the foreground. This should not affect the current focus.

toSelectthe new active part (not null)

◆ SetActive()

virtual void berry::StackPresentation::SetActive ( int  newState)
pure virtual

This is invoked to notify the presentation that its activation state has changed. StackPresentations can have three possible activation states (see the AS_* constants above)


◆ SetBounds()

virtual void berry::StackPresentation::SetBounds ( const QRect &  bounds)
pure virtual

Sets the bounding rectangle for this presentation.

boundsnew bounding rectangle (not null)

◆ SetState()

virtual void berry::StackPresentation::SetState ( int  state)
pure virtual

Sets the state of the presentation. That is, notifies the presentation that is has been minimized, maximized, or restored. Note that this method is the only way that a presentation is allowed to change its state.

If a presentation wishes to minimize itself, it must call setState on its associated IStackPresentationSite. If the site chooses to respond to the state change, it will call this method at the correct time. The presentation should not call this method directly.

stateone of the IStackPresentationSite.STATE_* constants.

◆ SetVisible()

virtual void berry::StackPresentation::SetVisible ( bool  isVisible)
pure virtual

This causes the presentation to become visible or invisible. When a presentation is invisible, it must not respond to user input or modify its parts. For example, a presentations will be made invisible if it belongs to a perspective and the user switches to another perspective.

isVisiblethe state to set visibility to

◆ ShowPartList()

virtual void berry::StackPresentation::ShowPartList ( )

Instructs the presentation to display the system menu Instructs the presentation to display the pane menu Instructs the presentation to display a list of all parts in the stack, and allow the user to change the selection using the keyboard.

Member Data Documentation


const int berry::StackPresentation::AS_ACTIVE_FOCUS

Activation state indicating that one of the parts in the presentation currently has focus

Definition at line 92 of file berryStackPresentation.h.


const int berry::StackPresentation::AS_ACTIVE_NOFOCUS

Activation state indicating that none of the parts in the presentation have focus, but one of the parts is being used as the context for global menus and toolbars

Definition at line 98 of file berryStackPresentation.h.


const int berry::StackPresentation::AS_INACTIVE

Inactive state. This is the default state for deselected presentations.

Definition at line 87 of file berryStackPresentation.h.

The documentation for this class was generated from the following file: