X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a23fd0e1d1329a4a258b4defb3e0b0001b700c6e..bcc46c75590b4127bbfd5b164b9c3f8f44980a84:/src/msw/dc.cpp diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 33423e3172..f424405768 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -29,22 +29,26 @@ #endif #ifndef WX_PRECOMP - #include "wx/frame.h" + #include "wx/window.h" #include "wx/dc.h" #include "wx/utils.h" #include "wx/dialog.h" #include "wx/app.h" #include "wx/bitmap.h" #include "wx/dcmemory.h" + #include "wx/log.h" + #include "wx/icon.h" #endif #include "wx/dcprint.h" -#include "wx/msw/private.h" #include #include #if wxUSE_COMMON_DIALOGS +#if wxUSE_NORLANDER_HEADERS + #include +#endif #include #endif @@ -52,17 +56,7 @@ #include #endif -#ifdef DrawText - #undef DrawText -#endif - -#ifdef GetCharWidth - #undef GetCharWidth -#endif - -#ifdef StartDoc - #undef StartDoc -#endif +#include "wx/msw/private.h" #if !USE_SHARED_LIBRARY IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) @@ -72,13 +66,10 @@ // constants // --------------------------------------------------------------------------- -#define VIEWPORT_EXTENT 1000 - -// --------------------------------------------------------------------------- -// macros -// --------------------------------------------------------------------------- +static const int VIEWPORT_EXTENT = 1000; -#define YSCALE(y) (yorigin - (y)) +static const int MM_POINTS = 9; +static const int MM_METRIC = 10; // =========================================================================== // implementation @@ -255,14 +246,19 @@ int wxDC::GetDepth() const void wxDC::Clear() { RECT rect; - if (m_canvas) + if ( m_canvas ) + { GetClientRect((HWND) m_canvas->GetHWND(), &rect); - else if (m_selectedBitmap.Ok()) + } + else { + wxCHECK_RET( m_selectedBitmap.Ok(), _T("this DC can't be cleared") ); + rect.left = 0; rect.top = 0; rect.right = m_selectedBitmap.GetWidth(); rect.bottom = m_selectedBitmap.GetHeight(); } + (void) ::SetMapMode(GetHdc(), MM_TEXT); DWORD colour = GetBkColor(GetHdc()); @@ -519,7 +515,7 @@ void wxDC::DoDrawRoundedRectangle(long x, long y, long width, long height, doubl long y2 = (y+height); (void)RoundRect(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), - YLOG2DEV(y2), 2*XLOG2DEV(radius), 2*YLOG2DEV(radius)); + YLOG2DEV(y2), (int) (2*XLOG2DEV(radius)), (int)( 2*YLOG2DEV(radius))); CalcBoundingBox(x, y); CalcBoundingBox(x2, y2); @@ -598,9 +594,11 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask ) HDC cdc = GetHdc(); HDC memdc = ::CreateCompatibleDC( cdc ); HBITMAP hbitmap = (HBITMAP) bmp.GetHBITMAP( ); + + wxASSERT_MSG( hbitmap, _T("bitmap is ok but HBITMAP is NULL?") ); + ::SelectObject( memdc, hbitmap ); ::BitBlt( cdc, x, y, bmp.GetWidth(), bmp.GetHeight(), memdc, 0, 0, SRCCOPY); - ::SelectObject( memdc, 0 ); ::DeleteDC( memdc ); } else @@ -641,11 +639,15 @@ void wxDC::DoDrawText(const wxString& text, long x, long y) else SetBkMode(GetHdc(), OPAQUE); - (void)TextOut(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), (char *) (const char *)text, strlen((const char *)text)); + (void)TextOut(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), WXSTRINGCAST text, wxStrlen(WXSTRINGCAST text)); if (m_textBackgroundColour.Ok()) (void)SetBkColor(GetHdc(), old_background); + // background colour is used only for DrawText, otherwise + // always TRANSPARENT, RR + SetBkMode(GetHdc(), TRANSPARENT); + CalcBoundingBox(x, y); long w, h; @@ -716,7 +718,7 @@ void wxDC::SetFont(const wxFont& the_font) HFONT f = (HFONT) ::SelectObject(GetHdc(), (HFONT) m_font.GetResourceHandle()); if (f == (HFONT) NULL) { - wxLogDebug("::SelectObject failed in wxDC::SetFont."); + wxLogDebug(_T("::SelectObject failed in wxDC::SetFont.")); } if (!m_oldFont) m_oldFont = (WXHFONT) f; @@ -829,10 +831,15 @@ void wxDC::SetBackgroundMode(int mode) { m_backgroundMode = mode; + // SetBackgroundColour now only refers to text background + // and m_backgroundMode is used there + +/* if (m_backgroundMode == wxTRANSPARENT) ::SetBkMode(GetHdc(), TRANSPARENT); else - ::SetBkMode(GetHdc(), OPAQUE); + ::SetBkMode(GetHdc(), OPAQUE); +*/ } void wxDC::SetLogicalFunction(int function) @@ -923,7 +930,7 @@ void wxDC::GetTextExtent(const wxString& string, long *x, long *y, SIZE sizeRect; TEXTMETRIC tm; - GetTextExtentPoint(GetHdc(), (char *)(const char *) string, strlen((char *)(const char *) string), &sizeRect); + GetTextExtentPoint(GetHdc(), WXSTRINGCAST string, wxStrlen(WXSTRINGCAST string), &sizeRect); GetTextMetrics(GetHdc(), &tm); if (x) *x = XDEV2LOGREL(sizeRect.cx); @@ -1066,22 +1073,22 @@ long wxDCBase::DeviceToLogicalYRel(long y) const long wxDCBase::LogicalToDeviceX(long x) const { - return (long) (floor((x) - m_logicalOriginX)*m_logicalScaleX*m_userScaleX*m_signX*m_scaleX + m_deviceOriginX); + return (long) ((x - m_logicalOriginX)*m_logicalScaleX*m_userScaleX*m_signX*m_scaleX + m_deviceOriginX); } long wxDCBase::LogicalToDeviceXRel(long x) const { - return (long) (floor(x)*m_logicalScaleX*m_userScaleX*m_signX*m_scaleX); + return (long) (x*m_logicalScaleX*m_userScaleX*m_signX*m_scaleX); } long wxDCBase::LogicalToDeviceY(long y) const { - return (long) (floor((y) - m_logicalOriginY)*m_logicalScaleY*m_userScaleY*m_signY*m_scaleY + m_deviceOriginY); + return (long) ((y - m_logicalOriginY)*m_logicalScaleY*m_userScaleY*m_signY*m_scaleY + m_deviceOriginY); } long wxDCBase::LogicalToDeviceYRel(long y) const { - return (long) (floor(y)*m_logicalScaleY*m_userScaleY*m_signY*m_scaleY); + return (long) (y*m_logicalScaleY*m_userScaleY*m_signY*m_scaleY); } // ---------------------------------------------------------------------------