X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0e320a79f187558effb04d92020b470372bbe456..56d8adc0c0de446235b11e9d449158d4c47b9ec8:/src/os2/dc.cpp diff --git a/src/os2/dc.cpp b/src/os2/dc.cpp index 2c1c613595..7a95c3ab97 100644 --- a/src/os2/dc.cpp +++ b/src/os2/dc.cpp @@ -31,355 +31,370 @@ IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) #define pt2mm 0.352777777778 //----------------------------------------------------------------------------- -// wxDC +// wxDCBase //----------------------------------------------------------------------------- -wxDC::wxDC(void) +long wxDCBase::DeviceToLogicalX(long x) const { - m_ok = FALSE; - m_optimize = FALSE; - m_autoSetting = FALSE; - m_colour = TRUE; - m_clipping = FALSE; - - m_mm_to_pix_x = 1.0; - m_mm_to_pix_y = 1.0; - - m_logicalOriginX = 0; - m_logicalOriginY = 0; - m_deviceOriginX = 0; - m_deviceOriginY = 0; - m_internalDeviceOriginX = 0; - m_internalDeviceOriginY = 0; - m_externalDeviceOriginX = 0; - m_externalDeviceOriginY = 0; - - m_logicalScaleX = 1.0; - m_logicalScaleY = 1.0; - m_userScaleX = 1.0; - m_userScaleY = 1.0; - m_scaleX = 1.0; - m_scaleY = 1.0; - - m_mappingMode = wxMM_TEXT; - m_needComputeScaleX = FALSE; - m_needComputeScaleY = FALSE; - - m_signX = 1; // default x-axis left to right - m_signY = 1; // default y-axis top down - - m_maxX = m_maxY = -100000; - m_minY = m_minY = 100000; - - m_logicalFunction = wxCOPY; -// m_textAlignment = wxALIGN_TOP_LEFT; - m_backgroundMode = wxTRANSPARENT; - - m_textForegroundColour = *wxBLACK; - m_textBackgroundColour = *wxWHITE; - m_pen = *wxBLACK_PEN; - m_font = *wxNORMAL_FONT; - m_brush = *wxTRANSPARENT_BRUSH; - m_backgroundBrush = *wxWHITE_BRUSH; - -// m_palette = wxAPP_COLOURMAP; + long new_x = x - m_deviceOriginX; + if (new_x > 0) + return (long)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; + else + return (long)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; }; -wxDC::~wxDC(void) +long wxDCBase::DeviceToLogicalY(long y) const { + long new_y = y - m_deviceOriginY; + if (new_y > 0) + return (long)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; + else + return (long)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; }; -void wxDC::DrawIcon( const wxIcon &WXUNUSED(icon), long WXUNUSED(x), long WXUNUSED(y), bool WXUNUSED(useMask) ) +long wxDCBase::DeviceToLogicalXRel(long x) const { + if (x > 0) + return (long)((double)(x) / m_scaleX + 0.5); + else + return (long)((double)(x) / m_scaleX - 0.5); }; -void wxDC::DrawPoint( wxPoint& point ) -{ - DrawPoint( point.x, point.y ); -}; - -void wxDC::DrawPolygon( wxList *list, long xoffset, long yoffset, int fillStyle ) +long wxDCBase::DeviceToLogicalYRel(long y) const { - int n = list->Number(); - wxPoint *points = new wxPoint[n]; - - int i = 0; - for( wxNode *node = list->First(); node; node = node->Next() ) - { - wxPoint *point = (wxPoint *)node->Data(); - points[i].x = point->x; - points[i++].y = point->y; - }; - DrawPolygon( n, points, xoffset, yoffset, fillStyle ); - delete[] points; + if (y > 0) + return (long)((double)(y) / m_scaleY + 0.5); + else + return (long)((double)(y) / m_scaleY - 0.5); }; -void wxDC::DrawLines( wxList *list, long xoffset, long yoffset ) +long wxDCBase::LogicalToDeviceX(long x) const { - int n = list->Number(); - wxPoint *points = new wxPoint[n]; - - int i = 0; - for( wxNode *node = list->First(); node; node = node->Next() ) - { - wxPoint *point = (wxPoint *)node->Data(); - points[i].x = point->x; - points[i++].y = point->y; - }; - DrawLines( n, points, xoffset, yoffset ); - delete []points; + long new_x = x - m_logicalOriginX; + if (new_x > 0) + return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; + else + return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; }; -void wxDC::DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 ) -{ - wxList list; - list.Append( (wxObject*)new wxPoint(x1, y1) ); - list.Append( (wxObject*)new wxPoint(x2, y2) ); - list.Append( (wxObject*)new wxPoint(x3, y3) ); - DrawSpline(&list); - wxNode *node = list.First(); - while (node) - { - wxPoint *p = (wxPoint*)node->Data(); - delete p; - node = node->Next(); - }; +long wxDCBase::LogicalToDeviceY(long y) const +{ + long new_y = y - m_logicalOriginY; + if (new_y > 0) + return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; + else + return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; }; -void wxDC::DrawSpline( int n, wxPoint points[] ) +long wxDCBase::LogicalToDeviceXRel(long x) const { - wxList list; - for (int i = 0; i < n; i++) list.Append( (wxObject*)&points[i] ); - DrawSpline( &list ); + if (x > 0) + return (long)((double)(x) * m_scaleX + 0.5); + else + return (long)((double)(x) * m_scaleX - 0.5); }; -void wxDC::SetClippingRegion( long x, long y, long width, long height ) +long wxDCBase::LogicalToDeviceYRel(long y) const { - m_clipping = TRUE; - m_clipX1 = x; - m_clipY1 = y; - m_clipX2 = x + width; - m_clipY2 = y + height; + if (y > 0) + return (long)((double)(y) * m_scaleY + 0.5); + else + return (long)((double)(y) * m_scaleY - 0.5); }; -void wxDC::DestroyClippingRegion(void) +//----------------------------------------------------------------------------- +// wxDC +//----------------------------------------------------------------------------- + +wxDC::wxDC(void) { - m_clipping = FALSE; -}; + m_owner = NULL; + m_bitmap = NULL; -void wxDC::GetClippingBox( long *x, long *y, long *width, long *height ) const -{ - if (m_clipping) - { - if (x) *x = m_clipX1; - if (y) *y = m_clipY1; - if (width) *width = (m_clipX2 - m_clipX1); - if (height) *height = (m_clipY2 - m_clipY1); - } - else - *x = *y = *width = *height = 0; + m_oldBitmap = 0; + m_oldPen = 0; + m_oldBrush = 0; + m_oldFont = 0; + m_oldPalette = 0; + m_hDC = 0; + m_hDCCount = 0; }; -void wxDC::GetSize( int* width, int* height ) const +wxDC::~wxDC(void) { - *width = m_maxX-m_minX; - *height = m_maxY-m_minY; + // TODO: }; -void wxDC::GetSizeMM( long* width, long* height ) const +void wxDC::DestroyClippingRegion(void) { - int w = 0; - int h = 0; - GetSize( &w, &h ); - *width = long( double(w) / (m_scaleX*m_mm_to_pix_x) ); - *height = long( double(h) / (m_scaleY*m_mm_to_pix_y) ); + // TODO: }; -void wxDC::SetTextForeground( const wxColour &col ) +void wxDC::DoGetSize( int* width, int* height ) const { - if (!Ok()) return; - m_textForegroundColour = col; + // TODO: }; -void wxDC::SetTextBackground( const wxColour &col ) +void wxDC::DoGetSizeMM( int* width, int* height ) const { - if (!Ok()) return; - m_textBackgroundColour = col; + // TODO: }; void wxDC::SetMapMode( int mode ) { - switch (mode) - { - case wxMM_TWIPS: - SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); - break; - case wxMM_POINTS: - SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); - break; - case wxMM_METRIC: - SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); - break; - case wxMM_LOMETRIC: - SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); - break; - default: - case wxMM_TEXT: - SetLogicalScale( 1.0, 1.0 ); - break; - }; - if (mode != wxMM_TEXT) - { - m_needComputeScaleX = TRUE; - m_needComputeScaleY = TRUE; - }; + // TODO: }; void wxDC::SetUserScale( double x, double y ) { - // allow negative ? -> no - m_userScaleX = x; - m_userScaleY = y; - ComputeScaleAndOrigin(); -}; + m_userScaleX = x; + m_userScaleY = y; -void wxDC::GetUserScale( double *x, double *y ) -{ - if (x) *x = m_userScaleX; - if (y) *y = m_userScaleY; + SetMapMode(m_mappingMode); }; void wxDC::SetLogicalScale( double x, double y ) { - // allow negative ? - m_logicalScaleX = x; - m_logicalScaleY = y; - ComputeScaleAndOrigin(); + // TODO: }; -void wxDC::GetLogicalScale( double *x, double *y ) +void wxDC::SetLogicalOrigin( long x, long y ) { - if (x) *x = m_logicalScaleX; - if (y) *y = m_logicalScaleY; + // TODO: }; -void wxDC::SetLogicalOrigin( long x, long y ) +void wxDC::SetDeviceOrigin( long x, long y ) { - m_logicalOriginX = x * m_signX; // is this still correct ? - m_logicalOriginY = y * m_signY; - ComputeScaleAndOrigin(); + // TODO: }; -void wxDC::GetLogicalOrigin( long *x, long *y ) +void wxDC::SetInternalDeviceOrigin( long x, long y ) { - if (x) *x = m_logicalOriginX; - if (y) *y = m_logicalOriginY; + // TODO: }; -void wxDC::SetDeviceOrigin( long x, long y ) +void wxDC::GetInternalDeviceOrigin( long *x, long *y ) { - m_externalDeviceOriginX = x; - m_externalDeviceOriginY = y; - ComputeScaleAndOrigin(); + // TODO: }; -void wxDC::GetDeviceOrigin( long *x, long *y ) +void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) { -// if (x) *x = m_externalDeviceOriginX; -// if (y) *y = m_externalDeviceOriginY; - if (x) *x = m_deviceOriginX; - if (y) *y = m_deviceOriginY; + // TODO: }; -void wxDC::SetInternalDeviceOrigin( long x, long y ) + +int wxDC::GetDepth() const { - m_internalDeviceOriginX = x; - m_internalDeviceOriginY = y; - ComputeScaleAndOrigin(); -}; + // TODO: + return (1); +} -void wxDC::GetInternalDeviceOrigin( long *x, long *y ) +wxSize wxDC::GetPPI() const { - if (x) *x = m_internalDeviceOriginX; - if (y) *y = m_internalDeviceOriginY; -}; + int x = 1; + int y = 1; + // TODO: + return (wxSize(x,y)); +} +void wxDC::GetTextExtent( const wxString& string + ,long* x + ,long* y + ,long* decent + ,long* externalLeading + ,wxFont* theFont + ) const +{ + // TODO: +} -void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) +long wxDC::GetCharWidth() const { - m_signX = (xLeftRight ? 1 : -1); - m_signY = (yBottomUp ? -1 : 1); - ComputeScaleAndOrigin(); -}; + // TODO + return(1); +} -long wxDC::DeviceToLogicalX(long x) const +long wxDC::GetCharHeight() const { - return XDEV2LOG(x); -}; + // TODO + return(1); +} -long wxDC::DeviceToLogicalY(long y) const +void wxDC::Clear() { - return YDEV2LOG(y); -}; + // TODO +} -long wxDC::DeviceToLogicalXRel(long x) const +void wxDC::SetFont(const wxFont& font) { - return XDEV2LOGREL(x); -}; + // TODO +} -long wxDC::DeviceToLogicalYRel(long y) const +void wxDC::SetPen(const wxPen& pen) { - return YDEV2LOGREL(y); -}; + // TODO +} +void wxDC::SetBrush(const wxBrush& brush) +{ + // TODO +} -long wxDC::LogicalToDeviceX(long x) const +void wxDC::SetBackground(const wxBrush& brush) { - return XLOG2DEV(x); -}; + // TODO +} -long wxDC::LogicalToDeviceY(long y) const +void wxDC::SetLogicalFunction(int function) { - return YLOG2DEV(y); -}; + // TODO +} -long wxDC::LogicalToDeviceXRel(long x) const +void wxDC::SetBackgroundMode(int mode) { - return XLOG2DEVREL(x); -}; + // TODO +} -long wxDC::LogicalToDeviceYRel(long y) const +void wxDC::SetPalette(const wxPalette& palette) { - return YLOG2DEVREL(y); -}; - -void wxDC::CalcBoundingBox( long x, long y ) + // TODO +} + +void wxDC::DoFloodFill( long x + ,long y + ,const wxColour& col + ,int style + ) { - if (x < m_minX) m_minX = x; - if (y < m_minY) m_minY = y; - if (x > m_maxX) m_maxX = x; - if (y > m_maxY) m_maxY = y; -}; + // TODO +} -void wxDC::ComputeScaleAndOrigin(void) +bool wxDC::DoGetPixel(long x, long y, wxColour *col) const { - // CMB: copy scale to see if it changes - double origScaleX = m_scaleX; - double origScaleY = m_scaleY; + // TODO + return(TRUE); +} - m_scaleX = m_logicalScaleX * m_userScaleX; - m_scaleY = m_logicalScaleY * m_userScaleY; +void wxDC::DoDrawPoint(long x, long y) +{ + // TODO +} - m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX; - m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY; +void wxDC::DoDrawLine(long x1, long y1, long x2, long y2) +{ + // TODO +} + +void wxDC::DoDrawArc( long x1, long y1 + ,long x2, long y2 + ,long xc, long yc + ) +{ + // TODO +} + +void wxDC::DoDrawEllipticArc( long x + ,long y + ,long w + ,long h + ,double sa + ,double ea + ) +{ + // TODO +} + +void wxDC::DoDrawRectangle(long x, long y, long width, long height) +{ + // TODO +} + +void wxDC::DoDrawRoundedRectangle( long x, long y + ,long width, long height + ,double radius + ) +{ + // TODO +} + +void wxDC::DoDrawEllipse(long x, long y, long width, long height) +{ + // TODO +} + +void wxDC::DoCrossHair(long x, long y) +{ + // TODO +} + +void wxDC::DoDrawIcon(const wxIcon& icon, long x, long y) +{ + // TODO +} + +void wxDC::DoDrawBitmap( const wxBitmap &bmp + ,long x, long y + ,bool useMask + ) +{ + // TODO +} + +void wxDC::DoDrawText(const wxString& text, long x, long y) +{ + // TODO +} + +bool wxDC::DoBlit( long xdest + ,long ydest + ,long width + ,long height + ,wxDC *source + ,long xsrc + ,long ysrc + ,int rop + ,bool useMask + ) +{ + // TODO + return(TRUE); +} + +void wxDC::DoDrawLines( int n, wxPoint points[] + ,long xoffset, long yoffset + ) +{ + // TODO +} + +void wxDC::DoDrawPolygon(int n, wxPoint points[] + ,long xoffset, long yoffset + ,int fillStyle + ) +{ + // TODO +} + +void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region) +{ + // TODO +} + +void wxDC::DoSetClippingRegion( long x, long y + ,long width, long height + ) +{ + // TODO +} + +#if wxUSE_SPLINES +void wxDC::DoDrawSpline(wxList *points) +{ + // TODO +} +#endif + +// +// Private functions +// - // CMB: if scale has changed call SetPen to recalulate the line width - if (m_scaleX != origScaleX || m_scaleY != origScaleY) - { - // this is a bit artificial, but we need to force wxDC to think - // the pen has changed - wxPen* pen = & GetPen(); - wxPen tempPen; - m_pen = tempPen; - SetPen(* pen); - } -};