Exemple #1
0
void CCheckBox::Draw() const
{
	CWindow::Draw();

	if (m_pSDLSurface)
	{
		CRect SubRect(m_WindowRect.SizeRect());
		CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
		Painter.DrawRect(m_WindowRect.SizeRect(), false, COLOR_WHITE);
		if (m_eCheckBoxState != DISABLED)
		{
			Painter.DrawRect(SubRect, false, COLOR_LIGHTGRAY);
			Painter.DrawHLine(SubRect.Left(), SubRect.Right(), SubRect.Top(), COLOR_BLACK);
			Painter.DrawVLine(SubRect.Top(), SubRect.Bottom(), SubRect.Left(), COLOR_BLACK);
			SubRect.Grow(-1);
      if (m_bHasFocus)
      {
        Painter.DrawRect(SubRect, false, COLOR_GRAY);
      }
			SubRect.Grow(-1);
			if (m_eCheckBoxState == CHECKED)
			{
//				Painter.DrawLine(SubRect.TopLeft(), SubRect.BottomRight(), DEFAULT_LINE_COLOR);
//				Painter.DrawLine(SubRect.BottomLeft(), SubRect.TopRight(), DEFAULT_LINE_COLOR);
        SDL_Rect SourceRect = m_WindowRect.SizeRect().SDLRect();
        SDL_Rect DestRect = SubRect.SDLRect();
        SDL_BlitSurface(m_hBitmapCheck.Bitmap(), &SourceRect, m_pSDLSurface, &DestRect);
			}
		}
	}
}
  void  paintEvent(QPaintEvent*) {
    QPainter Painter(this);
    float cxx = cos(rotZ);
    float cxy = sin(rotZ);
    float cxz = sin(rotY);
    float cyz = sin(rotX);
    float cyy = cos(rotX);
    float cyx = cyy * cxy + cyz * cxz * cxx;
    cyy = cyy * cxx - cyz * cxz * cxy;
    cyz *= cos(rotY);
    cxx *= cos(rotY);
    cxy *= cos(rotY);

    Painter.setPen(QPen(QPen::red,2));
    Painter.drawLine(CROSS3D_SIZE, CROSS3D_SIZE,
		     int(CROSS3D_SIZE * (1.0+cxx)),
		     int(CROSS3D_SIZE * (1.0-cyx)));
    Painter.setPen(QPen(QPen::green,2));
    Painter.drawLine(CROSS3D_SIZE, CROSS3D_SIZE,
		     int(CROSS3D_SIZE * (1.0-cxy)),
		     int(CROSS3D_SIZE * (1.0-cyy)));
    Painter.setPen(QPen(QPen::blue,2));
    Painter.drawLine(CROSS3D_SIZE, CROSS3D_SIZE,
		     int(CROSS3D_SIZE * (1.0+cxz)),
		     int(CROSS3D_SIZE * (1.0+cyz)));
  };
Exemple #3
0
void CProgress::Draw(void) const
{
	CWindow::Draw();

	if (m_pSDLSurface)
	{
		CRect SubRect(m_WindowRect.SizeRect());
		SubRect.Grow(-1);
		CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
		Painter.DrawRect(m_WindowRect.SizeRect(), false, COLOR_BLACK);
		Painter.DrawRect(SubRect, false, COLOR_LIGHTGRAY);
		Painter.DrawHLine(SubRect.Left(), SubRect.Right(), SubRect.Top(), COLOR_DARKGRAY);
		Painter.DrawVLine(SubRect.Top(), SubRect.Bottom(), SubRect.Left(), COLOR_DARKGRAY);
		SubRect.Grow(-2);
		if (m_Value > m_MinLimit)
		{
			if (m_Value < m_MaxLimit)
			{
				SubRect.SetRight(stdex::safe_static_cast<int>(SubRect.Left() +
					SubRect.Width() * (stdex::safe_static_cast<double>(m_Value - m_MinLimit) / (m_MaxLimit - m_MinLimit))));
			}
			Painter.DrawRect(SubRect, true, m_BarColor, m_BarColor);
		}
	}
}
Exemple #4
0
void CButton::Draw(void) const
{
	CWindow::Draw();

	if (m_pSDLSurface)
	{
		CPoint FontCenterPoint = m_WindowRect.SizeRect().Center();
		CRect SubRect(m_WindowRect.SizeRect());
		CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
		CRGBColor FontColor = DEFAULT_TEXT_COLOR;
		switch (m_eButtonState)
		{
		case UP:
			Painter.Draw3DRaisedRect(SubRect, DEFAULT_BUTTON_COLOR);
			break;
		case DOWN:
			Painter.Draw3DLoweredRect(SubRect, DEFAULT_BUTTON_COLOR);
			FontCenterPoint = FontCenterPoint + CPoint(1, 1);
			break;
		case DISABLED:
			FontColor = DEFAULT_DISABLED_LINE_COLOR;
			break;
		default:
			break;
		}
		SubRect.Grow(-2);
		if (m_pRenderedString.get())
		{
			m_pRenderedString->Draw(m_pSDLSurface, SubRect, FontCenterPoint, FontColor);
		}
	}
}
Exemple #5
0
void CListBox::Draw() const
{
	CWindow::Draw();    

	if (m_pSDLSurface)
	{
		CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
		Painter.DrawRect(m_WindowRect.SizeRect(), false, COLOR_DARKGRAY);
		int iStartIndex = m_pVScrollbar->GetValue();
		for (unsigned int i = iStartIndex; i < m_Items.size(); ++i)
		{
			CRect ItemRect(m_ClientRect.Left(), m_ClientRect.Top() + (i - iStartIndex) * m_iItemHeight,
				m_ClientRect.Right(), m_ClientRect.Top() + (i - iStartIndex + 1) * m_iItemHeight - 1);
			if (ItemRect.Overlaps(m_ClientRect))
			{
				ItemRect.ClipTo(m_ClientRect);
				ItemRect.SetBottom(ItemRect.Bottom() - 1);
				if (m_SelectedItems.at(i))
				{
					Painter.DrawRect(ItemRect, true, CApplication::Instance()->GetDefaultSelectionColor(), CApplication::Instance()->GetDefaultSelectionColor());
				}
				if (i == m_iFocusedItem && HasFocus())
				{
					ItemRect.Grow(1);
					Painter.DrawRect(ItemRect, false, COLOR_DARKGRAY);
					ItemRect.Grow(-1);
				}
				ItemRect.Grow(-1);
				m_RenderedStrings.at(i).Draw(m_pSDLSurface, ItemRect, ItemRect.TopLeft() + CPoint(0, 1), m_Items[i].ItemColor);
			}
		}
	}
  m_pVScrollbar->Draw();
}
Exemple #6
0
// ************************************************************
void SymbolWidget::paintEvent(QPaintEvent*)
{
  QPainter Painter(this);
  Painter.drawText(2, 2, 0, 0, Qt::AlignLeft | Qt::TextDontClip, PaintText);

  QFontMetrics metrics(QucsSettings.font, 0);
  Painter.drawText(2, metrics.height(), 0, 0, Qt::AlignLeft | Qt::TextDontClip, Warning);

  int dx = (x2-x1)/2 + TextWidth - DragNDropWidth/2;
  if(dx < 2)  dx = 2;
  Painter.drawText(dx, y2-y1+2, 0, 0, Qt::AlignLeft | Qt::TextDontClip, DragNDropText);

  // paint all lines
  for(int i=0; i<Lines.size(); i++) {
    Line *pl = Lines.at(i);
    Painter.setPen(pl->style);
    Painter.drawLine(cx+pl->x1, cy+pl->y1, cx+pl->x2, cy+pl->y2);
  }

  // paint all arcs
  for(int i=0; i<Arcs.size(); i++) {
    Arc *pc = Arcs.at(i);
    Painter.setPen(pc->style);
    Painter.drawArc(cx+pc->x, cy+pc->y, pc->w, pc->h, pc->angle, pc->arclen);
  }

  // paint all rectangles
  for(int i=0; i<Rects.size(); i++) {
    Area *pa = Rects.at(i);
    Painter.setPen(pa->Pen);
    Painter.setBrush(pa->Brush);
    Painter.drawRect(cx+pa->x, cy+pa->y, pa->w, pa->h);
  }

  // paint all ellipses
  for(int i=0; i<Ellips.size(); i++) {
    Area *pa = Ellips.at(i);
    Painter.setPen(pa->Pen);
    Painter.setBrush(pa->Brush);
    Painter.drawEllipse(cx+pa->x, cy+pa->y, pa->w, pa->h);
  }

  Painter.setPen(QPen(Qt::black,1));
  QFont Font = Painter.font();   // save current font
  Font.setWeight(QFont::Light);
  // write all text
  for(int i=0; i<Texts.size(); i++) {
    Text *pt = Texts.at(i);
    Font.setPointSizeF(pt->Size);
    Painter.setFont(Font);
    Painter.setPen(pt->Color);
    Painter.drawText(cx+pt->x, cy+pt->y, 0, 0, Qt::TextDontClip, pt->s);
  }
}
void ICMainWindow::updateMask()
{
    QBitmap Bitmap(size());
    Bitmap.clear();
    QPainter Painter(&Bitmap);

    Painter.setClipRegion(getRegion());
    Painter.fillRect(rect(), Qt::color1);
    Painter.end();

    setMask(Bitmap);
}
void SlippyMapWidget::paintEvent(QPaintEvent*)
{
    QPainter Painter(this);
    Painter.fillRect(QRect(0,0,width(),height()),QColor(255,255,255));
    int LonRect = int(floor(p->Lon));
    int LonPixel = int(-(p->Lon - LonRect ) * TILESIZE + width()/2);
    int LatRect = int(floor(p->Lat));
    int LatPixel = int(-(p->Lat - LatRect ) * TILESIZE + height()/2);

    while (LatPixel > 0)
        LatPixel -=TILESIZE, --LatRect;
    while (LonPixel > 0)
        LonPixel -= TILESIZE, --LonRect;

    for (int x=LonPixel; x<width(); x += TILESIZE)
        for (int y=LatPixel; y<height(); y+= TILESIZE)
        {
            int ThisLonRect = LonRect + (x-LonPixel)/TILESIZE;
            int ThisLatRect = LatRect + (y-LatPixel)/TILESIZE;
            QPixmap* img = p->getImage(ThisLonRect,ThisLatRect);
            if (img)
                Painter.drawPixmap(x,y,*img);
            delete img;
        }
    Painter.setPen(QPen(Qt::NoPen));
    Painter.setBrush(QBrush(QColor(255,255,255,128)));
    Painter.drawRect(width()-21,0,20,20);
    Painter.drawRect(width()-21,height()-21,20,20);
    Painter.drawRect(width()-21,(height()/2)-10,20,20);


    Painter.setBrush(QBrush(QColor(0,0,0)));
    Painter.drawRect(width()-19,8,16,4);
    Painter.drawRect(width()-19,height()-13,16,4);
    Painter.drawRect(width()-13,height()-19,4,16);

    Painter.setFont(QFont("Times", 19, QFont::Bold));
    Painter.setPen(QPen(Qt::black, 3));
    Painter.setBrush(Qt::NoBrush);
    Painter.drawText(QPoint(width()-21,(height()/2)+10), "V");

    if (p->InSelection) {
        Painter.setPen(QPen(Qt::blue, 1, Qt::DashLine));
        Painter.drawRect(QRect(p->SelectionStart, p->SelectionEnd));
    } else if (!p->CurrentSelectionCoord.isNull()) {
        Painter.setPen(QPen(Qt::blue, 1));
        QPoint topLeft     = coord2relative(p->CurrentSelectionCoord.topLeft());
        QPoint bottomRight = coord2relative(p->CurrentSelectionCoord.bottomRight());
        Painter.drawRect(QRect(topLeft, bottomRight));
    }
}
Exemple #9
0
void sTabBorderBase::OnPaint(int layer)
{
    auto sty = Style();
    auto pnt = Painter();

    if(BoxesDirty)
        UpdateElements();

    sRect r(Outer);
    r.y1 = r.y0 + ReqSizeY;

    sty->Rect(layer,this,sSK_ToolBorder_Top,r);

    sDragDropIcon icon;
    int mx,my;
    int drophere = -1;
    if(Gui->GetDragDropInfo(this,icon,mx,my))
        drophere = FindDragDrop(icon,mx,my);

    if(drophere==0)
    {
        pnt->SetLayer(layer+1);
        pnt->Rect(sty->Colors[sGC_HoverFeedback],sRect(Client.x0,Client.y0,Client.x0+2,Client.y1));
    }

    int n = 0;
    for(sTabDummyElement *e : *Array)
    {
        sTabElementInfo &info = e->*Info;
        int mod = 0;
        if(Pressed && e==Selected)
            mod |= sSM_Pressed;
        if(e==*WindowSelect)
            mod |= sSM_WindowSel;
        if(e==*GlobalSelect)
            mod |= sSM_GlobalSel;
        if(info.HoverDelete && (Flags & sWF_Hover))
            mod |= sSM_HoverIcon;

        sty->Rect(layer,this,sSK_TabItem,info.Client,mod,info.Name);

        n++;
        if(n==drophere)
        {
            int x = info.Client.x1 + 4;
            pnt->SetLayer(layer+1);
            pnt->Rect(sty->Colors[sGC_HoverFeedback],sRect(x-1,Client.y0,x+1,Client.y1));
        }
    }
}
QPixmap* SlippyMapWidgetPrivate::getImage(int x, int y)
{
    int Max = 1 << Zoom;
    if (x<0 || x>=Max) return 0;
    if (y<0 || y>=Max) return 0;
    QPixmap* img = theWidget->theSlippyCache->getImage(x,y,Zoom);
    if (img) return img;
    img = new QPixmap(TILESIZE,TILESIZE);
    QPainter Painter(img);
    Painter.setPen(QColor(0,0,0));
    Painter.fillRect(0,0,TILESIZE-1,TILESIZE-1,QColor(255,255,255));
    Painter.drawRect(0,0,TILESIZE-1,TILESIZE-1);
    Painter.drawText(10,TILESIZE/2,(QApplication::translate("Downloader","Downloading %1,%2 (zoom %3)...")).arg(x).arg(y).arg(Zoom));
    return img;
}
Exemple #11
0
void CToolTip::Draw(void) const
{
	CWindow::Draw();

	if (m_pSDLSurface)
	{
		CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
		Painter.DrawRect(m_WindowRect.SizeRect(), false);
		CRect SubRect(m_WindowRect.SizeRect());
		SubRect.Grow(-2);
		if (m_pRenderedString.get())
		{
			m_pRenderedString->Draw(m_pSDLSurface, SubRect, SubRect.TopLeft(), m_FontColor);
		}
	}
}
void GraphvizView::exportSceneAsPNG()
{
  QString FileName = QFileDialog::getSaveFileName(this,
                                                  tr("导出为PNG文件"),
                                                  "export_spatialgraph.png",
                                                  tr("PNG文件 (*.png)"));

  if (!FileName.isEmpty())
  {
    QImage Image((int)scene()->sceneRect().width(),
                 (int)scene()->sceneRect().height(),
                 QImage::Format_ARGB32_Premultiplied);
    QPainter Painter(&Image);
    Painter.setRenderHint(QPainter::Antialiasing);
    scene()->render(&Painter);
    Image.save(FileName);
  }
}
Exemple #13
0
void sStatusBorder::OnPaint(int layer)
{
    int left = Client.SizeX();
    int spacers = 0;
    for(auto &i : Items)
    {
        left -= i.Size;
        if(i.Size==0)
            spacers++;
    }

    int x = Client.x0;
    int n = 0;
    for(auto &i : Items)
    {
        i.r.y0 = Client.y1-Height+1;
        i.r.y1 = Client.y1;
        i.r.x0 = x;
        x += i.Size;
        if(i.Size==0)
        {
            x += (n+1)*left/spacers - n*left/spacers;
            n++;
        }
        i.r.x1 = x;
    }

    auto pnt = Painter();
    auto sty = Style();

    sRect r = Client;
    r.y0 = r.y1 - Height;
    r.y1 = r.y0 + 1;
    pnt->SetLayer(layer+0);
    pnt->Rect(sty->Colors[sGC_Draw],r);
    int flag = 1;
    for(auto i : Items)
    {
        sty->Rect(layer,this,sSK_StatusBorder,i.r,flag,i.Text);
        flag = 0;
    }
}
void GraphvizView::exportSceneAsSVG()
{
  QString FileName = QFileDialog::getSaveFileName(this,
                                                  tr("导出为SVG文件"),
                                                  "export_spatialgraph.svg",
                                                  tr("SVG文件 (*.svg)"));

  if (!FileName.isEmpty())
  {
    QSvgGenerator SvgGen;

    QRectF ExportRect = scene()->itemsBoundingRect();

    SvgGen.setFileName(FileName);
    SvgGen.setSize(QSize((int)ExportRect.width(),
                         (int)ExportRect.height()));
    SvgGen.setViewBox(QRectF(0,0,ExportRect.width(),ExportRect.height()));

    QPainter Painter(&SvgGen);
    scene()->render(&Painter);
  }
}
Exemple #15
0
//allow user pass parameter and print document
void
PrinterWriter::noGuiPrint(QWidget *doc, QString printFile,
    QString page, int dpi, QString color, QString orientation)
{
  //set property
  Printer->setOutputFileName(printFile);

  //page size
  if (page == "A3") {
    Printer->setPaperSize(QPrinter::A3);
  } else if (page == "B4") {
    Printer->setPaperSize(QPrinter::B4);
  } else if (page == "B5") {
    Printer->setPaperSize(QPrinter::B5);
  } else {
    Printer->setPaperSize(QPrinter::A4);
  }
  //dpi
  Printer->setResolution(dpi);
  //color
  if (color == "BW") {
    Printer->setColorMode(QPrinter::GrayScale);
  } else {
    Printer->setColorMode(QPrinter::Color);
  }
  //orientation
  if (orientation == "landscape") {
    Printer->setOrientation(QPrinter::Landscape);
  } else {
    Printer->setOrientation(QPrinter::Portrait);
  }
  QPainter Painter(Printer);
  if(!Painter.device()) {      // valid device available ?
    return;
  }

  static_cast<Schematic *>(doc)->print(Printer, &Painter,
    Printer->printRange() == QPrinter::AllPages, fitToPage);
}
Exemple #16
0
void
PrinterWriter::print(QWidget *doc)
{
  QPrintDialog *dialog = new QPrintDialog(Printer, 0);
  dialog->setWindowTitle(QObject::tr("Print Document"));
  dialog->addEnabledOption(QAbstractPrintDialog::PrintSelection);

  if (QucsApp::isTextDocument(doc))
  {
    if (dialog->exec() == QDialog::Accepted) {
       static_cast<QPlainTextEdit *>(doc)->print(Printer);
    }
  }
  else {
    Printer->setOrientation(QPrinter::Landscape);

    if (dialog->exec() == QDialog::Accepted)
    {
      QPainter Painter(Printer);
      if(!Painter.device()) {     // valid device available ?
        delete dialog;
        return;
      }
      for (int z = Printer->numCopies(); z > 0; --z) {
        if (Printer->aborted()) {
          break;
        }

        static_cast<Schematic *>(doc)->print(Printer, &Painter,
                Printer->printRange() == QPrinter::AllPages, fitToPage);
        if (z > 1 && !Printer->newPage()) {
          delete dialog;
          return;
        }
      }
    }
  }
  delete dialog;
}
Exemple #17
0
void CGroupBox::Draw(void) const
{
	CWindow::Draw();

	if (m_pSDLSurface)
	{
		CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
		CRect rect = CRect(0, 5, m_WindowRect.Width() - 2, m_WindowRect.Height() - 6);
        Painter.DrawRect(rect, false, m_BackgroundColor * 0.3);
        rect = rect + CPoint(1, 1);
        Painter.DrawRect(rect, false, m_BackgroundColor * 1.6);
		CPoint Dims, Offset;
		m_pRenderedString->GetMetrics(&Dims, &Offset, nullptr);
		Painter.DrawRect(CRect(CPoint(6, 0), CPoint(14, 0) + Dims),
			true, m_BackgroundColor, m_BackgroundColor);

		if (m_pRenderedString.get())
		{
			m_pRenderedString->Draw(m_pSDLSurface, m_WindowRect.SizeRect(), CPoint(10, 0), m_FontColor);
		}
	}
}
void CNavigationBar::Draw(void) const {
	CWindow::Draw();
	if (m_pSDLSurface)
	{
		CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);        
		Painter.Draw3DLoweredRect(m_WindowRect.SizeRect(), DEFAULT_BACKGROUND_COLOR);
        SDL_Rect PictureSourceRect = CRect(CPoint(0, 0), 30, 30).SDLRect();
		for (unsigned int i = 0; i < m_Items.size(); ++i)
		{
			CRect ItemRect(CPoint(m_ClientRect.Left() + i*m_iItemWidth, m_ClientRect.Top()),
				m_iItemWidth , m_iItemHeight);
			if (ItemRect.Overlaps(m_ClientRect))
			{
				ItemRect.ClipTo(m_ClientRect);
				ItemRect.SetBottom(ItemRect.Bottom() - 1);
				ItemRect.SetRight(ItemRect.Right() - 1);
				if (i == m_iSelectedItem)
				{
					Painter.DrawRect(ItemRect, true, CApplication::Instance()->GetDefaultSelectionColor(), CApplication::Instance()->GetDefaultSelectionColor());
				}
				if (i == m_iFocusedItem && HasFocus())
				{
					ItemRect.Grow(1);
					Painter.DrawRect(ItemRect, false, CApplication::Instance()->GetDefaultSelectionColor() * 0.7);
					ItemRect.Grow(-1);
				}
				ItemRect.Grow(-1);
        // '- CPoint(0,1)' is to move the reference point one pixel up (otherwise the lowest pixels of p,g,q,y 
        // etc. are not fully visible.
				m_RenderedStrings.at(i).Draw(m_pSDLSurface, ItemRect, ItemRect.BottomLeft() - CPoint(0, 1) + CPoint(ItemRect.Width()/2, 0), m_Items[i].ItemColor);
        // Draw the picture (if available):
        if (m_Bitmaps.at(i) != nullptr) {
          SDL_Rect DestRect = ItemRect.Move(9, 1).SDLRect();
          SDL_BlitSurface(m_Bitmaps.at(i)->Bitmap(), &PictureSourceRect, m_pSDLSurface, &DestRect);
        }
			}
		}
	}
}
void SlippyMapWidget::paintEvent(QPaintEvent*)
{
    QPainter Painter(this);
    Painter.fillRect(QRect(0,0,width(),height()),QColor(255,255,255));
    int LatRect = int(floor(p->Lat));
    int LatPixel = int(-(p->Lat - LatRect ) * TILESIZE + width()/2);
    int LonRect = int(floor(p->Lon));
    int LonPixel = int(-(p->Lon - LonRect ) * TILESIZE + height()/2);
    while (LatPixel > 0)
        LatPixel -=TILESIZE, --LatRect;
    while (LonPixel > 0)
        LonPixel -= TILESIZE, --LonRect;
    for (int x=LatPixel; x<width(); x += TILESIZE)
        for (int y=LonPixel; y<height(); y+= TILESIZE)
        {
            int ThisLatRect = LatRect + (x-LatPixel)/TILESIZE;
            int ThisLonRect = LonRect + (y-LonPixel)/TILESIZE;
            QPixmap* img = p->getImage(ThisLatRect,ThisLonRect);
            if (img)
                Painter.drawPixmap(x,y,*img);
            delete img;
        }
    Painter.setPen(QPen(Qt::NoPen));
    Painter.setBrush(QBrush(QColor(255,255,255,128)));
    Painter.drawRect(width()-21,0,20,20);
    Painter.drawRect(width()-21,height()-21,20,20);
    Painter.drawRect(width()-21,(height()/2)-10,20,20);


    Painter.setBrush(QBrush(QColor(0,0,0)));
    Painter.drawRect(width()-19,8,16,4);
    Painter.drawRect(width()-19,height()-13,16,4);
    Painter.drawRect(width()-13,height()-19,4,16);

    Painter.setFont(QFont("Times", 19, QFont::Bold));
    Painter.setPen(QPen(Qt::black, 3));
    Painter.setBrush(Qt::NoBrush);
    Painter.drawText(QPoint(width()-21,(height()/2)+10), "V");
}
Exemple #20
0
void CPictureButton::Draw(void) const
{
	CWindow::Draw();

	if (m_pSDLSurface)
	{
		CRect SubRect(m_WindowRect.SizeRect());
		CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
		switch (m_eButtonState)
		{
		case UP:
			Painter.Draw3DRaisedRect(SubRect, DEFAULT_BUTTON_COLOR);
			break;
		case DOWN:
			Painter.Draw3DLoweredRect(SubRect, DEFAULT_BUTTON_COLOR);
			SubRect = SubRect + CPoint(1, 1);
			break;
		case DISABLED:
			break;
		default:
			break;
		}
		SubRect.Grow(-1);
		SDL_Rect SourceRect;
		SourceRect.x = stdex::safe_static_cast<short int>((m_phBitmap->Bitmap()->w - SubRect.Width()) / 2 < 0 ? 0 : (m_phBitmap->Bitmap()->w - SubRect.Width()) / 2);
		SourceRect.y = stdex::safe_static_cast<short int>((m_phBitmap->Bitmap()->h - SubRect.Height()) / 2 < 0 ? 0 : (m_phBitmap->Bitmap()->w - SubRect.Height()) / 2);
		SourceRect.w = stdex::safe_static_cast<short int>(std::min(SubRect.Width(), m_phBitmap->Bitmap()->w));
		SourceRect.h = stdex::safe_static_cast<short int>(std::min(SubRect.Height(), m_phBitmap->Bitmap()->h));
		SDL_Rect DestRect;
		DestRect.x = stdex::safe_static_cast<short int>((SubRect.Width() - m_phBitmap->Bitmap()->w) / 2 < 0 ? SubRect.Left() : SubRect.Left() + (SubRect.Width() - m_phBitmap->Bitmap()->w) / 2);
		DestRect.y = stdex::safe_static_cast<short int>((SubRect.Height() - m_phBitmap->Bitmap()->h) / 2 < 0 ? SubRect.Top() : SubRect.Top() + (SubRect.Height() - m_phBitmap->Bitmap()->h) / 2);
		DestRect.w = stdex::safe_static_cast<short int>(std::min(SubRect.Width(), m_phBitmap->Bitmap()->w));
		DestRect.h = stdex::safe_static_cast<short int>(std::min(SubRect.Height(), m_phBitmap->Bitmap()->h));
		SDL_BlitSurface(m_phBitmap->Bitmap(), &SourceRect, m_pSDLSurface, &DestRect);
	}
}
void QColorPushButton::paintEvent(QPaintEvent* pPaintEvent)
{
	setText("");

	QPushButton::paintEvent(pPaintEvent);

	QPainter Painter(this);

	// Get button rectangle
	QRect ColorRectangle = pPaintEvent->rect();

	// Deflate it
	ColorRectangle.adjust(m_Margin, m_Margin, -m_Margin, -m_Margin);

	// Use anti aliasing
	Painter.setRenderHint(QPainter::Antialiasing);

	// Rectangle styling
	Painter.setBrush(QBrush(isEnabled() ? m_Color : Qt::lightGray));
	Painter.setPen(QPen(isEnabled() ? QColor(25, 25, 25) : Qt::darkGray, 0.5));

	// Draw
	Painter.drawRoundedRect(ColorRectangle, m_Radius, Qt::AbsoluteSize);
}
Exemple #22
0
void ListElement::paintEvent(QPaintEvent *event)
{
    QPainter Painter(this);
    QWidget::paintEvent(event);

    if( mCurAlpha < 0 )
    {
        Painter.fillRect(rect(), mCurColor );
        mTimer.stop();
        return;
    }

    QColor From( palette().color(QPalette::Background) );
    From.setAlpha(mCurColor.alpha());
    QColor color =  Blend(From, mCurColor, float(mCurAlpha)/255.f );
    //color.setAlpha(curAlpha);

    Painter.fillRect(rect(), color );

    mCurAlpha -= 255.f * mTimer.interval() / 500.f;
    if( mCurAlpha <= 0 ) {
        mTimer.stop();
    }
}
void lcTimelineWidget::Update(bool Clear, bool UpdateItems)
{
	if (mIgnoreUpdates)
		return;

	lcModel* Model = lcGetActiveModel();

	if (!Model)
	{
		mItems.clear();
		clear();
		return;
	}

	bool Blocked = blockSignals(true);

	if (Clear)
	{
		mItems.clear();
		clear();
	}

	lcStep LastStep = lcMax(Model->GetLastStep(), Model->GetCurrentStep());

	for (int TopLevelItemIdx = LastStep; TopLevelItemIdx < topLevelItemCount(); )
	{
		QTreeWidgetItem* StepItem = topLevelItem(TopLevelItemIdx);

		while (StepItem->childCount())
		{
			QTreeWidgetItem* PieceItem = StepItem->child(0);
			lcPiece* Piece = (lcPiece*)PieceItem->data(0, Qt::UserRole).value<uintptr_t>();
			mItems.remove(Piece);
			delete PieceItem;
		}

		delete StepItem;
	}

	for (unsigned int TopLevelItemIdx = topLevelItemCount(); TopLevelItemIdx < LastStep; TopLevelItemIdx++)
	{
		QTreeWidgetItem* StepItem = new QTreeWidgetItem(this, QStringList(tr("Step %1").arg(TopLevelItemIdx + 1)));
        StepItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
		addTopLevelItem(StepItem);
		StepItem->setExpanded(true);
	}

	const lcArray<lcPiece*>& Pieces = Model->GetPieces();
	QTreeWidgetItem* StepItem = NULL;
	int PieceItemIndex = 0;
	lcStep Step = 0;

	for (int PieceIdx = 0; PieceIdx != Pieces.GetSize(); PieceIdx++)
	{
		lcPiece* Piece = Pieces[PieceIdx];

		while (Step != Piece->GetStepShow())
		{
			if (StepItem)
			{
				while (PieceItemIndex < StepItem->childCount())
				{
					QTreeWidgetItem* PieceItem = StepItem->child(PieceItemIndex);
					lcPiece* RemovePiece = (lcPiece*)PieceItem->data(0, Qt::UserRole).value<uintptr_t>();

					if (Pieces.FindIndex(RemovePiece) == -1)
					{
						mItems.remove(RemovePiece);
						delete PieceItem;
					}
					else
					{
						PieceItem->parent()->removeChild(PieceItem);
						topLevelItem(RemovePiece->GetStepShow() - 1)->addChild(PieceItem);
					}
				}
			}

			Step++;
			StepItem = topLevelItem(Step - 1);
			PieceItemIndex = 0;
		}

		QTreeWidgetItem* PieceItem = mItems.value(Piece);
		bool UpdateItem = UpdateItems;

		if (!PieceItem)
		{
			PieceItem = new QTreeWidgetItem();
			PieceItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled);
			PieceItem->setData(0, Qt::UserRole, qVariantFromValue<uintptr_t>((uintptr_t)Piece));
			StepItem->insertChild(PieceItemIndex, PieceItem);
			mItems[Piece] = PieceItem;

			UpdateItem = true;
		}
		else
		{
			if (PieceItemIndex >= StepItem->childCount() || PieceItem != StepItem->child(PieceItemIndex))
			{
				QTreeWidgetItem* PieceParent = PieceItem->parent();

				if (PieceParent)
					PieceParent->removeChild(PieceItem);

				StepItem->insertChild(PieceItemIndex, PieceItem);
			}
		}

		if (UpdateItem)
		{
			PieceItem->setText(0, Piece->mPieceInfo->m_strDescription);

			int ColorIndex = Piece->mColorIndex;
			if (!mIcons.contains(ColorIndex))
			{
				int Size = rowHeight(indexFromItem(PieceItem));

				QImage Image(Size, Size, QImage::Format_ARGB32);
				Image.fill(QColor::fromRgbF(1.0, 1.0, 1.0, 0.0));

				float* Color = gColorList[ColorIndex].Value;
				QPainter Painter(&Image);
				Painter.setPen(Qt::NoPen);
				Painter.setBrush(QColor::fromRgbF(Color[0], Color[1], Color[2]));
				Painter.drawEllipse(QPoint(Size / 2, Size / 2), Size / 2, Size / 2);

				mIcons[ColorIndex] = QIcon(QPixmap::fromImage(Image));
			}

			PieceItem->setIcon(0, mIcons[ColorIndex]);

			QColor Color = palette().text().color();
			if (Piece->IsHidden())
				Color.setAlpha(128);
			PieceItem->setTextColor(0, Color);
		}

		PieceItem->setSelected(Piece->IsSelected());
		PieceItemIndex++;
	}

	if (Step == 0)
	{
		Step = 1;
		StepItem = topLevelItem(0);
	}

	while (Step <= LastStep)
	{
		while (PieceItemIndex < StepItem->childCount())
		{
			QTreeWidgetItem* PieceItem = StepItem->child(PieceItemIndex);
			lcPiece* RemovePiece = (lcPiece*)PieceItem->data(0, Qt::UserRole).value<uintptr_t>();

			mItems.remove(RemovePiece);
			delete PieceItem;
		}

		Step++;
		StepItem = topLevelItem(Step - 1);
		PieceItemIndex = 0;
	}

	blockSignals(Blocked);
}
Exemple #24
0
void TOSMWidget::paintEvent(QPaintEvent *)
{
    qDebug() << "Paint event";
    QImage newImage(QSize(rect().width(), rect().height()), QImage::Format_ARGB32);
    QPainter Painter(&newImage);
//    Painter.set
//    QPaintDevice t;

//    Painter.begin(&newImage);


    Painter.setPen(QPen(QColor(0, 0, 0)));

    midWayAttr = stWA.Median(drawProp);

    long long i = 0;
    for (TNWaysIter it = nways.begin(); it != nways.end(); it++)
    {
        TNWay *way = &it.value();
//        qDebug() << "F " << way->attrF << " R" << way->attrR << " / " << maxWayAttr;
//        bool deadEndF = MyNodes[way->nodes.last()].containedBy.size() == 1, deadEndR = MyNodes[way->nodes.first()].containedBy.size() == 1;



//        double v = way->Usage();

//        if ((way->usageF > 0) && (way->usageR > 0))
//        {
//            Painter.setPen(QPen(QColor(0, 255, 0)));
//            Painter.drawEllipse(w2s_p(MyNodes[way->nodes.first()].toPointF()), 25, 25);
//        }
//        else

//        if (v > midWayAttr)
//        {
//            Painter.setPen(QPen(QColor(255, 0, 0)));
//        }
//        else
//        {
//            Painter.setPen(QPen(QColor(0, 0, 255)));
//        }

//        / maxWayAttr;
//        Painter.setPen(QPen(QColor(long(v * 255) % 256, 0, 255 - long(v * 255) % 256)));

        bool first = true;
        QPointF prevP;
//        double dist1 = MyNodes[(*it).nodes.first()].attr,
//                dist2 = MyNodes[(*it).nodes.last()].attr,
//                wlen = (*it).Weight(),
//                wdist = 0.0;
        i++;
//        Painter.setPen(QPen(QColor((i*i)%200, ((i+11)*(i+11))%200, ((i+19)*(i+19))%200)));
        switch (way->roadClass())
        {
            case TOSMWidget::TNWay::EW_Trunk:
            case TOSMWidget::TNWay::EW_Motorway:
            case TOSMWidget::TNWay::EW_Raceway:
            case TOSMWidget::TNWay::EW_Primary: Painter.setPen(QPen(QColor(63, 200, 63))); break;
            case TOSMWidget::TNWay::EW_Tertiary:
            case TOSMWidget::TNWay::EW_Road:
            case TOSMWidget::TNWay::EW_Unclassified:
            case TOSMWidget::TNWay::EW_Secondary: Painter.setPen(QPen(QColor(100, 150, 63))); break;
            case TOSMWidget::TNWay::EW_LivingStreet:
            case TOSMWidget::TNWay::EW_Service: Painter.setPen(QPen(QColor(130, 100, 63))); break;
            case TOSMWidget::TNWay::EW_Residental: Painter.setPen(QPen(QColor(170, 90, 63))); break;
            case TOSMWidget::TNWay::EW_BusGuideway:
            case TOSMWidget::TNWay::EW_Track: Painter.setPen(QPen(QColor(200, 60, 63))); break;
            case TOSMWidget::TNWay::EW_Path:
            case TOSMWidget::TNWay::EW_Footway:
            case TOSMWidget::TNWay::EW_Steps:
            case TOSMWidget::TNWay::EW_Bridleway:
            case TOSMWidget::TNWay::EW_Construction:
            case TOSMWidget::TNWay::EW_Proposed:
            case TOSMWidget::TNWay::EW_Pedestrian: Painter.setPen(QPen(QColor(200, 200, 200))); break;
        default:
            Painter.setPen(QPen(QColor(0, 0, 0)));
        }

//        Painter.setPen(QPen(QColor((i*i)%200, ((i+11)*(i+11))%200, ((i+19)*(i+19))%200)));
        for (QList <TID> ::Iterator it_n = way->nodes.begin(); it_n != way->nodes.end(); it_n++)
        {
//            double dist = std::min(dist1 + wdist, dist2 + wlen - wdist);
//            Painter.setPen(QPen(QColor(long((dist*256/10)) % 256, 128, 128)));
            QPointF curP = nnodes[*it_n].toPointF();
            if ((nnodes[*it_n].metrica > 0.0) && (nnodes[*it_n].metrica < W_INF))
            {
                Painter.drawText(w2s_p(curP),QString::number(nnodes[*it_n].metrica));
            }
            if (!first)
            {
                drawLine(Painter, QLineF(prevP, curP));
//                wdist += fabs(distance(curP, prevP));
            }
            first = false;
            prevP = curP;
        }
    }

//    Painter.setPen(QPen(QColor(0, 0, 0)));
//    Painter.drawEllipse(w2s_p(MyNodes[*MyCrosses.begin()].toPointF()), 5, 5);

    Painter.setPen(QPen(QColor(0, 200, 0)));

    for (int i = 0; i < markers.size(); i++)
    {
//        qDebug() << "drawing marker " << markers[i];
//        QRect pieRect = QRect(
//                            w2s_x(markers[i].x())-20,
//                            w2s_y(markers[i].y())-20,
//                            w2s_x(markers[i].x())+20,
//                            w2s_y(markers[i].y())+20);
//        Painter.drawPie(pieRect, (90-10)*16, (90+10)*16);
        Painter.drawEllipse(w2s_p(markers[i]), 15, 15);
        Painter.drawEllipse(w2s_p(nnodes[nearestNode(markers[i])].toPointF()), 10, 10);
    }

    Painter.setPen(QPen(QColor(0, 255, 0)));
    QPointF p;
    bool first = true;
    for (QList <TID> ::Iterator it = path.nodes.begin(); it != path.nodes.end(); it++)
    {
        Painter.drawEllipse(w2s_p(nnodes[*it].toPointF()), 5, 5);
        first = false;
    }

//    for (QList <TWay> ::Iterator it = MyWays.begin(); it != MyWays.end(); it++)
//    {
//        TNWay *way = &(*it);
//        for (QList <TID> ::Iterator itn = way->nodes.begin(); itn != way->nodes.end(); itn++)
//        {

//        }
//    }

//    this->
//    Painter.drawImage();
//    Painter.end();

    QPainter newPainter(this);
    qDebug() << "rect " << this->rect();
    newPainter.drawRect(this->rect());
//    qDebug() << "rect " << this->rect();
//    newPainter.fillRect(this->Rect, QBrush(Qt::white));
    newPainter.drawImage(QPoint(0,0), newImage);

}
Exemple #25
0
//
// Notice_Procedure
//
// This window procedure handles messages that are sent to a notice window.
//
LRESULT CALLBACK Notice_Procedure(
  HWND   Notice_Window,
  UINT   Message,
  WPARAM wParam,
  LPARAM lParam
  )
  {
    static int	Char_Height;
    static int  Char_Width;
    static bool	HaveTextInfo = false;

    try {
	
      if (!HaveTextInfo) {
        TEXTMETRIC Text_Metrics;
        HDC        Context_Handle;

        Tracer(2, "Getting font size information in the notice window.");

        Context_Handle = GetDC(Notice_Window);
        SelectObject(Context_Handle, GetStockObject(OEM_FIXED_FONT));
        GetTextMetrics(Context_Handle, &Text_Metrics);
        Char_Height = Text_Metrics.tmHeight + Text_Metrics.tmExternalLeading;
        Char_Width  = Text_Metrics.tmAveCharWidth;
        ReleaseDC(Notice_Window, Context_Handle);

        HaveTextInfo = true;
      }
	
      switch (Message) {

        case WM_PAINT: {
            spica::Win32::Paint_Context Painter(Notice_Window);

            if (Current_Notice != 0) 
              Current_Notice->Redraw(Notice_Window, Painter);
          }
          return 0;

        case WM_HSCROLL: {
            Tracer(2, "Processing WM_HSCROLL in the notice window.");
            if (Current_Notice != 0)
              Current_Notice->HScroll(Notice_Window, wParam, Char_Width);
          }
          return 0;

        case WM_VSCROLL: {
            Tracer(2, "Processing WM_VSCROLL in the notice window.");
            if (Current_Notice != 0)
    	      Current_Notice->VScroll(Notice_Window, wParam, Char_Height);
          }
          return 0;

        case WM_CLOSE:
          Current_Notice = 0;
          DestroyWindow(Notice_Window);
          return 0;
      }

    }
    catch (spica::Win32::API_Error We) {
      spica::Win32::notifystream Error_Message;

      Error_Message << "Exception caught in the notice window\r" << We.what() << ends;
      Error_Message.say(Notice_Window);
      return 0;
    }
    catch (...) {
      spica::Win32::notifystream Error_Message;

      Error_Message << "Unknown exception caught in the notice window" << ends;
      Error_Message.say(Notice_Window);
      return 0;
    }

    return DefMDIChildProc(Notice_Window, Message, wParam, lParam);
  }
Exemple #26
0
void MidiTimelineNode::drawBackground( const KeyFramesWidgetInterface *pTrackWidget, const QRect &pUpdateRect, QImage &pBackImage ) const
{
	QPainter		Painter( &pBackImage );

	Painter.drawImage( pUpdateRect, pTrackWidget->viewImage(), pUpdateRect );

	if( !mEvents.isEmpty() )
	{
		Painter.setPen( Qt::red );

		QList<quint8>	Notes;

		int				j = 0;

		for( int i = pUpdateRect.left() ; i <= pUpdateRect.right() ; i++ )
		{
			const qint64	t1 = qint64( mKF->time( pTrackWidget->viewToTimestamp( i ) ) * 1000.0 );

			QList<quint8>	SliceNotes = Notes;

			while( j > 0 )
			{
				if( j < mEvents.size() )
				{
					fugio::MidiEvent	ME = mEvents[ j ];

					if( ME.timestamp <= t1 )
					{
						break;
					}
				}

				j--;
			}

			while( j < mEvents.size() )
			{
				fugio::MidiEvent	ME = mEvents[ j ];

				if( ME.timestamp > t1 )
				{
					break;
				}

				quint8	Status = Pm_MessageStatus( ME.message ) & 0xf0;
				quint8	Data1  = Pm_MessageData1( ME.message );
				quint8	Data2  = Pm_MessageData2( ME.message );

				if( Status == MIDI_NOTE_ON && Data2 > 0 )
				{
					Notes.removeAll( Data1 );
					Notes.append( Data1 );

					SliceNotes.removeAll( Data1 );
					SliceNotes.append( Data1 );
				}
				else if( Status == MIDI_NOTE_OFF || ( Status == MIDI_NOTE_ON && Data2 == 0 ) )
				{
					Notes.removeAll( Data1 );
				}

				j++;
			}

			if( i > pUpdateRect.left() )
			{
				for( quint8 n : SliceNotes )
				{
					qint32			y1 = pTrackWidget->valueToView( qreal( n ) / 127.0 );

					Painter.drawPoint( i, y1 );
				}
			}
			else
			{
				for( quint8 n : Notes )
				{
					qint32			y1 = pTrackWidget->valueToView( qreal( n ) / 127.0 );

					Painter.drawPoint( i, y1 );
				}
			}
		}
	}
}
void GenerateTopologyMap (CUniverse &Universe, CXMLElement *pCmdLine)
	{
	int i;

	//	Some parameters

	int iScale = pCmdLine->GetAttributeIntegerBounded(CONSTLIT("scale"), 100, -1, -1);

	//	We need to create all systems so that the global object table is 
	//	initialized.

	for (i = 0; i < Universe.GetTopologyNodeCount(); i++)
		{
		CTopologyNode *pNode = Universe.GetTopologyNode(i);

		//	Do not try to create end game nodes

		if (pNode->IsEndGame())
			continue;

		//	Node is known

		pNode->SetKnown();

		//	Create this system

		CSystem *pNewSystem;
		CString sError;
		if (Universe.CreateStarSystem(pNode, &pNewSystem, &sError) != NOERROR)
			{
			printf("ERROR: creating system %s: %s\n", (LPSTR)pNode->GetSystemName(), (LPSTR)sError);
			continue;
			}

		//	Delete the system

		Universe.FlushStarSystem(pNode);
		}

	//	Initialize the output

	COutputChart Output;
	Output.SetStyleFont(STYLE_NAME, pCmdLine->GetAttribute(CONSTLIT("font")));
	Output.SetStyleColor(STYLE_NAME, CG32bitPixel(0xFF, 0xFF, 0xFF));

	Output.SetOutputFilespec(pCmdLine->GetAttribute(CONSTLIT("output")));

	//	Get the topology node

	CTopologyNode *pFirstNode = Universe.GetFirstTopologyNode();
	if (pFirstNode == NULL)
		{
		printf("ERROR: Unable to find topology node.\n");
		return;
		}

	//	Get the system map for the node

	CSystemMap *pMap = pFirstNode->GetDisplayPos();
	if (pMap == NULL)
		{
		printf("ERROR: No system map for node %s.\n", pFirstNode->GetID().GetASCIIZPointer());
		return;
		}

	//	If we didn't set a scale, use the map's initial scale

	if (iScale == -1)
		pMap->GetScale(&iScale);

	//	Initialize painting structures

	CSystemMapThumbnails Thumbs;
	Thumbs.Init(Universe.GetGlobalObjects());

	CGalacticMapPainter Painter(Universe, pMap, Thumbs);
	int cxMap = Painter.GetWidth() * iScale / 100;
	int cyMap = Painter.GetHeight() * iScale / 100;

	//	Compute the size of the map

	RECT rcView;
	rcView.left = 0;
	rcView.top = 0;
	rcView.right = cxMap;
	rcView.bottom = cyMap;

	//	Create the output

	Output.SetContentSize(cxMap, cyMap);
	CG32bitImage &Dest = Output.GetOutputImage();

	//	Paint

    Painter.SetViewport(rcView);
    Painter.SetScale(iScale);
    Painter.SetPos(0, 0);
	Painter.Paint(Dest);

	//	Done

	Output.Output();
	}
Exemple #28
0
void ezQGridBarWidget::paintEvent(QPaintEvent* e)
{
  if (!MapFromSceneFunc.IsValid())
  {
    QWidget::paintEvent(e);
    return;
  }

  QPainter Painter(this);
  QPainter* painter = &Painter;
  painter->setRenderHint(QPainter::Antialiasing);
  painter->setRenderHint(QPainter::TextAntialiasing);
  painter->setRenderHint(QPainter::HighQualityAntialiasing);

  QRect areaRect = rect();

  // background
  painter->fillRect(areaRect, palette().button());
  painter->translate(0.5, 0.5);

  // render fine grid stop lines
  {
    double fSceneMinX, fSceneMaxX;
    ezWidgetUtils::ComputeGridExtentsX(m_viewportSceneRect, m_fFineGridStops, fSceneMinX, fSceneMaxX);
    fSceneMinX = ezMath::Max(fSceneMinX, 0.0);

    painter->setPen(palette().buttonText().color());

    ezHybridArray<QLine, 100> lines;

    // some overcompensation for the case that the GraphicsView displays a scrollbar at the side
    for (double x = fSceneMinX; x <= fSceneMaxX + m_fTextGridStops; x += m_fFineGridStops)
    {
      const QPoint pos = MapFromSceneFunc(QPointF(x, 0));

      QLine& l = lines.ExpandAndGetRef();
      l.setLine(pos.x(), areaRect.bottom() - 3, pos.x(), areaRect.bottom());
    }

    painter->drawLines(lines.GetData(), lines.GetCount());
  }

  // Grid Stop Value Text
  {
    double fSceneMinX, fSceneMaxX;
    ezWidgetUtils::ComputeGridExtentsX(m_viewportSceneRect, m_fTextGridStops, fSceneMinX, fSceneMaxX);
    fSceneMinX = ezMath::Max(fSceneMinX, 0.0);

    QTextOption textOpt(Qt::AlignCenter);
    QRectF textRect;

    painter->setPen(palette().buttonText().color());

    ezStringBuilder tmp;

    for (double x = fSceneMinX; x <= fSceneMaxX; x += m_fTextGridStops)
    {
      const QPoint pos = MapFromSceneFunc(QPointF(x, 0));

      textRect.setRect(pos.x() - 50, areaRect.top(), 99, areaRect.height());
      tmp.Format("{0}", ezArgF(x));

      painter->drawText(textRect, tmp.GetData(), textOpt);
    }
  }
}
Exemple #29
0
void sScrollBorder::OnPaint(int layer)
{
    sRect r;

    uint lo = Style()->Colors[sGC_Low];
    uint hi = Style()->Colors[sGC_High];
    //  uint ba = Style()->Colors[sGC_Back];
    uint bu = Style()->Colors[sGC_Button];
    int f = Style()->ScrollBorderFrameSize;
    sWindow *root = BorderParent;
    BarX.Set();
    BarY.Set();

    if(EnableX)
    {
        Painter()->SetLayer(layer);
        r = RectX;
        Painter()->Frame(hi,lo,r,f);
        r.Extend(-f);
        Style()->Rect(layer,this->FocusParent,sSK_Back,r);
        //    Painter()->Rect(ba,r);

        if(root->Inner.SizeX()<root->ReqSizeX && root->Inner.SizeX()>0)
        {
            int s = r.SizeX();
            int h = sMax(root->Inner.SizeX()*s/root->ReqSizeX, sMin(Style()->ScrollBorderSize,s/2));
            r.x0 = r.x0 + root->ScrollX * (s-h) / (root->ReqSizeX-root->Inner.SizeX());
            r.x1 = r.x0 + h;
            BarX = r;

            Painter()->SetLayer(layer+1);
            Painter()->Frame(hi,lo,r,f);
            r.Extend(-f);
            Painter()->Rect(bu,r);
        }
    }
    if(EnableY)
    {
        Painter()->SetLayer(layer);
        r = RectY;
        Painter()->Frame(hi,lo,r,f);
        r.Extend(-f);
        Style()->Rect(layer,this->FocusParent,sSK_Back,r);
        //    Painter()->Rect(ba,r);

        if(root->Inner.SizeY()<root->ReqSizeY && root->Inner.SizeY()>0)
        {
            int s = r.SizeY();
            int h = sMax(root->Inner.SizeY()*s/root->ReqSizeY, sMin(Style()->ScrollBorderSize,s/2));
            r.y0 = r.y0 + root->ScrollY * (s-h) / (root->ReqSizeY-root->Inner.SizeY());
            r.y1 = r.y0 + h;
            BarY = r;

            Painter()->SetLayer(layer+1);
            Painter()->Frame(hi,lo,r,f);
            r.Extend(-f);
            Painter()->Rect(bu,r);
        }
    }
    if(EnableX && EnableY)
    {
        Painter()->SetLayer(layer);
        Style()->Rect(layer,this->FocusParent,sSK_Back,RectC);
        //    Painter()->Rect(ba,RectC);
    }
}