::SetWindowOrgEx(GetHdc(), (int)m_logicalOriginX, (int)m_logicalOriginY, NULL);
}
-void wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
+bool wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
{
#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
+ if (!GetHDC()) return FALSE;
#endif
- if ( !::ExtFloodFill(GetHdc(), XLOG2DEV(x), YLOG2DEV(y),
+ bool success = (0 != ::ExtFloodFill(GetHdc(), XLOG2DEV(x), YLOG2DEV(y),
col.GetPixel(),
style == wxFLOOD_SURFACE ? FLOODFILLSURFACE
- : FLOODFILLBORDER) )
+ : FLOODFILLBORDER) ) ;
+ if (!success)
{
// quoting from the MSDN docs:
//
}
CalcBoundingBox(x, y);
+
+ return success;
}
bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
wxPalette *pal = bmp.GetPalette();
if ( pal && ::GetDeviceCaps(cdc,BITSPIXEL) <= 8 )
{
- oldPal = ::SelectPalette(hdcMem, GetHpaletteOf(pal), FALSE);
+ oldPal = ::SelectPalette(hdcMem, GetHpaletteOf(*pal), FALSE);
::RealizePalette(hdcMem);
}
#endif // wxUSE_PALETTE
wxPalette *pal = bmp.GetPalette();
if ( pal && ::GetDeviceCaps(cdc,BITSPIXEL) <= 8 )
{
- oldPal = ::SelectPalette(memdc, GetHpaletteOf(pal), FALSE);
+ oldPal = ::SelectPalette(memdc, GetHpaletteOf(*pal), FALSE);
::RealizePalette(memdc);
}
#endif // wxUSE_PALETTE
// "upper left" and "upper right"
CalcBoundingBox(x, y);
- CalcBoundingBox(x + w*cos(rad), y - h*sin(rad));
+ CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(h*sin(rad)));
// "bottom left" and "bottom right"
x += (wxCoord)(h*sin(rad));
y += (wxCoord)(h*cos(rad));
CalcBoundingBox(x, y);
- CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
+ CalcBoundingBox(x + wxCoord(h*sin(rad)), y + wxCoord(h*cos(rad)));
}
#endif
}
m_oldPalette = 0;
}
- if (m_palette.Ok() && m_palette.GetHPALETTE())
+ if ( m_palette.Ok() )
{
- HPALETTE oldPal = ::SelectPalette(GetHdc(), (HPALETTE) m_palette.GetHPALETTE(), FALSE);
+ HPALETTE oldPal = ::SelectPalette(GetHdc(),
+ GetHpaletteOf(m_palette),
+ FALSE);
if (!m_oldPalette)
m_oldPalette = (WXHPALETTE) oldPal;
if (realize)
::RealizePalette(GetHdc());
}
-
-
}
void wxDC::SetPalette(const wxPalette& palette)
{
- if (palette.Ok()) {
+ if ( palette.Ok() )
+ {
m_palette = palette;
- DoSelectPalette(true);
- }
+ DoSelectPalette(TRUE);
+ }
}
void wxDC::InitializePalette()
{
- if (wxDisplayDepth() <= 8) {
+ if ( wxDisplayDepth() <= 8 )
+ {
// look for any window or parent that has a custom palette. If any has
// one then we need to use it in drawing operations
- wxWindow *win = m_canvas;
- while (!win->HasCustomPalette() && win->GetParent()) win = win->GetParent();
- if (win->HasCustomPalette()) {
+ wxWindow *win = m_canvas->GetAncestorWithCustomPalette();
+
+ m_hasCustomPalette = win && win->HasCustomPalette();
+ if ( m_hasCustomPalette )
+ {
m_palette = win->GetPalette();
- m_custompalette = true;
+
// turn on MSW translation for this palette
DoSelectPalette();
- }
- else
- m_custompalette = false;
}
+ }
}
+
#endif // wxUSE_PALETTE
void wxDC::SetFont(const wxFont& the_font)
if (!GetHDC()) return;
#endif
- if ( w ) *w = ::GetDeviceCaps(GetHdc(), HORZSIZE);
- if ( h ) *h = ::GetDeviceCaps(GetHdc(), VERTSIZE);
+ // if we implement it in terms of DoGetSize() instead of directly using the
+ // results returned by GetDeviceCaps(HORZ/VERTSIZE) as was done before, it
+ // will also work for wxWindowDC and wxClientDC even though their size is
+ // not the same as the total size of the screen
+ int wPixels, hPixels;
+ DoGetSize(&wPixels, &hPixels);
+
+ if ( w )
+ {
+ int wTotal = ::GetDeviceCaps(GetHdc(), HORZRES);
+
+ wxCHECK_RET( wTotal, _T("0 width device?") );
+
+ *w = (wPixels * ::GetDeviceCaps(GetHdc(), HORZSIZE)) / wTotal;
+ }
+
+ if ( h )
+ {
+ int hTotal = ::GetDeviceCaps(GetHdc(), VERTRES);
+
+ wxCHECK_RET( hTotal, _T("0 height device?") );
+
+ *h = (hPixels * ::GetDeviceCaps(GetHdc(), VERTSIZE)) / hTotal;
+ }
}
wxSize wxDC::GetPPI() const