Ejemplo n.º 1
0
int
TTabCheckList::GetAverageCharWidths()
{
  LOGFONT logFont = TFont(GetWindowFont()).GetObject();
  int nBaseUnit = logFont.lfWidth;
  if(nBaseUnit == 0)
    nBaseUnit = LoUint16(::GetDialogBaseUnits());
  return nBaseUnit;
}
Ejemplo n.º 2
0
void TAbstractWindow::_draw(TRenderTarget& target) {
    if (needsRedraw == true) {
        TRenderTarget& localTarget = renderImage.getRenderTarget();
        localTarget.clear(_currentColor());
        if (image.drawingObject != nullptr) {
            if (image.image != nullptr) {
                sf::Sprite* sprite = image.drawingObject.get();
                if (sprite != nullptr) {
                    sprite->setColor(_currentColor());
                }
            }
            localTarget.draw(*image.drawingObject);
        }

        if (HasHeader() == true) {
            sf::RectangleShape headerRect( sf::Vector2f(size.x, headerHeight) );
            headerRect.setFillColor(_currentHeaderColor());
            localTarget.draw(headerRect);
        }

        if (headerText->GetText().empty() == false) {
            headerText->Draw(localTarget);
        }

        renderImage.createDrawingObject();
        needsRedraw = false;
    }

    const TCoordinate position = GetScreenPosition();
    renderImage.getDrawingObject().setPosition(position.x, position.y);
    target.draw(renderImage.getDrawingObject());

#if defined(_DEBUG)
    if (Debug::show_frames() == true) {
        sf::RectangleShape boundingRect( sf::Vector2f(size.x, size.y) );
        boundingRect.setFillColor(sf::Color(0, 0, 0, 0));
        boundingRect.setOutlineColor(sf::Color(0, 255 - 55 * mouseOver, 0, 128));
        boundingRect.setOutlineThickness(2.f);
        boundingRect.setPosition(position.x, position.y);
        target.draw(boundingRect);

        sf::Text rectText = TFont().CreateText(String::toWide(name));
        rectText.setPosition(position.x, position.y);
        target.draw(rectText);
    }
#endif // _DEBUG
}
Ejemplo n.º 3
0
//
/// Handles WM_SETFONT. Deletes any cached font and stores copy of new one.
//
void
TUrlLink::EvSetFont(HFONT hFont, bool redraw)
{
  TStatic::EvSetFont(hFont, redraw);
  try
  {
    LOGFONT logFont = TFont(hFont).GetObject();
    logFont.lfUnderline = bUnderline;
    delete LinkFont;
    LinkFont = new TFont(logFont);
    if (redraw)
      Invalidate();  
  }
  catch(const TXGdi&)
  {
    WARN(true, "TUrlLink::EvSetFont failed.");
  }
}
Ejemplo n.º 4
0
 void TWindowPrintout::PrintPage(int Pagina, TRect& /*rect*/, unsigned){

	Estado.DistanciaPuntos*=4;

	//DC->SetMapMode(MM_LOMETRIC);

	if( Pagina==1 )
	  ArreglarPaginas();

	//no se va a utilizar...   Window->Paint(*DC, FALSE, rect);

	Impresor= DC;
	Impresor->SelectObject(*LapizSolido);
	Impresor->SelectObject( *Brocha );
	Impresor->SelectObject( TFont( Estado.DistanciaPuntos,
			  int(float(Estado.DistanciaPuntos)*3.0/7.0), 0, 0,
			  FW_NORMAL, 0, 0, 0,ANSI_CHARSET,
			  OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
			  DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, NULL));

	int Fila= (Pagina-1)/ListaHojas.GetActualNPaginasX();
	int Columna= (Pagina-1)%ListaHojas.GetActualNPaginasX();

	int ActualX= ListaHojas.GetActualInicioXImp() + Columna*PageSize.cx ;
	int ActualY= Fila*PageSize.cy;

	/*
	Se llama a la funcion DibujarImp (hecha en la casa de fabian el 26-09-97)
	de todos los objetos del actual subprograma, enviando a ActualX y ActualY
	como argumentos para el punto de referencia,  para que se dibujen en la
	pagina que se esta imprimiendo .
	*/
	ObjetoEjecucion *ActualObjeto= ListaHojas.GetActualSubprograma();

	while( ActualObjeto ){
	  ActualObjeto->DibujarImp( ActualX, ActualY );
	  ActualObjeto= ActualObjeto->GetPunteroEnHoja();
	}

	Estado.DistanciaPuntos/=4;

 }
Ejemplo n.º 5
0
void TFuncSpecView::Paint(TDC& dc, bool erase, TRect& rect)
{
  TSwitchMinApp* theApp = TYPESAFE_DOWNCAST(GetApplication(), TSwitchMinApp);
  if (theApp) {
    // Only paint if we're printing and we have something to paint, otherwise do nothing.
    //
    if (theApp->Printing && theApp->Printer && !rect.IsEmpty()) {
      // Use pageSize to get the size of the window to render into.  For a Window it's the client area,
      // for a printer it's the printer DC dimensions and for print preview it's the layout window.
      //
      TSize   pageSize(rect.right - rect.left, rect.bottom - rect.top);

      TPrintDialog::TData& printerData = theApp->Printer->GetSetup();

      // Get area we can draw in
      TRect drawingArea(swdoc->PaintHeader(dc, rect, "", 0, 0, false), rect.BottomRight());

      TEXTMETRIC tm;
      dc.SelectObject(TFont("Arial", -12));
      if (!dc.GetTextMetrics(tm)) {
        dc.SelectObject(TFont("Arial", -12));
        dc.GetTextMetrics(tm);
      }
      int fHeight=tm.tmHeight+tm.tmExternalLeading;

      unsigned long inputs=swdoc->GetSystem()->GetInputs();

      XPosVector xpos;
      uint divider;
      char* data;

      Print_CreateWidths(xpos, divider, dc);
      if (xpos.back().x < rect.Size().cx) {  // put space in structure to stretch across page
        uint spacing=(rect.Size().cx - xpos.back().x)/(xpos.size()+1);
        uint space_inc=spacing;
        for(XPosVector::size_type i=0; i<xpos.size(); i++) {
          if (i==inputs) {  // after inputs section, increase divider
            divider += space_inc;
            space_inc += spacing;
          }
          xpos[i].x += space_inc;
          space_inc += spacing;
        }
      }

      data=new char[xpos.size()];

      unsigned long PagesDown=1+pow(2,inputs)/( (drawingArea.Size().cy/fHeight) - 2);  // 2 lines for header and horz divider
      unsigned long PagesAcross=1+xpos.back().x/drawingArea.Size().cx;
      unsigned long Pages=1+PagesDown*PagesAcross;

      // Compute the number of pages to print.
      //
      printerData.MinPage = 1;
      printerData.MaxPage = Pages;


      int fromPage = printerData.FromPage == -1 ? 1 : printerData.FromPage;
      int toPage = printerData.ToPage == -1 ? 1 : printerData.ToPage;
      int currentPage = fromPage;

      TPoint p;

      dc.SelectObject(TPen(TColor::Black));

      while (currentPage <= toPage) {
        swdoc->PaintHeader(dc, rect, "Specification", currentPage, Pages, true);
        if (currentPage==1) Print_Summary(dc, drawingArea);
        else {
          // Calculate origin of line by page number
            // x
            int col=((currentPage-2) ) % PagesAcross;
            p.x=drawingArea.left - col * drawingArea.Size().cx;
            // y
            int row=floor((currentPage-2)/PagesAcross);
            p.y=drawingArea.top/* - row * drawingArea.Size().cy*/;

          // Calculate starting and ending input states
          CELL_TYPE state, stateEnd;
          state=(row*(drawingArea.Size().cy-fHeight))/fHeight;
          stateEnd=state+(drawingArea.Size().cy-fHeight)/fHeight;
          if (stateEnd >= (pow(2,inputs)-1) ) stateEnd=pow(2,inputs)-1;

          //
          // Draw header and lines

          // Vertical
          if ( ((p.x+divider) > drawingArea.left) && ((p.x+divider)<drawingArea.right) ) {
            dc.MoveTo(p.x+divider, p.y);
            dc.LineTo(p.x+divider, p.y+((stateEnd-state)+3)*fHeight);
          }

          // Labels
          for(XPosVector::size_type i=0; i<xpos.size(); i++)
            dc.TextOut(TPoint(xpos[i].x, p.y), xpos[i].s.c_str());
          p.y += fHeight;

          // Horizontal
          dc.MoveTo(drawingArea.left, p.y + fHeight/2);
          dc.LineTo(p.x+xpos.back().x, p.y + fHeight/2);
          p.y += fHeight;

          //
          // Draw each line
          while(state <= stateEnd) {
            Print_GenerateLine(data, state);
            Print_Line(dc, p, xpos, data);
            p.y += fHeight;
            state++;
          }
        }

        currentPage++;
      }

      delete[] data;
    }
    else {
      // INSERT>> Normal painting code goes here.
      wTabs->InvalidateRect(rect, erase);
    }
  }
}
Ejemplo n.º 6
0
//
// Paint routine for Window, Printer, and PrintPreview for a TEdit/TListBox client.
//
void poundsMDIChild::Paint (TDC& dc, BOOL, TRect& rect)
{
    poundsApp *theApp = TYPESAFE_DOWNCAST(GetApplication(), poundsApp);
    if (theApp) {
        // Only paint if we're printing and we have something to paint, otherwise do nothing.
        if (theApp->Printing && theApp->Printer && !rect.IsEmpty()) {
            // Use pageSize to get the size of the window to render into.  For a Window it's the client area,
            // for a printer it's the printer DC dimensions and for print preview it's the layout window.
            TSize   pageSize(rect.right - rect.left, rect.bottom - rect.top);

            HFONT   hFont = (HFONT)GetClientWindow()->GetWindowFont();
            TFont   font("Arial", -12);
            if (hFont == 0)
              dc.SelectObject(font);
            else
              dc.SelectObject(TFont(hFont));

            TEXTMETRIC  tm;
            int fHeight = (dc.GetTextMetrics(tm) == TRUE) ? tm.tmHeight + tm.tmExternalLeading : 10;

            // How many lines of this font can we fit on a page.
            int linesPerPage = MulDiv(pageSize.cy, 1, fHeight);
            if (linesPerPage) {
                TPrintDialog::TData &printerData = theApp->Printer->GetSetup();

                int maxPg = 1;

                // Get the client class window (this is the contents we're going to print).
                TEdit *clientEditWindow /* = 0*/;
                TListBox *clientListWindow = 0;
                TWindow *clientUnknownWindow = 0;

                clientEditWindow = TYPESAFE_DOWNCAST(GetClientWindow(), TEdit);
                if (clientEditWindow)
                    maxPg = ((clientEditWindow->GetNumLines() / linesPerPage) + 1.0);
                else {
                    clientListWindow = TYPESAFE_DOWNCAST(GetClientWindow(), TListBox);
                    if (clientListWindow)
                        maxPg = ((clientListWindow->GetCount() / linesPerPage) + 1.0);
                    else
                       clientUnknownWindow = TYPESAFE_DOWNCAST(GetClientWindow(), TWindow);
                }

                // Compute the number of pages to print.
                printerData.MinPage = 1;
                printerData.MaxPage = maxPg;

                // Do the text stuff:
                int     fromPage = printerData.FromPage == -1 ? 1 : printerData.FromPage;
                int     toPage = printerData.ToPage == -1 ? 1 : printerData.ToPage;
                char    buffer[255];
                int     currentPage = fromPage;

                while (currentPage <= toPage) {
                    int startLine = (currentPage - 1) * linesPerPage;
                    int lineIdx = 0;
                    while (lineIdx < linesPerPage) {
                        // If the string is no longer valid then there's nothing more to display.
                        if (clientEditWindow) {
                            if (!clientEditWindow->GetLine(buffer, sizeof(buffer), startLine + lineIdx))
                                break;
                        }
                        else if (clientListWindow) {
                            if (clientListWindow->GetString(buffer, startLine + lineIdx) < 0)
                                break;
                        }
                        else if (clientUnknownWindow) {
                           clientUnknownWindow->Paint(dc, FALSE, rect);
                           break;
                        }
                        dc.TabbedTextOut(TPoint(0, lineIdx * fHeight), buffer, lstrlen(buffer), 0, NULL, 0);
                        lineIdx++;
                    }
                    currentPage++;
                }
            }
        }
    }
}