QVariant BoolProperty::decoration() const { static const QIcon checkedIcon = drawCheckBox(true); static const QIcon uncheckedIcon = drawCheckBox(false); return m_value ? checkedIcon : uncheckedIcon; }
void Journal::drawConfigPanel() { _vm->checkOptionSettings(); drawSlideBar(_vm->talkSpeed(), QueenEngine::MAX_TEXT_SPEED, BOB_TALK_SPEED, 164, FRAME_BLUE_PIN); drawSlideBar(_vm->sound()->getVolume(), Audio::Mixer::kMaxMixerVolume, BOB_MUSIC_VOLUME, 177, FRAME_GREEN_PIN); drawCheckBox(_vm->sound()->sfxOn(), BOB_SFX_TOGGLE, 221, 155, FRAME_CHECK_BOX); drawCheckBox(_vm->sound()->speechOn(), BOB_SPEECH_TOGGLE, 158, 155, FRAME_CHECK_BOX); drawCheckBox(_vm->subtitles(), BOB_TEXT_TOGGLE, 125, 167, FRAME_CHECK_BOX); drawCheckBox(_vm->sound()->musicOn(), BOB_MUSIC_TOGGLE, 125, 181, FRAME_CHECK_BOX); }
void renderDemo(struct NVGcontext* vg, float mx, float my, float width, float height, float t, int blowup, struct DemoData* data) { float x,y,popy; drawEyes(vg, width - 250, 50, 150, 100, mx, my, t); drawParagraph(vg, width - 450, 50, 150, 100, mx, my); drawGraph(vg, 0, height/2, width, height/2, t); drawColorwheel(vg, width - 300, height - 300, 250.0f, 250.0f, t); // Line joints drawLines(vg, 50, height-50, 600, 50, t); // Line caps drawWidths(vg, 10, 50, 30); // Line caps drawCaps(vg, 10, 300, 30); nvgSave(vg); if (blowup) { nvgRotate(vg, sinf(t*0.3f)*5.0f/180.0f*NVG_PI); nvgScale(vg, 2.0f, 2.0f); } // Widgets drawWindow(vg, "Widgets `n Stuff", 50, 50, 300, 400); x = 60; y = 95; drawSearchBox(vg, "Search", x,y,280,25); y += 40; drawDropDown(vg, "Effects", x,y,280,28); popy = y + 14; y += 45; // Form drawLabel(vg, "Login", x,y, 280,20); y += 25; drawEditBox(vg, "Email", x,y, 280,28); y += 35; drawEditBox(vg, "Password", x,y, 280,28); y += 38; drawCheckBox(vg, "Remember me", x,y, 140,28); drawButton(vg, ICON_LOGIN, "Sign in", x+138, y, 140, 28, nvgRGBA(0,96,128,255)); y += 45; // Slider drawLabel(vg, "Diameter", x,y, 280,20); y += 25; drawEditBoxNum(vg, "123.00", "px", x+180,y, 100,28); drawSlider(vg, 0.4f, x,y, 170,28); y += 55; drawButton(vg, ICON_TRASH, "Delete", x, y, 160, 28, nvgRGBA(128,16,8,255)); drawButton(vg, 0, "Cancel", x+170, y, 110, 28, nvgRGBA(0,0,0,0)); // Thumbnails box drawThumbnails(vg, 365, popy-30, 160, 300, data->images, 12, t); nvgRestore(vg); }
// draw //--------------------------------------------------------------------------- void CheckBox::draw(Surface &dest) { iRect bounds; getBounds(bounds); if (state) { drawCheckBox(dest); drawCheck(dest); } else { drawCheckBox(dest); } drawLabel(dest); } // end CheckBox::draw
void PYInfoPad::drawCategory(QPainter *painter) { painter->save(); int CateCnt = m_CategoryInfoVec.count(); qreal initY = 0; for(int CateIndex = 0;CateIndex < CateCnt ; CateIndex++) { // draw header QRectF HeaderRect = drawHeader(painter,initY); /// increment initY initY += SIW_HEADER_HEIGHT; if(!drawCheckBox(painter, HeaderRect, (initY - SIW_HEADER_HEIGHT), CateIndex)) { continue; } drawSubItems(painter, initY, CateIndex); } m_height = initY ; setMinimumHeight(m_height); painter->restore(); }
uint8_t mDisplayContent (uint8_t mode) { uint8_t ret = 3; clrContent(); switch(mode) { case M_DISP_CONTRAST: charChainDOGS(0, 0, 0,"Kontrast"); charChainDOGS(2, 0, 0,"Regulieren Sie so lange,"); charChainDOGS(3, 0, 0,"bis der Kontrast Ihrer"); charChainDOGS(4, 0, 0,"Vorstellung entspricht."); break; case M_DISP_BRIGHTNESS: charChainDOGS(0, 0, 0,"Helligkeit"); charChainDOGS(2, 0, 0,"Regulieren Sie so lange,"); charChainDOGS(3, 0, 0,"bis die Helligkeit Ihrer"); charChainDOGS(4, 0, 0,"Vorstellung entspricht."); break; case M_DISP_DEFAULT: charChainDOGS(0, 0, 0,"Display"); charChainDOGS(2, 5, 0,"Kontrast"); charChainDOGS(3, 5, 0,"Automatik"); if(autoLight) { drawCheckBox(3,90,CHECKED); charChainDOGS(4, 5, 0,"Exit"); } else { drawCheckBox(3,90,UNCHECKED); charChainDOGS(4, 5, 0,"Helligkeit"); charChainDOGS(5, 5, 0,"Exit"); ret = 4; } } return ret; }
void displayUISettings() { // getting window dimensions GLshort w=glutGet(GLUT_WINDOW_WIDTH); uiS.height=glutGet(GLUT_WINDOW_HEIGHT); GLshort percUnitW = w/100; GLshort percUnitH = uiS.height/100; glDisable(GL_DEPTH_TEST); glClear(GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glPushMatrix(); //to prepare for return to 3D glLoadIdentity(); gluOrtho2D(0,w,0,uiS.height); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //UI background 20% of screen gap from edges glColor3f(1,1,1); //white glBegin(GL_QUADS); glVertex2s(percUnitW*20,percUnitH*20); glVertex2s(w-percUnitW*20,percUnitH*20); glVertex2s(w-percUnitW*20,uiS.height-percUnitH*20); glVertex2s(percUnitW*20,uiS.height-percUnitH*20); glEnd(); glColor3f(0,0,1); displayText("SETTINGS:", percUnitW*22, percUnitH*78, 'l'); //draw chosen colour if not random if(!tmpState.colourRand){ uiS.chosenClr[0] = percUnitW*25; uiS.chosenClr[1] = percUnitH*55; glColor3fv(tmpState.colour); glBegin(GL_QUADS); glVertex2sv(uiS.chosenClr); glVertex2s(uiS.chosenClr[0]+20, uiS.chosenClr[1]); glVertex2s(uiS.chosenClr[0]+20, uiS.chosenClr[1]+20); glVertex2s(uiS.chosenClr[0], uiS.chosenClr[1]+20); glEnd(); displayText("Chosen Colour", uiS.chosenClr[0]+25, uiS.chosenClr[1]+2, 'm'); } //for colourpicker triangle drawColourPicker(percUnitW, percUnitH); //check box for selection of random colour uiS.randClr[0]=percUnitW*35; uiS.randClr[1]=percUnitH*55; drawCheckBox(uiS.randClr[0],uiS.randClr[1],"Random Colour"); //if random colour selected draw cross if(tmpState.colourRand){ drawCheck(uiS.randClr[0],uiS.randClr[1]); } //for selection of angle: draw a box then distribute evenly within 9 circles of radius 10, in 3 rows of 3, filled in for chosen angle drawAnglePresets(percUnitW, percUnitH); //check box for selection of random angle uiS.randAng[0] = percUnitW*60; uiS.randAng[1] = percUnitH*55; drawCheckBox(uiS.randAng[0], uiS.randAng[1] ,"Random Angle"); //slider bar for selection of lift charge/intial velocity uiS.velocityL[0]= percUnitW*23; uiS.velocityL[1]= percUnitH*42; uiS.velocityR[0]= percUnitW*65; uiS.velocityR[1]= percUnitH*42; snprintf(uiS.velocityMnTxt, 6, "%4.1f", tmpState.velocityMin); snprintf(uiS.velocityMxTxt, 6, "%4.1f", tmpState.velocityMax); displayText("Lift Charge giving initial velocity in m/s:", uiS.velocityL[0]-20, uiS.velocityL[1]+15, 'm'); drawSlider(uiS.velocityL, uiS.velocityR); displayText(uiS.velocityMnTxt, uiS.velocityL[0]-30, uiS.velocityL[1]-4, 'm'); displayText(uiS.velocityMxTxt, uiS.velocityR[0]+5, uiS.velocityR[1]-4, 'm'); //x coords of chosen velocity determined by (chosenValue - minValue)*((xRight - xLeft)/(maxValue-minValue)) + xLeft uiS.velocityChX = ((tmpState.velocityCh - tmpState.velocityMin)*(((float)uiS.velocityR[0]-(float)uiS.velocityL[0])/(tmpState.velocityMax-tmpState.velocityMin))+(float)uiS.velocityL[0]); drawMarker(uiS.velocityChX, uiS.velocityL[1]); snprintf(uiS.velocityChTxt, 6, "%3.1f", tmpState.velocityCh); displayText(uiS.velocityChTxt, uiS.velocityChX-10, uiS.velocityL[1]-17, 'm'); //slider bar for selection of fuser timer uiS.fuseL[0]= percUnitW*23; uiS.fuseL[1]= percUnitH*32; uiS.fuseR[0]= percUnitW*65; uiS.fuseR[1]= percUnitH*32; snprintf(uiS.fuseMnTxt, 6, "%5.1f", tmpState.fuseMin); snprintf(uiS.fuseMxTxt, 6, "%5.1f", tmpState.fuseMax); displayText("Fuse timer from launch to explosion in milliseconds:", uiS.fuseL[0]-20, uiS.fuseL[1]+15, 'm'); drawSlider(uiS.fuseL, uiS.fuseR); displayText(uiS.fuseMnTxt, uiS.fuseL[0]-40, uiS.fuseL[1]-4, 'm'); displayText(uiS.fuseMxTxt, uiS.fuseR[0]+5, uiS.fuseR[1]-4, 'm'); //x coords of chosen fuse determined by (chosenValue - minValue)*((xRight - xLeft)/(maxValue-minValue)) + xLeft uiS.fuseChX = ((tmpState.fuseCh - tmpState.fuseMin)*(((float)uiS.fuseR[0]-(float)uiS.fuseL[0])/(tmpState.fuseMax-tmpState.fuseMin))+(float)uiS.fuseL[0]); drawMarker(uiS.fuseChX, uiS.fuseL[1]); snprintf(uiS.fuseChTxt, 6, "%5.1f", tmpState.fuseCh); displayText(uiS.fuseChTxt, uiS.fuseChX-10, uiS.fuseL[1]-17, 'm'); //save button uiS.saveBL[0] = percUnitW*70; uiS.saveBL[1] = percUnitH*31; uiS.saveTR[0] = percUnitW*79; uiS.saveTR[1] = percUnitH*39; glColor3f(0, 0.5, 0); glBegin(GL_QUADS); glVertex2sv(uiS.saveBL); glVertex2s(uiS.saveTR[0], uiS.saveBL[1]); glVertex2sv(uiS.saveTR); glVertex2s(uiS.saveBL[0], uiS.saveTR[1]); glEnd(); displayText("Save", uiS.saveBL[0]+5, uiS.saveBL[1]+5,'l'); //underline S glLineWidth(2); glBegin(GL_LINES); glVertex2s(uiS.saveBL[0]+6,uiS.saveBL[1]+3); glVertex2s(uiS.saveBL[0]+18,uiS.saveBL[1]+3); glEnd(); glLineWidth(1); //cancel button uiS.cancelBL[0] = percUnitW*70; uiS.cancelBL[1] = percUnitH*22; uiS.cancelTR[0] = percUnitW*79; uiS.cancelTR[1] = percUnitH*30; glColor3f(0.6, 0, 0); glBegin(GL_QUADS); glVertex2sv(uiS.cancelBL); glVertex2s(uiS.cancelTR[0], uiS.cancelBL[1]); glVertex2sv(uiS.cancelTR); glVertex2s(uiS.cancelBL[0], uiS.cancelTR[1]); glEnd(); displayText("Cancel", uiS.cancelBL[0]+5, uiS.cancelBL[1]+5,'l'); //underline C glLineWidth(2); glBegin(GL_LINES); glVertex2s(uiS.cancelBL[0]+6,uiS.cancelBL[1]+3); glVertex2s(uiS.cancelBL[0]+18,uiS.cancelBL[1]+3); glEnd(); glLineWidth(1); // returning to 3D glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glEnable(GL_DEPTH_TEST); }
void lmcUserTreeWidgetDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { painter->save(); QPalette palette = QApplication::palette(); QRect itemRect = option.rect; lmcUserTreeWidgetItem* pItem = static_cast<lmcUserTreeWidgetItem*>(index.internalPointer()); lmcUserTreeWidget* pTreeWidget = (lmcUserTreeWidget*)pItem->treeWidget(); QString type = pItem->data(0, TypeRole).toString(); QString name = pItem->data(0, Qt::DisplayRole).toString(); int padding = 2; if(type == "Group") { // fill the entire item area with window background color (usually white) painter->fillRect(itemRect, palette.window()); // Fill the background of the item with highlight color, and draw a border with a darker shade QColor fillColor = palette.color(QPalette::Highlight); QColor borderColor = fillColor.darker(130); painter->setPen(QPen(borderColor)); painter->setBrush(QBrush(fillColor)); itemRect.adjust(1, 1, -2, -1); painter->drawRect(itemRect); // Draw checkbox if needed QRect checkBoxRect = pItem->checkBoxRect(itemRect); if(pTreeWidget->checkable()) drawCheckBox(painter, palette, checkBoxRect, pItem->checkState(0)); // Draw the expand/collapse arrow painter->setBrush(QBrush(palette.color(QPalette::HighlightedText))); painter->setPen(QPen(palette.color(QPalette::HighlightedText))); QPoint points[3]; if(option.state.testFlag(QStyle::State_Children) && option.state.testFlag(QStyle::State_Open)) { points[0] = QPoint(checkBoxRect.right() + 4, itemRect.top() + ((itemRect.height() - 4) / 2)); points[1] = QPoint(checkBoxRect.right() + 12, itemRect.top() + ((itemRect.height() - 4) / 2)); points[2] = QPoint(checkBoxRect.right() + 8, itemRect.top() + ((itemRect.height() - 4) / 2) + 4); } else { points[0] = QPoint(checkBoxRect.right() + 6, itemRect.top() + ((itemRect.height() - 7) / 2)); points[1] = QPoint(checkBoxRect.right() + 10, itemRect.top() + ((itemRect.height() - 7) / 2) + 4); points[2] = QPoint(checkBoxRect.right() + 6, itemRect.top() + ((itemRect.height() - 7) / 2) + 8); } painter->drawPolygon(points, 3); // Draw the text QFont font = painter->font(); font.setBold(true); painter->setFont(font); int textFlags = Qt::AlignLeft | Qt::AlignVCenter; // Leave a padding of 5px on left and right int leftPad = checkBoxRect.width() > 0 ? checkBoxRect.right() + 16 : 16; QRect textRect = itemRect.adjusted(leftPad, padding, -5, -padding); painter->setPen(QPen(palette.color(QPalette::HighlightedText))); QString text = elidedText(painter->fontMetrics(), textRect.width(), Qt::ElideRight, name); painter->drawText(textRect, textFlags, text); } else if(type == "User") { QColor fillColor, borderColor; if(index.row() % 2 == 1) borderColor = fillColor = palette.color(QPalette::AlternateBase); else borderColor = fillColor = palette.color(QPalette::Base); if(option.state.testFlag(QStyle::State_Active) && option.state.testFlag(QStyle::State_Enabled) && option.state.testFlag(QStyle::State_Selected)) borderColor = palette.color(QPalette::Shadow); painter->setPen(QPen(borderColor)); painter->setBrush(QBrush(fillColor)); itemRect.adjust(1, 0, -2, -1); painter->drawRect(itemRect); // Draw checkbox if needed QRect checkBoxRect = pItem->checkBoxRect(itemRect); if(pTreeWidget->checkable()) drawCheckBox(painter, palette, checkBoxRect, pItem->checkState(0)); // Draw the status image QPixmap statusImage = pItem->icon(0).pixmap(QSize(16, 16)); int leftPad = checkBoxRect.width() > 0 ? checkBoxRect.right() + 5 : 5; QRect statusRect = itemRect.adjusted(leftPad, padding, 0, 0); statusRect.setSize(statusImage.size()); painter->drawPixmap(statusRect, statusImage); // Draw the avatar image QRect avatarRect = itemRect.adjusted(itemRect.width(), padding, 0, 0); if(pTreeWidget->view() == ULV_Detailed) { QVariant avatar = pItem->data(0, AvatarRole); if(!avatar.isNull()) { QPixmap avatarImage = ((QIcon)pItem->data(0, AvatarRole).value<QIcon>()).pixmap(32, 32); avatarRect.setLeft(avatarRect.right() - avatarImage.width() - padding); avatarRect.setSize(avatarImage.size()); painter->drawPixmap(avatarRect, avatarImage); } } // Draw the text painter->setPen(QPen(palette.color(QPalette::WindowText))); int textFlags = Qt::AlignLeft; textFlags |= (pTreeWidget->view() == ULV_Detailed ? Qt::AlignTop : Qt::AlignVCenter); // Leave a padding of 5px on left and right QRect textRect = itemRect.adjusted(statusRect.right() + 5, padding, -(5 + avatarRect.width() + padding), -padding); QString text = elidedText(painter->fontMetrics(), textRect.width(), Qt::ElideRight, name); painter->drawText(textRect, textFlags, text); // Draw sub text if(pTreeWidget->view() == ULV_Detailed) { QVariant note = pItem->data(0, SubtextRole); if(!note.isNull()) { QString userNote = note.toString(); painter->setPen(QPen(GRAY_TEXT_COLOR)); textFlags = Qt::AlignLeft | Qt::AlignBottom; text = elidedText(painter->fontMetrics(), textRect.width(), Qt::ElideRight, userNote); painter->drawText(textRect, textFlags, text); } } } painter->restore(); }