m_OwnsMGLDC = FALSE;
m_ok = FALSE; // must call SetMGLDevCtx() before using it
-#if 0
m_mm_to_pix_x = (double)wxGetDisplaySize().GetWidth() /
(double)wxGetDisplaySizeMM().GetWidth();
m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() /
(double)wxGetDisplaySizeMM().GetHeight();
-#endif
- // FIXME_MGL -- not in wxUniversal branch (and not implementend anyway,
- // hardcode it for 75dpi for now)
- m_mm_to_pix_x = ((double)wxGetDisplaySize().GetWidth() / 75) * inches2mm;
- m_mm_to_pix_y = ((double)wxGetDisplaySize().GetHeight() / 75) * inches2mm;
m_pen = *wxBLACK_PEN;
m_font = *wxNORMAL_FONT;
m_downloadedPatterns[0] = m_downloadedPatterns[1] = FALSE;
m_mglFont = NULL;
- m_globalClippingRegion = NULL;
}
{
if (m_OwnsMGLDC)
delete m_MGLDC;
- delete m_globalClippingRegion;
}
void wxDC::SetMGLDC(MGLDevCtx *mgldc, bool OwnsMGLDC)
m_MGLDC = mgldc;
m_OwnsMGLDC = OwnsMGLDC;
m_ok = TRUE;
-
- if ( mgldc->getDC()->a.clipRegion )
- {
- m_globalClippingRegion = new MGLRegion;
- mgldc->getClipRegion(*m_globalClippingRegion);
- }
- else
- m_globalClippingRegion = NULL;
+
+ if ( !m_globalClippingRegion.IsNull() )
+ SetClippingRegion(m_globalClippingRegion);
InitializeMGLDC();
}
else
m_currentClippingRegion.Union(rect);
- if ( m_globalClippingRegion )
- {
- m_MGLDC->setClipRegion(m_currentClippingRegion.GetMGLRegion()
- & *m_globalClippingRegion);
- }
- else
- m_MGLDC->setClipRegion(m_currentClippingRegion.GetMGLRegion());
+ m_MGLDC->setClipRegion(m_currentClippingRegion.GetMGLRegion());
m_clipping = TRUE;
DO_SET_CLIPPING_BOX(m_currentClippingRegion)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
- if ( region.Empty() )
+ if ( region.IsEmpty() )
{
DestroyClippingRegion();
return;
else
m_currentClippingRegion.Union(rg);
- if ( m_globalClippingRegion )
- {
- m_MGLDC->setClipRegion(m_currentClippingRegion.GetMGLRegion()
- & *m_globalClippingRegion);
- }
- else
- m_MGLDC->setClipRegion(m_currentClippingRegion.GetMGLRegion());
+ m_MGLDC->setClipRegion(m_currentClippingRegion.GetMGLRegion());
m_clipping = TRUE;
DO_SET_CLIPPING_BOX(m_currentClippingRegion)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
- if ( m_globalClippingRegion )
- m_MGLDC->setClipRegion(*m_globalClippingRegion);
+ if ( !m_globalClippingRegion.IsNull() )
+ {
+ m_MGLDC->setClipRegion(m_globalClippingRegion.GetMGLRegion());
+ m_currentClippingRegion = m_globalClippingRegion;
+ m_clipping = TRUE;
+ }
else
- m_MGLDC->setClipRect(MGLRect(0, 0, m_MGLDC->sizex(), m_MGLDC->sizey()));
- m_clipping = FALSE;
- m_currentClippingRegion.Clear();
+ {
+ m_MGLDC->setClipRect(MGLRect(0, 0, m_MGLDC->sizex()+1, m_MGLDC->sizey()+1));
+ m_clipping = FALSE;
+ m_currentClippingRegion.Clear();
+ }
}
// ---------------------------------------------------------------------------
SetBrush(m_backgroundBrush);
SelectBrush();
GetSize(&w, &h);
- m_MGLDC->fillRect(0, 0, w-1, h-1);
+ m_MGLDC->fillRect(0, 0, w, h);
SetBrush(oldb);
}
}
wxCHECK_MSG( col, FALSE, _T("NULL colour parameter in wxDC::GetPixel"));
uchar r, g, b;
- m_MGLDC->unpackColorFast(m_MGLDC->getPixel(XLOG2DEV(x), XLOG2DEV(y)),
+ m_MGLDC->unpackColorFast(m_MGLDC->getPixel(XLOG2DEV(x), YLOG2DEV(y)),
r, g, b);
col->Set(r, g, b);
return TRUE;
m_MGLDC->makeCurrent(); // will go away with MGL6.0
if ( !m_penSelected )
SelectPen();
- m_MGLDC->line(XLOG2DEV(x1) + m_penOfsX, XLOG2DEV(y1) + m_penOfsY,
- XLOG2DEV(x2) + m_penOfsX, XLOG2DEV(y2) + m_penOfsY);
+ m_MGLDC->lineExt(XLOG2DEV(x1) + m_penOfsX, YLOG2DEV(y1) + m_penOfsY,
+ XLOG2DEV(x2) + m_penOfsX, YLOG2DEV(y2) + m_penOfsY,FALSE);
CalcBoundingBox(x1, y1);
CalcBoundingBox(x2, y2);
}
SelectMGLFont();
- m_MGLDC->setColor(m_MGLDC->packColorFast(m_textForegroundColour.Red(),
- m_textForegroundColour.Green(), m_textForegroundColour.Blue()));
- m_MGLDC->setBackColor(m_MGLDC->packColorFast(m_textBackgroundColour.Red(),
- m_textBackgroundColour.Green(), m_textBackgroundColour.Blue()));
-
// Render the text:
wxCoord xx = XLOG2DEV(x);
wxCoord yy = YLOG2DEV(y);
-
+
m_MGLDC->setLineStyle(MGL_LINE_STIPPLE);
m_MGLDC->setLineStipple(0xFFFF);
m_MGLDC->setPenSize(1, 1);
m_MGLDC->setPenStyle(MGL_BITMAP_SOLID);
-
+
#if wxUSE_UNICODE
const wchar_t *c_text = text.c_str();
#else
const char *c_text = text.c_str();
#endif
+
+#if 1
+ // FIXME_MGL - this is a temporary hack in absence of proper
+ // implementation of solid text background in MGL. Once
+ // the bug in MGL is fixed, this code should be nuked
+ // immediately. Note that the code is not 100% correct;
+ // it only works with wxCOPY logical function
+ if ( m_backgroundMode == wxSOLID )
+ {
+ int w = m_MGLDC->textWidth(c_text);
+ int h = m_MGLDC->textHeight();
+ m_MGLDC->setColor(m_MGLDC->packColorFast(m_textBackgroundColour.Red(),
+ m_textBackgroundColour.Green(), m_textBackgroundColour.Blue()));
+ m_MGLDC->fillRect(xx, yy, xx+w, yy+h);
+ }
+#endif
+
+ m_MGLDC->setColor(m_MGLDC->packColorFast(m_textForegroundColour.Red(),
+ m_textForegroundColour.Green(), m_textForegroundColour.Blue()));
+ m_MGLDC->setBackColor(m_MGLDC->packColorFast(m_textBackgroundColour.Red(),
+ m_textBackgroundColour.Green(), m_textBackgroundColour.Blue()));
+
m_MGLDC->drawStr(xx, yy, c_text);
// Render underline:
*descent = YDEV2LOGREL(m_mglFont->descent);
if ( externalLeading )
*externalLeading = YDEV2LOGREL(m_mglFont->leading);
-
+
if ( theFont != NULL )
wxConstCast(this, wxDC)->SetFont(oldFont);
}
void wxDC::DoGetSize(int *w, int *h) const
{
- if (w) *w = m_MGLDC->sizex();
- if (h) *h = m_MGLDC->sizey();
+ if (w) *w = m_MGLDC->sizex()+1;
+ if (h) *h = m_MGLDC->sizey()+1;
}
void wxDC::DoGetSizeMM(int *width, int *height) const