4 #ifndef CM_UIInstance_H
5 #define CM_UIInstance_H
16 #include "OOPDHeaders.h"
18 #include <QGraphicsView>
33 class UIInstance :
public UIBox {
48 explicit UIInstance();
51 static UIObject* createObject(QString objectData,
t_canvas* pdCanvas, QGraphicsView* parent = 0)
130 virtual void paint(QPainter* p,
const QStyleOptionGraphicsItem*, QWidget*)
133 QBrush brush(bgColor());
135 p->drawRect(boundingRect());
136 p->setBrush(QBrush());
139 p->setRenderHint(QPainter::HighQualityAntialiasing,
true);
140 p->scale(scale(), scale());
142 QColor c1 = (_opInstance) ? QColor(0, 192, 255) : QColor(255, 0, 0);
143 p->setPen(QPen(c1, 1, Qt::SolidLine, Qt::SquareCap, Qt::BevelJoin));
144 p->drawRect(0, 1, width(), height() - 2);
152 QColor rectColor = (errorBox()) ? QColor(255, 0, 0) : properties()->get(
"BorderColor")->asQColor();
153 p->setPen(QPen(rectColor, 1, (errorBox()) ? Qt::DashLine : Qt::SolidLine, Qt::SquareCap, Qt::BevelJoin));
154 p->drawRect(0, 0, width(), height());
155 QTextOption* op =
new QTextOption;
156 op->setAlignment(Qt::AlignLeft);
157 p->setPen(QPen(QColor(0, 0, 0), 2, Qt::SolidLine, Qt::SquareCap, Qt::BevelJoin));
160 p->setPen(QPen(QColor(0, 192, 255), 1, (errorBox()) ? Qt::DashLine : Qt::SolidLine, Qt::SquareCap, Qt::BevelJoin));
161 p->drawRect(0, 0, width(), height());
208 void mousePressEvent(QGraphicsSceneMouseEvent* ev)
211 if (ev->button() == Qt::RightButton) {
214 && !scene()->views().isEmpty()
215 && scene()->views().first()
216 && scene()->views().first()->viewport()) {
218 QGraphicsView* v = scene()->views().first();
219 QPoint pos = v->viewport()->mapToGlobal(ev->pos().toPoint());
222 showPopupMenu(pos + this->pos().toPoint());
231 if (subpatchController()) {
232 subpatchController()->mainWindow()->show();
239 _opInstance->showWindow();
242 if ((getEditMode() ==
em_Unlocked) && isSelected()) {
246 emit signalEditObject(
this);
250 emit selectBox(
this, ev);
251 dragOffset = ev->pos().toPoint();
257 void mouseReleaseEvent(QGraphicsSceneMouseEvent*)
266 void mouseMoveEvent(QGraphicsSceneMouseEvent* event)
268 if (event->buttons() & Qt::LeftButton) {
269 emit moveBox(
this, event);
273 if ((getEditMode() !=
em_Unlocked) && (subpatchController())) {
274 setCursor(QCursor(Qt::PointingHandCursor));
276 setCursor(QCursor(Qt::ArrowCursor));
280 void setPdMessage(QString message)
282 fromQString(message);
286 QFontMetrics fm(myFont);
287 int new_w = fm.width(QString(objectData()->toQString())) + 10;
288 new_w = (new_w < 25) ? 25 : new_w;
301 void msgNew(PdArguments msg)
337 void setOutletsPos();
345 void msgFree(PdArguments)
370 void msgSetObject(PdArguments msg)
393 void msgGetObject(PdArguments)
412 void msgSetType(PdArguments msg)
479 static void updateUI(
void* uiobj, PdArguments msg)
568 void updateUISignal();
578 #endif // CM_UIInstance_H
#define t_canvas
Definition: m_pd.h:205
Definition: CommonTypes.h:14
#define PREF_QSTRING(x)
Definition: Preferences.h:17
Definition: oop_common.h:352
#define t_outlet
Definition: m_pd.h:189
Definition: oop_common.h:81