Style changes by Vasilis Kaoutsis.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21460 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2007-06-18 17:35:48 +00:00
parent ffcd67bc82
commit 5680c33e48
25 changed files with 412 additions and 403 deletions
+96 -54
View File
@@ -1,5 +1,11 @@
// DiagramBox.cpp // DiagramBox.cpp
/*! \class DiagramBox
DiagramItem subclass providing a basic framework for
boxes in diagrams, i.e. objects that can contain various
endpoints
*/
#include "DiagramBox.h" #include "DiagramBox.h"
#include "DiagramDefs.h" #include "DiagramDefs.h"
#include "DiagramEndPoint.h" #include "DiagramEndPoint.h"
@@ -23,8 +29,8 @@ __USE_CORTEX_NAMESPACE
DiagramBox::DiagramBox(BRect frame, uint32 flags) DiagramBox::DiagramBox(BRect frame, uint32 flags)
: DiagramItem(DiagramItem::M_BOX), : DiagramItem(DiagramItem::M_BOX),
DiagramItemGroup(DiagramItem::M_ENDPOINT), DiagramItemGroup(DiagramItem::M_ENDPOINT),
m_frame(frame), fFrame(frame),
m_flags(flags) fFlags(flags)
{ {
D_METHOD(("DiagramBox::DiagramBox()\n")); D_METHOD(("DiagramBox::DiagramBox()\n"));
makeDraggable(true); makeDraggable(true);
@@ -37,7 +43,13 @@ DiagramBox::~DiagramBox()
} }
// derived from DiagramItemGroup (public) // #pragma mark - derived from DiagramItemGroup (public)
/*! Extends the DiagramItemGroup implementation by setting
the items owner and calling the attachedToDiagram() hook
on it
*/
bool bool
DiagramBox::AddItem(DiagramItem *item) DiagramBox::AddItem(DiagramItem *item)
{ {
@@ -45,7 +57,7 @@ DiagramBox::AddItem(DiagramItem *item)
if (item) { if (item) {
if (DiagramItemGroup::AddItem(item)) { if (DiagramItemGroup::AddItem(item)) {
if (m_view) { if (m_view) {
item->_setOwner(m_view); item->_SetOwner(m_view);
item->attachedToDiagram(); item->attachedToDiagram();
} }
return true; return true;
@@ -55,6 +67,9 @@ DiagramBox::AddItem(DiagramItem *item)
} }
/*! Extends the DiagramItemGroup implementation by calling
the detachedToDiagram() hook on the \a item
*/
bool bool
DiagramBox::RemoveItem(DiagramItem *item) DiagramBox::RemoveItem(DiagramItem *item)
{ {
@@ -62,7 +77,7 @@ DiagramBox::RemoveItem(DiagramItem *item)
if (item) { if (item) {
item->detachedFromDiagram(); item->detachedFromDiagram();
if (DiagramItemGroup::RemoveItem(item)) { if (DiagramItemGroup::RemoveItem(item)) {
item->_setOwner(0); item->_SetOwner(0);
return true; return true;
} }
} }
@@ -70,41 +85,46 @@ DiagramBox::RemoveItem(DiagramItem *item)
} }
// derived from DiagramItem (public) // #pragma mark - derived from DiagramItem (public)
/*! Prepares the drawing stack and clipping region, then
calls drawBox
*/
void void
DiagramBox::draw(BRect updateRect) DiagramBox::Draw(BRect updateRect)
{ {
D_DRAW(("DiagramBox::draw()\n")); D_DRAW(("DiagramBox::Draw()\n"));
if (view()) { if (view()) {
view()->PushState(); view()->PushState();
{ {
if (m_flags & M_DRAW_UNDER_ENDPOINTS) { if (fFlags & M_DRAW_UNDER_ENDPOINTS) {
BRegion region, clipping; BRegion region, clipping;
region.Include(frame()); region.Include(Frame());
if (group()->GetClippingAbove(this, &clipping)) if (group()->GetClippingAbove(this, &clipping))
region.Exclude(&clipping); region.Exclude(&clipping);
view()->ConstrainClippingRegion(&region); view()->ConstrainClippingRegion(&region);
drawBox(); DrawBox();
for (uint32 i = 0; i < CountItems(); i++) { for (uint32 i = 0; i < CountItems(); i++) {
DiagramItem *item = ItemAt(i); DiagramItem *item = ItemAt(i);
if (region.Intersects(item->frame())) if (region.Intersects(item->Frame()))
item->draw(item->frame()); item->Draw(item->Frame());
} }
} else { } else {
BRegion region, clipping; BRegion region, clipping;
region.Include(frame()); region.Include(Frame());
if (view()->GetClippingAbove(this, &clipping)) if (view()->GetClippingAbove(this, &clipping))
region.Exclude(&clipping); region.Exclude(&clipping);
for (uint32 i = 0; i < CountItems(); i++) { for (uint32 i = 0; i < CountItems(); i++) {
DiagramItem *item = ItemAt(i); DiagramItem *item = ItemAt(i);
BRect r; BRect r;
if (region.Intersects(r = item->frame())) { if (region.Intersects(r = item->Frame())) {
item->draw(r); item->Draw(r);
region.Exclude(r); region.Exclude(r);
} }
} }
view()->ConstrainClippingRegion(&region); view()->ConstrainClippingRegion(&region);
drawBox(); DrawBox();
} }
} }
view()->PopState(); view()->PopState();
@@ -112,13 +132,16 @@ DiagramBox::draw(BRect updateRect)
} }
/*! Is called from the parent DiagramViews MouseDown() implementation
if the Box was hit; this version initiates selection and dragging
*/
void void
DiagramBox::mouseDown(BPoint point, uint32 buttons, uint32 clicks) DiagramBox::MouseDown(BPoint point, uint32 buttons, uint32 clicks)
{ {
D_MOUSE(("DiagramBox::mouseDown()\n")); D_MOUSE(("DiagramBox::MouseDown()\n"));
DiagramItem *item = ItemUnder(point); DiagramItem *item = ItemUnder(point);
if (item) if (item)
item->mouseDown(point, buttons, clicks); item->MouseDown(point, buttons, clicks);
else if (clicks == 1) { else if (clicks == 1) {
if (isSelectable()) { if (isSelectable()) {
BMessage selectMsg(M_SELECTION_CHANGED); BMessage selectMsg(M_SELECTION_CHANGED);
@@ -133,119 +156,138 @@ DiagramBox::mouseDown(BPoint point, uint32 buttons, uint32 clicks)
if (isDraggable() && (buttons == B_PRIMARY_MOUSE_BUTTON)) { if (isDraggable() && (buttons == B_PRIMARY_MOUSE_BUTTON)) {
BMessage dragMsg(M_BOX_DRAGGED); BMessage dragMsg(M_BOX_DRAGGED);
dragMsg.AddPointer("item", static_cast<void *>(this)); dragMsg.AddPointer("item", static_cast<void *>(this));
dragMsg.AddPoint("offset", point - frame().LeftTop()); dragMsg.AddPoint("offset", point - Frame().LeftTop());
view()->DragMessage(&dragMsg, BRect(0.0, 0.0, -1.0, -1.0), view()); view()->DragMessage(&dragMsg, BRect(0.0, 0.0, -1.0, -1.0), view());
} }
} }
} }
/*! Is called from the DiagramViews MouseMoved() when no message is being
dragged, but the mouse has moved above the box
*/
void void
DiagramBox::mouseOver(BPoint point, uint32 transit) DiagramBox::MouseOver(BPoint point, uint32 transit)
{ {
D_MOUSE(("DiagramBox::mouseOver()\n")); D_MOUSE(("DiagramBox::MouseOver()\n"));
DiagramItem *last = _LastItemUnder(); DiagramItem *last = _LastItemUnder();
if (last && (transit == B_EXITED_VIEW)) { if (last && (transit == B_EXITED_VIEW)) {
last->mouseOver(point, B_EXITED_VIEW); last->MouseOver(point, B_EXITED_VIEW);
_ResetItemUnder(); _ResetItemUnder();
} else { } else {
DiagramItem *item = ItemUnder(point); DiagramItem *item = ItemUnder(point);
if (item) { if (item) {
if (item != last) { if (item != last) {
if (last) if (last)
last->mouseOver(point, B_EXITED_VIEW); last->MouseOver(point, B_EXITED_VIEW);
item->mouseOver(point, B_ENTERED_VIEW); item->MouseOver(point, B_ENTERED_VIEW);
} else } else
item->mouseOver(point, B_INSIDE_VIEW); item->MouseOver(point, B_INSIDE_VIEW);
} }
else if (last) else if (last)
last->mouseOver(point, B_EXITED_VIEW); last->MouseOver(point, B_EXITED_VIEW);
} }
} }
/*! Is called from the DiagramViews MouseMoved() when a message is being
dragged over the DiagramBox
*/
void void
DiagramBox::messageDragged(BPoint point, uint32 transit, const BMessage *message) DiagramBox::MessageDragged(BPoint point, uint32 transit, const BMessage *message)
{ {
D_MOUSE(("DiagramBox::messageDragged()\n")); D_MOUSE(("DiagramBox::MessageDragged()\n"));
DiagramItem *last = _LastItemUnder(); DiagramItem *last = _LastItemUnder();
if (last && (transit == B_EXITED_VIEW)) { if (last && (transit == B_EXITED_VIEW)) {
last->messageDragged(point, B_EXITED_VIEW, message); last->MessageDragged(point, B_EXITED_VIEW, message);
_ResetItemUnder(); _ResetItemUnder();
} else { } else {
DiagramItem *item = ItemUnder(point); DiagramItem *item = ItemUnder(point);
if (item) { if (item) {
if (item != last) { if (item != last) {
if (last) if (last)
last->messageDragged(point, B_EXITED_VIEW, message); last->MessageDragged(point, B_EXITED_VIEW, message);
item->messageDragged(point, B_ENTERED_VIEW, message); item->MessageDragged(point, B_ENTERED_VIEW, message);
} else } else
item->messageDragged(point, B_INSIDE_VIEW, message); item->MessageDragged(point, B_INSIDE_VIEW, message);
return; return;
} else if (last) } else if (last)
last->messageDragged(point, B_EXITED_VIEW, message); last->MessageDragged(point, B_EXITED_VIEW, message);
if (message->what == M_WIRE_DRAGGED) if (message->what == M_WIRE_DRAGGED)
view()->trackWire(point); view()->trackWire(point);
} }
} }
/*! Is called from the DiagramViews MessageReceived() function when a
message has been dropped on the DiagramBox
*/
void void
DiagramBox::messageDropped(BPoint point, BMessage *message) DiagramBox::MessageDropped(BPoint point, BMessage *message)
{ {
D_METHOD(("DiagramBox::messageDropped()\n")); D_METHOD(("DiagramBox::MessageDropped()\n"));
DiagramItem *item = ItemUnder(point); DiagramItem *item = ItemUnder(point);
if (item) { if (item) {
item->messageDropped(point, message); item->MessageDropped(point, message);
return; return;
} }
} }
// operations (public) // #pragma mark - operations (public)
/*! Moves the box by a given amount, and returns in updateRegion the
frames of wires impacted by the move
*/
void void
DiagramBox::moveBy(float x, float y, BRegion *wireRegion) DiagramBox::MoveBy(float x, float y, BRegion *wireRegion)
{ {
D_METHOD(("DiagramBox::moveBy()\n")); D_METHOD(("DiagramBox::MoveBy()\n"));
if (view()) { if (view()) {
view()->PushState(); view()->PushState();
{ {
for (uint32 i = 0; i < CountItems(); i++) { for (uint32 i = 0; i < CountItems(); i++) {
DiagramEndPoint *endPoint = dynamic_cast<DiagramEndPoint *>(ItemAt(i)); DiagramEndPoint *endPoint = dynamic_cast<DiagramEndPoint *>(ItemAt(i));
if (endPoint) if (endPoint)
endPoint->moveBy(x, y, wireRegion); endPoint->MoveBy(x, y, wireRegion);
} }
if (wireRegion) { if (wireRegion) {
wireRegion->Include(m_frame); wireRegion->Include(fFrame);
m_frame.OffsetBy(x, y); fFrame.OffsetBy(x, y);
wireRegion->Include(m_frame); wireRegion->Include(fFrame);
} }
else else
m_frame.OffsetBy(x, y); fFrame.OffsetBy(x, y);
} }
view()->PopState(); view()->PopState();
} }
} }
//! Resizes the boxes frame without doing any updating
void void
DiagramBox::resizeBy(float horizontal, float vertical) DiagramBox::ResizeBy(float horizontal, float vertical)
{ {
D_METHOD(("DiagramBox::resizeBy()\n")); D_METHOD(("DiagramBox::ResizeBy()\n"));
m_frame.right += horizontal; fFrame.right += horizontal;
m_frame.bottom += vertical; fFrame.bottom += vertical;
} }
// internal operations (private) // #pragma mark - internal operations (private)
//! Is called by the DiagramView when added
void void
DiagramBox::_setOwner(DiagramView *owner) DiagramBox::_SetOwner(DiagramView *owner)
{ {
D_METHOD(("DiagramBox::_setOwner()\n")); D_METHOD(("DiagramBox::_SetOwner()\n"));
m_view = owner; m_view = owner;
for (uint32 i = 0; i < CountItems(DiagramItem::M_ENDPOINT); i++) { for (uint32 i = 0; i < CountItems(DiagramItem::M_ENDPOINT); i++) {
DiagramItem *item = ItemAt(i); DiagramItem *item = ItemAt(i);
item->_setOwner(m_view); item->_SetOwner(m_view);
if (m_view) if (m_view)
item->attachedToDiagram(); item->attachedToDiagram();
} }
+27 -57
View File
@@ -1,10 +1,5 @@
// DiagramBox.h (Cortex/DiagramView.h) // DiagramBox.h (Cortex/DiagramView.h)
// //
// * PURPOSE
// DiagramItem subclass providing a basic framework for
// boxes in diagrams, i.e. objects that can contain various
// endpoints
//
// * HISTORY // * HISTORY
// c.lenz 25sep99 Begun // c.lenz 25sep99 Begun
// //
@@ -23,80 +18,55 @@ __BEGIN_CORTEX_NAMESPACE
class DiagramBox : public DiagramItem, public DiagramItemGroup { class DiagramBox : public DiagramItem, public DiagramItemGroup {
public: // flags
enum flag_t {
M_DRAW_UNDER_ENDPOINTS = 0x1
};
public: public:
DiagramBox(BRect frame, uint32 flags = 0); DiagramBox(BRect frame, uint32 flags = 0);
virtual ~DiagramBox(); virtual ~DiagramBox();
public: // hook functions virtual void DrawBox() = 0;
// is called from draw() to do the actual drawing // a hook functions that
virtual void drawBox() = 0; // is called from Draw() to do the actual drawing
public: // derived from DiagramItemGroup // derived from DiagramItemGroup
// extends the DiagramItemGroup implementation by setting
// the items owner and calling the attachedToDiagram() hook
// on it
virtual bool AddItem(DiagramItem *item); virtual bool AddItem(DiagramItem *item);
// extends the DiagramItemGroup implementation by calling
// the detachedToDiagram() hook on the item
virtual bool RemoveItem(DiagramItem *item); virtual bool RemoveItem(DiagramItem *item);
public: // derived from DiagramItem // derived from DiagramItem
// returns the Boxes frame rectangle // returns the Boxes frame rectangle
BRect frame() const { return m_frame; } BRect Frame() const
{
return fFrame;
}
// prepares the drawing stack and clipping region, then void Draw(BRect updateRect);
// calls drawBox
void draw(BRect updateRect);
// is called from the parent DiagramViews MouseDown() implementation virtual void MouseDown(BPoint point, uint32 buttons, uint32 clicks);
// if the Box was hit; this version initiates selection and dragging virtual void MouseOver(BPoint point, uint32 transit);
virtual void mouseDown(BPoint point, uint32 buttons, uint32 clicks);
// is called from the DiagramViews MouseMoved() when no message is being
// dragged, but the mouse has moved above the box
virtual void mouseOver(BPoint point, uint32 transit);
// is called from the DiagramViews MouseMoved() when a message is being virtual void MessageDragged(BPoint point, uint32 transit, const BMessage *message);
// dragged over the DiagramBox virtual void MessageDropped(BPoint point, BMessage *message);
virtual void messageDragged(BPoint point, uint32 transit, const BMessage *message);
// is called from the DiagramViews MessageReceived() function when a void MoveBy(float x, float y, BRegion *updateRegion);
// message has been dropped on the DiagramBox virtual void ResizeBy(float horizontal, float vertical);
virtual void messageDropped(BPoint point, BMessage *message);
enum flag_t {
public: // operations M_DRAW_UNDER_ENDPOINTS = 0x1
};
// moves the box by a given amount, and returns in updateRegion the
// frames of wires impacted by the move
void moveBy(float x, float y, BRegion *updateRegion);
// resizes the boxes frame without doing any updating
virtual void resizeBy(float horizontal, float vertical);
private:// internal methods
// is called by the DiagramView when added
void _setOwner(DiagramView *owner);
private: private:
void _SetOwner(DiagramView *owner);
// the boxes' frame rectangle
BRect m_frame; private:
BRect fFrame;
// the boxes' frame rectangle
// flags: // flags:
// M_DRAW_UNDER_ENDPOINTS - don't remove EndPoint frames from // M_DRAW_UNDER_ENDPOINTS - don't remove EndPoint frames from
// the clipping region // the clipping region
uint32 m_flags; uint32 fFlags;
}; };
__END_CORTEX_NAMESPACE __END_CORTEX_NAMESPACE
#endif // DIAGRAM_BOX_H #endif // DIAGRAM_BOX_H
+21 -21
View File
@@ -42,7 +42,7 @@ DiagramEndPoint::~DiagramEndPoint()
BPoint DiagramEndPoint::connectionPoint() const BPoint DiagramEndPoint::connectionPoint() const
{ {
D_METHOD(("DiagramEndPoint::connectionPoint()\n")); D_METHOD(("DiagramEndPoint::connectionPoint()\n"));
return BPoint(frame().left + frame().Height() / 2.0, frame().top + frame().Width() / 2.0); return BPoint(Frame().left + Frame().Height() / 2.0, Frame().top + Frame().Width() / 2.0);
} }
bool DiagramEndPoint::connectionRequested( bool DiagramEndPoint::connectionRequested(
@@ -60,16 +60,16 @@ bool DiagramEndPoint::connectionRequested(
// *** derived from DiagramItem // *** derived from DiagramItem
// -------------------------------------------------------- // // -------------------------------------------------------- //
void DiagramEndPoint::draw( void DiagramEndPoint::Draw(
BRect updateRect) BRect updateRect)
{ {
D_METHOD(("DiagramEndPoint::draw()\n")); D_METHOD(("DiagramEndPoint::Draw()\n"));
if (view()) if (view())
{ {
view()->PushState(); view()->PushState();
{ {
BRegion region; BRegion region;
region.Include(frame() & updateRect); region.Include(Frame() & updateRect);
view()->ConstrainClippingRegion(&region); view()->ConstrainClippingRegion(&region);
drawEndPoint(); drawEndPoint();
} }
@@ -77,12 +77,12 @@ void DiagramEndPoint::draw(
} }
} }
void DiagramEndPoint::mouseDown( void DiagramEndPoint::MouseDown(
BPoint point, BPoint point,
uint32 buttons, uint32 buttons,
uint32 clicks) uint32 clicks)
{ {
D_MOUSE(("DiagramEndPoint::mouseDown()\n")); D_MOUSE(("DiagramEndPoint::MouseDown()\n"));
if (clicks == 1) if (clicks == 1)
{ {
if (isSelectable()) if (isSelectable())
@@ -105,22 +105,22 @@ void DiagramEndPoint::mouseDown(
BMessage dragMsg(M_WIRE_DRAGGED); BMessage dragMsg(M_WIRE_DRAGGED);
dragMsg.AddPointer("from", static_cast<void *>(this)); dragMsg.AddPointer("from", static_cast<void *>(this));
view()->DragMessage(&dragMsg, BRect(0.0, 0.0, -1.0, -1.0), view()); view()->DragMessage(&dragMsg, BRect(0.0, 0.0, -1.0, -1.0), view());
view()->messageDragged(point, B_INSIDE_VIEW, &dragMsg); view()->MessageDragged(point, B_INSIDE_VIEW, &dragMsg);
} }
} }
} }
void DiagramEndPoint::messageDragged( void DiagramEndPoint::MessageDragged(
BPoint point, BPoint point,
uint32 transit, uint32 transit,
const BMessage *message) const BMessage *message)
{ {
D_MOUSE(("DiagramEndPoint::messageDragged()\n")); D_MOUSE(("DiagramEndPoint::MessageDragged()\n"));
switch (message->what) switch (message->what)
{ {
case M_WIRE_DRAGGED: case M_WIRE_DRAGGED:
{ {
D_MESSAGE(("DiagramEndPoint::messageDragged(M_WIRE_DRAGGED)\n")); D_MESSAGE(("DiagramEndPoint::MessageDragged(M_WIRE_DRAGGED)\n"));
switch (transit) switch (transit)
{ {
case B_INSIDE_VIEW: case B_INSIDE_VIEW:
@@ -186,21 +186,21 @@ void DiagramEndPoint::messageDragged(
} }
default: default:
{ {
DiagramItem::messageDragged(point, transit, message); DiagramItem::MessageDragged(point, transit, message);
} }
} }
} }
void DiagramEndPoint::messageDropped( void DiagramEndPoint::MessageDropped(
BPoint point, BPoint point,
BMessage *message) BMessage *message)
{ {
D_MESSAGE(("DiagramEndPoint::messageDropped()\n")); D_MESSAGE(("DiagramEndPoint::MessageDropped()\n"));
switch (message->what) switch (message->what)
{ {
case M_WIRE_DRAGGED: case M_WIRE_DRAGGED:
{ {
D_MESSAGE(("DiagramEndPoint::messageDropped(M_WIRE_DRAGGED)\n")); D_MESSAGE(("DiagramEndPoint::MessageDropped(M_WIRE_DRAGGED)\n"));
DiagramEndPoint *endPoint; DiagramEndPoint *endPoint;
if ((message->FindPointer("from", reinterpret_cast<void **>(&endPoint)) == B_OK) if ((message->FindPointer("from", reinterpret_cast<void **>(&endPoint)) == B_OK)
&& (endPoint != this)) && (endPoint != this))
@@ -222,7 +222,7 @@ void DiagramEndPoint::messageDropped(
} }
default: default:
{ {
DiagramItem::messageDropped(point, message); DiagramItem::MessageDropped(point, message);
} }
} }
} }
@@ -231,18 +231,18 @@ void DiagramEndPoint::messageDropped(
// *** frame related operations // *** frame related operations
// -------------------------------------------------------- // // -------------------------------------------------------- //
void DiagramEndPoint::moveBy( void DiagramEndPoint::MoveBy(
float x, float x,
float y, float y,
BRegion *updateRegion) BRegion *updateRegion)
{ {
D_METHOD(("DiagramEndPoint::moveBy()\n")); D_METHOD(("DiagramEndPoint::MoveBy()\n"));
if (isConnected() && m_wire && updateRegion) if (isConnected() && m_wire && updateRegion)
{ {
updateRegion->Include(m_wire->frame()); updateRegion->Include(m_wire->Frame());
m_frame.OffsetBy(x, y); m_frame.OffsetBy(x, y);
m_wire->endPointMoved(this); m_wire->endPointMoved(this);
updateRegion->Include(m_wire->frame()); updateRegion->Include(m_wire->Frame());
} }
else else
{ {
@@ -254,11 +254,11 @@ void DiagramEndPoint::moveBy(
} }
} }
void DiagramEndPoint::resizeBy( void DiagramEndPoint::ResizeBy(
float horizontal, float horizontal,
float vertical) float vertical)
{ {
D_METHOD(("DiagramEndPoint::resizeBy()\n")); D_METHOD(("DiagramEndPoint::ResizeBy()\n"));
m_frame.right += horizontal; m_frame.right += horizontal;
m_frame.bottom += vertical; m_frame.bottom += vertical;
} }
+14 -14
View File
@@ -38,7 +38,7 @@ public: // *** accessors
public: // *** hook functions public: // *** hook functions
// is called from draw() to do the actual drawing // is called from Draw() to do the actual drawing
virtual void drawEndPoint() = 0; virtual void drawEndPoint() = 0;
// should return the BPoint that a connected wire uses as // should return the BPoint that a connected wire uses as
@@ -46,7 +46,7 @@ public: // *** hook functions
// point of the EndPoint // point of the EndPoint
virtual BPoint connectionPoint() const; virtual BPoint connectionPoint() const;
// is called from messageDragged() and messageDropped() to // is called from MessageDragged() and MessageDropped() to
// let you verify that a connection is okay // let you verify that a connection is okay
virtual bool connectionRequested( virtual bool connectionRequested(
DiagramEndPoint *fromWhich); DiagramEndPoint *fromWhich);
@@ -64,42 +64,42 @@ public: // *** hook functions
public: // *** derived from DiagramItem public: // *** derived from DiagramItem
// returns the EndPoints frame rectangle // returns the EndPoints frame rectangle
BRect frame() const BRect Frame() const
{ return m_frame; } { return m_frame; }
// prepares the drawing stack and clipping region, then // prepares the drawing stack and clipping region, then
// calls drawEndPoint // calls drawEndPoint
void draw( void Draw(
BRect updateRect); BRect updateRect);
// is called from the parent DiagramBox's mouseDown() // is called from the parent DiagramBox's MouseDown()
// implementation if the EndPoint was hit; this version // implementation if the EndPoint was hit; this version
// initiates selection and dragging (i.e. connecting) // initiates selection and dragging (i.e. connecting)
virtual void mouseDown( virtual void MouseDown(
BPoint point, BPoint point,
uint32 buttons, uint32 buttons,
uint32 clicks); uint32 clicks);
// is called from the parent DiagramBox's mouseOver() // is called from the parent DiagramBox's MouseOver()
// implementation if the mouse is over the EndPoint // implementation if the mouse is over the EndPoint
virtual void mouseOver( virtual void MouseOver(
BPoint point, BPoint point,
uint32 transit) uint32 transit)
{ /* does nothing */ } { /* does nothing */ }
// is called from the parent DiagramBox's messageDragged() // is called from the parent DiagramBox's MessageDragged()
// implementation of a message is being dragged of the // implementation of a message is being dragged of the
// EndPoint; this implementation handles only wire drags // EndPoint; this implementation handles only wire drags
// (i.e. M_WIRE_DRAGGED messages) // (i.e. M_WIRE_DRAGGED messages)
virtual void messageDragged( virtual void MessageDragged(
BPoint point, BPoint point,
uint32 transit, uint32 transit,
const BMessage *message); const BMessage *message);
// is called from the parent DiagramBox's messageDropped() // is called from the parent DiagramBox's MessageDropped()
// implementation if the message was dropped on the EndPoint; // implementation if the message was dropped on the EndPoint;
// this version handles wire dropping (connecting) // this version handles wire dropping (connecting)
virtual void messageDropped( virtual void MessageDropped(
BPoint point, BPoint point,
BMessage *message); BMessage *message);
@@ -107,13 +107,13 @@ public: // *** derived from DiagramItem
// updateRegion the frames of connected wires if there are any // updateRegion the frames of connected wires if there are any
// NOTE: no drawing/refreshing is done in this method, that's // NOTE: no drawing/refreshing is done in this method, that's
// up to the parent // up to the parent
void moveBy( void MoveBy(
float x, float x,
float y, float y,
BRegion *updateRegion); BRegion *updateRegion);
// resize the EndPoints frame rectangle without redraw // resize the EndPoints frame rectangle without redraw
virtual void resizeBy( virtual void ResizeBy(
float horizontal, float horizontal,
float vertical); float vertical);
+4 -4
View File
@@ -50,7 +50,7 @@ void DiagramItem::select()
m_lastSelectionTime = m_selectionTime = system_time(); m_lastSelectionTime = m_selectionTime = system_time();
m_countSelected = 1; m_countSelected = 1;
selected(); selected();
view()->Invalidate(frame()); view()->Invalidate(Frame());
} }
} }
@@ -62,7 +62,7 @@ void DiagramItem::selectAdding()
m_selected = true; m_selected = true;
m_selectionTime = m_lastSelectionTime - m_countSelected++; m_selectionTime = m_lastSelectionTime - m_countSelected++;
selected(); selected();
view()->Invalidate(frame()); view()->Invalidate(Frame());
} }
} }
@@ -73,7 +73,7 @@ void DiagramItem::deselect()
{ {
m_selected = false; m_selected = false;
deselected(); deselected();
view()->Invalidate(frame()); view()->Invalidate(Frame());
} }
} }
@@ -85,7 +85,7 @@ float DiagramItem::howCloseTo(
BPoint point) const BPoint point) const
{ {
D_METHOD(("DiagramItem::howCloseTo()\n")); D_METHOD(("DiagramItem::howCloseTo()\n"));
if (frame().Contains(point)) if (Frame().Contains(point))
{ {
return 1.0; return 1.0;
} }
+14 -14
View File
@@ -89,19 +89,19 @@ public: // *** operations
// state has actually changed // state has actually changed
void deselect(); void deselect();
// moves the items frame to a given point by calling moveBy with the // moves the items frame to a given point by calling MoveBy with the
// absolute coords translated into relative shift amount // absolute coords translated into relative shift amount
void moveTo( void moveTo(
BPoint point, BPoint point,
BRegion *updateRegion = 0) BRegion *updateRegion = 0)
{ moveBy(point.x - frame().left, point.y - frame().top, updateRegion); } { MoveBy(point.x - Frame().left, point.y - Frame().top, updateRegion); }
// resizes the items frame to given dimensions; simply calls the resizeBy // resizes the items frame to given dimensions; simply calls the ResizeBy
// implementation // implementation
void resizeTo( void resizeTo(
float width, float width,
float height) float height)
{ resizeBy(width - frame().Width(), height - frame().Height()); } { ResizeBy(width - Frame().Width(), height - Frame().Height()); }
public: // *** hook functions public: // *** hook functions
@@ -117,7 +117,7 @@ public: // *** hook functions
// is called from the DiagramViews MouseDown() function after // is called from the DiagramViews MouseDown() function after
// finding out the mouse buttons and clicks quantity. // finding out the mouse buttons and clicks quantity.
virtual void mouseDown( virtual void MouseDown(
BPoint point, BPoint point,
uint32 buttons, uint32 buttons,
uint32 clicks) uint32 clicks)
@@ -125,14 +125,14 @@ public: // *** hook functions
// is called from the DiagramViews MouseMoved() when *no* message is being // is called from the DiagramViews MouseMoved() when *no* message is being
// dragged, i.e. the mouse is simply floating above the item // dragged, i.e. the mouse is simply floating above the item
virtual void mouseOver( virtual void MouseOver(
BPoint point, BPoint point,
uint32 transit) uint32 transit)
{/* does nothing */} {/* does nothing */}
// is called from the DiagramViews MouseMoved() when a message is being // is called from the DiagramViews MouseMoved() when a message is being
// dragged; always call the base class version when overriding! // dragged; always call the base class version when overriding!
virtual void messageDragged( virtual void MessageDragged(
BPoint point, BPoint point,
uint32 transit, uint32 transit,
const BMessage *message) const BMessage *message)
@@ -141,7 +141,7 @@ public: // *** hook functions
// is called from the DiagramViews MessageReceived() function when an // is called from the DiagramViews MessageReceived() function when an
// message has been received through Drag&Drop; always call the base // message has been received through Drag&Drop; always call the base
// class version when overriding! // class version when overriding!
virtual void messageDropped( virtual void MessageDropped(
BPoint point, BPoint point,
BMessage *message) BMessage *message)
{/* does nothing */} {/* does nothing */}
@@ -156,7 +156,7 @@ public: // *** interface definition
// this function must be implemented by derived classes to return the // this function must be implemented by derived classes to return the
// items frame rectangle in the DiagramViews coordinates // items frame rectangle in the DiagramViews coordinates
virtual BRect frame() const = 0; virtual BRect Frame() const = 0;
// this function should be implemented for non-rectangular subclasses // this function should be implemented for non-rectangular subclasses
// (like wires) to estimate how close a given point is to the object; // (like wires) to estimate how close a given point is to the object;
@@ -166,8 +166,8 @@ public: // *** interface definition
BPoint point) const; BPoint point) const;
// this is the hook function called by DiagramView when it's time to // this is the hook function called by DiagramView when it's time to
// draw the object // Draw the object
virtual void draw( virtual void Draw(
BRect updateRect) = 0; BRect updateRect) = 0;
// should move the items frame by the specified amount and do the // should move the items frame by the specified amount and do the
@@ -175,14 +175,14 @@ public: // *** interface definition
// caller supplied a BRegion pointer in updateRegion, this method // caller supplied a BRegion pointer in updateRegion, this method
// should add other areas affected by the move to it (e.g. wire // should add other areas affected by the move to it (e.g. wire
// frames) // frames)
virtual void moveBy( virtual void MoveBy(
float x, float x,
float y, float y,
BRegion *updateRegion = 0) BRegion *updateRegion = 0)
{ /* does nothing */ } { /* does nothing */ }
// should resize the items frame by the specified amount // should resize the items frame by the specified amount
virtual void resizeBy( virtual void ResizeBy(
float horizontal, float horizontal,
float vertical) float vertical)
{ /* does nothing */ } { /* does nothing */ }
@@ -215,7 +215,7 @@ protected: // *** internal methods
// called only by DiagramItemGroup objects in the method // called only by DiagramItemGroup objects in the method
// addItem() // addItem()
virtual void _setOwner( virtual void _SetOwner(
DiagramView *owner) DiagramView *owner)
{ m_view = owner; } { m_view = owner; }
@@ -20,7 +20,7 @@ __USE_CORTEX_NAMESPACE
DiagramItemGroup::DiagramItemGroup(uint32 acceptedTypes, bool multiSelection) DiagramItemGroup::DiagramItemGroup(uint32 acceptedTypes, bool multiSelection)
: fBoxes(0), :fBoxes(0),
fWires(0), fWires(0),
fEndPoints(0), fEndPoints(0),
fSelection(0), fSelection(0),
@@ -74,8 +74,9 @@ DiagramItemGroup::~DiagramItemGroup()
// #pragma mark - item accessors // #pragma mark - item accessors
//! Returns the number of items in the group (optionally only those /*! Returns the number of items in the group (optionally only those
// of the given type \param whichType) of the given type \param whichType)
*/
uint32 uint32
DiagramItemGroup::CountItems(uint32 whichType) const DiagramItemGroup::CountItems(uint32 whichType) const
{ {
@@ -149,7 +150,7 @@ DiagramItemGroup::ItemUnder(BPoint point)
if (fTypes & DiagramItem::M_BOX) { if (fTypes & DiagramItem::M_BOX) {
for (uint32 i = 0; i < CountItems(DiagramItem::M_BOX); i++) { for (uint32 i = 0; i < CountItems(DiagramItem::M_BOX); i++) {
DiagramItem *item = ItemAt(i, DiagramItem::M_BOX); DiagramItem *item = ItemAt(i, DiagramItem::M_BOX);
if (item->frame().Contains(point) && (item->howCloseTo(point) == 1.0)) { if (item->Frame().Contains(point) && (item->howCloseTo(point) == 1.0)) {
// DiagramItemGroup *group = dynamic_cast<DiagramItemGroup *>(item); // DiagramItemGroup *group = dynamic_cast<DiagramItemGroup *>(item);
return (fLastItemUnder = item); return (fLastItemUnder = item);
} }
@@ -161,7 +162,7 @@ DiagramItemGroup::ItemUnder(BPoint point)
DiagramItem *closestItem = 0; DiagramItem *closestItem = 0;
for (uint32 i = 0; i < CountItems(DiagramItem::M_WIRE); i++) { for (uint32 i = 0; i < CountItems(DiagramItem::M_WIRE); i++) {
DiagramItem *item = ItemAt(i, DiagramItem::M_WIRE); DiagramItem *item = ItemAt(i, DiagramItem::M_WIRE);
if (item->frame().Contains(point)) { if (item->Frame().Contains(point)) {
float howClose = item->howCloseTo(point); float howClose = item->howCloseTo(point);
if (howClose > closest) { if (howClose > closest) {
closestItem = item; closestItem = item;
@@ -179,7 +180,7 @@ DiagramItemGroup::ItemUnder(BPoint point)
if (fTypes & DiagramItem::M_ENDPOINT) { if (fTypes & DiagramItem::M_ENDPOINT) {
for (uint32 i = 0; i < CountItems(DiagramItem::M_ENDPOINT); i++) { for (uint32 i = 0; i < CountItems(DiagramItem::M_ENDPOINT); i++) {
DiagramItem *item = ItemAt(i, DiagramItem::M_ENDPOINT); DiagramItem *item = ItemAt(i, DiagramItem::M_ENDPOINT);
if (item->frame().Contains(point) && (item->howCloseTo(point) == 1.0)) if (item->Frame().Contains(point) && (item->howCloseTo(point) == 1.0))
return (fLastItemUnder = item); return (fLastItemUnder = item);
} }
} }
@@ -295,7 +296,7 @@ DiagramItemGroup::SortItems(uint32 whichType,
} }
/*! Fires a draw() command at all items of a specific type that /*! Fires a Draw() command at all items of a specific type that
intersect with the \param updateRect; intersect with the \param updateRect;
items are drawn in reverse order; they should be sorted by items are drawn in reverse order; they should be sorted by
selection time before this function gets called, so that selection time before this function gets called, so that
@@ -308,18 +309,18 @@ DiagramItemGroup::DrawItems(BRect updateRect, uint32 whichType, BRegion* updateR
if (whichType & DiagramItem::M_WIRE) { if (whichType & DiagramItem::M_WIRE) {
for (int32 i = CountItems(DiagramItem::M_WIRE) - 1; i >= 0; i--) { for (int32 i = CountItems(DiagramItem::M_WIRE) - 1; i >= 0; i--) {
DiagramItem *item = ItemAt(i, DiagramItem::M_WIRE); DiagramItem *item = ItemAt(i, DiagramItem::M_WIRE);
if (item->frame().Intersects(updateRect)) if (item->Frame().Intersects(updateRect))
item->draw(updateRect); item->Draw(updateRect);
} }
} }
if (whichType & DiagramItem::M_BOX) { if (whichType & DiagramItem::M_BOX) {
for (int32 i = CountItems(DiagramItem::M_BOX) - 1; i >= 0; i--) { for (int32 i = CountItems(DiagramItem::M_BOX) - 1; i >= 0; i--) {
DiagramItem *item = ItemAt(i, DiagramItem::M_BOX); DiagramItem *item = ItemAt(i, DiagramItem::M_BOX);
if (item && item->frame().Intersects(updateRect)) { if (item && item->Frame().Intersects(updateRect)) {
item->draw(updateRect); item->Draw(updateRect);
if (updateRegion) if (updateRegion)
updateRegion->Exclude(item->frame()); updateRegion->Exclude(item->Frame());
} }
} }
} }
@@ -327,8 +328,8 @@ DiagramItemGroup::DrawItems(BRect updateRect, uint32 whichType, BRegion* updateR
if (whichType & DiagramItem::M_ENDPOINT) { if (whichType & DiagramItem::M_ENDPOINT) {
for (int32 i = CountItems(DiagramItem::M_ENDPOINT) - 1; i >= 0; i--) { for (int32 i = CountItems(DiagramItem::M_ENDPOINT) - 1; i >= 0; i--) {
DiagramItem *item = ItemAt(i, DiagramItem::M_ENDPOINT); DiagramItem *item = ItemAt(i, DiagramItem::M_ENDPOINT);
if (item && item->frame().Intersects(updateRect)) if (item && item->Frame().Intersects(updateRect))
item->draw(updateRect); item->Draw(updateRect);
} }
} }
} }
@@ -349,11 +350,11 @@ DiagramItemGroup::GetClippingAbove(DiagramItem *which, BRegion *region)
{ {
int32 index = fBoxes->IndexOf(which); int32 index = fBoxes->IndexOf(which);
if (index >= 0) { // the item was found if (index >= 0) { // the item was found
BRect r = which->frame(); BRect r = which->Frame();
for (int32 i = 0; i < index; i++) { for (int32 i = 0; i < index; i++) {
DiagramItem *item = ItemAt(i, DiagramItem::M_BOX); DiagramItem *item = ItemAt(i, DiagramItem::M_BOX);
if (item && item->frame().Intersects(r)) { if (item && item->Frame().Intersects(r)) {
region->Include(item->frame() & r); region->Include(item->Frame() & r);
found = true; found = true;
} }
} }
@@ -363,11 +364,11 @@ DiagramItemGroup::GetClippingAbove(DiagramItem *which, BRegion *region)
case DiagramItem::M_WIRE: case DiagramItem::M_WIRE:
{ {
BRect r = which->frame(); BRect r = which->Frame();
for (uint32 i = 0; i < CountItems(DiagramItem::M_BOX); i++) { for (uint32 i = 0; i < CountItems(DiagramItem::M_BOX); i++) {
DiagramItem *item = ItemAt(i, DiagramItem::M_BOX); DiagramItem *item = ItemAt(i, DiagramItem::M_BOX);
if (item && item->frame().Intersects(r)) { if (item && item->Frame().Intersects(r)) {
region->Include(item->frame() & r); region->Include(item->Frame() & r);
found = true; found = true;
} }
} }
@@ -549,7 +550,7 @@ DiagramItemGroup::DragSelectionBy(float x, float y, BRegion* updateRegion)
for (int32 i = CountSelectedItems() - 1; i >= 0; i--) { for (int32 i = CountSelectedItems() - 1; i >= 0; i--) {
DiagramItem *item = dynamic_cast<DiagramItem *>(SelectedItemAt(i)); DiagramItem *item = dynamic_cast<DiagramItem *>(SelectedItemAt(i));
if (item->isDraggable()) if (item->isDraggable())
item->moveBy(x, y, updateRegion); item->MoveBy(x, y, updateRegion);
} }
} }
} }
+10 -6
View File
@@ -24,19 +24,21 @@ class DiagramItemGroup {
DiagramItemGroup(uint32 acceptedTypes, bool multiSelection = true); DiagramItemGroup(uint32 acceptedTypes, bool multiSelection = true);
virtual ~DiagramItemGroup(); virtual ~DiagramItemGroup();
public: // hook functions // hook function
// is called whenever the current selection has changed // is called whenever the current selection has changed
virtual void SelectionChanged() virtual void SelectionChanged()
{ {
} }
public: // item accessors // item accessors
uint32 CountItems(uint32 whichType = DiagramItem::M_ANY) const; uint32 CountItems(uint32 whichType = DiagramItem::M_ANY) const;
DiagramItem* ItemAt(uint32 index, DiagramItem* ItemAt(uint32 index,
uint32 whichType = DiagramItem::M_ANY) const; uint32 whichType = DiagramItem::M_ANY) const;
DiagramItem* ItemUnder(BPoint point); DiagramItem* ItemUnder(BPoint point);
public: // item operations // item operations
virtual bool AddItem(DiagramItem* item); virtual bool AddItem(DiagramItem* item);
bool RemoveItem(DiagramItem* item); bool RemoveItem(DiagramItem* item);
void SortItems(uint32 itemType, void SortItems(uint32 itemType,
@@ -45,7 +47,8 @@ class DiagramItemGroup {
BRegion *updateRegion = 0); BRegion *updateRegion = 0);
bool GetClippingAbove(DiagramItem* which, BRegion* outRegion); bool GetClippingAbove(DiagramItem* which, BRegion* outRegion);
public: // selection accessors // selection accessors
uint32 SelectedType() const; uint32 SelectedType() const;
uint32 CountSelectedItems() const; uint32 CountSelectedItems() const;
DiagramItem* SelectedItemAt(uint32 index) const; DiagramItem* SelectedItemAt(uint32 index) const;
@@ -57,7 +60,8 @@ class DiagramItemGroup {
return fMultiSelection; return fMultiSelection;
} }
public: // selection related operations // selection related operations
bool SelectItem(DiagramItem* which, bool deselectOthers = true); bool SelectItem(DiagramItem* which, bool deselectOthers = true);
bool DeselectItem(DiagramItem *which); bool DeselectItem(DiagramItem *which);
void SortSelectedItems(int (*compareFunc)(const void *, const void *)); void SortSelectedItems(int (*compareFunc)(const void *, const void *));
@@ -66,7 +70,7 @@ class DiagramItemGroup {
void DragSelectionBy(float x, float y, BRegion *updateRegion); void DragSelectionBy(float x, float y, BRegion *updateRegion);
void RemoveSelection(); void RemoveSelection();
public: // alignment related // alignment related
// set/get the 'item alignment' grid size; this is used when // set/get the 'item alignment' grid size; this is used when
// items are being dragged and inserted // items are being dragged and inserted
+38 -38
View File
@@ -53,17 +53,17 @@ DiagramView::~DiagramView()
// *** hook functions // *** hook functions
// -------------------------------------------------------- // // -------------------------------------------------------- //
void DiagramView::messageDragged( void DiagramView::MessageDragged(
BPoint point, BPoint point,
uint32 transit, uint32 transit,
const BMessage *message) const BMessage *message)
{ {
D_METHOD(("DiagramView::messageDragged()\n")); D_METHOD(("DiagramView::MessageDragged()\n"));
switch (message->what) switch (message->what)
{ {
case M_WIRE_DRAGGED: case M_WIRE_DRAGGED:
{ {
D_MESSAGE(("DiagramView::messageDragged(M_WIRE_DROPPED)\n")); D_MESSAGE(("DiagramView::MessageDragged(M_WIRE_DROPPED)\n"));
if (!m_draggedWire) if (!m_draggedWire)
{ {
DiagramEndPoint *fromEndPoint; DiagramEndPoint *fromEndPoint;
@@ -78,16 +78,16 @@ void DiagramView::messageDragged(
} }
} }
void DiagramView::messageDropped( void DiagramView::MessageDropped(
BPoint point, BPoint point,
BMessage *message) BMessage *message)
{ {
D_METHOD(("DiagramView::messageDropped()\n")); D_METHOD(("DiagramView::MessageDropped()\n"));
switch (message->what) switch (message->what)
{ {
case M_WIRE_DRAGGED: case M_WIRE_DRAGGED:
{ {
D_MESSAGE(("DiagramView::messageDropped(M_WIRE_DROPPED)\n")); D_MESSAGE(("DiagramView::MessageDropped(M_WIRE_DROPPED)\n"));
DiagramEndPoint *fromWhich = 0; DiagramEndPoint *fromWhich = 0;
if (message->FindPointer("from", reinterpret_cast<void **>(&fromWhich)) == B_OK) if (message->FindPointer("from", reinterpret_cast<void **>(&fromWhich)) == B_OK)
{ {
@@ -198,12 +198,12 @@ void DiagramView::MessageReceived(
DiagramItem *item = ItemUnder(point); DiagramItem *item = ItemUnder(point);
if (item) if (item)
{ {
item->messageDropped(point, message); item->MessageDropped(point, message);
return; return;
} }
else else
{ {
messageDropped(point, message); MessageDropped(point, message);
} }
} }
else else
@@ -308,7 +308,7 @@ void DiagramView::MouseDown(
DiagramItem *item = ItemUnder(point); DiagramItem *item = ItemUnder(point);
if (item) if (item)
{ {
item->mouseDown(point, m_lastButton, m_clickCount); item->MouseDown(point, m_lastButton, m_clickCount);
} }
else // no, the background was clicked else // no, the background was clicked
{ {
@@ -316,7 +316,7 @@ void DiagramView::MouseDown(
SelectionChanged(); SelectionChanged();
if (MultipleSelection() && (m_lastButton == B_PRIMARY_MOUSE_BUTTON) && !(modifiers() & B_CONTROL_KEY)) if (MultipleSelection() && (m_lastButton == B_PRIMARY_MOUSE_BUTTON) && !(modifiers() & B_CONTROL_KEY))
_beginRectTracking(point); _beginRectTracking(point);
mouseDown(point, m_lastButton, m_clickCount); BackgroundMouseDown(point, m_lastButton, m_clickCount);
} }
} }
@@ -395,8 +395,8 @@ void DiagramView::MouseMoved(
if (box) if (box)
{ {
BRegion updateRegion; BRegion updateRegion;
DragSelectionBy(point.x - box->frame().left - offset.x, DragSelectionBy(point.x - box->Frame().left - offset.x,
point.y - box->frame().top - offset.y, point.y - box->Frame().top - offset.y,
&updateRegion); &updateRegion);
updateDataRect(); updateDataRect();
for (int32 i = 0; i < updateRegion.CountRects(); i++) for (int32 i = 0; i < updateRegion.CountRects(); i++)
@@ -407,15 +407,15 @@ void DiagramView::MouseMoved(
} }
break; break;
} }
default: // unkwown message -> redirect to messageDragged() default: // unkwown message -> redirect to MessageDragged()
{ {
DiagramItem *last = _LastItemUnder(); DiagramItem *last = _LastItemUnder();
if (transit == B_EXITED_VIEW) if (transit == B_EXITED_VIEW)
{ {
if (last) if (last)
{ {
last->messageDragged(point, B_EXITED_VIEW, message); last->MessageDragged(point, B_EXITED_VIEW, message);
messageDragged(point, B_EXITED_VIEW, message); MessageDragged(point, B_EXITED_VIEW, message);
} }
} }
else else
@@ -426,38 +426,38 @@ void DiagramView::MouseMoved(
if (item != last) if (item != last)
{ {
if (last) if (last)
last->messageDragged(point, B_EXITED_VIEW, message); last->MessageDragged(point, B_EXITED_VIEW, message);
item->messageDragged(point, B_ENTERED_VIEW, message); item->MessageDragged(point, B_ENTERED_VIEW, message);
} }
else else
{ {
item->messageDragged(point, B_INSIDE_VIEW, message); item->MessageDragged(point, B_INSIDE_VIEW, message);
} }
} }
else if (last) else if (last)
{ {
last->messageDragged(point, B_EXITED_VIEW, message); last->MessageDragged(point, B_EXITED_VIEW, message);
messageDragged(point, B_ENTERED_VIEW, message); MessageDragged(point, B_ENTERED_VIEW, message);
} }
else else
{ {
messageDragged(point, transit, message); MessageDragged(point, transit, message);
} }
} }
break; break;
} }
} }
} }
else // no message at all -> redirect to mouseOver() else // no message at all -> redirect to MouseOver()
{ {
DiagramItem *last = _LastItemUnder(); DiagramItem *last = _LastItemUnder();
if ((transit == B_EXITED_VIEW) || (transit == B_OUTSIDE_VIEW)) if ((transit == B_EXITED_VIEW) || (transit == B_OUTSIDE_VIEW))
{ {
if (last) if (last)
{ {
last->mouseOver(point, B_EXITED_VIEW); last->MouseOver(point, B_EXITED_VIEW);
_ResetItemUnder(); _ResetItemUnder();
mouseOver(point, B_EXITED_VIEW); MouseOver(point, B_EXITED_VIEW);
} }
} }
else else
@@ -468,18 +468,18 @@ void DiagramView::MouseMoved(
if (item != last) if (item != last)
{ {
if (last) if (last)
last->mouseOver(point, B_EXITED_VIEW); last->MouseOver(point, B_EXITED_VIEW);
item->mouseOver(point, B_ENTERED_VIEW); item->MouseOver(point, B_ENTERED_VIEW);
} }
else else
{ {
item->mouseOver(point, B_INSIDE_VIEW); item->MouseOver(point, B_INSIDE_VIEW);
} }
} }
else if (last) else if (last)
{ {
last->mouseOver(point, B_EXITED_VIEW); last->MouseOver(point, B_EXITED_VIEW);
mouseOver(point, B_ENTERED_VIEW); MouseOver(point, B_ENTERED_VIEW);
} }
} }
} }
@@ -509,7 +509,7 @@ bool DiagramView::AddItem(
{ {
if (DiagramItemGroup::AddItem(item)) if (DiagramItemGroup::AddItem(item))
{ {
item->_setOwner(this); item->_SetOwner(this);
item->attachedToDiagram(); item->attachedToDiagram();
if (item->type() == DiagramItem::M_BOX) if (item->type() == DiagramItem::M_BOX)
{ {
@@ -530,7 +530,7 @@ bool DiagramView::RemoveItem(
item->detachedFromDiagram(); item->detachedFromDiagram();
if (DiagramItemGroup::RemoveItem(item)) if (DiagramItemGroup::RemoveItem(item))
{ {
item->_setOwner(0); item->_SetOwner(0);
if (item->type() == DiagramItem::M_BOX) if (item->type() == DiagramItem::M_BOX)
{ {
updateDataRect(); updateDataRect();
@@ -552,10 +552,10 @@ void DiagramView::trackWire(
if (m_draggedWire) if (m_draggedWire)
{ {
BRegion region; BRegion region;
region.Include(m_draggedWire->frame()); region.Include(m_draggedWire->Frame());
m_draggedWire->m_dragEndPoint = point; m_draggedWire->m_dragEndPoint = point;
m_draggedWire->endPointMoved(); m_draggedWire->endPointMoved();
region.Include(m_draggedWire->frame()); region.Include(m_draggedWire->Frame());
region.Exclude(&m_boxRegion); region.Exclude(&m_boxRegion);
for (int32 i = 0; i < region.CountRects(); i++) for (int32 i = 0; i < region.CountRects(); i++)
{ {
@@ -633,7 +633,7 @@ DiagramView::updateDataRect()
// calculate the area in which boxes display // calculate the area in which boxes display
m_boxRegion.MakeEmpty(); m_boxRegion.MakeEmpty();
for (uint32 i = 0; i < CountItems(DiagramItem::M_BOX); i++) { for (uint32 i = 0; i < CountItems(DiagramItem::M_BOX); i++) {
m_boxRegion.Include(ItemAt(i, DiagramItem::M_BOX)->frame()); m_boxRegion.Include(ItemAt(i, DiagramItem::M_BOX)->Frame());
} }
// adapt the data rect to the new region of boxes // adapt the data rect to the new region of boxes
BRect boxRect = m_boxRegion.Frame(); BRect boxRect = m_boxRegion.Frame();
@@ -654,7 +654,7 @@ DiagramView::_beginWireTracking(DiagramEndPoint *startPoint)
m_draggedWire = createWire(startPoint); m_draggedWire = createWire(startPoint);
AddItem(m_draggedWire); AddItem(m_draggedWire);
SelectItem(m_draggedWire, true); SelectItem(m_draggedWire, true);
Invalidate(startPoint->frame()); Invalidate(startPoint->Frame());
} }
void DiagramView::_endWireTracking() void DiagramView::_endWireTracking()
@@ -663,7 +663,7 @@ void DiagramView::_endWireTracking()
if (m_draggedWire) if (m_draggedWire)
{ {
RemoveItem(m_draggedWire); RemoveItem(m_draggedWire);
Invalidate(m_draggedWire->frame()); Invalidate(m_draggedWire->Frame());
DiagramEndPoint *endPoint = m_draggedWire->startPoint(); DiagramEndPoint *endPoint = m_draggedWire->startPoint();
if (!endPoint) if (!endPoint)
{ {
@@ -671,7 +671,7 @@ void DiagramView::_endWireTracking()
} }
if (endPoint) if (endPoint)
{ {
Invalidate(endPoint->frame()); Invalidate(endPoint->Frame());
} }
delete m_draggedWire; delete m_draggedWire;
m_draggedWire = 0; m_draggedWire = 0;
@@ -702,7 +702,7 @@ DiagramView::_trackRect(BPoint origin, BPoint current)
for (uint32 i = 0; i < CountItems(DiagramItem::M_BOX); i++) { for (uint32 i = 0; i < CountItems(DiagramItem::M_BOX); i++) {
DiagramBox *box = dynamic_cast<DiagramBox *>(ItemAt(i, DiagramItem::M_BOX)); DiagramBox *box = dynamic_cast<DiagramBox *>(ItemAt(i, DiagramItem::M_BOX));
if (box) { if (box) {
if (rect.Intersects(box->frame())) if (rect.Intersects(box->Frame()))
changed |= SelectItem(box, false); changed |= SelectItem(box, false);
else else
changed |= DeselectItem(box); changed |= DeselectItem(box);
+8 -8
View File
@@ -68,8 +68,8 @@ public: // *** hook functions
virtual DiagramWire *createWire( virtual DiagramWire *createWire(
DiagramEndPoint *fromWhich) = 0; DiagramEndPoint *fromWhich) = 0;
// hook called from MouseDown() if the background was hit // hook called from BackgroundMouseDown() if the background was hit
virtual void mouseDown( virtual void BackgroundMouseDown(
BPoint point, BPoint point,
uint32 buttons, uint32 buttons,
uint32 clicks) uint32 clicks)
@@ -77,21 +77,21 @@ public: // *** hook functions
// hook called from MouseMoved() if the mouse is floating over // hook called from MouseMoved() if the mouse is floating over
// the background (i.e. with no message attached) // the background (i.e. with no message attached)
virtual void mouseOver( virtual void MouseOver(
BPoint point, BPoint point,
uint32 transit) uint32 transit)
{ /* does nothing */ } { /* does nothing */ }
// hook called from MouseMoved() if a message is being dragged // hook called from MouseMoved() if a message is being dragged
// over the background // over the background
virtual void messageDragged( virtual void MessageDragged(
BPoint point, BPoint point,
uint32 transit, uint32 transit,
const BMessage *message); const BMessage *message);
// hook called from MessageReceived() if a message has been // hook called from MessageReceived() if a message has been
// dropped over the background // dropped over the background
virtual void messageDropped( virtual void MessageDropped(
BPoint point, BPoint point,
BMessage *message); BMessage *message);
@@ -125,14 +125,14 @@ public: // derived from BView
int32 numBytes); int32 numBytes);
// if an item is located at the click point, this function calls // if an item is located at the click point, this function calls
// that items mouseDown() method; else a deselectAll() command is // that items MouseDown() method; else a deselectAll() command is
// made and rect-tracking is initiated // made and rect-tracking is initiated
virtual void MouseDown( virtual void MouseDown(
BPoint point); BPoint point);
// if an item is located under the given point, this function // if an item is located under the given point, this function
// calls that items messageDragged() hook if a message is being // calls that items MessageDragged() hook if a message is being
// dragged, and mouseOver() if not // dragged, and MouseOver() if not
virtual void MouseMoved( virtual void MouseMoved(
BPoint point, BPoint point,
uint32 transit, uint32 transit,
+8 -8
View File
@@ -118,16 +118,16 @@ float DiagramWire::howCloseTo(
return result; return result;
} }
void DiagramWire::draw( void DiagramWire::Draw(
BRect updateRect) BRect updateRect)
{ {
D_METHOD(("DiagramWire::draw()\n")); D_METHOD(("DiagramWire::Draw()\n"));
if (view()) if (view())
{ {
view()->PushState(); view()->PushState();
{ {
BRegion region, clipping; BRegion region, clipping;
region.Include(frame() & updateRect); region.Include(Frame() & updateRect);
if (view()->GetClippingAbove(this, &clipping)) if (view()->GetClippingAbove(this, &clipping))
region.Exclude(&clipping); region.Exclude(&clipping);
view()->ConstrainClippingRegion(&region); view()->ConstrainClippingRegion(&region);
@@ -137,12 +137,12 @@ void DiagramWire::draw(
} }
} }
void DiagramWire::mouseDown( void DiagramWire::MouseDown(
BPoint point, BPoint point,
uint32 buttons, uint32 buttons,
uint32 clicks) uint32 clicks)
{ {
D_METHOD(("DiagramWire::mouseDown()\n")); D_METHOD(("DiagramWire::MouseDown()\n"));
if (clicks == 1) if (clicks == 1)
{ {
if (isSelectable()) if (isSelectable())
@@ -163,12 +163,12 @@ void DiagramWire::mouseDown(
} }
} }
void DiagramWire::messageDragged( void DiagramWire::MessageDragged(
BPoint point, BPoint point,
uint32 transit, uint32 transit,
const BMessage *message) const BMessage *message)
{ {
D_METHOD(("DiagramWire::messageDragged()\n")); D_METHOD(("DiagramWire::MessageDragged()\n"));
switch (message->what) switch (message->what)
{ {
case M_WIRE_DRAGGED: case M_WIRE_DRAGGED:
@@ -178,7 +178,7 @@ void DiagramWire::messageDragged(
} }
default: default:
{ {
DiagramItem::messageDragged(point, transit, message); DiagramItem::MessageDragged(point, transit, message);
} }
} }
} }
+7 -7
View File
@@ -65,7 +65,7 @@ public: // *** accessors
public: // *** hook functions public: // *** hook functions
// is called from draw() to do the actual drawing // is called from Draw() to do the actual drawing
virtual void drawWire() = 0; virtual void drawWire() = 0;
// is called by the connected diagramEndPoints whenever one is moved // is called by the connected diagramEndPoints whenever one is moved
@@ -77,7 +77,7 @@ public: // *** hook functions
public: // *** derived from DiagramItem public: // *** derived from DiagramItem
// returns the area in which the wire displays // returns the area in which the wire displays
virtual BRect frame() const virtual BRect Frame() const
{ return BRect(startConnectionPoint(), endConnectionPoint()); } { return BRect(startConnectionPoint(), endConnectionPoint()); }
// returns how close a given point is to the wire; the current // returns how close a given point is to the wire; the current
@@ -88,19 +88,19 @@ public: // *** derived from DiagramItem
// prepares the drawing stack and clipping region, then // prepares the drawing stack and clipping region, then
// calls drawWire // calls drawWire
void draw( void Draw(
BRect updateRect); BRect updateRect);
// is called from the parent DiagramViews MouseDown() implementation // is called from the parent DiagramViews MouseDown() implementation
// if the Wire was hit; this version initiates selection and dragging // if the Wire was hit; this version initiates selection and dragging
virtual void mouseDown( virtual void MouseDown(
BPoint point, BPoint point,
uint32 buttons, uint32 buttons,
uint32 clicks); uint32 clicks);
// is called from the DiagramViews MouseMoved() when no message is being // is called from the DiagramViews MouseMoved() when no message is being
// dragged, but the mouse has moved above the wire // dragged, but the mouse has moved above the wire
virtual void mouseOver( virtual void MouseOver(
BPoint point, BPoint point,
uint32 transit) uint32 transit)
{ /* does nothing */ } { /* does nothing */ }
@@ -108,14 +108,14 @@ public: // *** derived from DiagramItem
// is called from the DiagramViews MouseMoved() when a message is being // is called from the DiagramViews MouseMoved() when a message is being
// dragged over the DiagramWire // dragged over the DiagramWire
virtual void messageDragged( virtual void MessageDragged(
BPoint point, BPoint point,
uint32 transit, uint32 transit,
const BMessage *message); const BMessage *message);
// is called from the DiagramViews MessageReceived() function when a // is called from the DiagramViews MessageReceived() function when a
// message has been dropped on the DiagramWire // message has been dropped on the DiagramWire
virtual void messageDropped( virtual void MessageDropped(
BPoint point, BPoint point,
BMessage *message) BMessage *message)
{ /* does nothing */ } { /* does nothing */ }
@@ -135,11 +135,11 @@ void DormantNodeListItem::Update(
// BListItem impl. // BListItem impl.
// -------------------------------------------------------- // // -------------------------------------------------------- //
void DormantNodeListItem::mouseOver( void DormantNodeListItem::MouseOver(
BView *owner, BView *owner,
BPoint point, BPoint point,
uint32 transit) { uint32 transit) {
D_OPERATION(("DormantNodeListItem::mouseOver()\n")); D_OPERATION(("DormantNodeListItem::MouseOver()\n"));
switch (transit) { switch (transit) {
case B_ENTERED_VIEW: { case B_ENTERED_VIEW: {
@@ -54,7 +54,7 @@ public: // *** accessors
public: // *** operations public: // *** operations
void mouseOver( void MouseOver(
BView *owner, BView *owner,
BPoint point, BPoint point,
uint32 transit); uint32 transit);
@@ -171,16 +171,16 @@ void DormantNodeView::MouseMoved(
if (item && r.Contains(point)) { if (item && r.Contains(point)) {
if (item != last) { if (item != last) {
if (last) if (last)
last->mouseOver(this, point, B_EXITED_VIEW); last->MouseOver(this, point, B_EXITED_VIEW);
item->mouseOver(this, point, B_ENTERED_VIEW); item->MouseOver(this, point, B_ENTERED_VIEW);
m_lastItemUnder = item; m_lastItemUnder = item;
} }
else { else {
item->mouseOver(this, point, B_INSIDE_VIEW); item->MouseOver(this, point, B_INSIDE_VIEW);
} }
} }
else if (last) { else if (last) {
last->mouseOver(this, point, B_EXITED_VIEW); last->MouseOver(this, point, B_EXITED_VIEW);
} }
} }
+29 -29
View File
@@ -139,7 +139,7 @@ void MediaJack::detachedFromDiagram()
// make sure we're no longer displaying a tooltip // make sure we're no longer displaying a tooltip
TipManager *tips = TipManager::Instance(); TipManager *tips = TipManager::Instance();
tips->hideTip(view()->ConvertToScreen(frame())); tips->hideTip(view()->ConvertToScreen(Frame()));
} }
void MediaJack::drawEndPoint() void MediaJack::drawEndPoint()
@@ -148,7 +148,7 @@ void MediaJack::drawEndPoint()
if (m_bitmap) if (m_bitmap)
{ {
view()->DrawBitmap(m_bitmap, frame().LeftTop()); view()->DrawBitmap(m_bitmap, Frame().LeftTop());
} }
} }
@@ -162,11 +162,11 @@ BPoint MediaJack::connectionPoint() const
{ {
if (isInput()) if (isInput())
{ {
return BPoint(frame().left - 1.0, frame().top + frame().Height() / 2.0); return BPoint(Frame().left - 1.0, Frame().top + Frame().Height() / 2.0);
} }
else if (isOutput()) else if (isOutput())
{ {
return BPoint(frame().right + 1.0, frame().top + frame().Height() / 2.0); return BPoint(Frame().right + 1.0, Frame().top + Frame().Height() / 2.0);
} }
break; break;
} }
@@ -174,11 +174,11 @@ BPoint MediaJack::connectionPoint() const
{ {
if (isInput()) if (isInput())
{ {
return BPoint(frame().left + frame().Width() / 2.0, frame().top - 1.0); return BPoint(Frame().left + Frame().Width() / 2.0, Frame().top - 1.0);
} }
else if (isOutput()) else if (isOutput())
{ {
return BPoint(frame().left + frame().Width() / 2.0, frame().bottom + 1.0); return BPoint(Frame().left + Frame().Width() / 2.0, Frame().bottom + 1.0);
} }
break; break;
} }
@@ -199,17 +199,17 @@ bool MediaJack::connectionRequested(
return false; return false;
} }
void MediaJack::mouseDown( void MediaJack::MouseDown(
BPoint point, BPoint point,
uint32 buttons, uint32 buttons,
uint32 clicks) uint32 clicks)
{ {
D_MOUSE(("MediaJack::mouseOver()\n")); D_MOUSE(("MediaJack::MouseOver()\n"));
// if connected, redirect to the wire // if connected, redirect to the wire
if (isConnected()) if (isConnected())
{ {
dynamic_cast<MediaWire *>(wire())->mouseDown(point, buttons, clicks); dynamic_cast<MediaWire *>(wire())->MouseDown(point, buttons, clicks);
return; return;
} }
@@ -223,16 +223,16 @@ void MediaJack::mouseDown(
} }
default: default:
{ {
DiagramEndPoint::mouseDown(point, buttons, clicks); DiagramEndPoint::MouseDown(point, buttons, clicks);
} }
} }
} }
void MediaJack::mouseOver( void MediaJack::MouseOver(
BPoint point, BPoint point,
uint32 transit) uint32 transit)
{ {
D_MOUSE(("MediaJack::mouseOver()\n")); D_MOUSE(("MediaJack::MouseOver()\n"));
switch (transit) switch (transit)
{ {
case B_ENTERED_VIEW: case B_ENTERED_VIEW:
@@ -241,7 +241,7 @@ void MediaJack::mouseOver(
TipManager *tips = TipManager::Instance(); TipManager *tips = TipManager::Instance();
BString tipText = m_label.String(); BString tipText = m_label.String();
tipText << " (" << MediaString::getStringFor(m_format.type) << ")"; tipText << " (" << MediaString::getStringFor(m_format.type) << ")";
tips->showTip(tipText.String(),view()->ConvertToScreen(frame()), tips->showTip(tipText.String(),view()->ConvertToScreen(Frame()),
TipManager::LEFT_OFFSET_FROM_POINTER, BPoint(12.0, 8.0)); TipManager::LEFT_OFFSET_FROM_POINTER, BPoint(12.0, 8.0));
break; break;
} }
@@ -256,12 +256,12 @@ void MediaJack::mouseOver(
} }
} }
void MediaJack::messageDragged( void MediaJack::MessageDragged(
BPoint point, BPoint point,
uint32 transit, uint32 transit,
const BMessage *message) const BMessage *message)
{ {
D_MOUSE(("MediaJack::messageDragged()\n")); D_MOUSE(("MediaJack::MessageDragged()\n"));
switch (transit) switch (transit)
{ {
case B_ENTERED_VIEW: case B_ENTERED_VIEW:
@@ -278,35 +278,35 @@ void MediaJack::messageDragged(
break; break;
} }
} }
DiagramEndPoint::messageDragged(point, transit, message); DiagramEndPoint::MessageDragged(point, transit, message);
} }
void MediaJack::selected() void MediaJack::selected()
{ {
D_METHOD(("MediaJack::selected()\n")); D_METHOD(("MediaJack::selected()\n"));
_updateBitmap(); _updateBitmap();
view()->Invalidate(frame()); view()->Invalidate(Frame());
} }
void MediaJack::deselected() void MediaJack::deselected()
{ {
D_METHOD(("MediaJack::deselected()\n")); D_METHOD(("MediaJack::deselected()\n"));
_updateBitmap(); _updateBitmap();
view()->Invalidate(frame()); view()->Invalidate(Frame());
} }
void MediaJack::connected() void MediaJack::connected()
{ {
D_METHOD(("MediaJack::connected()\n")); D_METHOD(("MediaJack::connected()\n"));
_updateBitmap(); _updateBitmap();
view()->Invalidate(frame()); view()->Invalidate(Frame());
} }
void MediaJack::disconnected() void MediaJack::disconnected()
{ {
D_METHOD(("MediaJack::disconnected()\n")); D_METHOD(("MediaJack::disconnected()\n"));
_updateBitmap(); _updateBitmap();
view()->Invalidate(frame()); view()->Invalidate(Frame());
} }
// -------------------------------------------------------- // // -------------------------------------------------------- //
@@ -338,7 +338,7 @@ void MediaJack::setPosition(
} }
else if (isOutput()) else if (isOutput())
{ {
moveTo(BPoint(rightBottomBoundary - frame().Width(), offset), updateRegion); moveTo(BPoint(rightBottomBoundary - Frame().Width(), offset), updateRegion);
} }
break; break;
} }
@@ -350,7 +350,7 @@ void MediaJack::setPosition(
} }
else if (isOutput()) else if (isOutput())
{ {
moveTo(BPoint(offset, rightBottomBoundary - frame().Height()), updateRegion); moveTo(BPoint(offset, rightBottomBoundary - Frame().Height()), updateRegion);
} }
break; break;
} }
@@ -369,7 +369,7 @@ void MediaJack::_updateBitmap()
{ {
delete m_bitmap; delete m_bitmap;
} }
BBitmap *tempBitmap = new BBitmap(frame().OffsetToCopy(0.0, 0.0), B_CMAP8, true); BBitmap *tempBitmap = new BBitmap(Frame().OffsetToCopy(0.0, 0.0), B_CMAP8, true);
tempBitmap->Lock(); tempBitmap->Lock();
{ {
BView *tempView = new BView(tempBitmap->Bounds(), "", B_FOLLOW_NONE, 0); BView *tempView = new BView(tempBitmap->Bounds(), "", B_FOLLOW_NONE, 0);
@@ -413,7 +413,7 @@ void MediaJack::_drawInto(
// draw connection point // draw connection point
r = targetRect; r = targetRect;
p.Set(0.0, frame().Height() / 2.0 - 2.0); p.Set(0.0, Frame().Height() / 2.0 - 2.0);
target->BeginLineArray(4); target->BeginLineArray(4);
{ {
target->AddLine(r.LeftTop(), target->AddLine(r.LeftTop(),
@@ -470,7 +470,7 @@ void MediaJack::_drawInto(
font.SetSize(font.Size() - 2.0); font.SetSize(font.Size() - 2.0);
font.GetHeight(&fh); font.GetHeight(&fh);
p.x += 7.0; p.x += 7.0;
p.y = (frame().Height() / 2.0) + (fh.ascent / 2.0); p.y = (Frame().Height() / 2.0) + (fh.ascent / 2.0);
target->SetFont(&font); target->SetFont(&font);
target->SetDrawingMode(B_OP_OVER); target->SetDrawingMode(B_OP_OVER);
target->SetHighColor((isConnected() || isConnecting()) ? target->SetHighColor((isConnected() || isConnecting()) ?
@@ -491,7 +491,7 @@ void MediaJack::_drawInto(
// draw connection point // draw connection point
r = targetRect; r = targetRect;
p.Set(targetRect.right - 4.0, frame().Height() / 2.0 - 2.0); p.Set(targetRect.right - 4.0, Frame().Height() / 2.0 - 2.0);
target->BeginLineArray(4); target->BeginLineArray(4);
{ {
target->AddLine(r.RightTop(), target->AddLine(r.RightTop(),
@@ -544,7 +544,7 @@ void MediaJack::_drawInto(
font.SetSize(font.Size() - 2.0); font.SetSize(font.Size() - 2.0);
font.GetHeight(&fh); font.GetHeight(&fh);
p.x -= font.StringWidth(m_abbreviation.String()) + 2.0; p.x -= font.StringWidth(m_abbreviation.String()) + 2.0;
p.y = (frame().Height() / 2.0) + (fh.ascent / 2.0); p.y = (Frame().Height() / 2.0) + (fh.ascent / 2.0);
target->SetFont(&font); target->SetFont(&font);
target->SetDrawingMode(B_OP_OVER); target->SetDrawingMode(B_OP_OVER);
target->SetHighColor((isConnected() || isConnecting()) ? target->SetHighColor((isConnected() || isConnecting()) ?
@@ -569,7 +569,7 @@ void MediaJack::_drawInto(
// draw connection point // draw connection point
r = targetRect; r = targetRect;
p.Set(frame().Width() / 2.0 - 2.0, 0.0); p.Set(Frame().Width() / 2.0 - 2.0, 0.0);
target->BeginLineArray(4); target->BeginLineArray(4);
{ {
target->AddLine(r.LeftTop(), target->AddLine(r.LeftTop(),
@@ -628,7 +628,7 @@ void MediaJack::_drawInto(
// draw connection point // draw connection point
r = targetRect; r = targetRect;
p.Set(frame().Width() / 2.0 - 2.0, targetRect.bottom - 4.0); p.Set(Frame().Width() / 2.0 - 2.0, targetRect.bottom - 4.0);
target->BeginLineArray(4); target->BeginLineArray(4);
{ {
target->AddLine(r.LeftBottom(), target->AddLine(r.LeftBottom(),
+3 -3
View File
@@ -103,18 +103,18 @@ public: // *** derived from DiagramEndPoint/Item
DiagramEndPoint *which); DiagramEndPoint *which);
// displays the context menu for right-clicks // displays the context menu for right-clicks
virtual void mouseDown( virtual void MouseDown(
BPoint point, BPoint point,
uint32 buttons, uint32 buttons,
uint32 clicks); uint32 clicks);
// changes the mouse cursor and prepares a tooltip // changes the mouse cursor and prepares a tooltip
virtual void mouseOver( virtual void MouseOver(
BPoint point, BPoint point,
uint32 transit); uint32 transit);
// changes the mouse cursor // changes the mouse cursor
virtual void messageDragged( virtual void MessageDragged(
BPoint point, BPoint point,
uint32 transit, uint32 transit,
const BMessage *message); const BMessage *message);
@@ -107,7 +107,7 @@ void MediaNodePanel::detachedFromDiagram()
{ {
D_METHOD(("MediaNodePanel::detachedFromDiagram()\n")); D_METHOD(("MediaNodePanel::detachedFromDiagram()\n"));
BRect labelRect = m_labelRect.OffsetByCopy(frame().LeftTop()); BRect labelRect = m_labelRect.OffsetByCopy(Frame().LeftTop());
if (m_mouseOverLabel && m_labelTruncated) if (m_mouseOverLabel && m_labelTruncated)
{ {
TipManager *tips = TipManager::Instance(); TipManager *tips = TipManager::Instance();
@@ -117,27 +117,27 @@ void MediaNodePanel::detachedFromDiagram()
view()->Looper()->RemoveHandler(this); view()->Looper()->RemoveHandler(this);
} }
void MediaNodePanel::drawBox() void MediaNodePanel::DrawBox()
{ {
D_DRAW(("MediaNodePanel::drawBox()\n")); D_DRAW(("MediaNodePanel::DrawBox()\n"));
if (m_bitmap) if (m_bitmap)
{ {
view()->DrawBitmap(m_bitmap, frame().LeftTop()); view()->DrawBitmap(m_bitmap, Frame().LeftTop());
} }
} }
void MediaNodePanel::mouseDown( void MediaNodePanel::MouseDown(
BPoint point, BPoint point,
uint32 buttons, uint32 buttons,
uint32 clicks) uint32 clicks)
{ {
D_METHOD(("MediaNodePanel::mouseDown()\n")); D_METHOD(("MediaNodePanel::MouseDown()\n"));
_inherited::mouseDown(point, buttons, clicks); _inherited::MouseDown(point, buttons, clicks);
// +++ REALLY BAD WORKAROUND // +++ REALLY BAD WORKAROUND
MediaJack *jack = dynamic_cast<MediaJack *>(_LastItemUnder()); MediaJack *jack = dynamic_cast<MediaJack *>(_LastItemUnder());
if (jack && jack->frame().Contains(point)) if (jack && jack->Frame().Contains(point))
{ {
return; return;
} }
@@ -164,12 +164,12 @@ void MediaNodePanel::mouseDown(
} }
} }
void MediaNodePanel::mouseOver( void MediaNodePanel::MouseOver(
BPoint point, BPoint point,
uint32 transit) uint32 transit)
{ {
D_METHOD(("MediaNodePanel::mouseOver()\n")); D_METHOD(("MediaNodePanel::MouseOver()\n"));
_inherited::mouseOver(point, transit); _inherited::MouseOver(point, transit);
switch (transit) switch (transit)
{ {
@@ -179,7 +179,7 @@ void MediaNodePanel::mouseOver(
} }
case B_INSIDE_VIEW: case B_INSIDE_VIEW:
{ {
BRect labelRect = m_labelRect.OffsetByCopy(frame().LeftTop()); BRect labelRect = m_labelRect.OffsetByCopy(Frame().LeftTop());
if (labelRect.Contains(point)) if (labelRect.Contains(point))
{ {
if (!m_mouseOverLabel && m_labelTruncated) if (!m_mouseOverLabel && m_labelTruncated)
@@ -203,17 +203,17 @@ void MediaNodePanel::mouseOver(
} }
} }
void MediaNodePanel::messageDropped( void MediaNodePanel::MessageDropped(
BPoint point, BPoint point,
BMessage *message) BMessage *message)
{ {
D_METHOD(("MediaNodePanel::messageDropped()\n")); D_METHOD(("MediaNodePanel::MessageDropped()\n"));
// +++ REALLY BAD WORKAROUND // +++ REALLY BAD WORKAROUND
MediaJack *jack = dynamic_cast<MediaJack *>(ItemUnder(point)); MediaJack *jack = dynamic_cast<MediaJack *>(ItemUnder(point));
if (jack) if (jack)
{ {
jack->messageDropped(point, message); jack->MessageDropped(point, message);
return; return;
} }
else else
@@ -243,7 +243,7 @@ void MediaNodePanel::layoutChanged(
{ {
D_METHOD(("MediaNodePanel::layoutChanged()\n")); D_METHOD(("MediaNodePanel::layoutChanged()\n"));
BPoint p = frame().LeftTop(); BPoint p = Frame().LeftTop();
if (m_alternatePosition == s_invalidPosition) if (m_alternatePosition == s_invalidPosition)
{ {
m_alternatePosition = dynamic_cast<MediaRoutingView *> m_alternatePosition = dynamic_cast<MediaRoutingView *>
@@ -367,13 +367,13 @@ void MediaNodePanel::arrangeIOJacks()
minHeight += m_labelRect.Height(); minHeight += m_labelRect.Height();
minHeight += 2 * MediaJack::M_DEFAULT_GAP; minHeight += 2 * MediaJack::M_DEFAULT_GAP;
minHeight = ((int)minHeight / (int)align) * align + align; minHeight = ((int)minHeight / (int)align) * align + align;
if ((frame().Height() < minHeight) if ((Frame().Height() < minHeight)
|| ((frame().Height() > minHeight) || ((Frame().Height() > minHeight)
&& (minHeight >= MediaNodePanel::M_DEFAULT_HEIGHT))) && (minHeight >= MediaNodePanel::M_DEFAULT_HEIGHT)))
{ {
updateRegion.Include(frame()); updateRegion.Include(Frame());
resizeTo(frame().Width(), minHeight); resizeTo(Frame().Width(), minHeight);
updateRegion.Include(frame()); updateRegion.Include(Frame());
_prepareLabel(); _prepareLabel();
} }
@@ -381,7 +381,7 @@ void MediaNodePanel::arrangeIOJacks()
BRect r = m_bodyRect; BRect r = m_bodyRect;
r.bottom -= M_BODY_V_MARGIN; r.bottom -= M_BODY_V_MARGIN;
float inputOffset = 0.0, outputOffset = 0.0; float inputOffset = 0.0, outputOffset = 0.0;
float center = frame().top + r.top + (r.Height() / 2.0); float center = Frame().top + r.top + (r.Height() / 2.0);
center += MediaJack::M_DEFAULT_GAP - (MediaJack::M_DEFAULT_HEIGHT / 2.0); center += MediaJack::M_DEFAULT_GAP - (MediaJack::M_DEFAULT_HEIGHT / 2.0);
center = ((int)center / (int)align) * align; center = ((int)center / (int)align) * align;
if (numInputs) if (numInputs)
@@ -413,13 +413,13 @@ void MediaNodePanel::arrangeIOJacks()
{ {
if (jack->isInput()) if (jack->isInput())
{ {
jack->setPosition(inputOffset, frame().left, frame().right, &updateRegion); jack->setPosition(inputOffset, Frame().left, Frame().right, &updateRegion);
inputOffset += jack->frame().Height() + MediaJack::M_DEFAULT_GAP; inputOffset += jack->Frame().Height() + MediaJack::M_DEFAULT_GAP;
} }
if (jack->isOutput()) if (jack->isOutput())
{ {
jack->setPosition(outputOffset, frame().left, frame().right, &updateRegion); jack->setPosition(outputOffset, Frame().left, Frame().right, &updateRegion);
outputOffset += jack->frame().Height() + MediaJack::M_DEFAULT_GAP; outputOffset += jack->Frame().Height() + MediaJack::M_DEFAULT_GAP;
} }
} }
} }
@@ -457,18 +457,18 @@ void MediaNodePanel::arrangeIOJacks()
minWidth += m_bodyRect.Width(); minWidth += m_bodyRect.Width();
minWidth += 2 * MediaJack::M_DEFAULT_GAP; minWidth += 2 * MediaJack::M_DEFAULT_GAP;
minWidth = ((int)minWidth / (int)align) * align + align; minWidth = ((int)minWidth / (int)align) * align + align;
if ((frame().Width() < minWidth) if ((Frame().Width() < minWidth)
|| ((frame().Width() > minWidth) || ((Frame().Width() > minWidth)
&& (minWidth >= MediaNodePanel::M_DEFAULT_WIDTH))) && (minWidth >= MediaNodePanel::M_DEFAULT_WIDTH)))
{ {
updateRegion.Include(frame()); updateRegion.Include(Frame());
resizeTo(minWidth, frame().Height()); resizeTo(minWidth, Frame().Height());
updateRegion.Include(frame()); updateRegion.Include(Frame());
_prepareLabel(); _prepareLabel();
} }
// adjust the placement of the jacks // adjust the placement of the jacks
float inputOffset = 0.0, outputOffset = 0.0; float inputOffset = 0.0, outputOffset = 0.0;
float center = frame().left + m_labelRect.left + (m_labelRect.Width() / 2.0); float center = Frame().left + m_labelRect.left + (m_labelRect.Width() / 2.0);
center += MediaJack::M_DEFAULT_GAP - (MediaJack::M_DEFAULT_WIDTH / 2.0); center += MediaJack::M_DEFAULT_GAP - (MediaJack::M_DEFAULT_WIDTH / 2.0);
center = ((int)center / (int)align) * align; center = ((int)center / (int)align) * align;
if (numInputs) if (numInputs)
@@ -500,13 +500,13 @@ void MediaNodePanel::arrangeIOJacks()
{ {
if (jack->isInput()) if (jack->isInput())
{ {
jack->setPosition(inputOffset, frame().top, frame().bottom, &updateRegion); jack->setPosition(inputOffset, Frame().top, Frame().bottom, &updateRegion);
inputOffset += jack->frame().Width() + MediaJack::M_DEFAULT_GAP; inputOffset += jack->Frame().Width() + MediaJack::M_DEFAULT_GAP;
} }
if (jack->isOutput()) if (jack->isOutput())
{ {
jack->setPosition(outputOffset, frame().top, frame().bottom, &updateRegion); jack->setPosition(outputOffset, Frame().top, Frame().bottom, &updateRegion);
outputOffset += jack->frame().Width() + MediaJack::M_DEFAULT_GAP; outputOffset += jack->Frame().Width() + MediaJack::M_DEFAULT_GAP;
} }
} }
} }
@@ -719,12 +719,12 @@ status_t MediaNodePanel::exportState(
MediaRoutingView::layout_t layoutMode = v->getLayout(); MediaRoutingView::layout_t layoutMode = v->getLayout();
switch(layoutMode) { switch(layoutMode) {
case MediaRoutingView::M_ICON_VIEW: case MediaRoutingView::M_ICON_VIEW:
iconPos = frame().LeftTop(); iconPos = Frame().LeftTop();
miniIconPos = m_alternatePosition; miniIconPos = m_alternatePosition;
break; break;
case MediaRoutingView::M_MINI_ICON_VIEW: case MediaRoutingView::M_MINI_ICON_VIEW:
miniIconPos = frame().LeftTop(); miniIconPos = Frame().LeftTop();
iconPos = m_alternatePosition; iconPos = m_alternatePosition;
break; break;
} }
@@ -793,14 +793,14 @@ void MediaNodePanel::_prepareLabel()
{ {
case MediaRoutingView::M_ICON_VIEW: case MediaRoutingView::M_ICON_VIEW:
{ {
m_labelRect = frame(); m_labelRect = Frame();
m_labelRect.OffsetTo(0.0, 0.0); m_labelRect.OffsetTo(0.0, 0.0);
m_labelRect.bottom = 2 * M_LABEL_V_MARGIN + (fh.ascent + fh.descent + fh.leading) + 1.0; m_labelRect.bottom = 2 * M_LABEL_V_MARGIN + (fh.ascent + fh.descent + fh.leading) + 1.0;
break; break;
} }
case MediaRoutingView::M_MINI_ICON_VIEW: case MediaRoutingView::M_MINI_ICON_VIEW:
{ {
m_labelRect = frame(); m_labelRect = Frame();
m_labelRect.OffsetTo(0.0, 0.0); m_labelRect.OffsetTo(0.0, 0.0);
m_labelRect.left = M_BODY_H_MARGIN + B_MINI_ICON; m_labelRect.left = M_BODY_H_MARGIN + B_MINI_ICON;
m_labelRect.top += MediaJack::M_DEFAULT_HEIGHT; m_labelRect.top += MediaJack::M_DEFAULT_HEIGHT;
@@ -840,14 +840,14 @@ void MediaNodePanel::_prepareLabel()
{ {
case MediaRoutingView::M_ICON_VIEW: case MediaRoutingView::M_ICON_VIEW:
{ {
m_bodyRect = frame(); m_bodyRect = Frame();
m_bodyRect.OffsetTo(0.0, 0.0); m_bodyRect.OffsetTo(0.0, 0.0);
m_bodyRect.top = m_labelRect.bottom; m_bodyRect.top = m_labelRect.bottom;
break; break;
} }
case MediaRoutingView::M_MINI_ICON_VIEW: case MediaRoutingView::M_MINI_ICON_VIEW:
{ {
m_bodyRect = frame(); m_bodyRect = Frame();
m_bodyRect.OffsetTo(0.0, 0.0); m_bodyRect.OffsetTo(0.0, 0.0);
m_bodyRect.right = m_labelRect.left; m_bodyRect.right = m_labelRect.left;
break; break;
@@ -861,7 +861,7 @@ void MediaNodePanel::_updateBitmap()
{ {
delete m_bitmap; delete m_bitmap;
} }
BBitmap *tempBitmap = new BBitmap(frame().OffsetToCopy(0.0, 0.0), B_CMAP8, true); BBitmap *tempBitmap = new BBitmap(Frame().OffsetToCopy(0.0, 0.0), B_CMAP8, true);
tempBitmap->Lock(); tempBitmap->Lock();
{ {
BView *tempView = new BView(tempBitmap->Bounds(), "", B_FOLLOW_NONE, 0); BView *tempView = new BView(tempBitmap->Bounds(), "", B_FOLLOW_NONE, 0);
@@ -61,18 +61,18 @@ public: // *** derived from DiagramItem
virtual void detachedFromDiagram(); virtual void detachedFromDiagram();
virtual void drawBox(); virtual void DrawBox();
virtual void mouseDown( virtual void MouseDown(
BPoint point, BPoint point,
uint32 buttons, uint32 buttons,
uint32 clicks); uint32 clicks);
virtual void mouseOver( virtual void MouseOver(
BPoint point, BPoint point,
uint32 transit); uint32 transit);
virtual void messageDropped( virtual void MessageDropped(
BPoint point, BPoint point,
BMessage *message); BMessage *message);
@@ -194,56 +194,48 @@ DiagramWire *MediaRoutingView::createWire(
return 0; return 0;
} }
void MediaRoutingView::mouseDown(
BPoint point, void
uint32 buttons, MediaRoutingView::BackgroundMouseDown(BPoint point, uint32 buttons,
uint32 clicks) uint32 clicks)
{ {
D_MOUSE(("MediaRoutingView::mouseDown()\n")); D_MOUSE(("MediaRoutingView::BackgroundMouseDown()\n"));
if ((buttons == B_SECONDARY_MOUSE_BUTTON) if ((buttons == B_SECONDARY_MOUSE_BUTTON)
|| (modifiers() & B_CONTROL_KEY)) || (modifiers() & B_CONTROL_KEY)) {
{
EndRectTracking(); EndRectTracking();
showContextMenu(point); showContextMenu(point);
} }
} }
void MediaRoutingView::messageDropped(
BPoint point,
BMessage *message)
{
D_METHOD(("MediaRoutingView::messageDropped()\n"));
switch (message->what) void
{ MediaRoutingView::MessageDropped(BPoint point, BMessage *message)
{
D_METHOD(("MediaRoutingView::MessageDropped()\n"));
switch (message->what) {
case DormantNodeView::M_INSTANTIATE_NODE: case DormantNodeView::M_INSTANTIATE_NODE:
{ {
D_MESSAGE(("MediaRoutingView::messageDropped(DormantNodeView::M_INSTANTIATE_NODE)\n")); D_MESSAGE(("MediaRoutingView::MessageDropped(DormantNodeView::M_INSTANTIATE_NODE)\n"));
type_code type; type_code type;
int32 count; int32 count;
if (message->GetInfo("which", &type, &count) == B_OK) if (message->GetInfo("which", &type, &count) == B_OK) {
{ for (int32 n = 0; n < count; n++) {
for (int32 n = 0; n < count; n++)
{
dormant_node_info info; dormant_node_info info;
const void *data; const void *data;
ssize_t dataSize; ssize_t dataSize;
if (message->FindData("which", B_RAW_TYPE, &data, &dataSize) == B_OK) if (message->FindData("which", B_RAW_TYPE, &data, &dataSize) == B_OK) {
{
memcpy(reinterpret_cast<void *>(&info), data, dataSize); memcpy(reinterpret_cast<void *>(&info), data, dataSize);
NodeRef* droppedNode; NodeRef* droppedNode;
status_t error; status_t error;
error = manager->instantiate(info, &droppedNode); error = manager->instantiate(info, &droppedNode);
if (!error) if (!error) {
{
m_lastDroppedNode = droppedNode->id(); m_lastDroppedNode = droppedNode->id();
BPoint dropPoint, dropOffset; BPoint dropPoint, dropOffset;
dropPoint = message->DropPoint(&dropOffset); dropPoint = message->DropPoint(&dropOffset);
m_lastDropPoint = Align(ConvertFromScreen(dropPoint - dropOffset)); m_lastDropPoint = Align(ConvertFromScreen(dropPoint - dropOffset));
} } else {
else
{
BString s; BString s;
s << "Could not instantiate '" << info.name << "'"; s << "Could not instantiate '" << info.name << "'";
showErrorMessage(s, error); showErrorMessage(s, error);
@@ -253,36 +245,36 @@ void MediaRoutingView::messageDropped(
} }
break; break;
} }
case B_SIMPLE_DATA: case B_SIMPLE_DATA:
{ {
D_MESSAGE(("MediaRoutingView::messageDropped(B_SIMPLE_DATA)\n")); D_MESSAGE(("MediaRoutingView::MessageDropped(B_SIMPLE_DATA)\n"));
entry_ref fileRef; entry_ref fileRef;
if (message->FindRef("refs", &fileRef) == B_OK) if (message->FindRef("refs", &fileRef) == B_OK)
{
_checkDroppedFile(&fileRef, ConvertFromScreen(message->DropPoint())); _checkDroppedFile(&fileRef, ConvertFromScreen(message->DropPoint()));
}
break; break;
} }
case B_PASTE: case B_PASTE:
{ {
D_MESSAGE(("MediaRoutingView::messageDropped(B_PASTE)\n")); D_MESSAGE(("MediaRoutingView::MessageDropped(B_PASTE)\n"));
ssize_t size; ssize_t size;
const rgb_color *color; // [e.moon 21nov99] fixed const error const rgb_color *color; // [e.moon 21nov99] fixed const error
if (message->FindData("RGBColor", B_RGB_COLOR_TYPE, reinterpret_cast<const void **>(&color), &size) == B_OK) if (message->FindData("RGBColor", B_RGB_COLOR_TYPE,
{ reinterpret_cast<const void **>(&color), &size) == B_OK)
_changeBackground(*color); _changeBackground(*color);
}
break; break;
} }
default: default:
{ DiagramView::MessageDropped(point, message);
DiagramView::messageDropped(point, message);
}
} }
} }
void MediaRoutingView::selectionChanged() {
void
MediaRoutingView::selectionChanged()
{
D_METHOD(("MediaRoutingView::selectionChanged()\n")); D_METHOD(("MediaRoutingView::selectionChanged()\n"));
_broadcastSelection(); _broadcastSelection();
} }
@@ -723,7 +715,7 @@ BPoint MediaRoutingView::findFreePositionFor(
float bottom = 0.0; float bottom = 0.0;
for (uint32 i = 0; i < CountItems(DiagramItem::M_BOX); i++) for (uint32 i = 0; i < CountItems(DiagramItem::M_BOX); i++)
{ {
BRect r = ItemAt(i, DiagramItem::M_BOX)->frame(); BRect r = ItemAt(i, DiagramItem::M_BOX)->Frame();
if ((r.left >= p.x) if ((r.left >= p.x)
&& (r.left <= p.x + MediaNodePanel::M_DEFAULT_WIDTH)) && (r.left <= p.x + MediaNodePanel::M_DEFAULT_WIDTH))
{ {
@@ -752,7 +744,7 @@ BPoint MediaRoutingView::findFreePositionFor(
float right = 0.0; float right = 0.0;
for (uint32 i = 0; i < CountItems(DiagramItem::M_BOX); i++) for (uint32 i = 0; i < CountItems(DiagramItem::M_BOX); i++)
{ {
BRect r = ItemAt(i, DiagramItem::M_BOX)->frame(); BRect r = ItemAt(i, DiagramItem::M_BOX)->Frame();
if ((r.top >= p.y) if ((r.top >= p.y)
&& (r.top <= p.y + MediaNodePanel::M_DEFAULT_HEIGHT)) && (r.top <= p.y + MediaNodePanel::M_DEFAULT_HEIGHT))
{ {
@@ -1244,7 +1236,7 @@ status_t MediaRoutingView::_addPanelFor(
BPoint p = findFreePositionFor(panel); BPoint p = findFreePositionFor(panel);
panel->moveTo(p); panel->moveTo(p);
} }
Invalidate(panel->frame()); Invalidate(panel->Frame());
} }
} }
updateDataRect(); updateDataRect();
@@ -1283,7 +1275,7 @@ status_t MediaRoutingView::_removePanelFor(
if (RemoveItem(panel)) if (RemoveItem(panel))
{ {
remove_observer(this, panel->ref); remove_observer(this, panel->ref);
Invalidate(panel->frame()); Invalidate(panel->Frame());
delete panel; delete panel;
return B_OK; return B_OK;
} }
@@ -1331,9 +1323,9 @@ status_t MediaRoutingView::_addWireFor(
// [e.moon 21nov99] group creation/merging now performed by // [e.moon 21nov99] group creation/merging now performed by
// RouteAppNodeManager // RouteAppNodeManager
Invalidate(source->frame()); Invalidate(source->Frame());
Invalidate(destination->frame()); Invalidate(destination->Frame());
Invalidate(wire->frame()); Invalidate(wire->Frame());
return B_OK; return B_OK;
} }
else else
@@ -1372,19 +1364,19 @@ status_t MediaRoutingView::_removeWireFor(
_findPanelFor(wire->connection.sourceNode(), &source); _findPanelFor(wire->connection.sourceNode(), &source);
_findPanelFor(wire->connection.destinationNode(), &destination); _findPanelFor(wire->connection.destinationNode(), &destination);
RemoveItem(wire); RemoveItem(wire);
Invalidate(wire->frame()); Invalidate(wire->Frame());
delete wire; delete wire;
if (source) if (source)
{ {
source->updateIOJacks(); source->updateIOJacks();
source->arrangeIOJacks(); source->arrangeIOJacks();
Invalidate(source->frame()); Invalidate(source->Frame());
} }
if (destination) if (destination)
{ {
destination->updateIOJacks(); destination->updateIOJacks();
destination->arrangeIOJacks(); destination->arrangeIOJacks();
Invalidate(destination->frame()); Invalidate(destination->Frame());
} }
// [e.moon 21nov99] group split/remove now performed by // [e.moon 21nov99] group split/remove now performed by
@@ -172,12 +172,12 @@ public: // *** DiagramView impl
DiagramWire *createWire( DiagramWire *createWire(
DiagramEndPoint *fromWhich); DiagramEndPoint *fromWhich);
virtual void mouseDown( virtual void BackgroundMouseDown(
BPoint point, BPoint point,
uint32 buttons, uint32 buttons,
uint32 clicks); uint32 clicks);
virtual void messageDropped( virtual void MessageDropped(
BPoint point, BPoint point,
BMessage *message); BMessage *message);
+11 -11
View File
@@ -79,12 +79,12 @@ void MediaWire::detachedFromDiagram()
// make sure we're no longer displaying a tooltip // make sure we're no longer displaying a tooltip
TipManager *tips = TipManager::Instance(); TipManager *tips = TipManager::Instance();
tips->hideTip(view()->ConvertToScreen(frame())); tips->hideTip(view()->ConvertToScreen(Frame()));
} }
BRect MediaWire::frame() const BRect MediaWire::Frame() const
{ {
D_DRAW(("MediaWire::frame()\n")); D_DRAW(("MediaWire::Frame()\n"));
return m_frame; return m_frame;
} }
@@ -92,7 +92,7 @@ float MediaWire::howCloseTo(
BPoint point) const BPoint point) const
{ {
D_MOUSE(("MediaWire::howCloseTo()\n")); D_MOUSE(("MediaWire::howCloseTo()\n"));
if (frame().Contains(point)) if (Frame().Contains(point))
{ {
BPoint sp = m_startPoint; BPoint sp = m_startPoint;
BPoint ep = m_endPoint; BPoint ep = m_endPoint;
@@ -144,13 +144,13 @@ void MediaWire::drawWire()
view()->EndLineArray(); view()->EndLineArray();
} }
void MediaWire::mouseDown( void MediaWire::MouseDown(
BPoint point, BPoint point,
uint32 buttons, uint32 buttons,
uint32 clicks) uint32 clicks)
{ {
D_MOUSE(("MediaWire::mouseDown()\n")); D_MOUSE(("MediaWire::MouseDown()\n"));
_inherited::mouseDown(point, buttons, clicks); _inherited::MouseDown(point, buttons, clicks);
switch (buttons) switch (buttons)
{ {
@@ -164,11 +164,11 @@ void MediaWire::mouseDown(
} }
} }
void MediaWire::mouseOver( void MediaWire::MouseOver(
BPoint point, BPoint point,
uint32 transit) uint32 transit)
{ {
D_MOUSE(("MediaWire::mouseOver()\n")); D_MOUSE(("MediaWire::MouseOver()\n"));
if (isDragging()) if (isDragging())
{ {
@@ -180,7 +180,7 @@ void MediaWire::mouseOver(
{ {
TipManager *tips = TipManager::Instance(); TipManager *tips = TipManager::Instance();
BString tipText = MediaString::getStringFor(connection.format(), false); BString tipText = MediaString::getStringFor(connection.format(), false);
tips->showTip(tipText.String(), view()->ConvertToScreen(frame()), tips->showTip(tipText.String(), view()->ConvertToScreen(Frame()),
TipManager::LEFT_OFFSET_FROM_POINTER, BPoint(12.0, 8.0)); TipManager::LEFT_OFFSET_FROM_POINTER, BPoint(12.0, 8.0));
be_app->SetCursor(M_CABLE_CURSOR); be_app->SetCursor(M_CABLE_CURSOR);
break; break;
@@ -189,7 +189,7 @@ void MediaWire::mouseOver(
{ {
be_app->SetCursor(B_HAND_CURSOR); be_app->SetCursor(B_HAND_CURSOR);
TipManager *tips = TipManager::Instance(); TipManager *tips = TipManager::Instance();
tips->hideTip(view()->ConvertToScreen(frame())); tips->hideTip(view()->ConvertToScreen(Frame()));
break; break;
} }
} }
+3 -3
View File
@@ -59,7 +59,7 @@ public: // *** derived from DiagramWire/Item
virtual void detachedFromDiagram(); virtual void detachedFromDiagram();
// calculates and returns the frame rectangle of the wire // calculates and returns the frame rectangle of the wire
virtual BRect frame() const; virtual BRect Frame() const;
// returns a value > 0.5 for points pretty much close to the // returns a value > 0.5 for points pretty much close to the
// wire // wire
@@ -70,13 +70,13 @@ public: // *** derived from DiagramWire/Item
virtual void drawWire(); virtual void drawWire();
// displays the context-menu for right-clicks // displays the context-menu for right-clicks
virtual void mouseDown( virtual void MouseDown(
BPoint point, BPoint point,
uint32 buttons, uint32 buttons,
uint32 clicks); uint32 clicks);
// changes the mouse cursor and starts a tooltip // changes the mouse cursor and starts a tooltip
virtual void mouseOver( virtual void MouseOver(
BPoint point, BPoint point,
uint32 transit); uint32 transit);
@@ -227,7 +227,7 @@ pair<BView*, const tip_entry*> _ViewEntry::match(
BPoint point, BPoint screenPoint) { BPoint point, BPoint screenPoint) {
// fetch this view's current frame rect // fetch this view's current frame rect
BRect f = frame(); BRect f = Frame();
// check for a full-frame tip: // check for a full-frame tip:
@@ -277,7 +277,7 @@ pair<BView*, const tip_entry*> _ViewEntry::match(
} }
// get frame rect (in parent view's coordinates) // get frame rect (in parent view's coordinates)
BRect _ViewEntry::frame() { BRect _ViewEntry::Frame() {
ASSERT(m_target); ASSERT(m_target);
// ASSERT(m_target->Parent()); // ASSERT(m_target->Parent());
+1 -1
View File
@@ -149,7 +149,7 @@ public: // *** interface
BPoint screenPoint); BPoint screenPoint);
// retrieve current frame rect (in parent view's coordinates) // retrieve current frame rect (in parent view's coordinates)
BRect frame(); BRect Frame();
BView* target() const { return m_target; } BView* target() const { return m_target; }
_ViewEntry* parent() const { return m_parent; } _ViewEntry* parent() const { return m_parent; }