diff -u -r -N -x WIN32_WIN32_i386_DBG --minimal src.org/abi/src/af/gr/win/gr_Win32Graphics.cpp src/abi/src/af/gr/win/gr_Win32Graphics.cpp --- src.org/abi/src/af/gr/win/gr_Win32Graphics.cpp Wed Apr 19 19:52:18 2000 +++ src/abi/src/af/gr/win/gr_Win32Graphics.cpp Sat May 06 16:37:32 2000 @@ -43,6 +43,9 @@ m_pFont = NULL; m_pFontGUI = NULL; + m_iImplicitMarginLeft = 0; + m_iImplicitMarginTop = 0; + m_cs = GR_Graphics::GR_COLORSPACE_COLOR; m_cursor = GR_CURSOR_INVALID; setCursor(GR_CURSOR_DEFAULT); @@ -171,7 +174,7 @@ SetTextAlign(m_hdc, TA_LEFT | TA_TOP); SetBkMode(m_hdc, TRANSPARENT); // TODO: remember and reset? - ExtTextOutW(m_hdc, xoff, yoff, 0, NULL, &Char, 1, NULL); + ExtTextOutW(m_hdc, xoff - m_iImplicitMarginLeft, yoff - m_iImplicitMarginTop, 0, NULL, &Char, 1, NULL); } void GR_Win32Graphics::drawChars(const UT_UCSChar* pChars, @@ -184,7 +187,7 @@ SetTextAlign(m_hdc, TA_LEFT | TA_TOP); SetBkMode(m_hdc, TRANSPARENT); // TODO: remember and reset? - ExtTextOutW(m_hdc, xoff, yoff, 0, NULL, pChars + iCharOffset, iLength, NULL); + ExtTextOutW(m_hdc, xoff - m_iImplicitMarginLeft, yoff - m_iImplicitMarginTop, 0, NULL, pChars + iCharOffset, iLength, NULL); //TextOutW(m_hdc, xoff, yoff, pChars + iCharOffset, iLength); } @@ -246,8 +249,8 @@ HPEN hPen = CreatePen(PS_SOLID, m_iLineWidth, m_clrCurrent); HPEN hOldPen = (HPEN) SelectObject(m_hdc, hPen); - MoveToEx(m_hdc, x1, y1, NULL); - LineTo(m_hdc, x2, y2); + MoveToEx(m_hdc, x1 - m_iImplicitMarginLeft, y1 - m_iImplicitMarginTop, NULL); + LineTo(m_hdc, x2 - m_iImplicitMarginLeft, y2 - m_iImplicitMarginTop); (void) SelectObject(m_hdc, hOldPen); DeleteObject(hPen); @@ -268,8 +271,8 @@ int iROP = SetROP2(m_hdc, R2_XORPEN); HPEN hOldPen = (HPEN) SelectObject(m_hdc, hPen); - MoveToEx(m_hdc, x1, y1, NULL); - LineTo(m_hdc, x2, y2); + MoveToEx(m_hdc, x1 - m_iImplicitMarginLeft, y1 - m_iImplicitMarginTop, NULL); + LineTo(m_hdc, x2 - m_iImplicitMarginLeft, y2 - m_iImplicitMarginTop); (void) SelectObject(m_hdc, hOldPen); DeleteObject(hPen); @@ -287,8 +290,8 @@ for (UT_uint32 i = 0; i < nPoints; i++) { - points[i].x = pts[i].x; - points[i].y = pts[i].y; + points[i].x = pts[i].x - m_iImplicitMarginLeft; + points[i].y = pts[i].y - m_iImplicitMarginTop; } Polyline(m_hdc, points, nPoints); @@ -303,8 +306,8 @@ HBRUSH hBrush = CreateSolidBrush(RGB(c.m_red, c.m_grn, c.m_blu)); RECT r; - r.left = x; - r.top = y; + r.left = x - m_iImplicitMarginLeft; + r.top = y - m_iImplicitMarginTop; r.right = r.left + w; r.bottom = r.top + h; @@ -321,6 +324,7 @@ { UT_ASSERT(m_bPrint); UT_ASSERT(!m_bStartPrint); + m_bStartPrint = ( StartDoc(m_hdc,m_pDocInfo) > 0 ); return m_bStartPrint; @@ -332,6 +336,14 @@ if (m_bStartPage) EndPage(m_hdc); + /* + * Position 0,0 is the upper left of the _printable_ area. So if you + * want to position something at 1in, 1in, you need to subtract out + * the implicit margin created by the unprintable area. + */ + m_iImplicitMarginLeft = GetDeviceCaps(m_hdc, PHYSICALOFFSETX); + m_iImplicitMarginTop = GetDeviceCaps(m_hdc, PHYSICALOFFSETY); + m_bStartPage = UT_TRUE; return (StartPage(m_hdc) > 0); } @@ -381,8 +393,8 @@ HBRUSH hBrush = (HBRUSH) GetStockObject(WHITE_BRUSH); RECT r; - r.left = x; - r.top = y; + r.left = x - m_iImplicitMarginLeft; + r.top = y - m_iImplicitMarginTop; r.right = r.left + width; r.bottom = r.top + height; @@ -393,8 +405,8 @@ { RECT r; - r.left = pRect->left; - r.top = pRect->top; + r.left = pRect->left - m_iImplicitMarginLeft; + r.top = pRect->top - m_iImplicitMarginTop; r.right = pRect->left + pRect->width; r.bottom = pRect->top + pRect->height; @@ -408,8 +420,8 @@ if (pRect) { // set the clip rectangle - HRGN hrgn = CreateRectRgn(pRect->left, - pRect->top, + HRGN hrgn = CreateRectRgn(pRect->left - m_iImplicitMarginLeft, + pRect->top - m_iImplicitMarginTop, pRect->left + pRect->width, pRect->top + pRect->height); UT_ASSERT(hrgn); @@ -447,7 +459,8 @@ UT_Byte* pBits = ((unsigned char*) pDIB) + pDIB->bmiHeader.biSize + iSizeOfColorData; int iRes = StretchDIBits(m_hdc, - xDest, yDest, + xDest - m_iImplicitMarginLeft, + yDest - m_iImplicitMarginTop, pImg->getDisplayWidth(), pImg->getDisplayHeight(), 0, 0, pDIB->bmiHeader.biWidth, pDIB->bmiHeader.biHeight, @@ -561,8 +574,8 @@ HBRUSH hBrush = CreateSolidBrush(m_3dColors[c]); RECT r; - r.left = x; - r.top = y; + r.left = x - m_iImplicitMarginLeft; + r.top = y - m_iImplicitMarginTop; r.right = r.left + w; r.bottom = r.top + h; diff -u -r -N -x WIN32_WIN32_i386_DBG --minimal src.org/abi/src/af/gr/win/gr_Win32Graphics.h src/abi/src/af/gr/win/gr_Win32Graphics.h --- src.org/abi/src/af/gr/win/gr_Win32Graphics.h Wed Apr 19 19:52:20 2000 +++ src/abi/src/af/gr/win/gr_Win32Graphics.h Sat May 06 15:52:58 2000 @@ -139,6 +139,9 @@ GR_Win32Font* m_pFontGUI; UT_sint32 m_iLineWidth; + UT_sint32 m_iImplicitMarginLeft; + UT_sint32 m_iImplicitMarginTop; + GR_Graphics::ColorSpace m_cs; GR_Graphics::Cursor m_cursor;