-// Chris Breeze 20/5/98: first implementation of DrawEllipticArc on Windows
-void wxDC::DrawEllipticArc(long x,long y,long w,long h,double sa,double ea)
-{
- long x2 = (x+w);
- long y2 = (y+h);
-
- const double deg2rad = 3.14159265359 / 180.0;
- int rx1 = XLOG2DEV(x+w/2);
- int ry1 = YLOG2DEV(y+h/2);
- int rx2 = rx1;
- int ry2 = ry1;
- rx1 += (int)(100.0 * abs(w) * cos(sa * deg2rad));
- ry1 -= (int)(100.0 * abs(h) * m_signY * sin(sa * deg2rad));
- rx2 += (int)(100.0 * abs(w) * cos(ea * deg2rad));
- ry2 -= (int)(100.0 * abs(h) * m_signY * sin(ea * deg2rad));
-
- // draw pie with NULL_PEN first and then outline otherwise a line is
- // drawn from the start and end points to the centre
- HPEN orig_pen = (HPEN) ::SelectObject((HDC) m_hDC, (HPEN) ::GetStockObject(NULL_PEN));
- if (m_signY > 0)
- {
- (void)Pie((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2)+1, YLOG2DEV(y2)+1,
- rx1, ry1, rx2, ry2);
- }
- else
- {
- (void)Pie((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y)-1, XLOG2DEV(x2)+1, YLOG2DEV(y2),
- rx1, ry1-1, rx2, ry2-1);
- }
- ::SelectObject((HDC) m_hDC, orig_pen);
- (void)Arc((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2),
- rx1, ry1, rx2, ry2);
-
- CalcBoundingBox(x, y);
- CalcBoundingBox(x2, y2);
-}
-
-void wxDC::DrawIcon(const wxIcon& icon, long x, long y)
-{
- ::DrawIcon((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), (HICON) icon.GetHICON());
- CalcBoundingBox(x, y);
- CalcBoundingBox(x+icon.GetWidth(), y+icon.GetHeight());
+ if (!m_palette.Ok())
+ {
+ // Setting a NULL colourmap is a way of restoring
+ // the original colourmap
+ if (m_oldPalette)
+ {
+ ::SelectPalette(GetHdc(), (HPALETTE) m_oldPalette, FALSE);
+ m_oldPalette = 0;
+ }
+
+ return;
+ }
+
+ if (m_palette.Ok() && m_palette.GetHPALETTE())
+ {
+ HPALETTE oldPal = ::SelectPalette(GetHdc(), (HPALETTE) m_palette.GetHPALETTE(), FALSE);
+ if (!m_oldPalette)
+ m_oldPalette = (WXHPALETTE) oldPal;
+
+ ::RealizePalette(GetHdc());
+ }