//! Mouse event handler void QwtPlotCanvas::mousePressEvent(QMouseEvent *e) { if (d_outlineActive) { QPainter p(this); drawOutline(p); // Delete active outlines } d_outlineActive = FALSE; // // store this point as entry point // d_lastPoint = e->pos(); d_entryPoint = e->pos(); if (d_outlineEnabled) { QPainter p(this); drawOutline(p); // draw new outline d_outlineActive = TRUE; } d_mousePressed = TRUE; QMouseEvent m(QEvent::MouseButtonPress, e->pos() - rect().topLeft(), e->button(), e->state()); emit mousePressed(m); }
void QDeclarativeTextPrivate::checkImgCache() { if (!imgDirty) return; bool empty = text.isEmpty(); if (empty) { imgCache = QPixmap(); imgStyleCache = QPixmap(); } else if (richText) { imgCache = richTextImage(false); if (style != QDeclarativeText::Normal) imgStyleCache = richTextImage(true); //### should use styleColor } else { imgCache = wrappedTextImage(false); if (style != QDeclarativeText::Normal) imgStyleCache = wrappedTextImage(true); //### should use styleColor } if (!empty) switch (style) { case QDeclarativeText::Outline: drawOutline(); break; case QDeclarativeText::Sunken: drawOutline(-1); break; case QDeclarativeText::Raised: drawOutline(1); break; default: break; } imgDirty = false; }
void Client::drag() { XEvent ev; int x1, y1; int old_cx = x; int old_cy = y; if (!ws->grabPointer(ws->moveCursor())) return; ws->pointerPosition(&x1, &y1); ws->grabServer(); bool motion = false; for (;;) { ws->waitForMouse( &ev ); switch (ev.type) { case MotionNotify: if ( !motion ) { drawOutline(); motion = true; } drawOutline(); /* clear */ x = old_cx + (ev.xmotion.x_root - x1); y = old_cy + (ev.xmotion.y_root - y1); drawOutline(); /* redraw */ break; case ButtonRelease: if ( motion ) drawOutline(); /* clear */ ws->ungrabServer(); ws->ungrabPointer(); move(); return; /* get out of loop */ } } }
//! Mouse event handler void QwtPlotCanvas::mouseMoveEvent(QMouseEvent *e) { if (d_outlineActive) { QPainter p(this); drawOutline(p); d_lastPoint = e->pos(); drawOutline(p); } QMouseEvent m(QEvent::MouseMove, e->pos() - rect().topLeft(), e->button(), e->state()); emit mouseMoved(m); }
void ofxUICanvas::draw() { ofPushStyle(); glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); ofEnableBlendMode(OF_BLENDMODE_ALPHA); ofSetRectMode(OF_RECTMODE_CORNER); ofSetLineWidth(1.0); drawPadded(); drawPaddedOutline(); drawBack(); drawFill(); drawFillHighlight(); drawOutline(); drawOutlineHighlight(); for(int i = widgets.size()-1; i >= 0; i--) { if(widgets[i]->isVisible()) { widgets[i]->draw(); } } glDisable(GL_DEPTH_TEST); ofPopStyle(); }
/*! Draw a subset of the histogram samples \param painter Painter \param xMap Maps x-values into pixel coordinates. \param yMap Maps y-values into pixel coordinates. \param canvasRect Contents rect of the canvas \param from Index of the first sample to be painted \param to Index of the last sample to be painted. If to < 0 the series will be painted to its last sample. \sa drawOutline(), drawLines(), drawColumns */ void QwtPlotHistogram::drawSeries( QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &, int from, int to ) const { if ( !painter || dataSize() <= 0 ) return; if ( to < 0 ) to = dataSize() - 1; switch ( d_data->style ) { case Outline: drawOutline( painter, xMap, yMap, from, to ); break; case Lines: drawLines( painter, xMap, yMap, from, to ); break; case Columns: drawColumns( painter, xMap, yMap, from, to ); break; default: break; } }
//! Redraw the canvas, and focus rect void QwtPlotCanvas::drawContents(QPainter *painter) { if ( cacheMode() && d_cache && d_cache->size() == contentsRect().size() ) { painter->drawPixmap(contentsRect().topLeft(), *d_cache); } else drawCanvas(painter); #ifndef QWT_NO_COMPAT if ( d_outlineActive ) drawOutline(*painter); // redraw outline #endif if ( hasFocus() && focusIndicator() == CanvasFocusIndicator ) { const int margin = 1; QRect focusRect = contentsRect(); focusRect.setRect(focusRect.x() + margin, focusRect.y() + margin, focusRect.width() - 2 * margin, focusRect.height() - 2 * margin); drawFocusIndicator(painter, focusRect); } }
void ResizeGesture::drawControls(QPainter* p) { QColor drawColor = qApp->palette().color(QPalette::Active, QPalette::Highlight); QRect localRect = m_canvas->canvasToLocal(m_bounds.normalized()); p->save(); // p->setPen(QPen(Qt::black, 1, Qt::DashLine, Qt::FlatCap, Qt::MiterJoin)); // p->drawRect(localRect); if (m_rotation != 0) { p->setRenderHint(QPainter::Antialiasing); p->translate(localRect.x(), localRect.y()); p->rotate(m_rotation); p->translate(-localRect.x(), -localRect.y()); } p->setPen(QPen(drawColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); drawColor.setAlpha(64); p->setBrush(drawColor); p->drawRect(localRect); // p->setPen(Qt::darkMagenta); // p->drawLine(localRect.topLeft(), localRect.bottomRight()); p->restore(); if (m_origBounds != m_bounds) { QRectF n_bounds = m_bounds.normalized(); QRectF n_origBounds = m_origBounds.normalized(); p->save(); // p->translate(m_bounds.topLeft() - m_origBounds.topLeft()); drawOutline(p, qAbs(n_bounds.width()) / qMax(qAbs(n_origBounds.width()), static_cast<qreal>(1.0)), qAbs(n_bounds.height()) / qMax(qAbs(n_origBounds.height()), static_cast<qreal>(1.0)), n_bounds.left() - n_origBounds.left(), n_bounds.top() - n_origBounds.top()); p->restore(); } }
void QwtPlotCanvas::setOutlineStyle(Qwt::Shape os) { if (d_outlineActive) { QPainter p(this); // erase old outline drawOutline(p); } d_outline = os; if (d_outlineActive) { QPainter p(this); drawOutline(p); // draw new outline } }
void ECCCCS::drawShape(QPainter &p) { initPainter(p); drawOutline(p); drawTopArrow(p); drawBottomArrow(p); deinitPainter(p); }
void ofxUIScrollableCanvas::draw() { ofxUIPushStyle(); glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); ofEnableBlendMode(OF_BLENDMODE_ALPHA); ofxUISetRectMode(OFX_UI_RECTMODE_CORNER); ofSetLineWidth(1.0); drawPadded(); drawPaddedOutline(); drawBack(); drawFill(); drawFillHighlight(); drawOutline(); drawOutlineHighlight(); for(vector<ofxUIWidget *>::reverse_iterator it = widgets.rbegin(); it != widgets.rend(); ++it) { if((*it)->isVisible() && (*it)->getRect()->rInside(*sRect)) { (*it)->draw(); } } ofxUIPopStyle(); }
void KisColorSelector::paintEvent(QPaintEvent* /*event*/) { // 0 red -> (1,0,0) // 1 yellow -> (1,1,0) // 2 green -> (0,1,0) // 3 cyan -> (0,1,1) // 4 blue -> (0,0,1) // 5 maenta -> (1,0,1) // 6 red -> (1,0,0) m_renderBuffer.fill(0); QPainter imgPainter(&m_renderBuffer); QPainter wdgPainter(this); QRect fgRect(0, 0 , QWidget::width(), QWidget::height()/2); QRect bgRect(0, QWidget::height()/2, QWidget::width(), QWidget::height()/2); wdgPainter.fillRect(fgRect, m_fgColor.getQColor()); wdgPainter.fillRect(bgRect, m_bgColor.getQColor()); for(int i=0; i<m_colorRings.size(); ++i) drawRing(imgPainter, m_colorRings[i], m_renderArea); wdgPainter.drawImage(m_renderArea, m_renderBuffer); drawOutline (wdgPainter, m_renderArea); drawLightStrip(wdgPainter, m_lightStripArea); }
void TextBox::redrawSelf() { if (!keyFocus) isHighlighted = false; glBindTexture(GL_TEXTURE_2D, 0); glColor4ub(30, 30, 30, 100); glBegin(GL_QUADS); glVertex2f(x, y); glVertex2f(x+width, y); glVertex2f(x+width, y+height); glVertex2f(x, y+height); glEnd(); if (isHighlighted) drawHighlight(); drawOutline(); screenPrintf(x, y, *textParams, text.c_str()); if (keyFocus) drawCursor(); }
void drawBoundary(int width,int height) { static a=0; ////////////////Net//////////////// glColor3ub(100,100,0); glPushMatrix(); glTranslated(-25,height/2,0); drawNet(50,height/2); glPopMatrix(); glPushMatrix(); glTranslated(25+width,height/2,0); drawNet(50,height/2); glPopMatrix(); /////////////////////Upper Boundary//////////////// drawUpperBlock(width,height); ////////////////////Lower Boundary///////////////// drawLowerBlock(width,height); ///////Outline////////// drawOutline(); }
int draw(){ drawOutline(); drawMap(); water(); voidBlock(); attron(COLOR_PAIR(6)); mvprintw(12,0,"Block Type:"); return 0; }
void CanvasMode_EditPolygon::drawControls(QPainter* p) { p->save(); if (m_canvas->m_viewMode.operItemMoving) drawOutline(p); else drawSelection(p, false); if (m_doc->appMode == modeEditPolygon) drawControlsPolygon(p, m_doc->m_Selection->itemAt(0)); p->restore(); }
void Dialog::paint() { Design::drawFilledRect(&_gui->_screen, _bbox, kColorWhite, _gui->_wm.getPatterns(), kPatternSolid); _font->drawString(&_gui->_screen, _text, _bbox.left + 24, _bbox.top + 16, _bbox.width(), kColorBlack); static int boxOutline[] = { 1, 0, 0, 1, 1 }; drawOutline(_bbox, boxOutline, ARRAYSIZE(boxOutline)); for (uint i = 0; i < _buttons->size(); i++) { DialogButton *button = _buttons->operator[](i); static int buttonOutline[] = { 0, 0, 0, 0, 1 }; if (i == _defaultButton) { buttonOutline[0] = buttonOutline[1] = 1; } else { buttonOutline[0] = buttonOutline[1] = 0; } int color = kColorBlack; if ((int)i == _pressedButton && _mouseOverPressedButton) { Common::Rect bb(button->bounds.left + 5, button->bounds.top + 5, button->bounds.right - 5, button->bounds.bottom - 5); Design::drawFilledRect(&_gui->_screen, bb, kColorBlack, _gui->_wm.getPatterns(), kPatternSolid); color = kColorWhite; } int w = _font->getStringWidth(button->text); int x = button->bounds.left + (button->bounds.width() - w) / 2; int y = button->bounds.top + 6; _font->drawString(&_gui->_screen, button->text, x, y, _bbox.width(), color); drawOutline(button->bounds, buttonOutline, ARRAYSIZE(buttonOutline)); } g_system->copyRectToScreen(_gui->_screen.getBasePtr(_bbox.left, _bbox.top), _gui->_screen.pitch, _bbox.left, _bbox.top, _bbox.width() + 1, _bbox.height() + 1); _needsRedraw = false; }
void BitObject::draw(BitObjectDrawMode mode, Image<T_or_RGB>& img, const T_or_RGB& color, float opacity) { switch(mode) { case BODMnone: break; case BODMshape: drawShape(img, color, opacity); break; case BODMoutline: drawOutline(img, color, opacity); break; case BODMbbox: drawBoundingBox(img, color, opacity); break; default: LERROR("Unknown BitObjectDrawMode: %i - ignoring!",mode); } }
void CanvasMode_Normal::drawControls(QPainter* p) { // qDebug() << "CanvasMode_Normal::drawControls"; if (m_canvas->m_viewMode.operItemMoving) { drawOutline(p, 1.0, 1.0, m_objectDeltaPos.x(), m_objectDeltaPos.y()); } else { drawSelection(p, true); } }
void Client::resize() { XEvent ev; int old_cx = x; int old_cy = y; if (!ws->grabPointer(ws->resizeCursor())) return; ws->grabServer(); int pointer_x; int pointer_y; ws->pointerPosition(&pointer_x, &pointer_y); int offset_x = x + width - pointer_x; int offset_y = y + height - pointer_y; drawOutline(); for (;;) { ws->waitForMouse( &ev ); switch (ev.type) { case MotionNotify: drawOutline(); /* clear */ x = ev.xmotion.x_root + offset_x; y = ev.xmotion.y_root + offset_y; recalcResize(old_cx, old_cy, x, y ); drawOutline(); break; case ButtonRelease: drawOutline(); /* clear */ moveResize(); redraw( active, true ); ws->ungrabServer(); ws->ungrabPointer(); return; /* get out of loop */ } } }
void ChartXYPlot::draw(GraphLib::GraphRenderer *renderer, QRectF plotArea, QPointF anchor) { drawBackground(renderer, plotArea); drawOutline(renderer, plotArea); drawPoints(renderer, plotArea); if (m_data->gridIsVisible) { drawXGridLines(renderer, plotArea); drawYGridLines(renderer, plotArea); } drawAxis(renderer, plotArea); }
void QwtPlotCanvas::enableOutline(bool tf) { // // If the mouse is pressed, erase existing outline // or draw new outline if 'tf' changes the 'enabled' state. // if ((tf != d_outlineEnabled) && d_mousePressed) { QPainter p(this); drawOutline(p); d_outlineActive = tf; } d_outlineEnabled = tf; }
void RenderArea::paintEvent(QPaintEvent *event) { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); painter.fillRect(event->rect(), QBrush(Qt::white)); painter.translate(this->width()/3, this->height()/2.5); painter.save(); transformPainter(painter); drawShape(painter); painter.restore(); drawOutline(painter); transformPainter(painter); drawCoordinates(painter); }
void ofxUIWidget::draw() { ofxUIPushStyle(); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); drawPadded(); drawPaddedOutline(); drawBack(); drawOutline(); drawOutlineHighlight(); drawFill(); drawFillHighlight(); ofxUIPopStyle(); }
//! Mouse event handler void QwtPlotCanvas::mouseReleaseEvent(QMouseEvent *e) { if (d_outlineActive) { QPainter p(this); drawOutline(p); } d_outlineActive = FALSE; d_mousePressed = FALSE; QMouseEvent m(QEvent::MouseButtonRelease, e->pos() - rect().topLeft(), e->button(), e->state()); emit mouseReleased(m); }
void CanvasMode_EditArc::drawControls(QPainter* p) { p->save(); if (m_canvas->m_viewMode.operItemMoving) { drawOutline(p); } else { drawSelection(p, false); } if (m_doc->appMode == modeEditArc) { drawControlsArc(p, m_doc->m_Selection->itemAt(0)); } p->restore(); }
void MapArea::setActive(bool on, bool redraw) { if ((!on && isAlwaysActive()) || active==on) return; active=on; if (redraw && pane && mapper) { if (isActiveOutlineMode()) drawOutline(Q2G(pane->rect())); else if (!isCacheUsed()) repaint(); else { // Use cache to draw ourselves GRect brect=gmap_area->get_bound_rect(); mapper->map(brect); brect.inflate(3, 3); GRect pane_rect=Q2G(pane->rect()); GRect urect; if (urect.intersect(pane_rect, brect)) { for(GPosition pos=pieces;pos;++pos) { GP<MapPiece> piece=pieces[pos]; GRect piece_rect=*piece; mapper->map(piece_rect); GRect irect; if (irect.intersect(piece_rect, urect)) { QPixmap & pix=active ? piece->getOnPixmap() : piece->getOffPixmap(); if (pix.isNull()) repaint(piece_rect); QPainter p(pane); GRect crect=doc_rect; mapper->map(crect); p.setClipRect(G2Q(crect)); p.drawPixmap(irect.xmin, irect.ymin, pix, irect.xmin-piece_rect.xmin, irect.ymin-piece_rect.ymin, irect.width(), irect.height()); } } } } } }
/* * displayScene * * parameter glContextData - GLContextData */ void Scene::display(GLContextData& glContextData) const { DataItem* dataItem = glContextData.retrieveDataItem<DataItem> (this); pushGLState(glContextData); if (showDisplay) { if (alphaChanged) { update1DColorMap(dataItem); } if (colorMapChanged) { update1DColorMap(dataItem); } glDisable(GL_CULL_FACE); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); if (showOutline) drawOutline(); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); glEnable(GL_CULL_FACE); glDisable(GL_LIGHTING); // Add Points and Lines glEnable(GL_LIGHTING); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask(GL_FALSE); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); if (smoothPoints) glEnable(GL_POINT_SMOOTH); glPointSize(pointSize); if (showPointe) drawPointe(glContextData, dataItem); if (smoothPoints) glDisable(GL_POINT_SMOOTH); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); glDepthMask(GL_TRUE); glDisable(GL_BLEND); } popGLState(glContextData); } // end displayScene()
void ofxUIDropDownList::draw() { ofxUIPushStyle(); ofEnableBlendMode(OF_BLENDMODE_ALPHA); drawPadded(); drawPaddedOutline(); drawBack(); drawOutline(); drawOutlineHighlight(); drawFill(); drawFillHighlight(); ofxUIPopStyle(); }
void KeyboardLayoutWidget::drawKey(QPainter* painter, DrawingKey* key) { XkbShapeRec *shape; QColor color; XkbOutlineRec *outline; int origin_offset_x; /* gint i; */ if (!xkb) return; shape = xkb->geom->shapes + key->xkbkey->shape_ndx; if (key->pressed) color = qApp->palette().color(QPalette::Active, QPalette::Highlight); else color = colors[key->xkbkey->color_ndx]; /* draw the primary outline */ outline = shape->primary ? shape->primary : shape->outlines; drawOutline (painter, outline, color, key->angle, key->originX, key->originY); #if 0 /* don't draw other outlines for now, since * the text placement does not take them into account */ for (i = 0; i < shape->num_outlines; i++) { if (shape->outlines + i == shape->approx || shape->outlines + i == shape->primary) continue; draw_outline (context, shape->outlines + i, NULL, key->angle, key->origin_x, key->origin_y); } #endif origin_offset_x = calcShapeOriginOffsetX (outline); drawKeyLabel (painter, key->keycode, key->angle, key->originX + origin_offset_x, key->originY, shape->bounds.x2, shape->bounds.y2, key->pressed); }