From d6929a12b2ba80d67d4534c1deede5daa00568d4 Mon Sep 17 00:00:00 2001 From: cxl Date: Wed, 28 Nov 2012 20:37:35 +0000 Subject: [PATCH] rainbow: Fixed for refactored CtrlCore/Draw git-svn-id: svn://ultimatepp.org/upp/trunk@5589 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- rainbow/Framebuffer/Wnd.cpp | 14 +- rainbow/Skeleton/Ctrl.cpp | 4 + rainbow/Skeleton/DrawOp.cpp | 3 +- rainbow/Skeleton/Gui.h | 358 ------------------------------------ rainbow/Skeleton/Image.cpp | 31 ---- rainbow/Skeleton/Skeleton.h | 2 +- rainbow/Skeleton/Wnd.cpp | 2 +- rainbow/WinFb/Local.h | 2 - 8 files changed, 14 insertions(+), 402 deletions(-) delete mode 100644 rainbow/Skeleton/Gui.h diff --git a/rainbow/Framebuffer/Wnd.cpp b/rainbow/Framebuffer/Wnd.cpp index 3c93454c1..9e5a05f14 100644 --- a/rainbow/Framebuffer/Wnd.cpp +++ b/rainbow/Framebuffer/Wnd.cpp @@ -192,10 +192,6 @@ bool Ctrl::ProcessEvent(bool *quit) { LLOG("@ ProcessEvent"); ASSERT(IsMainThread()); - if(DoCall()) { - SyncTopWindows(); - return false; - } if(!GetMouseLeft() && !GetMouseRight() && !GetMouseMiddle()) ReleaseCtrlCapture(); if(FBProcessEvent(quit)) { @@ -450,9 +446,9 @@ void Ctrl::GuiSleep0(int ms) GuiLock __; ASSERT(IsMainThread()); LLOG("GuiSleep"); - int level = LeaveGMutexAll(); + int level = LeaveGuiMutexAll(); FBSleep(ms); - EnterGMutex(level); + EnterGuiMutex(level); } Rect Ctrl::GetWndScreenRect() const @@ -641,7 +637,7 @@ bool Ctrl::HasWndCapture() const return captureCtrl && captureCtrl->GetTopCtrl() == this; } -void Ctrl::WndInvalidateRect0(const Rect& r) +void Ctrl::WndInvalidateRect(const Rect& r) { GuiLock __; int q = FindTopCtrl(); @@ -759,6 +755,10 @@ Vector SplitCmdLine__(const char *cmd) return out; } +void Ctrl::InstallPanicBox() +{ +} + END_UPP_NAMESPACE #endif diff --git a/rainbow/Skeleton/Ctrl.cpp b/rainbow/Skeleton/Ctrl.cpp index 6f6608534..dcbe2470b 100644 --- a/rainbow/Skeleton/Ctrl.cpp +++ b/rainbow/Skeleton/Ctrl.cpp @@ -102,6 +102,10 @@ String Ctrl::Name() const { return s; } +void Ctrl::InstallPanicBox() +{ +} + END_UPP_NAMESPACE #endif diff --git a/rainbow/Skeleton/DrawOp.cpp b/rainbow/Skeleton/DrawOp.cpp index a7e6a3b1a..dcd6a2d14 100644 --- a/rainbow/Skeleton/DrawOp.cpp +++ b/rainbow/Skeleton/DrawOp.cpp @@ -69,10 +69,9 @@ void SystemDraw::DrawLineOp(int x1, int y1, int x2, int y2, int width, Color col GuiLock __; } -void SystemDraw::DrawImageOp(int x, int y, int cx, int cy, const Image& img, const Rect& src, Color color) +void SystemDraw::SysDrawImageOp(int x, int y, const Image& img, const Rect& src, Color color) { GuiLock __; - StdDrawImage(*this, x, y, cx, cy, img, src, color); } void SystemDraw::DrawPolyPolylineOp(const Point *vertices, int vertex_count, diff --git a/rainbow/Skeleton/Gui.h b/rainbow/Skeleton/Gui.h deleted file mode 100644 index 2070bdbec..000000000 --- a/rainbow/Skeleton/Gui.h +++ /dev/null @@ -1,358 +0,0 @@ -#define GUI_SKELETON - -NAMESPACE_UPP - -class SystemDraw : public Draw { -public: - virtual dword GetInfo() const; - virtual Size GetPageSize() const; - - virtual void BeginOp(); - virtual void EndOp(); - virtual void OffsetOp(Point p); - virtual bool ClipOp(const Rect& r); - virtual bool ClipoffOp(const Rect& r); - virtual bool ExcludeClipOp(const Rect& r); - virtual bool IntersectClipOp(const Rect& r); - virtual bool IsPaintingOp(const Rect& r) const; - virtual Rect GetPaintRect() const; - - virtual void DrawRectOp(int x, int y, int cx, int cy, Color color); - virtual void DrawImageOp(int x, int y, int cx, int cy, const Image& img, const Rect& src, Color color); - virtual void DrawLineOp(int x1, int y1, int x2, int y2, int width, Color color); - - virtual void DrawPolyPolylineOp(const Point *vertices, int vertex_count, - const int *counts, int count_count, - int width, Color color, Color doxor); - virtual void DrawPolyPolyPolygonOp(const Point *vertices, int vertex_count, - const int *subpolygon_counts, int scc, - const int *disjunct_polygon_counts, int dpcc, - Color color, int width, Color outline, - uint64 pattern, Color doxor); - virtual void DrawArcOp(const Rect& rc, Point start, Point end, int width, Color color); - - virtual void DrawEllipseOp(const Rect& r, Color color, int pen, Color pencolor); - virtual void DrawTextOp(int x, int y, int angle, const wchar *text, Font font, - Color ink, int n, const int *dx); - - virtual Size GetNativeDpi() const; - virtual void BeginNative(); - virtual void EndNative(); - - virtual int GetCloffLevel() const; - -private: - Size pageSize; - Size nativeSize; - Size nativeDpi; - bool palette:1; - bool color16:1; - bool is_mono:1; - int native; - - friend class ImageDraw; - friend class FontInfo; - friend class Font; - - friend void StaticExitDraw_(); - - Point actual_offset_bak; - - struct Cloff : Moveable { - Point org; - HRGN hrgn; - Rect drawingclip; - }; - - Array cloff; - Rect drawingclip; - - COLORREF lastTextColor; - Color lastColor; - HBRUSH orgBrush; - HBRUSH actBrush; - HPEN orgPen; - HPEN actPen; - int lastPen; - Color lastPenColor; - - void Unselect0(); - void Cinit(); - - void LoadCaps(); - void SetPrinterMode(); - void Reset(); - void SetOrg(); - friend HPALETTE GetQlibPalette(); - void DotsMode(); - - static void InitColors(); - - friend class BackDraw; - friend class ScreenDraw; - friend class PrintDraw; - -protected: - dword style; - HDC handle; - Point actual_offset; - - SystemDraw(); - void Init(); - void InitClip(const Rect& clip); - -public: - static Rect GetVirtualScreenArea(); - - static void SetAutoPalette(bool ap); - static bool AutoPalette(); - bool PaletteMode() { return palette; } - - static void Flush() { GdiFlush(); } - - COLORREF GetColor(Color color) const; - - Point GetOffset() const { return actual_offset; } - -#ifndef PLATFORM_WINCE - Point LPtoDP(Point p) const; - Point DPtoLP(Point p) const; - Rect LPtoDP(const Rect& r) const; - Rect DPtoLP(const Rect& r) const; -#endif - - void SetColor(Color color); - void SetDrawPen(int width, Color color); - - Size GetSizeCaps(int i, int j) const; - HDC BeginGdi(); - void EndGdi(); - HDC GetHandle() { return handle; } - operator HDC() const { return handle; } - void Unselect(); - void Attach(HDC ahandle) { handle = ahandle; Init(); } - HDC Detach() { Unselect(); HDC h = handle; handle = NULL; return h; } - - SystemDraw(HDC hdc); - virtual ~SystemDraw(); - - bool CanSetSurface() { return IsGui() && IsWinNT(); } -}; - -#ifndef PLATFORM_WINCE -class WinMetaFile { - Size size; - HENHMETAFILE hemf; - - void Init(); - -public: - void Attach(HENHMETAFILE emf); - HENHMETAFILE Detach(); - - void Set(const void *data, dword len); - void Set(const String& data) { Set(~data, data.GetCount()); } - - String Get() const; - - operator bool() const { return hemf; } - void SetSize(const Size& sz) { size = sz; } - Size GetSize() const { return hemf ? size : Size(0, 0); } - - void Clear(); - - void Paint(Draw& w, const Rect& r) const; - void Paint(Draw& w, int x, int y, int cx, int cy) const; - - void Serialize(Stream& s); - - void ReadClipboard(); - void WriteClipboard() const; - void Load(const char *file) { Set(LoadFile(file)); } - - WinMetaFile() { Init(); } - WinMetaFile(HENHMETAFILE hemf); - WinMetaFile(HENHMETAFILE hemf, Size sz); - WinMetaFile(const char *file); - WinMetaFile(void *data, int len); - WinMetaFile(const String& data); - - ~WinMetaFile() { Clear(); } - - HENHMETAFILE GetHEMF() const { return hemf; } -}; - -class WinMetaFileDraw : public SystemDraw { - Size size; - -public: - bool Create(HDC hdc, int cx, int cy, const char *app = NULL, const char *name = NULL, const char *file = NULL); - bool Create(int cx, int cy, const char *app = NULL, const char *name = NULL, const char *file = NULL); - WinMetaFile Close(); - - WinMetaFileDraw() {} - WinMetaFileDraw(HDC hdc, int cx, int cy, const char *app = NULL, const char *name = NULL, const char *file = NULL); - WinMetaFileDraw(int cx, int cy, const char *app = NULL, const char *name = NULL, const char *file = NULL); - ~WinMetaFileDraw(); -}; - -void DrawWMF(Draw& w, int x, int y, int cx, int cy, const String& wmf); -void DrawWMF(Draw& w, int x, int y, const String& wmf); -Drawing LoadWMF(const char *path, int cx, int cy); -Drawing LoadWMF(const char *path); - -String AsWMF(const Drawing& iw); - -#endif - -class ScreenDraw : public SystemDraw { -public: - ScreenDraw(bool ic = false); - ~ScreenDraw(); -}; - -#ifndef PLATFORM_WINCE -class PrintDraw : public SystemDraw { -public: - virtual void StartPage(); - virtual void EndPage(); - -private: - bool aborted; - - void InitPrinter(); -public: - PrintDraw(HDC hdc, const char *jobname); - ~PrintDraw(); -}; -#endif - -inline bool BitBlt(HDC ddc, Point d, HDC sdc, const Rect& s, dword rop = SRCCOPY) -{ return BitBlt(ddc, d.x, d.y, s.Width(), s.Height(), sdc, s.left, s.top, rop); } - -inline bool StretchBlt(HDC ddc, const Rect& r, HDC sdc, const Rect& s, dword rop = SRCCOPY) -{ return StretchBlt(ddc, r.left, r.top, r.Width(), r.Height(), sdc, s.left, s.top, s.Width(), s.Height(), rop); } - -inline bool PatBlt(HDC dc, const Rect& r, dword rop = PATCOPY) -{ return PatBlt(dc, r.left, r.top, r.Width(), r.Height(), rop); } - -inline void MoveTo(HDC hdc, Point pt) { MoveToEx(hdc, pt.x, pt.y, 0); } -inline void LineTo(HDC hdc, Point pt) { LineTo(hdc, pt.x, pt.y); } - -inline void DrawLine(HDC hdc, Point p, Point q) { MoveTo(hdc, p); LineTo(hdc, q); } -inline void DrawLine(HDC hdc, int px, int py, int qx, int qy) { MoveToEx(hdc, px, py, 0); LineTo(hdc, qx, qy); } - -#ifndef PLATFORM_WINCE -inline void DrawArc(HDC hdc, const Rect& rc, Point p, Point q){ Arc(hdc, rc.left, rc.top, rc.right, rc.bottom, p.x, p.y, q.x, q.y); } -#endif -inline void DrawCircle(HDC hdc, int x, int y, int radius) { Ellipse(hdc, x - radius, y - radius, x + radius + 1, y + radius + 1); } -inline void DrawCircle(HDC hdc, Point centre, int radius) { DrawCircle(hdc, centre.x, centre.y, radius); } -inline void DrawEllipse(HDC hdc, const Rect& rc) { Ellipse(hdc, rc.left, rc.top, rc.right, rc.bottom); } - -inline void DrawRect(HDC hdc, const Rect& rc) { Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom); } - -HDC ScreenHDC(); -HPALETTE GetQlibPalette(); - -Image Win32Icon(LPCSTR id, int iconsize = 0); -Image Win32Icon(int id, int iconsize = 0); -Image Win32Cursor(LPCSTR id); -Image Win32Cursor(int id); -HICON IconWin32(const Image& img, bool cursor = false); -Image Win32DllIcon(const char *dll, int ii, bool large); - -class BackDraw : public SystemDraw { -public: - virtual bool IsPaintingOp(const Rect& r) const; - -protected: - HBITMAP hbmpold; - HBITMAP hbmp; - - Size size; - Draw *painting; - Point painting_offset; - -public: - void Put(SystemDraw& w, int x, int y); - void Put(SystemDraw& w, Point p) { Put(w, p.x, p.y); } - - void Create(SystemDraw& w, int cx, int cy); - void Create(SystemDraw& w, Size sz) { Create(w, sz.cx, sz.cy); } - void Destroy(); - - void SetPaintingDraw(Draw& w, Point off) { painting = &w; painting_offset = off; } - - BackDraw(); - ~BackDraw(); -}; - -class ImageDraw : public SystemDraw { - Size size; - - struct Section { - HDC dc; - HBITMAP hbmp, hbmpOld; - RGBA *pixels; - - void Init(int cx, int cy); - ~Section(); - }; - - Section rgb; - Section a; - SystemDraw alpha; - - - bool has_alpha; - - void Init(); - Image Get(bool pm) const; - -public: - Draw& Alpha(); - - operator Image() const; - - Image GetStraight() const; - - ImageDraw(Size sz); - ImageDraw(int cx, int cy); - ~ImageDraw(); -}; - -END_UPP_NAMESPACE - -#define GUIPLATFORM_KEYCODES_INCLUDE "Win32Keys.h" - - -#define GUIPLATFORM_CTRL_TOP_DECLS \ - HWND hwnd; \ - UDropTarget *dndtgt; \ - - -#define GUIPLATFORM_CTRL_DECLS_INCLUDE "Win32Ctrl.h" - - -#define GUIPLATFORM_PASTECLIP_DECLS \ - UDropTarget *dt; \ - -#define GUIPLATFORM_TOPWINDOW_DECLS_INCLUDE "Win32Top.h" - -NAMESPACE_UPP - -inline unsigned GetHashValue(const HWND& hwnd) -{ - return (unsigned)(intptr_t)hwnd; -} -END_UPP_NAMESPACE - -#ifdef PLATFORM_WIN32 -#ifndef PLATFORM_WINCE - -#include - -#endif -#endif - -#define GUIPLATFORM_INCLUDE_AFTER "Win32GuiA.h" diff --git a/rainbow/Skeleton/Image.cpp b/rainbow/Skeleton/Image.cpp index 15f955b10..2bbf591ec 100644 --- a/rainbow/Skeleton/Image.cpp +++ b/rainbow/Skeleton/Image.cpp @@ -18,37 +18,6 @@ void SetSurface(SystemDraw& w, const Rect& dest, const RGBA *pixels, Size psz, P GuiLock __; } -struct Image::Data::SystemData { -}; - -void Image::Data::SysInitImp() -{ - SystemData& sd = Sys(); -} - -void Image::Data::SysReleaseImp() -{ - SystemData& sd = Sys(); -} - -Image::Data::SystemData& Image::Data::Sys() const -{ - ASSERT(sizeof(system_buffer) >= sizeof(SystemData)); - return *(SystemData *)system_buffer; -} - -int Image::Data::GetResCountImp() const -{ - SystemData& sd = Sys(); - return 0; -} - -void Image::Data::PaintImp(SystemDraw& w, int x, int y, const Rect& src, Color c) -{ - GuiLock __; - SystemData& sd = Sys(); -} - ImageDraw::operator Image() const { return Image(); diff --git a/rainbow/Skeleton/Skeleton.h b/rainbow/Skeleton/Skeleton.h index d5ba26bd8..d30c88bca 100644 --- a/rainbow/Skeleton/Skeleton.h +++ b/rainbow/Skeleton/Skeleton.h @@ -18,7 +18,7 @@ public: virtual Rect GetPaintRect() const; virtual void DrawRectOp(int x, int y, int cx, int cy, Color color); - virtual void DrawImageOp(int x, int y, int cx, int cy, const Image& img, const Rect& src, Color color); + virtual void SysDrawImageOp(int x, int y, const Image& img, const Rect& src, Color color); virtual void DrawLineOp(int x1, int y1, int x2, int y2, int width, Color color); virtual void DrawPolyPolylineOp(const Point *vertices, int vertex_count, diff --git a/rainbow/Skeleton/Wnd.cpp b/rainbow/Skeleton/Wnd.cpp index 709bd0ea0..936ee5bad 100644 --- a/rainbow/Skeleton/Wnd.cpp +++ b/rainbow/Skeleton/Wnd.cpp @@ -303,7 +303,7 @@ bool Ctrl::HasWndCapture() const return false; } -void Ctrl::WndInvalidateRect0(const Rect& r) +void Ctrl::WndInvalidateRect(const Rect& r) { GuiLock __; } diff --git a/rainbow/WinFb/Local.h b/rainbow/WinFb/Local.h index f23de235e..0fa22d913 100644 --- a/rainbow/WinFb/Local.h +++ b/rainbow/WinFb/Local.h @@ -13,8 +13,6 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int nCmdSh UPP::FBInit(hInstance); \ GuiMainFn_(); \ Ctrl::ExitFB(); \ - UPP::UsrLog("---------- About to delete this log of WinFB..."); \ - UPP::DeleteUsrLog(); \ return UPP::GetExitCode(); \ } \ \