& images);
/**
* Sets the window manager of this window.
*
* Note that this method is used by WindowManager
to maintain
* a backpointer. Clients must not call the method directly.
*
*
* @param manager
* the window manager, or null
if none
*/
void SetWindowManager(WindowManager* manager);
/**
* Sets the exception handler for this application.
*
* Note that the handler may only be set once. Subsequent calls to this method will be
* ignored.
*
*
* @param handler
* the exception handler for the application.
*/
static void SetExceptionHandler(IExceptionHandler::Pointer handler);
/**
* Sets the default parent for modal Windows. This will be used to locate
* the parent for any modal Window constructed with a null parent.
*
* @param provider shell provider that will be used to locate the parent shell
* whenever a Window is created with a null parent
* @since 3.1
*/
static void SetDefaultModalParent(IShellProvider::Pointer provider);
};
}
#endif /* BERRYWINDOW_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkControlEvent.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkControlEvent.h
index ba0eae4ede..05157ffc58 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkControlEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkControlEvent.h
@@ -1,55 +1,55 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYGUITKCONTROLEVENT_H_
#define BERRYGUITKCONTROLEVENT_H_
#include "berryGuiTkEvent.h"
namespace berry
{
namespace GuiTk
{
/**
* Instances of this class are sent as a result of
* controls being moved or resized.
*
* @see ControlListener
* @see Sample code and further information
*/
class BERRY_UI_QT ControlEvent: public Event
{
public:
- berryObjectMacro(ControlEvent);
+ berryObjectMacro(ControlEvent)
ControlEvent();
ControlEvent(void* item, int x = 0, int y = 0, int width = 0, int height = 0);
};
}
}
#endif /* BERRYGUITKCONTROLEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryAbstractDropTarget.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryAbstractDropTarget.h
index cae66c62d9..67381778bd 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryAbstractDropTarget.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryAbstractDropTarget.h
@@ -1,44 +1,44 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYABSTRACTDROPTARGET_H_
#define BERRYABSTRACTDROPTARGET_H_
#include "berryIDropTarget.h"
namespace berry {
struct AbstractDropTarget : public IDropTarget
{
/*
* @see IDropTarget#GetSnapRectangle()
*/
- Rectangle GetSnapRectangle()
+ QRect GetSnapRectangle()
{
- return Rectangle();
+ return QRect();
}
void DragFinished(bool /*dropPerformed*/)
{
}
};
}
#endif /* BERRYABSTRACTDROPTARGET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDefaultStackPresentationSite.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDefaultStackPresentationSite.cpp
index d9283f1ccb..c326b63c8b 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDefaultStackPresentationSite.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDefaultStackPresentationSite.cpp
@@ -1,113 +1,113 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryDefaultStackPresentationSite.h"
namespace berry {
DefaultStackPresentationSite::DefaultStackPresentationSite()
: state(IStackPresentationSite::STATE_RESTORED),
activeState(StackPresentation::AS_INACTIVE)
{}
void DefaultStackPresentationSite::SetPresentation(StackPresentation::Pointer newPresentation) {
presentation = newPresentation;
if (presentation != 0) {
presentation->SetState(state);
presentation->SetActive(activeState);
}
}
StackPresentation::Pointer DefaultStackPresentationSite::GetPresentation() {
return presentation;
}
int DefaultStackPresentationSite::GetState() {
return state;
}
void DefaultStackPresentationSite::SetActive(int activeState) {
if (activeState != this->activeState) {
this->activeState = activeState;
if (presentation != 0) {
presentation->SetActive(activeState);
}
}
}
int DefaultStackPresentationSite::GetActive() {
return activeState;
}
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IStackPresentationSite#selectPart(org.blueberry.ui.internal.skins.IPresentablePart)
*/
void DefaultStackPresentationSite::SelectPart(IPresentablePart::Pointer toSelect) {
if (presentation != 0) {
presentation->SelectPart(toSelect);
}
}
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentationSite#setState(int)
*/
void DefaultStackPresentationSite::SetState(int newState) {
this->SetPresentationState(newState);
}
void DefaultStackPresentationSite::SetPresentationState(int newState) {
state = newState;
if (presentation != 0) {
presentation->SetState(newState);
}
}
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentablePart#isClosable()
*/
bool DefaultStackPresentationSite::IsCloseable(IPresentablePart::Pointer part) {
return part->IsCloseable();
}
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentationSite#dragStart(org.blueberry.ui.internal.skins.IPresentablePart, boolean)
*/
- void DefaultStackPresentationSite::DragStart(IPresentablePart::Pointer /*beingDragged*/, Point& /*initialPosition*/,
+ void DefaultStackPresentationSite::DragStart(IPresentablePart::Pointer /*beingDragged*/, QPoint& /*initialPosition*/,
bool /*keyboard*/) {
}
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentationSite#close(org.blueberry.ui.internal.skins.IPresentablePart)
*/
void DefaultStackPresentationSite::Close(IPresentablePart::Pointer /*toClose*/) {
}
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentationSite#dragStart(boolean)
*/
- void DefaultStackPresentationSite::DragStart(Point& /*initialPosition*/, bool /*keyboard*/) {
+ void DefaultStackPresentationSite::DragStart(QPoint& /*initialPosition*/, bool /*keyboard*/) {
}
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IStackPresentationSite#supportsState(int)
*/
bool DefaultStackPresentationSite::SupportsState(int /*state*/) {
return true;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDefaultStackPresentationSite.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDefaultStackPresentationSite.h
index bb32abdfac..ee7ea5b0c6 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDefaultStackPresentationSite.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDefaultStackPresentationSite.h
@@ -1,101 +1,101 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYDEFAULTSTACKPRESENTATIONSITE_H_
#define BERRYDEFAULTSTACKPRESENTATIONSITE_H_
#include "presentations/berryIStackPresentationSite.h"
#include "presentations/berryStackPresentation.h"
namespace berry
{
class DefaultStackPresentationSite: public IStackPresentationSite
{
private:
StackPresentation::Pointer presentation;
int state;
int activeState;
public:
berryObjectMacro(DefaultStackPresentationSite)
DefaultStackPresentationSite();
void SetPresentation(StackPresentation::Pointer newPresentation);
StackPresentation::Pointer GetPresentation();
int GetState();
void SetActive(int activeState);
int GetActive();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IStackPresentationSite#selectPart(org.blueberry.ui.internal.skins.IPresentablePart)
*/
void SelectPart(IPresentablePart::Pointer toSelect);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentationSite#setState(int)
*/
void SetState(int newState);
void SetPresentationState(int newState);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentablePart#isClosable()
*/
bool IsCloseable(IPresentablePart::Pointer part);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentationSite#dragStart(org.blueberry.ui.internal.skins.IPresentablePart, boolean)
*/
void DragStart(IPresentablePart::Pointer beingDragged,
- Point& initialPosition, bool keyboard);
+ QPoint& initialPosition, bool keyboard);
using IStackPresentationSite::Close;
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentationSite#close(org.blueberry.ui.internal.skins.IPresentablePart)
*/
void Close(IPresentablePart::Pointer toClose);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentationSite#dragStart(boolean)
*/
- void DragStart(Point& initialPosition, bool keyboard);
+ void DragStart(QPoint& initialPosition, bool keyboard);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IStackPresentationSite#supportsState(int)
*/
bool SupportsState(int state);
// void AddSystemActions(IMenuManager menuManager) {
//
// }
};
}
#endif /* BERRYDEFAULTSTACKPRESENTATIONSITE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedPlaceHolder.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedPlaceHolder.cpp
index 3afc3ee7dd..6632e297aa 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedPlaceHolder.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedPlaceHolder.cpp
@@ -1,146 +1,146 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryDetachedPlaceHolder.h"
#include "berryILayoutContainer.h"
#include "berryPartPlaceholder.h"
#include "berryWorkbenchConstants.h"
namespace berry
{
DetachedPlaceHolder::DetachedPlaceHolder(const QString& id,
- const Rectangle& b) :
+ const QRect& b) :
PartPlaceholder(id), bounds(b)
{
}
void DetachedPlaceHolder::Add(LayoutPart::Pointer newPart)
{
if (newPart.Cast () == 0)
{
return;
}
children.push_back(newPart);
}
bool DetachedPlaceHolder::AllowsBorder()
{
return false;
}
bool DetachedPlaceHolder::AllowsAdd(LayoutPart::Pointer toAdd)
{
return PartPlaceholder::AllowsAdd(toAdd);
}
bool DetachedPlaceHolder::AllowsAutoFocus()
{
return PartPlaceholder::AllowsAutoFocus();
}
-Rectangle DetachedPlaceHolder::GetBounds()
+QRect DetachedPlaceHolder::GetBounds()
{
return bounds;
}
QList DetachedPlaceHolder::GetChildren()
{
return children;
}
void DetachedPlaceHolder::Remove(LayoutPart::Pointer part)
{
children.removeAll(part);
}
void DetachedPlaceHolder::Replace(LayoutPart::Pointer oldPart,
LayoutPart::Pointer newPart)
{
this->Remove(oldPart);
this->Add(newPart);
}
void DetachedPlaceHolder::RestoreState(IMemento::Pointer memento)
{
// Read the bounds.
int x = 0;
memento->GetInteger(WorkbenchConstants::TAG_X, x);
int y = 0;
memento->GetInteger(WorkbenchConstants::TAG_Y, y);
int width = 0;
memento->GetInteger(WorkbenchConstants::TAG_WIDTH, width);
int height = 0;
memento->GetInteger(WorkbenchConstants::TAG_HEIGHT, height);
- bounds = Rectangle(x, y, width, height);
+ bounds = QRect(x, y, width, height);
// Restore the placeholders.
QList childrenMem(memento
->GetChildren(WorkbenchConstants::TAG_VIEW));
for (int i = 0; i < childrenMem.size(); i++)
{
QString id;
childrenMem[i]->GetString(WorkbenchConstants::TAG_ID, id);
PartPlaceholder::Pointer holder(new PartPlaceholder(id));
holder->SetContainer(ILayoutContainer::Pointer(this));
children.push_back(holder);
}
}
void DetachedPlaceHolder::SaveState(IMemento::Pointer memento)
{
// Save the bounds.
- memento->PutInteger(WorkbenchConstants::TAG_X, bounds.x);
- memento->PutInteger(WorkbenchConstants::TAG_Y, bounds.y);
- memento->PutInteger(WorkbenchConstants::TAG_WIDTH, bounds.width);
- memento->PutInteger(WorkbenchConstants::TAG_HEIGHT, bounds.height);
+ memento->PutInteger(WorkbenchConstants::TAG_X, bounds.x());
+ memento->PutInteger(WorkbenchConstants::TAG_Y, bounds.y());
+ memento->PutInteger(WorkbenchConstants::TAG_WIDTH, bounds.width());
+ memento->PutInteger(WorkbenchConstants::TAG_HEIGHT, bounds.height());
// Save the views.
for (QList::iterator i = children.begin();
i != children.end(); ++i)
{
IMemento::Pointer childMem = memento
->CreateChild(WorkbenchConstants::TAG_VIEW);
childMem->PutString(WorkbenchConstants::TAG_ID, (*i)->GetID());
}
}
void DetachedPlaceHolder::FindSashes(LayoutPart::Pointer /*part*/,
PartPane::Sashes& sashes)
{
ILayoutContainer::Pointer container = this->GetContainer();
if (container != 0)
{
container->FindSashes(LayoutPart::Pointer(this), sashes);
}
}
ILayoutContainer::ChildrenType DetachedPlaceHolder::GetChildren() const
{
return children;
}
void DetachedPlaceHolder::ResizeChild(LayoutPart::Pointer childThatChanged)
{
PartPlaceholder::ResizeChild(childThatChanged);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedPlaceHolder.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedPlaceHolder.h
index bf64ef3cee..5640a20a73 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedPlaceHolder.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedPlaceHolder.h
@@ -1,112 +1,109 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYDETACHEDPLACEHOLDER_H_
#define BERRYDETACHEDPLACEHOLDER_H_
#include "berryPartPlaceholder.h"
#include "berryILayoutContainer.h"
#include "berryIMemento.h"
-#include "berryRectangle.h"
-
-#include
namespace berry {
/**
* DetachedPlaceHolder is the placeholder for detached views.
*
*/
class DetachedPlaceHolder : public PartPlaceholder, public ILayoutContainer
{
private:
QList children;
- Rectangle bounds;
+ QRect bounds;
public:
berryObjectMacro(DetachedPlaceHolder)
/**
* DetachedPlaceHolder constructor comment.
* @param id java.lang.String
* @param bounds the size of the placeholder
*/
- DetachedPlaceHolder(const QString& id, const Rectangle& b);
+ DetachedPlaceHolder(const QString& id, const QRect& b);
/**
* Add a child to the container.
*/
void Add(LayoutPart::Pointer newPart);
/**
* Return true if the container allows its
* parts to show a border if they choose to,
* else false if the container does not want
* its parts to show a border.
* @return boolean
*/
bool AllowsBorder();
bool AllowsAdd(LayoutPart::Pointer toAdd);
bool AllowsAutoFocus();
- Rectangle GetBounds();
+ QRect GetBounds();
/**
* Returns a list of layout children.
*/
QList GetChildren();
/**
* Remove a child from the container.
*/
void Remove(LayoutPart::Pointer part);
/**
* Replace one child with another
*/
void Replace(LayoutPart::Pointer oldPart, LayoutPart::Pointer newPart);
/**
* Restore the state from the memento.
* @param memento
*/
void RestoreState(IMemento::Pointer memento);
/**
* Save state to the memento.
* @param memento
*/
void SaveState(IMemento::Pointer memento);
void FindSashes(LayoutPart::Pointer part, PartPane::Sashes& sashes);
ILayoutContainer::ChildrenType GetChildren() const;
void ResizeChild(LayoutPart::Pointer childThatChanged);
};
}
#endif /* BERRYDETACHEDPLACEHOLDER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedWindow.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedWindow.cpp
index 58084a7f33..bf970afb08 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedWindow.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedWindow.cpp
@@ -1,540 +1,540 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryDetachedWindow.h"
#include "berryIWorkbenchPartConstants.h"
#include "berryISaveablePart.h"
#include "berryWorkbenchWindow.h"
#include "berryWorkbenchConstants.h"
#include "berryEditorManager.h"
#include "berryDragUtil.h"
namespace berry
{
DetachedWindow::ShellListener::ShellListener(DetachedWindow* wnd) :
window(wnd)
{
}
void DetachedWindow::ShellListener::ShellClosed(const ShellEvent::Pointer& e)
{
// hold on to a reference of the DetachedWindow instance
// (otherwise, wnd->HandleClose() woulde delete the DetachedWindow
// instance too early, trying to write to members afterwards)
DetachedWindow::Pointer wnd(window);
// only continue to close if the handleClose
// wasn't canceled
e->doit = wnd->HandleClose();
}
DetachedWindow::ShellControlListener::ShellControlListener(DetachedWindow* wnd) :
window(wnd)
{
}
GuiTk::IControlListener::Events::Types DetachedWindow::ShellControlListener::GetEventTypes() const
{
return Events::RESIZED;
}
void DetachedWindow::ShellControlListener::ControlResized(
GuiTk::ControlEvent::Pointer e)
{
window->folder->SetBounds(
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetClientArea(e->item));
}
DetachedWindow::DetachedWindow(WorkbenchPage* workbenchPage)
: folder(new PartStack(workbenchPage, false))
, page(workbenchPage)
, hideViewsOnClose(true)
, shellListener(new ShellListener(this))
, resizeListener(new ShellControlListener(this))
{
}
void DetachedWindow::PropertyChange(const Object::Pointer& /*source*/, int propId)
{
if (propId == IWorkbenchPartConstants::PROP_TITLE)
{
this->UpdateTitle();
}
else if (propId == PartStack::PROP_SELECTION)
{
this->ActivePartChanged(this->GetPartReference(folder->GetSelection()));
}
}
Shell::Pointer DetachedWindow::GetShell()
{
return windowShell;
}
void DetachedWindow::Create()
{
folder->AddListener(this);
windowShell
= page->GetWorkbenchWindow().Cast () ->GetDetachedWindowPool()->AllocateShell(
shellListener.data());
windowShell->SetData(Object::Pointer(this));
windowShell->SetText("");
DragUtil::AddDragTarget(windowShell->GetControl(), this);
hideViewsOnClose = true;
- if (bounds.IsEmpty())
+ if (bounds.isEmpty())
{
- Rectangle windowRect = page->GetWorkbenchWindow()->GetShell()->GetBounds();
- Point center(windowRect.x + windowRect.width / 2, windowRect.y
- - windowRect.height / 2);
- bounds = Rectangle(center.x - 150, center.y + 100, 300, 200);
+ QRect windowRect = page->GetWorkbenchWindow()->GetShell()->GetBounds();
+ QPoint center(windowRect.x() + windowRect.width() / 2, windowRect.y()
+ - windowRect.height() / 2);
+ bounds = QRect(center.x() - 150, center.y() + 100, 300, 200);
}
// Force the rect into the current display
- Rectangle dispBounds =
+ QRect dispBounds =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetAvailableScreenSize();
- if (bounds.width > dispBounds.width)
- bounds.width = dispBounds.width;
- if (bounds.height > dispBounds.height)
- bounds.height = dispBounds.height;
- if (bounds.x + bounds.width > dispBounds.width)
- bounds.x = dispBounds.width - bounds.width;
- if (bounds.y + bounds.height > dispBounds.height)
- bounds.y = dispBounds.height - bounds.height;
+ if (bounds.width() > dispBounds.width())
+ bounds.setWidth(dispBounds.width());
+ if (bounds.height() > dispBounds.height())
+ bounds.setHeight(dispBounds.height());
+ if (bounds.x() + bounds.width() > dispBounds.width())
+ bounds.setX(dispBounds.width() - bounds.width());
+ if (bounds.y() + bounds.height() > dispBounds.height())
+ bounds.setY(dispBounds.height() - bounds.height());
this->GetShell()->SetBounds(bounds);
this->ConfigureShell(windowShell);
this->CreateContents(windowShell->GetControl());
//windowShell->Layout(true);
//folder->SetBounds(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetClientArea(windowShell->GetControl()));
}
void DetachedWindow::Add(LayoutPart::Pointer part)
{
Shell::Pointer shell = this->GetShell();
if (shell != 0)
{
part->Reparent(shell->GetControl());
}
folder->Add(part);
this->UpdateMinimumSize();
}
bool DetachedWindow::BelongsToWorkbenchPage(
IWorkbenchPage::Pointer workbenchPage)
{
return (workbenchPage == this->page);
}
bool DetachedWindow::Close()
{
hideViewsOnClose = false;
Shell::Pointer shell = this->GetShell();
if (shell != 0)
{
shell->Close();
}
return true;
}
IDropTarget::Pointer DetachedWindow::Drag(void* /*currentControl*/,
- const Object::Pointer& draggedObject, const Point& position, const Rectangle& /*dragRectangle*/)
+ const Object::Pointer& draggedObject, const QPoint& position, const QRect& /*dragRectangle*/)
{
if (draggedObject.Cast () == 0)
{
return IDropTarget::Pointer(0);
}
PartPane::Pointer sourcePart = draggedObject.Cast ();
if (sourcePart->GetWorkbenchWindow() != page->GetWorkbenchWindow())
{
return IDropTarget::Pointer(0);
}
// Only handle the event if the source part is acceptable to the particular PartStack
IDropTarget::Pointer target;
if (folder->AllowsDrop(sourcePart))
{
target = folder->GetDropTarget(draggedObject, position);
if (target == 0)
{
- Rectangle displayBounds =
+ QRect displayBounds =
DragUtil::GetDisplayBounds(folder->GetControl());
- if (displayBounds.Contains(position))
+ if (displayBounds.contains(position))
{
StackDropResult::Pointer stackDropResult(new StackDropResult(
displayBounds, Object::Pointer(0)));
target = folder->CreateDropTarget(sourcePart, stackDropResult);
}
else
{
return IDropTarget::Pointer(0);
}
}
}
return target;
}
ILayoutContainer::ChildrenType DetachedWindow::GetChildren() const
{
return folder->GetChildren();
}
WorkbenchPage::Pointer DetachedWindow::GetWorkbenchPage()
{
return WorkbenchPage::Pointer(this->page);
}
void DetachedWindow::RestoreState(IMemento::Pointer memento)
{
// Read the bounds.
int x = 0;
memento->GetInteger(WorkbenchConstants::TAG_X, x);
int y = 0;
memento->GetInteger(WorkbenchConstants::TAG_Y, y);
int width = 0;
memento->GetInteger(WorkbenchConstants::TAG_WIDTH, width);
int height = 0;
memento->GetInteger(WorkbenchConstants::TAG_HEIGHT, height);
// memento->GetInteger(WorkbenchConstants::TAG_FLOAT);
// Set the bounds.
- bounds = Rectangle(x, y, width, height);
+ bounds = QRect(x, y, width, height);
if (GetShell())
{
GetShell()->SetBounds(bounds);
}
// Create the folder.
IMemento::Pointer childMem =
memento->GetChild(WorkbenchConstants::TAG_FOLDER);
if (childMem)
{
folder->RestoreState(childMem);
}
}
void DetachedWindow::SaveState(IMemento::Pointer memento)
{
if (GetShell())
{
bounds = GetShell()->GetBounds();
}
// Save the bounds.
- memento->PutInteger(WorkbenchConstants::TAG_X, bounds.x);
- memento->PutInteger(WorkbenchConstants::TAG_Y, bounds.y);
- memento->PutInteger(WorkbenchConstants::TAG_WIDTH, bounds.width);
- memento->PutInteger(WorkbenchConstants::TAG_HEIGHT, bounds.height);
+ memento->PutInteger(WorkbenchConstants::TAG_X, bounds.x());
+ memento->PutInteger(WorkbenchConstants::TAG_Y, bounds.y());
+ memento->PutInteger(WorkbenchConstants::TAG_WIDTH, bounds.width());
+ memento->PutInteger(WorkbenchConstants::TAG_HEIGHT, bounds.height());
// Save the views.
IMemento::Pointer childMem = memento->CreateChild(
WorkbenchConstants::TAG_FOLDER);
folder->SaveState(childMem);
}
void* DetachedWindow::GetControl()
{
return folder->GetControl();
}
int DetachedWindow::Open()
{
if (this->GetShell() == 0)
{
this->Create();
}
- Rectangle bounds = this->GetShell()->GetBounds();
+ QRect bounds = this->GetShell()->GetBounds();
if (!(bounds == this->GetShell()->GetBounds()))
{
this->GetShell()->SetBounds(bounds);
}
this->GetShell()->SetVisible(true);
folder->SetBounds(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetClientArea(this->GetShell()->GetControl()));
return 0;
}
void DetachedWindow::ActivePartChanged(
IWorkbenchPartReference::Pointer partReference)
{
if (activePart == partReference)
{
return;
}
if (activePart != 0)
{
activePart->RemovePropertyListener(this);
}
activePart = partReference;
if (partReference != 0)
{
partReference->AddPropertyListener(this);
}
this->UpdateTitle();
}
void DetachedWindow::ConfigureShell(Shell::Pointer shell)
{
this->UpdateTitle();
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(
shell->GetControl(), resizeListener);
//shell.addListener(SWT.Activate, activationListener);
//shell.addListener(SWT.Deactivate, activationListener);
//TODO DetachedWindow key bindings
// // Register this detached view as a window (for key bindings).
// IContextService contextService = (IContextService) getWorkbenchPage()
// .getWorkbenchWindow().getWorkbench().getService(IContextService.class);
// contextService.registerShell(shell, IContextService.TYPE_WINDOW);
//
// page.getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp(shell,
// IWorkbenchHelpContextIds.DETACHED_WINDOW);
}
void* DetachedWindow::CreateContents(void* parent)
{
// Create the tab folder.
folder->CreateControl(parent);
// Reparent each view in the tab folder.
QList detachedChildren;
this->CollectViewPanes(detachedChildren, this->GetChildren());
for (QList::iterator itr = detachedChildren.begin(); itr
!= detachedChildren.end(); ++itr)
{
PartPane::Pointer part = *itr;
part->Reparent(parent);
}
//TODO DetachedWindow listen to folder events (update size?)
// if (folder->GetPresentation()
// instanceof TabbedStackPresentation)
// {
// TabbedStackPresentation stack = (TabbedStackPresentation) folder.getPresentation();
// AbstractTabFolder tabFolder = stack.getTabFolder();
// tabFolder.addListener(new TabFolderListener()
// {
// public void handleEvent(TabFolderEvent e)
// {
// switch (e.type)
// {
// case TabFolderEvent.EVENT_CLOSE:
// {
// updateMinimumSize();
// break;
// }
// case TabFolderEvent.EVENT_PREFERRED_SIZE:
// {
// updateMinimumSize();
// break;
// }
// }
// }
// });
// }
// Return tab folder control.
return folder->GetControl();
}
void DetachedWindow::UpdateTitle()
{
if (activePart != 0)
{
// Uncomment to set the shell title to match the title of the active part
// String text = activePart.getTitle();
//
// if (!text.equals(s.getText())) {
// s.setText(text);
// }
}
}
void DetachedWindow::UpdateMinimumSize()
{
// // We can only do this for 'Tabbed' stacked presentations.
// if (folder.getPresentation().Cast() != 0)
// {
// TabbedStackPresentation stack = (TabbedStackPresentation) folder.getPresentation();
//
// if (stack->GetPartList().size() == 1)
// {
// // Get the minimum space required for the part
// int width = stack->ComputePreferredSize(true, Constants::INF, Constants::INF, 0);
// int height = stack->ComputePreferredSize(false, Constants::INF, Constants::INF, 0);
//
// // Take the current shell 'trim' into account
// int shellHeight = windowShell->GetBounds().height - windowShell->GetClientArea().height;
// int shellWidth = windowShell->GetBounds().width - windowShell->GetClientArea().width;
//
// windowShell->SetMinimumSize(width + shellWidth, height + shellHeight);
// }
// }
}
IWorkbenchPartReference::Pointer DetachedWindow::GetPartReference(
LayoutPart::Pointer pane)
{
if (pane == 0 || pane.Cast () == 0)
{
return IWorkbenchPartReference::Pointer(0);
}
return pane.Cast ()->GetPartReference();
}
bool DetachedWindow::HandleClose()
{
if (hideViewsOnClose)
{
QList views;
this->CollectViewPanes(views, this->GetChildren());
// Save any dirty views
if (!this->HandleSaves(views))
{
return false; // User canceled the save
}
// OK, go on with the closing
for (QList::iterator itr = views.begin(); itr
!= views.end(); ++itr)
{
PartPane::Pointer child = *itr;
// Only close if closable...
if (child->IsCloseable())
{
page->HideView(child->GetPartReference().Cast ());
// Was the close cancelled?
if (child->GetContainer() != 0)
return false;
}
else
{
page->AttachView(child->GetPartReference().Cast ());
}
}
}
if (folder != 0)
{
folder->Dispose();
}
if (windowShell != 0)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->RemoveControlListener(
windowShell->GetControl(), resizeListener);
// windowShell.removeListener(SWT.Activate, activationListener);
// windowShell.removeListener(SWT.Deactivate, activationListener);
DragUtil::RemoveDragTarget(windowShell->GetControl(), this);
bounds = windowShell->GetBounds();
//TODO DetachedWindow unregister key bindings
// // Unregister this detached view as a window (for key bindings).
// final IContextService contextService = (IContextService) getWorkbenchPage().getWorkbenchWindow().getWorkbench().getService(IContextService.class);
// contextService.unregisterShell(windowShell);
windowShell->SetData(Object::Pointer(0));
windowShell = 0;
}
return true;
}
bool DetachedWindow::HandleSaves(QList views)
{
QList dirtyViews;
for (QList::iterator iterator = views.begin(); iterator
!= views.end(); ++iterator)
{
PartPane::Pointer pane = *iterator;
IViewReference::Pointer ref =
pane->GetPartReference().Cast ();
IViewPart::Pointer part = ref->GetView(false);
if (part.Cast () != 0)
{
ISaveablePart::Pointer saveable = part.Cast ();
if (saveable->IsDirty() && saveable->IsSaveOnCloseNeeded())
{
dirtyViews.push_back(part);
}
}
}
// If there are any prompt to save -before- any closing happens
// FIXME: This code will result in a double prompt if the user
// decides not to save a particular view at this stage they'll
// get a second one from the 'hideView' call...
if (dirtyViews.size() > 0)
{
IWorkbenchWindow::Pointer window = page->GetWorkbenchWindow();
bool success =
EditorManager::SaveAll(dirtyViews, true, true, false, window);
if (!success)
{
return false; // the user canceled.
}
}
return true;
}
void DetachedWindow::CollectViewPanes(QList& result,
const QList& parts)
{
for (QList::const_iterator iter = parts.begin(); iter
!= parts.end(); ++iter)
{
LayoutPart::Pointer part = *iter;
if (part.Cast () != 0)
{
result.push_back(part.Cast ());
}
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedWindow.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedWindow.h
index 938c7e4357..51ecbf4e31 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedWindow.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedWindow.h
@@ -1,197 +1,196 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYDETACHEDWINDOW_H_
#define BERRYDETACHEDWINDOW_H_
#include "berryPartStack.h"
#include "berryWorkbenchPage.h"
#include "berryLayoutPart.h"
#include "berryIDragOverListener.h"
#include "berryIShellListener.h"
#include "guitk/berryGuiTkIControlListener.h"
-#include "berryRectangle.h"
#include "berryShell.h"
namespace berry
{
/**
* TODO: Drag from detached to fast view bar back to detached causes NPE
*/
class DetachedWindow: public Object, private IPropertyChangeListener,
private IDragOverListener
{
public:
berryObjectMacro(DetachedWindow)
private:
PartStack::Pointer folder;
WorkbenchPage* page;
- Rectangle bounds;
+ QRect bounds;
Shell::Pointer windowShell;
bool hideViewsOnClose;
struct ShellListener: public IShellListener
{
ShellListener(DetachedWindow* wnd);
void ShellClosed(const ShellEvent::Pointer& e);
private:
DetachedWindow* window;
};
QScopedPointer shellListener;
struct ShellControlListener: public GuiTk::IControlListener
{
ShellControlListener(DetachedWindow* wnd);
Events::Types GetEventTypes() const;
void ControlResized(GuiTk::ControlEvent::Pointer e);
private:
DetachedWindow* window;
};
GuiTk::IControlListener::Pointer resizeListener;
// Listener activationListener = new Listener() {
// public void handleEvent(Event event) {
// switch (event.type) {
// case SWT.Activate:
// page.window.liftRestrictions();
// break;
// case SWT.Deactivate:
// page.window.imposeRestrictions();
// break;
// }
// }
// };
IWorkbenchPartReference::Pointer activePart;
public:
/**
* Create a new FloatingWindow.
*/
DetachedWindow(WorkbenchPage* workbenchPage);
using IPropertyChangeListener::PropertyChange;
void PropertyChange(const Object::Pointer& source, int propId);
Shell::Pointer GetShell();
void Create();
/**
* Adds a visual part to this window.
* Supports reparenting.
*/
void Add(LayoutPart::Pointer part);
bool BelongsToWorkbenchPage(IWorkbenchPage::Pointer workbenchPage);
bool Close();
/*
- * @see org.blueberry.ui.internal.IDragOverListener#Drag(void*, Object::Pointer, const Point&, const Rectangle& )
+ * @see org.blueberry.ui.internal.IDragOverListener#Drag(void*, Object::Pointer, const QPoint&, const QRect& )
*/
IDropTarget::Pointer Drag(void* currentControl,
- const Object::Pointer& draggedObject, const Point& position,
- const Rectangle& dragRectangle);
+ const Object::Pointer& draggedObject, const QPoint& position,
+ const QRect& dragRectangle);
ILayoutContainer::ChildrenType GetChildren() const;
WorkbenchPage::Pointer GetWorkbenchPage();
/**
* @see IPersistablePart
*/
void RestoreState(IMemento::Pointer memento);
/**
* @see IPersistablePart
*/
void SaveState(IMemento::Pointer memento);
void* GetControl();
/**
* Opens the detached window.
*/
int Open();
protected:
void ActivePartChanged(IWorkbenchPartReference::Pointer partReference);
/**
* This method will be called to initialize the given Shell's layout
*/
void ConfigureShell(Shell::Pointer shell);
/**
* Override this method to create the widget tree that is used as the window's contents.
*/
void* CreateContents(void* parent);
private:
void UpdateTitle();
/**
* Ensure that the shell's minimum size is equal to the minimum size
* of the first part added to the shell.
*/
void UpdateMinimumSize();
static IWorkbenchPartReference::Pointer GetPartReference(
LayoutPart::Pointer pane);
/**
* Closes this window and disposes its shell.
*/
bool HandleClose();
/**
* Prompts for and handles the saving of dirty, saveable views
* @param views The list of ViewPanes
* @return true
unless the user cancels the save(s)
*/
bool HandleSaves(QList views);
/**
* Answer a list of the view panes.
*/
void CollectViewPanes(QList& result,
const QList& parts);
};
}
#endif /* BERRYDETACHEDWINDOW_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDragUtil.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDragUtil.cpp
index 6960e0ec7b..5b8cb5afa9 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDragUtil.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDragUtil.cpp
@@ -1,362 +1,361 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryDragUtil.h"
#include "berryGeometry.h"
-#include "tweaklets/berryDnDTweaklet.h"
-#include "tweaklets/berryITracker.h"
+#include "berryQtTracker.h"
namespace berry
{
const QString DragUtil::DROP_TARGET_ID =
"org.blueberry.ui.internal.dropTarget";
TestDropLocation::Pointer DragUtil::forcedDropTarget(0);
QList DragUtil::defaultTargets = QList();
DragUtil::TrackerMoveListener::TrackerMoveListener(Object::Pointer draggedItem,
- const Rectangle& sourceBounds, const Point& initialLocation,
+ const QRect& sourceBounds, const QPoint& initialLocation,
bool allowSnapping) :
allowSnapping(allowSnapping), draggedItem(draggedItem), sourceBounds(
sourceBounds), initialLocation(initialLocation)
{
}
GuiTk::IControlListener::Events::Types DragUtil::TrackerMoveListener::GetEventTypes() const
{
return Events::MOVED;
}
void DragUtil::TrackerMoveListener::ControlMoved(
GuiTk::ControlEvent::Pointer event)
{
// Get the curslor location as a point
- Point location(event->x, event->y);
+ QPoint location(event->x, event->y);
// Select a drop target; use the global one by default
IDropTarget::Pointer target;
void* targetControl =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetCursorControl();
- // Get the ITracker which fired the event
- ITracker* tracker = static_cast (event->item);
+ // Get the QtTracker which fired the event
+ QtTracker* tracker = static_cast (event->item);
// Get the drop target for this location
target = DragUtil::GetDropTarget(targetControl, draggedItem, location,
tracker->GetRectangle());
// Set up the tracker feedback based on the target
- Rectangle snapTarget;
+ QRect snapTarget;
if (target != 0)
{
snapTarget = target->GetSnapRectangle();
tracker->SetCursor(target->GetCursor());
}
else
{
- tracker->SetCursor(DnDTweaklet::CURSOR_INVALID);
+ tracker->SetCursor(CURSOR_INVALID);
}
// If snapping then reset the tracker's rectangle based on the current drop target
if (allowSnapping)
{
- if (snapTarget.width == 0 || snapTarget.height == 0)
+ if (snapTarget.width() < 0 || snapTarget.height() < 0)
{
- snapTarget = Rectangle(sourceBounds.x + location.x - initialLocation.x,
- sourceBounds.y + location.y - initialLocation.y, sourceBounds.width,
- sourceBounds.height);
+ snapTarget = QRect(sourceBounds.x() + location.x() - initialLocation.x(),
+ sourceBounds.y() + location.y() - initialLocation.y(), sourceBounds.width(),
+ sourceBounds.height());
}
// Try to prevent flicker: don't change the rectangles if they're already in
// the right location
- Rectangle currentRectangle = tracker->GetRectangle();
+ QRect currentRectangle = tracker->GetRectangle();
if (!(currentRectangle == snapTarget))
{
tracker->SetRectangle(snapTarget);
}
}
}
DragUtil::TargetListType::Pointer DragUtil::GetTargetList(void* control)
{
Object::Pointer data = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetData(
control, DROP_TARGET_ID);
TargetListType::Pointer list = data.Cast ();
return list;
}
IDropTarget::Pointer DragUtil::GetDropTarget(const QList& toSearch,
void* mostSpecificControl,
Object::Pointer draggedObject,
- const Point& position,
- const Rectangle& dragRectangle)
+ const QPoint& position,
+ const QRect& dragRectangle)
{
for (QList::const_iterator iter =
toSearch.begin(); iter != toSearch.end(); ++iter)
{
IDragOverListener* next = *iter;
IDropTarget::Pointer dropTarget = next->Drag(mostSpecificControl,
draggedObject, position, dragRectangle);
if (dropTarget != 0)
{
return dropTarget;
}
}
return IDropTarget::Pointer(0);
}
void DragUtil::AddDragTarget(void* control, IDragOverListener* target)
{
if (control == 0)
{
defaultTargets.push_back(target);
}
else
{
TargetListType::Pointer targetList = GetTargetList(control);
if (targetList == 0)
{
targetList = new TargetListType();
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetData(control, DROP_TARGET_ID,
targetList);
}
targetList->push_back(target);
}
}
void DragUtil::RemoveDragTarget(void* control, IDragOverListener* target)
{
if (control == 0)
{
defaultTargets.removeAll(target);
}
else
{
TargetListType::Pointer targetList = GetTargetList(control);
if (targetList != 0)
{
targetList->removeAll(target);
if (targetList->empty())
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetData(control,
DROP_TARGET_ID, Object::Pointer(0));
}
}
}
}
-Rectangle DragUtil::GetDisplayBounds(void* boundsControl)
+QRect DragUtil::GetDisplayBounds(void* boundsControl)
{
void* parent = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(
boundsControl);
if (parent == 0)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(boundsControl);
}
- Rectangle rect = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(
+ QRect rect = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(
boundsControl);
return Geometry::ToDisplay(parent, rect);
}
bool DragUtil::PerformDrag(Object::Pointer draggedItem,
- const Rectangle& sourceBounds, const Point& initialLocation,
+ const QRect& sourceBounds, const QPoint& initialLocation,
bool allowSnapping)
{
IDropTarget::Pointer target = DragToTarget(draggedItem, sourceBounds,
initialLocation, allowSnapping);
if (target == 0)
{
return false;
}
target->Drop();
target->DragFinished(true);
return true;
}
void DragUtil::ForceDropLocation(TestDropLocation::Pointer forcedLocation)
{
forcedDropTarget = forcedLocation;
}
IDropTarget::Pointer DragUtil::DragToTarget(Object::Pointer draggedItem,
- const Rectangle& sourceBounds, const Point& initialLocation,
+ const QRect& sourceBounds, const QPoint& initialLocation,
bool allowSnapping)
{
//final Display display = Display.getCurrent();
// Testing...immediately 'drop' onto the test target
if (forcedDropTarget != 0)
{
- Point location = forcedDropTarget->GetLocation();
+ QPoint location = forcedDropTarget->GetLocation();
void* currentControl =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->FindControl(
forcedDropTarget->GetShells(), location);
return GetDropTarget(currentControl, draggedItem, location, sourceBounds);
}
// Create a tracker. This is just an XOR rect on the screen.
// As it moves we notify the drag listeners.
- ITracker* tracker = Tweaklets::Get(DnDTweaklet::KEY)->CreateTracker();
+ QtTracker tracker;
//tracker.setStippled(true);
GuiTk::IControlListener::Pointer trackerListener(new TrackerMoveListener(
draggedItem, sourceBounds, initialLocation, allowSnapping));
- tracker->AddControlListener(trackerListener);
+ tracker.AddControlListener(trackerListener);
// Setup...when the drag starts we might already be over a valid target, check this...
// If there is a 'global' target then skip the check
IDropTarget::Pointer target;
void* startControl =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetCursorControl();
if (startControl != 0 && allowSnapping)
{
target = GetDropTarget(startControl, draggedItem, initialLocation,
sourceBounds);
}
// Set up an initial tracker rectangle
- Rectangle startRect = sourceBounds;
+ QRect startRect = sourceBounds;
if (target != 0)
{
- Rectangle rect = target->GetSnapRectangle();
+ QRect rect = target->GetSnapRectangle();
- if (rect.width != 0 && rect.height != 0)
+ if (rect.width() != 0 && rect.height() != 0)
{
startRect = rect;
}
- tracker->SetCursor(target->GetCursor());
+ tracker.SetCursor(target->GetCursor());
}
- if (startRect.width != 0 && startRect.height != 0)
+ if (startRect.width() != 0 && startRect.height() != 0)
{
- tracker->SetRectangle(startRect);
+ tracker.SetRectangle(startRect);
}
// Tracking Loop...tracking is preformed on the 'SWT.Move' listener registered
// against the tracker.
// // HACK:
// // Some control needs to capture the mouse during the drag or other
// // controls will interfere with the cursor
// Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
// if (shell != null)
// {
// shell.setCapture(true);
// }
// Run tracker until mouse up occurs or escape key pressed.
- bool trackingOk = tracker->Open();
+ bool trackingOk = tracker.Open();
// // HACK:
// // Release the mouse now
// if (shell != null)
// {
// shell.setCapture(false);
// }
// Done tracking...
// Get the current drop target
IDropTarget::Pointer dropTarget;
- Point finalLocation =
+ QPoint finalLocation =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetCursorLocation();
void* targetControl =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetCursorControl();
dropTarget = GetDropTarget(targetControl, draggedItem, finalLocation,
- tracker->GetRectangle());
+ tracker.GetRectangle());
// Cleanup...
- delete tracker;
+ //delete tracker;
// if we're going to perform a 'drop' then delay the issuing of the 'finished'
// callback until after it's done...
if (trackingOk)
{
return dropTarget;
}
else if (dropTarget != 0)
{
// If the target can handle a 'finished' notification then send one
dropTarget->DragFinished(false);
}
return IDropTarget::Pointer(0);
}
IDropTarget::Pointer DragUtil::GetDropTarget(void* toSearch,
- Object::Pointer draggedObject, const Point& position,
- const Rectangle& dragRectangle)
+ Object::Pointer draggedObject, const QPoint& position,
+ const QRect& dragRectangle)
{
// Search for a listener by walking the control's parent hierarchy
for (void* current = toSearch; current != 0; current = Tweaklets::Get(
GuiWidgetsTweaklet::KEY)->GetParent(current))
{
TargetListType::Pointer targetList = GetTargetList(current);
QList targets;
if (targetList != 0)
targets = *targetList;
IDropTarget::Pointer dropTarget = GetDropTarget(targets, toSearch,
draggedObject, position, dragRectangle);
if (dropTarget != 0)
{
return dropTarget;
}
// // Don't look to parent shells for drop targets
// if (current instanceof Shell) {
// break;
// }
}
// No controls could handle this event -- check for default targets
return GetDropTarget(defaultTargets, toSearch, draggedObject, position,
dragRectangle);
}
-//Point DragUtil::GetEventLoc(GuiTk::ControlEvent::Pointer event)
+//QPoint DragUtil::GetEventLoc(GuiTk::ControlEvent::Pointer event)
//{
// Control ctrl = (Control) event.widget;
-// return ctrl.toDisplay(new Point(event.x, event.y));
+// return ctrl.toDisplay(new QPoint(event.x, event.y));
//}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDragUtil.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDragUtil.h
index 02ae03ceed..4df7ba7b62 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDragUtil.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDragUtil.h
@@ -1,214 +1,215 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYDRAGUTIL_H_
#define BERRYDRAGUTIL_H_
#include
-#include "berryRectangle.h"
#include "guitk/berryGuiTkIControlListener.h"
#include "berryTestDropLocation.h"
#include "berryIDragOverListener.h"
#include "berryIDropTarget.h"
#include
-#include
+
+#include
+#include
namespace berry {
/**
* Provides the methods for attaching drag-and-drop listeners to SWT controls.
*/
class BERRY_UI_QT DragUtil
{
public:
typedef ObjectList TargetListType;
private:
static const QString DROP_TARGET_ID;
/**
* The location where all drags will end. If this is non-null, then
* all user input is ignored in drag/drop. If null, we use user input
* to determine where objects should be dropped.
*/
static TestDropLocation::Pointer forcedDropTarget;
/**
* List of IDragOverListener
*/
static QList defaultTargets;
/**
* Return the list of 'IDragOverListener' elements associated with
* the given control. If there's a 'global' listener then always
* return it.
*
* @param control
* @return
*/
static TargetListType::Pointer GetTargetList(void* control);
/**
* Given a list of IDragOverListeners and a description of what is being dragged, it returns
* a IDropTarget for the current drop.
*
* @param toSearch
* @param mostSpecificControl
* @param draggedObject
* @param position
* @param dragRectangle
* @return
*/
static IDropTarget::Pointer GetDropTarget(const QList& toSearch,
- void* mostSpecificControl, Object::Pointer draggedObject, const Point &position,
- const Rectangle& dragRectangle);
+ void* mostSpecificControl, Object::Pointer draggedObject, const QPoint &position,
+ const QRect& dragRectangle);
struct TrackerMoveListener : public GuiTk::IControlListener {
- TrackerMoveListener(Object::Pointer draggedItem, const Rectangle& sourceBounds,
- const Point& initialLocation, bool allowSnapping);
+ TrackerMoveListener(Object::Pointer draggedItem, const QRect& sourceBounds,
+ const QPoint& initialLocation, bool allowSnapping);
Events::Types GetEventTypes() const;
void ControlMoved(GuiTk::ControlEvent::Pointer event);
private:
bool allowSnapping;
Object::Pointer draggedItem;
- Rectangle sourceBounds;
- Point initialLocation;
+ QRect sourceBounds;
+ QPoint initialLocation;
};
public:
/**
* Sets the drop target for the given control. It is possible to add one or more
* targets for a "null" control. This becomes a default target that is used if no
* other targets are found (for example, when dragging objects off the application
* window).
*
* @param control the control that should be treated as a drag target, or null
* to indicate the default target
* @param target the drag target to handle the given control
*/
static void AddDragTarget(void* control, IDragOverListener* target);
/**
* Removes a drop target from the given control.
*
* @param control
* @param target
*/
static void RemoveDragTarget(void* control, IDragOverListener* target);
/**
* Shorthand method. Returns the bounding rectangle for the given control, in
* display coordinates.
*
* @param draggedItem
* @param boundsControl
* @return
*/
- static Rectangle GetDisplayBounds(void* boundsControl);
+ static QRect GetDisplayBounds(void* boundsControl);
static bool PerformDrag(Object::Pointer draggedItem,
- const Rectangle& sourceBounds, const Point& initialLocation, bool allowSnapping);
+ const QRect& sourceBounds, const QPoint& initialLocation, bool allowSnapping);
// /**
// * Drags the given item to the given location (in display coordinates). This
// * method is intended for use by test suites.
// *
// * @param draggedItem object being dragged
// * @param finalLocation location being dragged to
// * @return true iff the drop was accepted
// */
// static bool DragTo(Display display, Object draggedItem,
-// Point finalLocation, Rectangle dragRectangle) {
+// QPoint finalLocation, QRect dragRectangle) {
// Control currentControl = SwtUtil.findControl(display, finalLocation);
//
// IDropTarget target = getDropTarget(currentControl, draggedItem,
// finalLocation, dragRectangle);
//
// if (target == null) {
// return false;
// }
//
// target.drop();
//
// return true;
// }
/**
* Forces all drags to end at the given position (display coordinates). Intended
* for use by test suites. If this method is called, then all subsequent calls
* to performDrag will terminate immediately and behave as though the object were
* dragged to the given location. Calling this method with null cancels this
* behavior and causes performDrag to behave normally.
*
* @param forcedLocation location where objects will be dropped (or null to
* cause drag/drop to behave normally).
*/
static void ForceDropLocation(TestDropLocation::Pointer forcedLocation);
/**
* Drags the given item, given an initial bounding rectangle in display coordinates.
* Due to a quirk in the Tracker class, changing the tracking rectangle when using the
* keyboard will also cause the mouse cursor to move. Since "snapping" causes the tracking
* rectangle to change based on the position of the mouse cursor, it is impossible to do
* drag-and-drop with the keyboard when snapping is enabled.
*
* @param draggedItem object being dragged
* @param sourceBounds initial bounding rectangle for the dragged item
* @param initialLocation initial position of the mouse cursor
* @param allowSnapping true iff the rectangle should snap to the drop location. This must
* be false if the user might be doing drag-and-drop using the keyboard.
*
* @return
*/
static IDropTarget::Pointer DragToTarget(Object::Pointer draggedItem,
- const Rectangle& sourceBounds, const Point& initialLocation,
+ const QRect& sourceBounds, const QPoint& initialLocation,
bool allowSnapping);
/**
* Returns the drag target for the given control or null if none.
*
* @param toSearch
* @param e
* @return
*/
static IDropTarget::Pointer GetDropTarget(void* toSearch,
- Object::Pointer draggedObject, const Point& position, const Rectangle& dragRectangle);
+ Object::Pointer draggedObject, const QPoint& position, const QRect& dragRectangle);
/**
* Returns the location of the given event, in display coordinates
* @return
*/
- //static Point GetEventLoc(GuiTk::ControlEvent::Pointer event);
+ //static QPoint GetEventLoc(GuiTk::ControlEvent::Pointer event);
};
}
#endif /* BERRYDRAGUTIL_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorSashContainer.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorSashContainer.cpp
index 132f5ce9a2..9ff0db04d8 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorSashContainer.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorSashContainer.cpp
@@ -1,609 +1,609 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryEditorSashContainer.h"
#include "berryPresentationSerializer.h"
#include "berryWorkbenchConstants.h"
#include "berryWorkbenchPlugin.h"
#include "berryLayoutTree.h"
#include "berryWorkbenchWindowConfigurer.h"
#include "berryWorkbenchWindow.h"
#include "berryQtDnDControlWidget.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include
#include
namespace berry
{
const QString EditorSashContainer::DEFAULT_WORKBOOK_ID =
"DefaultEditorWorkbook";
void EditorSashContainer::AddChild(const RelationshipInfo& info)
{
PartSashContainer::AddChild(info);
this->UpdateStackButtons();
}
void EditorSashContainer::ChildAdded(LayoutPart::Pointer child)
{
PartSashContainer::ChildAdded(child);
if (child.Cast () != 0)
{
editorWorkbooks.push_back(child.Cast ());
}
}
void EditorSashContainer::ChildRemoved(LayoutPart::Pointer child)
{
PartSashContainer::ChildRemoved(child);
if (child.Cast () != 0)
{
editorWorkbooks.removeAll(child.Cast());
if (activeEditorWorkbook == child)
{
this->SetActiveWorkbook(PartStack::Pointer(0), false);
}
this->UpdateStackButtons();
}
}
PartStack::Pointer EditorSashContainer::CreateDefaultWorkbook()
{
PartStack::Pointer newWorkbook = this->NewEditorWorkbook();
newWorkbook->SetID(DEFAULT_WORKBOOK_ID);
this->Add(newWorkbook);
return newWorkbook;
}
void EditorSashContainer::AddDropSupport()
{
WorkbenchWindowConfigurer::Pointer winConfigurer = page->GetWorkbenchWindow().Cast()->GetWindowConfigurer();
QtDnDControlWidget* dropWidget = static_cast(GetParent());
dropWidget->SetTransferTypes(winConfigurer->GetTransfers());
dropWidget->AddDropListener(winConfigurer->GetDropTargetListener());
}
PartStack::Pointer EditorSashContainer::NewEditorWorkbook()
{
PartStack::Pointer newWorkbook(new PartStack(page, true, PresentationFactoryUtil::ROLE_EDITOR));
QString str;
QTextStream buf(&str);
buf << newWorkbook->GetClassName() << newWorkbook.GetPointer();
newWorkbook->SetID(str);
return newWorkbook;
}
void* EditorSashContainer::CreateParent(void* parentWidget)
{
//return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->CreateComposite(parentWidget);
return new QtDnDControlWidget(static_cast(parentWidget));
}
void EditorSashContainer::DisposeParent()
{
this->parent = 0;
}
bool EditorSashContainer::IsActiveWorkbook(PartStack::Pointer workbook)
{
return activeEditorWorkbook == workbook;
}
PartStack::Pointer EditorSashContainer::CreateStack()
{
return this->NewEditorWorkbook();
}
void EditorSashContainer::SetVisiblePart(
ILayoutContainer::Pointer container, PartPane::Pointer visiblePart)
{
PartStack::Pointer stack = container.Cast();
if (stack == 0) return;
stack->GetContainer().Cast()->SetActiveWorkbook(stack, true);
stack->SetSelection(visiblePart);
}
LayoutPart::Pointer EditorSashContainer::GetVisiblePart(
ILayoutContainer::Pointer container)
{
PartStack::Pointer refPart = container.Cast();
return refPart->GetSelection();
}
EditorSashContainer::EditorSashContainer(const QString& editorId,
WorkbenchPage* page, void* parent)
: PartSashContainer(editorId, page, parent)
{
this->CreateDefaultWorkbook();
}
bool EditorSashContainer::AllowsAdd(LayoutPart::Pointer layoutPart)
{
return LayoutPart::AllowsAdd(layoutPart);
}
void EditorSashContainer::AddEditor(PartPane::Pointer pane,
PartStack::Pointer stack)
{
//EditorStack workbook = getActiveWorkbook();
stack->Add(pane);
}
void EditorSashContainer::UpdateStackButtons()
{
// // This is applicable only when the new
// // min/max behaviour is being used
// Perspective persp = getPage().getActivePerspective();
// if (!Perspective.useNewMinMax(persp))
// return;
//
// // Find the upper Right editor stack
// LayoutPart[] stacks = getChildren();
// EditorStack winner = getUpperRightEditorStack(stacks);
//
// // Now hide the buttons for all but the upper right stack
// for (int i = 0; i < stacks.length; i++)
// {
// if (!(stacks[i] instanceof EditorStack)
// )
// continue;
// ((EditorStack) stacks[i]).showMinMax(stacks[i] == winner);
// }
//
// // Force the stack's presentation state to match its perspective
// persp.refreshEditorAreaVisibility();
}
PartStack::Pointer EditorSashContainer::GetUpperRightEditorStack()
{
return this->GetUpperRightEditorStack(this->GetChildren());
}
PartStack::Pointer EditorSashContainer::GetUpperRightEditorStack(
const ILayoutContainer::ChildrenType& stacks)
{
// Find the upper Right editor stack
PartStack::Pointer winner;
- Rectangle winnerRect;
+ QRect winnerRect;
for (ILayoutContainer::ChildrenType::const_iterator iter = stacks.begin();
iter != stacks.end(); ++iter)
{
LayoutPart::Pointer part = *iter;
if (part.Cast() == 0)
continue;
PartStack::Pointer stack = part.Cast();
- Rectangle bb = stack->GetBounds();
- if (iter == stacks.begin() || bb.y < winnerRect.y || (bb.y == winnerRect.y && bb.x
- > winnerRect.x))
+ QRect bb = stack->GetBounds();
+ if (iter == stacks.begin() || bb.y() < winnerRect.y() || (bb.y() == winnerRect.y() && bb.x()
+ > winnerRect.x()))
{
winner = stack;
winnerRect = bb;
}
}
return winner;
}
PartStack::Pointer EditorSashContainer::GetActiveWorkbook()
{
if (activeEditorWorkbook == 0)
{
if (editorWorkbooks.size() < 1)
{
this->SetActiveWorkbook(this->CreateDefaultWorkbook(), false);
}
else
{
this->SetActiveWorkbook(editorWorkbooks.front(), false);
}
}
return activeEditorWorkbook;
}
QString EditorSashContainer::GetActiveWorkbookID()
{
return this->GetActiveWorkbook()->GetID();
}
QList EditorSashContainer::GetEditorWorkbooks()
{
return editorWorkbooks;
}
std::size_t EditorSashContainer::GetEditorWorkbookCount()
{
return editorWorkbooks.size();
}
void EditorSashContainer::FindSashes(LayoutPart::Pointer pane,
PartPane::Sashes& sashes)
{
//Find the sashes around the current editor and
//then the sashes around the editor area.
PartSashContainer::FindSashes(pane, sashes);
ILayoutContainer::Pointer container = this->GetContainer();
if (container != 0)
{
container->FindSashes(LayoutPart::Pointer(this), sashes);
}
}
void EditorSashContainer::RemoveAllEditors()
{
PartStack::Pointer currentWorkbook = this->GetActiveWorkbook();
// Iterate over a copy so the original can be modified.
QList workbooks(editorWorkbooks);
for (QList::iterator iter = workbooks.begin();
iter != workbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
QList children = workbook->GetChildren();
for (QList::iterator childIter = children.begin();
childIter != children.end(); ++childIter)
{
workbook->Remove(*childIter);
}
if (workbook != currentWorkbook)
{
this->Remove(workbook);
workbook->Dispose();
}
}
}
void EditorSashContainer::RemoveEditor(PartPane::Pointer pane)
{
PartStack::Pointer workbook = pane->GetContainer().Cast();
if (workbook == 0)
{
return;
}
workbook->Remove(pane);
// remove the editor workbook if empty
if (workbook->GetItemCount() < 1 /* && editorWorkbooks.size() > 1*/)
{
// // If the user closes the last editor and the editor area
// // is maximized, restore it
// Perspective persp = getPage().getActivePerspective();
// if (Perspective.useNewMinMax(persp))
// {
// if (persp.getPresentation().getMaximizedStack() instanceof EditorStack)
// persp.getPresentation().getMaximizedStack().
// setState(IStackPresentationSite.STATE_RESTORED);
// }
this->Remove(workbook);
workbook->Dispose();
}
}
bool EditorSashContainer::RestoreState(IMemento::Pointer memento)
{
//TODO EditorSashContainer restore state
// MultiStatus
// result =
// new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, WorkbenchMessages.RootLayoutContainer_problemsRestoringPerspective, 0);
bool result = true;
// Remove the default editor workbook that is
// initialy created with the editor area.
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
//
// public void runWithException() throws Throwable
// {
PartStack::Pointer defaultWorkbook;
for (ILayoutContainer::ChildrenType::iterator i = children.begin();
i != children.end(); ++i)
{
LayoutPart::Pointer child = *i;
if (child->GetID() == DEFAULT_WORKBOOK_ID)
{
defaultWorkbook = child.Cast();
if (defaultWorkbook->GetItemCount() > 0)
{
defaultWorkbook = 0;
}
}
}
if (defaultWorkbook)
{
Remove(defaultWorkbook);
}
// }}
// );
// Restore the relationship/layout
QList infos(memento->GetChildren(WorkbenchConstants::TAG_INFO));
QHash mapIDtoPart;
for (int i = 0; i < infos.size(); i++)
{
// Get the info details.
IMemento::Pointer childMem = infos[i];
QString partID; childMem->GetString(WorkbenchConstants::TAG_PART, partID);
QString relativeID; childMem->GetString(WorkbenchConstants::TAG_RELATIVE, relativeID);
int relationship = 0;
int left = 0, right = 0;
if (!relativeID.isEmpty())
{
childMem->GetInteger(WorkbenchConstants::TAG_RELATIONSHIP, relationship);
childMem->GetInteger(WorkbenchConstants::TAG_RATIO_LEFT, left);
childMem->GetInteger(WorkbenchConstants::TAG_RATIO_RIGHT, right);
}
PartStack::Pointer workbook;
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
//
// public void runWithException() throws Throwable
// {
// Create the part.
workbook = NewEditorWorkbook();
workbook->SetID(partID);
// 1FUN70C: ITPUI:WIN - Shouldn't set Container when not active
workbook->SetContainer(ILayoutContainer::Pointer(this));
// }}
// );
IMemento::Pointer workbookMemento = childMem->GetChild(
WorkbenchConstants::TAG_FOLDER);
if (workbookMemento)
{
//result.add(workbook[0].restoreState(workbookMemento));
result &= workbook->RestoreState(workbookMemento);
}
const int myLeft = left, myRight = right, myRelationship = relationship;
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
//
// public void runWithException() throws Throwable
// {
// Add the part to the layout
if (relativeID.isEmpty())
{
Add(workbook);
}
else
{
LayoutPart::Pointer refPart = mapIDtoPart[relativeID];
if (refPart)
{
Add(workbook, myRelationship, myLeft, myRight, refPart);
}
else
{
WorkbenchPlugin::Log("Unable to find part for ID: " + relativeID);
}
}
// }}
// );
mapIDtoPart[partID] = workbook;
}
return result;
}
bool EditorSashContainer::SaveState(IMemento::Pointer memento)
{
QList relationships(ComputeRelation());
// MultiStatus
// result =
// new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, WorkbenchMessages.RootLayoutContainer_problemsSavingPerspective, 0);
bool result = true;
for (int i = 0; i < relationships.size(); i++)
{
// Save the relationship info ..
// private LayoutPart part;
// private int relationship;
// private float ratio;
// private LayoutPart relative;
const RelationshipInfo& info = relationships[i];
IMemento::Pointer childMem = memento->CreateChild(
WorkbenchConstants::TAG_INFO);
childMem->PutString(WorkbenchConstants::TAG_PART, info.part->GetID());
PartStack::Pointer stack = info.part.Cast();
if (stack)
{
IMemento::Pointer folderMem = childMem->CreateChild(
WorkbenchConstants::TAG_FOLDER);
//result.add(stack.saveState(folderMem));
result &= stack->SaveState(folderMem);
}
if (info.relative != 0)
{
childMem->PutString(WorkbenchConstants::TAG_RELATIVE, info.relative->GetID());
childMem->PutInteger(WorkbenchConstants::TAG_RELATIONSHIP, info.relationship);
childMem->PutInteger(WorkbenchConstants::TAG_RATIO_LEFT, info.left);
childMem->PutInteger(WorkbenchConstants::TAG_RATIO_RIGHT, info.right);
}
}
return result;
}
void EditorSashContainer::SetActiveWorkbook(PartStack::Pointer newWorkbook,
bool hasFocus)
{
if (newWorkbook != 0)
{
if (std::find(editorWorkbooks.begin(), editorWorkbooks.end(), newWorkbook) == editorWorkbooks.end())
{
return;
}
}
PartStack::Pointer oldWorkbook = activeEditorWorkbook;
activeEditorWorkbook = newWorkbook;
if (oldWorkbook != 0 && oldWorkbook != newWorkbook)
{
oldWorkbook->SetActive(StackPresentation::AS_INACTIVE);
}
if (newWorkbook != 0)
{
if (hasFocus)
{
newWorkbook->SetActive(StackPresentation::AS_ACTIVE_FOCUS);
}
else
{
newWorkbook->SetActive(StackPresentation::AS_ACTIVE_NOFOCUS);
}
}
this->UpdateTabList();
}
void EditorSashContainer::SetActiveWorkbookFromID(const QString& id)
{
for (QList::iterator iter = editorWorkbooks.begin();
iter != editorWorkbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
if (workbook->GetID() == id)
{
this->SetActiveWorkbook(workbook, false);
}
}
}
PartStack::Pointer EditorSashContainer::GetWorkbookFromID(const QString& id)
{
for (QList::iterator iter = editorWorkbooks.begin();
iter != editorWorkbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
if (workbook->GetID() == id)
{
return workbook;
}
}
return PartStack::Pointer(0);
}
void EditorSashContainer::UpdateTabList()
{
void* parent = this->GetParent();
if (parent != 0)
{ // parent may be 0 on startup
PartStack::Pointer wb(this->GetActiveWorkbook());
//TODO EditorSashContainer update tab list
// if (wb == 0)
// {
// parent.setTabList(new Control[0]);
// }
// else
// {
// parent.setTabList(wb.getTabList());
// }
}
}
void EditorSashContainer::CreateControl(void* parent)
{
PartSashContainer::CreateControl(parent);
///let the user drop files/editor input on the editor area
this->AddDropSupport();
}
bool EditorSashContainer::IsCompressible()
{
//Added for bug 19524
return true;
}
bool EditorSashContainer::IsStackType(ILayoutContainer::Pointer toTest)
{
if (toTest.Cast() == 0)
return false;
return (toTest.Cast ()->GetAppearance()
== PresentationFactoryUtil::ROLE_EDITOR);
}
bool EditorSashContainer::IsPaneType(LayoutPart::Pointer toTest)
{
if (toTest.Cast() == 0)
return false;
return (toTest.Cast ()->GetPartReference().Cast ()
!= 0);
}
bool EditorSashContainer::RestorePresentationState(IMemento::Pointer /*areaMem*/)
{
QList workbooks = this->GetEditorWorkbooks();
for (QList::iterator iter = workbooks.begin();
iter != workbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
IMemento::Pointer memento = workbook->GetSavedPresentationState();
if (memento == 0)
{
continue;
}
QList parts = workbook->GetPresentableParts();
PresentationSerializer serializer(parts);
//StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
// public void runWithException() throws Throwable
// {
workbook->GetPresentation()->RestoreState(&serializer, memento);
// }}
// );
}
//return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", 0); //$NON-NLS-1$
return true;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryIDragOverListener.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryIDragOverListener.h
index 8ecc015846..9e5ddeea3e 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryIDragOverListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryIDragOverListener.h
@@ -1,67 +1,65 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYIDRAGOVERLISTENER_H_
#define BERRYIDRAGOVERLISTENER_H_
#include
-#include "berryPoint.h"
-#include "berryRectangle.h"
-
+#include "berryObject.h"
#include "berryIDropTarget.h"
namespace berry {
/**
* Implementers of this interface will receive notifications when objects are dragged over
* a particular control.
*/
struct IDragOverListener
{
struct Events {
- typedef Message4 DragEventType;
- typedef MessageDelegate4 DragDelegate;
+ typedef Message4 DragEventType;
+ typedef MessageDelegate4 DragDelegate;
DragEventType drag;
void AddListener(IDragOverListener* listener);
void RemoveListener(IDragOverListener* listener);
};
virtual ~IDragOverListener();
/**
* Notifies the receiver that the given object has been dragged over
* the given position. Returns a drop target if the object may be
* dropped in this position. Returns null otherwise.
*
* @param draggedObject object being dragged over this location
* @param position location of the cursor
* @param dragRectangle current drag rectangle (may be an empty rectangle if none)
* @return a valid drop target or null if none
*/
virtual IDropTarget::Pointer Drag(void* currentControl, const Object::Pointer& draggedObject,
- const Point& position, const Rectangle& dragRectangle) = 0;
+ const QPoint& position, const QRect& dragRectangle) = 0;
};
}
#endif /* BERRYIDRAGOVERLISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryIDropTarget.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryIDropTarget.h
index 0304b77b5d..f2e3d0ddb8 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryIDropTarget.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryIDropTarget.h
@@ -1,71 +1,73 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYIDROPTARGET_H_
#define BERRYIDROPTARGET_H_
#include
+#include
+#include
-#include "berryRectangle.h"
-#include "tweaklets/berryDnDTweaklet.h"
+#include
namespace berry {
/**
* This interface is used to drop objects. It knows how to drop a particular object
* in a particular location. IDropTargets are typically created by IDragOverListeners, and
* it is the job of the IDragOverListener to supply the drop target with information about
* the object currently being dragged.
*
* @see IDragOverListener
*/
-struct BERRY_UI_QT IDropTarget : public Object {
+struct BERRY_UI_QT IDropTarget : public Object
+{
- berryObjectMacro(IDropTarget);
+ berryObjectMacro(IDropTarget)
~IDropTarget();
/**
* Drops the object in this position
*/
virtual void Drop() = 0;
/**
* Returns a cursor id describing this drop operation
*
* @return a cursor id describing this drop operation
*/
- virtual DnDTweaklet::CursorType GetCursor() = 0;
+ virtual CursorType GetCursor() = 0;
/**
* Returns a rectangle (screen coordinates) describing the target location
* for this drop operation.
*
* @return a snap rectangle or null if this drop target does not have a specific snap
* location.
*/
- virtual Rectangle GetSnapRectangle() = 0;
+ virtual QRect GetSnapRectangle() = 0;
/**
* This is called whenever a drag operation is cancelled
*/
virtual void DragFinished(bool dropPerformed) = 0;
};
}
#endif /* BERRYIDROPTARGET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPart.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPart.cpp
index 00fc90488c..cfbb0c9b37 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPart.cpp
@@ -1,347 +1,345 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryLayoutPart.h"
#include "berryILayoutContainer.h"
#include "berryDetachedWindow.h"
#include "berryIWorkbenchWindow.h"
#include "berryConstants.h"
namespace berry
{
const QString LayoutPart::PROP_VISIBILITY = "PROP_VISIBILITY";
LayoutPart::LayoutPart(const QString& id_)
: container(0), id(id_), deferCount(0)
{
}
LayoutPart::~LayoutPart()
{
}
bool LayoutPart::AllowsAutoFocus()
{
if (container != 0)
{
return container->AllowsAutoFocus();
}
return true;
}
void LayoutPart::Dispose()
{
}
-Rectangle LayoutPart::GetBounds()
+QRect LayoutPart::GetBounds()
{
if (this->GetControl() == 0)
- return Rectangle();
+ return QRect();
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetControl());
}
ILayoutContainer::Pointer LayoutPart::GetContainer()
{
return ILayoutContainer::Pointer(container);
}
bool LayoutPart::IsPlaceHolder() const
{
return false;
}
QString LayoutPart::GetID() const
{
return id;
}
bool LayoutPart::IsCompressible()
{
return false;
}
-Point LayoutPart::GetSize()
+QSize LayoutPart::GetSize()
{
- Rectangle r = this->GetBounds();
- Point ptSize(r.width, r.height);
- return ptSize;
+ return this->GetBounds().size();
}
int LayoutPart::GetSizeFlags(bool /*horizontal*/)
{
return Constants::MIN;
}
int LayoutPart::ComputePreferredSize(bool /*width*/, int /*availableParallel*/,
int /*availablePerpendicular*/, int preferredParallel)
{
return preferredParallel;
}
-IDropTarget::Pointer LayoutPart::GetDropTarget(Object::Pointer /*draggedObject*/, const Point& /*displayCoordinates*/)
+IDropTarget::Pointer LayoutPart::GetDropTarget(Object::Pointer /*draggedObject*/, const QPoint& /*displayCoordinates*/)
{
return IDropTarget::Pointer(0);
}
bool LayoutPart::IsDocked()
{
Shell::Pointer s = this->GetShell();
if (s == 0) {
return false;
}
return s->GetData().Cast() != 0;
}
Shell::Pointer LayoutPart::GetShell()
{
void* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetShell(ctrl);
}
return Shell::Pointer(0);
}
IWorkbenchWindow::Pointer LayoutPart::GetWorkbenchWindow()
{
Shell::Pointer s = this->GetShell();
if (s == 0)
{
return IWorkbenchWindow::Pointer(0);
}
Object::Pointer data = s->GetData();
if (data.Cast() != 0)
{
return data.Cast();
}
else if (data.Cast() != 0)
{
return data.Cast()->GetWorkbenchPage()->GetWorkbenchWindow();
}
return IWorkbenchWindow::Pointer(0);
}
void LayoutPart::MoveAbove(void* /*refControl*/)
{
}
void LayoutPart::Reparent(void* newParent)
{
void* control = this->GetControl();
GuiWidgetsTweaklet* guiTweaklet = Tweaklets::Get(GuiWidgetsTweaklet::KEY);
if ((control == 0) || (guiTweaklet->GetParent(control) == newParent))
{
return;
}
if (guiTweaklet->IsReparentable(control))
{
// make control small in case it is not resized with other controls
//control.setBounds(0, 0, 0, 0);
// By setting the control to disabled before moving it,
// we ensure that the focus goes away from the control and its children
// and moves somewhere else
bool enabled = guiTweaklet->GetEnabled(control);
guiTweaklet->SetEnabled(control, false);
guiTweaklet->SetParent(control, newParent);
guiTweaklet->SetEnabled(control, enabled);
guiTweaklet->MoveAbove(control, 0);
}
}
bool LayoutPart::GetVisible()
{
void* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetVisible(ctrl);
}
return false;
}
bool LayoutPart::IsVisible()
{
void* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->IsVisible(ctrl);
}
return false;
}
void LayoutPart::SetVisible(bool makeVisible)
{
void* ctrl = this->GetControl();
if (ctrl != 0)
{
if (makeVisible == Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetVisible(ctrl))
{
return;
}
// if (!makeVisible && this->IsFocusAncestor(ctrl))
// {
// // Workaround for Bug 60970 [EditorMgmt] setActive() called on an editor when it does not have focus.
// // Force focus on the shell so that when ctrl is hidden,
// // SWT does not try to send focus elsewhere, which may cause
// // some other part to be activated, which affects the part
// // activation order and can cause flicker.
// ctrl.getShell().forceFocus();
// }
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(ctrl, makeVisible);
}
}
bool LayoutPart::IsFocusAncestor(void* /*ctrl*/)
{
// Control f = ctrl.getDisplay().getFocusControl();
// while (f != null && f != ctrl)
// {
// f = f.getParent();
// }
// return f == ctrl;
return false;
}
-void LayoutPart::SetBounds(const Rectangle& r)
+void LayoutPart::SetBounds(const QRect& r)
{
void* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetBounds(ctrl, r);
}
}
void LayoutPart::SetContainer(ILayoutContainer::Pointer container)
{
this->container = container.GetPointer();
//TODO Zoom
// if (container != 0)
// {
// setZoomed(container.childIsZoomed(this));
// }
}
void LayoutPart::SetFocus()
{
}
void LayoutPart::SetID(const QString& str)
{
id = str;
}
LayoutPart::Pointer LayoutPart::GetPart()
{
return LayoutPart::Pointer(this);
}
void LayoutPart::DeferUpdates(bool shouldDefer)
{
if (shouldDefer)
{
if (deferCount == 0)
{
this->StartDeferringEvents();
}
deferCount++;
}
else
{
if (deferCount> 0)
{
deferCount--;
if (deferCount == 0)
{
this->HandleDeferredEvents();
}
}
}
}
void LayoutPart::StartDeferringEvents()
{
}
void LayoutPart::HandleDeferredEvents()
{
}
bool LayoutPart::IsDeferred()
{
return deferCount> 0;
}
void LayoutPart::DescribeLayout(QString& /*buf*/) const
{
}
QString LayoutPart::GetPlaceHolderId()
{
return this->GetID();
}
void LayoutPart::ResizeChild(LayoutPart::Pointer /*childThatChanged*/)
{
}
void LayoutPart::FlushLayout()
{
ILayoutContainer::Pointer container = this->GetContainer();
if (container != 0)
{
container->ResizeChild(LayoutPart::Pointer(this));
}
}
bool LayoutPart::AllowsAdd(LayoutPart::Pointer /*toAdd*/)
{
return false;
}
QString LayoutPart::ToString() const
{
return "";
}
void LayoutPart::TestInvariants()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPart.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPart.h
index 182d188152..86d5c4eb0f 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPart.h
@@ -1,305 +1,303 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYLAYOUTPART_H_
#define BERRYLAYOUTPART_H_
#include
#include "berryIDropTarget.h"
#include "berryISizeProvider.h"
-#include "berryRectangle.h"
-#include "berryPoint.h"
#include "berryShell.h"
namespace berry {
struct ILayoutContainer;
struct IWorkbenchWindow;
/**
* \ingroup org_blueberry_ui_internal
*
* A presentation part is used to build the presentation for the
* workbench. Common subclasses are pane and folder.
*/
class LayoutPart : virtual public Object, public virtual ISizeProvider
{
public:
berryObjectMacro(LayoutPart)
protected: ILayoutContainer* container;
protected: QString id;
public: static const QString PROP_VISIBILITY;// = "PROP_VISIBILITY";
/**
* Number of times deferUpdates(true) has been called without a corresponding
* deferUpdates(false)
*/
private: int deferCount;
/**
* PresentationPart constructor comment.
*/
public: LayoutPart(const QString& id);
public: virtual ~LayoutPart();
/**
* When a layout part closes, focus will return to a previously active part.
* This method determines whether this part should be considered for activation
* when another part closes. If a group of parts are all closing at the same time,
* they will all return false from this method while closing to ensure that the
* parent does not activate a part that is in the process of closing. Parts will
* also return false from this method if they are minimized, closed fast views,
* obscured by zoom, etc.
*
* @return true iff the parts in this container may be given focus when the active
* part is closed
*/
public: virtual bool AllowsAutoFocus();
/**
* Creates the GUI control
*/
public: virtual void CreateControl(void* parent) = 0;
/**
* Disposes the GUI control
*
* This can be used to execute cleanup code or notify listeners
* when a LayoutPart is no longer used, but is still referenced
* by a SmartPointer (instead of putting the code in the LayoutPart
* destructor).
*/
public: virtual void Dispose();
/**
* Gets the presentation bounds.
*/
- public: Rectangle GetBounds();
+ public: QRect GetBounds();
/**
* Gets the parent for this part.
*
* In general, this is non-null if the object has been added to a container and the
* container's widgetry exists. The exception to this rule is PartPlaceholders
* created when restoring a ViewStack using restoreState, which point to the
* ViewStack even if its widgetry doesn't exist yet. Returns null in the remaining
* cases.
*
*
* TODO: change the semantics of this method to always point to the parent container,
* regardless of whether its widgetry exists. Locate and refactor code that is currently
* depending on the special cases.
*
*/
public: virtual SmartPointer GetContainer();
/**
* Get the part control. This method may return null.
*/
public: virtual void* GetControl() = 0;
public: virtual bool IsPlaceHolder() const;
/**
* Gets the ID for this part.
*/
public: virtual QString GetID() const;
public: virtual bool IsCompressible();
/**
* Gets the presentation size.
*/
- public: virtual Point GetSize();
+ public: virtual QSize GetSize();
/**
* @see org.blueberry.ui.presentations.StackPresentation#getSizeFlags(boolean)
*
* @since 3.1
*/
public: virtual int GetSizeFlags(bool horizontal);
/**
* @see org.blueberry.ui.presentations.StackPresentation#computePreferredSize(boolean, int, int, int)
*
* @since 3.1
*/
public: virtual int ComputePreferredSize(bool width, int availableParallel, int availablePerpendicular, int preferredParallel);
- public: virtual IDropTarget::Pointer GetDropTarget(Object::Pointer draggedObject, const Point& displayCoordinates);
+ public: virtual IDropTarget::Pointer GetDropTarget(Object::Pointer draggedObject, const QPoint& displayCoordinates);
public: bool IsDocked();
public: virtual Shell::Pointer GetShell();
/**
* Returns the workbench window window for a part.
*
* @return the workbench window, or null
if there's no window
* associated with this part.
*/
public: virtual SmartPointer GetWorkbenchWindow();
/**
* Move the control over another one.
*/
public: virtual void MoveAbove(void* refControl);
/**
* Reparent a part.
*/
public: virtual void Reparent(void* newParent);
/**
* Returns true if this part was set visible. This returns whatever was last passed into
* setVisible, but does not necessarily indicate that the part can be seen (ie: one of its
* ancestors may be invisible)
*/
public: virtual bool GetVisible();
/**
* Returns true if this part can be seen. Returns false if the part or any of its ancestors
* are invisible.
*/
public: virtual bool IsVisible();
/**
* Shows the receiver if visible
is true otherwise hide it.
*/
public: virtual void SetVisible(bool makeVisible);
/**
* Returns true
if the given control or any of its descendents has focus.
*/
private: virtual bool IsFocusAncestor(void* ctrl);
/**
* Sets the presentation bounds.
*/
- public: virtual void SetBounds(const Rectangle& r);
+ public: virtual void SetBounds(const QRect& r);
/**
* Sets the parent for this part.
*/
public: virtual void SetContainer(SmartPointer container);
/**
* Sets focus to this part.
*/
public: virtual void SetFocus();
/**
* Sets the part ID.
*/
public: virtual void SetID(const QString& str);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.IWorkbenchDragDropPart#getPart()
*/
public: virtual LayoutPart::Pointer GetPart();
/**
* deferUpdates(true) disables widget updates until a corresponding call to
* deferUpdates(false). Exactly what gets deferred is the decision
* of each LayoutPart, however the part may only defer operations in a manner
* that does not affect the final result.
* That is, the state of the receiver after the final call to deferUpdates(false)
* must be exactly the same as it would have been if nothing had been deferred.
*
* @param shouldDefer true iff events should be deferred
*/
public: void DeferUpdates(bool shouldDefer);
/**
* This is called when deferUpdates(true) causes UI events for this
* part to be deferred. Subclasses can overload to initialize any data
* structures that they will use to collect deferred events.
*/
protected: virtual void StartDeferringEvents();
/**
* Immediately processes all UI events which were deferred due to a call to
* deferUpdates(true). This is called when the last call is made to
* deferUpdates(false). Subclasses should overload this method if they
* defer some or all UI processing during deferUpdates.
*/
protected: virtual void HandleDeferredEvents();
/**
* Subclasses can call this method to determine whether UI updates should
* be deferred. Returns true iff there have been any calls to deferUpdates(true)
* without a corresponding call to deferUpdates(false). Any operation which is
* deferred based on the result of this method should be performed later within
* handleDeferredEvents().
*
* @return true iff updates should be deferred.
*/
protected: bool IsDeferred();
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they do not need to be translated.
*
* @param buf
*/
public: virtual void DescribeLayout(QString& buf) const;
/**
* Returns an id representing this part, suitable for use in a placeholder.
*
* @since 3.0
*/
public: virtual QString GetPlaceHolderId();
public: virtual void ResizeChild(LayoutPart::Pointer childThatChanged);
public: void FlushLayout();
/**
* Returns true iff the given part can be added to this ILayoutContainer
* @param toAdd
* @return
* @since 3.1
*/
public: virtual bool AllowsAdd(LayoutPart::Pointer toAdd);
/**
* Tests the integrity of this object. Throws an exception if the object's state
* is not internally consistent. For use in test suites.
*/
public: virtual void TestInvariants();
public: virtual QString ToString() const;
};
}
#endif /*BERRYLAYOUTPART_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPartSash.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPartSash.cpp
index 2d8dff9339..82c3ecf95e 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPartSash.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPartSash.cpp
@@ -1,306 +1,306 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryLayoutPartSash.h"
#include "berryLayoutTree.h"
#include "berryLayoutTreeNode.h"
#include "berryWorkbenchPlugin.h"
#include "berryConstants.h"
namespace berry
{
LayoutPartSash::SelectionListener::SelectionListener(LayoutPartSash* lp)
: layoutPartSash(lp)
{
}
void LayoutPartSash::SelectionListener::WidgetSelected(GuiTk::SelectionEvent::Pointer e)
{
layoutPartSash->CheckDragLimit(e);
if (e->detail != Constants::DRAG)
{
layoutPartSash->WidgetSelected(e->x, e->y, e->width,
e->height);
}
}
LayoutPartSash::LayoutPartSash(PartSashContainer* rootContainer, int style)
: LayoutPart(""), sash(0), enabled(false), rootContainer(rootContainer),
style(style), left(300), right(300), presFactory(0), isVisible(false)
{
selectionListener = new SelectionListener(this);
}
LayoutPartSash::~LayoutPartSash()
{
this->Dispose();
}
void LayoutPartSash::CheckDragLimit(GuiTk::SelectionEvent::Pointer event)
{
LayoutTree::Pointer root = rootContainer->GetLayoutTree();
LayoutTreeNode::Pointer node = root->FindSash(LayoutPartSash::Pointer(this));
- Rectangle nodeBounds = node->GetBounds();
- Rectangle eventRect(event->x, event->y, event->width, event->height);
+ QRect nodeBounds = node->GetBounds();
+ QRect eventRect(event->x, event->y, event->width, event->height);
bool vertical = (style == Constants::VERTICAL);
// If a horizontal sash, flip the coordinate system so that we
// can handle horizontal and vertical sashes without special cases
if (!vertical)
{
- nodeBounds.FlipXY();
- eventRect.FlipXY();
+ nodeBounds = QRect(nodeBounds.y(), nodeBounds.x(), nodeBounds.height(), nodeBounds.width());
+ eventRect = QRect(eventRect.y(), eventRect.x(), eventRect.height(), eventRect.width());
}
- int eventX = eventRect.x;
- int left = std::max(0, eventX - nodeBounds.x);
- left = std::min(left, nodeBounds.width - this->GetSashSize());
- int right = nodeBounds.width - left - this->GetSashSize();
+ int eventX = eventRect.x();
+ int left = std::max(0, eventX - nodeBounds.x());
+ left = std::min(left, nodeBounds.width() - this->GetSashSize());
+ int right = nodeBounds.width() - left - this->GetSashSize();
- LayoutTreeNode::ChildSizes sizes = node->ComputeChildSizes(nodeBounds.width, nodeBounds.height, left, right, nodeBounds.width);
+ LayoutTreeNode::ChildSizes sizes = node->ComputeChildSizes(nodeBounds.width(), nodeBounds.height(), left, right, nodeBounds.width());
- eventRect.x = nodeBounds.x + sizes.left;
+ eventRect.setX(nodeBounds.x() + sizes.left);
// If it's a horizontal sash, restore eventRect to its original coordinate system
if (!vertical)
{
- eventRect.FlipXY();
+ eventRect = QRect(eventRect.y(), eventRect.x(), eventRect.height(), eventRect.width());
}
- event->x = eventRect.x;
- event->y = eventRect.y;
+ event->x = eventRect.x();
+ event->y = eventRect.y();
}
void LayoutPartSash::CreateControl(void* /*parent*/)
{
// Defer creation of the control until it becomes visible
if (isVisible)
{
this->DoCreateControl();
}
}
void LayoutPartSash::DoCreateControl()
{
if (sash == 0)
{
// ask the presentation factory to create the sash
IPresentationFactory* factory = WorkbenchPlugin::GetDefault()->GetPresentationFactory();
int sashStyle = IPresentationFactory::SASHTYPE_NORMAL | style;
sash = factory->CreateSash(this->rootContainer->GetParent(), sashStyle);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddSelectionListener(sash, selectionListener);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetEnabled(sash, enabled);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetBounds(sash, bounds);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(sash, isVisible);
}
}
-void LayoutPartSash::SetBounds(const Rectangle& r)
+void LayoutPartSash::SetBounds(const QRect& r)
{
LayoutPart::SetBounds(r);
bounds = r;
}
void LayoutPartSash::SetVisible(bool visible)
{
if (visible == isVisible)
{
return;
}
if (visible)
{
this->DoCreateControl();
}
else
{
this->Dispose();
}
LayoutPart::SetVisible(visible);
isVisible = visible;
}
bool LayoutPartSash::IsVisible()
{
return isVisible;
}
void LayoutPartSash::Dispose()
{
if (sash != 0)
{
bounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(sash);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->Dispose(sash);
}
sash = 0;
}
-Rectangle LayoutPartSash::GetBounds()
+QRect LayoutPartSash::GetBounds()
{
if (sash == 0)
{
return bounds;
}
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(sash);
}
void* LayoutPartSash::GetControl()
{
return sash;
}
QString LayoutPartSash::GetID() const
{
return "";
}
LayoutPartSash::Pointer LayoutPartSash::GetPostLimit()
{
return postLimit;
}
LayoutPartSash::Pointer LayoutPartSash::GetPreLimit()
{
return preLimit;
}
int LayoutPartSash::GetLeft()
{
return left;
}
int LayoutPartSash::GetRight()
{
return right;
}
bool LayoutPartSash::IsHorizontal()
{
return ((style & Constants::HORIZONTAL) == Constants::HORIZONTAL);
}
bool LayoutPartSash::IsVertical()
{
return ((style & Constants::VERTICAL) == Constants::VERTICAL);
}
void LayoutPartSash::SetPostLimit(LayoutPartSash::Pointer newPostLimit)
{
postLimit = newPostLimit;
}
void LayoutPartSash::SetPreLimit(LayoutPartSash::Pointer newPreLimit)
{
preLimit = newPreLimit;
}
void LayoutPartSash::SetRatio(float newRatio)
{
int total = left + right;
int newLeft = (int) (total * newRatio);
this->SetSizes(newLeft, total - newLeft);
}
void LayoutPartSash::SetSizes(int left, int right)
{
if (left < 0 || right < 0)
{
return;
}
if (left == this->left && right == this->right)
{
return;
}
this->left = left;
this->right = right;
this->FlushCache();
}
void LayoutPartSash::FlushCache()
{
LayoutTree::Pointer root = rootContainer->GetLayoutTree();
if (root != 0)
{
LayoutTreeNode::Pointer node = root->FindSash(LayoutPartSash::Pointer(this));
if (node != 0)
{
node->FlushCache();
}
}
}
void LayoutPartSash::WidgetSelected(int x, int y, int /*width*/, int /*height*/)
{
if (!enabled)
{
return;
}
LayoutTree::Pointer root = rootContainer->GetLayoutTree();
LayoutTreeNode::Pointer node = root->FindSash(LayoutPartSash::Pointer(this));
- Rectangle nodeBounds = node->GetBounds();
+ QRect nodeBounds = node->GetBounds();
//Recompute ratio
- x -= nodeBounds.x;
- y -= nodeBounds.y;
+ x -= nodeBounds.x();
+ y -= nodeBounds.y();
if (style == Constants::VERTICAL)
{
- this->SetSizes(x, nodeBounds.width - x - this->GetSashSize());
+ this->SetSizes(x, nodeBounds.width() - x - this->GetSashSize());
}
else
{
- this->SetSizes(y, nodeBounds.height - y - this->GetSashSize());
+ this->SetSizes(y, nodeBounds.height() - y - this->GetSashSize());
}
node->SetBounds(nodeBounds);
}
void LayoutPartSash::SetEnabled(bool resizable)
{
this->enabled = resizable;
if (sash != 0)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetEnabled(sash, enabled);
}
}
int LayoutPartSash::GetSashSize() const
{
IPresentationFactory* factory = WorkbenchPlugin::GetDefault()->GetPresentationFactory();
int sashStyle = IPresentationFactory::SASHTYPE_NORMAL | style;
int size = factory->GetSashSize(sashStyle);
return size;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPartSash.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPartSash.h
index 268407b6a1..ef5d5dadfc 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPartSash.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPartSash.h
@@ -1,182 +1,184 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYLAYOUTPARTSASH_H_
#define BERRYLAYOUTPARTSASH_H_
#include "berryLayoutPart.h"
#include "berryPartSashContainer.h"
#include "guitk/berryGuiTkISelectionListener.h"
#include "presentations/berryIPresentationFactory.h"
+#include
+
namespace berry
{
class LayoutPartSash: public LayoutPart
{
friend class WorkbenchPage;
friend class PartSashContainer;
friend class LayoutTreeNode;
public:
berryObjectMacro(LayoutPartSash);
LayoutPartSash(PartSashContainer* rootContainer, int style);
~LayoutPartSash();
private:
void* sash;
bool enabled;
PartSashContainer* rootContainer;
int style;
LayoutPartSash::Pointer preLimit;
LayoutPartSash::Pointer postLimit;
int left;
int right;
- Rectangle bounds;
+ QRect bounds;
IPresentationFactory* presFactory;
/**
* Stores whether or not the sash is visible. (This is expected to have a meaningful
* value even if the underlying control doesn't exist).
*/
bool isVisible;
struct SelectionListener : public GuiTk::ISelectionListener
{
SelectionListener(LayoutPartSash* layoutPartSash);
void WidgetSelected(GuiTk::SelectionEvent::Pointer e);
private: LayoutPartSash* layoutPartSash;
};
GuiTk::ISelectionListener::Pointer selectionListener;
// checkDragLimit contains changes by cagatayk@acm.org
void CheckDragLimit(GuiTk::SelectionEvent::Pointer event);
/**
* Creates the control. As an optimization, creation of the control is deferred if
* the control is invisible.
*/
public:
void CreateControl(void* parent);
/**
* Creates the underlying SWT control.
*
* @since 3.1
*/
private:
void DoCreateControl();
public:
- void SetBounds(const Rectangle& r);
+ void SetBounds(const QRect& r);
/**
* Makes the sash visible or invisible. Note: as an optimization, the actual widget is destroyed when the
* sash is invisible.
*/
public:
void SetVisible(bool visible);
public:
bool IsVisible();
/**
* See LayoutPart#dispose
*/
public:
void Dispose();
/**
* Gets the presentation bounds.
*/
public:
- Rectangle GetBounds();
+ QRect GetBounds();
/**
* Returns the part control.
*/
public:
void* GetControl();
/**
*
*/
public:
QString GetID() const;
protected:
LayoutPartSash::Pointer GetPostLimit();
LayoutPartSash::Pointer GetPreLimit();
int GetLeft();
int GetRight();
bool IsHorizontal();
bool IsVertical();
void SetPostLimit(LayoutPartSash::Pointer newPostLimit);
void SetPreLimit(LayoutPartSash::Pointer newPreLimit);
void SetRatio(float newRatio);
void SetSizes(int left, int right);
private:
void FlushCache();
private:
void WidgetSelected(int x, int y, int width, int height);
/**
* @param resizable
* @since 3.1
*/
public:
void SetEnabled(bool resizable);
protected:
/* package */int GetSashSize() const;
};
}
#endif /* BERRYLAYOUTPARTSASH_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTree.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTree.cpp
index bc08e19e2d..fdab418d8c 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTree.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTree.cpp
@@ -1,480 +1,481 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLayoutTree.h"
#include "berryLayoutTreeNode.h"
#include "berryLayoutPartSash.h"
#include "berryConstants.h"
+#include "berryLog.h"
namespace berry
{
int LayoutTree::minCacheHits = 0;
int LayoutTree::minCacheMisses = 0;
int LayoutTree::maxCacheHits = 0;
int LayoutTree::maxCacheMisses = 0;
LayoutTree::LayoutTree(LayoutPart::Pointer part)
: parent(0),
cachedMinimumWidthHint(Constants::DEFAULT),
cachedMinimumWidth(Constants::DEFAULT),
cachedMinimumHeightHint(Constants::DEFAULT),
cachedMinimumHeight(Constants::DEFAULT),
cachedMaximumWidthHint(Constants::DEFAULT),
cachedMaximumWidth(Constants::DEFAULT),
cachedMaximumHeightHint(Constants::DEFAULT),
cachedMaximumHeight(Constants::DEFAULT),
forceLayout(true),
sizeFlagsDirty(true),
widthSizeFlags(0),
heightSizeFlags(0)
{
this->part = part;
}
LayoutPart::Pointer LayoutTree::ComputeRelation(
QList& /*relations*/)
{
return part;
}
-LayoutPart::Pointer LayoutTree::FindPart(const Point& /*toFind*/)
+LayoutPart::Pointer LayoutTree::FindPart(const QPoint& /*toFind*/)
{
return part;
}
void LayoutTree::DisposeSashes()
{
}
LayoutTree::Pointer LayoutTree::Find(LayoutPart::Pointer child)
{
if (part != child)
{
return LayoutTree::Pointer(0);
}
return LayoutTree::Pointer(this);
}
void LayoutTree::FindSashes(PartPane::Sashes sashes)
{
if (this->GetParent() == 0)
{
return;
}
this->GetParent()->FindSashes(LayoutTree::Pointer(this), sashes);
}
LayoutPart::Pointer LayoutTree::FindBottomRight()
{
return part;
}
LayoutTreeNode::Pointer LayoutTree::FindSash(LayoutPartSash::Pointer /*sash*/)
{
return LayoutTreeNode::Pointer(0);
}
-Rectangle LayoutTree::GetBounds()
+QRect LayoutTree::GetBounds()
{
return currentBounds;
}
int LayoutTree::Subtract(int a, int b)
{
poco_assert(b >= 0 && b < INF);
return Add(a, -b);
}
int LayoutTree::Add(int a, int b)
{
if (a == INF || b == INF)
{
return INF;
}
return a + b;
}
void LayoutTree::AssertValidSize(int toCheck)
{
poco_assert(toCheck >= 0 && (toCheck == INF || toCheck < INF / 2));
}
int LayoutTree::ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
this->AssertValidSize(availableParallel);
this->AssertValidSize(availablePerpendicular);
this->AssertValidSize(preferredParallel);
if (!this->IsVisible())
{
return 0;
}
if (availableParallel == 0)
{
return 0;
}
if (preferredParallel == 0)
{
return std::min(availableParallel, this->ComputeMinimumSize(width,
availablePerpendicular));
}
else if (preferredParallel == INF && availableParallel == INF)
{
return this->ComputeMaximumSize(width, availablePerpendicular);
}
// Optimization: if this subtree doesn't have any size preferences beyond its minimum and maximum
// size, simply return the preferred size
if (!this->HasSizeFlag(width, Constants::FILL))
{
return preferredParallel;
}
int result = this->DoComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredParallel);
return result;
}
int LayoutTree::DoGetSizeFlags(bool width)
{
return part->GetSizeFlags(width);
}
int LayoutTree::DoComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
int result = std::min(availableParallel, part->ComputePreferredSize(width,
availableParallel, availablePerpendicular, preferredParallel));
this->AssertValidSize(result);
return result;
}
int LayoutTree::ComputeMinimumSize(bool width, int availablePerpendicular)
{
this->AssertValidSize(availablePerpendicular);
// Optimization: if this subtree has no minimum size, then always return 0 as its
// minimum size.
if (!this->HasSizeFlag(width, Constants::MIN))
{
return 0;
}
// If this subtree doesn't contain any wrapping controls (ie: they don't care
// about their perpendicular size) then force the perpendicular
// size to be INF. This ensures that we will get a cache hit
// every time for non-wrapping controls.
if (!this->HasSizeFlag(width, Constants::WRAP))
{
availablePerpendicular = INF;
}
if (width)
{
// Check if we have a cached width measurement (we can only return a cached
// value if we computed it for the same height)
if (cachedMinimumWidthHint == availablePerpendicular)
{
minCacheHits++;
return cachedMinimumWidth;
}
// Recompute the minimum width and store it in the cache
minCacheMisses++;
int result = this->DoComputeMinimumSize(width, availablePerpendicular);
cachedMinimumWidth = result;
cachedMinimumWidthHint = availablePerpendicular;
return result;
}
else
{
// Check if we have a cached height measurement (we can only return a cached
// value if we computed it for the same width)
if (cachedMinimumHeightHint == availablePerpendicular)
{
minCacheHits++;
return cachedMinimumHeight;
}
// Recompute the minimum width and store it in the cache
minCacheMisses++;
int result = this->DoComputeMinimumSize(width, availablePerpendicular);
cachedMinimumHeight = result;
cachedMinimumHeightHint = availablePerpendicular;
return result;
}
}
void LayoutTree::PrintCacheStatistics()
{
BERRY_INFO << "minimize cache " << minCacheHits << " / " << (minCacheHits
+ minCacheMisses) << " hits " <<
(minCacheHits * 100 / (minCacheHits + minCacheMisses)) << "%\n";
BERRY_INFO << "maximize cache " << maxCacheHits << " / " << (maxCacheHits
+ maxCacheMisses) << " hits" <<
(maxCacheHits * 100 / (maxCacheHits + maxCacheMisses)) << "%\n";
}
int LayoutTree::DoComputeMinimumSize(bool width, int availablePerpendicular)
{
int result = this->DoComputePreferredSize(width, INF, availablePerpendicular,
0);
this->AssertValidSize(result);
return result;
}
int LayoutTree::ComputeMaximumSize(bool width, int availablePerpendicular)
{
this->AssertValidSize(availablePerpendicular);
// Optimization: if this subtree has no maximum size, then always return INF as its
// maximum size.
if (!this->HasSizeFlag(width, Constants::MAX))
{
return INF;
}
// If this subtree doesn't contain any wrapping controls (ie: they don't care
// about their perpendicular size) then force the perpendicular
// size to be INF. This ensures that we will get a cache hit
// every time.
if (!this->HasSizeFlag(width, Constants::WRAP))
{
availablePerpendicular = INF;
}
if (width)
{
// Check if we have a cached width measurement (we can only return a cached
// value if we computed it for the same height)
if (cachedMaximumWidthHint == availablePerpendicular)
{
maxCacheHits++;
return cachedMaximumWidth;
}
maxCacheMisses++;
// Recompute the maximum width and store it in the cache
int result = this->DoComputeMaximumSize(width, availablePerpendicular);
cachedMaximumWidth = result;
cachedMaximumWidthHint = availablePerpendicular;
return result;
}
else
{
// Check if we have a cached height measurement
if (cachedMaximumHeightHint == availablePerpendicular)
{
maxCacheHits++;
return cachedMaximumHeight;
}
maxCacheMisses++;
// Recompute the maximum height and store it in the cache
int result = this->DoComputeMaximumSize(width, availablePerpendicular);
cachedMaximumHeight = result;
cachedMaximumHeightHint = availablePerpendicular;
return result;
}
}
int LayoutTree::DoComputeMaximumSize(bool width, int availablePerpendicular)
{
return this->DoComputePreferredSize(width, INF, availablePerpendicular,
INF);
}
void LayoutTree::FlushNode()
{
// Clear cached sizes
cachedMinimumWidthHint = Constants::DEFAULT;
cachedMinimumWidth = Constants::DEFAULT;
cachedMinimumHeightHint = Constants::DEFAULT;
cachedMinimumHeight = Constants::DEFAULT;
cachedMaximumWidthHint = Constants::DEFAULT;
cachedMaximumWidth = Constants::DEFAULT;
cachedMaximumHeightHint = Constants::DEFAULT;
cachedMaximumHeight = Constants::DEFAULT;
// Flags may have changed. Ensure that they are recomputed the next time around
sizeFlagsDirty = true;
// The next setBounds call should trigger a layout even if set to the same bounds since
// one of the children has changed.
forceLayout = true;
}
void LayoutTree::FlushChildren()
{
this->FlushNode();
}
void LayoutTree::FlushCache()
{
this->FlushNode();
if (parent != 0)
{
parent->FlushCache();
}
}
int LayoutTree::GetSizeFlags(bool width)
{
if (sizeFlagsDirty)
{
widthSizeFlags = this->DoGetSizeFlags(true);
heightSizeFlags = this->DoGetSizeFlags(false);
sizeFlagsDirty = false;
}
return width ? widthSizeFlags : heightSizeFlags;
}
LayoutTreeNode* LayoutTree::GetParent() const
{
return parent;
}
LayoutTree::Pointer LayoutTree::Insert(LayoutPart::Pointer child, bool left,
LayoutPartSash::Pointer sash, LayoutPart::Pointer relative)
{
LayoutTree::Pointer relativeChild = this->Find(relative);
LayoutTreeNode::Pointer node(new LayoutTreeNode(sash));
if (relativeChild == 0)
{
//Did not find the relative part. Insert beside the root.
node->SetChild(left, child);
node->SetChild(!left, LayoutTree::Pointer(this));
return node;
}
else
{
LayoutTreeNode* oldParent = relativeChild->GetParent();
node->SetChild(left, child);
node->SetChild(!left, relativeChild);
if (oldParent == 0)
{
//It was the root. Return a new root.
return node;
}
oldParent->ReplaceChild(relativeChild, node);
return LayoutTree::Pointer(this);
}
}
bool LayoutTree::IsCompressible()
{
//Added for bug 19524
return part->IsCompressible();
}
bool LayoutTree::IsVisible()
{
return !part->IsPlaceHolder();
}
void LayoutTree::RecomputeRatio()
{
}
LayoutTree::Pointer LayoutTree::Remove(LayoutPart::Pointer child)
{
LayoutTree::Pointer tree = this->Find(child);
if (tree == 0)
{
return LayoutTree::Pointer(this);
}
LayoutTreeNode::Pointer oldParent(tree->GetParent());
if (oldParent == 0)
{
//It was the root and the only child of this tree
return LayoutTree::Pointer(0);
}
if (oldParent->GetParent() == 0)
{
return oldParent->Remove(tree);
}
oldParent->Remove(tree);
return LayoutTree::Pointer(this);
}
-void LayoutTree::SetBounds(const Rectangle& bounds)
+void LayoutTree::SetBounds(const QRect& bounds)
{
if (!(bounds == currentBounds) || forceLayout)
{
currentBounds = bounds;
this->DoSetBounds(currentBounds);
forceLayout = false;
}
}
-void LayoutTree::DoSetBounds(const Rectangle& bounds)
+void LayoutTree::DoSetBounds(const QRect& bounds)
{
part->SetBounds(bounds);
}
void LayoutTree::SetParent(LayoutTreeNode* parent)
{
this->parent = parent;
}
void LayoutTree::SetPart(LayoutPart::Pointer part)
{
this->part = part;
this->FlushCache();
}
QString LayoutTree::ToString() const
{
return "(" + part->ToString() + ")";
}
void LayoutTree::CreateControl(void* /*parent*/)
{
}
void LayoutTree::DescribeLayout(QString& buf) const
{
part->DescribeLayout(buf);
}
bool LayoutTree::HasSizeFlag(bool width, int flag)
{
return (this->GetSizeFlags(width) & flag) != 0;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTree.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTree.h
index 68f81a282e..9cb62bd853 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTree.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTree.h
@@ -1,371 +1,370 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYLAYOUTTREE_H_
#define BERRYLAYOUTTREE_H_
#include "berryISizeProvider.h"
-#include "berryRectangle.h"
-#include "berryPoint.h"
-
#include "berryPartSashContainer.h"
+#include
+
namespace berry
{
class LayoutTreeNode;
class LayoutPartSash;
/**
* \ingroup org_blueberry_ui_internal
*
* Implementation of a tree where the node is allways a sash
* and it allways has two chidren. If a children is removed
* the sash, ie the node, is removed as well and its other children
* placed on its parent.
*/
class LayoutTree : public Object, public ISizeProvider
{ //implements ISizeProvider {
public:
berryObjectMacro(LayoutTree)
/* The parent of this tree or null if it is the root */
LayoutTreeNode* parent;
/* Any LayoutPart if this is a leaf or a LayoutSashPart if it is a node */
LayoutPart::Pointer part;
private:
// Cached information
int cachedMinimumWidthHint;
int cachedMinimumWidth;
int cachedMinimumHeightHint;
int cachedMinimumHeight;
int cachedMaximumWidthHint;
int cachedMaximumWidth;
int cachedMaximumHeightHint;
int cachedMaximumHeight;
bool forceLayout;
- Rectangle currentBounds;
+ QRect currentBounds;
// Cached size flags
bool sizeFlagsDirty;
int widthSizeFlags;
int heightSizeFlags;
public:
// Cache statistics. For use in benchmarks and test suites only!
static int minCacheHits;
static int minCacheMisses;
static int maxCacheHits;
static int maxCacheMisses;
/**
* Initialize this tree with its part.
*/
LayoutTree(LayoutPart::Pointer part);
/**
* Add the relation ship between the children in the list
* and returns the left children.
*/
virtual LayoutPart::Pointer ComputeRelation(
QList& relations);
/**
* Locates the part that intersects the given point
*
* @param toFind
* @return
*/
- virtual LayoutPart::Pointer FindPart(const Point& toFind);
+ virtual LayoutPart::Pointer FindPart(const QPoint& toFind);
/**
* Dispose all Sashs in this tree
*/
virtual void DisposeSashes();
/**
* Find a LayoutPart in the tree and return its sub-tree. Returns
* null if the child is not found.
*/
virtual SmartPointer Find(LayoutPart::Pointer child);
/**
* Find the Left,Right,Top and Bottom
* sashes around this tree and set them
* in sashes
*/
virtual void FindSashes(PartPane::Sashes sashes);
/**
* Find the part that is in the bottom right position.
*/
virtual LayoutPart::Pointer FindBottomRight();
/**
* Find a sash in the tree and return its sub-tree. Returns
* null if the sash is not found.
*/
virtual SmartPointer FindSash(SmartPointer sash);
/**
* Return the bounds of this tree which is the rectangle that
* contains all Controls in this tree.
*/
- Rectangle GetBounds();
+ QRect GetBounds();
/**
* Subtracts two integers. If a is INF, this is treated as
* positive infinity.
*
* @param a a positive integer or INF indicating positive infinity
* @param b a positive integer (may not be INF)
* @return a - b, or INF if a == INF
* @since 3.1
*/
static int Subtract(int a, int b);
/**
* Adds two positive integers. Treates INF as positive infinity.
*
* @param a a positive integer
* @param b a positive integer
* @return a + b, or INF if a or b are positive infinity
* @since 3.1
*/
static int Add(int a, int b);
/**
* Asserts that toCheck is a positive integer less than INF / 2 or equal
* to INF. Many of the methods of this class use positive integers as sizes,
* with INF indicating positive infinity. This picks up accidental addition or
* subtraction from infinity.
*
* @param toCheck integer to validate
* @since 3.1
*/
static void AssertValidSize(int toCheck);
/**
* Computes the preferred size for this object. The interpretation of the result depends on the flags returned
* by getSizeFlags(). If the caller is looking for a maximum or minimum size, this delegates to computeMinimumSize
* or computeMaximumSize in order to benefit from caching optimizations. Otherwise, it delegates to
* doComputePreferredSize. Subclasses should overload one of doComputeMinimumSize, doComputeMaximumSize, or
* doComputePreferredSize to specialize the return value.
*
* @see LayoutPart#computePreferredSize(boolean, int, int, int)
*/
int ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel);
protected:
/**
* Returns the size flags for this tree.
*
* @see org.blueberry.ui.presentations.StackPresentation#getSizeFlags(boolean)
*
* @param b indicates whether the caller wants the flags for computing widths (=true) or heights (=false)
* @return a bitwise combiniation of flags with the same meaning as StackPresentation.getSizeFlags(boolean)
*/
virtual int DoGetSizeFlags(bool width);
/**
* Subclasses should overload this method instead of computePreferredSize(boolean, int, int, int)
*
* @see org.blueberry.ui.presentations.StackPresentation#computePreferredSize(boolean, int, int, int)
*
* @since 3.1
*/
virtual int DoComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel);
public:
/**
* Returns the minimum size for this subtree. Equivalent to calling
* computePreferredSize(width, INF, availablePerpendicular, 0).
* Returns a cached value if possible or defers to doComputeMinimumSize otherwise.
* Subclasses should overload doComputeMinimumSize if they want to specialize the
* return value.
*
* @param width true iff computing the minimum width, false iff computing the minimum height
* @param availablePerpendicular available space (pixels) perpendicular to the dimension
* being computed. This is a height when computing a width, or a width when computing a height.
*
* @see LayoutPart#computePreferredSize(boolean, int, int, int)
*/
int ComputeMinimumSize(bool width, int availablePerpendicular);
/**
* For use in benchmarks and test suites only. Displays cache utilization statistics for all
* LayoutTree instances.
*
* @since 3.1
*/
static void PrintCacheStatistics();
virtual int DoComputeMinimumSize(bool width, int availablePerpendicular);
int ComputeMaximumSize(bool width, int availablePerpendicular);
protected:
virtual int DoComputeMaximumSize(bool width, int availablePerpendicular);
public:
/**
* Called to flush any cached information in this tree and its parents.
*/
virtual void FlushNode();
/**
* Flushes all cached information about this node and all of its children.
* This should be called if something may have caused all children to become
* out of synch with their cached information (for example, if a lot of changes
* may have happened without calling flushCache after each change)
*
* @since 3.1
*/
virtual void FlushChildren();
/**
* Flushes all cached information about this node and all of its ancestors.
* This should be called when a single child changes.
*
* @since 3.1
*/
void FlushCache();
int GetSizeFlags(bool width);
/**
* Returns the parent of this tree or null if it is the root.
*/
virtual LayoutTreeNode* GetParent() const;
/**
* Inserts a new child on the tree. The child will be placed beside
* the relative
child. Returns the new root of the tree.
*/
virtual SmartPointer Insert(LayoutPart::Pointer child, bool left,
SmartPointer sash, SmartPointer relative);
/**
* Returns true if this tree can be compressed and expanded.
* @return true if springy
*/
virtual bool IsCompressible();
/**
* Returns true if this tree has visible parts otherwise returns false.
*/
virtual bool IsVisible();
/**
* Recompute the ratios in this tree.
*/
virtual void RecomputeRatio();
/**
* Find a child in the tree and remove it and its parent.
* The other child of its parent is placed on the parent's parent.
* Returns the new root of the tree.
*/
virtual SmartPointer Remove(LayoutPart::Pointer child);
/**
* Sets the bounds of this node. If the bounds have changed or any children have
* changed then the children will be recursively layed out. This implementation
* filters out redundant calls and delegates to doSetBounds to layout the children.
* Subclasses should overload doSetBounds to lay out their children.
*
* @param bounds new bounds of the tree
*/
- void SetBounds(const Rectangle& bounds);
+ void SetBounds(const QRect& bounds);
protected:
/**
* Resize the parts on this tree to fit in bounds
.
*/
- virtual void DoSetBounds(const Rectangle& bounds);
+ virtual void DoSetBounds(const QRect& bounds);
public:
/**
* Set the parent of this tree.
*/
virtual void SetParent(LayoutTreeNode* parent);
/**
* Set the part of this leaf
*/
virtual void SetPart(LayoutPart::Pointer part);
/**
* Returns a string representation of this object.
*/
virtual QString ToString() const;
/**
* Creates SWT controls owned by the LayoutTree (ie: the sashes). Does not affect the
* LayoutParts that are being arranged by the LayoutTree.
*
* @param parent
* @since 3.1
*/
virtual void CreateControl(void* parent);
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they should not be translated or equality tests will fail.
*
* This is only intended for use by test suites.
*
*
* @param buf
*/
virtual void DescribeLayout(QString& buf) const;
/**
* This is a shorthand method that checks if the tree contains the
* given size flag. For example, hasSizeFlag(false, SWT.MIN) returns
* true iff the receiver enforces a minimum height, or
* hasSizeFlag(true, SWT.WRAP) returns true iff the receiver needs to
* know its height when computing its preferred width.
*
* @param vertical
* @return
* @since 3.1
*/
bool HasSizeFlag(bool width, int flag);
};
}
#endif /*BERRYLAYOUTTREE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTreeNode.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTreeNode.cpp
index fa15915437..2193b84808 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTreeNode.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTreeNode.cpp
@@ -1,719 +1,723 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLayoutTreeNode.h"
#include "berryConstants.h"
#include "berryIPageLayout.h"
#include
namespace berry
{
LayoutTreeNode::ChildSizes::ChildSizes (int l, int r, bool resize)
{
left = l;
right = r;
resizable = resize;
}
LayoutTreeNode::LayoutTreeNode(LayoutPartSash::Pointer sash)
: LayoutTree(sash)
{
children[0] = 0;
children[1] = 0;
}
LayoutTreeNode::~LayoutTreeNode()
{
}
void LayoutTreeNode::FlushChildren()
{
LayoutTree::FlushChildren();
children[0]->FlushChildren();
children[1]->FlushChildren();
}
-LayoutPart::Pointer LayoutTreeNode::FindPart(const Point& toFind)
+LayoutPart::Pointer LayoutTreeNode::FindPart(const QPoint& toFind)
{
if (!children[0]->IsVisible())
{
if (!children[1]->IsVisible())
{
return LayoutPart::Pointer(0);
}
return children[1]->FindPart(toFind);
}
else
{
if (!children[1]->IsVisible())
{
return children[0]->FindPart(toFind);
}
}
LayoutPartSash::Pointer sash = this->GetSash();
- Rectangle bounds = sash->GetBounds();
+ QRect bounds = sash->GetBounds();
if (sash->IsVertical())
{
- if (toFind.x < bounds.x + (bounds.width / 2))
+ if (toFind.x() < bounds.x() + (bounds.width() / 2))
{
return children[0]->FindPart(toFind);
}
return children[1]->FindPart(toFind);
}
else
{
- if (toFind.y < bounds.y + (bounds.height / 2))
+ if (toFind.y() < bounds.y() + (bounds.height() / 2))
{
return children[0]->FindPart(toFind);
}
return children[1]->FindPart(toFind);
}
}
LayoutPart::Pointer LayoutTreeNode::ComputeRelation(
QList& relations)
{
PartSashContainer::RelationshipInfo r =
PartSashContainer::RelationshipInfo();
r.relative = children[0]->ComputeRelation(relations);
r.part = children[1]->ComputeRelation(relations);
r.left = this->GetSash()->GetLeft();
r.right = this->GetSash()->GetRight();
r.relationship = this->GetSash()->IsVertical() ? IPageLayout::RIGHT : IPageLayout::BOTTOM;
relations.push_front(r);
return r.relative;
}
void LayoutTreeNode::DisposeSashes()
{
children[0]->DisposeSashes();
children[1]->DisposeSashes();
this->GetSash()->Dispose();
}
LayoutTree::Pointer LayoutTreeNode::Find(LayoutPart::Pointer child)
{
LayoutTree::Pointer node = children[0]->Find(child);
if (node != 0)
{
return node;
}
node = children[1]->Find(child);
return node;
}
LayoutPart::Pointer LayoutTreeNode::FindBottomRight()
{
if (children[1]->IsVisible())
{
return children[1]->FindBottomRight();
}
return children[0]->FindBottomRight();
}
LayoutTreeNode* LayoutTreeNode::FindCommonParent(LayoutPart::Pointer child1,
LayoutPart::Pointer child2, bool foundChild1,
bool foundChild2)
{
if (!foundChild1)
{
foundChild1 = this->Find(child1) != 0;
}
if (!foundChild2)
{
foundChild2 = this->Find(child2) != 0;
}
if (foundChild1 && foundChild2)
{
return this;
}
if (parent == 0)
{
return 0;
}
return parent
->FindCommonParent(child1, child2, foundChild1, foundChild2);
}
LayoutTreeNode::Pointer LayoutTreeNode::FindSash(LayoutPartSash::Pointer sash)
{
if (this->GetSash() == sash)
{
return LayoutTreeNode::Pointer(this);
}
LayoutTreeNode::Pointer node = children[0]->FindSash(sash);
if (node != 0)
{
return node;
}
node = children[1]->FindSash(sash);
if (node != 0)
{
return node;
}
return LayoutTreeNode::Pointer(0);
}
void LayoutTreeNode::FindSashes(LayoutTree::Pointer child, PartPane::Sashes sashes)
{
void* sash = this->GetSash()->GetControl();
bool leftOrTop = children[0] == child;
if (sash != 0)
{
LayoutPartSash::Pointer partSash = this->GetSash();
//If the child is in the left, the sash
//is in the rigth and so on.
if (leftOrTop)
{
if (partSash->IsVertical())
{
if (sashes.right == 0)
{
sashes.right = sash;
}
}
else
{
if (sashes.bottom == 0)
{
sashes.bottom = sash;
}
}
}
else
{
if (partSash->IsVertical())
{
if (sashes.left == 0)
{
sashes.left = sash;
}
}
else
{
if (sashes.top == 0)
{
sashes.top = sash;
}
}
}
}
if (this->GetParent() != 0)
{
this->GetParent()->FindSashes(LayoutTree::Pointer(this), sashes);
}
}
LayoutPartSash::Pointer LayoutTreeNode::GetSash() const
{
return part.Cast();
}
int LayoutTreeNode::GetSashSize() const
{
return this->GetSash()->GetSashSize();
}
bool LayoutTreeNode::IsVisible()
{
return children[0]->IsVisible() || children[1]->IsVisible();
}
LayoutTree::Pointer LayoutTreeNode::Remove(LayoutTree::Pointer child)
{
this->GetSash()->Dispose();
if (parent == 0)
{
//This is the root. Return the other child to be the new root.
if (children[0] == child)
{
children[1]->SetParent(0);
return children[1];
}
children[0]->SetParent(0);
return children[0];
}
LayoutTreeNode::Pointer oldParent(parent);
if (children[0] == child)
{
oldParent->ReplaceChild(LayoutTree::Pointer(this), children[1]);
}
else
{
oldParent->ReplaceChild(LayoutTree::Pointer(this), children[0]);
}
return oldParent;
}
void LayoutTreeNode::ReplaceChild(LayoutTree::Pointer oldChild, LayoutTree::Pointer newChild)
{
if (children[0] == oldChild)
{
children[0] = newChild;
}
else if (children[1] == oldChild)
{
children[1] = newChild;
}
newChild->SetParent(this);
if (!children[0]->IsVisible() || !children[0]->IsVisible())
{
this->GetSash()->Dispose();
}
this->FlushCache();
}
bool LayoutTreeNode::SameDirection(bool isVertical, LayoutTreeNode::Pointer subTree)
{
bool treeVertical = this->GetSash()->IsVertical();
if (treeVertical != isVertical)
{
return false;
}
while (subTree != 0)
{
if (this == subTree.GetPointer())
{
return true;
}
if (subTree->children[0]->IsVisible() && subTree->children[1]->IsVisible())
{
if (subTree->GetSash()->IsVertical() != isVertical)
{
return false;
}
}
subTree = subTree->GetParent();
}
return true;
}
int LayoutTreeNode::DoComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
this->AssertValidSize(availablePerpendicular);
this->AssertValidSize(availableParallel);
this->AssertValidSize(preferredParallel);
// If one child is invisible, defer to the other child
if (!children[0]->IsVisible())
{
return children[1]->ComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredParallel);
}
if (!children[1]->IsVisible())
{
return children[0]->ComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredParallel);
}
if (availableParallel == 0)
{
return 0;
}
// If computing the dimension perpendicular to our sash
if (width == this->GetSash()->IsVertical())
{
// Compute the child sizes
ChildSizes sizes = this->ComputeChildSizes(availableParallel,
availablePerpendicular,
GetSash()->GetLeft(), GetSash()->GetRight(), preferredParallel);
// Return the sum of the child sizes plus the sash size
return this->Add(sizes.left, this->Add(sizes.right, this->GetSashSize()));
}
else
{
// Computing the dimension parallel to the sash. We will compute and return the preferred size
// of whichever child is closest to the ideal size.
// First compute the dimension of the child sizes perpendicular to the sash
ChildSizes sizes = this->ComputeChildSizes(availablePerpendicular, availableParallel,
GetSash()->GetLeft(), GetSash()->GetRight(), availablePerpendicular);
// Use this information to compute the dimension of the child sizes parallel to the sash.
// Return the preferred size of whichever child is largest
int leftSize = children[0]->ComputePreferredSize(width, availableParallel,
sizes.left, preferredParallel);
// Compute the preferred size of the right child
int rightSize = children[1]->ComputePreferredSize(width, availableParallel,
sizes.right, preferredParallel);
// Return leftSize or rightSize: whichever one is largest
int result = rightSize;
if (leftSize > rightSize)
{
result = leftSize;
}
this->AssertValidSize(result);
return result;
}
}
LayoutTreeNode::ChildSizes LayoutTreeNode::ComputeChildSizes(int width, int height, int left,
int right, int preferredWidth)
{
poco_assert(children[0]->IsVisible());
poco_assert(children[1]->IsVisible());
this->AssertValidSize(width);
this->AssertValidSize(height);
this->AssertValidSize(preferredWidth);
poco_assert(left >= 0);
poco_assert(right >= 0);
poco_assert(preferredWidth >= 0);
poco_assert(preferredWidth <= width);
bool vertical = this->GetSash()->IsVertical();
if (width <= this->GetSashSize())
{
return ChildSizes(0,0, false);
}
if (width == INF)
{
if (preferredWidth == INF)
{
return ChildSizes(children[0]->ComputeMaximumSize(vertical, height),
children[1]->ComputeMaximumSize(vertical, height), false);
}
if (preferredWidth == 0)
{
return ChildSizes(children[0]->ComputeMinimumSize(vertical, height),
children[1]->ComputeMinimumSize(vertical, height), false);
}
}
int total = left + right;
// Use all-or-none weighting
double wLeft = left, wRight = right;
switch (this->GetCompressionBias())
{
case -1:
wLeft = 0.0;
break;
case 1:
wRight = 0.0;
break;
default:
break;
}
double wTotal = wLeft + wRight;
// Subtract the SASH_WIDTH from preferredWidth and width. From here on, we'll deal with the
// width available to the controls and neglect the space used by the sash.
preferredWidth = std::max(0, this->Subtract(preferredWidth, this->GetSashSize()));
width = std::max(0, this->Subtract(width, this->GetSashSize()));
int redistribute = this->Subtract(preferredWidth, total);
// Compute the minimum and maximum sizes for each child
int leftMinimum = children[0]->ComputeMinimumSize(vertical, height);
int rightMinimum = children[1]->ComputeMinimumSize(vertical, height);
int leftMaximum = children[0]->ComputeMaximumSize(vertical, height);
int rightMaximum = children[1]->ComputeMaximumSize(vertical, height);
int idealLeft = 0;
int idealRight = 0;
if (PartSashContainer::leftToRight)
{
// Keep track of the available space for each child, given the minimum size of the other child
int leftAvailable = std::min(leftMaximum, std::max(0, this->Subtract(width,
rightMinimum)));
int rightAvailable = std::min(rightMaximum, std::max(0, this->Subtract(width,
leftMinimum)));
// Figure out the ideal size of the left child
idealLeft = std::max(leftMinimum, std::min(preferredWidth, left
+ (int)(redistribute * wLeft / wTotal)));
// If the right child can't use all its available space, let the left child fill it in
idealLeft = std::max(idealLeft, preferredWidth - rightAvailable);
// Ensure the left child doesn't get larger than its available space
idealLeft = std::min(idealLeft, leftAvailable);
// Check if the left child would prefer to be a different size
idealLeft = children[0]->ComputePreferredSize(vertical, leftAvailable, height,
idealLeft);
// Ensure that the left child is larger than its minimum size
idealLeft = std::max(idealLeft, leftMinimum);
idealLeft = std::min(idealLeft, leftAvailable);
// Compute the right child width
idealRight = std::max(rightMinimum, preferredWidth - idealLeft);
rightAvailable = std::max(0, std::min(rightAvailable, this->Subtract(width,
idealLeft)));
idealRight = std::min(idealRight, rightAvailable);
idealRight = children[1]->ComputePreferredSize(vertical, rightAvailable,
height, idealRight);
idealRight = std::max(idealRight, rightMinimum);
}
else
{
// Keep track of the available space for each child, given the minimum size of the other child
int rightAvailable = std::min(rightMaximum, std::max(0, this->Subtract(width,
leftMinimum)));
int leftAvailable = std::min(leftMaximum, std::max(0, this->Subtract(width,
rightMinimum)));
// Figure out the ideal size of the right child
idealRight = std::max(rightMinimum, std::min(preferredWidth, right
+ (int)(redistribute * wRight / wTotal)));
// If the left child can't use all its available space, let the right child fill it in
idealRight = std::max(idealRight, preferredWidth - leftAvailable);
// Ensure the right child doesn't get larger than its available space
idealRight = std::min(idealRight, rightAvailable);
// Check if the right child would prefer to be a different size
idealRight = children[1]->ComputePreferredSize(vertical, rightAvailable, height,
idealRight);
// Ensure that the right child is larger than its minimum size
idealRight = std::max(idealRight, rightMinimum);
idealRight = std::min(idealRight, rightAvailable);
// Compute the left child width
idealLeft = std::max(leftMinimum, preferredWidth - idealRight);
leftAvailable = std::max(0, std::min(leftAvailable, this->Subtract(width,
idealRight)));
idealLeft = std::min(idealLeft, leftAvailable);
idealLeft = children[0]->ComputePreferredSize(vertical, leftAvailable,
height, idealLeft);
idealLeft = std::max(idealLeft, leftMinimum);
}
return ChildSizes(idealLeft, idealRight, leftMaximum> leftMinimum
&& rightMaximum> rightMinimum
&& leftMinimum + rightMinimum < width);
}
int LayoutTreeNode::DoGetSizeFlags(bool width)
{
if (!children[0]->IsVisible())
{
return children[1]->GetSizeFlags(width);
}
if (!children[1]->IsVisible())
{
return children[0]->GetSizeFlags(width);
}
int leftFlags = children[0]->GetSizeFlags(width);
int rightFlags = children[1]->GetSizeFlags(width);
return ((leftFlags | rightFlags) & ~Constants::MAX) | (leftFlags & rightFlags
& Constants::MAX);
}
-void LayoutTreeNode::DoSetBounds(const Rectangle& b)
+void LayoutTreeNode::DoSetBounds(const QRect& b)
{
if (!children[0]->IsVisible())
{
children[1]->SetBounds(b);
this->GetSash()->SetVisible(false);
return;
}
if (!children[1]->IsVisible())
{
children[0]->SetBounds(b);
this->GetSash()->SetVisible(false);
return;
}
- Rectangle bounds = b;
+ QRect bounds = b;
bool vertical = this->GetSash()->IsVertical();
// If this is a horizontal sash, flip coordinate systems so
// that we can eliminate special cases
if (!vertical)
{
- bounds.FlipXY();
+ bounds = FlipRect(bounds);
}
- ChildSizes childSizes = this->ComputeChildSizes(bounds.width, bounds.height,
- this->GetSash()->GetLeft(), this->GetSash()->GetRight(), bounds.width);
+ ChildSizes childSizes = this->ComputeChildSizes(bounds.width(), bounds.height(),
+ this->GetSash()->GetLeft(), this->GetSash()->GetRight(), bounds.width());
this->GetSash()->SetVisible(true);
this->GetSash()->SetEnabled(childSizes.resizable);
- Rectangle leftBounds = Rectangle(bounds.x, bounds.y, childSizes.left, bounds.height);
- Rectangle sashBounds = Rectangle(leftBounds.x + leftBounds.width, bounds.y, this->GetSashSize(), bounds.height);
- Rectangle
- rightBounds =
- Rectangle(sashBounds.x + sashBounds.width, bounds.y, childSizes.right, bounds.height);
+ QRect leftBounds = QRect(bounds.x(), bounds.y(), childSizes.left, bounds.height());
+ QRect sashBounds = QRect(leftBounds.x() + leftBounds.width(), bounds.y(), this->GetSashSize(), bounds.height());
+ QRect rightBounds = QRect(sashBounds.x() + sashBounds.width(), bounds.y(),
+ childSizes.right, bounds.height());
if (!vertical)
{
- leftBounds.FlipXY();
- sashBounds.FlipXY();
- rightBounds.FlipXY();
+ leftBounds = FlipRect(leftBounds);
+ sashBounds = FlipRect(sashBounds);
+ rightBounds = FlipRect(rightBounds);
}
this->GetSash()->SetBounds(sashBounds);
children[0]->SetBounds(leftBounds);
children[1]->SetBounds(rightBounds);
}
void LayoutTreeNode::CreateControl(void* parent)
{
children[0]->CreateControl(parent);
children[1]->CreateControl(parent);
this->GetSash()->CreateControl(parent);
LayoutTree::CreateControl(parent);
}
bool LayoutTreeNode::IsCompressible()
{
return children[0]->IsCompressible() || children[1]->IsCompressible();
}
int LayoutTreeNode::GetCompressionBias()
{
bool left = children[0]->IsCompressible();
bool right = children[1]->IsCompressible();
if (left == right)
{
return 0;
}
if (right)
{
return -1;
}
return 1;
}
bool LayoutTreeNode::IsLeftChild(LayoutTree::ConstPointer toTest)
{
return children[0] == toTest;
}
LayoutTree::Pointer LayoutTreeNode::GetChild(bool left)
{
int index = left ? 0 : 1;
return (children[index]);
}
void LayoutTreeNode::SetChild(bool left, LayoutPart::Pointer part)
{
LayoutTree::Pointer child(new LayoutTree(part));
this->SetChild(left, child);
this->FlushCache();
}
void LayoutTreeNode::SetChild(bool left, LayoutTree::Pointer child)
{
int index = left ? 0 : 1;
children[index] = child;
child->SetParent(this);
this->FlushCache();
}
QString LayoutTreeNode::ToString() const
{
QString str;
QTextStream s(&str);
s << "\n";
if (part->GetControl() != 0)
{
s << "<@" << part->GetControl() << ">\n";
}
QString str2;
QTextStream result(&str2);
result << "[";
if (children[0]->GetParent() != this)
{
result << str2 << "{" << children[0] << "}" << str;
}
else
{
result << str2 << children[0] << str;
}
if (children[1]->GetParent() != this)
{
result << str2 << "{" << children[1] << "}]";
}
else
{
result << str2 << children[1] << "]";
}
return str2;
}
//void LayoutTreeNode::UpdateSashes(void* parent) {
// if (parent == 0)
// return;
// children[0]->UpdateSashes(parent);
// children[1]->UpdateSashes(parent);
// if (children[0]->IsVisible() && children[1]->IsVisible())
// this->GetSash()->CreateControl(parent);
// else
// this->GetSash()->Dispose();
// }
void LayoutTreeNode::DescribeLayout(QString& buf) const
{
if (!(children[0]->IsVisible()))
{
if (!children[1]->IsVisible())
{
return;
}
children[1]->DescribeLayout(buf);
return;
}
if (!children[1]->IsVisible())
{
children[0]->DescribeLayout(buf);
return;
}
buf.append("("); //$NON-NLS-1$
children[0]->DescribeLayout(buf);
buf.append(this->GetSash()->IsVertical() ? "|" : "-");
children[1]->DescribeLayout(buf);
buf.append(")");
}
+QRect LayoutTreeNode::FlipRect(const QRect& rect)
+{
+ return QRect(rect.y(), rect.x(), rect.height(), rect.width());
+}
+
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTreeNode.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTreeNode.h
index 2f2dc90cd3..65baa5a47b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTreeNode.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTreeNode.h
@@ -1,226 +1,229 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYLAYOUTTREENODE_H_
#define BERRYLAYOUTTREENODE_H_
#include "berryLayoutTree.h"
#include "berryLayoutPartSash.h"
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
* Implementation of a tree node. The node represents a
* sash and it allways has two children.
*/
class LayoutTreeNode : public LayoutTree {
public:
berryObjectMacro(LayoutTreeNode)
struct ChildSizes {
int left;
int right;
bool resizable;
ChildSizes (int l, int r, bool resize);
};
/* The node children witch may be another node or a leaf */
private: LayoutTree::Pointer children[2];
/**
* Initialize this tree with its sash.
*/
public: LayoutTreeNode(LayoutPartSash::Pointer sash);
public: ~LayoutTreeNode();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutTree#flushChildren()
*/
public: void FlushChildren();
/**
* Traverses the tree to find the part that intersects the given point
*
* @param toFind
* @return the part that intersects the given point
*/
- public: LayoutPart::Pointer FindPart(const Point& toFind);
+ public: LayoutPart::Pointer FindPart(const QPoint& toFind);
/**
* Add the relation ship between the children in the list
* and returns the left children.
*/
public: LayoutPart::Pointer ComputeRelation(QList& relations);
/**
* Dispose all Sashs in this tree
*/
public: void DisposeSashes();
/**
* Find a LayoutPart in the tree and return its sub-tree. Returns
* null if the child is not found.
*/
public: SmartPointer Find(LayoutPart::Pointer child);
/**
* Find the part that is in the bottom right position.
*/
public: LayoutPart::Pointer FindBottomRight();
/**
* Go up in the tree finding a parent that is common of both children.
* Return the subtree.
*/
LayoutTreeNode* FindCommonParent(LayoutPart::Pointer child1, LayoutPart::Pointer child2,
bool foundChild1 = false, bool foundChild2 = false);
/**
* Find a sash in the tree and return its sub-tree. Returns
* null if the sash is not found.
*/
public: SmartPointer FindSash(LayoutPartSash::Pointer sash);
using LayoutTree::FindSashes;
/**
* Sets the elements in the array of sashes with the
* Left,Rigth,Top and Botton sashes. The elements
* may be null depending whether there is a shash
* beside the part
*/
void FindSashes(SmartPointer child, PartPane::Sashes sashes);
/**
* Returns the sash of this node.
*/
public: LayoutPartSash::Pointer GetSash() const;
private: int GetSashSize() const;
/**
* Returns true if this tree has visible parts otherwise returns false.
*/
public: bool IsVisible();
using LayoutTree::Remove;
/**
* Remove the child and this node from the tree
*/
SmartPointer Remove(SmartPointer child);
/**
* Replace a child with a new child and sets the new child's parent.
*/
void ReplaceChild(SmartPointer oldChild, SmartPointer newChild);
/**
* Go up from the subtree and return true if all the sash are
* in the direction specified by isVertical
*/
public: bool SameDirection(bool isVertical, SmartPointer subTree);
public: int DoComputePreferredSize(bool width, int availableParallel, int availablePerpendicular, int preferredParallel);
/**
* Computes the pixel sizes of this node's children, given the available
* space for this node. Note that "width" and "height" actually refer
* to the distance perpendicular and parallel to the sash respectively.
* That is, their meaning is reversed when computing a horizontal sash.
*
* @param width the pixel width of a vertical node, or the pixel height
* of a horizontal node (INF if unbounded)
* @param height the pixel height of a vertical node, or the pixel width
* of a horizontal node (INF if unbounded)
* @return a struct describing the pixel sizes of the left and right children
* (this is a width for horizontal nodes and a height for vertical nodes)
*/
ChildSizes ComputeChildSizes(int width, int height, int left, int right, int preferredWidth);
protected: int DoGetSizeFlags(bool width);
/**
* Resize the parts on this tree to fit in bounds
.
*/
- public: void DoSetBounds(const Rectangle& bounds);
+ public: void DoSetBounds(const QRect& bounds);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutTree#createControl(org.blueberry.swt.widgets.Composite)
*/
public: void CreateControl(void* parent);
//Added by hudsonr@us.ibm.com - bug 19524
public: bool IsCompressible();
/**
* Returns 0 if there is no bias. Returns -1 if the first child should be of
* fixed size, and the second child should be compressed. Returns 1 if the
* second child should be of fixed size.
* @return the bias
*/
public: int GetCompressionBias();
bool IsLeftChild(SmartPointer toTest);
SmartPointer GetChild(bool left);
/**
* Sets a child in this node
*/
void SetChild(bool left, LayoutPart::Pointer part);
/**
* Sets a child in this node
*/
void SetChild(bool left, SmartPointer child);
/**
* Returns a string representation of this object.
*/
public: QString ToString() const;
/**
* Create the sashes if the children are visible
* and dispose it if they are not.
*/
//public: void UpdateSashes(void* parent);
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they should not be translated or equality tests will fail.
*
* @param buf
*/
public: void DescribeLayout(QString& buf) const;
+private:
+
+ static QRect FlipRect(const QRect& rect);
};
}
#endif /*BERRYLAYOUTTREENODE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPartPane.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPartPane.cpp
index 4528612f65..d7bab9d5ed 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPartPane.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPartPane.cpp
@@ -1,464 +1,464 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryPartPane.h"
#include "tweaklets/berryWorkbenchPageTweaklet.h"
#include "berryWorkbenchPage.h"
#include "berryPartStack.h"
#include "berryEditorAreaHelper.h"
#include "berryPerspective.h"
#include "berryPartStack.h"
#include "berryDragUtil.h"
namespace berry
{
PartPane::Sashes::Sashes() :
left(0), right(0), top(0), bottom(0)
{
}
PartPane::PartPane(IWorkbenchPartReference::Pointer partReference,
WorkbenchPage* workbenchPage)
: LayoutPart(partReference->GetId()),
control(0), inLayout(true), busy(false), hasFocus(false)
{
//super(partReference.getId());
this->partReference = partReference;
this->page = workbenchPage;
}
void PartPane::CreateControl(void* parent) {
if (this->GetControl() != 0)
{
return;
}
partReference.Lock()->AddPropertyListener(this);
// Create view form.
control = Tweaklets::Get(WorkbenchPageTweaklet::KEY)->CreatePaneControl(parent);
// the part should never be visible by default. It will be made visible
// by activation. This allows us to have views appear in tabs without
// becoming active by default.
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(control, false);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->MoveAbove(control, 0);
// Create a title bar.
//this->CreateTitleBar();
// When the pane or any child gains focus, notify the workbench.
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(control, GuiTk::IControlListener::Pointer(this));
//control.addTraverseListener(traverseListener);
}
PartPane::~PartPane()
{
// super.dispose();
//
this->Register();
if (control != 0)
{
BERRY_DEBUG << "Deleting PartPane control";
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->RemoveControlListener(control, GuiTk::IControlListener::Pointer(this));
// control.removeTraverseListener(traverseListener);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->Dispose(control);
control = 0;
}
// if ((paneMenuManager != null))
// {
// paneMenuManager.dispose();
// paneMenuManager = null;
// }
//
if (!partReference.Expired())
{
partReference.Lock()->RemovePropertyListener(this);
}
// partReference.removePartPropertyListener(this);
this->UnRegister(false);
}
void PartPane::DoHide()
{
if (partReference.Lock().Cast() != 0)
{
this->GetPage()->HideView(partReference.Lock().Cast());
}
else if (partReference.Lock().Cast() != 0)
{
this->GetPage()->CloseEditor(partReference.Lock().Cast(), true);
}
}
-Rectangle PartPane::GetParentBounds()
+QRect PartPane::GetParentBounds()
{
void* ctrl = this->GetControl();
if (this->GetContainer() != 0 && this->GetContainer().Cast() != 0)
{
LayoutPart::Pointer part = this->GetContainer().Cast();
if (part->GetControl() != 0)
{
ctrl = part->GetControl();
}
}
return DragUtil::GetDisplayBounds(ctrl);
}
void* PartPane::GetControl()
{
return control;
}
IWorkbenchPartReference::Pointer PartPane::GetPartReference() const
{
return partReference.Lock();
}
void PartPane::ControlActivated(GuiTk::ControlEvent::Pointer /*e*/)
{
if (inLayout)
{
this->RequestActivation();
}
}
GuiTk::IControlListener::Events::Types PartPane::GetEventTypes() const
{
return GuiTk::IControlListener::Events::ACTIVATED;
}
void PartPane::MoveAbove(void* refControl)
{
if (this->GetControl() != 0)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->MoveAbove(this->GetControl(), refControl);
}
}
void PartPane::RequestActivation()
{
IWorkbenchPart::Pointer part = partReference.Lock()->GetPart(true);
this->page->RequestActivation(part);
}
//PartStack::Pointer PartPane::GetStack()
//{
// return partStack;
//}
PartPane::Sashes PartPane::FindSashes()
{
Sashes result;
ILayoutContainer::Pointer container = this->GetContainer();
if (container == 0) {
return result;
}
container->FindSashes(LayoutPart::Pointer(this), result);
return result;
}
WorkbenchPage::Pointer PartPane::GetPage()
{
return WorkbenchPage::Pointer(page);
}
void PartPane::SetContainer(ILayoutContainer::Pointer container)
{
if (hasFocus)
{
ILayoutContainer::Pointer oldContainer = this->GetContainer();
if (PartStack::Pointer oldStack = oldContainer.Cast())
{
oldStack->SetActive(StackPresentation::AS_INACTIVE);
}
if (PartStack::Pointer newContainer = container.Cast())
{
newContainer->SetActive(StackPresentation::AS_ACTIVE_FOCUS);
}
}
void* containerControl = container == 0 ? 0 : container.Cast()->GetControl();
if (containerControl != 0)
{
void* control = this->GetControl();
void* newParent = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(containerControl);
if (control != 0 && newParent != Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(control))
{
this->Reparent(newParent);
}
}
LayoutPart::SetContainer(container);
}
void PartPane::Reparent(void* newParent)
{
void* control = this->GetControl();
GuiWidgetsTweaklet* guiTweaklet = Tweaklets::Get(GuiWidgetsTweaklet::KEY);
if ((control == 0) || (guiTweaklet->GetParent(control) == newParent))
{
return;
}
if (guiTweaklet->IsReparentable(control))
{
// make control small in case it is not resized with other controls
//control.setBounds(0, 0, 0, 0);
// By setting the control to disabled before moving it,
// we ensure that the focus goes away from the control and its children
// and moves somewhere else
bool enabled = guiTweaklet->GetEnabled(control);
guiTweaklet->SetEnabled(control, false);
guiTweaklet->SetParent(control, newParent);
guiTweaklet->SetEnabled(control, enabled);
guiTweaklet->MoveAbove(control, 0);
}
}
void PartPane::ShowFocus(bool inFocus)
{
if (partReference.Lock().Cast() != 0)
{
hasFocus = inFocus;
}
if (PartStack::Pointer stack = this->GetContainer().Cast())
{
if (partReference.Lock().Cast() != 0)
{
stack->SetActive(inFocus ? StackPresentation::AS_ACTIVE_FOCUS
: StackPresentation::AS_INACTIVE);
}
else if (partReference.Lock().Cast() != 0)
{
if (inFocus)
{
page->GetEditorPresentation()->SetActiveWorkbook(stack, true);
}
else
{
stack->SetActive(page->GetEditorPresentation()->GetActiveWorkbook() == stack ?
StackPresentation::AS_ACTIVE_NOFOCUS : StackPresentation::AS_INACTIVE);
}
}
}
}
PartStack::Pointer PartPane::GetStack()
{
ILayoutContainer::Pointer container = this->GetContainer();
return container.Cast();
}
void PartPane::SetVisible(bool makeVisible)
{
// Avoid redundant visibility changes
if (makeVisible == this->GetVisible())
{
return;
}
if (makeVisible)
{
partReference.Lock()->GetPart(true);
}
if (this->GetControl() != 0)
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(this->GetControl(), makeVisible);
partReference.Lock().Cast()->FireVisibilityChange();
}
bool PartPane::GetVisible()
{
if (this->GetControl() != 0)
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetVisible(this->GetControl());
return false;
}
void PartPane::SetFocus()
{
this->RequestActivation();
IWorkbenchPart::Pointer part = partReference.Lock()->GetPart(true);
if (part.IsNotNull())
{
// Control control = getControl();
// if (!SwtUtil.isFocusAncestor(control))
// {
// First try to call part.setFocus
part->SetFocus();
//}
}
}
void PartPane::SetWorkbenchPage(WorkbenchPage::Pointer workbenchPage)
{
this->page = workbenchPage.GetPointer();
}
void PartPane::DoDock()
{
// do nothing
}
void PartPane::SetBusy(bool isBusy)
{
if (isBusy != busy)
{
busy = isBusy;
//firePropertyChange(IPresentablePart.PROP_BUSY);
}
}
void PartPane::ShowHighlight()
{
//No nothing by default
}
void* PartPane::GetToolBar()
{
return 0;
}
bool PartPane::HasViewMenu()
{
return false;
}
bool PartPane::IsBusy()
{
return busy;
}
void PartPane::DescribeLayout(QString& buf) const
{
IWorkbenchPartReference::Pointer part = this->GetPartReference();
if (part.IsNotNull())
{
buf.append(part->GetPartName());
return;
}
}
bool PartPane::IsCloseable()
{
if (partReference.Lock().Cast() != 0)
{
Perspective::Pointer perspective = page->GetActivePerspective();
if (perspective == 0) {
// Shouldn't happen -- can't have a ViewStack without a
// perspective
return true;
}
return perspective->IsCloseable(partReference.Lock().Cast());
}
return true;
}
void PartPane::SetInLayout(bool inLayout)
{
this->inLayout = inLayout;
}
bool PartPane::GetInLayout()
{
return inLayout;
}
bool PartPane::AllowsAutoFocus()
{
if (!inLayout)
{
return false;
}
//return super.allowsAutoFocus();
return true;
}
void PartPane::RemoveContributions()
{
}
void PartPane::AddPropertyListener(IPropertyChangeListener *listener)
{
propertyChangeEvents.AddListener(listener);
}
void PartPane::RemovePropertyListener(IPropertyChangeListener *listener)
{
propertyChangeEvents.RemoveListener(listener);
}
void PartPane::FirePropertyChange(const PropertyChangeEvent::Pointer& event)
{
propertyChangeEvents.propertyChange(event);
}
void PartPane::PropertyChange(const PropertyChangeEvent::Pointer& event)
{
this->FirePropertyChange(event);
}
int PartPane::ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
return partReference.Lock().Cast()->ComputePreferredSize(width,
availableParallel, availablePerpendicular, preferredParallel);
}
int PartPane::GetSizeFlags(bool horizontal)
{
return partReference.Lock().Cast()->GetSizeFlags(horizontal);
}
void PartPane::ShellActivated()
{
}
void PartPane::ShellDeactivated()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPartPane.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPartPane.h
index 0dcb80ac98..181bb7cf83 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPartPane.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPartPane.h
@@ -1,437 +1,436 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYPARTPANE_H_
#define BERRYPARTPANE_H_
#include "berryWorkbenchPartReference.h"
#include "berryLayoutPart.h"
-#include "berryRectangle.h"
#include "berryIPropertyChangeListener.h"
#include "guitk/berryGuiTkIControlListener.h"
namespace berry {
class WorkbenchPage;
class PartStack;
struct ILayoutContainer;
/**
* Provides the common behavior for both views
* and editor panes.
*
*/
class PartPane : public LayoutPart,
public IPropertyChangeListener,
public GuiTk::IControlListener
{
public:
berryObjectMacro(PartPane)
friend class PartSashContainer;
friend class EditorSashContainer;
friend class WorkbenchPage;
friend struct ILayoutContainer;
friend class PartStack;
friend class ContainerPlaceholder;
friend class LayoutTree;
friend class LayoutTreeNode;
friend class DetachedPlaceHolder;
friend class PerspectiveHelper;
// private: MenuManager paneMenuManager;
// private: ListenerList listeners = new ListenerList();
// private: ListenerList partListeners = new ListenerList();
private: IPropertyChangeListener::Events propertyChangeEvents;
protected: IWorkbenchPartReference::WeakPtr partReference;
protected: WorkbenchPage* page;
protected: void* control;
private: bool inLayout;
// private: TraverseListener traverseListener = new TraverseListener() {
// /* (non-Javadoc)
// * @see org.blueberry.swt.events.TraverseListener#keyTraversed(org.blueberry.swt.events.TraverseEvent)
// */
// public: void keyTraversed(TraverseEvent e) {
// // Hack: Currently, SWT sets focus whenever we call Control.traverse. This doesn't
// // cause too much of a problem for ctrl-pgup and ctrl-pgdn, but it is seriously unexpected
// // for other traversal events. When (and if) it becomes possible to call traverse() without
// // forcing a focus change, this if statement should be removed and ALL events should be
// // forwarded to the container.
// if (e.detail == SWT.TRAVERSE_PAGE_NEXT
// || e.detail == SWT.TRAVERSE_PAGE_PREVIOUS) {
// ILayoutContainer container = getContainer();
// if (container != null && container instanceof LayoutPart) {
// LayoutPart parent = (LayoutPart) container;
// Control parentControl = parent.getControl();
// if (parentControl != null && !parentControl.isDisposed()) {
// e.doit = parentControl.traverse(e.detail);
// if (e.doit) {
// e.detail = SWT.TRAVERSE_NONE;
// }
// }
// }
// }
// }
//
// };
private: bool busy;
private: bool hasFocus;
//private: SmartPointer partStack;
protected:
/*static*/ class Sashes {
public:
Sashes();
/*Sash*/ void* left;
/*Sash*/ void* right;
/*Sash*/ void* top;
/*Sash*/ void* bottom;
};
/**
* Construct a pane for a part.
*/
public: PartPane(IWorkbenchPartReference::Pointer partReference,
WorkbenchPage* workbenchPage);
// public: void addSizeMenuItem(Menu menu, int index) {
// //Add size menu
// MenuItem item = new MenuItem(menu, SWT.CASCADE, index);
// item.setText(WorkbenchMessages.PartPane_size);
// Menu sizeMenu = new Menu(menu);
// item.setMenu(sizeMenu);
// addSizeItems(sizeMenu);
// }
/**
*
* Creates the GUI-dependent container control
* for the part widgets. This is passed to
* IWorkbenchPart::CreatePartControl(void*)
*/
public: virtual void CreateControl(void* parent);
//public: virtual void SetControlEnabled(bool enabled) = 0;
/**
* Create a title bar for the pane if required.
*/
// protected: virtual void CreateTitleBar() = 0;
/**
* @private:
*/
public: virtual ~PartPane();
/**
* User has requested to close the pane.
* Take appropriate action depending on type.
*/
public: void DoHide();
- protected: Rectangle GetParentBounds();
+ protected: QRect GetParentBounds();
/**
* Get the control.
*/
public: void* GetControl();
/**
* Answer the part child.
*/
public: IWorkbenchPartReference::Pointer GetPartReference() const;
/**
* @see GuiTk::IControlListener
*/
public: void ControlActivated(GuiTk::ControlEvent::Pointer e);
/**
* @see GuiTk::IControlListener
*/
public: GuiTk::IControlListener::Events::Types GetEventTypes() const;
/**
* Move the control over another one.
*/
public: void MoveAbove(void* refControl);
/**
* Notify the workbook page that the part pane has
* been activated by the user.
*/
public: void RequestActivation();
/**
* Shows the receiver if visible
is true otherwise hide it.
*/
public: void SetVisible(bool makeVisible);
public: virtual bool GetVisible();
/**
* Sets focus to this part.
*/
public: void SetFocus();
/**
* Sets the workbench page of the view.
*/
public: void SetWorkbenchPage(SmartPointer workbenchPage);
public: void Reparent(void* newParent);
/**
* Indicate focus in part.
*/
public: void ShowFocus(bool inFocus);
/**
* @see IPartDropTarget::targetPartFor
*/
// public: LayoutPart targetPartFor(LayoutPart dragSource) {
// return this;
// }
/**
* Returns the PartStack that contains this PartPane, or null if none.
*
* @return
*/
public: SmartPointer GetStack();
public: void SetContainer(SmartPointer stack);
/**
* Show a title label menu for this pane.
*/
// public: void ShowPaneMenu() {
// PartStack folder = getStack();
//
// if (folder != null) {
// folder.showPaneMenu();
// }
// }
/**
* Show the context menu for this part.
*/
// public: void showSystemMenu() {
// PartStack folder = getStack();
//
// if (folder != null) {
// folder.showSystemMenu();
// }
// }
/**
* Finds and return the sashes around this part.
*/
protected: Sashes FindSashes();
/**
* Enable the user to resize this part using
* the keyboard to move the specified sash
*/
// protected: void moveSash(final Sash sash) {
// moveSash(sash, this);
// }
// public: static void moveSash(final Sash sash,
// final LayoutPart toGetFocusWhenDone) {
// final KeyListener listener = new KeyAdapter() {
// public: void keyPressed(KeyEvent e) {
// if (e.character == SWT.ESC || e.character == '\r') {
// if (toGetFocusWhenDone != null) {
// toGetFocusWhenDone.setFocus();
// }
// }
// }
// };
// sash.addFocusListener(new FocusAdapter() {
// public: void focusGained(FocusEvent e) {
// sash.setBackground(sash.getDisplay().getSystemColor(
// SWT.COLOR_LIST_SELECTION));
// sash.addKeyListener(listener);
// }
//
// public: void focusLost(FocusEvent e) {
// sash.setBackground(null);
// sash.removeKeyListener(listener);
// }
// });
// sash.setFocus();
//
// }
/**
* Add a menu item to the Size Menu
*/
// protected: void addSizeItem(Menu sizeMenu, String labelMessage,
// final Sash sash) {
// MenuItem item = new MenuItem(sizeMenu, SWT.NONE);
// item.setText(labelMessage);
// item.addSelectionListener(new SelectionAdapter() {
// public: void widgetSelected(SelectionEvent e) {
// moveSash(sash);
// }
// });
// item.setEnabled(!isZoomed() && sash != null);
// }
/**
* Returns the workbench page of this pane.
*/
public: SmartPointer GetPage();
/**
* Add the Left,Right,Up,Botton menu items to the Size menu.
*/
// protected: void addSizeItems(Menu sizeMenu) {
// Sashes sashes = findSashes();
// addSizeItem(sizeMenu,
// WorkbenchMessages.PartPane_sizeLeft, sashes.left);
// addSizeItem(sizeMenu,
// WorkbenchMessages.PartPane_sizeRight, sashes.right);
// addSizeItem(sizeMenu,
// WorkbenchMessages.PartPane_sizeTop, sashes.top);
// addSizeItem(sizeMenu, WorkbenchMessages.PartPane_sizeBottom, sashes.bottom);
// }
/**
* Pin this part.
*/
protected: virtual void DoDock();
/**
* Set the busy state of the pane.
*/
public: virtual void SetBusy(bool isBusy);
/**
* Show a highlight for the receiver if it is
* not currently the part in the front of its
* presentation.
*
*/
public: virtual void ShowHighlight();
/**
* @return
*/
public: virtual void* GetToolBar();
/**
* @return
*/
public: bool HasViewMenu();
/**
* @param location
*/
// public: void ShowViewMenu(Point location) {
//
// }
public: bool IsBusy();
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they do not need to be translated.
*
* @param buf
*/
public: void DescribeLayout(QString& buf) const;
/**
* @return
* @since 3.1
*/
public: bool IsCloseable();
public: void SetInLayout(bool inLayout);
public: bool GetInLayout();
public: bool AllowsAutoFocus();
/**
* Clears all contribution items from the contribution managers (this is done separately
* from dispose() since it is done after the part is disposed). This is a bit of a hack.
* Really, the contribution managers should be part of the site, not the PartPane. If these
* were moved elsewhere, then disposal of the PartPane would be atomic and this method could
* be removed.
*/
public: virtual void RemoveContributions();
public: void AddPropertyListener(IPropertyChangeListener* listener);
public: void RemovePropertyListener(IPropertyChangeListener* listener);
public: void FirePropertyChange(const PropertyChangeEvent::Pointer& event);
/* (non-Javadoc)
* @see IPropertyChangeListener#PropertyChange(PropertyChangeEvent::Pointer)
*/
public:
using IPropertyChangeListener::PropertyChange;
void PropertyChange(const PropertyChangeEvent::Pointer& event);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#computePreferredSize(boolean, int, int, int)
*/
public: int ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#getSizeFlags(boolean)
*/
public: int GetSizeFlags(bool horizontal);
/**
* Informs the pane that it's window shell has
* been activated.
*/
public: virtual void ShellActivated();
/**
* Informs the pane that it's window shell has
* been deactivated.
*/
public: virtual void ShellDeactivated();
};
}
#endif /*BERRYPARTPANE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPartSashContainer.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPartSashContainer.cpp
index 6bf4bd7481..128666fdda 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPartSashContainer.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPartSashContainer.cpp
@@ -1,1272 +1,1274 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryPartSashContainer.h"
#include "berryLayoutTree.h"
#include "berryLayoutTreeNode.h"
#include "berryPartStack.h"
#include "berryPageLayout.h"
#include "berryPerspective.h"
#include "berryPerspectiveHelper.h"
#include "berryDragUtil.h"
#include "berryWorkbenchPlugin.h"
#include "berryIPreferencesService.h"
#include "berryIPreferences.h"
#include "berryWorkbenchPreferenceConstants.h"
#include "berryGeometry.h"
#include "berryPartPane.h"
+#include "berryQtTracker.h"
+
#include "berryConstants.h"
namespace berry
{
bool PartSashContainer::leftToRight = true;
PartSashContainer::ControlListener::ControlListener(
PartSashContainer* container) :
partSashContainer(container)
{
}
GuiTk::IControlListener::Events::Types PartSashContainer::ControlListener::GetEventTypes() const
{
return Events::RESIZED;
}
void PartSashContainer::ControlListener::ControlResized(
GuiTk::ControlEvent::Pointer /*e*/)
{
partSashContainer->ResizeSashes();
}
PartSashContainer::SashContainerDropTarget::SashContainerDropTarget(
PartSashContainer* partSashContainer, Object::Pointer sourcePart, int side,
int cursor, Object::Pointer targetPart) :
partSashContainer(partSashContainer)
{
this->SetTarget(sourcePart, side, cursor, targetPart);
}
void PartSashContainer::SashContainerDropTarget::SetTarget(
Object::Pointer sourcePart, int side, int cursor,
Object::Pointer targetPart)
{
this->side = side;
this->targetPart = targetPart;
this->sourcePart = sourcePart;
this->cursor = cursor;
}
void PartSashContainer::SashContainerDropTarget::Drop()
{
if (side != Constants::NONE)
{
LayoutPart::Pointer visiblePart = sourcePart.Cast ();
if (sourcePart.Cast () != 0)
{
visiblePart = partSashContainer->GetVisiblePart(sourcePart.Cast<
ILayoutContainer> ());
}
partSashContainer->DropObject(
partSashContainer->GetVisibleParts(sourcePart), visiblePart,
targetPart, side);
}
}
void PartSashContainer::DropObject(const QList& toDrop,
LayoutPart::Pointer visiblePart, Object::Pointer targetPart, int side)
{
//getControl().setRedraw(false);
// Targetpart is null if there isn't a part under the cursor (all the parts are
// hidden or the container is empty). In this case, the actual side doesn't really
// since we'll be the only visible container and will fill the entire space. However,
// we can't leave it as Constants::CENTER since we can't stack if we don't have something
// to stack on. In this case, we pick Constants::BOTTOM -- this will insert the new pane
// below any currently-hidden parts.
if (targetPart == 0 && side == Constants::CENTER)
{
side = Constants::BOTTOM;
}
PartStack::Pointer targetStack = targetPart.Cast ();
if (targetStack == 0 && targetPart.Cast() != 0)
{
targetStack = targetPart.Cast ()->GetStack();
}
LayoutPart::Pointer targetLayoutPart = targetStack;
// if targetLayoutPart == 0 then we normally got a EditorSashContainer
if (targetLayoutPart == 0)
targetLayoutPart = targetPart.Cast();
if (side == Constants::CENTER)
{
if (this->IsStackType(targetStack))
{
for (int idx = 0; idx < toDrop.size(); idx++)
{
LayoutPart::Pointer next = toDrop[idx];
this->Stack(next, targetStack);
}
}
}
else
{
PartStack::Pointer newPart = this->CreateStack();
// if the toDrop array has 1 item propagate the stack
// appearance
if (toDrop.size() == 1 && toDrop[0]->GetStack() != 0)
{
toDrop[0]->GetStack()->CopyAppearanceProperties(newPart);
}
for (int idx = 0; idx < toDrop.size(); idx++)
{
LayoutPart::Pointer next = toDrop[idx];
this->Stack(next, newPart);
}
this->AddEnhanced(newPart, side, this->GetDockingRatio(newPart, targetStack),
targetLayoutPart);
}
if (visiblePart != 0)
{
this->SetVisiblePart(visiblePart->GetContainer(),
visiblePart.Cast