QScriptValue REcmaSharedPointerTextLabel::getText (QScriptContext* context, QScriptEngine* engine) { //REcmaHelper::functionStart("REcmaSharedPointerTextLabel::getText", context, engine); //qDebug() << "ECMAScript WRAPPER: REcmaSharedPointerTextLabel::getText"; //QCoreApplication::processEvents(); QScriptValue result = engine->undefinedValue(); // public function: can be called from ECMA wrapper of ECMA shell: RTextLabel* self = getSelf("getText", context); //Q_ASSERT(self!=NULL); if (self==NULL) { return REcmaHelper::throwError("self is NULL", context); } if( context->argumentCount() == 0 ){ // prepare arguments: // end of arguments // call C++ function: // return type 'QString' QString cppResult = self->getText(); // return type: QString // standard Type result = QScriptValue(cppResult); } else { return REcmaHelper::throwError("Wrong number/types of arguments for RTextLabel.getText().", context); } //REcmaHelper::functionEnd("REcmaSharedPointerTextLabel::getText", context, engine); return result; }
void REventHandler::drawInfoLabel(QPainter* painter, const RTextLabel& textLabel) { RVector pos = textLabel.getPosition(); QString text = textLabel.getText(); RVector p = graphicsView->mapToView(pos); // info labels might have individual colors in future //var color = RSettings.getColor("GraphicsViewColors/TextLabelColor", new RColor(249,198,31)); RColor color = RSettings::getColor("GraphicsViewColors/MeasurementToolsColor", RColor(155,220,112)); painter->setPen(color); if (!text.isEmpty()) { QFont font = RSettings::getInfoLabelFont(); font.setPointSizeF(font.pointSizeF()*graphicsView->getDevicePixelRatio()); QFontMetrics fm(font); int w = fm.width(text)+10; int h = fm.height()+10; //fm.destroy(); painter->setFont(font); painter->drawText(p.x - w - 15, p.y + h + 5, w, h, Qt::AlignHCenter | Qt::AlignVCenter, text, NULL); } }