// Author: Vaclav Slavik
// Created: 2001/03/09
// RCS-ID: $Id$
-// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
+// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// constants
//-----------------------------------------------------------------------------
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
const double mm2inches = 0.0393700787402;
const double inches2mm = 25.4;
const double mm2twips = 56.6929133859;
// check if the DC is scaled or moved, and if yes, then
// convert rg to device coordinates:
if ( m_deviceOriginX != 0 || m_deviceOriginY != 0 ||
+ m_logicalOriginX != 0 || m_logicalOriginY != 0 ||
XLOG2DEVREL(500) != 500 || YLOG2DEVREL(500) != 500 )
{
region_t *mrg = rg.GetMGLRegion().rgnPointer();
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);
}
}
-void wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
+extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
+ const wxColour & col, int style);
+
+bool wxDC::DoFloodFill(wxCoord x, wxCoord y,
+ const wxColour& col, int style)
{
- wxFAIL_MSG( wxT("wxDC::DoFloodFill not implemented") );
+ return wxDoFloodFill(this, x, y, col, style);
}
bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
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->lineExt(XLOG2DEV(x1) + m_penOfsX, XLOG2DEV(y1) + m_penOfsY,
- XLOG2DEV(x2) + m_penOfsX, XLOG2DEV(y2) + m_penOfsY,FALSE);
+ 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);
}
{
if ( !m_penSelected )
SelectPen();
+
m_MGLDC->rect(xx + m_penOfsX, yy + m_penOfsY,
xx + ww + m_penOfsX, yy + hh + m_penOfsY);
}
!wxTestFontEncoding(nativeEnc) )
{
#if wxUSE_FONTMAP
- if ( !wxTheFontMapper->GetAltForEncoding(encoding, &nativeEnc) )
+ if ( !wxFontMapper::Get()->GetAltForEncoding(encoding, &nativeEnc) )
#endif
{
nativeEnc.mglEncoding = MGL_ENCODING_ASCII;
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:
if ( palette == wxNullPalette )
{
- SetPalette(m_oldPalette);
+ if ( m_oldPalette.Ok() )
+ SetPalette(m_oldPalette);
return;
}
void wxDC::SetFont(const wxFont& font)
{
- wxCHECK_RET( font.Ok(), wxT("invalid font") );
- m_font = font;
- m_mglFont = NULL;
+ if ( font.Ok() )
+ {
+ m_font = font;
+ m_mglFont = NULL;
+ }
}
void wxDC::SetBackground(const wxBrush& brush)