Developing Draw

git-svn-id: svn://ultimatepp.org/upp/trunk@1146 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2009-05-07 21:52:17 +00:00
parent 39f7e7385c
commit 6674597efe
15 changed files with 90 additions and 48 deletions

View file

@ -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

View file

@ -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); }
};

View file

@ -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<SystemDraw *>(this);
return w ? w->BeginGdi() : NULL;
}
void Draw::EndGdi()
{
SystemDraw *w = dynamic_cast<SystemDraw *>(this);
if(w) w->EndGdi();
}
void Draw::Flush()
{
SystemDraw::Flush();
}
// ---------------------------
dword NilDraw::GetInfo() const { return DOTS; }

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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<Cloff> {
@ -75,7 +71,6 @@ private:
Array<Cloff> 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:

View file

@ -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);

View file

@ -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

View file

@ -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);

View file

@ -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);

View file

@ -1,4 +1,4 @@
class ImageDraw : public Draw {
class ImageDraw : public SystemDraw {
Size size;
#ifdef PLATFORM_WIN32

View file

@ -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++;

View file

@ -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) {

View file

@ -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<SystemDraw *>(&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;
}