Esempio n. 1
0
void wxGraphicsContext::SetPen( const wxPen& pen )
{
    if ( !pen.Ok() || pen.GetStyle() == wxTRANSPARENT )
        SetPen( wxNullGraphicsPen );
    else
        SetPen( CreatePen( pen ) );
}
Esempio n. 2
0
void
wxGraphicsContext::DoDrawFilledText(const wxString &str,
                                    wxDouble x,
                                    wxDouble y,
                                    const wxGraphicsBrush& backgroundBrush)
{
    wxGraphicsBrush formerBrush = m_brush;
    wxGraphicsPen formerPen = m_pen;
    wxDouble width;
    wxDouble height;
    wxDouble descent;
    wxDouble externalLeading;
    GetTextExtent( str , &width, &height, &descent, &externalLeading );
    SetBrush( backgroundBrush );
    // to make sure our 'OffsetToPixelBoundaries' doesn't move the fill shape
    SetPen( wxNullGraphicsPen );

    wxGraphicsPath path = CreatePath();
    path.AddRectangle( x , y, width, height );
    FillPath( path );

    DrawText( str, x ,y);
    SetBrush( formerBrush );
    SetPen( formerPen );
}
Esempio n. 3
0
void wxGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle, const wxGraphicsBrush& backgroundBrush )
{
    wxGraphicsBrush formerBrush = m_brush;
	wxGraphicsPen formerPen = m_pen;

    wxDouble width;
    wxDouble height;
    wxDouble descent;
    wxDouble externalLeading;
    GetTextExtent( str , &width, &height, &descent, &externalLeading );
    SetBrush( backgroundBrush );
	// to make sure our 'OffsetToPixelBoundaries' doesn't move the fill shape
	SetPen( wxNullGraphicsPen );

    wxGraphicsPath path = CreatePath();
    path.MoveToPoint( x , y );
    path.AddLineToPoint( (int) (x + sin(angle) * height) , (int) (y + cos(angle) * height) );
    path.AddLineToPoint(
        (int) (x + sin(angle) * height + cos(angle) * width) ,
        (int) (y + cos(angle) * height - sin(angle) * width));
    path.AddLineToPoint((int) (x + cos(angle) * width) , (int) (y - sin(angle) * width) );
    FillPath( path );
    DrawText( str, x ,y, angle);
    SetBrush( formerBrush );
	SetPen( formerPen );
}
Esempio n. 4
0
void AtCell::Draw(wxPoint point, int fontsize)
{
  MathCell::Draw(point, fontsize);

  Configuration *configuration = Configuration::Get();
  double scale = configuration->GetScale();
  wxDC& dc = configuration->GetDC();
  if (DrawThisCell(point) && InUpdateRegion())
  {
    wxPoint bs, in;

    bs.x = point.x;
    bs.y = point.y;
    m_baseCell->DrawList(bs, fontsize);

    in.x = point.x + m_baseCell->GetFullWidth(scale) + SCALE_PX(4, scale);
    in.y = point.y + m_baseCell->GetMaxDrop() +
           + m_indexCell->GetMaxCenter() - SCALE_PX(7, scale);
    m_indexCell->DrawList(in, MAX(MC_MIN_SIZE, fontsize - 3));
    SetPen();
    dc.DrawLine(in.x - SCALE_PX(2, scale),
                bs.y - m_baseCell->GetMaxCenter(),
                in.x - SCALE_PX(2, scale),
                in.y);
    UnsetPen();
  }
}
Esempio n. 5
0
void CWaveEditControl::DrawWave()
{
    float XInc=0.01;
    float PosInc=Zoom*XInc;
    if (PosInc < 1.0)
    {
        PosInc=1;
        XInc=PosInc/Zoom;
    }
    qDebug() << PosInc << XInc << Zoom;
    float YFactor=height()*0.5;
    int HalfHeight=height()*0.5;
    int Width=width();
    if (m_Length-m_Start<(Width/XInc)) m_Start=m_Length-(Width/XInc);
    ClearGradient();
    SetPen(Qt::black);
    if (m_Length)
    {
        for (int Channel=0;Channel<m_WG->Channels;Channel++)
        {
            float* Buffer=m_WG->BufferPointer(Channel);
            float X=0;
            double Pos=m_Start;
            MoveTo((int)X,HalfHeight+(Buffer[(size_t)Pos]*YFactor));
            while (X<Width)
            {
                LineTo((int)X,HalfHeight+(Buffer[(size_t)Pos]*YFactor));
                Pos+=PosInc;
                if (Pos>m_Length) break;
                X+=XInc;
            }
        }
    }
}
Esempio n. 6
0
wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC *owner, wxDC* dc)
              : wxWindowDCImpl(owner)
{
    m_ok = true;
    if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC)))
        m_display = ((wxWindowDCImpl *)dc->GetImpl())->GetDisplay();
    else
        m_display = wxGetDisplay();

    Display* display = (Display*) m_display;

    XGCValues gcvalues;
    gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
    gcvalues.background = WhitePixel (display, DefaultScreen (display));
    gcvalues.graphics_exposures = False;
    gcvalues.subwindow_mode = IncludeInferiors;
    gcvalues.line_width = 1;
    m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
        GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
        &gcvalues);

    m_backgroundPixel = gcvalues.background;

    SetBrush (* wxWHITE_BRUSH);
    SetPen (* wxBLACK_PEN);
}
Esempio n. 7
0
void ImgCell::Draw(CellParser& parser, wxPoint point, int fontsize)
{
  wxDC& dc = parser.GetDC();

  if (DrawThisCell(parser, point) && m_image != NULL)
  {
    wxMemoryDC bitmapDC;
    double scale = parser.GetScale();
    m_image->ViewportSize(m_canvasSize.x,m_canvasSize.y,scale);
  
    m_height = (m_image->m_height) + 2 * m_imageBorderWidth;
    m_width  = (m_image->m_width)  + 2 * m_imageBorderWidth;

    SetPen(parser);
    if (m_drawRectangle)
      
      dc.DrawRectangle(wxRect(point.x, point.y - m_center, m_width, m_height));  

    wxBitmap bitmap = m_image->GetBitmap();
    bitmapDC.SelectObject(bitmap);
      
    dc.Blit(point.x + m_imageBorderWidth, point.y - m_center + m_imageBorderWidth, m_width - 2 * m_imageBorderWidth, m_height - 2 * m_imageBorderWidth, &bitmapDC, 0, 0);
  }
  else
    // The cell isn't drawn => No need to keep it's image cache for now.
    ClearCache();

  MathCell::Draw(parser, point, fontsize);
}
Esempio n. 8
0
void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap )
{
    m_bitmap = bitmap;

    if (m_gc)
        XFreeGC((Display*) m_display, (GC) m_gc);
    m_gc = (WXGC) NULL;

    if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
    {
        m_pixmap = m_bitmap.GetDrawable();
        Display* display = (Display*) m_display;

        XGCValues gcvalues;
        gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
        gcvalues.background = WhitePixel (display, DefaultScreen (display));
        gcvalues.graphics_exposures = False;
        gcvalues.subwindow_mode = IncludeInferiors;
        gcvalues.line_width = 1;
        m_gc = (WXGC) XCreateGC (display, (Drawable)m_pixmap/* RootWindow (display, DefaultScreen (display)) */,
            GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
            &gcvalues);

        m_backgroundPixel = gcvalues.background;
        m_ok = true;

        SetBrush (* wxWHITE_BRUSH);
        SetPen (* wxBLACK_PEN);
    }
    else
    {
        m_ok = false;
        m_pixmap = (WXPixmap) 0;
    };
}
Esempio n. 9
0
void wxMemoryDCImpl::Init()
{
    m_ok = true;
    SetBackground(*wxWHITE_BRUSH);
    SetBrush(*wxWHITE_BRUSH);
    SetPen(*wxBLACK_PEN);
    SetFont(*wxNORMAL_FONT);
    m_ok = false;
}
Esempio n. 10
0
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
: m_selected()
{
    m_ok = TRUE;
    SetBackground(*wxWHITE_BRUSH);
    SetBrush(*wxWHITE_BRUSH);
    SetPen(*wxBLACK_PEN);
    m_ok = FALSE;
};
Esempio n. 11
0
wxMemoryDC::wxMemoryDC(void)
: m_selected()
{
    m_ok = TRUE;
    SetBackground(*wxWHITE_BRUSH);
    SetBrush(*wxWHITE_BRUSH);
    SetPen(*wxBLACK_PEN);
    m_ok = FALSE;
};
Esempio n. 12
0
void wxDCBase::DoDrawEllipticArcRot( wxCoord x, wxCoord y,
                                     wxCoord w, wxCoord h,
                                     double sa, double ea, double angle )
{
    wxList list;

    CalculateEllipticPoints( &list, x, y, w, h, sa, ea );
    Rotate( &list, angle, wxPoint( x+w/2, y+h/2 ) );

    // Add center (for polygon/pie)
    list.Append( (wxObject*) new wxPoint( x+w/2, y+h/2 ) );

    // copy list into array and delete list elements
    int n = list.Number();
    wxPoint *points = new wxPoint[n];
    int i = 0;
    wxNode* node = 0;
    for ( node = list.First(); node; node = node->Next(), i++ )
    {
        wxPoint *point = (wxPoint *)node->Data();
        points[i].x = point->x;
        points[i].y = point->y;
        delete point;
    }

    // first draw the pie without pen, if necessary
    if( GetBrush() != *wxTRANSPARENT_BRUSH )
    {
        wxPen tempPen( GetPen() );
        SetPen( *wxTRANSPARENT_PEN );
        DoDrawPolygon( n, points, 0, 0 );
        SetPen( tempPen );
    }

    // then draw the arc without brush, if necessary
    if( GetPen() != *wxTRANSPARENT_PEN )
    {
        // without center
        DoDrawLines( n-1, points, 0, 0 );
    }

    delete [] points;

} // DrawEllipticArcRot
Esempio n. 13
0
CBufView::~CBufView()
{
	SetPen(NULL);
	SetBrush(NULL);
	SetFont(NULL);
	SelectObject(m_buffer.hDC, m_buffer.hOldBmp);
	DeleteObject(m_buffer.hBmp);
	DeleteDC(m_buffer.hDC);
	ReleaseDC(GetDesktopWindow(), m_buffer.hDCDesktop);
}
Esempio n. 14
0
void wxPrinterDCImpl::Init()
{
    if (m_hDC)
    {
        SetMapMode(wxMM_TEXT);

        SetBrush(*wxBLACK_BRUSH);
        SetPen(*wxBLACK_PEN);
    }
} // end of wxPrinterDC::Init
Esempio n. 15
0
void
wxDCBase::DoDrawPolyPolygon(int n,
                            int count[],
                            wxPoint points[],
                            wxCoord xoffset, wxCoord yoffset,
                            int fillStyle)
{
    if ( n == 1 )
    {
        DoDrawPolygon(count[0], points, xoffset, yoffset, fillStyle);
        return;
    }

    int      i, j, lastOfs;
    wxPoint* pts;
    wxPen    pen;

    for (i = j = lastOfs = 0; i < n; i++)
    {
        lastOfs = j;
        j      += count[i];
    }
    pts = new wxPoint[j+n-1];
    for (i = 0; i < j; i++)
        pts[i] = points[i];
    for (i = 2; i <= n; i++)
    {
        lastOfs -= count[n-i];
        pts[j++] = pts[lastOfs];
    }

    pen = GetPen();
    SetPen(wxPen(*wxBLACK, 0, wxTRANSPARENT));
    DoDrawPolygon(j, pts, xoffset, yoffset, fillStyle);
    SetPen(pen);
    for (i = j = 0; i < n; i++)
    {
        DoDrawLines(count[i], pts+j, xoffset, yoffset);
        j += count[i];
    }
    delete[] pts;
}
Esempio n. 16
0
wxPrinterDCImpl::wxPrinterDCImpl( wxPrinterDC *owner, const wxPrintData& rPrintData ) :
    wxPMDCImpl( owner )
{
    m_printData = rPrintData;
    m_isInteractive = false;
    m_hDC = wxGetPrinterDC(rPrintData);
    m_ok = (m_hDC != 0);
    if (m_hDC)
        SetMapMode(wxMM_TEXT);
    SetBrush(*wxBLACK_BRUSH);
    SetPen(*wxBLACK_PEN);
} // end of wxPrinterDC::wxPrinterDC
Esempio n. 17
0
void wxMemoryDCImpl::Init()
{
    if ( m_ok )
    {
        SetBrush(*wxWHITE_BRUSH);
        SetPen(*wxBLACK_PEN);

        // the background mode is only used for text background and is set in
        // DrawText() to OPAQUE as required, otherwise always TRANSPARENT
        ::SetBkMode( GetHdc(), TRANSPARENT );
    }
}
Esempio n. 18
0
mpLayer::mpLayer()
    : m_type(mpLAYER_UNDEF)
{
    SetPen( *wxBLACK_PEN);
    SetFont( *wxNORMAL_FONT);
    m_pointType  = mpPOINT;
    m_continuous = FALSE; // Default
    m_showName   = TRUE;  // Default
    m_drawOutsideMargins = TRUE;
    m_visible = true;
    m_RectSize = wxSize(6, 6);
}
Esempio n. 19
0
void wxPrinterDCImpl::Init()
{
    if ( m_hDC )
    {
        //     int width = GetDeviceCaps(m_hDC, VERTRES);
        //     int height = GetDeviceCaps(m_hDC, HORZRES);
        SetMapMode(wxMM_TEXT);

        SetBrush(*wxBLACK_BRUSH);
        SetPen(*wxBLACK_PEN);
    }
}
Esempio n. 20
0
void FracCell::Draw(wxPoint point)
{
  if (DrawThisCell(point) && InUpdateRegion())
  {
    Cell::Draw(point);
    Configuration *configuration = (*m_configuration);
    
    wxDC *dc = configuration->GetDC();
    wxPoint num, denom;

    if (m_exponent && !m_isBrokenIntoLines)
    {
      num.x = point.x;
      num.y = point.y;
      denom.x = point.x + m_num->GetFullWidth() + m_expDivideWidth;
      denom.y = num.y;

      m_num->DrawList(num);
      m_denom->DrawList(denom);

      int fontsize1 = Scale_Px(m_fontSize);
      wxASSERT(fontsize1 > 0);
      dc->SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN,
                        wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false,
                        configuration->GetFontName(TS_VARIABLE)));
      dc->DrawText(wxT("/"),
                  point.x + m_num->GetFullWidth(),
                  point.y - m_num->GetMaxCenter() + MC_TEXT_PADDING);
    }
    else
    {
      num.x = point.x + m_horizontalGapLeft +
              (m_width - m_horizontalGapLeft - m_horizontalGapRight - m_num->GetFullWidth()) / 2;
      num.y = point.y - m_num->GetMaxHeight() + m_num->GetMaxCenter() -
              Scale_Px(2);
      m_num->DrawList(num);

      denom.x = point.x + m_horizontalGapLeft +
                (m_width - m_horizontalGapLeft - m_horizontalGapRight - m_denom->GetFullWidth()) / 2;
      denom.y = point.y + m_denom->GetMaxCenter() + Scale_Px(2);
      m_denom->DrawList(denom);
      SetPen(1.2);
      if (m_fracStyle != FC_CHOOSE)
        dc->DrawLine(point.x + m_horizontalGapLeft + (*m_configuration)->GetDefaultLineWidth() / 2,
                    point.y,
                    point.x + m_width - m_horizontalGapRight - (*m_configuration)->GetDefaultLineWidth() / 2,
                    point.y
        );
      UnsetPen();
    }
  }
}
Esempio n. 21
0
void wxMemoryDCImpl::Init()
{
    if (m_ok)
    {
        SetBrush(*wxWHITE_BRUSH);
        SetPen(*wxBLACK_PEN);

        // the background mode is only used for text background and is set in
        // DrawText() to OPAQUE as required, otherwise always TRANSPARENT
        ::GpiSetBackMix( GetHPS(), BM_LEAVEALONE );
    }
    memset(&m_vRclPaint, 0, sizeof(m_vRclPaint));
} // end of wxMemoryDC::Init
Esempio n. 22
0
void MusWxDC::EndGraphic( MusDocObject *object, MusRC *rc )
{
    // actually draw the two bounding boxes
    // bounding boxes are given in logical coordinates - we need to convert them
    // this is why we have a MusRC object

    return;

    SetPen( AxRED, 1, wxDOT_DASH );
    if ( object->HasSelfBB() ) {
        m_dc->DrawRectangle( rc->ToRendererX( object->m_selfBB_x1 ), rc->ToRendererY( object->m_selfBB_y1 ),
                             rc->ToRendererX( object->m_selfBB_x2 ) - rc->ToRendererX( object->m_selfBB_x1 ),
                             rc->ToRendererY( object->m_selfBB_y2 ) - rc->ToRendererY( object->m_selfBB_y1 ));
    }

    SetPen( AxBLUE, 1, wxDOT);
    if ( object->HasContentBB() ) {
        m_dc->DrawRectangle( rc->ToRendererX( object->m_contentBB_x1 ), rc->ToRendererY( object->m_contentBB_y1 ),
                             rc->ToRendererX( object->m_contentBB_x2 ) - rc->ToRendererX( object->m_contentBB_x1 ),
                             rc->ToRendererY( object->m_contentBB_y2 ) - rc->ToRendererY( object->m_contentBB_y1 ));
    }
}
Esempio n. 23
0
wxPrinterDC::wxPrinterDC(
  const wxPrintData&                rPrintData
)
{
    m_printData = rPrintData;
    m_isInteractive = FALSE;
    m_hDC = wxGetPrinterDC(rPrintData);
    m_ok = (m_hDC != 0);
    if (m_hDC)
        SetMapMode(wxMM_TEXT);
    SetBrush(*wxBLACK_BRUSH);
    SetPen(*wxBLACK_PEN);
} // end of wxPrinterDC::wxPrinterDC
Esempio n. 24
0
wxControlPoint::wxControlPoint(wxShapeCanvas *theCanvas, wxShape *object, double size, double the_xoffset, double the_yoffset, int the_type): wxRectangleShape(size, size)
{
	m_canvas = theCanvas;
	m_shape = object;
	m_xoffset = the_xoffset;
	m_yoffset = the_yoffset;
	m_type = the_type;
	SetPen(g_oglBlackForegroundPen);
	SetBrush((wxBrush *) wxBLACK_BRUSH);
	m_oldCursor = NULL;
	m_visible = TRUE;
	m_eraseObject = TRUE;
}
Esempio n. 25
0
wxPrinterDCImpl::wxPrinterDCImpl( wxPrinterDC *owner, WXHDC hTheDC ) :
    wxPMDCImpl( owner )
{
    m_isInteractive = false;
    m_hDC = hTheDC;
    m_ok = true;
    if (m_hDC)
    {
        SetMapMode(wxMM_TEXT);
    }
    SetBrush(*wxBLACK_BRUSH);
    SetPen(*wxBLACK_PEN);
} // end of wxPrinterDC::wxPrinterDC
Esempio n. 26
0
wxPrinterDC::wxPrinterDC(
  WXHDC                             hTheDC
)
{
    m_isInteractive = FALSE;
    m_hDC = hTheDC;
    m_ok = TRUE;
    if (m_hDC)
    {
        SetMapMode(wxMM_TEXT);
    }
    SetBrush(*wxBLACK_BRUSH);
    SetPen(*wxBLACK_PEN);
} // end of wxPrinterDC::wxPrinterDC
Esempio n. 27
0
void CPaintHelper::SetElement(UIELEMENT eElement)
{
	UIELEMENTINFO *info = m_uig.GetElementInfo(eElement);
	if (!info)
		return;

	if (info->eFont != UIF_LAST)
		SetFont(info->eFont);
	if (info->eBrush != UIB_LAST)
		SetBrush(info->eBrush);
	if (info->ePen != UIP_LAST)
		SetPen(info->ePen);
	SetText(info->eText, info->eBk);
}
Esempio n. 28
0
/*
    Change the color of the pen.
*/
static void GDI_modify_pen(int pen, unsigned char red, unsigned char green, unsigned char blue)
{
    assert(This.m_bModifiablePalette == TRUE); /* Shouldn't modify pen if flag is not set! */

    assert(0 <= pen && pen < This.m_nTotalColors);

    if (This.m_PalEntries[pen].peRed    == red
    &&  This.m_PalEntries[pen].peGreen  == green
    &&  This.m_PalEntries[pen].peBlue   == blue)
        return;

    SetPen(pen, red, green, blue);

    This.m_bUpdatePalette = TRUE;
}
Esempio n. 29
0
void OCPiano::DrawBlackKey(const int Pos, const bool Down)
{
    if (!Down)
    {
        SetPenBrush("#888","#666");
        //Scene.addRect(Pos+2,1,BlackKeyWidth,BlackKeyHeight,QPen("#888"),QBrush("#666"));
        Rectangle(Pos+2,1,BlackKeyWidth,BlackKeyHeight);
    }
    SetPenBrush(Qt::black);
    //Scene.addRect(Pos,0,BlackKeyWidth,BlackKeyHeight,QPen(Qt::black),QBrush(Qt::black));
    Rectangle(Pos,0,BlackKeyWidth,BlackKeyHeight);
    QColor col("#666");
    if (Down) col=QColor("#444");
    SetPen(col);
    //Scene.addLine(Pos+1,1,Pos+1,BlackKeyHeight-3,QPen(col));
    Line(Pos+1,1,Pos+1,BlackKeyHeight-3);
    QLinearGradient lg(0,0,0,BlackKeyHeight-7);
    if (Down)
    {
        lg.setColorAt(0,"#000");
        lg.setColorAt(1,"#444");
    }
    else
    {
        lg.setColorAt(0,"#000");
        lg.setColorAt(1,"#666");
    }
    QPainterPath p(QPoint(Pos+2,1));
    p.lineTo(Pos+2,BlackKeyHeight-5);
    p.cubicTo(Pos+2,BlackKeyHeight-3,Pos+BlackKeyWidth-1,BlackKeyHeight-3,Pos+BlackKeyWidth-1,BlackKeyHeight-5);
    p.lineTo(Pos+BlackKeyWidth-1,1);
    SetPen(Qt::black);
    SetBrush(lg);
    Path(p);
    //Scene.addPath(p,QPen(Qt::black),QBrush(lg));
}
Esempio n. 30
0
BBoxDeviceContext::BBoxDeviceContext ( View *view, int width, int height):
    DeviceContext()
{
    m_view = view;
    m_width = width;
    m_height = height;

    m_userScaleX = 1.0;
    m_userScaleY = 1.0;

    m_drawingText = false;

    SetBrush( AxBLACK, AxSOLID );
    SetPen( AxBLACK, 1, AxSOLID );
}