void MButtonView::drawContents(QPainter *painter, const QStyleOptionGraphicsItem *option) const { Q_UNUSED(option); Q_D(const MButtonView); drawIcon(painter, d->iconRect); }
void UILineEdit::drawSelf() { drawBackground(m_rect); drawBorder(m_rect); drawImage(m_rect); drawIcon(m_rect); //TODO: text rendering could be much optimized by using vertex buffer or caching the render into a texture int textLength = m_text.length(); const TexturePtr& texture = m_font->getTexture(); g_painter.setColor(m_color); for(int i=0;i<textLength;++i) g_painter.drawTexturedRect(m_glyphsCoords[i], texture, m_glyphsTexCoords[i]); // render cursor if(isExplicitlyEnabled() && (isActive() || m_alwaysActive) && m_cursorPos >= 0) { assert(m_cursorPos <= textLength); // draw every 333ms const int delay = 333; if(g_clock.ticksElapsed(m_cursorTicks) <= delay) { Rect cursorRect; // when cursor is at 0 or is the first visible element if(m_cursorPos == 0 || m_cursorPos == m_startRenderPos) cursorRect = Rect(m_drawArea.left()-1, m_drawArea.top(), 1, m_font->getGlyphHeight()); else cursorRect = Rect(m_glyphsCoords[m_cursorPos-1].right(), m_glyphsCoords[m_cursorPos-1].top(), 1, m_font->getGlyphHeight()); g_painter.drawFilledRect(cursorRect); } else if(g_clock.ticksElapsed(m_cursorTicks) >= 2*delay) { m_cursorTicks = g_clock.ticks(); } } }
static void showTimeLeft(int t, int max) { char buf[BUFSIZ]; int cx, cy, ex, ey, tx, ty; if ((max - t) < 10 && t & 1) { W_Beep(); W_Deiconify(baseWin); } if (iconified) drawIcon(); /* XFIX */ W_ClearArea(qwin, 0, 0, BOXSIDE, BOXSIDE); W_DrawImageNoClip(qwin, 0, 0, 0, getImage(I_CLOCK), foreColor); cx = BOXSIDE / 2; cy = BOXSIDE / 2 - 6; ex = cx - 35 * Sin[((255 * t) / max + 64) % 256]; ey = cy - 35 * Cos[((255 * t) / max + 64) % 256]; W_MakeLine(qwin, cx, cy, ex, ey, foreColor); sprintf(buf, "%d", max - t); cy = BOXSIDE / 2 - 1; tx = cx - (int)W_StringWidth(buf, W_RegularFont) / 2; ty = cy - W_Textheight; W_WriteText(qwin, tx, ty, textColor, buf, strlen(buf), W_RegularFont); }
void AGOSEngine_Elvira2::oe2_drawItem() { // 113: draw item Item *i = getNextItemPtr(); int a = getVarOrByte(); int x = getVarOrWord(); int y = getVarOrWord(); mouseOff(); drawIcon(_windowArray[a % 8], itemGetIconNumber(i), x, y); mouseOn(); }
void UIProgressRect::drawSelf(Fw::DrawPane drawPane) { if((drawPane & Fw::ForegroundPane) == 0) return; g_painter->setColor(m_backgroundColor); // todo: check +1 to right/bottom // todo: add smooth Rect drawRect = getPaddingRect(); // 0% - 12.5% (12.5) // triangle from top center, to top right (var x) if(m_percent < 12.5) { Point var = Point(std::max<int>(m_percent - 0.0, 0.0) * (drawRect.right() - drawRect.horizontalCenter()) / 12.5, 0); g_painter->drawFilledTriangle(drawRect.center(), drawRect.topRight() + Point(1,0), drawRect.topCenter() + var); } // 12.5% - 37.5% (25) // triangle from top right to bottom right (var y) if(m_percent < 37.5) { Point var = Point(0, std::max<int>(m_percent - 12.5, 0.0) * (drawRect.bottom() - drawRect.top()) / 25.0); g_painter->drawFilledTriangle(drawRect.center(), drawRect.bottomRight() + Point(1,1), drawRect.topRight() + var + Point(1,0)); } // 37.5% - 62.5% (25) // triangle from bottom right to bottom left (var x) if(m_percent < 62.5) { Point var = Point(std::max<int>(m_percent - 37.5, 0.0) * (drawRect.right() - drawRect.left()) / 25.0, 0); g_painter->drawFilledTriangle(drawRect.center(), drawRect.bottomLeft() + Point(0,1), drawRect.bottomRight() - var + Point(1,1)); } // 62.5% - 87.5% (25) // triangle from bottom left to top left if(m_percent < 87.5) { Point var = Point(0, std::max<int>(m_percent - 62.5, 0.0) * (drawRect.bottom() - drawRect.top()) / 25.0); g_painter->drawFilledTriangle(drawRect.center(), drawRect.topLeft(), drawRect.bottomLeft() - var + Point(0,1)); } // 87.5% - 100% (12.5) // triangle from top left to top center if(m_percent < 100) { Point var = Point(std::max<int>(m_percent - 87.5, 0.0) * (drawRect.horizontalCenter() - drawRect.left()) / 12.5, 0); g_painter->drawFilledTriangle(drawRect.center(), drawRect.topCenter(), drawRect.topLeft() + var); } drawImage(m_rect); drawBorder(m_rect); drawIcon(m_rect); drawText(m_rect); }
void UIWidget::drawSelf() { // draw style components in order if(m_backgroundColor.aF() > Fw::MIN_ALPHA) { Rect backgroundDestRect = m_rect; backgroundDestRect.expand(-m_borderWidth.top, -m_borderWidth.right, -m_borderWidth.bottom, -m_borderWidth.left); drawBackground(m_rect); } drawImage(m_rect); drawBorder(m_rect); drawIcon(m_rect); drawText(m_rect); }
//called to draw one item void GlutGuiViewport::drawMobile( Mobile& item) { //drawing a triangle const vec2 &pos = item.getPos(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glTranslatef(pos.x, pos.y, 0); glRotatef( item.getAngle()*(180/M_PI), 0,0,1); drawIcon( item ); glPopMatrix(); }
void NameItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &styleOption, const QModelIndex &modelIndex) const { painter->save(); if (styleOption.state & QStyle::State_Selected) NavigatorTreeView::drawSelectionBackground(painter, styleOption); int iconOffset = drawIcon(painter, styleOption, modelIndex); QRect textFrame = drawText(painter, styleOption, modelIndex, iconOffset); if (modelIndex.data(NavigatorTreeModel::ErrorRole).toBool()) drawRedWavyUnderLine(painter, styleOption, textFrame); painter->restore(); }
void Element::draw(DrawContext dc, double zoom) { dc->set_line_width(1); // GTimer *t = g_timer_new(); drawBody(dc, zoom); // gulong m; // g_timer_elapsed(t, &m); // DEBUG_MSG("Body: " << m) if(zoom > 0.6) drawIcon(dc); // g_timer_elapsed(t, &m); // DEBUG_MSG("Icon: " << m) drawPoints(dc); // g_timer_elapsed(t, &m); // DEBUG_MSG("Points: " << m) // g_timer_destroy(t); }
void UIItem::drawSelf(Fw::DrawPane drawPane) { if((drawPane & Fw::ForegroundPane) == 0) return; // draw style components in order if(m_backgroundColor.aF() > Fw::MIN_ALPHA) { Rect backgroundDestRect = m_rect; backgroundDestRect.expand(-m_borderWidth.top, -m_borderWidth.right, -m_borderWidth.bottom, -m_borderWidth.left); drawBackground(m_rect); } drawImage(m_rect); if(m_itemVisible && m_item) { Rect drawRect = getPaddingRect(); Point dest = drawRect.bottomRight() + Point(1,1); int exactSize = std::max<int>(32, m_item->getExactSize()); if(exactSize == 0) return; float scaleFactor = std::min<float>(drawRect.width() / (float)exactSize, drawRect.height() / (float)exactSize); dest += (m_item->getDisplacement() - Point(32,32)) * scaleFactor; g_painter->setColor(m_color); m_item->draw(dest, scaleFactor, true); if(m_font && (m_item->isStackable() || m_item->isChargeable()) && m_item->getCountOrSubType() > 1) { std::string count = stdext::to_string(m_item->getCountOrSubType()); g_painter->setColor(Color(231, 231, 231)); m_font->drawText(count, Rect(m_rect.topLeft(), m_rect.bottomRight() - Point(3, 0)), Fw::AlignBottomRight); } if(m_showId) m_font->drawText(stdext::to_string(m_item->getServerId()), m_rect, Fw::AlignBottomRight); } drawBorder(m_rect); drawIcon(m_rect); drawText(m_rect); }
static void redrawTeam(W_Window win, int teamNo, int *lastnum) { char buf[BUFSIZ]; int num = numShips(teamNo); /* Only redraw if number of players has changed */ if (*lastnum == num) return; drawIcon(); W_ClearWindow(win); W_DrawImageNoClip(teamWin[teamNo], 0, 0, 0, teaminfo[teamNo].shield_logo, shipCol[teamNo + 1]); (void) sprintf(buf, "%d", num); W_MaskText(win, 5, 46, shipCol[teamNo + 1], buf, strlen(buf), W_BigFont); if (!(tournMask & (1 << teamNo))) W_DrawImage(win, 0, 0, 0, getImage(I_NOENTRY), W_Red); *lastnum = num; }
void DropDownList::drawItem(DC& dc, int y, size_t item) { if (y + item_size.height <= 0 || y >= dc.GetSize().y) return; // not visible // draw background dc.SetPen(*wxTRANSPARENT_PEN); if (item == selected_item) { if (itemEnabled(item)) { dc.SetBrush (wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); } else { dc.SetBrush (wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT)); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); } dc.DrawRectangle(marginW, y, (int)item_size.width, (int)item_size.height); } else if (!itemEnabled(item)) { // mix between foreground and background dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT)); } else if (highlightItem(item)) { // mix a color between selection and window dc.SetBrush (lerp(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), 0.75)); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); dc.DrawRectangle(marginW, y, (int)item_size.width, (int)item_size.height); } else { dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); } // draw text and icon drawIcon(dc, marginW, y, item, item == selected_item); dc.DrawText(capitalize(itemText(item)), marginW + (int)icon_size.width + 1, y + text_offset); // draw popup icon if (submenu(item)) { draw_menu_arrow(this, dc, RealRect(marginW, y, item_size.width, item_size.height), item == selected_item); } // draw line below if (lineBelow(item) && item != itemCount()) { dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); dc.DrawLine(marginW, y + (int)item_size.height, marginW + (int)item_size.width, y + (int)item_size.height); } }
WorkoutWindow::WorkoutWindow(Context *context) : GcChartWindow(context), draw(true), context(context), active(false), recording(false) { setContentsMargins(0,0,0,0); setProperty("color", GColor(CTRAINPLOTBACKGROUND)); setControls(NULL); ergFile = NULL; QVBoxLayout *main = new QVBoxLayout; QHBoxLayout *layout = new QHBoxLayout; QVBoxLayout *editor = new QVBoxLayout; setChartLayout(main); connect(context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32))); // the workout scene workout = new WorkoutWidget(this, context); // paint the TTE curve mmp = new WWMMPCurve(workout); // add a line between the dots line = new WWLine(workout); // block cursos bcursor = new WWBlockCursor(workout); // block selection brect = new WWBlockSelection(workout); // paint the W'bal curve wbline = new WWWBLine(workout, context); // telemetry telemetry = new WWTelemetry(workout, context); // add the power, W'bal scale powerscale = new WWPowerScale(workout, context); wbalscale = new WWWBalScale(workout, context); // lap markers lap = new WWLap(workout); // tte warning bar at bottom tte = new WWTTE(workout); // selection tool rect = new WWRect(workout); // guides always on top! guide = new WWSmartGuide(workout); // recording ... now = new WWNow(workout, context); // scroller, hidden until needed scroll = new QScrollBar(Qt::Horizontal, this); scroll->hide(); // setup the toolbar toolbar = new QToolBar(this); toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); toolbar->setFloatable(true); toolbar->setIconSize(QSize(18 *dpiXFactor,18 *dpiYFactor)); QIcon newIcon(":images/toolbar/new doc.png"); newAct = new QAction(newIcon, tr("New"), this); connect(newAct, SIGNAL(triggered()), this, SLOT(newFile())); toolbar->addAction(newAct); QIcon saveIcon(":images/toolbar/save.png"); saveAct = new QAction(saveIcon, tr("Save"), this); connect(saveAct, SIGNAL(triggered()), this, SLOT(saveFile())); toolbar->addAction(saveAct); QIcon saveAsIcon(":images/toolbar/saveas.png"); saveAsAct = new QAction(saveAsIcon, tr("Save As"), this); connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); toolbar->addAction(saveAsAct); toolbar->addSeparator(); //XXX TODO //XXXHelpWhatsThis *helpToolbar = new HelpWhatsThis(toolbar); //XXXtoolbar->setWhatsThis(helpToolbar->getWhatsThisText(HelpWhatsThis::ChartRides_Editor)); // undo and redo deliberately at a distance from the // save icon, since accidentally hitting the wrong // icon in that instance would be horrible QIcon undoIcon(":images/toolbar/undo.png"); undoAct = new QAction(undoIcon, tr("Undo"), this); connect(undoAct, SIGNAL(triggered()), workout, SLOT(undo())); toolbar->addAction(undoAct); QIcon redoIcon(":images/toolbar/redo.png"); redoAct = new QAction(redoIcon, tr("Redo"), this); connect(redoAct, SIGNAL(triggered()), workout, SLOT(redo())); toolbar->addAction(redoAct); toolbar->addSeparator(); QIcon drawIcon(":images/toolbar/edit.png"); drawAct = new QAction(drawIcon, tr("Draw"), this); connect(drawAct, SIGNAL(triggered()), this, SLOT(drawMode())); toolbar->addAction(drawAct); QIcon selectIcon(":images/toolbar/select.png"); selectAct = new QAction(selectIcon, tr("Select"), this); connect(selectAct, SIGNAL(triggered()), this, SLOT(selectMode())); toolbar->addAction(selectAct); selectAct->setEnabled(true); drawAct->setEnabled(false); toolbar->addSeparator(); QIcon cutIcon(":images/toolbar/cut.png"); cutAct = new QAction(cutIcon, tr("Cut"), this); cutAct->setEnabled(true); toolbar->addAction(cutAct); connect(cutAct, SIGNAL(triggered()), workout, SLOT(cut())); QIcon copyIcon(":images/toolbar/copy.png"); copyAct = new QAction(copyIcon, tr("Copy"), this); copyAct->setEnabled(true); toolbar->addAction(copyAct); connect(copyAct, SIGNAL(triggered()), workout, SLOT(copy())); QIcon pasteIcon(":images/toolbar/paste.png"); pasteAct = new QAction(pasteIcon, tr("Paste"), this); pasteAct->setEnabled(false); toolbar->addAction(pasteAct); connect(pasteAct, SIGNAL(triggered()), workout, SLOT(paste())); toolbar->addSeparator(); QIcon propertiesIcon(":images/toolbar/properties.png"); propertiesAct = new QAction(propertiesIcon, tr("Properties"), this); connect(propertiesAct, SIGNAL(triggered()), this, SLOT(properties())); toolbar->addAction(propertiesAct); QIcon zoomInIcon(":images/toolbar/zoom in.png"); zoomInAct = new QAction(zoomInIcon, tr("Zoom In"), this); connect(zoomInAct, SIGNAL(triggered()), this, SLOT(zoomIn())); toolbar->addAction(zoomInAct); QIcon zoomOutIcon(":images/toolbar/zoom out.png"); zoomOutAct = new QAction(zoomOutIcon, tr("Zoom Out"), this); connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(zoomOut())); toolbar->addAction(zoomOutAct); // stretch the labels to the right hand side QWidget *empty = new QWidget(this); empty->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); toolbar->addWidget(empty); xlabel = new QLabel("00:00"); toolbar->addWidget(xlabel); ylabel = new QLabel("150w"); toolbar->addWidget(ylabel); IFlabel = new QLabel("0 Intensity"); toolbar->addWidget(IFlabel); TSSlabel = new QLabel("0 Stress"); toolbar->addWidget(TSSlabel); #if 0 // not yet! // get updates.. connect(context, SIGNAL(telemetryUpdate(RealtimeData)), this, SLOT(telemetryUpdate(RealtimeData))); telemetryUpdate(RealtimeData()); #endif // editing the code... code = new CodeEditor(this); code->setContextMenuPolicy(Qt::NoContextMenu); // no context menu code->installEventFilter(this); // filter the undo/redo stuff code->hide(); // WATTS and Duration for the cursor main->addWidget(toolbar); editor->addWidget(workout); editor->addWidget(scroll); layout->addLayout(editor); layout->addWidget(code); main->addLayout(layout); // make it look right saveAct->setEnabled(false); undoAct->setEnabled(false); redoAct->setEnabled(false); // watch for erg file selection connect(context, SIGNAL(ergFileSelected(ErgFile*)), this, SLOT(ergFileSelected(ErgFile*))); // watch for erg run/stop connect(context, SIGNAL(start()), this, SLOT(start())); connect(context, SIGNAL(stop()), this, SLOT(stop())); // text changed connect(code, SIGNAL(textChanged()), this, SLOT(qwkcodeChanged())); connect(code, SIGNAL(cursorPositionChanged()), workout, SLOT(hoverQwkcode())); // scrollbar connect(scroll, SIGNAL(sliderMoved(int)), this, SLOT(scrollMoved())); // set the widgets etc configChanged(CONFIG_APPEARANCE); }
/*! */ void QFoldPanel::paint(QPainter *p, QEditor *e) { QDocument *doc = editor()->document(); QLanguageDefinition *def = e->languageDefinition(); if ( !def || !doc ) { return; } m_rects.clear(); m_lines.clear(); bool bVisible = false; //, // inCursorBlock = false; QDocumentLine block; const QFontMetrics fm(doc->font()); int n, pos, depth = 0, max = doc->lines(), h = fm.height(), ls = fm.lineSpacing(), pageBottom = e->viewport()->height(), contentsY = e->verticalOffset(); pos = - contentsY; //qDebug("beg pos : %i", pos); for ( n = 0; n < max; ++n ) { if ( pos > pageBottom ) break; block = doc->line(n); if ( block.isHidden() ) { continue; } int len = ls * block.lineSpan(); int flags = def->blockFlags(doc, n, depth); short open = QCE_FOLD_OPEN_COUNT(flags); short close = QCE_FOLD_CLOSE_COUNT(flags); bVisible = ((pos + len) >= 0); int oldDepth = depth; depth -= close; if ( depth < 0 ) depth = 0; depth += open; if ( open ) { if ( flags & QLanguageDefinition::Collapsed ) { int bound = (ls - 8) / 2; int mid = pos + len - ls / 6; // outermost block folded : none of the opening is actually opened depth -= open; if ( bVisible ) { // draw icon if ( bound > 0 && oldDepth > 0 ) { p->drawLine(7, pos, 7, pos + bound); } if ( close ) { p->drawLine(7, pos + 8 + bound, 7, mid); p->drawLine(7, mid, 12, mid); } m_lines << n; m_rects << drawIcon(p, e, 3, pos + bound, true); } int sub = open; //qDebug("%i : +%i", n, open); while ( sub > 0 && ((n + 1) < max) ) { ++n; block = doc->line(n); if ( !block.isHidden() ) { if ( bVisible ) p->drawLine(7, pos + 8 + bound, 7, pos + len); --n; break; } int sflags = def->blockFlags(doc, n, depth + 1); short sopen = QCE_FOLD_OPEN_COUNT(sflags); short sclose = QCE_FOLD_CLOSE_COUNT(sflags); sub -= sclose; if ( sub <= 0 ) break; sub += sopen; } depth += sub; if ( bVisible && depth > 0 ) { if ( close ) p->drawLine(7, mid, 7, pos + len); else p->drawLine(7, pos + 8 + bound, 7, pos + len); } } else { if ( bVisible ) { int bound = (ls - 8) / 2; if ( oldDepth > 0 && bound > 0 ) p->drawLine(7, pos, 7, pos + bound); m_lines << n; m_rects << drawIcon(p, e, 3, pos + bound, false); int mid = pos + len - ls / 6; if ( close ) p->drawLine(7, mid, 12, mid); if ( bound > 0 ) p->drawLine(7, pos + 8 + bound, 7, pos + len); } } } else if ( (oldDepth > 0) && bVisible ) { if ( close ) { int mid = pos + len - ls / 6; p->drawLine(7, pos, 7, mid); p->drawLine(7, mid, 12, mid); if ( depth > 0 ) p->drawLine(7, pos, 7, pos + len); } else { p->drawLine(7, pos, 7, pos + len); } } pos += len; } }
void KGridWidget::drawDeathIcon() { drawIcon(deathPng); }
void KGridWidget::drawDeathBorder() { drawIcon(borderPng); }
void KGridWidget::drawHitIcon() { drawIcon(hitPng); }
void KGridWidget::drawWaterIcon() { drawIcon(waterPng); }
void ImagedButton::drawItem(LPDRAWITEMSTRUCT dis) { HDC dc = dis->hDC; BOOL isPressed = (dis->itemState & ODS_SELECTED); BOOL isFocused = (dis->itemState & ODS_FOCUS); BOOL isDisabled = (dis->itemState & ODS_DISABLED); BOOL drawFocusRect = !(dis->itemState & ODS_NOFOCUSRECT); RECT itemRect = dis->rcItem; SetBkMode(dc, TRANSPARENT); if (m_isUsingTheme) { DWORD state = (isPressed) ? PBS_PRESSED : PBS_NORMAL; if (state == PBS_NORMAL) { if (isFocused) { state = PBS_DEFAULTED; } if (m_mouseOver) { state = PBS_HOT; } if (isDisabled) { state = PBS_DISABLED; } } ThemeLib::DrawThemeBackground(m_theme, dc, BP_PUSHBUTTON, state, &itemRect, NULL); } else { if (isFocused) { HBRUSH br = CreateSolidBrush(RGB(0,0,0)); FrameRect(dc, &itemRect, br); InflateRect(&itemRect, -1, -1); DeleteObject(br); } HBRUSH background = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); FillRect(dc, &itemRect, background); DeleteObject(background); if (isPressed) { HBRUSH shadow = CreateSolidBrush(GetSysColor(COLOR_BTNSHADOW)); FrameRect(dc, &itemRect, shadow); DeleteObject(shadow); } else { UINT uState = DFCS_BUTTONPUSH | ((m_mouseOver) ? DFCS_HOT : 0) | ((isPressed) ? DFCS_PUSHED : 0); DrawFrameControl(dc, &itemRect, DFC_BUTTON, uState); } } StringStorage title; getText(&title); RECT captionRect = dis->rcItem; TEXTMETRIC metric; GetTextMetrics(dc, &metric); RECT imageRect; calcRect(&itemRect, isPressed == TRUE, 0, metric.tmHeight, m_iconWidth, m_iconHeight, &captionRect, &imageRect); if (m_icon != NULL) { drawIcon(&dc, &imageRect, isPressed == TRUE, isDisabled == TRUE); } if (!title.isEmpty()) { if (isPressed && !m_isUsingTheme) { OffsetRect(&captionRect, 1, 1); } if (m_isUsingTheme) { WCHAR *unicodeString = new WCHAR[title.getLength() + 1]; size_t len = title.getLength(); title.toUnicodeString(unicodeString, &len); DWORD state = PBS_NORMAL; if (isDisabled) { state = PBS_DISABLED; } ThemeLib::DrawThemeText(m_theme, dc, BP_PUSHBUTTON, state, unicodeString, len, DT_CENTER | DT_VCENTER | DT_SINGLELINE, 0, &captionRect); delete[] unicodeString; } else { SetBkMode(dc, TRANSPARENT); if (isDisabled) { OffsetRect(&captionRect, 1, 1); SetTextColor(dc, ::GetSysColor(COLOR_3DHILIGHT)); DrawText(dc, title.getString(), -1, &captionRect, DT_WORDBREAK | DT_CENTER); OffsetRect(&captionRect, -1, -1); SetTextColor(dc, ::GetSysColor(COLOR_3DSHADOW)); DrawText(dc, title.getString(), -1, &captionRect, DT_WORDBREAK | DT_CENTER); } else { SetTextColor(dc, ::GetSysColor(COLOR_BTNTEXT)); SetBkColor(dc, ::GetSysColor(COLOR_BTNFACE)); DrawText(dc, title.getString(), -1, &captionRect, DT_WORDBREAK | DT_CENTER); } } } if (isFocused && drawFocusRect) { RECT focusRect = itemRect; InflateRect(&focusRect, -3, -3); DrawFocusRect(dc, &focusRect); } }
void KGridWidget::drawShipIcon(int ship, int part, bool rotate, bool hit) { switch(ship) { case 1: if(!rotate) drawIcon(ship1p1Png, hit); else drawIcon(ship1p1rPng, hit, false, rotate); break; case 2: switch(part) { case 1: if(!rotate) drawIcon(ship2p1Png, hit); else drawIcon(ship2p1rPng, hit, false, rotate); break; case 2: if(!rotate) drawIcon(ship2p2Png, hit); else drawIcon(ship2p2rPng, hit, false, rotate); break; } break; case 3: switch(part) { case 1: if(!rotate) drawIcon(ship3p1Png, hit); else drawIcon(ship3p1rPng, hit, false, rotate); break; case 2: if(!rotate) drawIcon(ship3p2Png, hit); else drawIcon(ship3p2rPng, hit, false, rotate); break; case 3: if(!rotate) drawIcon(ship3p3Png, hit); else drawIcon(ship3p3rPng, hit, false, rotate); break; } break; case 4: switch(part) { case 1: if(!rotate) drawIcon(ship4p1Png, hit); else drawIcon(ship4p1rPng, hit, false, rotate); break; case 2: if(!rotate) drawIcon(ship4p2Png, hit); else drawIcon(ship4p2rPng, hit, false, rotate); break; case 3: if(!rotate) drawIcon(ship4p3Png, hit); else drawIcon(ship4p3rPng, hit, false, rotate); break; case 4: if(!rotate) drawIcon(ship4p4Png, hit); else drawIcon(ship4p4rPng, hit, false, rotate); break; } break; } }
void KGridWidget::drawShipIcon(int type, bool rotate, bool hit, bool water) { int ship = 0; int part = 0; switch(type) { case KBattleField::SHIP1P1: ship = 1; part = 1; break; case KBattleField::SHIP2P1: ship = 2; if(!rotate) part = 1; else part = 2; break; case KBattleField::SHIP2P2: ship = 2; if(!rotate) part = 2; else part = 1; break; case KBattleField::SHIP3P1: ship = 3; if(!rotate) part = 1; else part = 3; break; case KBattleField::SHIP3P2: ship = 3; if(!rotate) part = 2; else part = 2; break; case KBattleField::SHIP3P3: ship = 3; if(!rotate) part = 3; else part = 1; break; case KBattleField::SHIP4P1: ship = 4; if(!rotate) part = 1; else part = 4; break; case KBattleField::SHIP4P2: ship = 4; if(!rotate) part = 2; else part = 3; break; case KBattleField::SHIP4P3: ship = 4; if(!rotate) part = 3; else part = 2; break; case KBattleField::SHIP4P4: ship = 4; if(!rotate) part = 4; else part = 1; break; } switch(ship) { case 1: if(!rotate) drawIcon(ship1p1Png, hit, water); else drawIcon(ship1p1rPng, hit, water, rotate); break; case 2: switch(part) { case 1: if(!rotate) drawIcon(ship2p1Png, hit, water); else drawIcon(ship2p1rPng, hit, water, rotate); break; case 2: if(!rotate) drawIcon(ship2p2Png, hit, water); else drawIcon(ship2p2rPng, hit, water, rotate); break; } break; case 3: switch(part) { case 1: if(!rotate) drawIcon(ship3p1Png, hit, water); else drawIcon(ship3p1rPng, hit, water, rotate); break; case 2: if(!rotate) drawIcon(ship3p2Png, hit, water); else drawIcon(ship3p2rPng, hit, water, rotate); break; case 3: if(!rotate) drawIcon(ship3p3Png, hit, water); else drawIcon(ship3p3rPng, hit, water, rotate); break; } break; case 4: switch(part) { case 1: if(!rotate) drawIcon(ship4p1Png, hit, water); else drawIcon(ship4p1rPng, hit, water, rotate); break; case 2: if(!rotate) drawIcon(ship4p2Png, hit, water); else drawIcon(ship4p2rPng, hit, water, rotate); break; case 3: if(!rotate) drawIcon(ship4p3Png, hit, water); else drawIcon(ship4p3rPng, hit, water, rotate); break; case 4: if(!rotate) drawIcon(ship4p4Png, hit, water); else drawIcon(ship4p4rPng, hit, water, rotate); break; } break; } }
/*! */ bool QFoldPanel::paint(QPainter *p, QEditor *e) { QDocument *doc = editor()->document(); QLanguageDefinition *def = e->languageDefinition(); if ( !def || !doc ) { return true; } m_rects.clear(); m_lines.clear(); bool bVisible = false; //, // inCursorBlock = false; int endHighlightLineNr = -1; int pos, max = doc->lines(), ls = doc->getLineSpacing(), pageBottom = e->viewport()->height(), contentsY = e->verticalOffset(); int xMid = 6, iconSize = 9, yIconOffset = (ls - iconSize) / 2; pos = - contentsY; //qDebug("beg pos : %i", pos); p->save(); QPen linePen(QColor(128,0,128)); linePen.setWidth(3); linePen.setCapStyle(Qt::FlatCap); p->setPen(linePen); QFoldedLineIterator fli = def->foldedLineIterator(doc); for (; fli.lineNr<max; ++fli) { if ( pos > pageBottom ) break; const QDocumentLine &line=fli.line; if ( fli.lineFlagsInvalid() ){ //correct folding when the folding of the current line is invalid //problems: slow (but O(n) like the paint method is anyways), doesn't work if panel is hidden //pro: simple, doesn't correct invalid, but invisible folding (e.g. like folding that is only temporary invalid, until the user writes a closing bracket; otherwise writing $$ would expand every folded $-block) doc->correctFolding(fli.lineNr, doc->lines()); //this will again call paint break; } if ( line.isHidden() ) { continue; } int len = ls * line.lineSpan(); bVisible = ((pos + len) >= 0); if (bVisible) { if ( fli.open ) { if ( line.hasFlag(QDocumentLine::CollapsedBlockStart) ) { // line above icon int topLineEnd = yIconOffset-1; if (topLineEnd > 0 && fli.lineNr <= endHighlightLineNr) p->drawLine(xMid, pos, xMid, pos + topLineEnd); // draw icon m_lines << fli.lineNr; m_rects << drawIcon(p, e, 2, pos + yIconOffset, true, fli.lineNr == m_lastMouseLine); // line below icon int bottomLineStart = yIconOffset + iconSize + 1; if (bottomLineStart < len && fli.lineNr < endHighlightLineNr) p->drawLine(xMid, pos + bottomLineStart, xMid, pos + len); } else { // line above icon int topLineEnd = yIconOffset; if (topLineEnd > 0 && fli.lineNr <= endHighlightLineNr) p->drawLine(xMid, pos, xMid, pos + topLineEnd); // draw icon m_lines << fli.lineNr; m_rects << drawIcon(p, e, 2, pos + yIconOffset, false, fli.lineNr == m_lastMouseLine); if (fli.lineNr == m_lastMouseLine) { QFoldedLineIterator findEnd = fli; findEnd.incrementUntilBlockEnd(); endHighlightLineNr = findEnd.lineNr; } // line below icon int bottomLineStart = yIconOffset + iconSize; if ( bottomLineStart < len && fli.lineNr < endHighlightLineNr) p->drawLine(xMid, pos + bottomLineStart, xMid, pos + len); } } else if (fli.lineNr <= endHighlightLineNr) { if ( fli.lineNr == endHighlightLineNr ) { int mid = pos + len - ls / 6; p->drawLine(xMid, pos, xMid, mid); // line ending here } else { p->drawLine(xMid, pos, xMid, pos + len); // line continues } } } pos += len; } p->restore(); return true; }
USHORT EXPENTRY sknDrawIcon(HSKIN skn, HPS hps, USHORT id, USHORT x, USHORT y) { return drawIcon(hps,skn->iconbar,id,x,y); }
//___________________________________________________ void Button::paint( QPainter& painter ) { QPalette palette( _client.palette() ); palette.setCurrentColorGroup( isActive() ? QPalette::Active : QPalette::Inactive); if( _client.compositingActive() && !( _client.isMaximized() || _type == ButtonItemClose || _type == ButtonItemMenu ) ) { painter.translate( 0, -1 ); } // translate buttons down if window maximized if( _client.isMaximized() ) painter.translate( 0, 1 ); // base button color QColor base; if( _type == ButtonItemClose && _forceInactive ) base = _client.backgroundPalette( this, palette ).window().color(); else if( _type == ButtonItemClose ) base = palette.window().color(); else base = palette.button().color(); // text color QColor color = (_type == ButtonItemClose && _forceInactive ) ? buttonDetailColor( _client.backgroundPalette( this, palette ) ): buttonDetailColor( palette ); // decide decoration color QColor glow; if( isAnimated() || (_status&Hovered) ) { glow = isCloseButton() ? _helper.viewNegativeTextBrush().brush(palette).color(): _helper.viewHoverBrush().brush(palette).color(); if( isAnimated() ) { color = KColorUtils::mix( color, glow, glowIntensity() ); glow = _helper.alphaColor( glow, glowIntensity() ); } else if( _status&Hovered ) color = glow; } if( hasDecoration() ) { // scale qreal scale( (21.0*_client.buttonSize())/22.0 ); // pressed state const bool pressed( (_status&Pressed) || ( _type == ButtonSticky && _client.isOnAllDesktops() ) || ( _type == ButtonAbove && _client.keepAbove() ) || ( _type == ButtonBelow && _client.keepBelow() ) ); // draw button shape painter.drawPixmap(0, 0, _helper.windecoButton( base, glow, pressed, scale ) ); } // Icon // for menu button the application icon is used if( isMenuButton() ) { int iconScale( 0 ); switch( _client.buttonSize() ) { case Configuration::ButtonSmall: iconScale = 13; break; default: case Configuration::ButtonDefault: iconScale = 16; break; case Configuration::ButtonLarge: iconScale = 20; break; case Configuration::ButtonVeryLarge: iconScale = 24; break; case Configuration::ButtonHuge: iconScale = 35; break; } const QPixmap& pixmap( _client.icon().pixmap( iconScale ) ); const double offset = 0.5*(width()-pixmap.width() ); painter.drawPixmap(offset, offset-1, pixmap ); } else { painter.setRenderHints(QPainter::Antialiasing); qreal width( 1.2 ); // contrast painter.setBrush(Qt::NoBrush); painter.setPen(QPen( _helper.calcLightColor( base ), width, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); drawIcon(&painter); // main painter.translate(0,-1.5); painter.setBrush(Qt::NoBrush); painter.setPen(QPen(color, width, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); drawIcon(&painter); } }
void FancyTabProxyStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *p, const QWidget *widget) const { const QStyleOptionTabV3 *v3Opt = qstyleoption_cast<const QStyleOptionTabV3*>(option); if (element != CE_TabBarTab || !v3Opt) { QProxyStyle::drawControl(element, option, p, widget); return; } const QRect rect = v3Opt->rect; const bool selected = v3Opt->state &State_Selected; const bool verticalTabs = v3Opt->shape == QTabBar::RoundedWest; const QString text = v3Opt->text; QTransform m; if (verticalTabs) { m = QTransform::fromTranslate(rect.left(), rect.bottom()); m.rotate(-90); } else { m = QTransform::fromTranslate(rect.left(), rect.top()); } const QRect draw_rect(QPoint(0, 0), m.mapRect(rect).size()); if (!selected && GtkStyle::isActive()) { p->fillRect(option->rect, option->palette.background()); } p->save(); p->setTransform(m); QRect iconRect(QPoint(8, 0), v3Opt->iconSize); QRect textRect(iconRect.topRight() + QPoint(4, 0), draw_rect.size()); textRect.setRight(draw_rect.width()); iconRect.translate(0, (draw_rect.height() - iconRect.height()) / 2); QStyleOptionViewItemV4 styleOpt; styleOpt.palette=option->palette; styleOpt.rect=draw_rect; if (QStyleOptionTab::Beginning==v3Opt->position) { styleOpt.rect.adjust(0, 0, -1, 0); } styleOpt.state=option->state; styleOpt.state&=~(QStyle::State_Selected|QStyle::State_MouseOver); styleOpt.state|=QStyle::State_Selected|QStyle::State_Enabled; styleOpt.viewItemPosition = QStyleOptionViewItemV4::OnlyOne; styleOpt.showDecorationSelected=true; bool drawBgnd=true; int fader = 1; if (!selected && drawBgnd) { const QString faderKey = "tab_" + text + "_fader"; const QString animationKey = "tab_" + text + "_animation"; const QString tab_hover = widget->property("tab_hover").toString(); fader=widget->property(faderKey.toUtf8().constData()).toInt(); QPropertyAnimation *animation = widget->property(animationKey.toUtf8().constData()).value<QPropertyAnimation*>(); if (!animation) { QWidget* mut_widget = const_cast<QWidget*>(widget); fader = 0; mut_widget->setProperty(faderKey.toUtf8().constData(), fader); animation = new QPropertyAnimation(mut_widget, faderKey.toUtf8(), mut_widget); connect(animation, SIGNAL(valueChanged(QVariant)), mut_widget, SLOT(update())); mut_widget->setProperty(animationKey.toUtf8().constData(), QVariant::fromValue(animation)); } if (text == tab_hover) { if (animation->state() != QAbstractAnimation::Running && fader != 40) { animation->stop(); animation->setDuration(80); animation->setEndValue(50); animation->start(); } } else { if (animation->state() != QAbstractAnimation::Running && fader != 0) { animation->stop(); animation->setDuration(160); animation->setEndValue(0); animation->start(); } } if (fader<1) { drawBgnd=false; } else { QColor col(styleOpt.palette.highlight().color()); col.setAlpha(fader); styleOpt.palette.setColor(styleOpt.palette.currentColorGroup(), QPalette::Highlight, col); } } if (drawBgnd) { if (!selected && GtkStyle::isActive()) { GtkStyle::drawSelection(styleOpt, p, (fader*1.0)/150.0); } else { #ifdef Q_OS_MAC OSXStyle::self()->drawSelection(styleOpt, p, selected ? 1.0 : (fader*1.0)/150.0); #else #ifdef Q_OS_WIN if (QPalette::Active!=styleOpt.palette.currentColorGroup()) { styleOpt.palette.setColor(QPalette::Highlight, styleOpt.palette.color(QPalette::Window).darker(110)); } #endif QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &styleOpt, p, 0); #endif } } int textFlags = Qt::AlignTop | Qt::AlignVCenter; #ifdef Q_OS_MAC p->setPen(selected && option->state&State_Active ? OSXStyle::self()->viewPalette().highlightedText().color() : OSXStyle::self()->viewPalette().foreground().color()); #else p->setPen(selected && option->state&State_Active ? QApplication::palette().highlightedText().color() : QApplication::palette().foreground().color()); #endif drawIcon(v3Opt->icon, iconRect, p, v3Opt->iconSize, selected && option->state&State_Active); QString txt=text; txt.replace("&", ""); txt=p->fontMetrics().elidedText(txt, elideMode(), textRect.width()); p->drawText(textRect.translated(0, -1), textFlags, txt); p->restore(); }
void UITextEdit::drawSelf(Fw::DrawPane drawPane) { if((drawPane & Fw::ForegroundPane) == 0) return; drawBackground(m_rect); drawBorder(m_rect); drawImage(m_rect); drawIcon(m_rect); //TODO: text rendering could be much optimized by using vertex buffer or caching the render into a texture int textLength = m_text.length(); const TexturePtr& texture = m_font->getTexture(); if(!texture) return; if(hasSelection()) { if(m_color != Color::alpha) { g_painter->setColor(m_color); for(int i=0;i<m_selectionStart;++i) g_painter->drawTexturedRect(m_glyphsCoords[i], texture, m_glyphsTexCoords[i]); } for(int i=m_selectionStart;i<m_selectionEnd;++i) { g_painter->setColor(m_selectionBackgroundColor); g_painter->drawFilledRect(m_glyphsCoords[i]); g_painter->setColor(m_selectionColor); g_painter->drawTexturedRect(m_glyphsCoords[i], texture, m_glyphsTexCoords[i]); } if(m_color != Color::alpha) { g_painter->setColor(m_color); for(int i=m_selectionEnd;i<textLength;++i) g_painter->drawTexturedRect(m_glyphsCoords[i], texture, m_glyphsTexCoords[i]); } } else if(m_color != Color::alpha) { g_painter->setColor(m_color); for(int i=0;i<textLength;++i) g_painter->drawTexturedRect(m_glyphsCoords[i], texture, m_glyphsTexCoords[i]); } // render cursor if(isExplicitlyEnabled() && m_cursorVisible && m_cursorInRange && isActive() && m_cursorPos >= 0) { assert(m_cursorPos <= textLength); // draw every 333ms const int delay = 333; int elapsed = g_clock.millis() - m_cursorTicks; if(elapsed <= delay) { Rect cursorRect; // when cursor is at 0 if(m_cursorPos == 0) cursorRect = Rect(m_rect.left()+m_padding.left, m_rect.top()+m_padding.top, 1, m_font->getGlyphHeight()); else cursorRect = Rect(m_glyphsCoords[m_cursorPos-1].right(), m_glyphsCoords[m_cursorPos-1].top(), 1, m_font->getGlyphHeight()); if(hasSelection() && m_cursorPos >= m_selectionStart && m_cursorPos <= m_selectionEnd) g_painter->setColor(m_selectionColor); else g_painter->setColor(m_color); g_painter->drawFilledRect(cursorRect); } else if(elapsed >= 2*delay) { m_cursorTicks = g_clock.millis(); } } g_painter->resetColor(); }
/* NOT [BDyess] 8/22/95 */ void dmessage(char *message, unsigned int flags, unsigned int from, unsigned int to) { struct distress dist; int len; /*char dead[20], alive[20];*/ /* aha! A new type distress/macro call came in. parse it appropriately */ if (F_gen_distress && (flags == (MTEAM | MDISTR | MVALID))) { if (paradise) printf("RCD: %s\n", message); HandleGenDistr(message, from, to, &dist); len = makedistress(&dist, message, distmacro[dist.distype].macro); if (UseLite) rcdlite(&dist); if (len <= 0) return; flags ^= MDISTR; } /* keep track of how many queued messages there are for use with the infoIcon [BDyess] */ if (infoIcon) { if (to == me->p_no && flags & MINDIV) { /* personal message */ me_messages++; } else if (flags & MTEAM) { /* team message */ team_messages++; } else { /* message for all */ all_messages++; } if (iconified) drawIcon(); } logit(message); /* fix for upgrade bug. Forced UDP would resend numbers, (thinking them speed changes) screwing up upgrading on those twinkish sturgeon servers. [BDyess] */ if (strncmp(message, "UPG->", 5) == 0) upgrading = 1; if (upgrading && !(me->p_flags & PFORBIT)) upgrading = 0; if ((from != me->p_no) || pigSelf) rsvp_borg_call(message, from); /* beep when a personal message is sent while iconified [BDyess] */ if (to == me->p_no && (flags & MINDIV) && iconified) { W_Beep(); } if (from == 255 && strcmp(message, "Tractor beam aborted warp engagement") == 0) { me->p_flags &= ~PFWARPPREP; } /* want a warning for personal kills, so check here [BDyess] */ /* and personal deaths [BDyess] */ if(strncmp(message,"GOD->ALL",8) && (0 == strcmp(message,pseudo))) { hwarning(message+9); } print_message(message, flags, from, to); }
void KGridWidget::drawSquare() { drawIcon(seaPng); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //agenttype_bitmap_notify //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void agenttype_bitmap_notify(agent *a, int notifytype, void *messagedata) { //Get the agent details agenttype_bitmap_details *details = (agenttype_bitmap_details *) a->agentdetails; styledrawinfo *di; int xpos, ypos; switch(notifytype) { case NOTIFY_DRAW: di = (styledrawinfo *) messagedata; if (details->is_icon) { HICON load_sysicon(wchar_t *filepath, int size); HICON hIcon = (HICON)LoadImage(plugin_instance_plugin, details->absolute_path, IMAGE_ICON, details->width, details->height, LR_LOADFROMFILE); // this one can retrieve the standard system icons also: if (NULL == hIcon) hIcon = load_sysicon(details->absolute_path, 32); if (NULL != hIcon) { switch (details->halign) { case 0: xpos = ((di->rect.right - di->rect.left) / 2) - (details->width / 2); break; case 1: xpos = 2; break; case 2: xpos = (di->rect.right - 2) - (details->width); break; } switch (details->valign) { case 0: ypos = ((di->rect.bottom - di->rect.top) / 2) - (details->height / 2); break; case 1: ypos = 2; break; case 2: ypos = (di->rect.bottom - 2) - (details->height); break; } drawIcon (xpos, ypos, details->width, (HICON) hIcon, di->buffer, di->apply_sat_hue); //DrawIconEx(di->buffer, xpos, ypos, (HICON) hIcon, details->width, details->height, 0, NULL, DI_NORMAL); DestroyIcon(hIcon); } } else { pImage = new Gdiplus::Image(details->absolute_path); if (NULL != pImage) { details->width = pImage->GetWidth() * ((double)details->scale / 100); details->height = pImage->GetHeight() * ((double)details->scale / 100); switch (details->halign) { case 0: xpos = ((di->rect.right - di->rect.left) / 2) - (details->width / 2); break; case 1: xpos = 2; break; case 2: xpos = (di->rect.right - 2) - (details->width); break; } switch (details->valign) { case 0: ypos = ((di->rect.bottom - di->rect.top) / 2) - (details->height / 2); break; case 1: ypos = 2; break; case 2: ypos = (di->rect.bottom - 2) - (details->height); break; } imageAttr = new Gdiplus::ImageAttributes(); imageAttr->SetColorKey(RGB(255,0,255), RGB(255,0,255)); graphics = new Gdiplus::Graphics(di->buffer); graphics->DrawImage(pImage, Gdiplus::Rect(xpos, ypos, details->width, details->height), 0, 0, pImage->GetWidth(), pImage->GetHeight(), Gdiplus::UnitPixel, imageAttr, NULL, NULL); delete imageAttr; delete graphics; delete pImage; } } break; case NOTIFY_SAVE_AGENT: //Write existance config_write(config_get_control_setagent_c(a->controlptr, a->agentaction, a->agenttypeptr->agenttypename, details->filename)); //Save properties if (details->is_icon) config_write(config_get_control_setagentprop_i(a->controlptr, a->agentaction, L"Size", &details->width)); else if (details->filename) config_write(config_get_control_setagentprop_i(a->controlptr, a->agentaction, L"Scale", &details->scale)); config_write(config_get_control_setagentprop_c(a->controlptr, a->agentaction, L"VAlign", image_valigns[details->valign])); config_write(config_get_control_setagentprop_c(a->controlptr, a->agentaction, L"HAlign", image_haligns[details->halign])); break; } }
/*! */ bool QFoldPanel::paint(QPainter *p, QEditor *e) { QDocument *doc = editor()->document(); QLanguageDefinition *def = e->languageDefinition(); if ( !def || !doc ) { return true; } m_rects.clear(); m_lines.clear(); bool bVisible = false; //, // inCursorBlock = false; int pos, max = doc->lines(), ls = doc->getLineSpacing(), pageBottom = e->viewport()->height(), contentsY = e->verticalOffset(); pos = - contentsY; //qDebug("beg pos : %i", pos); QFoldedLineIterator fli = def->foldedLineIterator(doc); bool oldFolding=false; for (; fli.lineNr<max; ++fli) { if ( pos > pageBottom ) break; const QDocumentLine &line=fli.line; if ( fli.lineFlagsInvalid() ){ //correct folding when the folding of the current line is invalid //problems: slow (but O(n) like the paint method is anyways), doesn't work if panel is hidden //pro: simple, doesn't correct invalid, but invisible folding (e.g. like folding that is only temporary invalid, until the user writes a closing bracket; otherwise writing $$ would expand every folded $-block) doc->correctFolding(fli.lineNr, doc->lines()); //this will again call paint return true; } if ( line.isHidden() ) { continue; } int len = ls * line.lineSpan(); // bool oldFolding = !fli.openParentheses.empty() && fli.openParentheses.first().line!=fli.lineNr; bVisible = ((pos + len) >= 0); if ( fli.open ) { if ( line.hasFlag(QDocumentLine::CollapsedBlockStart) ) { // outermost block folded : none of the opening is actually opened int bound = (ls - 8) / 2; int mid = pos + len - ls / 6; if ( bVisible ) { // draw icon if ( bound > 0 && oldFolding ) { p->drawLine(7, pos, 7, pos + bound); } if ( fli.close ) { p->drawLine(7, pos + 8 + bound, 7, mid); p->drawLine(7, mid, 12, mid); } m_lines << fli.lineNr; m_rects << drawIcon(p, e, 3, pos + bound, true); } int firstParenthesisPos = fli.openParentheses.size() - fli.open; const FoldedParenthesis firstParenthesis = fli.openParentheses[firstParenthesisPos]; while (fli.lineNr<doc->lines() && firstParenthesisPos<fli.openParentheses.size() && fli.openParentheses[firstParenthesisPos] == firstParenthesis){ if (fli.lineNr < doc->lines()-1 && !doc->line(fli.lineNr+1).isHidden()) { if ( bVisible ) p->drawLine(7, pos + 8 + bound, 7, pos + len); break; } ++fli; } if ( bVisible && !fli.openParentheses.empty() ) { if ( fli.close ) p->drawLine(7, mid, 7, pos + len); else p->drawLine(7, pos + 8 + bound, 7, pos + len); } } else { if ( bVisible ) { int bound = (ls - 8) / 2; if ( oldFolding && bound > 0 ) p->drawLine(7, pos, 7, pos + bound); m_lines << fli.lineNr; m_rects << drawIcon(p, e, 3, pos + bound, false); int mid = pos + len - ls / 6; if ( fli.close ) p->drawLine(7, mid, 12, mid); if ( bound > 0 ) p->drawLine(7, pos + 8 + bound, 7, pos + len); } } } else if ( (oldFolding) && bVisible ) { if ( fli.close ) { int mid = pos + len - ls / 6; p->drawLine(7, pos, 7, mid); p->drawLine(7, mid, 12, mid); if ( !fli.openParentheses.empty() ) p->drawLine(7, pos, 7, pos + len); } else { p->drawLine(7, pos, 7, pos + len); } } pos += len; oldFolding=!fli.openParentheses.empty(); } return true; }