KJFilename::KJFilename(const QStringList &l, KJLoader *p) : QObject(0), KJWidget(p), mBack(0) { int x = l[1].toInt(); int y = l[2].toInt(); int xs = l[3].toInt() - x; int ys = l[4].toInt() - y; // fix for all those weird skins where the filenamewindow has more // height than needed for the font // ( ... usually resulting in garbage on-screen ) if ( ys > (textFont().fontHeight()) ) ys = textFont().fontHeight(); // background under filename-scroller QPixmap tmp = p->pixmap(p->item("backgroundimage")[1]); mBack = new KPixmap ( QSize(xs,ys) ); bitBlt( mBack, 0, 0, &tmp, x, y, xs, ys, Qt::CopyROP ); setRect(x,y,xs,ys); // how far it moves per cycle // TODO: make that configurable for the user //mDistance = 1; // mDistance = (int)(textFont().fontWidth()/2); readConfig(); prepareString(i18n("Welcome to Noatun").local8Bit()); killTimers(); }
void KJFilename::readConfig() { kdDebug(66666) << "KJFilename::readConfig()" << endl; mDistance = (int)( textFont().fontWidth() * KJLoader::kjofol->prefs()->titleMovingDistance() ); if ( mDistance <= 0 ) mDistance = 1; mTimerUpdates = KJLoader::kjofol->prefs()->titleMovingUpdates(); textFont().recalcSysFont(); mLastTitle=""; // invalidate title so it gets repainted on next timeUpdate() }
QSize QseVerticalAxisWidget::minimumSizeHint() const { if (metricProvider()) switch (m_alignment) { case AlignLeft: case AlignRight: return QSize(QFontMetrics(textFont()).width( QString(m_provider->maximumTextLenght(), '0')) + metricSize() + 2, 0); case AlignHCenter: return QSize(QFontMetrics(textFont()).width( QString(m_provider->maximumTextLenght(), '0')) + metricSize() * 2 + 4, 0); } return QseAbstractAxisWidget::minimumSizeHint(); }
void draw() { background(gray(122)); if (Soloud_getActiveVoiceCount(soloud) > 0) { float * v = Soloud_calcFFT(soloud); int p = (int)(v[10] * 30); rect(10, 10, p * 10, 30); } if (keyReleased) { char sentence[20]; sprintf(sentence, "%c", key); destroyAudio(keySound); keySound = loadSpeech(sentence); playAudio(keySound); } textFont(font); textAlign(NVG_ALIGN_LEFT); textSize(30); textLeading(5); text(sentence, 10, 100); }
void displayInEditor(bool endflag, QString text, QString txtfont, QTextCursor cursor) { //QTextCursor mycursor(activeEditor()->textCursor()); if(endflag){ cursor.insertText("\n"); }//if QFont textFont("Courier"); textFont.setPixelSize(12); QFont boldFont("Arial"); boldFont.setPixelSize(12); if(txtfont == "bold"){ QTextCharFormat boldFormat; boldFormat.setFont(boldFont); boldFormat.setFontWeight(QFont::Bold); cursor.insertText(text, boldFormat); }//if else if (txtfont == "normal"){ QTextCharFormat textFormat; textFormat.setFont(textFont); textFormat.setFontWeight(QFont::Normal); cursor.insertText(text, textFormat); }//else if else if (txtfont == "underl"){ QTextCharFormat textFormat; textFormat.setFont(textFont); textFormat.setFontWeight(QFont::Normal); textFormat.setFontUnderline(true); cursor.insertText(text, textFormat); }//else if }
ZenTextEditor::ZenTextEditor(const String& componentName, const ImageBorderType& imageBorderType, const String& labelText, int componentWidth, int componentHeight) :TextEditor(componentName) { Component::setSize(componentWidth, componentHeight); setText(labelText); if (imageBorderType == LargeBorder) { leftEndImage = ImageCache::getFromMemory(ZenBinaryData::textFieldLargeBorderLeftEnd_png, ZenBinaryData::textFieldLargeBorderLeftEnd_pngSize); rightEndImage = ImageCache::getFromMemory(ZenBinaryData::textFieldLargeBorderRightEnd_png, ZenBinaryData::textFieldLargeBorderRightEnd_pngSize); centerImage = ImageCache::getFromMemory(ZenBinaryData::textFieldLargeBorderCenter_png, ZenBinaryData::textFieldLargeBorderCenter_pngSize); fullImage = ImageCache::getFromMemory(ZenBinaryData::textFieldLargeBorderFull_png, ZenBinaryData::textFieldLargeBorderFull_pngSize); } else { leftEndImage = ImageCache::getFromMemory(ZenBinaryData::textFieldSmallBorderLeftEnd_png, ZenBinaryData::textFieldSmallBorderLeftEnd_pngSize); rightEndImage = ImageCache::getFromMemory(ZenBinaryData::textFieldSmallBorderRightEnd_png, ZenBinaryData::textFieldSmallBorderRightEnd_pngSize); centerImage = ImageCache::getFromMemory(ZenBinaryData::textFieldSmallBorderCenter_png, ZenBinaryData::textFieldSmallBorderCenter_pngSize); fullImage = ImageCache::getFromMemory(ZenBinaryData::textFieldSmallBorderFull_png, ZenBinaryData::textFieldSmallBorderFull_pngSize); } this->setColour(textColourId, Colours::antiquewhite); this->setColour(backgroundColourId, Colour(0.0f)); //transparent background since we're drawing image this->setColour(highlightColourId, Colours::white); this->setColour(CaretComponent::caretColourId, Colour(0xffc3c3c3)); Typeface::Ptr tface = Typeface::createSystemTypefaceFor(ZenBinaryData::futurabook_ttf, ZenBinaryData::futurabook_ttfSize); Font textFont(tface); textFont.setHeight(14.0f); this->setFont(textFont); addComponentListener(this); setBorder(BorderSize<int>(1, 5, 1, 5 )); }
/*! Creates all widget primitives. */ void SnsrOledClockWidget::createPrimitives() { // TODO: final graphics will be named qtg_graf_screensaver_clock_oled_xxx. // not available in platform yet if (!mClockBackground) { mClockBackground = new HbIconItem(QLatin1String("qtg_graf_clock_night_bg"), this); HbStyle::setItemName(mClockBackground, QLatin1String("oled_clock_background")); } if (!mClockHourHand) { mClockHourHand = new HbIconItem(QLatin1String("qtg_graf_clock_night_hour"), this); HbStyle::setItemName(mClockHourHand, QLatin1String("oled_clock_hour_hand")); } if (!mClockMinuteHand) { mClockMinuteHand = new HbIconItem(QLatin1String("qtg_graf_clock_night_min"), this); HbStyle::setItemName(mClockMinuteHand, QLatin1String("oled_clock_minute_hand")); } if (!mClockAmPmLabel) { mClockAmPmLabel = new HbTextItem(this); HbStyle::setItemName(mClockAmPmLabel, QLatin1String("oled_clock_am_pm_label")); mClockAmPmLabel->setTextColor(SnsrColors::PowerSaveModeWidgetColor); mClockAmPmLabel->setMinimumLines(1); mClockAmPmLabel->setMaximumLines(1); mClockAmPmLabel->setTextWrapping(Hb::TextNoWrap); HbFontSpec textFont(HbFontSpec::Primary); qreal textHeight = 0; style()->parameter(QLatin1String("hb-param-text-height-tiny"), textHeight); textFont.setTextHeight(textHeight); mClockAmPmLabel->setFontSpec(textFont); } }
/** * Event: OnPaint * * Render the Notification Window */ LRESULT NotificationWindow::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { PAINTSTRUCT ps; BeginPaint(&ps); { MyGdiplusHelper gdi_plus_autostart; { // get draw area RECT clientRect; ::GetClientRect(m_hWnd, &clientRect); // create Gdiplus Graphics object Gdiplus::Graphics graphics(m_hWnd, FALSE); graphics.SetClip(Gdiplus::Rect(clientRect.left, clientRect.top, clientRect.right - clientRect.left, clientRect.bottom - clientRect.top)); // draw a background Gdiplus::SolidBrush backgroundBrush(Gdiplus::Color(DEFAULT_ALPHA, 255, 255, 255)); graphics.FillRectangle(&backgroundBrush, clientRect.left, clientRect.top, clientRect.right - clientRect.left, clientRect.bottom - clientRect.top); // shrink draw area int inset = 4; clientRect.left += inset; clientRect.top += inset; clientRect.right -= inset; clientRect.bottom -= inset; // whack a logo TODO //Bitmap* bitmap = new Bitmap(m_icon.c_str(), FALSE); int bitmapWidth = 0;//bitmap->GetWidth(); int bitmapHeight = 15;//bitmap->GetHeight(); //graphics->DrawImage(bitmap, clientRect.left, clientRect.top, //bitmapWidth, bitmapHeight); // draw a separator Gdiplus::Pen blackPen(Gdiplus::Color(0, 0, 0), 1.0f); graphics.DrawLine(&blackPen, clientRect.left, clientRect.top + bitmapHeight + inset, clientRect.right, clientRect.top + bitmapHeight + inset); // setup text properties Gdiplus::Font titleFont(L"Verdana", 10, Gdiplus::FontStyleBold); Gdiplus::Font textFont(L"Verdana", 10, Gdiplus::FontStyleRegular); Gdiplus::RectF titleRect((float)clientRect.left + inset + bitmapWidth, (float)clientRect.top, (float)clientRect.right, 20.0f); Gdiplus::RectF textRect((float)clientRect.left, (float)clientRect.top + bitmapHeight + (inset * 2), (float)clientRect.right, (float)clientRect.bottom - bitmapHeight - (inset * 2)); Gdiplus::StringFormat format; format.SetTrimming(Gdiplus::StringTrimmingEllipsisCharacter); format.SetFormatFlags(Gdiplus::StringFormatFlagsLineLimit); Gdiplus::SolidBrush blackBrush(Gdiplus::Color(255, 0, 0, 0)); // draw the message graphics.DrawString(m_title.c_str(), (int)m_title.length(), &titleFont, titleRect, &format, &blackBrush); graphics.DrawString(m_message.c_str(), (int)m_message.length(), &textFont, textRect, &format, &blackBrush); } } EndPaint(&ps); bHandled = TRUE; return 0; }
void SceneGraphNode::paint(QPainter* painter) { feather::status e; painter->setRenderHints(QPainter::Antialiasing, true); QPen trimPen = QPen(QColor(0,0,0),1); //trimPen.setStyle(Qt::NoPen); QPen textPen = QPen(QColor(NODE_TEXT_COLOR),2); QFont textFont("DejaVuSans",10); if(feather::smg::Instance()->selected(m_uid)) m_nodeFillBrush.setColor(QColor(SELECTED_NODE_COLOR)); else m_nodeFillBrush.setColor(QColor(DESELECTED_NODE_COLOR)); textFont.setBold((feather::smg::Instance()->selected(m_uid)) ? true : false); QBrush connInFillBrush = QBrush(QColor("#FF4500")); QBrush connOutFillBrush = QBrush(QColor("#DA70D6")); // set the node's height based on side with the most connections int max = 0; if(m_pInConns.size() > m_pOutConns.size()) max = m_pInConns.size(); else max = m_pOutConns.size(); //setWidth(NODE_WIDTH+4); //int height = (CONNECTION_HEIGHT * max) + NODE_HEIGHT; //setHeight(height+10); //setHeight(NODE_HEIGHT+44); // node trim painter->setPen(trimPen); // draw layer bar painter->setBrush(m_layerFillBrush); // draw title block painter->setBrush(m_nodeTitleBrush); painter->drawRect(CONNECTION_WIDTH+5,2,NODE_WIDTH-10,18); // draw the node block painter->setBrush(m_nodeFillBrush); painter->drawRect(CONNECTION_WIDTH,18,NODE_WIDTH,height()-20); // node icon QRectF tgt(CONNECTION_WIDTH + (NODE_WIDTH/2)-12,height()-24,24,24); QImage img(m_imgPath.str().c_str()); painter->drawImage(tgt,img); // node label painter->setPen(textPen); painter->setFont(textFont); std::string name; feather::qml::command::get_node_name(m_uid,name,e); painter->drawText(QRect(CONNECTION_WIDTH+5,2,NODE_WIDTH-10,18),Qt::AlignHCenter|Qt::AlignVCenter,name.c_str()); }
void KJFileInfo::prepareString(const QCString &str) { if ( str == mLastTime ) return; mLastTime = str; mTime = textFont().draw(str, rect().width()); repaint(); }
void KJFilename::prepareString(const QCString &str) { killTimers(); // i.e. stop timers mView = textFont().draw(str, rect().width()); startTimer(mTimerUpdates); }
void draw() { // Draw line to set the texts on top or below it fill(0); line( 0, height/2, width, height/2 ); // Text, left-bottom aligned (on top of the line ), with tahoma font fill( 255, 255, 0 ); textAlign( LEFT, BOTTOM ); textFont( tahoma, 20 ); text( "This a text (tahoma)... with left-bottom alignment\nwith another line here...", 0, height/2 ); // Text, right-top aligned (below the line), with calibri font fill( 0, 0, 255 ); textAlign( RIGHT, TOP ); textFont( calibri, 30 ); text( "This is blue line text (calibri), bigger and top-right aligned\nwith a new line here...", width, height/2); }
void PreferencesDialog::updatePreviewFont() { if (ui->spinDataBrowserFontSize->value() != 0) { QFont textFont(ui->comboDataBrowserFont->currentText()); textFont.setPointSize(ui->spinDataBrowserFontSize->value()); ui->txtRegular->setFont(textFont); textFont.setItalic(true); ui->txtNull->setFont(textFont); ui->txtBlob->setFont(textFont); } }
void CharacterDisplay::SetText(const wchar_t* szTxt) { if (!m_hDisplayRecord) return; if ( LTStrEquals(m_Text.GetText(),szTxt ) ) { return; } if (szTxt) { m_Text.SetText(szTxt); } uint32 nLen = LTStrLen(szTxt); HRECORD hFont = DATABASE_CATEGORY( CharacterDisplayLayoutDB ).GETRECORDATTRIB( m_hLayoutRecord, Font ); char const* pszFont = DATABASE_CATEGORY( CharacterDisplayLayoutDB ).GetString( hFont, "Face" ); if (nLen <= nTextLimits[0]) { CFontInfo textFont(pszFont,m_nTextSize[0]); textFont.m_nStyle = CFontInfo::kStyle_Bold; m_Text.SetFont(textFont); } else if (nLen <= nTextLimits[1]) { CFontInfo textFont(pszFont,m_nTextSize[1]); textFont.m_nStyle = CFontInfo::kStyle_Bold; m_Text.SetFont(textFont); } else { CFontInfo textFont(pszFont,m_nTextSize[2]); textFont.m_nStyle = CFontInfo::kStyle_Bold; m_Text.SetFont(textFont); } }
void EditDialog::reloadSettings() { // Set the databrowser font for the text editor but the (SQL) editor // font for hex editor, since it needs a Monospace font and the // databrowser font would be usually of variable width. QFont textFont(Settings::getValue("databrowser", "font").toString()); textFont.setPointSize(Settings::getValue("databrowser", "fontsize").toInt()); ui->editorText->setFont(textFont); QFont hexFont(Settings::getValue("editor", "font").toString()); hexFont.setPointSize(Settings::getValue("databrowser", "fontsize").toInt()); hexEdit->setFont(hexFont); sciEdit->reloadSettings(); }
void draw() { background(gray(122)); if (mousePressed) { image(img1, mouseX, mouseY, img1.width, img1.height); } else { image(img2, mouseX, mouseY, img2.width, img2.height); } textFont(font); textAlign(NVG_ALIGN_CENTER); textSize(30); textLeading(5); text("test everything here", width/2, height/2); }
MainWidget::MainWidget(GameLogic* gameLogic, QWidget* parent) : QWidget(parent) , mGameLogic(gameLogic) , mCardBoardWidget(new CardBoardWidget(gameLogic)) { setWindowTitle("Memory Puzzle"); setWindowModality(Qt::WindowModal); QFont textFont("Times", 12, QFont::Bold); mLevelLabel = new QLabel(QString("Level: %1").arg(mGameLogic->getCurrentLevel())); mLevelLabel->setAlignment(Qt::AlignLeft); mLevelLabel->setFont(textFont); mScoreLabel = new QLabel(QString("Score: %1").arg(mGameLogic->getTotalScore())); mScoreLabel->setAlignment(Qt::AlignCenter); mScoreLabel->setFont(textFont); mTimeLabel = new QLabel(QString("Time: %1").arg(QTime(0, 0, 0).toString("hh:mm:ss"))); mTimeLabel->setAlignment(Qt::AlignRight); mTimeLabel->setFont(textFont); QHBoxLayout* hLayout = new QHBoxLayout; hLayout->addWidget(mLevelLabel); hLayout->addWidget(mScoreLabel); hLayout->addWidget(mTimeLabel); mLevelLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); mScoreLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); mTimeLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); mCardBoardWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QVBoxLayout* vLayout = new QVBoxLayout; vLayout->addLayout(hLayout); vLayout->addWidget(mCardBoardWidget); resize(800, 600); setLayout(vLayout); connect(mGameLogic, SIGNAL(scoreChanged(int)), this, SLOT(scoreUpdated(int))); connect(mGameLogic, SIGNAL(timeChanged(int)), this, SLOT(timeUpdated(int))); }
ExtConsole::ExtConsole(QWidget *parent) : QFrame(parent), console_(0), capturedPieces_(0), showCapturedPieces_(false) { console_ = new QPlainTextEdit(this); capturedPieces_ = new CapturedPiecesView(this); // setFrameShape(console_->frameShape()); setFrameStyle(console_->frameStyle()); // console_->setFrameShape(QFrame::NoFrame); // console_->setReadOnly(true); console_->setFocusPolicy(Qt::NoFocus); console_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); console_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); console_->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); // QFont textFont("Sans", 8, QFont::Bold); console_->setFont(textFont); }
void SceneGraphConnection::paint(QPainter* painter) { painter->setRenderHints(QPainter::Antialiasing, true); if(!m_selected){ if(m_type == In) m_connFillBrush = QBrush(QColor(DESELECTED_IN_CONNECTOR_COLOR)); else m_connFillBrush = QBrush(QColor(DESELECTED_OUT_CONNECTOR_COLOR)); } else { m_connFillBrush = QBrush(QColor(SELECTED_CONNECTOR_COLOR)); } painter->setBrush(m_connFillBrush); // text block if(m_type == In) painter->drawRect(CONNECTION_WIDTH+2,0,width(),height()); else painter->drawRect(0,0,width()-CONNECTION_WIDTH,height()); QPen textPen(QColor(NODE_TEXT_COLOR),2); QFont textFont("DejaVuSans",7); painter->setPen(textPen); painter->setFont(textFont); if(m_type == In) { painter->drawText(QRect(CONNECTION_WIDTH+2,0,NODE_WIDTH/2,height()),Qt::AlignLeft|Qt::AlignVCenter,m_name); } else { painter->drawText(QRect(0,0,(NODE_WIDTH/2)-2,height()),Qt::AlignRight|Qt::AlignVCenter,m_name); } if(m_type == In) { painter->drawRect(0,0,CONNECTION_WIDTH,CONNECTION_HEIGHT); } else { painter->drawRect(NODE_WIDTH/2,0,CONNECTION_WIDTH,CONNECTION_HEIGHT); } }
void QPlasmaTextDoc::setSyntax(SyntaxMode syn) { fSyntax = syn; switch (fSyntax) { case kStxConsole: fEditor->setLexer(fLexerFNI); break; case kStxFX: fEditor->setLexer(fLexerFX); break; case kStxHex: fEditor->setLexer(fLexerHEX); break; case kStxIni: fEditor->setLexer(fLexerINI); break; case kStxPython: fEditor->setLexer(fLexerPY); break; case kStxSDL: fEditor->setLexer(fLexerSDL); break; case kStxXML: fEditor->setLexer(fLexerXML); break; default: fEditor->setLexer(NULL); { QSettings settings("PlasmaShop", "PlasmaShop"); QFont textFont(settings.value("SciFont", PLAT_FONT).toString(), settings.value("SciFontSize", 10).toInt(), settings.value("SciFontWeight", QFont::Normal).toInt(), settings.value("SciFontItalic", false).toBool()); fEditor->setFont(textFont); } } }
void BpDocument::composeTable1( void ) { // START THE STANDARD PREAMBLE USED BY ALL TABLE COMPOSITION FUNCTIONS. // WIN98 requires that we actually create a font here and use it for // font metrics rather than using the widget's font. QFont textFont( property()->string( "tableTextFontFamily" ), property()->integer( "tableTextFontSize" ) ); QPen textPen( property()->color( "tableTextFontColor" ) ); QFontMetrics textMetrics( textFont ); QFont titleFont( property()->string( "tableTitleFontFamily" ), property()->integer( "tableTitleFontSize" ) ); QPen titlePen( property()->color( "tableTitleFontColor" ) ); QFontMetrics titleMetrics( titleFont ); QFont valueFont( property()->string( "tableValueFontFamily" ), property()->integer( "tableValueFontSize" ) ); QPen valuePen( property()->color( "tableValueFontColor" ) ); QFontMetrics valueMetrics( valueFont ); // Store pixel resolution into local variables. double yppi = m_screenSize->m_yppi; double xppi = m_screenSize->m_xppi; double textHt, titleHt, valueHt; textHt = ( textMetrics.lineSpacing() + m_screenSize->m_padHt ) / yppi; titleHt = ( titleMetrics.lineSpacing() + m_screenSize->m_padHt ) / yppi; valueHt = ( valueMetrics.lineSpacing() + m_screenSize->m_padHt ) / yppi; // END THE STANDARD PREAMBLE USED BY ALL TABLE COMPOSITION FUNCTIONS QString results(""); translate( results, "BpDocument:Table:Results" ); // Determine variable label, value, and units minimum column widths. int nameWdPixels = 0; int resultWdPixels = 0; int unitsWdPixels = 0; int vid, len; QString qStr; EqVar *varPtr; // Loop for each output variable. for ( vid = 0; vid < tableVars(); vid++ ) { varPtr = tableVar(vid); // Label width. len = textMetrics.width( *(varPtr->m_label) ); if ( len > nameWdPixels ) { nameWdPixels = len; } // Units width. len = textMetrics.width( varPtr->m_displayUnits ); if ( len > unitsWdPixels ) { unitsWdPixels = len; } // Value width. if ( varPtr->isContinuous() ) { qStr.sprintf( "%1.*f", varPtr->m_displayDecimals, tableVal(vid) ); len = valueMetrics.width( qStr ); if ( len > resultWdPixels ) { resultWdPixels = len; } } else if ( varPtr->isDiscrete() ) { int iid = (int) tableVal(vid); qStr = varPtr->m_itemList->itemName(iid); len = valueMetrics.width( varPtr->m_itemList->itemName(iid) ); if ( len > resultWdPixels ) { resultWdPixels = len; } } } // Add padding for differences in screen and printer font sizes int wmPad = textMetrics.width( "WM" ); unitsWdPixels += wmPad; nameWdPixels += wmPad; resultWdPixels += valueMetrics.width( "WM" ); // If the name is too wide for the page, reduce the name field width. if ( ( nameWdPixels + unitsWdPixels + resultWdPixels + 2 * m_screenSize->m_padWd ) > m_screenSize->m_bodyWd ) { nameWdPixels = m_screenSize->m_bodyWd - resultWdPixels - unitsWdPixels - 2 * m_screenSize->m_padWd; } // Convert name and units widths from pixels to inches. double resultWd = (double) resultWdPixels / xppi; double nameWd = (double) nameWdPixels / xppi; double unitsWd = (double) unitsWdPixels / xppi; // Determine offset (inches) required to horizontally center the table. double offsetX = ( m_screenSize->m_bodyWd - nameWdPixels - resultWdPixels - ( unitsWdPixels - wmPad ) - 2 * m_screenSize->m_padWd ) / ( 2. * xppi ); // Determine column offsets. double nameColX = m_pageSize->m_marginLeft + offsetX; double resultColX = nameColX + nameWd + m_pageSize->m_padWd; double unitsColX = resultColX + resultWd + m_pageSize->m_padWd; // Open the composer and start with a new page. startNewPage( results, TocListOut ); double yPos = m_pageSize->m_marginTop + titleHt; // Print the table header. m_composer->font( titleFont ); // use tableTitleFont m_composer->pen( titlePen ); // use tableTitleFontColor qStr = m_eqTree->m_eqCalc->docDescriptionStore().stripWhiteSpace(); //if ( qStr.isNull() || qStr.isEmpty() ) //{ // translate( qStr, "BpDocument:NoRunDescription" ); //} m_composer->text( m_pageSize->m_marginLeft, yPos, // start at UL corner m_pageSize->m_bodyWd, titleHt, // width and height Qt::AlignVCenter|Qt::AlignCenter, // center alignment qStr ); // display description yPos += titleHt; // Draw each output variable on its own line. m_composer->font( textFont ); m_composer->pen( textPen ); for ( vid = 0; vid < tableVars(); vid++ ) { varPtr = tableVar(vid); if ( varPtr->isDiagram() ) { continue; } // Get the next y position. if ( ( yPos += textHt ) > m_pageSize->m_bodyEnd ) { startNewPage( results, TocBlank ); yPos = m_pageSize->m_marginTop; } // Write the variable name. m_composer->font( textFont ); // use tableTextFont m_composer->pen( textPen ); // use tableTextFontColor qStr = *(varPtr->m_label); // display label text m_composer->text( nameColX, yPos, // start at UL corner nameWd, textHt, // width and height Qt::AlignVCenter|Qt::AlignLeft, // left justified qStr ); // display label text // Continuous variable value and units. if ( varPtr->isContinuous() ) { qStr.sprintf( "%1.*f", varPtr->m_displayDecimals, tableVal(vid) ); m_composer->font( valueFont ); // use tableValueFont m_composer->pen( valuePen ); // use tableValueFontColor m_composer->text( resultColX, yPos, // start at UL corner resultWd, valueHt, // width and height Qt::AlignVCenter|Qt::AlignRight, // right justified qStr ); // display value text m_composer->font( textFont ); // use tableTextFont m_composer->pen( textPen ); // use tableTextFontColor m_composer->text( unitsColX, yPos, // start at UL corner unitsWd, textHt, // width and height Qt::AlignVCenter|Qt::AlignLeft, // left justified varPtr->displayUnits() ); // display units text } // Discrete variable value name else if ( varPtr->isDiscrete() ) { int id = (int) tableVal(vid); m_composer->font( valueFont ); // use tableValueFont m_composer->pen( valuePen ); // use tableValueFontColor m_composer->text( resultColX, yPos, // start at UL corner resultWd, valueHt, // width and height Qt::AlignVCenter|Qt::AlignRight, // right justify varPtr->m_itemList->itemName(id) ); // display item name } } // Write any prescription results if ( false && property()->boolean( "tableShading" ) ) { // Get the next y position. if ( ( yPos += textHt ) > m_pageSize->m_bodyEnd ) { startNewPage( results, TocBlank ); yPos = m_pageSize->m_marginTop; } // Write the prescription label m_composer->font( textFont ); // use tableTextFont m_composer->pen( textPen ); // use tableTextFontColor translate( qStr, "BpDocument:Results:RxVar:Label" ); m_composer->text( nameColX, yPos, // start at UL corner nameWd, textHt, // width and height Qt::AlignVCenter|Qt::AlignLeft, // left justified qStr ); // display label text // Write the result translate( qStr, tableInRx(0) ? "BpDocument:Results:RxVar:Yes" : "BpDocument:Results:RxVar:No" ); m_composer->font( valueFont ); // use tableValueFont m_composer->pen( valuePen ); // use tableValueFontColor m_composer->text( resultColX, yPos, // start at UL corner resultWd, valueHt, // width and height Qt::AlignVCenter|Qt::AlignRight, // right justify qStr ); // display item name } // Be polite and stop the composer. m_composer->end(); // Write the spreadsheet files composeTable1Spreadsheet(); composeTable1Html(); return; }
void QseVerticalAxisWidget::recalcProviderMinimumSize(QseAbstractMetricProvider *provider) { if (provider) provider->setMinimumStep(QFontMetrics(textFont()).height() * 2.0); }
void QPlasmaTextDoc::updateSettings() { QSettings settings("PlasmaShop", "PlasmaShop"); QFont textFont(settings.value("SciFont", PLAT_FONT).toString(), settings.value("SciFontSize", 10).toInt(), settings.value("SciFontWeight", QFont::Normal).toInt(), settings.value("SciFontItalic", false).toBool()); fEditor->setLexer(NULL); if (fLexersInited) { delete fLexerFNI; delete fLexerFX; delete fLexerHEX; delete fLexerINI; delete fLexerPY; delete fLexerSDL; delete fLexerXML; } fLexerFNI = new QsciLexerFni(fEditor); fLexerFX = new QsciLexerFX(fEditor); fLexerHEX = new QsciLexerHexIsle(fEditor); fLexerINI = new QsciLexerProperties(fEditor); fLexerPY = new QsciLexerPython(fEditor); fLexerSDL = new QsciLexerSDL(fEditor); fLexerXML = new QsciLexerXML(fEditor); fLexersInited = true; fLexerFNI->setDefaultFont(textFont); fLexerFX->setDefaultFont(textFont); fLexerHEX->setDefaultFont(textFont); fLexerINI->setDefaultFont(textFont); fLexerPY->setDefaultFont(textFont); fLexerSDL->setDefaultFont(textFont); fLexerXML->setDefaultFont(textFont); fEditor->setWhitespaceForegroundColor(QColor(0xA0, 0xA0, 0xA0)); QFont braceFont = textFont; braceFont.setBold(true); fEditor->setMatchedBraceFont(braceFont); fEditor->setUnmatchedBraceFont(braceFont); QPalette pal; fEditor->setMarginsBackgroundColor(pal.color(QPalette::Active, QPalette::Window)); fEditor->setMarginsForegroundColor(pal.color(QPalette::Active, QPalette::WindowText)); fEditor->setMatchedBraceForegroundColor(QColor(0x00, 0x00, 0xff)); fEditor->setUnmatchedBraceForegroundColor(QColor(0xff, 0x00, 0x00)); fEditor->setBraceMatching(QsciScintilla::SloppyBraceMatch); fEditor->setTabWidth(settings.value("SciTabWidth", 4).toInt()); fEditor->setIndentationsUseTabs(!settings.value("SciUseSpaces", true).toBool()); fEditor->setAutoIndent(settings.value("SciAutoIndent", true).toBool()); fEditor->setIndentationGuides(settings.value("SciIndentGuides", false).toBool()); fEditor->setWhitespaceVisibility(settings.value("SciShowWhitespace", false).toBool() ? QsciScintilla::WsVisible : QsciScintilla::WsInvisible); fEditor->setEdgeColor(QColor(0xE0, 0xE0, 0xE0)); fEditor->setEdgeMode(settings.value("SciLongLineMark", false).toBool() ? QsciScintilla::EdgeLine : QsciScintilla::EdgeNone); fEditor->setEdgeColumn(settings.value("SciLongLineSize", 80).toInt()); // Margin Magic (tm) fEditor->setMarginWidth(MARGIN_LINES, 0); fEditor->setMarginWidth(MARGIN_FOLDERS, 0); if (settings.value("SciMargin", true).toBool()) { fDoLineNumbers = settings.value("SciLineNumberMargin", true).toBool(); if (settings.value("SciFoldMargin", true).toBool()) fEditor->setFolding(QsciScintilla::BoxedTreeFoldStyle, MARGIN_FOLDERS); fEditor->setMarginLineNumbers(MARGIN_LINES, fDoLineNumbers); adjustLineNumbers(); if (!fDoLineNumbers) fEditor->setMarginWidth(MARGIN_LINES, 16); } else { fDoLineNumbers = false; fEditor->setMarginLineNumbers(MARGIN_LINES, false); } setSyntax(fSyntax); fEditor->setMarginsFont(textFont); adjustLineNumbers(); }
void BpDocument::composeGraphBasics( Graph *g, bool isLineGraph, EqVar *xVar, EqVar *yVar, EqVar *zVar, int curves, GraphAxleParms *xParms, GraphAxleParms *yParms ) { //-------------------------------------------------------------------------- // Set the logical fonts and colors here //-------------------------------------------------------------------------- // Axis text fonts. QFont textFont( property()->string( "graphTextFontFamily" ), property()->integer( "graphTextFontSize" ) ); QPen textPen( property()->color( "graphTextFontColor" ) ); QFont axleFont( textFont ); QColor axleColor( property()->color( "graphAxleColor" ) ); QPen axlePen( axleColor, property()->integer( "graphAxleWidth" ), Qt::SolidLine ); QPen gridPen( property()->color( "graphGridColor" ), property()->integer( "graphGridWidth" ), Qt::SolidLine ); // Title fonts and colors. QFont subTitleFont( property()->string( "graphSubtitleFontFamily" ), property()->integer( "graphSubtitleFontSize" ) ); QColor subTitleColor( property()->color( "graphSubtitleFontColor" ) ); QFont titleFont( property()->string( "graphTitleFontFamily" ), property()->integer( "graphTitleFontSize" ) ); QColor titleColor( property()->color( "graphTitleFontColor" ) ); // Background and canvas colors. QBrush worldBg( property()->color( "graphBackgroundColor" ), Qt::SolidPattern ); QBrush canvasBg( "white", SolidPattern ); QPen canvasBox( "black", 1, NoPen ); //-------------------------------------------------------------------------- // Create the graph canvas, world, and decoration. //-------------------------------------------------------------------------- // Get the x- and y-axle parameters double xValMin = xParms->m_axleMin; double xValMax = xParms->m_axleMax; double xMajorStep = xParms->m_majorStep; int xDec = xParms->m_decimals; double yValMin = yParms->m_axleMin; double yValMax = yParms->m_axleMax; double yMajorStep = yParms->m_majorStep; int yDec = yParms->m_decimals; // Graph title and subtitle. QString qStr = m_eqTree->m_eqCalc->docDescriptionStore().stripWhiteSpace(); //if ( qStr.isNull() || qStr.isEmpty() ) //{ // translate( qStr, "BpDocument:NoRunDescription" ); //} g->setTitle( qStr, titleFont, titleColor ); if ( property()->boolean( "graphTitleActive" ) ) { QString text(""); translate( text, "BpDocument:Graphs:By" ); qStr = *(yVar->m_label) + "\n" + text + " " + *(xVar->m_label); if ( curves > 1 && isLineGraph && zVar ) { translate( text, "BpDocument:Graphs:And" ); qStr += "\n" + text + " " + *(zVar->m_label); } g->setSubTitle( qStr, subTitleFont, subTitleColor ); } // Use portrait orientation (assuming screen output, not printer). g->setCanvasRotation( 0.0 ); g->setCanvasScale( 1.0, 1.0 ); // NOTE: to change the graph location or size, // we must manipulate the m_composer->graph() args! g->setCanvas( m_screenSize->m_marginLeft, // upper left X pixel m_screenSize->m_marginTop, // upper left Y pixel m_screenSize->m_bodyWd, // graph canvas width in pixels m_screenSize->m_bodyHt, // graph canvas height in pixels 0 // graph border in pixels ); // Canvas background and box. g->setCanvasBg( canvasBg ); g->setCanvasBox( canvasBox ); // Make the world coordinate system 20% larger than the data range. g->setWorld( xValMin - 0.2 * (xValMax-xValMin), // canvas WORLD left coordinate yValMin - 0.2 * (yValMax-yValMin), // canvas WORLD bottom coordinate xValMax + 0.1 * (xValMax-xValMin), // canvas WORLD right coordinate yValMax + 0.1 * (yValMax-yValMin) // canvas WORLD top coordinate ); // Provide a colored background for the graph area. g->setWorldBg( xValMin, // colored bg WORLD left coordinate yValMin, // colored bg WORLD bottom coordinate xValMax, // colored bg WORLD right coordinate yValMax, // colored bg WORLD top coordinate worldBg // brush color and pattern ); //-------------------------------------------------------------------------- // Create a bottom axle with endpoints in WORLD coordinates (not AXLE). // This has all elements of an axle EXCEPT a minor grid and subtitle. //-------------------------------------------------------------------------- GraphAxle *b = g->addGraphAxle( xValMin, // axle's min scale (NOT WORLD) value xValMax, // axle's max scale (NOT WORLD) value axlePen // axle line pen (color, width, style) ); b->setWorld( xValMin, // axle's start WORLD x coordinate yValMin, // axle's start WORLD y coordinate xValMax, // axle's end WORLD x coordinate yValMin // axle's end WORLD y coordinate ); // Line graph bottom axles need labels and tic marks. if ( isLineGraph ) { b->setMajorLabels( axleFont, // label font axleColor, // font color xDec // decimal places (-1 mean no label) ); b->setMajorTics( GraphAxleBottom, // side of axle to draw tic marks xValMin, // first tic mark location in AXLE units xValMax, // last tic mark location in AXLE units xMajorStep, // tic spacing in AXLE units 0.05 * (yValMax-yValMin), // tic mark length in Y WORLD units axlePen // tic pen (color, width, style) ); b->setMinorTics( GraphAxleBottom, // side of axle to draw tic marks xValMin, // first tic mark location in AXLE units xValMax, // last tic mark location in AXLE units 0.50 * xMajorStep, // tic spacing in AXLE units 0.03 * (yValMax-yValMin), // tic mark length in Y WORLD units axlePen // tic pen (color, width, style) ); b->setMajorGrid( gridPen, // grid pen color, width, style (yValMax-yValMin) // length in Y WORLD units !! ); // Don't show the units for ratio variables. qStr = *(xVar->m_label) + " " + xVar->displayUnits(true); b->setTitle( qStr, // axle title string GraphAxleBottom, // axle side to write the string axleFont, // axle title font axleColor // axle title color ); } // Bar graphs just need the title. else { b->setTitle( *(xVar->m_label), // axle title string GraphAxleBottom, // axle side to write the string axleFont, // axle title font axleColor // axle title color ); } //-------------------------------------------------------------------------- // Create a top axle with endpoints in WORLD coordinates (not AXLE) // Same as bottom axle EXCEPT no tic labels or axle label //-------------------------------------------------------------------------- // Line graph top axles need tic marks. if ( isLineGraph ) { GraphAxle *t = g->addGraphAxle( xValMin, // axle's min scale (NOT WORLD) value xValMax, // axle's max scale (NOT WORLD) value axlePen // axle line pen (color, width, style) ); t->setWorld( xValMin, // axle's start WORLD x coordinate yValMax, // axle's start WORLD y coordinate xValMax, // axle's end WORLD x coordinate yValMax // axle's end WORLD y coordinate ); if ( false ) t->setMajorTics( GraphAxleTop, // side of axle to draw tic marks xValMin, // first tic mark location in AXLE units xValMax, // last tic mark location in AXLE units xMajorStep, // tic spacing in AXLE units 0.05 * (yValMax-yValMin), // tic mark length in WORLD units axlePen // tic pen (color, width, style) ); if ( false ) t->setMinorTics( GraphAxleTop, // side of axle to draw tic marks xValMin, // first tic mark location in AXLE units xValMax, // last tic mark location in AXLE units 0.50 * xMajorStep, // tic spacing in AXLE units 0.03 * (yValMax-yValMin), // tic mark length in WORLD units axlePen // tic pen (color, width, style) ); } //-------------------------------------------------------------------------- // Create a left axle with endpoints in WORLD coordinates (not AXLE) // This has all elements of an axle EXCEPT a minor grid and subtitle //-------------------------------------------------------------------------- GraphAxle *l = g->addGraphAxle( yValMin, // axle's min scale (NOT WORLD) value yValMax, // axle's max scale (NOT WORLD) value axlePen // axle line pen (color, width, style) ); l->setWorld( xValMin, // axle's start WORLD x coordinate yValMin, // axle's start WORLD y coordinate xValMin, // axle's end WORLD x coordinate yValMax // axle's end WORLD y coordinate ); l->setMajorLabels( axleFont, // label font axleColor, // font color yDec // decimal places (-1 mean no label) ); l->setMajorTics( GraphAxleLeft, // side of axle to draw tic marks yValMin, // first tic mark location in AXLE units yValMax, // last tic mark location in AXLE units yMajorStep, // tic spacing in AXLE units 0.04 * (xValMax-xValMin), // tic mark length in X WORLD units axlePen // tic pen (color, width, style) ); l->setMinorTics( GraphAxleLeft, // side of axle to draw tic marks yValMin, // first tic mark location in AXLE units yValMax, // last tic mark location in AXLE units 0.50 * yMajorStep, // tic spacing in AXLE units 0.02 * (xValMax-xValMin), // tic mark length in X WORLD units axlePen // tic pen (color, width, style) ); l->setMajorGrid( gridPen, // grid pen color, width, style (xValMax-xValMin) // length in X axis WORLD units !! ); // Don't show the units for fraction or ratio variables. qStr = *(yVar->m_label) + " " + yVar->displayUnits(true); l->setTitle( qStr, // axle title string GraphAxleLeft, // axle side to write the string axleFont, // axle title font axleColor // axle title font color ); //-------------------------------------------------------------------------- // Create a right axle with endpoints in WORLD coordinates (not AXLE) // Same as the left axle EXCEPT no tic labels or axle label. //-------------------------------------------------------------------------- GraphAxle *r = g->addGraphAxle( yValMin, // axle's min scale (NOT WORLD) value yValMax, // axle's max scale (NOT WORLD) value axlePen // axle line pen (color, width, style) ); r->setWorld( xValMax, // axle's start WORLD x coordinate yValMin, // axle's start WORLD y coordinate xValMax, // axle's end WORLD x coordinate yValMax // axle's end WORLD y coordinate ); if ( false ) r->setMajorTics( GraphAxleRight, // side of axle to draw tic marks yValMin, // first tic mark location in AXLE units yValMax, // last tic mark location in AXLE units yMajorStep, // tic spacing in AXLE units 0.04 * (xValMax-xValMin), // tic mark length in X WORLD units axlePen // tic pen (color, width, style) ); if ( false ) r->setMinorTics( GraphAxleLeft, // side of axle to draw tic marks yValMin, // first tic mark location in AXLE units yValMax, // last tic mark location in AXLE units 0.50 * yMajorStep, // tic spacing in AXLE units 0.02 * (xValMax-xValMin), // tic mark length in X WORLD units axlePen // tic pen (color, width, style) ); return; }
void BpDocument::composeBarGraph( int yid, EqVar *xVar, EqVar *yVar, GraphAxleParms *xParms, GraphAxleParms *yParms ) { //-------------------------------------------------------------------------- // 1: Set up fonts, pens, and colors used by this graph //-------------------------------------------------------------------------- // Graph fonts. QFont textFont( property()->string( "graphTextFontFamily" ), property()->integer( "graphTextFontSize" ) ); QColor textColor( property()->color( "graphTextFontColor" ) ); QPen textPen( textColor ); // How many colors are requested? QString colorName( property()->color( "graphBarColor" ) ); int colors = 1; if ( colorName == "rainbow" ) { colors = property()->integer( "graphRainbowColors" ); } // Allocate number of requested colors. QColor *color = new QColor [colors]; checkmem( __FILE__, __LINE__, color, "QColor color", colors ); int colorId = 0; // If only 1 color... if ( colors == 1 ) { color[0].setNamedColor( colorName ); } // else if rainbow colors are requested. else { // \todo - add some code to check conflicts with graphBackgroundColor // and graphGridColor (if graphGridWidth > 0 ). int hue = 0; for ( colorId = 0; colorId < colors; colorId++ ) { color[colorId].setHsv( hue, 255, 255); hue += 360 / colors; } colorId = 0; } // Setup bar brush and color QBrush barBrush( color[colorId], Qt::SolidPattern ); //-------------------------------------------------------------------------- // 2: Create the graph and its text and axles. //-------------------------------------------------------------------------- // Initialize graph and variables Graph g; int bars = ( tableRows() < graphMaxBars ) ? tableRows() : graphMaxBars ; int vStep = tableVars(); // Draw thew basic graph (axis and text) composeGraphBasics( &g, false, xVar, yVar, 0, bars, xParms, yParms ); //-------------------------------------------------------------------------- // 3: Add the bars. //-------------------------------------------------------------------------- // Each bar occupies 2/3 of its x range, plus a 1/3 padding on right. double xMin = xParms->m_axleMin; double xMax = xParms->m_axleMax; double xMinorStep = ( xMax - xMin ) / (double) ( 3 * bars + 1 ); double xMajorStep = 3. * xMinorStep; // Create each data bar and add it to the graph. double x0, x1, y0, y1, xl; double yl = 0.; double rotation = 0.; QString label; int row, vid; for ( row = 0, vid = yid; row < bars; row++, vid += vStep ) { x0 = xMin + xMinorStep + row * xMajorStep; x1 = xMin + ( row + 1 ) * xMajorStep; y0 = yParms->m_axleMin; y1 = tableVal( vid ); xl = 0.5 * (x0 + x1) ; // If we're out of colors, start over. if ( colorId >= colors ) { colorId = 0; } // Set the bar brush to this color. barBrush.setColor( color[colorId++] ); // Create the graph bar. GraphBar *bar = g.addGraphBar( x0, y0, x1, y1, barBrush, textPen ); // Create the bar label. int iid = (int) tableRow( row ); label = xVar->m_itemList->itemName( iid ); bar->setGraphBarLabel( label, xl, yl, textFont, textColor, rotation ); } //-------------------------------------------------------------------------- // 4: Add an output page on which to draw the graph. //-------------------------------------------------------------------------- // Create a separate page for this graph. QString text(""); translate( text, "BpDocument:Graphs:By" ); label = QString( "%1 %2 %3" ) .arg( *(yVar->m_label) ) .arg( text ) .arg( *(xVar->m_label) ); startNewPage( label, TocBarGraph ); // This is how we save the graph and its composer. m_composer->graph( g, m_pageSize->m_marginLeft + m_pageSize->m_bodyWd * property()->real( "graphXOffset" ), m_pageSize->m_marginTop + m_pageSize->m_bodyHt * property()->real( "graphYOffset" ), m_pageSize->m_bodyWd * property()->real( "graphScaleWidth" ), m_pageSize->m_bodyHt * property()->real( "graphScaleHeight" ) ); // Be polite and stop the composer. m_composer->end(); delete[] color; return; }
void BpDocument::composeTable3( int vid, EqVar *rowVar, EqVar *colVar ) { // START THE STANDARD PREAMBLE USED BY ALL TABLE COMPOSITION FUNCTIONS. // WIN98 requires that we actually create a font here and use it for // font metrics rather than using the widget's font. QFont subTitleFont( property()->string( "tableSubtitleFontFamily" ), property()->integer( "tableSubtitleFontSize" ) ); QPen subTitlePen( property()->color( "tableSubtitleFontColor" ) ); QFontMetrics subTitleMetrics( subTitleFont ); QFont textFont( property()->string( "tableTextFontFamily" ), property()->integer( "tableTextFontSize" ) ); QPen textPen( property()->color( "tableTextFontColor" ) ); QFontMetrics textMetrics( textFont ); QFont titleFont( property()->string( "tableTitleFontFamily" ), property()->integer( "tableTitleFontSize" ) ); QPen titlePen( property()->color( "tableTitleFontColor" ) ); QFontMetrics titleMetrics( titleFont ); QFont valueFont( property()->string( "tableValueFontFamily" ), property()->integer( "tableValueFontSize" ) ); QPen valuePen( property()->color( "tableValueFontColor" ) ); QFontMetrics valueMetrics( valueFont ); bool doRowBg = property()->boolean( "tableRowBackgroundColorActive" ); QBrush rowBrush( property()->color( "tableRowBackgroundColor" ), Qt::SolidPattern ); QString text(""); // Store pixel resolution into local variables. double yppi = m_screenSize->m_yppi; double xppi = m_screenSize->m_xppi; double m_padWd = m_pageSize->m_padWd; // Determine the height of the various display fonts. double textHt, titleHt, valueHt, rowHt, x0, x1; textHt = ( textMetrics.lineSpacing() + m_screenSize->m_padHt ) / yppi; titleHt = ( titleMetrics.lineSpacing() + m_screenSize->m_padHt ) / yppi; valueHt = ( valueMetrics.lineSpacing() + m_screenSize->m_padHt ) / yppi; rowHt = ( textHt > valueHt ) ? textHt : valueHt; // END THE STANDARD PREAMBLE USED BY ALL TABLE COMPOSITION FUNCTIONS. // Determine the number of rows we can display on a page. int rowsPerPage = (int) ( ( m_pageSize->m_bodyHt - 5. * titleHt - 4. * textHt ) / rowHt ); // Number of pages the table requires to accomodate all the rows. int pagesLong = 1 + (int) ( tableRows() / rowsPerPage ); // Arrays to hold the output values' column information. // Page on which the output value column appears. int *colPage = new int[ tableCols() ]; checkmem( __FILE__, __LINE__, colPage, "int colPage", tableCols() ); // Horizontal position of each output value column. double *colXPos = new double[ tableCols() ]; checkmem( __FILE__, __LINE__, colXPos, "double colXPos", tableCols() ); // Column header text. QString *colText = new QString[ tableCols() ]; checkmem( __FILE__, __LINE__, colText, "double colText", tableCols() ); // Prescription shading? bool doRx = property()->boolean( "tableShading" ); bool doBlank = property()->boolean( "tableShadingBlank" ); // Determine the row variable's (left-most) column width. int row, iid, cell; double len; QString qStr; // Start wide enough to hold the variable name and units. double rowWd = m_padWd + ( (double) headerWidth( rowVar, textMetrics ) / xppi ); // Enlarge it to hold the fattest row value. m_rowDecimals = 0; for ( row = 0; row < tableRows(); row++ ) { if ( rowVar->isDiscrete() ) { iid = (int) tableRow( row ); qStr = rowVar->m_itemList->itemName( iid ) + "MMM"; } else if ( rowVar->isContinuous() ) { // CDB DECIMALS MOD if ( false ) { qStr.sprintf( "%1.*fMMM", rowVar->m_displayDecimals, tableRow( row ) ); } else { // Start with 6 decimals for this row value int decimals = 6; qStr.sprintf( "%1.*f", decimals, tableRow( row ) ); // Remove all trailing zeros while ( qStr.endsWith( "0" ) ) { qStr = qStr.left( qStr.length()-1 ); decimals--; } // Update m_rowDecimals digits m_rowDecimals = ( decimals > m_rowDecimals ) ? decimals : m_rowDecimals; qStr.append( "MWM" ); } } len = (double) textMetrics.width( qStr ) / xppi; if ( len > rowWd ) { rowWd = len; } } // Find the fattest output value for this table variable. int col; int out = vid; EqVar *outVar = tableVar(vid); double colWd = 0; for ( row = 0; row < tableRows(); row++ ) { for ( col = 0; col < tableCols(); col++ ) { if ( outVar->isDiscrete() ) { iid = (int) tableVal( out ); qStr = outVar->m_itemList->itemName( iid ) + "WM"; } else if ( outVar->isContinuous() ) { qStr.sprintf( "%1.*fWM", outVar->m_displayDecimals, tableVal( out ) ); } len = (double) textMetrics.width( qStr ) / xppi; if ( len > colWd ) { colWd = len; } out += tableVars(); } // Next table column. } // Next table row. // Set the column header value text. m_colDecimals = 0; for ( col = 0; col < tableCols(); col++ ) { if ( colVar->isDiscrete() ) { iid = (int) tableCol( col ); colText[col] = colVar->m_itemList->itemName( iid ); } else if ( colVar->isContinuous() ) { // CDB DECIMALS MOD if ( false ) { colText[col].sprintf( " %1.*f", colVar->m_displayDecimals, tableCol( col ) ); } else { // Start with 6 decimals for this row value int decimals = 6; colText[col].sprintf( " %1.*f", decimals, tableCol( col ) ); // Remove all trailing zeros while ( colText[col].endsWith( "0" ) ) { colText[col] = colText[col].left( colText[col].length()-1 ); decimals--; } // Update Decimals digits m_colDecimals = ( decimals > m_colDecimals ) ? decimals : m_colDecimals; } } // Expand the column width to accomodate the header value text? len = (double) textMetrics.width( colText[col] ) / xppi; if ( len > colWd ) { colWd = len; } } // Next table column. // CDB DECIMALS MOD for ( col = 0; col < tableCols(); col++ ) { if ( colVar->isContinuous() ) { colText[col].sprintf( " %1.*f", m_colDecimals, tableCol( col ) ); } } // Add padding between each column. colWd += m_padWd; // Determine each column's position on each page. int pagesWide = 1; // Horizontal position of first column on the first page. double xpos = m_pageSize->m_bodyLeft + rowWd + 2. * m_padWd; for ( col = 0; col < tableCols(); col++ ) { // If past the right page edge, start a new page. if ( xpos + colWd > m_pageSize->m_bodyRight ) { // The table page width has just increased. pagesWide++; // This will be the first column on the new page. xpos = m_pageSize->m_bodyLeft + rowWd + 2. * m_padWd; } // Store the page and position of this output variable's column. colXPos[col] = xpos; colPage[col] = pagesWide; // Update the position pointer. xpos += ( 2. * m_padWd + colWd ); } // Determine the column title width (inches). double colTitleWd = textMetrics.width( *(colVar->m_label) ) / xppi; if ( ( textMetrics.width( colVar->m_displayUnits ) / xppi ) > colTitleWd ) { colTitleWd = textMetrics.width( colVar->m_displayUnits ) / xppi; } colTitleWd += ( 2. * m_padWd ); // Determine an offset shift to center each pageAcross. double *shift = new double[ pagesWide + 1 ]; checkmem( __FILE__, __LINE__, shift, "double shift", pagesWide + 1 ); for ( col = 0; col < tableCols(); col++ ) { // Table must be at least this wide. double minLeft = m_pageSize->m_bodyLeft + rowWd + 2. * m_padWd + colTitleWd; // Does it need to be wider to accomodate this column? if ( colXPos[col] + colWd > minLeft ) { minLeft = colXPos[col] + colWd; } // Just the last column of each page finally gets stored in shift[]. shift[colPage[col]] = 0.5 * ( m_pageSize->m_bodyRight - minLeft ); } // Start drawing the table. double yPos, s, bgLeft, bgRight, rightEdge, leftEdge; int i; // Loop for each page down. int thisPage = 1; for ( int pageDown = 1; pageDown <= pagesLong; pageDown++ ) { // Loop for each page across. for ( int pageAcross = 1; pageAcross <= pagesWide; pageAcross++, thisPage++ ) { // Table title indicates the table portion translate( text, "BpDocument:Table:PageOf", *(tableVar(vid)->m_label), QString( "%1" ).arg( thisPage ), QString( "%1" ).arg( pagesLong * pagesWide ) ); // Start a new page startNewPage( text, TocTable ); yPos = m_pageSize->m_marginTop + titleHt; // Draw a map of where we are. composePageMap( ( 2. * titleHt - 0.1 ), pagesLong, pagesWide, pagesLong, pagesWide, 1, 1, pageDown-1, pageAcross-1 ); // Display the table title::description m_composer->font( titleFont ); // use tableTitleFont m_composer->pen( titlePen ); // use tableTitleFontColor qStr = m_eqTree->m_eqCalc->docDescriptionStore().stripWhiteSpace(); m_composer->text( m_pageSize->m_marginLeft, yPos, // start at UL corner m_pageSize->m_bodyWd, titleHt,// width and height Qt::AlignVCenter|Qt::AlignHCenter, // center alignement qStr ); // display description yPos += titleHt; // Display the table title::variable m_composer->font( subTitleFont ); // use tableSubtitleFont m_composer->pen( subTitlePen ); // use tableSubtitleFontColor qStr = *(outVar->m_label); if ( outVar->isContinuous() ) { qStr = *(outVar->m_label) + " " + outVar->displayUnits(true); } m_composer->text( m_pageSize->m_marginLeft, yPos, // start at UL corner m_pageSize->m_bodyWd, titleHt,// width and height Qt::AlignVCenter|Qt::AlignHCenter, // center alignment qStr ); // table variable name yPos += titleHt; // Display the table title::portion //m_composer->text( // m_pageSize->m_marginLeft, yPos, // m_pageSize->m_bodyWd, titleHt, // Qt::AlignVCenter|Qt::AlignHCenter, // portion ); //yPos += titleHt; yPos += titleHt; // Everything else on this page is shifted s = shift[pageAcross]; // Determine left and right edges of the table. leftEdge = -1; for ( col = 0; col < tableCols(); col++ ) { if ( pageAcross == colPage[col] ) { rightEdge = colXPos[col] + colWd + s; if ( leftEdge < 0. ) { leftEdge = colXPos[col] + s; } } } // Must be at least wide enough to accomodate column header text. if ( rightEdge < leftEdge + colTitleWd ) { rightEdge = leftEdge + colTitleWd; } bgLeft = m_pageSize->m_marginLeft + s - m_padWd ; bgRight = rightEdge - leftEdge + rowWd + 4 * m_padWd ; // Display a colored row column header background? if ( doRowBg ) { m_composer->fill( bgLeft, yPos, bgRight, 3 * textHt, rowBrush ); } // Display the row column header0. m_composer->font( textFont ); // use tableTextFont m_composer->pen( textPen ); // use tableTextFontColor m_composer->text( m_pageSize->m_marginLeft + s, yPos, rowWd, textHt, Qt::AlignVCenter|Qt::AlignLeft, *(rowVar->m_hdr0) ); // Display the row column header1. m_composer->text( m_pageSize->m_marginLeft + s, yPos + textHt, rowWd, textHt, Qt::AlignVCenter|Qt::AlignLeft, *(rowVar->m_hdr1) ); // Display the row column units. m_composer->text( m_pageSize->m_marginLeft + s, yPos + 2. * textHt, rowWd, textHt, Qt::AlignVCenter|Qt::AlignLeft, rowVar->displayUnits() ); // Display the row column header underline // only if we are not coloring row backgrounds. int skipLines = 3; if ( ! doRowBg ) { m_composer->line( m_pageSize->m_marginLeft + s, yPos + 3.5 * textHt, m_pageSize->m_marginLeft + rowWd + s, yPos + 3.5 * textHt ); skipLines = 4; } // Display the output column headers. for ( col = 0; col < tableCols(); col++ ) { if ( pageAcross == colPage[col] ) { // Display the output column units. m_composer->text( colXPos[col] + s, yPos + 2. * textHt, colWd, textHt, Qt::AlignVCenter|Qt::AlignRight, colText[col] ); // Display the output column underline. if ( ! doRowBg ) { m_composer->line( colXPos[col] + s, yPos + 3.5 * textHt, colXPos[col] + colWd + s, yPos + 3.5 * textHt ); } } } // Display a centered column variable name and units header. m_composer->text( leftEdge, yPos, ( rightEdge - leftEdge ), textHt, Qt::AlignVCenter|Qt::AlignHCenter, *(colVar->m_label) ); if ( colVar->isContinuous() ) { m_composer->text( leftEdge, yPos + textHt, ( rightEdge - leftEdge ), textHt, Qt::AlignVCenter|Qt::AlignHCenter, colVar->displayUnits() ); } // If there are previous columns, display a visual cue. if ( pageAcross > 1 ) { for ( i = 0; i < 3; i++ ) { m_composer->text( 0, ( yPos + i * textHt ), ( m_pageSize->m_marginLeft + s - m_padWd ), textHt, Qt::AlignVCenter|Qt::AlignRight, "<" ); } } // If there are subsequent column pages, display a visual clue. if ( pageAcross < pagesWide ) { for ( i = 0; i < 3; i++ ) { m_composer->text( ( rightEdge + m_padWd ), ( yPos + i * textHt ), ( m_pageSize->m_pageWd - rightEdge ), textHt, Qt::AlignVCenter|Qt::AlignLeft, ">" ); } } // Set vertical start of rows. yPos += skipLines * textHt; // Determine the rows range to display on this page. int rowFrom = ( pageDown - 1 ) * rowsPerPage; int rowThru = pageDown * rowsPerPage - 1; if ( rowThru >= tableRows() ) { rowThru = tableRows() - 1; } // Determine the columns range to display on this page. int colFrom = -1; int colThru = 0; for ( col = 0; col < tableCols(); col++ ) { if ( colPage[col] == pageAcross ) { if ( colFrom == -1 ) { colFrom = col; } colThru = col; } } // Loop for each row on this page. bool doThisRowBg = false; for ( row = rowFrom; row <= rowThru; row++ ) { // Display a colored row background? if ( doRowBg && doThisRowBg ) { m_composer->fill( bgLeft, yPos, bgRight, textHt, rowBrush ); } doThisRowBg = ! doThisRowBg; // Left-most (row variable) column value. if ( rowVar->isDiscrete() ) { iid = (int) tableRow( row ); qStr = rowVar->m_itemList->itemName( iid ); } else if ( rowVar->isContinuous() ) { // CDB DECIMALS MOD if ( false ) { qStr.sprintf( "%1.*f", rowVar->m_displayDecimals, tableRow( row ) ); } else { qStr.sprintf( "%1.*f", m_rowDecimals, tableRow( row ) ); } } m_composer->font( textFont ); // use tableTextFont m_composer->pen( textPen ); // use tableTextFontColor m_composer->text( m_pageSize->m_marginLeft + s, yPos, rowWd, textHt, Qt::AlignVCenter|Qt::AlignLeft, qStr ); // Loop for each column value on this page. m_composer->font( valueFont ); // use tableValueFont m_composer->pen( valuePen ); // use tableValueFontColor out = vid + colFrom * tableVars() + row * tableCols() * tableVars(); for ( col = colFrom; col <= colThru; col++ ) { // Determine whether to hatch this cell cell = col + row * tableCols(); bool hatch = doRx && ! tableInRx( cell ); // Discrete variables use their item name. if ( outVar->isDiscrete() ) { iid = (int) tableVal( out ); qStr = outVar->m_itemList->itemName( iid ); } // Continuous variables use the current display units format. else if ( outVar->isContinuous() ) { qStr.sprintf( " %1.*f", outVar->m_displayDecimals, tableVal( out ) ); } // Display the output value. if ( hatch && doBlank ) { // draw nothing } else { m_composer->text( colXPos[col] + s, yPos, colWd, textHt, Qt::AlignVCenter|Qt::AlignRight, qStr ); } out += tableVars(); // RX hatching if ( hatch && ! doBlank && ! outVar->isDiagram() ) { x0 = colXPos[col] + s - m_padWd; x1 = colXPos[col] + s + m_padWd + colWd; m_composer->line( x0, yPos, x1, ( yPos + textHt ) ); m_composer->line( x0, ( yPos + textHt ), x1, yPos ); } } // Next table output variable. yPos += rowHt; } // Next table row. } // Next pageAcross. } // Next pageDown. // Be polite and stop the composer. m_composer->end(); // Clean up and return. delete[] colPage; delete[] colXPos; delete[] colText; delete[] shift; return; }
void KPrMSPresentation::initCreation( KProgress *progressBar ) { int p; // the title images, and the subsequent real images need to // be in a file under DCIM/, and they start at 101MSPJP, so // we create the DCIM file, and then iterate through looking // for the next "available" directory slot KURL str( path + "/DCIM" ); KIO::NetAccess::mkdir( str,( QWidget* )0L ); p = progressBar->progress(); progressBar->setProgress( ++p ); kapp->processEvents(); for (int dirNum = 101; dirNum < 999; dirNum++) { slidePath = QString("/DCIM/%1MSPJP").arg(dirNum); if (! KIO::NetAccess::exists(( path + slidePath), true, ( QWidget* )0L) ) break; } p = progressBar->progress(); progressBar->setProgress( ++p ); kapp->processEvents(); str = ( path + slidePath ); KIO::NetAccess::mkdir( str,( QWidget* )0L ); p = progressBar->progress(); progressBar->setProgress( ++p ); kapp->processEvents(); // now do the SPP file directory str = ( path + "/MSSONY" ); KIO::NetAccess::mkdir( str,( QWidget* )0L ); p = progressBar->progress(); progressBar->setProgress( ++p ); kapp->processEvents(); str = ( path + "/MSSONY/PJ" ); KIO::NetAccess::mkdir( str,( QWidget* )0L ); p = progressBar->progress(); progressBar->setProgress( ++p ); kapp->processEvents(); // create the title slides QPixmap titleSlide( 1024, 768 ); titleSlide.fill( backColour ); QPainter painter( &titleSlide ); //the second title is just blank, so create that now KTempFile tmp; QString filename = path + slidePath + "/SPJT0002.JPG"; titleSlide.save( tmp.name(), "JPEG" ); KIO::NetAccess::file_move( tmp.name(), filename, -1, true /*overwrite*/); p = progressBar->progress(); progressBar->setProgress( ++p ); kapp->processEvents(); // and put the specified title string on the first slide QFont textFont( "SansSerif", 96 ); painter.setFont( textFont ); painter.setPen( textColour ); painter.drawText( titleSlide.rect(), Qt::AlignCenter | Qt::WordBreak, title ); filename = path + slidePath + "/SPJT0001.JPG"; KTempFile tmp2; titleSlide.save( tmp2.name(), "JPEG" ); KIO::NetAccess::file_move( tmp2.name(), filename, -1, true /*overwrite*/); p = progressBar->progress(); progressBar->setProgress( ++p ); kapp->processEvents(); }
void BpDocument::composeLineGraph( int yid, EqVar *xVar, EqVar *yVar, EqVar *zVar, GraphAxleParms *xParms, GraphAxleParms *yParms ) { //-------------------------------------------------------------------------- // 1: Set up fonts, pens, and colors used by this graph //-------------------------------------------------------------------------- // Graph fonts QFont textFont( property()->string( "graphTextFontFamily" ), property()->integer( "graphTextFontSize" ) ); QColor textColor( property()->color( "graphTextFontColor" ) ); QPen textPen( textColor ); // How many colors are requested? QString colorName( property()->color( "graphLineColor" ) ); int colors = 1; if ( colorName == "rainbow" ) { colors = property()->integer( "graphRainbowColors" ); } // Allocate number of requested colors. QColor *color = new QColor [colors]; checkmem( __FILE__, __LINE__, color, "QColor color", colors ); int colorId = 0; // If only 1 color... if ( colors == 1 ) { color[0].setNamedColor( colorName ); } // else if rainbow colors are requested... else { // todo - add some code to check conflicts with graphBackgroundColor // and graphGridColor (if graphGridWidth > 0 ). int hue = 0; for ( colorId = 0; colorId < colors; colorId++ ) { color[colorId].setHsv( hue, 255, 255); hue += 360 / colors; } colorId = 0; } // Set up line width and color int lineWidth = property()->integer( "graphLineWidth" ); QPen pen( color[0], lineWidth, SolidLine ); //-------------------------------------------------------------------------- // 2: Create the graph and add its curves. //-------------------------------------------------------------------------- // Initialize graph and variables Graph g; GraphLine *line[graphMaxLines]; double l_x[graphMaxSteps]; double l_y[graphMaxSteps]; int curves = ( tableCols() < graphMaxLines ) ? ( tableCols() ) : ( graphMaxLines ); int points = tableRows(); int vStep = tableCols() * tableVars(); // Loop for each zVar family curve value in this graph (or at least once!). // Note that zVar count is in tableCols(), e.g. each column stores a curve, // and zVar values are in tableCol( col ). int col, vid; for ( col = 0; col < curves; col++ ) { // tableVal[] offset of first y-value for this curve. vid = yid + col * tableVars(); // Set up the y[point] array for this curve. // Note number of points is in tableRows() and // point x values are in tableRow( point ). for ( int point = 0; point < points; point++ ) { l_x[point] = tableRow( point ); l_y[point] = tableVal( vid ); vid += vStep; } // If we're out of colors, start over. if ( colorId >= colors ) { colorId = 0; } // Create a graph line (with its own copy of the data). pen.setColor( color[colorId++] ); line[col] = g.addGraphLine( points, l_x, l_y, pen ); } // Next z-variable curve. //-------------------------------------------------------------------------- // 3: Add curve labels if there is more than 1 curve. //-------------------------------------------------------------------------- QString label; if ( curves > 1 ) { colorId = 0; #define GRAPH_LABEL_METHOD_1 #ifdef GRAPH_LABEL_METHOD_1 // Label x array index step size between labels int j1 = points / curves; if ( j1 < 1 ) { j1 = 1; } // Label x array index offset int j0 = j1 / 2; #endif double xLabel, yLabel; int idx; // Loop for each z-variable curve. for ( col = 0; col < curves; col++ ) { // Get a new color for the curve. if ( colorId >= colors ) { colorId = 0; } // Set the curve label. if ( zVar->isDiscrete() ) { int iid = (int) tableCol( col ); label = zVar->m_itemList->itemName( iid ); } else if ( zVar->isContinuous() ) { int decimals = zVar->m_displayDecimals; label.sprintf( "%1.*f", zVar->m_displayDecimals, tableCol( col ) ); // Remove all trailing zeros while ( decimals && label.endsWith( "0" ) ) { label = label.left( label.length()-1 ); decimals--; } } #ifdef GRAPH_LABEL_METHOD_1 // Determine an x-axis index for the label position. idx = ( j0 + col * j1 ) % points; xLabel = line[col]->m_x[idx]; yLabel = line[col]->m_y[idx]; #endif #ifdef GRAPH_LABEL_METHOD_2 // NEW LABEL POSITIONING METHOD STARTS HERE // Find the x position where this variable has the maximum y // clearance // Loop for each x value for this curve idx = 0; double dMax = 0; double dir = 1.; double yMin = yParms->m_axleMin; double yMax = yParms->m_axleMax; for ( int row=1; row<tableRows()-1; row++ ) { // Find vertical clearance above and below this x point double y0 = m_eqTree->getResult( row, col, yid ); // Don't consider locations outside the viewport if ( y0 < yMin || y0 > yMax ) { continue; } double below = y0 - yMin; double above = yMax - y0; double dist, y1; // Loop for each family member curve for ( int c=0; c<curves; c++ ) { // Skip self if ( c == col ) { continue; } y1 = m_eqTree->getResult( row, c, yid ); y1 = ( y1 < yMax ) ? y1 : yMax; y1 = ( y1 > yMin ) ? y1 : yMin; // Shrink vertical clearance above and below this x point? if ( y0 <= y1 ) { dist = y1 - y0; above = ( dist < above ) ? dist : above; } else { dist = y0 - y1; below = ( dist < below ) ? dist : below; } } // Is this the maximum vertical clearance so far? if ( above + below > dMax ) { dMax = above + below; idx = row; dir = ( above > below ) ? 1. : -1; } } xLabel = line[col]->m_x[idx]; double offset = dir * 0.02 * ( yMax - yMin ); yLabel = line[col]->m_y[idx] + offset; #endif // Set the label text, font, color, and position. line[col]->setGraphLineLabel( label, xLabel, yLabel, textFont, QColor( color[colorId++] ) ); } // Next curve. // Add a z-variable label to the graph. label = *(zVar->m_label); if ( zVar->isContinuous() ) { label = *(zVar->m_label) + "\n" + zVar->displayUnits(true); } g.setMultipleCurveLabel( label ); } //-------------------------------------------------------------------------- // 4: Compose the graph and add an output page to draw it onto //-------------------------------------------------------------------------- composeGraphBasics( &g, true, xVar, yVar, zVar, curves, xParms, yParms ); // Create a separate output page for this graph. QString text(""); translate( text, "BpDocument:Graphs:By" ); label = *(yVar->m_label) + " " + text + " " + *(xVar->m_label); if ( curves > 1 ) { translate( text, "BpDocument:Graphs:And" ); label += " " + text + " " + *(zVar->m_label); } startNewPage( label, TocLineGraph ); // This is how we save the graph and its composer. m_composer->graph( g, m_pageSize->m_marginLeft + m_pageSize->m_bodyWd * property()->real( "graphXOffset" ), m_pageSize->m_marginTop + m_pageSize->m_bodyHt * property()->real( "graphYOffset" ), m_pageSize->m_bodyWd * property()->real( "graphScaleWidth" ), m_pageSize->m_bodyHt * property()->real( "graphScaleHeight" ) ); // Be polite and stop the composer. m_composer->end(); delete[] color; return; }
void QgsGCPCanvasItem::paint( QPainter* p ) { QgsRenderContext context; if ( !setRenderContextVariables( p, context ) ) { return; } p->setRenderHint( QPainter::Antialiasing ); bool enabled = true; QgsPoint worldCoords; int id = -1; if ( mDataPoint ) { enabled = mDataPoint->isEnabled(); worldCoords = mDataPoint->mapCoords(); id = mDataPoint->id(); } p->setOpacity( enabled ? 1.0 : 0.3 ); // draw the point p->setPen( Qt::black ); p->setBrush( mPointBrush ); p->drawEllipse( -2, -2, 5, 5 ); QSettings s; bool showIDs = s.value( "/Plugin-GeoReferencer/Config/ShowId" ).toBool(); bool showCoords = s.value( "/Plugin-GeoReferencer/Config/ShowCoords" ).toBool(); QString msg; if ( showIDs && showCoords ) { msg = QString( "%1\nX %2\nY %3" ).arg( QString::number( id ) ).arg( QString::number( worldCoords.x(), 'f' ) ).arg( QString::number( worldCoords.y(), 'f' ) ); } else if ( showIDs ) { msg = msg = QString::number( id ); } else if ( showCoords ) { msg = QString( "X %1\nY %2" ).arg( QString::number( worldCoords.x(), 'f' ) ).arg( QString::number( worldCoords.y(), 'f' ) ); } if ( !msg.isEmpty() ) { p->setBrush( mLabelBrush ); QFont textFont( "helvetica" ); textFont.setPixelSize( fontSizePainterUnits( 12, context ) ); p->setFont( textFont ); QRectF textBounds = p->boundingRect( 3 * context.scaleFactor(), 3 * context.scaleFactor(), 5 * context.scaleFactor(), 5 * context.scaleFactor(), Qt::AlignLeft, msg ); mTextBoxRect = QRectF( textBounds.x() - context.scaleFactor() * 1, textBounds.y() - context.scaleFactor() * 1, \ textBounds.width() + 2 * context.scaleFactor(), textBounds.height() + 2 * context.scaleFactor() ); p->drawRect( mTextBoxRect ); p->drawText( textBounds, Qt::AlignLeft, msg ); } if ( data( 0 ) != "composer" ) //draw residuals only on screen { drawResidualArrow( p, context ); } }
void DishRatingView::init() { // Properties this->setAttribute( Qt::WA_NoSystemBackground, true ); // Add buttons float imageScale = Style::getWindowScale() * ( Style::getWindowScale() < 1.0f ? 1.3f : 1.0f ) * kImagesScale; QPixmap wowPixmap = QPixmap( RESOURCES_ROOT"wow.png" ); wowButton = new QPushButton( this ); wowButton->setCheckable( true ); wowButton->setAutoExclusive( true ); wowButton->setStyleSheet( kButtonsStyleSheet ); wowButton->setIcon( wowPixmap ); wowButton->setIconSize( wowPixmap.size() * imageScale ); wowButton->adjustSize(); QPixmap happyPixmap = QPixmap( RESOURCES_ROOT"happy.png" ); happyButton = new QPushButton( this ); happyButton->setCheckable( true ); happyButton->setAutoExclusive( true ); happyButton->setStyleSheet( kButtonsStyleSheet ); happyButton->setIcon( happyPixmap ); happyButton->setIconSize( happyPixmap.size() * imageScale ); happyButton->adjustSize(); QPixmap meahPixmap = QPixmap( RESOURCES_ROOT"meah.png" ); meahButton = new QPushButton( this ); meahButton->setCheckable( true ); meahButton->setAutoExclusive( true ); meahButton->setStyleSheet( kButtonsStyleSheet ); meahButton->setIcon( meahPixmap ); meahButton->setIconSize( meahPixmap.size() * imageScale ); meahButton->adjustSize(); // QPixmap yuckPixmap = QPixmap( RESOURCES_ROOT"yuck.png" ); // disabled so no negative feedback // yuckButton = new QPushButton( this ); // yuckButton->setCheckable( true ); // yuckButton->setAutoExclusive( true ); // yuckButton->setStyleSheet( kButtonsStyleSheet ); // yuckButton->setIcon( yuckPixmap ); // yuckButton->setIconSize( yuckPixmap.size() ); // yuckButton->adjustSize(); // Add rating text QFont textFont( kFontName, kCounterFontSize ); // textFont.setWeight( QFont::DemiBold ); numWowsLabel = new QLabel( this ); numWowsLabel->setText( "____" ); numWowsLabel->setFont( textFont ); numWowsLabel->setAlignment( Qt::AlignCenter ); numWowsLabel->adjustSize(); numWowsLabel->setAttribute( Qt::WA_NoSystemBackground, true ); numHappiesLabel = new QLabel( this ); numHappiesLabel->setText( "____" ); numHappiesLabel->setFont( textFont ); numHappiesLabel->setAlignment( Qt::AlignCenter ); numHappiesLabel->adjustSize(); numHappiesLabel->setAttribute( Qt::WA_NoSystemBackground, true ); numMeahsLabel = new QLabel( this ); numMeahsLabel->setText( "____" ); numMeahsLabel->setFont( textFont ); numMeahsLabel->setAlignment( Qt::AlignCenter ); numMeahsLabel->adjustSize(); numMeahsLabel->setAttribute( Qt::WA_NoSystemBackground, true ); // numYucksLabel = new QLabel( this ); // numYucksLabel->setText( "____" ); // numYucksLabel->setFont( textFont ); // numYucksLabel->setAlignment( Qt::AlignCenter ); // numYucksLabel->adjustSize(); QPalette palette = numWowsLabel->palette(); palette.setColor( numWowsLabel->foregroundRole(), Qt::black ); numWowsLabel->setPalette( palette ); numHappiesLabel->setPalette( palette ); numMeahsLabel->setPalette( palette ); // Move wowButton->move( 0, kBorderSize ); happyButton->move( wowButton->width(), kBorderSize ); meahButton->move( happyButton->x() + happyButton->width(), kBorderSize ); // yuckButton->move( meahButton->x() + meahButton->width(), kBorderSize ); numWowsLabel->move( wowButton->x() + wowButton->width() - numWowsLabel->width(), wowButton->y() + wowButton->height() - numWowsLabel->height() ); numHappiesLabel->move( happyButton->x() + happyButton->width() - numHappiesLabel->width(), happyButton->y() + happyButton->height() - numHappiesLabel->height() ); numMeahsLabel->move( meahButton->x() + meahButton->width() - numMeahsLabel->width(), meahButton->y() + meahButton->height() - numMeahsLabel->height() ); // numYucksLabel->move( yuckButton->x() + yuckButton->width() - numYucksLabel->width(), yuckButton->y() + yuckButton->height() - numYucksLabel->height() ); this->adjustSize(); this->setMinimumHeight( this->height() + kBorderSize ); updateCounterLabels(); updateRatingButtons(); connectSignals(); }