Beispiel #1
0
void CommandPanel::drawPanel(QPainter& painter, const QRect& clipRect)
{
   QColor textColor = palette().color(QPalette::Text);
   QColor backgroundColor = palette().color(QPalette::Background);
   QColor disabledTextColor = blendColor(textColor, backgroundColor);
   //
   painter.setRenderHint(QPainter::TextAntialiasing);
   //
   painter.setPen(Qt::NoPen);
   painter.setBrush(backgroundColor);
   painter.drawRect(clipRect);
   //
   painter.setFont(font());
   painter.setPen(textColor);
   painter.setBackgroundMode(Qt::OpaqueMode);
   painter.setBackground(backgroundColor);
   //
   std::list<CommandOption>::const_iterator it = options_.items().begin(), itEnd = options_.items().end();
   for(int i=0;it!=itEnd;++it, ++i)
   {
      assert(i<(int)rects_.size());
      //
      QRect rect(rects_[i]);
      QRect textRect(rect);
      textRect.setBottom(textRect.bottom()-cUnderlineHeight);
      //
      if(!rect.intersects(clipRect)) continue;
      //
      if(i==pressedIndex_)
      {
         painter.setPen(backgroundColor);
         painter.setBackground(textColor);
         painter.drawText(textRect, Qt::AlignHCenter, it->text());
      }
      else if(enabled_[i])
      {
         painter.setPen(textColor);
         //
         QRect underlineRect(rect.left(), rect.bottom()-cUnderlineHeight,
                             rect.width()-1, cUnderlineHeight);
         if(i==highlightedIndex_ && showHighlight_)
         {
            painter.setBrush(textColor);
            painter.drawRect(underlineRect);
         }
         //
         painter.drawText(textRect, Qt::AlignCenter, it->text());
      }
      else
      {
         painter.setPen(disabledTextColor);
         painter.drawText(textRect, Qt::AlignCenter, it->text());
      }
   }
}
Beispiel #2
0
void Graph::paintEvent(QPaintEvent *)
{
    QPainter painter;
    painter.begin(this);
    painter.setBackground(background);
    painter.eraseRect(rect());
    QPoint *points = new QPoint[MAX_DATA_LENGTH +2];
    points[0] = QPoint(0,150);
    points[MAX_DATA_LENGTH +1] = QPoint(MAX_DATA_LENGTH,150);
    for (int s = 0; s < MAX_DATA_LENGTH; s++){
        points[s +1] = QPoint(s,100 - data.at(data.length() - s -1));
    }
    painter.setPen(gridPen);
    painter.setBrush(filler);
    for (int s = 0; s < MAX_DATA_LENGTH / 30; s++){
        painter.drawLine(MAX_DATA_LENGTH - 30 * (s+1), 0,MAX_DATA_LENGTH - 30 * (s+1), 100);
    }
    for (int s = 0; s < 10; s++){
        painter.drawLine(0, 10*s,MAX_DATA_LENGTH, 10*s);
    }
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(circlePen);
    painter.drawPolygon(points,MAX_DATA_LENGTH +2);
    painter.end();
    delete points;
}
Beispiel #3
0
void t_libraryEditor::drawText(QPainter &painter, const someTextClass &text)
{
    painter.save();

    painter.setFont(text.font);

    QFontMetrics fm(text.font);
    int16_t fmW, fmH;
    fmW = fm.width(QString::fromStdString(text.theText));
    fmH = fm.height();

    painter.translate(text.posX, text.posY);
    if(text.direction)
        painter.rotate(text.direction);

    QPen dotPen;
    dotPen.setWidth(4);
    dotPen.setStyle(Qt::SolidLine);
    dotPen.setColor(g_color);
    painter.setPen(dotPen);

    painter.setBackground(QBrush(QColor(0,0,0,0)));

    painter.drawText(0, 0, QString::fromStdString(text.theText));
    painter.restore();
}
Beispiel #4
0
void GLWidget::paintEvent(QPaintEvent *event)
{

    
    QPainter painter;
    painter.begin(this);
    glClearColor(1.0,1.0,1.0,1.0);
    glClear(GL_COLOR_BUFFER_BIT); // << If I don't do this it clears out my viewer white
// and I want it black
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//    painter.setBackgroundMode(Qt::TranspaarentMode); // < was a test, doesn't seem to do anything
    painter.setBackground(QColor(1,1,1,1));
    

    painter.save();
    if(cell){

        //Zoom and invert
//        painter.translate(-visibleArea.rect.x1(),
//        -visibleArea.rect.y1());
//        painter.translate(-cell->width()*visibleArea.zoom/2,-cell->height()*visibleArea.zoom/2);

        painter.scale(visibleArea.zoom,-visibleArea.zoom);
        painter.translate(xcenter/visibleArea.zoom, -ycenter/visibleArea.zoom);
        painter.translate(-visibleArea.rect.x1()/visibleArea.zoom,-visibleArea.rect.y1()/visibleArea.zoom);

//        painter.translate(visibleArea.rect.x1()/visibleArea.zoom, -visibleArea.rect.y1()/visibleArea.zoom);        
        cellPainter->paintCell(painter,cell,"");
    }
    
    painter.restore();
    
    painter.end();
}
Beispiel #5
0
			void PiecesWidget::paintEvent (QPaintEvent *e)
			{
				int s = Pieces_.size ();
				QPainter painter (this);
				painter.setRenderHints (QPainter::Antialiasing |
						QPainter::SmoothPixmapTransform);
				if (!s)
				{
					painter.setBackgroundMode (Qt::OpaqueMode);
					painter.setBackground (Qt::white);
					painter.end ();
					return;
				}
			
				QPixmap tempPicture (s, 1);
				QPainter tempPainter (&tempPicture);
				tempPainter.setPen (Qt::red);
				tempPainter.drawLine (0, 0, s, 0);
				QList<QPair<int, int> > trues = FindTrues (Pieces_);
				for (int i = 0; i < trues.size (); ++i)
				{
					QPair<int, int> pair = trues.at (i);
			
					tempPainter.setPen (Qt::darkGreen);
					tempPainter.drawLine (pair.first, 0, pair.second, 0);
				}
				tempPainter.end ();
			
				painter.drawPixmap (QRect (0, 0, width (), height ()), tempPicture);
				painter.end ();
			
				e->accept ();
			}
Beispiel #6
0
void Drawboard::setupBuffer()
{
    QPixmap* newBuffer = new QPixmap(width(), height());
    QPainter* newPainter = new QPainter(newBuffer);

    newPainter->setBackgroundMode(Qt::OpaqueMode);
    newPainter->setBackground(Qt::white);

    newPainter->setRenderHint(QPainter::Antialiasing);
    newPainter->setRenderHint(QPainter::SmoothPixmapTransform);

    newPainter->eraseRect(newBuffer->rect());
    if (buffer != NULL)
    {
        int w = std::min(buffer->width(), newBuffer->width());
        int h = std::min(buffer->height(), newBuffer->height());
        newPainter->drawPixmap(0, 0, *buffer, 0, 0, w, h);
    }

    newPainter->setBrush(QColor(255, 0, 0, 128));
    newPainter->setPen(QColor(255, 0, 0, 255));

    delete painter;
    delete buffer;
    buffer = newBuffer;
    painter = newPainter;

    update();
}
Beispiel #7
0
void HexView::drawLines(QPainter &painter, quint64 docpos, int y, int x_begin, int x_end, uint size)
{
	HexConfig::XIterator xitr = config_.createXIterator();
	HexConfig::YIterator yitr = config_.createYIterator(y);
	const CursorSelection selection = cursor_->getSelection();
	QString hex;
	hex.resize(2);

	// Draw loop
	for (uint index = 0; index < size; ++index) {
		if (x_begin <= *xitr && *xitr < x_end) {
			// Set color
			ColorType color = selection.color(docpos++);
			QBrush brush = QBrush(config_.color(color.Background));
			painter.setBackground(brush);
			painter.setPen(config_.color(color.Text));

			// Draw background
			painter.fillRect(xitr.screenX(), *yitr, config_.byteWidth(), config_.byteHeight(), brush);

			// Draw text
			byteToHex(buff_[index], hex);
			drawText(painter, hex, xitr.textX(), yitr.screenY());
		}

		// Move next line
		++xitr;
		//if (*xitr == 0) {
		if (xitr.isNext()) {
			xitr.setNext(false);
			++yitr;
		}
	}
}
//Input Port #0: Buffer_Size = 1, Params_Type = ProcessorMulti_Processor_Control_Params, Data_Type = ProcessorMulti_Processor_Control_Data
//Input Port #1: Buffer_Size = 1, Params_Type = SensorInternalEvent_Sensor_Joystick_Params, Data_Type = SensorInternalEvent_Sensor_Joystick_Data
bool DECOFUNC(processMultiDrainData)(void * paramsPtr, void * varsPtr, QVector<QVector<void *> > drainParams, QVector<QVector<void *> > drainData)
{
	VisualizationMulti_VisualMisc_ControlJoy_Params * params=(VisualizationMulti_VisualMisc_ControlJoy_Params *)paramsPtr;
	VisualizationMulti_VisualMisc_ControlJoy_Vars * vars=(VisualizationMulti_VisualMisc_ControlJoy_Vars *)varsPtr;
	QVector<ProcessorMulti_Processor_Control_Params *> drainparams_0; copyQVector(drainparams_0,drainParams[0]);
	QVector<SensorInternalEvent_Sensor_Joystick_Params *> drainparams_1; copyQVector(drainparams_1,drainParams[1]);
	QVector<ProcessorMulti_Processor_Control_Data *> draindata_0; copyQVector(draindata_0,drainData[0]);
	QVector<SensorInternalEvent_Sensor_Joystick_Data *> draindata_1; copyQVector(draindata_1,drainData[1]);
	if(draindata_0.size()==0){return 0;}
	if(draindata_1.size()==0){return 0;}
	/*======Please Program below======*/
	/*
	Function: process draindata_index.
	*/
    ProcessorMulti_Processor_Control_Data* controldata = draindata_0.front();
    SensorInternalEvent_Sensor_Joystick_Data* joystick_data = draindata_1.front();

    if(controldata->isManualControl == 1)//manual control
    {
        QImage image(vars->width, vars->height, QImage::Format_ARGB32);

        QPainter painter;

        //vars->joystick_label->resize(vars->width, vars->height);
        painter.begin(&image);
        painter.setBackground(QBrush(QColor(241,241,241)));
        painter.eraseRect(0,0, vars->width, vars->height);

         if(joystick_data->forward)
            painter.drawImage(vars->width/2-16, vars->height/2-56, vars->forwardArrowImg);

        if(joystick_data->left)
            painter.drawImage(vars->width/2 -56, vars->height/2-16, vars->leftArrowImg);

        if(joystick_data->right)
            painter.drawImage(vars->width/2+24, vars->height/2-16, vars->rightArrowImg);

        if(joystick_data->back)
            painter.drawImage(vars->width/2-16, vars->height/2+24, vars->backArrowImg);
        painter.end();

        vars->label->setPixmap(QPixmap::fromImage(image));
    }
    else //Auto control
    {
        QFont serifFont("Times", vars->fontSize);
        vars->label->setFont(serifFont);
        QPalette pa;
        pa.setColor(QPalette::WindowText,Qt::red);
        vars->label->setPalette(pa);
        //vars->label->setAlignment(Qt::AlignLeft);

        QString outputstr = QString("Left_Motor: %1\nRight_Motor: %2\n").arg(controldata->left_motor).arg(controldata->right_motor);
        vars->label->setText(outputstr);
    }

    //vars->label->setFixedHeight(250);
	return 1;
}
Beispiel #9
0
void QSplineEdit::paintBackground(QPainter & pnt)
{
	QBrush brbg(Qt::darkGray);
	pnt.setBackground(brbg);
	
	QRectF square(0,0,200,100);
	pnt.fillRect(square, brbg);
}
Beispiel #10
0
void TextCanvas::draw(QPainter & p)
{
    if (! visible()) return;

    p.setRenderHint(QPainter::Antialiasing, true);
    QColor bgcolor = p.background().color();
    QPen fgcolor = p.pen();
    QBrush backgroundColor = p.background();

    if (bg_c == UmlTransparent)
        p.setBackgroundMode(::Qt::TransparentMode);
    else {
        p.setBackgroundMode(::Qt::OpaqueMode);
        //p.setBackgroundColor(color(bg_c));
        backgroundColor.setColor(bg_c);
        p.setBackground(backgroundColor);
    }

    if (fg_c != UmlTransparent)
        p.setPen(color(fg_c));

    QRect r = rect();

    p.setFont(the_canvas()->get_font(itsfont));
    p.drawText(r.left(), r.top(), r.width(), r.height(),
               ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::TextWordWrap, text);

    FILE * fp = svg();

    if (fp != 0)
        draw_text(r.left(), r.top(), r.width(), r.height(),
                  ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::TextWordWrap,
                  text, p.font(), fp, fg_c, bg_c);

    p.setFont(the_canvas()->get_font(UmlNormalFont));
    backgroundColor.setColor(bgcolor);
    //p.setBackgroundColor(bgcolor);
    p.setBackground(backgroundColor);
    p.setPen(fgcolor);

    if (selected())
        show_mark(p, r);
}
Beispiel #11
0
void KisDuplicateOpSettings::paintOutline(const QPointF& pos, KisImageSP image, QPainter &painter, const KoViewConverter &converter) const
{
    KisBrushSP brush = m_optionsWidget->m_brushOption->brush();
    QPointF hotSpot = brush->hotSpot(1.0, 1.0);
    painter.setPen(Qt::black);
    painter.setBackground(Qt::black);
    painter.drawEllipse( converter.documentToView( image->pixelToDocument(QRect(0,0, brush->width(), brush->height()) ).translated( pos - hotSpot + QPoint(1,1) ) ) );
    
    QRectF rect2 = converter.documentToView( duplicateOutlineRect( pos, image ) );
    painter.drawLine(rect2.topLeft(), rect2.bottomRight() );
    painter.drawLine(rect2.topRight(), rect2.bottomLeft() );

}
Beispiel #12
0
void t_libraryEditor::paintPin(QPainter &painter, const t_PinObject &ob)
{
    QPen dotPen;
    dotPen.setWidth(4);
    dotPen.setStyle(Qt::SolidLine);
    dotPen.setColor(g_color);
    painter.setPen(dotPen);
    painter.setBrush(Qt::NoBrush);

    painter.setBackground(QBrush(QColor(0,0,0,0)));

    QFont tFont;
    tFont.setPixelSize(ob.name_text_size);
    painter.setFont(tFont);

    int16_t tox, toy;
    tox = toy = 0;
    if(ob.direction == 'U')
    {
        tox = ob.posx;
        toy = ob.posy - ob.length;
    }
    else if(ob.direction == 'D')
    {
        tox = ob.posx;
        toy = ob.posy + ob.length;
    }
    else if(ob.direction == 'R')
    {
        tox = ob.posx + ob.length;
        toy = ob.posy;
    }
    else if(ob.direction == 'L')
    {
        tox = ob.posx - ob.length;
        toy = ob.posy;
    }
/*    if(currentComponent->flags & (1 << DRAW_PINNUMBER))
        painter.drawText(QPoint(ob.posx - 10, ob.posy - 10), QString::fromStdString(ob.num));
    if(currentComponent->flags & (1 << DRAW_PINNAME))
        painter.drawText(QPoint(ob.posx - 10, ob.posy + 10), QString::fromStdString(ob.name));
*/
    painter.drawLine(ob.posx, ob.posy, tox, toy);

    dotPen.setColor(p_color);
    dotPen.setWidth(2);
    painter.setPen(dotPen);
    painter.drawEllipse(QPoint(ob.posx, ob.posy), 10, 10);
}
//イメージファイルの出力
bool SXBSchView::exportImage(const QString& fname)
{
    m_pDoc->resetSelect();
    updateViewBuffer(true);

    int w = SheetSize().width();
    int h = SheetSize().height();

    QPixmap buffer(w,h);

    QPainter painter;
    painter.begin(&buffer);
    QRect rcClip = QRect(0,0,w,h);
    SRect srcClip =SRect(0,0,w,h);

    //    int currentScale = m_viewScale;
    //    int currentScaleMul = m_viewScaleMul;

    //    m_viewScale = 1;
    //    m_viewScaleMul = 1;
    SSize size = m_pDoc->SheetSize();

    //#ifdef _WINDOWS
    //    painter.setBackgroundColor(Qt::color0);
    //    painter.eraseRect(0,0,w,h);
    //    g_drawFrame(&painter,size,rcClip,Qt::color1,1,1);
    //    drawMainXBSchObj(&painter,DRAW_MONO,&srcClip,1,1);
    //#else
    painter.setBackground(Qt::white);
    painter.eraseRect(0,0,w,h);
    g_drawFrame(&painter,size,rcClip,Qt::black,1,1);
    //    drawMainXBSchObj(&painter,DRAW_ON,&srcClip);

    QSettings *settings = g_cfg.getSettings();
    settings->beginGroup("PrintOption");
    bool color = settings->value("Color",true).toBool();
    settings->endGroup();
    drawMainXBSchObj(&painter,(color ? DRAW_ON : DRAW_MONO),&srcClip,false,1,1);
    //#endif
    //    m_viewScale = currentScale;
    //    m_viewScaleMul = currentScaleMul;
    bool result = buffer.save(fname);


    //qDebug("SXBSchView::exportImage(const QString& fname)");

    update();    //画面の更新を強制
    return result;
}
Beispiel #14
0
void doPaint(QPainter & p)
{
    QRgb rgb = qRgb(161, 161, 161);

    p.setBackground(QBrush(rgb));
    p.eraseRect(0, 0, LCD_W, LCD_H);

    if (1) {
#if !defined(PCBTARANIS)
        rgb = qRgb(0, 0, 0);
        p.setPen(rgb);
        p.setBrush(QBrush(rgb));
#endif

#if defined(PCBTARANIS)
        unsigned int previousDepth = 0xFF;
#endif

        for (int y=0; y<LCD_H; y++) {
#if defined(PCBTARANIS)
            unsigned int idx = (y/2) * LCD_W;
#else
            unsigned int idx = (y/8) * LCD_W;
            unsigned int mask = (1 << (y%8));
#endif
            for (int x=0; x<LCD_W; x++, idx++) {
#if !defined(PCBTARANIS)
                if (lcd_buf[idx] & mask) {
                    p.drawPoint(x, y);
                }
#else
                unsigned int z = (y & 1) ? (lcd_buf[idx] >> 4) : (lcd_buf[idx] & 0x0F);
                if (z) {
                    if (z != previousDepth) {
                        previousDepth = z;
                        rgb = qRgb(161-(z*161)/15, 161-(z*161)/15, 161-(z*161)/15);
                        p.setPen(rgb);
                        p.setBrush(QBrush(rgb));
                    }
                    p.drawPoint(x, y);
                }
#endif
            }
        }
    }
			void PiecesWidget::paintEvent (QPaintEvent *e)
			{
				int s = Pieces_.size ();
				QPainter painter (this);
				painter.setRenderHints (QPainter::Antialiasing |
						QPainter::SmoothPixmapTransform);
				if (!s)
				{
					painter.setBackgroundMode (Qt::OpaqueMode);
					painter.setBackground (Qt::white);
					painter.end ();
					return;
				}
			
				const QPalette& palette = QApplication::palette ();
				const QColor& backgroundColor = palette.color (QPalette::Base);
				const QColor& downloadedPieceColor = palette.color (QPalette::Highlight);

				QPixmap tempPicture (s, 1);
				QPainter tempPainter (&tempPicture);
				tempPainter.setPen (backgroundColor);
				tempPainter.drawLine (0, 0, s, 0);
				QList<QPair<int, int> > trues = FindTrues (Pieces_);
				for (int i = 0; i < trues.size (); ++i)
				{
					QPair<int, int> pair = trues.at (i);
			
					tempPainter.setPen (downloadedPieceColor);
					tempPainter.drawLine (pair.first, 0, pair.second, 0);
				}
				tempPainter.end ();
			
				painter.drawPixmap (QRect (0, 0, width (), height ()), tempPicture);
				painter.end ();
			
				e->accept ();
			}
Beispiel #16
0
void UserViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
    UserViewItemBase *base = dynamic_cast<UserViewItemBase*>(m_uv->itemFromIndex(index));
    if( NULL == base )
        return;

    painter->save();
    painter->translate(option.rect.x(), option.rect.y());

    QPainter *p = painter;
    QPalette cg = option.palette;
    int width = option.rect.width();
    int height = option.rect.height();
    QSize itemsize = option.rect.size();
    int margin = 1;

    switch( base->type() )
    {
    case GRP_ITEM:
        {
            GroupItem *item = static_cast<GroupItem*>(base);
            QString text = index.data( Qt::DisplayRole ).toString();
            QImage img = Image( ( option.state & QStyle::State_Open ) ? "expanded" : "collapsed");
            if (!img.isNull())
                p->drawImage(2 + margin, (height - img.height()) / 2, img);
            int x = 24 + margin;
            if (!( option.state & QStyle::State_Open ) && item->m_unread)
            {
                CommandDef *lcmdDefUnreadMessages = CorePlugin::instance()->messageTypes.find(item->m_unread);
                if (lcmdDefUnreadMessages)
                {
                    img = Image(lcmdDefUnreadMessages->icon);
                    if (!img.isNull())
                    {
                        if (m_uv->m_bUnreadBlink)
                            p->drawImage(x, (height - img.height()) / 2, img);
                        x += img.width() + 2;
                    }
                }
            }
            if (!CorePlugin::instance()->value("UseSysColors").toBool())
                p->setPen(CorePlugin::instance()->value("ColorGroup").toUInt());
            QFont f(option.font);
            if (CorePlugin::instance()->value("SmallGroupFont").toBool())
            {
                int size = f.pixelSize();
                if (size > 0)
                    f.setPixelSize(size * 3 / 4);
                else
                {
                    size = f.pointSize();
                    f.setPointSize(size * 3 / 4);
                }
            }
            f.setBold(true);
            p->setFont(f);
            x = drawText(p, x, itemsize, text);
            if (CorePlugin::instance()->value("GroupSeparator").toBool())
                drawSeparator(p, x, itemsize, m_uv->style());
            break;
        }
    case USR_ITEM:
        {
            ContactItem *item = static_cast<ContactItem*>(base);
            QFont f(option.font);
            if (item->style() & CONTACT_ITALIC)
            {
                if (CorePlugin::instance()->value("VisibleStyle").toUInt()  & STYLE_ITALIC)
                    f.setItalic(true);
                if (CorePlugin::instance()->value("VisibleStyle").toUInt()  & STYLE_UNDER)
                    f.setUnderline(true);
                if (CorePlugin::instance()->value("VisibleStyle").toUInt()  & STYLE_STRIKE)
                    f.setStrikeOut(true);
            }
            if (item->style() & CONTACT_UNDERLINE)
            {
                if (CorePlugin::instance()->value("AuthStyle").toUInt()  & STYLE_ITALIC)
                    f.setItalic(true);
                if (CorePlugin::instance()->value("AuthStyle").toUInt()  & STYLE_UNDER)
                    f.setUnderline(true);
                if (CorePlugin::instance()->value("AuthStyle").toUInt()  & STYLE_STRIKE)
                    f.setStrikeOut(true);
            }
            if (item->style() & CONTACT_STRIKEOUT)
            {
                if (CorePlugin::instance()->value("InvisibleStyle").toUInt()  & STYLE_ITALIC)
                    f.setItalic(true);
                if (CorePlugin::instance()->value("InvisibleStyle").toUInt()  & STYLE_UNDER)
                    f.setUnderline(true);
                if (CorePlugin::instance()->value("InvisibleStyle").toUInt()  & STYLE_STRIKE)
                    f.setStrikeOut(true);
            }
            int x = margin;
            QIcon mainIcon = index.data( Qt::DecorationRole ).value<QIcon>();
            if (!mainIcon.isNull())
            {
                QPixmap img = mainIcon.pixmap( 16 );
                x += 2;
                p->drawPixmap(x, ( height - img.height() ) / 2, img);
                x += img.width() + 2;
            }
            if (x < 24)
                x = 24;
            if (!item->isSelected() || !m_uv->hasFocus() || !CorePlugin::instance()->value("UseDblClick").toBool())
            {
                if (!CorePlugin::instance()->value("UseSysColors").toBool())
                {
                    switch (item->status())
                    {
                    case STATUS_ONLINE:
                        p->setPen(CorePlugin::instance()->value("ColorOnline").toUInt());
                        break;
                    case STATUS_FFC:
                        p->setPen(CorePlugin::instance()->value("ColorOnline").toUInt());
                        break;
                    case STATUS_AWAY:
                        p->setPen(CorePlugin::instance()->value("ColorAway").toUInt());
                        break;
                    case STATUS_NA:
                        p->setPen(CorePlugin::instance()->value("ColorNA").toUInt());
                        break;
                    case STATUS_DND:
                        p->setPen(CorePlugin::instance()->value("ColorDND").toUInt());
                        break;
                    default:
                        p->setPen(CorePlugin::instance()->value("ColorOffline").toUInt());
                        break;
                    }
                }
                if (item->status() != STATUS_ONLINE && item->status() != STATUS_FFC)
                    p->setPen(m_uv->palette().color(QPalette::Disabled,QPalette::Text));
            }
            if (item->m_bBlink)
                f.setBold(true);
            else
                f.setBold(false);

            p->setFont(f);
            QString highlight;
            QString text = index.data( Qt::DisplayRole ).toString();
            int pos=0;
            if(!m_uv->m_search.isEmpty())
            {
                pos=text.toUpper().indexOf(m_uv->m_search.toUpper());
                //Search for substring in contact name
                if (pos > -1)
                    highlight=text.mid(pos,m_uv->m_search.length());
            }
            int save_x = x;
            //p->setPen(QColor(0, 0, 0));
            x = drawText(p, x, itemsize, text);
            if (pos > 0)
                save_x = drawText(p, save_x, itemsize, text.left(pos)) - 4;
            x += 2;
            if (!highlight.isEmpty())
            {
                QPen oldPen = p->pen();
                QColor oldBg = p->background().color();
                p->setBackgroundMode(Qt::OpaqueMode);
                if (item == m_uv->m_searchItem)
                    if (item == m_uv->currentItem() && CorePlugin::instance()->value("UseDblClick").toBool())
                    {
                        p->setBackground(cg.color(QPalette::HighlightedText));
                        p->setPen(cg.color(QPalette::Highlight));
                    }
                    else
                    {
                        p->setBackground(cg.color(QPalette::Highlight));
                        p->setPen(cg.color(QPalette::HighlightedText));
                    }
                else
                {
                    p->setBackground(oldPen.color());
                    p->setPen(oldBg);
                }
                drawText(p, save_x, itemsize, highlight);
                p->setPen(oldPen);
                p->setBackground(oldBg);
                p->setBackgroundMode(Qt::TransparentMode);
            }
            unsigned xIcon = width;
            QString icons = index.data( SIM::ExtraIconsRole ).toString();
            while( !icons.isEmpty() ) 
            {
                QString icon = getToken(icons, ',');
                QImage img = Image(icon);
                if (!img.isNull())
                {
                    xIcon -= img.width() + 2;
                    if (xIcon < (unsigned)x)
                        break;
                    p->drawImage(xIcon, (height - img.height()) / 2, img);
                }
            }
            break;
        }
    case DIV_ITEM:
        {
            QString text = index.data( Qt::DisplayRole ).toString();
            QFont f(option.font);
            int size = f.pixelSize();
            if (size <= 0)
            {
                size = f.pointSize();
                f.setPointSize(size * 3 / 4);
            }
            else
                f.setPixelSize(size * 3 / 4);
            p->setFont(f);
            int x = drawText(p, 24 + margin, itemsize, text);
            drawSeparator(p, x, itemsize, m_uv->style());
            break;
        }
    }

    painter->restore();
}
Beispiel #17
0
void screen::print(const QString &j)
{
  activate();

  p2.begin(&m2);

  p2.setPen( colors[nForecolor] );   
  p2.setBackgroundMode(Qt::OpaqueMode);
  p2.setBackground ( colors[nBackcolor] );
  p2.setFont(font); 


  int i = 0;
  int i2 = 0;
  bool b = false;
  QString k;

  do {

    i2 = j.indexOf("\n", i);
    if (i2 != -1){
      k = j.mid(i, i2 - i);
      i = i2;
      b = true;
    } else {
      k = j.mid(i);
      if (k == 0) break;
      b = false;
    }

  
   do {

      int n = k.length() + nCursorX;
      if (n > getColumn){
        n = getColumn - nCursorX;
       // p.drawText(getCursorX, getCursorY, k.left(n));

        p2.drawText(getCursorX, getCursorY, k.left(n));

        k = k.mid(n);

        nCursorX = 1;
        incCursorY();

      } else {
        

        p2.drawText(getCursorX, getCursorY, k);

        if (b){
          i++;
          nCursorX = 1;
          incCursorY();
        } else {
          nCursorX += k.length();
        }

        break;
      }

   } while (k.length());
 
 
} while (b);

  update();

  p2.end();

}
void SXBSchView::print(QPrinter*  pPrinter)
{
    m_pDoc->resetSelect();
    updateViewBuffer(true);
    QPainter paint;
    if(paint.begin(pPrinter ) ) {
        int dpi;
#ifdef Q_WS_MACX
        int dpix,dpiy;;
        dpix = pPrinter->logicalDpiX();
        dpiy = pPrinter->logicalDpiY();
        dpi=((dpix < dpiy) ? dpix : dpiy);
#else
        dpi = pPrinter->resolution();
#endif

        paint.setRenderHint(QPainter::Antialiasing, true);


        //    	QRect rcPaper = pPrinter->paperRect();
        //    printf("paperRect %d,%d,%d,%d\n",rcPaper.left(),rcPaper.top(),rcPaper.width(),rcPaper.height());
        QRect rcVp = paint.viewport();
        QRect rcPg = pPrinter->pageRect();
        //    printf("pageRect %d,%d,%d,%d\n",rcPg.left(),rcPg.top(),rcPg.width(),rcPg.height());
        //    	int orientation = pPrinter->orientation();
        //    printf("orientation %d\n",orientation);

        int vpWidth, vpHeight;
        int pgLeft, pgTop, pgWidth, pgHeight;

        vpWidth    =rcVp.width();
        vpHeight = rcVp.height();

        pgLeft    =rcPg.left();
        pgTop    =rcPg.top();
        pgWidth    =rcPg.width();
        pgHeight = rcPg.height();


        //印刷時に印刷の向きを変えてもpageRect()の返す値が変わらないQtのバグ(?)の対策
        if(    	(vpWidth > vpHeight && pgWidth < pgHeight)
                ||    (vpWidth < vpHeight && pgWidth > pgHeight)    ) {
            int swapn;
            swapn = pgLeft;
            pgLeft = pgTop;
            pgTop = swapn;

            swapn = pgWidth;
            pgWidth = pgHeight;
            pgHeight = swapn;
        }

        QSettings *settings = g_cfg.getSettings();

        int leftMargin = 15;
        int topMargin = 15;
        int rightMargin = 15;
        int bottomMargin = 15;

        settings->beginGroup("PrintOption");
        bool color = settings->value("Color",true).toBool();
        settings->endGroup();


        settings->beginGroup("PrintMargin");
        topMargin = settings->value("Top",15).toInt();
        bottomMargin = settings->value("Bottom",15).toInt();
        leftMargin = settings->value("Left",15).toInt();
        rightMargin = settings->value("Right",15).toInt();
        settings->endGroup();

        if      (topMargin    < 0)   topMargin = 0;
        else if (topMargin    > 50)  topMargin = 50;
        if      (bottomMargin < 0)   bottomMargin = 0;
        else if (bottomMargin > 50)  bottomMargin = 50;
        if      (leftMargin   < 0)   leftMargin = 0;
        else if (leftMargin   > 50)  leftMargin = 50;
        if      (rightMargin  < 0)   rightMargin = 0;
        else if (rightMargin  > 50)  rightMargin = 50;

        topMargin = dpi * 10 * topMargin / 254;
        bottomMargin = dpi * 10 * bottomMargin / 254;
        leftMargin = dpi * 10 * leftMargin / 254;
        rightMargin = dpi * 10 * rightMargin / 254;




        //    printf("SXBSchView::print() dpi:%d\n",dpi);

        paint.save();

        paint.setViewTransformEnabled (true);
        paint.resetMatrix();

        SSize size = m_pDoc->SheetSize();
        int w = size.w();
        int h = size.h();

        int dw = w*10;
        int dh = h*10;
        //    p->setWindow( 0,0, dw, dh );
        //    QRect rc = paint.viewport();

        int rightWidth = vpWidth-(pgLeft+pgWidth);
        if(rightWidth < 0) rightWidth = 0;
        int bottomWidth = vpHeight-(pgTop+pgHeight);
        if(bottomWidth < 0) bottomWidth = 0;

        leftMargin -= pgLeft;
        if(leftMargin < 0)leftMargin = 0;

        topMargin -= pgTop;
        if(topMargin < 0) topMargin = 0;

        rightMargin -= rightWidth;
        if(rightMargin < 0) rightMargin = 0;

        bottomMargin -= bottomWidth;
        if(bottomMargin < 0) bottomMargin = 0;

        int vw = pgWidth-(leftMargin+rightMargin);
        int vh = pgHeight-(topMargin+bottomMargin);


        double sheetRatio=(double)w / (double)h;
        double viewRatio=(double)vw / (double)vh;

        int newW;
        int newH;

        if(sheetRatio > viewRatio) {
            newW = vw;
            newH = (int)(vw / sheetRatio);
        } else {
            newH = vh;
            newW = (int)(vh *  sheetRatio);
        }
        //    printf("newW,H=%d,%d\n",newW,newH);
        //     p->setViewport(     rc.left() + (vw-newW)/2,
        //    	    	    rc.top() + (vh-newH)/2,
        //    	    	    newW, newH );
        //    QRect rcvp = p->viewport();
        //    printf("x,y,w,h  %d,%d,%d,%d\n",rcvp.x(),rcvp.y(),rcvp.width(),rcvp.height());

        paint.setViewport( leftMargin+ (vw-newW)/2,
                           topMargin + (vh-newH)/2,
                           newW, newH );
        paint.setWindow( 0,0, dw, dh );


        //    rcvp = p->viewport();
        //    printf("x,y,w,h  %d,%d,%d,%d\n",rcvp.x(),rcvp.y(),rcvp.width(),rcvp.height());


        QRect rcClip = QRect(0,0,dw,dh);
        SRect srcClip =SRect(0,0,w,h);

        paint.setBackground(Qt::white);
        paint.eraseRect(0,0,dw,dh);
        g_drawFrame(&paint,size,rcClip,Qt::black,1,10);
        drawMainXBSchObj(&paint,(color ? DRAW_ON : DRAW_MONO)|DRAW_FOR_PRINT,&srcClip,false,1,10);
        paint.restore();

        paint.end();
    }
}
Beispiel #19
0
void
PlayField::mouseMoveEvent(QMouseEvent *e) {
  lastMouseXPos_ = e->x();
  lastMouseYPos_ = e->y();

  if (!dragInProgress_) return highlight();

  int old_x = dragX_, old_y = dragY_;

  dragX_ = lastMouseXPos_ - mousePosX_;
  dragY_ = lastMouseYPos_ - mousePosY_;

  {
    int x = pixel2x(dragX_ + size_/2);
    int y = pixel2y(dragY_ + size_/2);
    if (x >= 0 && x < levelMap_->width() &&
	y >= 0 && y < levelMap_->height() &&
	pathFinder_.canDragTo(x, y)) {
      x = x2pixel(x);
      y = y2pixel(y);

      if (dragX_ >= x - size_/4 &&
	  dragX_ <  x + size_/4 &&
	  dragY_ >= y - size_/4 &&
	  dragY_ <  y + size_/4) {
	dragX_ = x;
	dragY_ = y;
      }
    }
  }

  if (dragX_ == old_x && dragY_ == old_y) return;

  QRect rect(dragX_, dragY_, size_, size_);

  dragXpm_= QPixmap(size_, size_);

  QPainter paint;
  paint.begin(&dragXpm_);
  paint.setBackground(palette().color(backgroundRole()));
  paint.setBrushOrigin(- dragX_, - dragY_);
  paint.translate((double) (- dragX_), (double) (- dragY_));
  paintPainter(paint, rect);
  paint.end();

  dragImage_ = dragXpm_.toImage();
  for (int yy=0; yy<size_; yy++) {
    for (int xx=0; xx<size_; xx++) {
      QRgb rgb1 = imageData_->objectImg().pixel(xx, yy);
      int r1 = qRed(rgb1);
      int g1 = qGreen(rgb1);
      int b1 = qBlue(rgb1);
      if (r1 != g1 || r1 != b1 || r1 == 255) {
	QRgb rgb2 = dragImage_.pixel(xx, yy);
	int r2 = qRed(rgb2);
	int g2 = qGreen(rgb2);
	int b2 = qBlue(rgb2);
	r2 = (int) (0.75 * r1 + 0.25 * r2 + 0.5);
	g2 = (int) (0.75 * g1 + 0.25 * g2 + 0.5);
	b2 = (int) (0.75 * b1 + 0.25 * b2 + 0.5);
	dragImage_.setPixel(xx, yy, qRgb(r2, g2, b2));
      }
    }
  }

  paint.begin(this);

  // the following line is a workaround for a bug in Qt 2.0.1
  // (and possibly earlier versions)
  paint.setBrushOrigin(0, 0);

  dragXpm_ = QPixmap::fromImage(dragImage_,
			    Qt::OrderedDither|Qt::OrderedAlphaDither|
			    Qt::ColorOnly|Qt::AvoidDither);
  paint.drawPixmap(dragX_, dragY_, dragXpm_);

  {
    int dx = dragX_ - old_x;
    int dy = dragY_ - old_y;
    int y2 = old_y;
    if (dy > 0) {
      paintPainterClip(paint, old_x, old_y, size_, dy);
      // NOTE: clipping is now activated in the QPainter paint
      y2 += dy;
    } else if (dy < 0) {
      paintPainterClip(paint, old_x, old_y+size_+dy, size_, -dy);
      // NOTE: clipping is now activated in the QPainter paint
      dy = -dy;
    }
    if (dx > 0) {
      paintPainterClip(paint, old_x, y2, dx, size_-dy);
      // NOTE: clipping is now activated in the QPainter paint
    } else if (dx < 0) {
      paintPainterClip(paint, old_x+size_+dx, y2, -dx, size_-dy);
      // NOTE: clipping is now activated in the QPainter paint
    }
  }
  paint.end();
}
Beispiel #20
0
void QZint::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode mode)
{
	encode();
	bool textdone;
	int comp_offset = 0, xoffset = m_whitespace, j, main_width = 0, addon_text_height = 0;
	int yoffset = 0;
	QString caption = QString::fromUtf8((const char *)m_zintSymbol->text, -1);
	QFont fontSmall(fontstyle);
	fontSmall.setPixelSize(fontPixelSizeSmall);
	QFont fontLarge(fontstyle);
	fontLarge.setPixelSize(fontPixelSizeLarge);

	if (m_lastError.length())
	{
		painter.setFont(fontLarge);
		painter.drawText(paintRect,Qt::AlignCenter,m_lastError);
		return;
	}

	painter.save();
	painter.setClipRect(paintRect,Qt::IntersectClip);
	qreal xtr=paintRect.x();
	qreal ytr=paintRect.y();

	int zrow_height=m_zintSymbol->height;
	int zrows=0;
	for (int i=0;i<m_zintSymbol->rows;i++)
	{
		zrow_height-=m_zintSymbol->row_height[i];
		if (!m_zintSymbol->row_height[i])
			zrows++;
	}
	if (zrows)
	{
		zrow_height/=zrows;
		for (int i=0;i<m_zintSymbol->rows;i++)
			if (!m_zintSymbol->row_height[i])
				m_zintSymbol->row_height[i]=zrow_height;
	}
	else
		m_zintSymbol->height-=zrow_height;


	qreal gwidth=m_zintSymbol->width;
	qreal gheight=m_zintSymbol->height;
	if (m_zintSymbol->symbology == BARCODE_MAXICODE)
	{
		gheight*=(maxi_width);
		gwidth*=(maxi_width+1);
	}

	qreal xsf=1;
	qreal ysf=1;
	qreal textoffset = 0;

	gwidth+=((m_border==BOX)?m_borderWidth*2:0);
	gheight+=((m_border!=NO_BORDER)?m_borderWidth*2:0);
	if(QString((const char*)m_zintSymbol->text).isEmpty() == false) {
		textoffset = 9;
		gheight += textoffset;
	} else {
		textoffset = 0;
	}
    gwidth+=m_zintSymbol->whitespace_width*2;
	switch(mode)
	{
		case IgnoreAspectRatio:
				xsf=(qreal)paintRect.width()/gwidth;
				ysf=(qreal)paintRect.height()/gheight;
			break;

		case KeepAspectRatio:
			if (paintRect.width()/gwidth<paintRect.height()/gheight)
			{
				ysf=xsf=(qreal)paintRect.width()/gwidth;
				ytr+=(qreal)(paintRect.height()-gheight*ysf)/2;
			}
			else
			{
				ysf=xsf=(qreal)paintRect.height()/gheight;
				xtr+=(qreal)(paintRect.width()-gwidth*xsf)/2;
			}
			break;

		case CenterBarCode:
				xtr+=((qreal)paintRect.width()-gwidth*xsf)/2;
				ytr+=((qreal)paintRect.height()-gheight*ysf)/2;
			break;
	}

	painter.setBackground(QBrush(m_bgColor));
	painter.fillRect(paintRect,QBrush(m_bgColor));
	painter.translate(xtr,ytr);
	painter.scale(xsf,ysf);

	QPen p;
	p.setColor(m_fgColor);
	p.setWidth(m_borderWidth);
	painter.setPen(p);

	QPainterPath pt;
	if(m_zintSymbol->symbology != BARCODE_MAXICODE) {
		/* Draw boundary bars or boxes around the symbol */
		switch(m_border)
		{
			case BOX:
				painter.fillRect(0,m_borderWidth,m_borderWidth,m_zintSymbol->height,QBrush(m_fgColor));
				painter.fillRect(m_zintSymbol->width + xoffset + xoffset + m_borderWidth,m_borderWidth,m_borderWidth,m_zintSymbol->height,QBrush(m_fgColor));
				painter.fillRect(0,0,m_zintSymbol->width + xoffset + xoffset + m_borderWidth + m_borderWidth,m_borderWidth,QBrush(m_fgColor));
				painter.fillRect(0,m_zintSymbol->height + m_borderWidth,m_zintSymbol->width + xoffset + xoffset + m_borderWidth + m_borderWidth, m_borderWidth,QBrush(m_fgColor));
				painter.translate(m_borderWidth+m_zintSymbol->whitespace_width,m_borderWidth);
				yoffset = m_borderWidth;
				break;
			case BIND:
				painter.fillRect(0,0,m_zintSymbol->width + xoffset + xoffset,m_borderWidth,QBrush(m_fgColor));
				painter.fillRect(0,m_zintSymbol->height + m_borderWidth,m_zintSymbol->width + xoffset + xoffset, m_borderWidth,QBrush(m_fgColor));
				painter.translate(m_zintSymbol->whitespace_width,m_borderWidth);
				yoffset = m_borderWidth;
				break;
	
			default:
				painter.translate(m_zintSymbol->whitespace_width,0);
				break;;
		}
	}

	while(!(module_set(m_zintSymbol->rows - 1, comp_offset))) {
		comp_offset++;
	}
	xoffset = comp_offset;
	
	/* Set up some values for displaying EAN and UPC symbols correctly */
	main_width = m_zintSymbol->width;
	if ((((m_zintSymbol->symbology == BARCODE_EANX) && (m_zintSymbol->rows == 1)) || (m_zintSymbol->symbology == BARCODE_EANX_CC))
		|| (m_zintSymbol->symbology == BARCODE_ISBNX)) {
		switch(caption.size()) {
			case 13: /* EAN 13 */
			case 16:
			case 19:
				if(m_zintSymbol->whitespace_width == 0) {
					m_zintSymbol->whitespace_width = 10;
				}
				main_width = 96 + comp_offset;
				break;
			default:
				main_width = 68 + comp_offset;
				break;
		}
	}
	
	if (((m_zintSymbol->symbology == BARCODE_UPCA) && (m_zintSymbol->rows == 1)) || (m_zintSymbol->symbology == BARCODE_UPCA_CC)) {
		if(m_zintSymbol->whitespace_width == 0) {
			m_zintSymbol->whitespace_width = 10;
		}
		main_width = 96 + comp_offset;
	}
	
	if (((m_zintSymbol->symbology == BARCODE_UPCE) && (m_zintSymbol->rows == 1)) || (m_zintSymbol->symbology == BARCODE_UPCE_CC)) {
		if(m_zintSymbol->whitespace_width == 0) {
			m_zintSymbol->whitespace_width = 10;
		}
		main_width = 51 + comp_offset;
	}
	
	p.setWidth(1);
	painter.setPen(p);

	if (m_zintSymbol->symbology == BARCODE_MAXICODE)
	{
		/* Draw Maxicode with hexagons */
		painter.save();
		painter.setRenderHint(QPainter::Antialiasing);
		for (int r=0;r<m_zintSymbol->rows;r++)
		{
			for (int c=0;c<m_zintSymbol->width;c++)
			{
				if (module_set(r, c))
				{
					qreal col=(qreal)c*(maxi_width+1)+(r%2)*((maxi_width+1)/2);
					qreal row=(qreal)r*(maxi_width+1)*0.868;
					QPainterPath pt;
					pt.moveTo(col+maxi_width/2, 	row);
					pt.lineTo(col+maxi_width, 	row+maxi_diagonal/4);
					pt.lineTo(col+maxi_width, 	row+(maxi_diagonal-maxi_diagonal/4));
					pt.lineTo(col+maxi_width/2, 	row+maxi_diagonal);
					pt.lineTo(col, 			row+(maxi_diagonal-maxi_diagonal/4));
					pt.lineTo(col, 			row+maxi_diagonal/4);
					pt.lineTo(col+maxi_width/2, 	row);
					painter.fillPath(pt,QBrush(m_fgColor));
				}
			}
		}
		p.setWidth(maxi_width);
		painter.setPen(p);
		const qreal w=maxi_width+1;
		painter.drawEllipse(QPointF(14.5*w,16.5*w*0.868),w,w);
		painter.drawEllipse(QPointF(14.5*w,16.5*w*0.868),w+w*1.5,w+w*1.5);
		painter.drawEllipse(QPointF(14.5*w,16.5*w*0.868),w+w*3,w+w*3);
		painter.restore();
	}
	else
	{
		/* Draw all other symbols with rectangles */
		int y=0;
		for (int row=0;row<m_zintSymbol->rows;row++)
		{
			for (int i=0;i<m_zintSymbol->width;i++) {
				if (module_set(row, i))
				{
					int ed = module_set(row, i);
					int linewidth=0;
					for (int j=i;j<m_zintSymbol->width;j++,linewidth++)
						if (ed != module_set(row, j))
							break;
					QColor color;
					color=m_fgColor;
					
					if(!((i > main_width) && (row == m_zintSymbol->rows - 1)))  {
						painter.fillRect(i,y,linewidth,m_zintSymbol->row_height[row],QBrush(color));
					} else {
						painter.fillRect(i,y + 8,linewidth,m_zintSymbol->row_height[row] - 3,QBrush(color));
						addon_text_height = y;
					}
				}
			}
			/* Add row binding */
			if(((m_zintSymbol->symbology == BARCODE_CODE16K) || (m_zintSymbol->symbology == BARCODE_CODE49)) && (row != 0)) {
				painter.fillRect(0,y - 1,m_zintSymbol->width,2,QBrush(m_fgColor));
			}
			y+=m_zintSymbol->row_height[row];
		}
	}

	textdone = false;
	
	if(m_hidetext == false) {
		painter.setFont(fontSmall);
		if(((m_zintSymbol->symbology == BARCODE_EANX) || (m_zintSymbol->symbology == BARCODE_EANX_CC)) ||
			(m_zintSymbol->symbology == BARCODE_ISBNX)) {
			/* Add bridge and format text for EAN */
			switch(caption.size()) {
				case 8:
				case 11:
				case 14:
					painter.fillRect(0 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
					painter.fillRect(2 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
					painter.fillRect(32 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
					painter.fillRect(34 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
					painter.fillRect(64 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
					painter.fillRect(66 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
					painter.setFont(fontLarge);
					painter.drawText(3 + xoffset, m_zintSymbol->height + yoffset, 29, 9,Qt::AlignCenter, caption.mid(0,4));
					painter.drawText(35 + xoffset, m_zintSymbol->height + yoffset, 29, 9,Qt::AlignCenter, caption.mid(4,4));
					if(caption.size() == 11) { /* EAN-2 */ painter.drawText(76 + xoffset, addon_text_height, 20, 9,Qt::AlignCenter, caption.mid(9,2)); };
					if(caption.size() == 14) { /* EAN-5 */ painter.drawText(76 + xoffset, addon_text_height, 47, 9,Qt::AlignCenter, caption.mid(9,5)); };
					painter.setFont(fontSmall);
					textdone = true;
					break;
				case 13:
				case 16:
				case 19:
					painter.fillRect(0 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
					painter.fillRect(2 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
					painter.fillRect(46 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
					painter.fillRect(48 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
					painter.fillRect(92 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
					painter.fillRect(94 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
					painter.setFont(fontLarge);
					painter.drawText(xoffset - 7, m_zintSymbol->height + yoffset, 7, 9,Qt::AlignCenter, caption.mid(0,1));
					painter.drawText(3 + xoffset, m_zintSymbol->height + yoffset, 43, 9,Qt::AlignCenter, caption.mid(1,6));
					painter.drawText(49 + xoffset, m_zintSymbol->height + yoffset, 43, 9,Qt::AlignCenter, caption.mid(7,6));
					if(caption.size() == 16) { /* EAN-2 */ painter.drawText(104 + xoffset, addon_text_height, 20, 9,Qt::AlignCenter, caption.mid(14,2)); };
					if(caption.size() == 19) { /* EAN-5 */ painter.drawText(104 + xoffset, addon_text_height, 47, 9,Qt::AlignCenter, caption.mid(14,5)); };
					painter.setFont(fontSmall);
					textdone = true;
					break;
			}
			if(textdone == false) {
				painter.setFont(fontLarge);
				painter.drawText(0, m_zintSymbol->height, m_zintSymbol->width, 9,Qt::AlignCenter, caption);
				painter.setFont(fontSmall);
				textdone = true;
			}
		}
		
		if((m_zintSymbol->symbology == BARCODE_UPCA) || (m_zintSymbol->symbology == BARCODE_UPCA_CC)) {
			/* Add bridge and format text for UPC-A */
			int block_width;
			bool latch = true;
			
			j = 0 + comp_offset;
			do {
				block_width = 0;
				do {
					block_width++;
				} while (module_set(m_zintSymbol->rows - 1, j + block_width) == module_set(m_zintSymbol->rows - 1, j));
				if(latch == true) {
					/* a bar */
					painter.fillRect(j + xoffset - comp_offset,m_zintSymbol->height,block_width,5,QBrush(m_fgColor));
					latch = false;
				} else {
					/* a space */
					latch = true;
				}
				j += block_width;
			} while (j < 11 + comp_offset);
			painter.fillRect(46 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
			painter.fillRect(48 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
			latch = true;
			j = 85 + comp_offset;
			do {
				block_width = 0;
				do {
					block_width++;
				} while (module_set(m_zintSymbol->rows - 1, j + block_width) == module_set(m_zintSymbol->rows - 1, j));
				if(latch == true) {
					/* a bar */
					painter.fillRect(j + xoffset - comp_offset,m_zintSymbol->height,block_width,5,QBrush(m_fgColor));
					latch = false;
				} else {
					/* a space */
					latch = true;
				}
				j += block_width;
			} while (j < 96 + comp_offset);
			painter.drawText(xoffset - 7, m_zintSymbol->height + yoffset + 2, 7, 7,Qt::AlignCenter, caption.mid(0,1));
			painter.drawText(96 + xoffset, m_zintSymbol->height + yoffset + 2, 7, 7,Qt::AlignCenter, caption.mid(11,1));
			painter.setFont(fontLarge);
			painter.drawText(11 + xoffset, m_zintSymbol->height + yoffset, 35, 9,Qt::AlignCenter, caption.mid(1,5));
			painter.drawText(49 + xoffset, m_zintSymbol->height + yoffset, 35, 9,Qt::AlignCenter, caption.mid(6,5));
			if(caption.size() == 15) { /* EAN-2 */ painter.drawText(104 + xoffset, addon_text_height, 20, 9,Qt::AlignCenter, caption.mid(13,2)); };
			if(caption.size() == 18) { /* EAN-5 */ painter.drawText(104 + xoffset, addon_text_height, 47, 9,Qt::AlignCenter, caption.mid(13,5)); };
			painter.setFont(fontSmall);
			textdone = true;
		}
		
		if((m_zintSymbol->symbology == BARCODE_UPCE) || (m_zintSymbol->symbology == BARCODE_UPCE_CC)) {
			/* Add bridge and format text for UPC-E */
			painter.fillRect(0 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
			painter.fillRect(2 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
			painter.fillRect(46 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
			painter.fillRect(48 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
			painter.fillRect(50 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
			painter.drawText(xoffset - 7, m_zintSymbol->height + yoffset + 2, 7, 7,Qt::AlignCenter, caption.mid(0,1));
			painter.drawText(51 + xoffset, m_zintSymbol->height + yoffset + 2, 7, 7,Qt::AlignCenter, caption.mid(7,1));
			painter.setFont(fontLarge);
			painter.drawText(3 + xoffset, m_zintSymbol->height + yoffset, 43, 9,Qt::AlignCenter, caption.mid(1,6));
			if(caption.size() == 11) { /* EAN-2 */ painter.drawText(60 + xoffset, addon_text_height, 20, 9,Qt::AlignCenter, caption.mid(9,2)); };
			if(caption.size() == 14) { /* EAN-2 */ painter.drawText(60 + xoffset, addon_text_height, 47, 9,Qt::AlignCenter, caption.mid(9,5)); };
			painter.setFont(fontSmall);
			textdone = true;
		}
	} /* if (m_hidetext == false) */
	
	if((m_hidetext == false) && (textdone == false)) {
		/* Add text to any other symbol */
		painter.drawText(0, m_zintSymbol->height + yoffset, m_zintSymbol->width, 7, Qt::AlignCenter, caption);
	}
	painter.restore();
}
Beispiel #21
0
void ArtGraficos::muestraPantalla ( int numpantalla )
{
    m_pantallaActual = numpantalla;

    QDomElement docElem = m_doc.documentElement();

    m_numPantallas = docElem.elementsByTagName ( "PANTALLA" ).count();

    /// Simulamos un sistema ciclico.
    if ( m_pantallaActual > m_numPantallas - 1 ) m_pantallaActual = 0;
    if ( m_pantallaActual < 0 ) m_pantallaActual = m_numPantallas - 1;

    QDomElement pantalla = docElem.elementsByTagName ( "PANTALLA" ).at ( m_pantallaActual ).toElement();
    /// Cogemos la coordenada X
    QString grid = pantalla.firstChildElement ( "GRID" ).toElement().text();

    /// Cogemos la coordenada Y
    QString cellwidth = pantalla.firstChildElement ( "CELLWIDTH" ).toElement().text();

    /// Cogemos el titulo de la pantalla
    QString titulo = pantalla.firstChildElement ( "NOMBRE" ).toElement().text();
    mui_titulo->setText ( titulo );

    mui_list->clear();
    mui_list->setRowCount ( grid.toInt() );
    mui_list->setColumnCount ( grid.toInt() );

    for ( int row = 0; row < grid.toInt(); row++ )
        mui_list->setRowHeight ( row, cellwidth.toInt() );
    for ( int column  = 0; column < grid.toInt(); column++ )
        mui_list->setColumnWidth ( column, cellwidth.toInt() );



    /// Tratamos cada ventana

    QDomNodeList nodos = pantalla.elementsByTagName ( "ITEM" );
    int nitem = 0;

    for ( int row = 0; row < grid.toInt(); row++ ) {
        for ( int column  = 0; column < grid.toInt(); column++ ) {

            if ( nitem < nodos.count() ) {
                QDomNode ventana = nodos.item ( nitem );

                QString nombre = ventana.firstChildElement ( "TITULO" ).toElement().text();

                QDomElement e1 = ventana.toElement(); /// try to convert the node to an element.
                QString text = e1.text();

                QString codigo = ventana.firstChildElement ( "CODIGO" ).toElement().text();
                if ( codigo.isEmpty() ) {
                    codigo = text;
                } // end if

                QString pvp = ventana.firstChildElement ( "PVPIVAINCARTICULO" ).toElement().text();
                if ( pvp.isEmpty() ) {
                    pvp = text;
                } // end if


                /// Creamos el elemento y lo ponemos en la tabla.
                QLabel *lab = new QLabel ( NULL );
                /// El escalado completo tarda demasiado.
//                lab->setPixmap(QPixmap("/var/bulmages/articles/"+text+".jpg", "no", Qt::OrderedDither | Qt::OrderedAlphaDither | Qt::AvoidDither).scaled(cellwidth.toInt(),cellwidth.toInt()));
                /// El escalado lateral tambien tarda demasiado
//                lab->setPixmap(QPixmap("/var/bulmages/articles/"+text+".jpg").scaledToWidth(cellwidth.toInt()));
                /// Ponemos las imagenes sin escalado.
//                lab->setPixmap ( QPixmap ( g_confpr->value( CONF_DIR_THUMB_ARTICLES ) + text + ".jpg" ) );

// Probamos con una Picture
                QPicture picture;
                QPainter painter;
                painter.begin ( &picture );        // paint in picture
//  painter.drawPixmap(0,0,cellwidth.toInt(),cellwidth.toInt(),QPixmap ( g_confpr->value( CONF_DIR_THUMB_ARTICLES ) + codigo + ".jpg" ));

//                painter.drawPixmap ( 0, 0, cellwidth.toInt(), cellwidth.toInt(), QPixmap ( g_confpr->value( CONF_DIR_THUMB_ARTICLES ) + "blanco.jpg" ) );

                painter.drawPixmap ( 0, 0, cellwidth.toInt(), cellwidth.toInt() - 25, QPixmap ( g_confpr->value( CONF_DIR_THUMB_ARTICLES ) + codigo + ".jpg" ) );

//         painter.drawEllipse(10,20, 80,70); // draw an ellipse
                painter.setPen ( QColor ( 0, 0, 0 ) );
                painter.setBackground ( QColor ( 0, 0, 0 ) );

                painter.drawText ( 5, 95, nombre );

		painter.drawText(5, 10, pvp);
//  painter.setPen(QColor(0,25,0));
//  painter.drawText(5,10,nombre);
//  painter.drawText(5,15,nombre);
//  painter.drawText(5,5,codigo);
//  painter.drawText(5,10,cellwidth);

                painter.end();                     // painting done


                lab->setPicture ( picture );

                mui_list->setCellWidget ( row, column, lab );
                m_articulos[row][column] = codigo;
		m_nodarticulos[row][column] = nodos.item ( nitem );
                nitem ++;
            } // end if

        }// end for
    } // end for


}