void TMenuItem::paintAt(Graphics* g, int x, int y) { switch (type) { case TYPE_ITEM: if (getEnabled()) { if (getFocused()) { g->setColor(Color::blue); g->drawRect(x, y, getWidth(), getHeight()); g->setColor(COLOR_BLUEGRAY); g->fillRect(x + 1, y + 1, getWidth() - 2, getHeight() - 2); } else { g->setColor(getBackground()); g->fillRect(x, y, getWidth(), getHeight()); } g->setColor(getForeground()); g->drawString(title, x + 10, y + 3); } else { g->setColor(getBackground()); g->fillRect(x, y, getWidth(), getHeight()); g->setColor(Color::gray); g->drawString(title, 10 + x, 3 + y); } break; case TYPE_SEPARATOR: g->setColor(getForeground()); g->drawLine(x + 5, y + 3, x + getWidth() - 5, y + 3); break; default: break; } }
Layer* Button::getDrawnForeground(void) const { if(getEnabled()) { //if(getFocused()) //{ // return getFocusedTextColor(); //} if(getActive()) { return getActiveForeground(); } else if(_MouseInComponentLastMouse) { return getRolloverForeground(); } else { return getForeground(); } } else { return getDisabledForeground(); } }
Layer* AbstractWindow::getDrawnForeground(void) const { if(getDrawDecorations()) { if(getEnabled()) { if(getFocused()) { return getFocusedForeground(); } else if(_MouseInComponentLastMouse) { return getRolloverForeground(); } else { return getForeground(); } } else { return getDisabledForeground(); } } else { return NULL; } }
void ComboBox::keyDown(int keyCode, char character) { if ((this != Control::getFocus()) || (!_pnlOptions.isVisible())) { return; } int change = 0; switch (keyCode) { case VK_RETURN: case VK_SPACE: setSelectedIndex(_listIndex); return; case VK_DOWN: change = 1; break; case VK_UP: change = -1; break; default: return; } vector<Control*> controls; _pnlOptions.getAllControls(&controls); controls[_listIndex]->setBackground(getBackground()); controls[_listIndex]->setForeground(getForeground()); if ((change == -1) && (_listIndex == 0)) { _listIndex = controls.size() - 1; } else { _listIndex = (_listIndex + change) % controls.size(); } controls[_listIndex]->setBackground(getForeground()); controls[_listIndex]->setForeground(getBackground()); }
void TPopupMenu::paint(Graphics* g) { g->setColor(Color::white); g->drawLine(0, 0, getWidth() - 1, 0); g->drawLine(0, 0, 0, getHeight() - 1); g->setColor(getForeground()); g->drawLine(0, getHeight() - 1, getWidth() - 1, getHeight() - 1); g->drawLine(getWidth() - 1, 0, getWidth() - 1, getHeight() - 1); }
void Button::paint(Graphics* g) { int w = getWidth(); int h = getHeight(); // 一度背景色でクリア g->setColor(getBackground()); g->fillRect(0, 0, w, h); // 枠を描画 g->setColor(Color::black); g->drawLine(2, 0, w - 3, 0); g->drawLine(2, h - 1, w - 3, h - 1); g->drawLine(0, 2, 0, h - 3); g->drawLine(w - 1, 2, w - 1, h - 3); g->drawLine(1, 1, 1, 1); g->drawLine(1, h - 2 , 1, h - 2); g->drawLine(w - 2 , 1, w - 2, 1); g->drawLine(w - 2 , h - 2, w - 2, h - 2); if (this->pushed) { g->setColor(Color::white); g->drawLine(2, h - 2, w - 3, h - 2); g->drawLine(w - 2, 2, w - 2, h - 3); g->drawLine(w - 3 , h - 3, w - 3, h - 3); g->setColor(Color::gray); g->drawLine(1, 2, 1, h - 3); g->drawLine(2, 1, w - 3, 1); } else { g->setColor(Color::gray); g->drawLine(2, h - 2, w - 3, h - 2); g->drawLine(w - 2, 2, w - 2, h - 3); g->drawLine(w - 3 , h - 3, w - 3, h - 3); g->setColor(Color::white); g->drawLine(1, 2, 1, h - 3); g->drawLine(2, 1, w - 3, 1); } // 文字 int fw = getFontMetrics()->getWidth(getLabel()); int fh = getFontMetrics()->getHeight(getLabel()); int x = (w - fw) / 2; int y = (h - fh) / 2; if (this->pushed) { x++; y++; } if (getEnabled() == true) { g->setColor(getForeground()); } else { g->setColor(Color::gray); } g->drawString(getLabel(), x, y); }
int caNumeric::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = ENumeric::qt_metacall(_c, _id, _a); if (_id < 0) return _id; #ifndef QT_NO_PROPERTIES if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = getPV(); break; case 1: *reinterpret_cast< QColor*>(_v) = getForeground(); break; case 2: *reinterpret_cast< QColor*>(_v) = getBackground(); break; case 3: *reinterpret_cast< SourceMode*>(_v) = getPrecisionMode(); break; case 4: *reinterpret_cast< bool*>(_v) = getFixedFormat(); break; case 5: *reinterpret_cast< SourceMode*>(_v) = getLimitsMode(); break; case 6: *reinterpret_cast< double*>(_v) = getMaxValue(); break; case 7: *reinterpret_cast< double*>(_v) = getMinValue(); break; } _id -= 8; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setPV(*reinterpret_cast< QString*>(_v)); break; case 1: setForeground(*reinterpret_cast< QColor*>(_v)); break; case 2: setBackground(*reinterpret_cast< QColor*>(_v)); break; case 3: setPrecisionMode(*reinterpret_cast< SourceMode*>(_v)); break; case 4: setFixedFormat(*reinterpret_cast< bool*>(_v)); break; case 5: setLimitsMode(*reinterpret_cast< SourceMode*>(_v)); break; case 6: setMaxValue(*reinterpret_cast< double*>(_v)); break; case 7: setMinValue(*reinterpret_cast< double*>(_v)); break; } _id -= 8; } else if (_c == QMetaObject::ResetProperty) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 8; } #endif // QT_NO_PROPERTIES return _id; }
void TextField::paint(Graphics* g) { int w = getWidth(), h = getHeight(); // 外枠 if (getFocused() == true && getEnabled() == true) { g->setColor(0, 128, 255); g->drawRect(0, 0, w, h); } else { g->setColor(getParent()->getBackground()); g->drawRect(0, 0, w, h); } // 内枠 g->setColor(getBackground()); g->fillRect(1, 1, w - 2, h - 2); g->setColor(getForeground()); g->drawRect(1, 1, w - 2, h - 2); // 文字 int fh = getFontMetrics()->getHeight(getText()); int fw = getFontMetrics()->getWidth(getText()); if (getEnabled() == true) { g->setColor(getForeground()); } else { g->setColor(Color::gray); } g->drawString(getText(), this->offx, (h - fh) / 2); // キャレット if (getFocused() == true && getEnabled() == true) { g->drawLine(offx + fw, offy, offx + fw, offy + 12); } // todo pullup int width = _imeManager->isOn() ? 100 : 0; _imeManager->setBounds(getX() + offx + fw, getY() + offy, width, getHeight() - offy * 2); }
void LLDragHandleTop::draw() { /* Disable lines. Can drag anywhere in most windows. JC if( getVisible() && getEnabled() && mForeground) { const S32 BORDER_PAD = 2; const S32 HPAD = 2; const S32 VPAD = 2; S32 left = BORDER_PAD + HPAD; S32 top = getRect().getHeight() - 2 * VPAD; S32 right = getRect().getWidth() - HPAD; // S32 bottom = VPAD; // draw lines for drag areas const S32 LINE_SPACING = (DRAG_HANDLE_HEIGHT - 2 * VPAD) / 4; S32 line = top - LINE_SPACING; LLRect title_rect = mTitleBox->getRect(); S32 title_right = title_rect.mLeft + mTitleWidth; BOOL show_right_side = title_right < getRect().getWidth(); for( S32 i=0; i<4; i++ ) { gl_line_2d(left, line+1, title_rect.mLeft - LEADING_PAD, line+1, mDragHighlightColor); if( show_right_side ) { gl_line_2d(title_right, line+1, right, line+1, mDragHighlightColor); } gl_line_2d(left, line, title_rect.mLeft - LEADING_PAD, line, mDragShadowColor); if( show_right_side ) { gl_line_2d(title_right, line, right, line, mDragShadowColor); } line -= LINE_SPACING; } } */ // Colorize the text to match the frontmost state if (mTitleBox) { mTitleBox->setEnabled(getForeground()); } LLView::draw(); }
void JListBox::paint(JGraphics g) { int dx = d2+d2, dy; int th = getBaseH(); int ns = section; JString text; JFontMetrics fm(g); JRect clip = g.getClipJRect(); JRect frame = JRect(0, 0, width-scroller->width, height); JRegion rgn(clip &= frame); JColor color = getForeground(); JColor bkgnd = getBackground(); JColor light = bkgnd.brighter(); clip &= frame.shrink(d, d); if (base+ns > content.size()) ns = content.size()-base; for (int i=0; i<ns; i++) { dy = i*th+d2; JRect cell(d2, dy, width-scroller->width-d2*2, th-d); JRect area = cell & clip; JRect inner = cell.shrink(d, d) & clip; if (area.isEmpty()) continue; JAssociation &obj = *(JAssociation*)content[i+base]; text = *(JString*)obj.key(); g.setClipJRect(cell & clip); g.setJColor(bkgnd); if (!(int)*(JInteger*)obj.value()) { g.fill3DJRect(cell, d); g.setJColor(light); g.setClipJRect(inner); g.drawJString(text, dx+1, dy+1); } else { g.fill3DJRect(cell, -d); g.setJColor(light); g.setClipJRect(inner); g.drawJString(text, dx-1, dy-1); } g.setJColor(color); g.drawJString(text, dx, dy); rgn -= JRegion(area); } g.setJRegion(rgn); g.setJColor(bkgnd); g.fill3DJRect(frame, -d); }
void TextEdit::createWindow() { if (GWindow::m_Display == 0) { if (!GWindow::initX()) { perror("A connection with X server could not be established"); exit(1); } } // Load font, calculate window size, etc. initialize(); strncpy(m_WindowTitle, getFileName(), 127); setBgColorName("LightGray"); setFgColorName("black"); GWindow::createWindow(); // Save background and foreground colors bgColor = getBackground(); fgColor = getForeground(); // Status line colors /usr/X11R6/lib/X11/rgb.txt bgStatusLineColor = allocateColor("MidnightBlue"); fgStatusLineColor = allocateColor("white"); setFont(textFont); // Hints for window manager XSizeHints sizeHints; memset(&sizeHints, 0, sizeof(sizeHints)); // Minimal size 16 * 1 sizeHints.min_width = 44*dx + leftMargin + rightMargin; sizeHints.min_height = 1*dy + topMargin + bottomMargin; // Base size sizeHints.base_width = 0*dx + leftMargin + rightMargin; sizeHints.base_height = 0*dy + topMargin + bottomMargin; // Resize increment sizeHints.width_inc = dx; sizeHints.height_inc = dy; sizeHints.flags = (PMinSize | PBaseSize | PResizeInc); XSetWMNormalHints(m_Display, m_Window, &sizeHints); }
bool MMSLabelWidget::checkRefreshStatus() { if (MMSWidget::checkRefreshStatus()) return true; if (this->current_fgset) { // current foreground initialized MMSFBColor color; getForeground(&color); if (color == this->current_fgcolor) { // foreground color not changed, so we do not enable refreshing return false; } } // (re-)enable refreshing enableRefresh(); return true; }
// assumes GL state is set for 2D void LLDragHandleLeft::draw() { /* Disable lines. Can drag anywhere in most windows. JC if( getVisible() && getEnabled() && mForeground ) { const S32 BORDER_PAD = 2; // const S32 HPAD = 2; const S32 VPAD = 2; const S32 LINE_SPACING = 3; S32 left = BORDER_PAD + LINE_SPACING; S32 top = getRect().getHeight() - 2 * VPAD; // S32 right = getRect().getWidth() - HPAD; S32 bottom = VPAD; // draw lines for drag areas // no titles yet //LLRect title_rect = mTitleBox->getRect(); //S32 title_right = title_rect.mLeft + mTitleWidth; //BOOL show_right_side = title_right < getRect().getWidth(); S32 line = left; for( S32 i=0; i<4; i++ ) { gl_line_2d(line, top, line, bottom, mDragHighlightColor); gl_line_2d(line+1, top, line+1, bottom, mDragShadowColor); line += LINE_SPACING; } } */ // Colorize the text to match the frontmost state if (mTitleBox) { mTitleBox->setEnabled(getForeground()); } LLView::draw(); }
Layer* Component::getDrawnForeground(void) const { if(getEnabled()) { if(getMouseOver()) { return getFocusedForeground(); } else if(getFocused()) { return getRolloverForeground(); } else { return getForeground(); } } else { return getDisabledForeground(); } }
void caGraphics::paintEvent( QPaintEvent *event ) { Q_UNUSED(event); if(thisHide) return; int m_margin = 3; QPointF p1,p2; QPainter painter( this ); painter.setRenderHint( QPainter::Antialiasing ); int margin = thisLineSize/2; int w = width() - 2 * margin; int h = height() - 2 * margin; // do not increase linesize beyond the canvas size if(w <= 0 || h <= 0) { setLineSize(thisLineSize-1); } margin = thisLineSize/2; w = width() - 2 * margin; h = height() - 2 * margin; int x = margin; int y = margin; if(thisLineStyle == Dash) { painter.setPen( QPen( getLineColor(), getLineSize(), Qt::DotLine, Qt::SquareCap) ); } else if (thisLineStyle == BigDash) { painter.setPen( QPen( getLineColor(), getLineSize(), Qt::DashLine, Qt::SquareCap) ); } else { painter.setPen( QPen( getLineColor(), getLineSize(), Qt::SolidLine, Qt::SquareCap) ); } if(thisFillStyle == Filled) { painter.setBrush(getForeground()); } if(getForm() == Rectangle) { QPolygonF rectangle; rectangle.append(QPointF(x,y)); rectangle.append(QPointF(x+w,y)); rectangle.append(QPointF(x+w,y+h)); rectangle.append(QPointF(x,y+h)); rectangle.append(QPointF(x,y)); // rotate QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, rectangle); painter.drawPolygon(rotated); } else if(getForm() == Circle) { // rotate my calculated ellipse QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, drawCircle(x, x+w, y, y+h)); painter.drawPolygon(rotated); } else if(getForm() == Triangle) { QPolygonF triangle; triangle.append(QPointF(x+w/2,0)); triangle.append(QPointF(x,y+h)); triangle.append(QPointF(x+w,y+h)); triangle.append(QPointF(x+w/2,0)); // rotate QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, triangle); painter.drawPolygon(rotated); } else if(getForm() == Arc) { if(thisFillStyle == Filled) { painter.drawPie (x, y, w, h, thisStartAngle * 16, thisSpanAngle * 16); } else { painter.drawArc (x, y, w, h, thisStartAngle * 16, thisSpanAngle * 16); } } else if(getForm() == Line) { QPolygonF line; line.append(QPointF(x,y+h/2)); line.append(QPointF(x+w,y+h/2)); // rotate QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, line); painter.drawPolygon(rotated); } else if(getForm() == Arrow) { QPolygonF lines; QPolygonF head1; QPolygonF head2; p1 = QPointF( m_margin, height()/2 ); p2 = QPointF( width()-m_margin, height()/2 ); lines.append(p1); lines.append(p2); head1 = getHead(p1,p2); if (getArrowMode() == Double) { head2 = getHead(p2,p1); } for(int i=0; i<head1.count(); i++) lines.append(head1.at(i)); for(int i=0; i<head2.count(); i++) lines.append(head2.at(i)); // rotate QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, lines); painter.drawPolygon(rotated); } }
void caPolyLine::paintEvent(QPaintEvent * /* event */) { QStringList pairs; if(thisHide) return; QPainter painter(this); painter.setRenderHint( QPainter::Antialiasing ); int nbPoints = 0; if(inEditor) { painter.setBrush(QColor(Qt::white)); painter.drawRect(editSize); } if(thisLineStyle == Dash) { painter.setPen( QPen( getLineColor(), getLineSize(), Qt::DotLine, Qt::FlatCap)); } else if (thisLineStyle == BigDash) { painter.setPen( QPen( getLineColor(), getLineSize(), Qt::DashLine, Qt::FlatCap )); } else { painter.setPen( QPen( getLineColor(), getLineSize(), Qt::SolidLine, Qt::FlatCap)); } if(inDesigner) { pairs = thisXYpairs.split(";", QString::SkipEmptyParts); } else { pairs = XYpairs.split(";", QString::SkipEmptyParts); } QPolygon polygon(pairs.count()); for(int i=0; i< pairs.count(); i++) { QStringList xy = pairs.at(i).split(",", QString::SkipEmptyParts); if(xy.count() == 2) { polygon.putPoints(i, 1, atoi(qasc(xy.at(0))), atoi(qasc(xy.at(1)))); lastPosition = QPointF(atoi(qasc(xy.at(0))), atoi(qasc(xy.at(1)))); nbPoints++; } } // when polygon, close the line if((thisPolyStyle == Polygon) && (nbPoints > 2)) { QStringList xy = pairs.at(0).split(",", QString::SkipEmptyParts); if(xy.count() == 2) { polygon.putPoints(nbPoints, 1, atoi(qasc(xy.at(0))), atoi(qasc(xy.at(1)))); nbPoints++; } } if(thisFillStyle == Filled) { painter.setBrush(getForeground()); } if(nbPoints > 0) { if(thisPolyStyle == Polygon) { painter.drawPolygon(polygon); } else { painter.drawPolyline(polygon); } } if(inEditor && mouseMove) { painter.setPen( QPen(QColor(Qt::red), getLineSize(), Qt::SolidLine, Qt::FlatCap ) ); if(actualPosition != lastPosition) painter.drawLine(actualPosition, lastPosition); } }
bool MMSLabelWidget::draw(bool *backgroundFilled) { int width, height, x, y; bool myBackgroundFilled = false; if(!surface) return false; if (backgroundFilled) { if (this->has_own_surface) *backgroundFilled = false; } else backgroundFilled = &myBackgroundFilled; // lock this->surface->lock(); // draw widget basics if (MMSWidget::draw(backgroundFilled)) { // draw my things if (prepareText(&width, &height)) { // text is translated and font is set MMSFBRectangle surfaceGeom = getSurfaceGeometry(); // save the width of the text this->slide_width = width; switch ((!this->swap_left_right) ? getAlignment() : swapAlignmentHorizontal(getAlignment())) { case MMSALIGNMENT_LEFT: x = surfaceGeom.x; y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y; break; case MMSALIGNMENT_RIGHT: x = surfaceGeom.x + surfaceGeom.w - width; y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y; break; case MMSALIGNMENT_CENTER: x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x; y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y; break; case MMSALIGNMENT_TOP_CENTER: x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x; y = surfaceGeom.y; break; case MMSALIGNMENT_TOP_LEFT: x = surfaceGeom.x; y = surfaceGeom.y; break; case MMSALIGNMENT_TOP_RIGHT: x = surfaceGeom.x + surfaceGeom.w - width; y = surfaceGeom.y; break; case MMSALIGNMENT_BOTTOM_CENTER: x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x; y = surfaceGeom.y + surfaceGeom.h - height; break; case MMSALIGNMENT_BOTTOM_LEFT: x = surfaceGeom.x; y = surfaceGeom.y + surfaceGeom.h - height; break; case MMSALIGNMENT_BOTTOM_RIGHT: x = surfaceGeom.x + surfaceGeom.w - width; y = surfaceGeom.y + surfaceGeom.h - height; break; default: x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x; y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y; break; } // get color MMSFBColor color; getForeground(&color); this->current_fgcolor = color; this->current_fgset = true; if (color.a) { // prepare for drawing this->surface->setDrawingColorAndFlagsByBrightnessAndOpacity( color, (isSelected())?getSelShadowColor(MMSPOSITION_TOP):getShadowColor(MMSPOSITION_TOP), (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM):getShadowColor(MMSPOSITION_BOTTOM), (isSelected())?getSelShadowColor(MMSPOSITION_LEFT):getShadowColor(MMSPOSITION_LEFT), (isSelected())?getSelShadowColor(MMSPOSITION_RIGHT):getShadowColor(MMSPOSITION_RIGHT), (isSelected())?getSelShadowColor(MMSPOSITION_TOP_LEFT):getShadowColor(MMSPOSITION_TOP_LEFT), (isSelected())?getSelShadowColor(MMSPOSITION_TOP_RIGHT):getShadowColor(MMSPOSITION_TOP_RIGHT), (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM_LEFT):getShadowColor(MMSPOSITION_BOTTOM_LEFT), (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM_RIGHT):getShadowColor(MMSPOSITION_BOTTOM_RIGHT), getBrightness(), getOpacity()); // draw the text this->surface->drawString(this->translated_text, -1, x - this->slide_offset, y); } } // update window surface with an area of surface updateWindowSurfaceWithSurface(!*backgroundFilled); } // unlock this->surface->unlock(); // draw widgets debug frame return MMSWidget::drawDebug(); }