Another round of style updates by Vasilis Kaoutsis.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20880 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
__BEGIN_CORTEX_NAMESPACE
|
__BEGIN_CORTEX_NAMESPACE
|
||||||
namespace addon_host {
|
namespace addon_host {
|
||||||
|
|
||||||
class App:public BApplication {
|
class App : public BApplication {
|
||||||
typedef BApplication _inherited;
|
typedef BApplication _inherited;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -16,41 +16,35 @@ __USE_CORTEX_NAMESPACE
|
|||||||
#define D_MOUSE(x) //PRINT (x)
|
#define D_MOUSE(x) //PRINT (x)
|
||||||
#define D_DRAW(x) //PRINT (x)
|
#define D_DRAW(x) //PRINT (x)
|
||||||
|
|
||||||
// -------------------------------------------------------- //
|
|
||||||
// *** ctor/dtor (public)
|
|
||||||
// -------------------------------------------------------- //
|
|
||||||
|
|
||||||
DiagramBox::DiagramBox(
|
// #pragma mark -
|
||||||
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),
|
m_frame(frame),
|
||||||
m_flags(flags)
|
m_flags(flags)
|
||||||
{
|
{
|
||||||
D_METHOD(("DiagramBox::DiagramBox()\n"));
|
D_METHOD(("DiagramBox::DiagramBox()\n"));
|
||||||
makeDraggable(true);
|
makeDraggable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DiagramBox::~DiagramBox()
|
DiagramBox::~DiagramBox()
|
||||||
{
|
{
|
||||||
D_METHOD(("DiagramBox::~DiagramBox()\n"));
|
D_METHOD(("DiagramBox::~DiagramBox()\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------- //
|
|
||||||
// *** derived from DiagramItemGroup (public)
|
|
||||||
// -------------------------------------------------------- //
|
|
||||||
|
|
||||||
bool DiagramBox::addItem(
|
// derived from DiagramItemGroup (public)
|
||||||
DiagramItem *item)
|
bool
|
||||||
|
DiagramBox::addItem(DiagramItem *item)
|
||||||
{
|
{
|
||||||
D_METHOD(("DiagramBox::addItem()\n"));
|
D_METHOD(("DiagramBox::addItem()\n"));
|
||||||
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();
|
||||||
}
|
}
|
||||||
@@ -60,15 +54,14 @@ bool DiagramBox::addItem(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiagramBox::removeItem(
|
|
||||||
DiagramItem *item)
|
bool
|
||||||
|
DiagramBox::removeItem(DiagramItem *item)
|
||||||
{
|
{
|
||||||
D_METHOD(("DiagramBox::removeItem()\n"));
|
D_METHOD(("DiagramBox::removeItem()\n"));
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -76,47 +69,36 @@ bool DiagramBox::removeItem(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------- //
|
|
||||||
// *** derived from DiagramItem (public)
|
|
||||||
// -------------------------------------------------------- //
|
|
||||||
|
|
||||||
void DiagramBox::draw(
|
// derived from DiagramItem (public)
|
||||||
BRect updateRect)
|
void
|
||||||
|
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 (m_flags & 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(®ion);
|
view()->ConstrainClippingRegion(®ion);
|
||||||
drawBox();
|
drawBox();
|
||||||
for (int32 i = 0; i < countItems(); i++)
|
for (int32 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 (int32 i = 0; i < countItems(); i++)
|
for (int32 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);
|
||||||
}
|
}
|
||||||
@@ -129,36 +111,26 @@ void DiagramBox::draw(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramBox::mouseDown(
|
|
||||||
BPoint point,
|
void
|
||||||
uint32 buttons,
|
DiagramBox::mouseDown(BPoint point, uint32 buttons, uint32 clicks)
|
||||||
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);
|
||||||
if (modifiers() & B_SHIFT_KEY)
|
if (modifiers() & B_SHIFT_KEY)
|
||||||
{
|
|
||||||
selectMsg.AddBool("replace", false);
|
selectMsg.AddBool("replace", false);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
selectMsg.AddBool("replace", true);
|
selectMsg.AddBool("replace", true);
|
||||||
}
|
|
||||||
selectMsg.AddPointer("item", reinterpret_cast<void *>(this));
|
selectMsg.AddPointer("item", reinterpret_cast<void *>(this));
|
||||||
DiagramView* v = view();
|
DiagramView* v = view();
|
||||||
BMessenger(v).SendMessage(&selectMsg);
|
BMessenger(v).SendMessage(&selectMsg);
|
||||||
}
|
}
|
||||||
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());
|
||||||
@@ -167,159 +139,114 @@ void DiagramBox::mouseDown(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramBox::mouseOver(
|
|
||||||
BPoint point,
|
void
|
||||||
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);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramBox::messageDragged(
|
|
||||||
BPoint point,
|
void
|
||||||
uint32 transit,
|
DiagramBox::messageDragged(BPoint point, uint32 transit, const BMessage *message)
|
||||||
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);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramBox::messageDropped(
|
|
||||||
BPoint point,
|
void
|
||||||
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)
|
|
||||||
// -------------------------------------------------------- //
|
|
||||||
|
|
||||||
void DiagramBox::moveBy(
|
// operations (public)
|
||||||
float x,
|
void
|
||||||
float y,
|
DiagramBox::moveBy(float x, float y, BRegion *wireRegion)
|
||||||
BRegion *wireRegion)
|
|
||||||
{
|
{
|
||||||
D_METHOD(("DiagramBox::moveBy()\n"));
|
D_METHOD(("DiagramBox::moveBy()\n"));
|
||||||
if (view())
|
if (view()) {
|
||||||
{
|
|
||||||
view()->PushState();
|
view()->PushState();
|
||||||
{
|
{
|
||||||
for (int32 i = 0; i < countItems(); i++)
|
for (int32 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(m_frame);
|
||||||
m_frame.OffsetBy(x, y);
|
m_frame.OffsetBy(x, y);
|
||||||
wireRegion->Include(m_frame);
|
wireRegion->Include(m_frame);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
m_frame.OffsetBy(x, y);
|
m_frame.OffsetBy(x, y);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
view()->PopState();
|
view()->PopState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramBox::resizeBy(
|
|
||||||
float horizontal,
|
void
|
||||||
float vertical)
|
DiagramBox::resizeBy(float horizontal, float vertical)
|
||||||
{
|
{
|
||||||
D_METHOD(("DiagramBox::resizeBy()\n"));
|
D_METHOD(("DiagramBox::resizeBy()\n"));
|
||||||
m_frame.right += horizontal;
|
m_frame.right += horizontal;
|
||||||
m_frame.bottom += vertical;
|
m_frame.bottom += vertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------- //
|
|
||||||
// *** internal operations (private)
|
|
||||||
// -------------------------------------------------------- //
|
|
||||||
|
|
||||||
void DiagramBox::_setOwner(
|
// internal operations (private)
|
||||||
DiagramView *owner)
|
void
|
||||||
|
DiagramBox::_setOwner(DiagramView *owner)
|
||||||
{
|
{
|
||||||
D_METHOD(("DiagramBox::_setOwner()\n"));
|
D_METHOD(("DiagramBox::_setOwner()\n"));
|
||||||
m_view = owner;
|
m_view = owner;
|
||||||
for (int32 i = 0; i < countItems(DiagramItem::M_ENDPOINT); i++)
|
for (int32 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();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// END -- DiagramBox.cpp --
|
|
||||||
|
|||||||
@@ -8,123 +8,95 @@
|
|||||||
// * HISTORY
|
// * HISTORY
|
||||||
// c.lenz 25sep99 Begun
|
// c.lenz 25sep99 Begun
|
||||||
//
|
//
|
||||||
|
#ifndef DIAGRAM_BOX_H
|
||||||
|
#define DIAGRAM_BOX_H
|
||||||
|
|
||||||
#ifndef __DiagramBox_H__
|
#include "cortex_defs.h"
|
||||||
#define __DiagramBox_H__
|
#include "DiagramItem.h"
|
||||||
|
#include "DiagramItemGroup.h"
|
||||||
|
|
||||||
#include <Region.h>
|
#include <Region.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
#include "DiagramItem.h"
|
|
||||||
#include "DiagramItemGroup.h"
|
|
||||||
|
|
||||||
#include "cortex_defs.h"
|
|
||||||
__BEGIN_CORTEX_NAMESPACE
|
__BEGIN_CORTEX_NAMESPACE
|
||||||
|
|
||||||
class DiagramBox : public DiagramItem,
|
|
||||||
public DiagramItemGroup
|
|
||||||
{
|
|
||||||
|
|
||||||
public: // *** flags
|
class DiagramBox : public DiagramItem, public DiagramItemGroup {
|
||||||
|
public: // flags
|
||||||
|
|
||||||
enum flag_t
|
enum flag_t {
|
||||||
{
|
M_DRAW_UNDER_ENDPOINTS = 0x1
|
||||||
M_DRAW_UNDER_ENDPOINTS = 0x1
|
};
|
||||||
};
|
|
||||||
|
|
||||||
public: // *** ctor/dtor
|
public:
|
||||||
|
DiagramBox(BRect frame, uint32 flags = 0);
|
||||||
|
virtual ~DiagramBox();
|
||||||
|
|
||||||
DiagramBox(
|
public: // hook functions
|
||||||
BRect frame,
|
// is called from draw() to do the actual drawing
|
||||||
uint32 flags = 0);
|
virtual void drawBox() = 0;
|
||||||
|
|
||||||
virtual ~DiagramBox();
|
public: // derived from DiagramItemGroup
|
||||||
|
|
||||||
public: // *** hook functions
|
// extends the DiagramItemGroup implementation by setting
|
||||||
|
// the items owner and calling the attachedToDiagram() hook
|
||||||
|
// on it
|
||||||
|
virtual bool addItem(DiagramItem *item);
|
||||||
|
|
||||||
// is called from draw() to do the actual drawing
|
// extends the DiagramItemGroup implementation by calling
|
||||||
virtual void drawBox() = 0;
|
// the detachedToDiagram() hook on the item
|
||||||
|
virtual bool removeItem(DiagramItem *item);
|
||||||
|
|
||||||
public: // ** derived from DiagramItemGroup
|
public: // derived from DiagramItem
|
||||||
|
|
||||||
// extends the DiagramItemGroup implementation by setting
|
// returns the Boxes frame rectangle
|
||||||
// the items owner and calling the attachedToDiagram() hook
|
BRect frame() const { return m_frame; }
|
||||||
// on it
|
|
||||||
virtual bool addItem(
|
|
||||||
DiagramItem *item);
|
|
||||||
|
|
||||||
// extends the DiagramItemGroup implementation by calling
|
// prepares the drawing stack and clipping region, then
|
||||||
// the detachedToDiagram() hook on the item
|
// calls drawBox
|
||||||
virtual bool removeItem(
|
void draw(BRect updateRect);
|
||||||
DiagramItem *item);
|
|
||||||
|
|
||||||
public: // *** derived from DiagramItem
|
// is called from the parent DiagramViews MouseDown() implementation
|
||||||
|
// if the Box was hit; this version initiates selection and dragging
|
||||||
|
virtual void mouseDown(BPoint point, uint32 buttons, uint32 clicks);
|
||||||
|
|
||||||
// returns the Boxes frame rectangle
|
// is called from the DiagramViews MouseMoved() when no message is being
|
||||||
BRect frame() const
|
// dragged, but the mouse has moved above the box
|
||||||
{ return m_frame; }
|
virtual void mouseOver(BPoint point, uint32 transit);
|
||||||
|
|
||||||
// prepares the drawing stack and clipping region, then
|
// is called from the DiagramViews MouseMoved() when a message is being
|
||||||
// calls drawBox
|
// dragged over the DiagramBox
|
||||||
void draw(
|
virtual void messageDragged(BPoint point, uint32 transit, const BMessage *message);
|
||||||
BRect updateRect);
|
|
||||||
|
|
||||||
// is called from the parent DiagramViews MouseDown() implementation
|
// is called from the DiagramViews MessageReceived() function when a
|
||||||
// if the Box was hit; this version initiates selection and dragging
|
// message has been dropped on the DiagramBox
|
||||||
virtual void mouseDown(
|
virtual void messageDropped(BPoint point, BMessage *message);
|
||||||
BPoint point,
|
|
||||||
uint32 buttons,
|
|
||||||
uint32 clicks);
|
|
||||||
|
|
||||||
// is called from the DiagramViews MouseMoved() when no message is being
|
public: // operations
|
||||||
// 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
|
// moves the box by a given amount, and returns in updateRegion the
|
||||||
// dragged over the DiagramBox
|
// frames of wires impacted by the move
|
||||||
virtual void messageDragged(
|
void moveBy(float x, float y, BRegion *updateRegion);
|
||||||
BPoint point,
|
|
||||||
uint32 transit,
|
|
||||||
const BMessage *message);
|
|
||||||
|
|
||||||
// is called from the DiagramViews MessageReceived() function when a
|
// resizes the boxes frame without doing any updating
|
||||||
// message has been dropped on the DiagramBox
|
virtual void resizeBy(float horizontal, float vertical);
|
||||||
virtual void messageDropped(
|
|
||||||
BPoint point,
|
|
||||||
BMessage *message);
|
|
||||||
|
|
||||||
public: // *** operations
|
private:// internal methods
|
||||||
|
|
||||||
// moves the box by a given amount, and returns in updateRegion the
|
// is called by the DiagramView when added
|
||||||
// frames of wires impacted by the move
|
void _setOwner(DiagramView *owner);
|
||||||
void moveBy(
|
|
||||||
float x,
|
|
||||||
float y,
|
|
||||||
BRegion *updateRegion);
|
|
||||||
|
|
||||||
// resizes the boxes frame without doing any updating
|
private:
|
||||||
virtual void resizeBy(
|
|
||||||
float horizontal,
|
|
||||||
float vertical);
|
|
||||||
|
|
||||||
private: // *** internal methods
|
|
||||||
|
|
||||||
// is called by the DiagramView when added
|
|
||||||
void _setOwner(
|
|
||||||
DiagramView *owner);
|
|
||||||
|
|
||||||
private: // *** data
|
|
||||||
|
|
||||||
// the boxes' frame rectangle
|
// the boxes' frame rectangle
|
||||||
BRect m_frame;
|
BRect m_frame;
|
||||||
|
|
||||||
// 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 m_flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
__END_CORTEX_NAMESPACE
|
__END_CORTEX_NAMESPACE
|
||||||
#endif /* __DiagramBox_H__ */
|
#endif // DIAGRAM_BOX_H
|
||||||
|
|||||||
@@ -7,9 +7,8 @@
|
|||||||
// * HISTORY
|
// * HISTORY
|
||||||
// c.lenz 25sep99 Begun
|
// c.lenz 25sep99 Begun
|
||||||
//
|
//
|
||||||
|
#ifndef DIAGRAM_DEFS_H
|
||||||
#ifndef __DiagramDefs_H__
|
#define DIAGRAM_DEFS_H
|
||||||
#define __DiagramDefs_H__
|
|
||||||
|
|
||||||
#include "cortex_defs.h"
|
#include "cortex_defs.h"
|
||||||
__BEGIN_CORTEX_NAMESPACE
|
__BEGIN_CORTEX_NAMESPACE
|
||||||
@@ -43,4 +42,4 @@ enum message_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
__END_CORTEX_NAMESPACE
|
__END_CORTEX_NAMESPACE
|
||||||
#endif /* __DiagramDefs_H__ */
|
#endif // DIAGRAM_DEFS_H
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// NumericValControl.cpp
|
// NumericValControl.cpp
|
||||||
// e.moon 30jan99
|
// e.moon 30jan99
|
||||||
|
|
||||||
|
|
||||||
#include "NumericValControl.h"
|
#include "NumericValControl.h"
|
||||||
#include "ValControlDigitSegment.h"
|
#include "ValControlDigitSegment.h"
|
||||||
#include "ValCtrlLayoutEntry.h"
|
#include "ValCtrlLayoutEntry.h"
|
||||||
@@ -15,30 +16,18 @@
|
|||||||
|
|
||||||
__USE_CORTEX_NAMESPACE
|
__USE_CORTEX_NAMESPACE
|
||||||
|
|
||||||
// ---------------------------------------------------------------- //
|
|
||||||
// ctor/dtor/accessors
|
|
||||||
// ---------------------------------------------------------------- //
|
|
||||||
|
|
||||||
// parameter-linked ctor
|
NumericValControl::NumericValControl(BRect frame, const char* name, BContinuousParameter* param,
|
||||||
NumericValControl::NumericValControl(
|
uint16 wholeDigits, uint16 fractionalDigits, align_mode alignMode, align_flags alignFlags)
|
||||||
BRect frame,
|
: ValControl(frame, name, 0, 0, alignMode, alignFlags, UPDATE_ASYNC, false),
|
||||||
const char* name,
|
fParam(param),
|
||||||
BContinuousParameter* param,
|
fWholeDigits(wholeDigits),
|
||||||
uint16 wholeDigits,
|
fFractionalDigits(fractionalDigits)
|
||||||
uint16 fractionalDigits,
|
{
|
||||||
align_mode alignMode,
|
|
||||||
align_flags alignFlags) :
|
|
||||||
|
|
||||||
ValControl(frame, name, 0, 0, alignMode, alignFlags, UPDATE_ASYNC, false),
|
|
||||||
m_param(param),
|
|
||||||
m_wholeDigits(wholeDigits),
|
|
||||||
m_fractionalDigits(fractionalDigits) {
|
|
||||||
|
|
||||||
// ensure that the parameter represents a continuous value
|
// ensure that the parameter represents a continuous value
|
||||||
ASSERT(
|
ASSERT(fParam->ValueType() == B_FLOAT_TYPE ||
|
||||||
m_param->ValueType() == B_FLOAT_TYPE ||
|
fParam->ValueType() == B_DOUBLE_TYPE
|
||||||
m_param->ValueType() == B_DOUBLE_TYPE
|
|
||||||
|
|
||||||
/*|| unimplemented so far
|
/*|| unimplemented so far
|
||||||
m_pParam->ValueType() == B_INT8_TYPE ||
|
m_pParam->ValueType() == B_INT8_TYPE ||
|
||||||
m_pParam->ValueType() == B_UINT8_TYPE ||
|
m_pParam->ValueType() == B_UINT8_TYPE ||
|
||||||
@@ -54,82 +43,83 @@ NumericValControl::NumericValControl(
|
|||||||
mediaParameterChanged();
|
mediaParameterChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
NumericValControl::NumericValControl(
|
|
||||||
BRect frame,
|
|
||||||
const char* name,
|
|
||||||
BMessage* message,
|
|
||||||
uint16 wholeDigits,
|
|
||||||
uint16 fractionalDigits,
|
|
||||||
bool negativeVisible,
|
|
||||||
align_mode alignMode,
|
|
||||||
align_flags alignFlags) :
|
|
||||||
|
|
||||||
ValControl(frame, name, 0, message, alignMode, alignFlags, UPDATE_ASYNC, false),
|
NumericValControl::NumericValControl(BRect frame, const char* name, BMessage* message,
|
||||||
m_wholeDigits(wholeDigits),
|
uint16 wholeDigits, uint16 fractionalDigits, bool negativeVisible,
|
||||||
m_fractionalDigits(fractionalDigits),
|
align_mode alignMode, align_flags alignFlags)
|
||||||
m_param(0) {
|
: ValControl(frame, name, 0, message, alignMode, alignFlags, UPDATE_ASYNC, false),
|
||||||
|
fParam(0),
|
||||||
setDefaultConstraints(negativeVisible);
|
fWholeDigits(wholeDigits),
|
||||||
|
fFractionalDigits(fractionalDigits)
|
||||||
|
{
|
||||||
|
_SetDefaultConstraints(negativeVisible);
|
||||||
initSegments();
|
initSegments();
|
||||||
}
|
}
|
||||||
|
|
||||||
NumericValControl::~NumericValControl() {}
|
|
||||||
|
|
||||||
BContinuousParameter* NumericValControl::param() const {
|
NumericValControl::~NumericValControl()
|
||||||
return m_param;
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void NumericValControl::initSegments() {
|
|
||||||
// sanity check
|
|
||||||
ASSERT(m_wholeDigits);
|
|
||||||
|
|
||||||
bool negativeVisible = m_minFixed < 0.0;
|
BContinuousParameter*
|
||||||
|
NumericValControl::param() const
|
||||||
|
{
|
||||||
|
return fParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
NumericValControl::initSegments()
|
||||||
|
{
|
||||||
|
ASSERT(fWholeDigits);
|
||||||
|
|
||||||
|
bool negativeVisible = fMinFixed < 0.0;
|
||||||
|
|
||||||
// *** SEGMENT DIVISION NEEDS TO BE CONFIGURABLE +++++
|
// *** SEGMENT DIVISION NEEDS TO BE CONFIGURABLE +++++
|
||||||
// GOOD 23aug99
|
// GOOD 23aug99
|
||||||
// init segments:
|
// init segments:
|
||||||
add(
|
add(new ValControlDigitSegment(fWholeDigits, 0, negativeVisible), RIGHT_MOST);
|
||||||
new ValControlDigitSegment(m_wholeDigits, 0, negativeVisible),
|
|
||||||
RIGHT_MOST);
|
|
||||||
|
|
||||||
if(m_fractionalDigits)
|
if(fFractionalDigits)
|
||||||
add(ValCtrlLayoutEntry::decimalPoint, RIGHT_MOST);
|
add(ValCtrlLayoutEntry::decimalPoint, RIGHT_MOST);
|
||||||
|
|
||||||
for(int n = 0; n < m_fractionalDigits; ++n)
|
for (int n = 0; n < fFractionalDigits; ++n)
|
||||||
add(
|
add(new ValControlDigitSegment(1, (-1)-n, false, ValControlDigitSegment::ZERO_FILL),
|
||||||
new ValControlDigitSegment(1, (-1)-n, false, ValControlDigitSegment::ZERO_FILL),
|
|
||||||
RIGHT_MOST);
|
RIGHT_MOST);
|
||||||
// add(new ValControlDigitSegment(m_fractionalDigits, -m_fractionalDigits,
|
// add(new ValControlDigitSegment(fFractionalDigits, -fFractionalDigits,
|
||||||
// false, ValControlDigitSegment::ZERO_FILL),
|
// false, ValControlDigitSegment::ZERO_FILL),
|
||||||
// RIGHT_MOST);
|
// RIGHT_MOST);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// // +++++ individual-segment test
|
// // +++++ individual-segment test
|
||||||
//
|
//
|
||||||
// for(int n = 0; n < m_wholeDigits; ++n)
|
// for(int n = 0; n < fWholeDigits; ++n)
|
||||||
// add(
|
// add(
|
||||||
// new ValControlDigitSegment(1, m_wholeDigits-n, bNegativeCapable),
|
// new ValControlDigitSegment(1, fWholeDigits-n, bNegativeCapable),
|
||||||
// RIGHT_MOST);
|
// RIGHT_MOST);
|
||||||
//
|
//
|
||||||
// if(m_fractionalDigits)
|
// if(fFractionalDigits)
|
||||||
// add(ValCtrlLayoutEntry::decimalPoint, RIGHT_MOST);
|
// add(ValCtrlLayoutEntry::decimalPoint, RIGHT_MOST);
|
||||||
//
|
//
|
||||||
// for(int n = 0; n < m_fractionalDigits; ++n)
|
// for(int n = 0; n < fFractionalDigits; ++n)
|
||||||
// add(
|
// add(
|
||||||
// new ValControlDigitSegment(1, (-1)-n, false, ValControlDigitSegment::ZERO_FILL),
|
// new ValControlDigitSegment(1, (-1)-n, false, ValControlDigitSegment::ZERO_FILL),
|
||||||
// RIGHT_MOST);
|
// RIGHT_MOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NumericValControl::initConstraintsFromParam() {
|
|
||||||
// +++++
|
void
|
||||||
ASSERT(m_param);
|
NumericValControl::initConstraintsFromParam()
|
||||||
|
{
|
||||||
|
ASSERT(fParam);
|
||||||
|
|
||||||
printf("NumericValControl::initConstraintsFromParam():\n ");
|
printf("NumericValControl::initConstraintsFromParam():\n ");
|
||||||
int r;
|
int r;
|
||||||
float fFactor;
|
float fFactor;
|
||||||
float fOffset;
|
float fOffset;
|
||||||
m_param->GetResponse(&r, &fFactor, &fOffset);
|
fParam->GetResponse(&r, &fFactor, &fOffset);
|
||||||
switch(r) {
|
switch (r) {
|
||||||
case BContinuousParameter::B_LINEAR:
|
case BContinuousParameter::B_LINEAR:
|
||||||
printf("Linear");
|
printf("Linear");
|
||||||
break;
|
break;
|
||||||
@@ -149,57 +139,57 @@ void NumericValControl::initConstraintsFromParam() {
|
|||||||
default:
|
default:
|
||||||
printf("unknown (?)");
|
printf("unknown (?)");
|
||||||
}
|
}
|
||||||
printf(" response; factor %.2f, offset %.2f\n",
|
printf(" response; factor %.2f, offset %.2f\n", fFactor, fOffset);
|
||||||
fFactor, fOffset);
|
|
||||||
|
|
||||||
setConstraints(
|
setConstraints(fParam->MinValue(), fParam->MaxValue());
|
||||||
m_param->MinValue(),
|
|
||||||
m_param->MaxValue());
|
|
||||||
|
|
||||||
// step not yet supported +++++ 19sep99
|
// step not yet supported +++++ 19sep99
|
||||||
//
|
//
|
||||||
float fStep = m_param->ValueStep();
|
float fStep = fParam->ValueStep();
|
||||||
|
|
||||||
printf(" min value: %f\n", m_param->MinValue());
|
printf(" min value: %f\n", fParam->MinValue());
|
||||||
printf(" max value: %f\n", m_param->MaxValue());
|
printf(" max value: %f\n", fParam->MaxValue());
|
||||||
printf(" value step: %f\n\n", fStep);
|
printf(" value step: %f\n\n", fStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
// value constraints (by default, the min/max allowed by the
|
|
||||||
|
//! Value constraints (by default, the min/max allowed by the
|
||||||
// setting of nWholeDigits, nFractionalDigits, and bNegativeCapable)
|
// setting of nWholeDigits, nFractionalDigits, and bNegativeCapable)
|
||||||
void NumericValControl::getConstraints(
|
void
|
||||||
double* outMinValue,
|
NumericValControl::getConstraints(double* outMinValue, double* outMaxValue)
|
||||||
double* outMaxValue) {
|
{
|
||||||
|
double factor = pow(10, -fFractionalDigits);
|
||||||
|
|
||||||
double factor = pow(10, -m_fractionalDigits);
|
*outMinValue = (double)fMinFixed * factor;
|
||||||
|
*outMaxValue = (double)fMaxFixed * factor;
|
||||||
*outMinValue = (double)m_minFixed * factor;
|
|
||||||
*outMaxValue = (double)m_maxFixed * factor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t NumericValControl::setConstraints(
|
|
||||||
double minValue,
|
|
||||||
double maxValue) {
|
|
||||||
|
|
||||||
if(maxValue < minValue)
|
status_t
|
||||||
|
NumericValControl::setConstraints(double minValue, double maxValue)
|
||||||
|
{
|
||||||
|
if (maxValue < minValue)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
double factor = pow(10, m_fractionalDigits);
|
double factor = pow(10, fFractionalDigits);
|
||||||
|
|
||||||
m_minFixed = (minValue < 0.0) ?
|
fMinFixed = (minValue < 0.0) ?
|
||||||
(int64)floor(minValue * factor) :
|
(int64)floor(minValue * factor) :
|
||||||
(int64)ceil(minValue * factor);
|
(int64)ceil(minValue * factor);
|
||||||
|
|
||||||
m_maxFixed = (maxValue < 0.0) ?
|
fMaxFixed = (maxValue < 0.0) ?
|
||||||
(int64)floor(maxValue * factor) :
|
(int64)floor(maxValue * factor) :
|
||||||
(int64)ceil(maxValue * factor);
|
(int64)ceil(maxValue * factor);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetches the current value (calculated on the spot from each
|
|
||||||
|
//! Fetches the current value (calculated on the spot from each
|
||||||
// segment.)
|
// segment.)
|
||||||
double NumericValControl::value() const {
|
double
|
||||||
|
NumericValControl::value() const
|
||||||
|
{
|
||||||
// double acc = 0.0;
|
// double acc = 0.0;
|
||||||
//
|
//
|
||||||
// // walk segments, adding the value of each
|
// // walk segments, adding the value of each
|
||||||
@@ -229,7 +219,7 @@ double NumericValControl::value() const {
|
|||||||
//
|
//
|
||||||
// return acc;
|
// return acc;
|
||||||
|
|
||||||
double ret = (double)_value_fixed() / pow(10, m_fractionalDigits);
|
double ret = (double)_ValueFixed() / pow(10, fFractionalDigits);
|
||||||
|
|
||||||
// PRINT((
|
// PRINT((
|
||||||
// "### NumericValControl::value(): %.12f\n", ret));
|
// "### NumericValControl::value(): %.12f\n", ret));
|
||||||
@@ -237,17 +227,18 @@ double NumericValControl::value() const {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the displayed value (and, if setParam is true, the
|
|
||||||
|
//! Set the displayed value (and, if setParam is true, the
|
||||||
// linked parameter.) The value will be constrained if necessary.
|
// linked parameter.) The value will be constrained if necessary.
|
||||||
void NumericValControl::setValue(
|
void
|
||||||
double value,
|
NumericValControl::setValue(double value, bool setParam)
|
||||||
bool setParam) {
|
{
|
||||||
|
|
||||||
// PRINT((
|
// PRINT((
|
||||||
// "### NumericValControl::setValue(%.12f)\n", value));
|
// "### NumericValControl::setValue(%.12f)\n", value));
|
||||||
|
|
||||||
// round to displayed precision
|
// round to displayed precision
|
||||||
double scaleFactor = pow(10, m_fractionalDigits);
|
double scaleFactor = pow(10, fFractionalDigits);
|
||||||
|
|
||||||
int64 fixed = (int64)(value * scaleFactor);
|
int64 fixed = (int64)(value * scaleFactor);
|
||||||
double junk = (value * scaleFactor) - (double)fixed;
|
double junk = (value * scaleFactor) - (double)fixed;
|
||||||
@@ -255,11 +246,11 @@ void NumericValControl::setValue(
|
|||||||
// PRINT((
|
// PRINT((
|
||||||
// " : junk == %.12f\n", junk));
|
// " : junk == %.12f\n", junk));
|
||||||
|
|
||||||
if(value < 0.0) {
|
if (value < 0.0) {
|
||||||
if(junk * scaleFactor < 0.5)
|
if (junk * scaleFactor < 0.5)
|
||||||
fixed--;
|
fixed--;
|
||||||
} else {
|
} else {
|
||||||
if(junk * scaleFactor >= 0.5)
|
if (junk * scaleFactor >= 0.5)
|
||||||
fixed++;
|
fixed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,13 +259,13 @@ void NumericValControl::setValue(
|
|||||||
// PRINT((
|
// PRINT((
|
||||||
// " -> %.12f, %Ld\n", value, fixed));
|
// " -> %.12f, %Ld\n", value, fixed));
|
||||||
|
|
||||||
_set_value_fixed(fixed);
|
_SetValueFixed(fixed);
|
||||||
|
|
||||||
// notify target
|
// notify target
|
||||||
Invoke();
|
Invoke();
|
||||||
|
|
||||||
// set parameter
|
// set parameter
|
||||||
if(setParam && m_param)
|
if (setParam && fParam)
|
||||||
updateParameter(value);
|
updateParameter(value);
|
||||||
|
|
||||||
// +++++ redraw?
|
// +++++ redraw?
|
||||||
@@ -315,7 +306,7 @@ void NumericValControl::setValue(
|
|||||||
// m_dfValue = dfValue;
|
// m_dfValue = dfValue;
|
||||||
//
|
//
|
||||||
// // set parameter
|
// // set parameter
|
||||||
// if(bSetParam && m_param)
|
// if(bSetParam && fParam)
|
||||||
// updateParameter();
|
// updateParameter();
|
||||||
//
|
//
|
||||||
// // notify target (ugh. what if the target called this? +++++)
|
// // notify target (ugh. what if the target called this? +++++)
|
||||||
@@ -345,19 +336,18 @@ void NumericValControl::setValue(
|
|||||||
// 18sep99: new segment interface. 'offset' is given
|
// 18sep99: new segment interface. 'offset' is given
|
||||||
// in the segment's units.
|
// in the segment's units.
|
||||||
|
|
||||||
void NumericValControl::offsetSegmentValue(
|
void
|
||||||
ValControlDigitSegment* segment,
|
NumericValControl::offsetSegmentValue(ValControlDigitSegment* segment,
|
||||||
int64 offset) {
|
int64 offset)
|
||||||
|
{
|
||||||
|
|
||||||
// PRINT((
|
// PRINT((
|
||||||
// "### offsetSegmentValue(): %Ld\n",
|
// "### offsetSegmentValue(): %Ld\n",
|
||||||
// offset));
|
// offset));
|
||||||
|
|
||||||
int64 segmentFactor = (int64)pow(
|
int64 segmentFactor = (int64)pow(10, fFractionalDigits + segment->scaleFactor());
|
||||||
10,
|
|
||||||
m_fractionalDigits + segment->scaleFactor());
|
|
||||||
|
|
||||||
int64 value = _value_fixed();
|
int64 value = _ValueFixed();
|
||||||
|
|
||||||
// cut values below domain of the changed segment
|
// cut values below domain of the changed segment
|
||||||
value /= segmentFactor;
|
value /= segmentFactor;
|
||||||
@@ -368,44 +358,43 @@ void NumericValControl::offsetSegmentValue(
|
|||||||
// restore
|
// restore
|
||||||
value *= segmentFactor;
|
value *= segmentFactor;
|
||||||
|
|
||||||
_set_value_fixed(value);
|
_SetValueFixed(value);
|
||||||
|
|
||||||
// notify target
|
// notify target
|
||||||
Invoke();
|
Invoke();
|
||||||
|
|
||||||
if(m_param)
|
if (fParam)
|
||||||
updateParameter(
|
updateParameter((double)value * (double)segmentFactor);
|
||||||
(double)value * (double)segmentFactor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------- //
|
|
||||||
// hook implementations
|
|
||||||
// ---------------------------------------------------------------- //
|
|
||||||
|
|
||||||
void NumericValControl::mediaParameterChanged() {
|
|
||||||
|
|
||||||
|
void
|
||||||
|
NumericValControl::mediaParameterChanged()
|
||||||
|
{
|
||||||
// fetch value
|
// fetch value
|
||||||
size_t nSize;
|
size_t nSize;
|
||||||
bigtime_t tLastChanged;
|
bigtime_t tLastChanged;
|
||||||
status_t err;
|
status_t err;
|
||||||
switch(m_param->ValueType()) {
|
switch (fParam->ValueType()) {
|
||||||
case B_FLOAT_TYPE: { // +++++ left-channel hack
|
case B_FLOAT_TYPE:
|
||||||
|
{ // +++++ left-channel hack
|
||||||
float fParamValue[4];
|
float fParamValue[4];
|
||||||
nSize = sizeof(float)*4;
|
nSize = sizeof(float) * 4;
|
||||||
// +++++ broken
|
// +++++ broken
|
||||||
err = m_param->GetValue((void*)&fParamValue, &nSize, &tLastChanged);
|
err = fParam->GetValue((void*)&fParamValue, &nSize, &tLastChanged);
|
||||||
// if(err != B_OK)
|
// if (err != B_OK)
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
setValue(fParamValue[0]);
|
setValue(fParamValue[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_DOUBLE_TYPE: {
|
case B_DOUBLE_TYPE:
|
||||||
|
{
|
||||||
double fParamValue;
|
double fParamValue;
|
||||||
nSize = sizeof(double);
|
nSize = sizeof(double);
|
||||||
err = m_param->GetValue((void*)&fParamValue, &nSize, &tLastChanged);
|
err = fParam->GetValue((void*)&fParamValue, &nSize, &tLastChanged);
|
||||||
if(err != B_OK)
|
if (err != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
setValue(fParamValue);
|
setValue(fParamValue);
|
||||||
@@ -414,10 +403,11 @@ void NumericValControl::mediaParameterChanged() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NumericValControl::updateParameter(
|
|
||||||
double value) {
|
|
||||||
|
|
||||||
ASSERT(m_param);
|
void
|
||||||
|
NumericValControl::updateParameter(double value)
|
||||||
|
{
|
||||||
|
ASSERT(fParam);
|
||||||
|
|
||||||
// // is this kosher? +++++
|
// // is this kosher? +++++
|
||||||
// // ++++++ 18sep99: no.
|
// // ++++++ 18sep99: no.
|
||||||
@@ -425,52 +415,53 @@ void NumericValControl::updateParameter(
|
|||||||
|
|
||||||
// store value
|
// store value
|
||||||
status_t err;
|
status_t err;
|
||||||
switch(m_param->ValueType()) {
|
switch (fParam->ValueType()) {
|
||||||
case B_FLOAT_TYPE: { // +++++ left-channel hack
|
case B_FLOAT_TYPE:
|
||||||
|
{ // +++++ left-channel hack
|
||||||
float fValue[2];
|
float fValue[2];
|
||||||
fValue[0] = value;
|
fValue[0] = value;
|
||||||
fValue[1] = value;
|
fValue[1] = value;
|
||||||
err = m_param->SetValue((void*)&fValue, sizeof(float)*2, 0LL);
|
err = fParam->SetValue((void*)&fValue, sizeof(float)*2, 0LL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_DOUBLE_TYPE: {
|
case B_DOUBLE_TYPE: {
|
||||||
double fValue = value;
|
double fValue = value;
|
||||||
err = m_param->SetValue((void*)&fValue, sizeof(double), 0LL);
|
err = fParam->SetValue((void*)&fValue, sizeof(double), 0LL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------- //
|
void
|
||||||
// ValControl impl.
|
NumericValControl::setValue(const void* data, size_t size)
|
||||||
// ---------------------------------------------------------------- //
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void NumericValControl::setValue(
|
|
||||||
const void* data,
|
|
||||||
size_t size) {} //nyi +++++
|
|
||||||
|
|
||||||
void NumericValControl::getValue(
|
void
|
||||||
void* data,
|
NumericValControl::getValue(void* data, size_t* ioSize)
|
||||||
size_t* ioSize) {} //nyi +++++
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// * string value access
|
|
||||||
|
|
||||||
status_t NumericValControl::setValueFrom(
|
status_t
|
||||||
const char* text) {
|
NumericValControl::setValueFrom(const char* text)
|
||||||
|
{
|
||||||
double d = atof(text);
|
double d = atof(text);
|
||||||
setValue(d, true);
|
setValue(d, true);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t NumericValControl::getString(
|
|
||||||
BString& buffer) {
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
NumericValControl::getString(BString& buffer)
|
||||||
|
{
|
||||||
// should provide the same # of digits as the control! +++++
|
// should provide the same # of digits as the control! +++++
|
||||||
BString format = "%.";
|
BString format = "%.";
|
||||||
format << (int32)m_fractionalDigits << 'f';
|
format << (int32)fFractionalDigits << 'f';
|
||||||
char cbuf[120];
|
char cbuf[120];
|
||||||
sprintf(cbuf, format.String(), value());
|
sprintf(cbuf, format.String(), value());
|
||||||
buffer = cbuf;
|
buffer = cbuf;
|
||||||
@@ -479,19 +470,16 @@ status_t NumericValControl::getString(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------- //
|
void
|
||||||
// BHandler impl.
|
NumericValControl::MessageReceived(BMessage* pMsg)
|
||||||
// ---------------------------------------------------------------- //
|
{
|
||||||
|
|
||||||
void NumericValControl::MessageReceived(BMessage* pMsg) {
|
|
||||||
status_t err;
|
status_t err;
|
||||||
double dfValue;
|
double dfValue;
|
||||||
|
|
||||||
|
switch (pMsg->what) {
|
||||||
switch(pMsg->what) {
|
|
||||||
case M_SET_VALUE:
|
case M_SET_VALUE:
|
||||||
err = pMsg->FindDouble("value", &dfValue);
|
err = pMsg->FindDouble("value", &dfValue);
|
||||||
if(err < B_OK) {
|
if (err < B_OK) {
|
||||||
_inherited::MessageReceived(pMsg);
|
_inherited::MessageReceived(pMsg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -499,12 +487,13 @@ void NumericValControl::MessageReceived(BMessage* pMsg) {
|
|||||||
setValue(dfValue);
|
setValue(dfValue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_MEDIA_PARAMETER_CHANGED: {
|
case B_MEDIA_PARAMETER_CHANGED:
|
||||||
|
{
|
||||||
int32 id;
|
int32 id;
|
||||||
if(pMsg->FindInt32("be:parameter", &id) != B_OK)
|
if (pMsg->FindInt32("be:parameter", &id) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ASSERT(id == m_param->ID());
|
ASSERT(id == fParam->ID());
|
||||||
mediaParameterChanged();
|
mediaParameterChanged();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -515,38 +504,32 @@ void NumericValControl::MessageReceived(BMessage* pMsg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------- //
|
|
||||||
// internal operations
|
|
||||||
// ---------------------------------------------------------------- //
|
|
||||||
|
|
||||||
void NumericValControl::setDefaultConstraints(
|
void
|
||||||
bool negativeVisible) {
|
NumericValControl::_SetDefaultConstraints(bool negativeVisible)
|
||||||
|
{
|
||||||
double max = pow(10, m_wholeDigits) - pow(10, -m_fractionalDigits);
|
double max = pow(10, fWholeDigits) - pow(10, -fFractionalDigits);
|
||||||
double min = (negativeVisible) ? -max : 0.0;
|
double min = (negativeVisible) ? -max : 0.0;
|
||||||
|
|
||||||
setConstraints(min, max);
|
setConstraints(min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------- //
|
|
||||||
// guts
|
|
||||||
// ---------------------------------------------------------------- //
|
|
||||||
|
|
||||||
// calculates the current value as an int64
|
//! calculates the current value as an int64
|
||||||
|
int64
|
||||||
int64 NumericValControl::_value_fixed() const {
|
NumericValControl::_ValueFixed() const {
|
||||||
|
|
||||||
// PRINT((
|
// PRINT((
|
||||||
// "### NumericValControl::_value_fixed()\n", value));
|
// "### NumericValControl::_ValueFixed()\n", value));
|
||||||
|
|
||||||
int64 acc = 0LL;
|
int64 acc = 0LL;
|
||||||
|
|
||||||
int64 scaleBase = m_fractionalDigits;
|
int64 scaleBase = fFractionalDigits;
|
||||||
|
|
||||||
// walk segments, adding the value of each
|
// walk segments, adding the value of each
|
||||||
for(int n = countEntries(); n > 0; --n) {
|
for (int n = countEntries(); n > 0; --n) {
|
||||||
const ValCtrlLayoutEntry& e = entryAt(n-1);
|
const ValCtrlLayoutEntry& e = entryAt(n-1);
|
||||||
if(e.type == ValCtrlLayoutEntry::SEGMENT_ENTRY) {
|
if (e.type == ValCtrlLayoutEntry::SEGMENT_ENTRY) {
|
||||||
const ValControlDigitSegment* digitSegment =
|
const ValControlDigitSegment* digitSegment =
|
||||||
dynamic_cast<ValControlDigitSegment*>(e.pView);
|
dynamic_cast<ValControlDigitSegment*>(e.pView);
|
||||||
ASSERT(digitSegment);
|
ASSERT(digitSegment);
|
||||||
@@ -558,10 +541,8 @@ int64 NumericValControl::_value_fixed() const {
|
|||||||
// digitSegment->scaleFactor(),
|
// digitSegment->scaleFactor(),
|
||||||
// digitSegment->value()));
|
// digitSegment->value()));
|
||||||
//
|
//
|
||||||
acc += digitSegment->value() *
|
acc += digitSegment->value() * (int64)pow(10,
|
||||||
(int64)pow(
|
scaleBase + digitSegment->scaleFactor());
|
||||||
10,
|
|
||||||
scaleBase + digitSegment->scaleFactor());
|
|
||||||
//
|
//
|
||||||
// PRINT((
|
// PRINT((
|
||||||
// "\t-> %Ld\n\n", acc));
|
// "\t-> %Ld\n\n", acc));
|
||||||
@@ -571,26 +552,30 @@ int64 NumericValControl::_value_fixed() const {
|
|||||||
return acc;
|
return acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sets the value of each segment based on an int64 value;
|
|
||||||
// does not constrain the value
|
|
||||||
void NumericValControl::_set_value_fixed(
|
|
||||||
int64 fixed) {
|
|
||||||
|
|
||||||
|
//! sets the value of each segment based on an int64 value;
|
||||||
|
// does not constrain the value
|
||||||
|
void
|
||||||
|
NumericValControl::_SetValueFixed(int64 fixed)
|
||||||
|
{
|
||||||
// PRINT((
|
// PRINT((
|
||||||
// "### NumericValControl::_set_value_fixed(%Ld)\n", fixed));
|
// "### NumericValControl::_SetValueFixed(%Ld)\n", fixed));
|
||||||
|
|
||||||
// constrain
|
// constrain
|
||||||
if(fixed > m_maxFixed) fixed = m_maxFixed;
|
if (fixed > fMaxFixed)
|
||||||
if(fixed < m_minFixed) fixed = m_minFixed;
|
fixed = fMaxFixed;
|
||||||
|
|
||||||
int64 scaleBase = m_fractionalDigits;
|
if (fixed < fMinFixed)
|
||||||
|
fixed = fMinFixed;
|
||||||
|
|
||||||
|
int64 scaleBase = fFractionalDigits;
|
||||||
|
|
||||||
// set segments
|
// set segments
|
||||||
for(int n = countEntries(); n > 0; --n) {
|
for (int n = countEntries(); n > 0; --n) {
|
||||||
|
|
||||||
const ValCtrlLayoutEntry& e = entryAt(n-1);
|
const ValCtrlLayoutEntry& e = entryAt(n-1);
|
||||||
|
|
||||||
if(e.type == ValCtrlLayoutEntry::SEGMENT_ENTRY) {
|
if (e.type == ValCtrlLayoutEntry::SEGMENT_ENTRY) {
|
||||||
ValControlDigitSegment* digitSegment =
|
ValControlDigitSegment* digitSegment =
|
||||||
dynamic_cast<ValControlDigitSegment*>(e.pView);
|
dynamic_cast<ValControlDigitSegment*>(e.pView);
|
||||||
ASSERT(digitSegment);
|
ASSERT(digitSegment);
|
||||||
@@ -602,27 +587,20 @@ void NumericValControl::_set_value_fixed(
|
|||||||
// digitSegment->scaleFactor()));
|
// digitSegment->scaleFactor()));
|
||||||
|
|
||||||
// subtract higher-magnitude segments' value
|
// subtract higher-magnitude segments' value
|
||||||
int64 hiCut = fixed %
|
int64 hiCut = fixed % (int64)pow(10,
|
||||||
(int64)pow(
|
scaleBase + digitSegment->scaleFactor() + digitSegment->digitCount());
|
||||||
10,
|
|
||||||
scaleBase + digitSegment->scaleFactor() + digitSegment->digitCount());
|
|
||||||
|
|
||||||
// PRINT((
|
// PRINT((
|
||||||
// "\t [] %Ld\n", hiCut));
|
// "\t [] %Ld\n", hiCut));
|
||||||
|
|
||||||
// shift value
|
// shift value
|
||||||
int64 segmentValue = hiCut /
|
int64 segmentValue = hiCut / (int64)pow(10,
|
||||||
(int64)pow(
|
scaleBase + digitSegment->scaleFactor());
|
||||||
10,
|
|
||||||
scaleBase + digitSegment->scaleFactor());
|
|
||||||
|
|
||||||
// PRINT((
|
// PRINT((
|
||||||
// "\t -> %Ld\n\n", segmentValue));
|
// "\t -> %Ld\n\n", segmentValue));
|
||||||
|
|
||||||
// set
|
|
||||||
digitSegment->setValue(segmentValue, fixed < 0);
|
digitSegment->setValue(segmentValue, fixed < 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// END -- NumericValControl.cpp --
|
|
||||||
|
|||||||
@@ -9,146 +9,117 @@
|
|||||||
// +++++ 31jan99: negatives are still handled wrong...
|
// +++++ 31jan99: negatives are still handled wrong...
|
||||||
//
|
//
|
||||||
// CLASS: NumericValControl
|
// CLASS: NumericValControl
|
||||||
|
#ifndef NUMERIC_VAL_CONTROL_H
|
||||||
#ifndef __NumericValControl_H__
|
#define NUMERIC_VAL_CONTROL_H
|
||||||
#define __NumericValControl_H__
|
|
||||||
|
|
||||||
#include "ValControl.h"
|
|
||||||
|
|
||||||
class BContinuousParameter;
|
|
||||||
#include <MediaDefs.h>
|
|
||||||
|
|
||||||
#include "cortex_defs.h"
|
#include "cortex_defs.h"
|
||||||
|
#include "ValControl.h"
|
||||||
|
|
||||||
|
#include <MediaDefs.h>
|
||||||
|
|
||||||
|
|
||||||
|
class BContinuousParameter;
|
||||||
|
|
||||||
|
|
||||||
__BEGIN_CORTEX_NAMESPACE
|
__BEGIN_CORTEX_NAMESPACE
|
||||||
|
|
||||||
class ValControlDigitSegment;
|
class ValControlDigitSegment;
|
||||||
|
|
||||||
class NumericValControl : /*extends*/ public ValControl {
|
|
||||||
typedef ValControl _inherited;
|
|
||||||
|
|
||||||
public: // ctor/dtor/accessors
|
class NumericValControl : public ValControl {
|
||||||
|
public:
|
||||||
|
typedef ValControl _inherited;
|
||||||
|
|
||||||
// +++++ need control over number of segments +++++
|
public:
|
||||||
|
|
||||||
// parameter-linked ctor
|
// +++++ need control over number of segments +++++
|
||||||
NumericValControl(
|
|
||||||
BRect frame,
|
|
||||||
const char* name,
|
|
||||||
BContinuousParameter* param,
|
|
||||||
uint16 wholeDigits,
|
|
||||||
uint16 fractionalDigits=0,
|
|
||||||
align_mode alignMode=ALIGN_FLUSH_RIGHT,
|
|
||||||
align_flags alignFlags=ALIGN_NONE);
|
|
||||||
|
|
||||||
// 'plain' ctor
|
// parameter-linked ctor
|
||||||
NumericValControl(
|
NumericValControl(BRect frame, const char* name, BContinuousParameter* param,
|
||||||
BRect frame,
|
uint16 wholeDigits, uint16 fractionalDigits = 0, align_mode alignMode = ALIGN_FLUSH_RIGHT,
|
||||||
const char* name,
|
align_flags alignFlags = ALIGN_NONE);
|
||||||
BMessage* message,
|
|
||||||
uint16 wholeDigits,
|
|
||||||
uint16 fractionalDigits=0,
|
|
||||||
bool negativeVisible=true,
|
|
||||||
align_mode alignMode=ALIGN_FLUSH_RIGHT,
|
|
||||||
align_flags alignFlags=ALIGN_NONE);
|
|
||||||
|
|
||||||
~NumericValControl();
|
// 'plain' ctor
|
||||||
|
NumericValControl(BRect frame, const char* name, BMessage* message, uint16 wholeDigits,
|
||||||
|
uint16 fractionalDigits = 0, bool negativeVisible = true,
|
||||||
|
align_mode alignMode = ALIGN_FLUSH_RIGHT, align_flags alignFlags = ALIGN_NONE);
|
||||||
|
|
||||||
// bound parameter, or 0 if none
|
~NumericValControl();
|
||||||
BContinuousParameter* param() const;
|
|
||||||
|
|
||||||
// value constraints (by default, the min/max allowed by the ctor
|
BContinuousParameter* param() const;
|
||||||
// settings: wholeDigits, fractionalDigits, and negativeVisible)
|
// bound parameter, or 0 if none
|
||||||
|
|
||||||
void getConstraints(
|
void getConstraints(double* outMinValue, double* outMaxValue);
|
||||||
double* outMinValue,
|
// value constraints (by default, the min/max allowed by the ctor
|
||||||
double* outMaxValue);
|
// settings: wholeDigits, fractionalDigits, and negativeVisible)
|
||||||
|
|
||||||
// +++++ the current value is not yet re-constrained by this call
|
status_t setConstraints(double minValue, double maxValue);
|
||||||
|
// the current value is not yet re-constrained by this call
|
||||||
|
|
||||||
status_t setConstraints(
|
double value() const;
|
||||||
double minValue,
|
// fetches the current value (calculated on the spot from each
|
||||||
double maxValue);
|
// segment.)
|
||||||
|
|
||||||
// fetches the current value (calculated on the spot from each
|
void setValue(double value, bool setParam = false);
|
||||||
// segment.)
|
// set the displayed value (and, if setParam is true, the
|
||||||
double value() const;
|
// linked parameter.) The value will be constrained if necessary.
|
||||||
|
|
||||||
// set the displayed value (and, if setParam is true, the
|
public: // segment interface
|
||||||
// linked parameter.) The value will be constrained if necessary.
|
// 18sep99: old segment interface
|
||||||
void setValue(
|
// virtual void offsetValue(double dfDelta);
|
||||||
double value,
|
|
||||||
bool setParam=false);
|
|
||||||
|
|
||||||
public: // segment interface
|
// 18sep99: new segment interface. 'offset' is given
|
||||||
// 18sep99: old segment interface
|
// in the segment's units.
|
||||||
// virtual void offsetValue(double dfDelta);
|
|
||||||
|
|
||||||
// 18sep99: new segment interface. 'offset' is given
|
virtual void offsetSegmentValue(ValControlDigitSegment* segment, int64 offset);
|
||||||
// in the segment's units.
|
|
||||||
|
|
||||||
virtual void offsetSegmentValue(
|
public:
|
||||||
ValControlDigitSegment* segment,
|
virtual void mediaParameterChanged();
|
||||||
int64 offset);
|
|
||||||
|
|
||||||
public: // hooks
|
virtual void updateParameter(double value);
|
||||||
virtual void mediaParameterChanged();
|
// writes the stored value to the bound parameter
|
||||||
|
|
||||||
// writes the stored value to the bound parameter
|
virtual void initSegments();
|
||||||
virtual void updateParameter(
|
virtual void initConstraintsFromParam();
|
||||||
double value);
|
|
||||||
|
|
||||||
virtual void initSegments();
|
public: // ValControl impl.
|
||||||
virtual void initConstraintsFromParam();
|
void setValue(const void* data, size_t size); //nyi
|
||||||
|
|
||||||
public: // ValControl impl.
|
void getValue(void* data, size_t* ioSize); //nyi
|
||||||
void setValue(
|
|
||||||
const void* data,
|
|
||||||
size_t size); //nyi
|
|
||||||
|
|
||||||
void getValue(
|
// string value access
|
||||||
void* data,
|
virtual status_t setValueFrom(const char* text);
|
||||||
size_t* ioSize); //nyi
|
virtual status_t getString(BString& buffer);
|
||||||
|
|
||||||
// * string value access
|
public:
|
||||||
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
virtual status_t setValueFrom(
|
protected: // internal operations
|
||||||
const char* text);
|
virtual void _SetDefaultConstraints(bool negativeVisible);
|
||||||
virtual status_t getString(
|
|
||||||
BString& buffer);
|
private:
|
||||||
|
int64 _ValueFixed() const; //nyi
|
||||||
|
// calculates the current value as an int64
|
||||||
|
|
||||||
|
void _SetValueFixed(int64 fixed); //nyi
|
||||||
|
// sets the value of each segment based on an int64 value;
|
||||||
|
// does not constrain the value
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// double m_dfValue; removed 18sep99
|
||||||
|
|
||||||
|
BContinuousParameter* fParam;
|
||||||
|
// bound parameter
|
||||||
|
|
||||||
|
uint16 fWholeDigits;
|
||||||
|
uint16 fFractionalDigits;
|
||||||
|
|
||||||
|
// constraints
|
||||||
|
int64 fMinFixed;
|
||||||
|
int64 fMaxFixed;
|
||||||
|
|
||||||
|
|
||||||
public: // BHandler impl.
|
|
||||||
virtual void MessageReceived(
|
|
||||||
BMessage* message);
|
|
||||||
|
|
||||||
protected: // internal operations
|
|
||||||
virtual void setDefaultConstraints(
|
|
||||||
bool negativeVisible);
|
|
||||||
|
|
||||||
private: // guts
|
|
||||||
|
|
||||||
// calculates the current value as an int64
|
|
||||||
int64 _value_fixed() const; //nyi
|
|
||||||
|
|
||||||
// sets the value of each segment based on an int64 value;
|
|
||||||
// does not constrain the value
|
|
||||||
void _set_value_fixed(
|
|
||||||
int64 fixed); //nyi
|
|
||||||
|
|
||||||
protected: // members
|
|
||||||
|
|
||||||
// double m_dfValue; removed 18sep99
|
|
||||||
|
|
||||||
uint16 m_wholeDigits;
|
|
||||||
uint16 m_fractionalDigits;
|
|
||||||
|
|
||||||
// constraints
|
|
||||||
int64 m_minFixed;
|
|
||||||
int64 m_maxFixed;
|
|
||||||
|
|
||||||
// bound parameter
|
|
||||||
BContinuousParameter* m_param;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
__END_CORTEX_NAMESPACE
|
__END_CORTEX_NAMESPACE
|
||||||
#endif /* __NumericValControl_H__ */
|
#endif /* NUMERIC_VAL_CONTROL_H */
|
||||||
|
|||||||
@@ -10,12 +10,14 @@
|
|||||||
__USE_CORTEX_NAMESPACE
|
__USE_CORTEX_NAMESPACE
|
||||||
|
|
||||||
/*static*/
|
/*static*/
|
||||||
ValCtrlLayoutEntry ValCtrlLayoutEntry::decimalPoint(
|
ValCtrlLayoutEntry ValCtrlLayoutEntry::decimalPoint(DECIMAL_POINT_ENTRY,
|
||||||
DECIMAL_POINT_ENTRY, LAYOUT_NO_PADDING);
|
LAYOUT_NO_PADDING);
|
||||||
|
|
||||||
/*static*/
|
/*static*/
|
||||||
void ValCtrlLayoutEntry::InitChildFrame(ValCtrlLayoutEntry& e) {
|
void
|
||||||
if(e.pView) {
|
ValCtrlLayoutEntry::InitChildFrame(ValCtrlLayoutEntry& e)
|
||||||
|
{
|
||||||
|
if (e.pView) {
|
||||||
// PRINT((
|
// PRINT((
|
||||||
// "### ValCtrlLayoutEntry::InitChildFrame(): (%.1f,%.1f)-(%.1f,%.1f)\n",
|
// "### ValCtrlLayoutEntry::InitChildFrame(): (%.1f,%.1f)-(%.1f,%.1f)\n",
|
||||||
// e.frame.left, e.frame.top, e.frame.right, e.frame.bottom));
|
// e.frame.left, e.frame.top, e.frame.right, e.frame.bottom));
|
||||||
@@ -23,7 +25,3 @@ void ValCtrlLayoutEntry::InitChildFrame(ValCtrlLayoutEntry& e) {
|
|||||||
e.pView->ResizeTo(e.frame.Width(), e.frame.Height());
|
e.pView->ResizeTo(e.frame.Width(), e.frame.Height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// END -- ValCtrlLayoutEntry.cpp --
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,93 +3,96 @@
|
|||||||
// hide this class!
|
// hide this class!
|
||||||
//
|
//
|
||||||
// e.moon 28jan99
|
// e.moon 28jan99
|
||||||
|
#ifndef VAL_CTRL_LAYOUT_ENTRY_H
|
||||||
|
#define VAL_CTRL_LAYOUT_ENTRY_H
|
||||||
|
|
||||||
#ifndef __VALCTRLLAYOUTENTRY_H__
|
|
||||||
#define __VALCTRLLAYOUTENTRY_H__
|
#include "cortex_defs.h"
|
||||||
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
#include "cortex_defs.h"
|
|
||||||
__BEGIN_CORTEX_NAMESPACE
|
__BEGIN_CORTEX_NAMESPACE
|
||||||
|
|
||||||
// a ValCtrlLayoutEntry manages the layout state information for
|
// a ValCtrlLayoutEntry manages the layout state information for
|
||||||
// a single child view
|
// a single child view
|
||||||
|
|
||||||
class ValCtrlLayoutEntry {
|
class ValCtrlLayoutEntry {
|
||||||
friend class ValControl;
|
public:
|
||||||
|
friend class ValControl;
|
||||||
|
|
||||||
public: // static instances
|
public: // static instances
|
||||||
static ValCtrlLayoutEntry decimalPoint;
|
static ValCtrlLayoutEntry decimalPoint;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum entry_type {
|
enum entry_type {
|
||||||
SEGMENT_ENTRY,
|
SEGMENT_ENTRY,
|
||||||
VIEW_ENTRY,
|
VIEW_ENTRY,
|
||||||
DECIMAL_POINT_ENTRY
|
DECIMAL_POINT_ENTRY
|
||||||
};
|
};
|
||||||
|
|
||||||
enum layout_flags {
|
enum layout_flags {
|
||||||
LAYOUT_NONE =0,
|
LAYOUT_NONE = 0,
|
||||||
LAYOUT_NO_PADDING =1, // disables left/right padding
|
LAYOUT_NO_PADDING = 1, // disables left/right padding
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// stl compatibility ctor
|
ValCtrlLayoutEntry() {}
|
||||||
ValCtrlLayoutEntry() {}
|
// stl compatibility ctor
|
||||||
|
|
||||||
// standard: yes, the frame is left invalid; that's for
|
// standard: yes, the frame is left invalid; that's for
|
||||||
// ValControl::insertEntry() to fix
|
// ValControl::insertEntry() to fix
|
||||||
ValCtrlLayoutEntry(BView* _pView, entry_type t,
|
ValCtrlLayoutEntry(BView* _pView, entry_type t,
|
||||||
layout_flags f=LAYOUT_NONE) :
|
layout_flags f = LAYOUT_NONE)
|
||||||
|
:
|
||||||
|
pView(_pView),
|
||||||
|
type(t),
|
||||||
|
flags(f),
|
||||||
|
fPadding(0.0)
|
||||||
|
{}
|
||||||
|
|
||||||
pView(_pView),
|
ValCtrlLayoutEntry(entry_type t, layout_flags f = LAYOUT_NONE)
|
||||||
type(t),
|
:
|
||||||
flags(f),
|
pView(0),
|
||||||
fPadding(0.0) {}
|
type(t),
|
||||||
|
flags(f),
|
||||||
|
fPadding(0.0)
|
||||||
|
{}
|
||||||
|
|
||||||
ValCtrlLayoutEntry(entry_type t,
|
ValCtrlLayoutEntry(const ValCtrlLayoutEntry& clone) {
|
||||||
layout_flags f=LAYOUT_NONE) :
|
operator=(clone);
|
||||||
|
}
|
||||||
|
|
||||||
pView(0),
|
ValCtrlLayoutEntry& operator=(const ValCtrlLayoutEntry& clone) {
|
||||||
type(t),
|
type = clone.type;
|
||||||
flags(f),
|
flags = clone.flags;
|
||||||
fPadding(0.0) {}
|
pView = clone.pView;
|
||||||
|
|
||||||
ValCtrlLayoutEntry(const ValCtrlLayoutEntry& clone) {
|
frame = clone.frame;
|
||||||
operator=(clone);
|
fPadding = clone.fPadding;
|
||||||
}
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
ValCtrlLayoutEntry& operator=(const ValCtrlLayoutEntry& clone) {
|
// order first by x position, then by y:
|
||||||
type = clone.type;
|
bool operator<(const ValCtrlLayoutEntry& b) const {
|
||||||
flags = clone.flags;
|
return frame.left < b.frame.left ||
|
||||||
pView = clone.pView;
|
frame.top < b.frame.top;
|
||||||
|
}
|
||||||
|
|
||||||
frame = clone.frame;
|
protected:
|
||||||
fPadding = clone.fPadding;
|
// move & size ref'd child view to match 'frame'
|
||||||
return *this;
|
static void InitChildFrame(ValCtrlLayoutEntry& e);
|
||||||
}
|
|
||||||
|
|
||||||
// order first by x position, then by y:
|
public:
|
||||||
bool operator<(const ValCtrlLayoutEntry& b) const {
|
BView* pView;
|
||||||
return frame.left < b.frame.left ||
|
|
||||||
frame.top < b.frame.top;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
entry_type type;
|
||||||
// move & size ref'd child view to match 'frame'
|
layout_flags flags;
|
||||||
static void InitChildFrame(ValCtrlLayoutEntry& e);
|
|
||||||
|
|
||||||
public:
|
// layout state info (filled in by ValControl):
|
||||||
|
BRect frame;
|
||||||
BView* pView;
|
float fPadding;
|
||||||
|
|
||||||
entry_type type;
|
|
||||||
layout_flags flags;
|
|
||||||
|
|
||||||
// layout state info (filled in by ValControl):
|
|
||||||
BRect frame;
|
|
||||||
float fPadding;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
__END_CORTEX_NAMESPACE
|
__END_CORTEX_NAMESPACE
|
||||||
#endif /* __VALCTRLLAYOUTENTRY_H__ */
|
#endif // VAL_CTRL_LAYOUT_ENTRY_H
|
||||||
|
|||||||
@@ -11,13 +11,13 @@
|
|||||||
//
|
//
|
||||||
// * HISTORY
|
// * HISTORY
|
||||||
// e.moon 25jun99 Begun
|
// e.moon 25jun99 Begun
|
||||||
|
#ifndef CORTEX_DEFS_H
|
||||||
|
#define CORTEX_DEFS_H
|
||||||
|
|
||||||
#ifndef __cortex_defs_h__
|
|
||||||
#define __cortex_defs_h__
|
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
// *** namespace support
|
// namespace support
|
||||||
#ifdef CORTEX_NAMESPACE
|
#ifdef CORTEX_NAMESPACE
|
||||||
#define __BEGIN_CORTEX_NAMESPACE namespace CORTEX_NAMESPACE {
|
#define __BEGIN_CORTEX_NAMESPACE namespace CORTEX_NAMESPACE {
|
||||||
#define __END_CORTEX_NAMESPACE }
|
#define __END_CORTEX_NAMESPACE }
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#define TOUCH(x) ((void)(x))
|
#define TOUCH(x) ((void)(x))
|
||||||
|
|
||||||
// *** message 'what' code base values
|
// message 'what' code base values
|
||||||
|
|
||||||
const uint32 NodeManager_message_base = 'NMaA';
|
const uint32 NodeManager_message_base = 'NMaA';
|
||||||
const uint32 NodeManager_int_message_base = 'Nm_A';
|
const uint32 NodeManager_int_message_base = 'Nm_A';
|
||||||
@@ -63,4 +63,4 @@ const uint32 InfoView_message_base = 'InVA';
|
|||||||
|
|
||||||
const uint32 ParameterWindow_message_base = 'PaWA';
|
const uint32 ParameterWindow_message_base = 'PaWA';
|
||||||
|
|
||||||
#endif /*__cortex_defs_h__*/
|
#endif // CORTEX_DEFS_H
|
||||||
|
|||||||
Reference in New Issue
Block a user