diff --git a/uppdev/Draw/BackDraw.cpp b/uppdev/Draw/BackDraw.cpp index b7c0eca7e..222d56ff3 100644 --- a/uppdev/Draw/BackDraw.cpp +++ b/uppdev/Draw/BackDraw.cpp @@ -1,8 +1,8 @@ #include "Draw.h" -// --------------------------- +NAMESPACE_UPP -Draw& ScreenInfo(); +SystemDraw& ScreenInfo(); void BackDraw::Create(int cx, int cy) { @@ -29,8 +29,6 @@ BackDraw::~BackDraw() Destroy(); } -Draw& ScreenInfo(); - bool ScreenInPaletteMode() { return ScreenInfo().PaletteMode(); @@ -40,3 +38,5 @@ Size GetScreenSize() { return ScreenInfo().GetPagePixels(); } + +END_UPP_NAMESPACE diff --git a/uppdev/Draw/BackDraw.h b/uppdev/Draw/BackDraw.h index cc47cf483..0967ebce5 100644 --- a/uppdev/Draw/BackDraw.h +++ b/uppdev/Draw/BackDraw.h @@ -19,8 +19,8 @@ public: void Put(SystemDraw& w, int x, int y); void Put(SystemDraw& w, Point p) { Put(w, p.x, p.y); } - void Create(SystemDraw& draw, int cx, int cy); - void Create(SystemDraw& draw, Size sz) { Create(draw, sz.cx, sz.cy); } + void Create(SystemDraw& w, int cx, int cy); + void Create(SystemDraw& w, Size sz) { Create(w, sz.cx, sz.cy); } void Create(int cx, int cy); void Create(Size sz) { Create(sz.cx, sz.cy); } void Destroy(); @@ -29,4 +29,11 @@ public: BackDraw(); ~BackDraw(); + +// Deprecated: + void Put(Draw& w, int x, int y) { Put(*(SystemDraw*)&w, x, y); } + void Put(Draw& w, Point p) { Put(*(SystemDraw*)&w, p.x, p.y); } + + void Create(Draw& w, int cx, int cy) { Create(*(SystemDraw*)&w, cx, cy); } + void Create(Draw& w, Size sz) { Create(*(SystemDraw*)&w, sz.cx, sz.cy); } }; diff --git a/uppdev/Draw/Draw.cpp b/uppdev/Draw/Draw.cpp index 5a216a0d5..ca0810692 100644 --- a/uppdev/Draw/Draw.cpp +++ b/uppdev/Draw/Draw.cpp @@ -31,7 +31,7 @@ void Draw::SinCos(int angle, double& sina, double& cosa) Size Draw::GetPixelsPerInch() const { - return IsDots() ? Size(600, 600) : Size(96, 96); + return Dots() ? Size(600, 600) : Size(96, 96); } int Draw::GetNativeX(int x) const @@ -398,6 +398,23 @@ void Draw::DrawPainting(int x, int y, int cx, int cy, const Painting& ig) DrawPainting(RectC(x, y, cx, cy), ig); } +HDC Draw::BeginGdi() +{ + SystemDraw *w = dynamic_cast(this); + return w ? w->BeginGdi() : NULL; +} + +void Draw::EndGdi() +{ + SystemDraw *w = dynamic_cast(this); + if(w) w->EndGdi(); +} + +void Draw::Flush() +{ + SystemDraw::Flush(); +} + // --------------------------- dword NilDraw::GetInfo() const { return DOTS; } diff --git a/uppdev/Draw/Draw.h b/uppdev/Draw/Draw.h index 8b31c468a..6c91e9b9a 100644 --- a/uppdev/Draw/Draw.h +++ b/uppdev/Draw/Draw.h @@ -84,6 +84,7 @@ enum { class Drawing; class Draw; class Painting; +class SystemDraw; #ifdef PLATFORM_WIN32 HDC ScreenHDC(); @@ -736,6 +737,17 @@ public: Color ink = DefaultInk, const int *dx = NULL); static void SinCos(int angle, double& sina, double& cosa); + + // deprecated: + static void SetStdFont(Font font) { UPP::SetStdFont(font); } + static Font GetStdFont() { return UPP::GetStdFont(); } + static Size GetStdFontSize() { return UPP::GetStdFontSize(); } + static int GetStdFontCy() { return GetStdFontSize().cy; } + + static void Flush(); + + HDC BeginGdi(); + void EndGdi(); }; void DrawImageBandRLE(Draw& w, int x, int y, const Image& m, int minp); @@ -793,6 +805,8 @@ public: class DrawingDraw : public Draw { public: + virtual dword GetInfo() const; + virtual Size GetPagePixels() const; virtual void BeginOp(); virtual void EndOp(); virtual void OffsetOp(Point p); @@ -969,7 +983,6 @@ DrawingToPdfFnType GetDrawingToPdfFn(); #include "DrawX11.h" #endif - #include "BackDraw.h" #include "Display.h" diff --git a/uppdev/Draw/DrawText.cpp b/uppdev/Draw/DrawText.cpp index fe6950700..4ee5e17e4 100644 --- a/uppdev/Draw/DrawText.cpp +++ b/uppdev/Draw/DrawText.cpp @@ -133,9 +133,4 @@ Size GetTextSize(const String& text, Font font) return GetTextSize(text, font, text.GetLength()); } -Font Draw::GetStdFont() -{ - return AStdFont; -} - END_UPP_NAMESPACE diff --git a/uppdev/Draw/DrawTextXft.cpp b/uppdev/Draw/DrawTextXft.cpp index 4eba88ee0..1aa19bb6e 100644 --- a/uppdev/Draw/DrawTextXft.cpp +++ b/uppdev/Draw/DrawTextXft.cpp @@ -1,5 +1,7 @@ #include "Draw.h" +#ifdef PLATFORM_X11 + NAMESPACE_UPP #define LLOG(x) //LOG(x) @@ -370,3 +372,5 @@ void Draw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, } END_UPP_NAMESPACE + +#endif \ No newline at end of file diff --git a/uppdev/Draw/DrawWin32.h b/uppdev/Draw/DrawWin32.h index eeac2c993..d338b1cdb 100644 --- a/uppdev/Draw/DrawWin32.h +++ b/uppdev/Draw/DrawWin32.h @@ -45,7 +45,6 @@ public: virtual int GetCloffLevel() const; private: - dword style; Size pagePixels; Size nativeDpi; bool palette:1; @@ -53,8 +52,6 @@ private: bool is_mono:1; int native; - SystemDraw(); - friend class ImageDraw; friend class FontInfo; friend class Font; @@ -63,7 +60,6 @@ private: FontInfo lastFont; - Point actual_offset; Point actual_offset_bak; struct Cloff : Moveable { @@ -75,7 +71,6 @@ private: Array cloff; Rect drawingclip; - HDC handle; COLORREF lastTextColor; Color lastColor; HBRUSH orgBrush; @@ -88,7 +83,6 @@ private: void Unselect0(); void Cinit(); - void Init(); void LoadCaps(); void SetPrinterMode(); @@ -103,13 +97,24 @@ private: friend class ScreenDraw; friend class PrintDraw; +protected: + dword style; + HDC handle; + Point actual_offset; + + SystemDraw(); + void Init(); + public: static void SetAutoPalette(bool ap); static bool AutoPalette(); + bool PaletteMode() { return palette; } static void Flush() { GdiFlush(); } COLORREF GetColor(Color color) const; + + Point GetOffset() const; #ifndef PLATFORM_WINCE Point LPtoDP(Point p) const; @@ -180,7 +185,7 @@ public: HENHMETAFILE GetHEMF() const { ChkP(); return hemf; } }; -class WinMetaFileDraw : public Draw { +class WinMetaFileDraw : public SystemDraw { Size size; public: diff --git a/uppdev/Draw/Drawing.cpp b/uppdev/Draw/Drawing.cpp index e4628d8ea..7808c962a 100644 --- a/uppdev/Draw/Drawing.cpp +++ b/uppdev/Draw/Drawing.cpp @@ -104,6 +104,16 @@ Stream& DrawingDraw::DrawingOp(int code) return drawing; } +dword DrawingDraw::GetInfo() const +{ + return DOTS; +} + +Size DrawingDraw::GetPagePixels() const +{ + return size; +} + void DrawingDraw::BeginOp() { DrawingOp(DRAWING_BEGIN); diff --git a/uppdev/Draw/Font.cpp b/uppdev/Draw/Font.cpp index c9e6a0292..986d79ed9 100644 --- a/uppdev/Draw/Font.cpp +++ b/uppdev/Draw/Font.cpp @@ -196,8 +196,7 @@ FontInfo& FontInfo::operator=(const FontInfo& f) bool FontInfo::IsEqual(byte _charset, Font f, int angle, int device) const { - return ptr && ptr->font == f && ptr->angle == angle && ptr->device == device && - charset == _charset; + return ptr && ptr->font == f && ptr->angle == angle && charset == _charset; } FontInfo::CharMetrics FontInfo::GetCM(int c) const diff --git a/uppdev/Draw/Image.cpp b/uppdev/Draw/Image.cpp index 23b45a635..914f9176c 100644 --- a/uppdev/Draw/Image.cpp +++ b/uppdev/Draw/Image.cpp @@ -206,7 +206,7 @@ int Image::GetKind() const return data ? data->GetKind() : IMAGE_EMPTY; } -void Image::PaintImage(Draw& w, int x, int y, const Rect& src, Color c) const +void Image::PaintImage(SystemDraw& w, int x, int y, const Rect& src, Color c) const { if(data) data->Paint(w, x, y, src, c); diff --git a/uppdev/Draw/Image.h b/uppdev/Draw/Image.h index 2c0755ace..02a172fe8 100644 --- a/uppdev/Draw/Image.h +++ b/uppdev/Draw/Image.h @@ -153,7 +153,7 @@ private: void SysInit(); void SysRelease(); int GetKind(); - void Paint(Draw& w, int x, int y, const Rect& src, Color c); + void Paint(SystemDraw& w, int x, int y, const Rect& src, Color c); void PaintOnlyShrink(); Data(ImageBuffer& b); @@ -172,7 +172,7 @@ private: friend class Draw; - void PaintImage(Draw& w, int x, int y, const Rect& src, Color c) const; + void PaintImage(SystemDraw& w, int x, int y, const Rect& src, Color c) const; friend void SetPaintOnly___(Image& m); friend void DrawImageBandRLE(Draw& w, int x, int y, const Image& m, int minp); diff --git a/uppdev/Draw/ImageDraw.h b/uppdev/Draw/ImageDraw.h index ab84cd831..550090677 100644 --- a/uppdev/Draw/ImageDraw.h +++ b/uppdev/Draw/ImageDraw.h @@ -1,4 +1,4 @@ -class ImageDraw : public Draw { +class ImageDraw : public SystemDraw { Size size; #ifdef PLATFORM_WIN32 diff --git a/uppdev/Draw/ImageWin32.cpp b/uppdev/Draw/ImageWin32.cpp index c40217a74..8f5ca714e 100644 --- a/uppdev/Draw/ImageWin32.cpp +++ b/uppdev/Draw/ImageWin32.cpp @@ -88,7 +88,7 @@ void SetSurface(HDC dc, int x, int y, int cx, int cy, const RGBA *pixels) bi, DIB_RGB_COLORS); } -void SetSurface(Draw& w, int x, int y, int cx, int cy, const RGBA *pixels) +void SetSurface(SystemDraw& w, int x, int y, int cx, int cy, const RGBA *pixels) { SetSurface(w.GetHandle(), x, y, cx, cy, pixels); } @@ -100,7 +100,7 @@ class DrawSurface : NoCopy { HDC dc, dcMem; HBITMAP hbmp, hbmpOld; - void Init(Draw& w, int x, int y, int cx, int cy); + void Init(SystemDraw& w, int x, int y, int cx, int cy); RGBA* Line(int i) const { ASSERT(i >= 0 && i < size.cy); return (RGBA *)pixels + size.cx * (size.cy - i - 1); } public: @@ -110,12 +110,12 @@ public: const RGBA *operator[](int i) const { return Line(i); } int GetLineDelta() const { return -size.cx; } - DrawSurface(Draw& w, const Rect& r); - DrawSurface(Draw& w, int x, int y, int cx, int cy); + DrawSurface(SystemDraw& w, const Rect& r); + DrawSurface(SystemDraw& w, int x, int y, int cx, int cy); ~DrawSurface(); }; -void DrawSurface::Init(Draw& w, int _x, int _y, int cx, int cy) +void DrawSurface::Init(SystemDraw& w, int _x, int _y, int cx, int cy) { DrawLock __; dc = w.GetHandle(); @@ -129,12 +129,12 @@ void DrawSurface::Init(Draw& w, int _x, int _y, int cx, int cy) ::BitBlt(dcMem, 0, 0, cx, cy, dc, x, y, SRCCOPY); } -DrawSurface::DrawSurface(Draw& w, const Rect& r) +DrawSurface::DrawSurface(SystemDraw& w, const Rect& r) { Init(w, r.left, r.top, r.Width(), r.Height()); } -DrawSurface::DrawSurface(Draw& w, int x, int y, int cx, int cy) +DrawSurface::DrawSurface(SystemDraw& w, int x, int y, int cx, int cy) { Init(w, x, y, cx, cy); } @@ -215,7 +215,7 @@ void Image::Data::CreateHBMP(HDC dc, const RGBA *data) ResCount++; } -void Image::Data::Paint(Draw& w, int x, int y, const Rect& src, Color c) +void Image::Data::Paint(SystemDraw& w, int x, int y, const Rect& src, Color c) { DrawLock __; ASSERT(!paintonly || IsNull(c)); @@ -238,8 +238,7 @@ void Image::Data::Paint(Draw& w, int x, int y, const Rect& src, Color c) w.DrawRect(x, y, sz.cx, sz.cy, c); return; } - if(GetKind() == IMAGE_OPAQUE && paintcount == 0 && sr == Rect(sz) && !w.IsMetaFile() - && IsWinNT() && !w.IsPrinter()) { + if(GetKind() == IMAGE_OPAQUE && paintcount == 0 && sr == Rect(sz) && IsWinNT() && w.IsGui()) { LTIMING("Image Opaque direct set"); SetSurface(w, x, y, sz.cx, sz.cy, buffer); paintcount++; diff --git a/uppdev/Draw/ImageX11.cpp b/uppdev/Draw/ImageX11.cpp index 9e9d5b3f5..e8f811164 100644 --- a/uppdev/Draw/ImageX11.cpp +++ b/uppdev/Draw/ImageX11.cpp @@ -116,7 +116,7 @@ static XPicture sGetSolidFill(Color c) return f.picture; } -void Image::Data::Paint(Draw& w, int x, int y, const Rect& src, Color c) +void Image::Data::Paint(SystemDraw& w, int x, int y, const Rect& src, Color c) { DrawLock __; while(ResCount > 512) { diff --git a/uppdev/Draw/MetaFile.cpp b/uppdev/Draw/MetaFile.cpp index 474df4543..803038200 100644 --- a/uppdev/Draw/MetaFile.cpp +++ b/uppdev/Draw/MetaFile.cpp @@ -11,8 +11,9 @@ void WinMetaFile::Init() { void WinMetaFile::Paint(Draw& w, const Rect& r) const { ChkP(); - if(hemf) - PlayEnhMetaFile(w, hemf, r); + SystemDraw *h = dynamic_cast(&w); + if(hemf && h) + PlayEnhMetaFile(h->GetHandle(), hemf, r); } void WinMetaFile::Paint(Draw& w, int x, int y, int cx, int cy) const { @@ -197,7 +198,7 @@ bool WinMetaFileDraw::Create(HDC hdc, int cx, int cy, const char *app, const cha Init(); - pixels = false; + style = DOTS|BACK; ::SetMapMode(handle, MM_ANISOTROPIC); ::SetWindowOrgEx(handle, 0, 0, 0); @@ -214,14 +215,6 @@ bool WinMetaFileDraw::Create(HDC hdc, int cx, int cy, const char *app, const cha actual_offset = Point(0, 0); - printer = false; - pixels = false; - actual_offset = Point(0, 0); - device = -1; - aborted = false; - palette = false; - backdraw = true; - return true; }