From 91a6a9b382f9a9cc545dee614784f4534d26099e Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 17 Jun 2011 11:45:13 +0000 Subject: [PATCH] .Developing rainbow - framebuffer git-svn-id: svn://ultimatepp.org/upp/trunk@3542 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- rainbow/Framebuffer/After.h | 27 ++ rainbow/Framebuffer/ChSysInit.cpp | 16 ++ rainbow/Framebuffer/Clip.cpp | 241 ++++++++++++++++++ rainbow/Framebuffer/Ctrl.cpp | 99 ++++++++ rainbow/Framebuffer/Ctrl.h | 3 + rainbow/Framebuffer/DnD.cpp | 38 +++ rainbow/Framebuffer/Draw.cpp | 62 +++++ rainbow/Framebuffer/DrawOp.cpp | 99 ++++++++ rainbow/Framebuffer/DrawText.cpp | 16 ++ rainbow/Framebuffer/Framebuffer.upp | 22 ++ rainbow/Framebuffer/Gui.h | 358 ++++++++++++++++++++++++++ rainbow/Framebuffer/Image.cpp | 92 +++++++ rainbow/Framebuffer/Keys.h | 109 ++++++++ rainbow/Framebuffer/Msg.i | 126 ++++++++++ rainbow/Framebuffer/Proc.cpp | 24 ++ rainbow/Framebuffer/Skeleton.h | 129 ++++++++++ rainbow/Framebuffer/Top.cpp | 81 ++++++ rainbow/Framebuffer/Top.h | 3 + rainbow/Framebuffer/Util.cpp | 20 ++ rainbow/Framebuffer/Wnd.cpp | 375 ++++++++++++++++++++++++++++ rainbow/Framebuffer/init | 3 + rainbow/Paint/Draw.cpp | 32 +++ rainbow/Paint/Paint.upp | 12 + rainbow/Paint/init | 5 + rainbow/Skeleton/Skeleton.upp | 2 + rainbow/guiplatform.h | 4 + 26 files changed, 1998 insertions(+) create mode 100644 rainbow/Framebuffer/After.h create mode 100644 rainbow/Framebuffer/ChSysInit.cpp create mode 100644 rainbow/Framebuffer/Clip.cpp create mode 100644 rainbow/Framebuffer/Ctrl.cpp create mode 100644 rainbow/Framebuffer/Ctrl.h create mode 100644 rainbow/Framebuffer/DnD.cpp create mode 100644 rainbow/Framebuffer/Draw.cpp create mode 100644 rainbow/Framebuffer/DrawOp.cpp create mode 100644 rainbow/Framebuffer/DrawText.cpp create mode 100644 rainbow/Framebuffer/Framebuffer.upp create mode 100644 rainbow/Framebuffer/Gui.h create mode 100644 rainbow/Framebuffer/Image.cpp create mode 100644 rainbow/Framebuffer/Keys.h create mode 100644 rainbow/Framebuffer/Msg.i create mode 100644 rainbow/Framebuffer/Proc.cpp create mode 100644 rainbow/Framebuffer/Skeleton.h create mode 100644 rainbow/Framebuffer/Top.cpp create mode 100644 rainbow/Framebuffer/Top.h create mode 100644 rainbow/Framebuffer/Util.cpp create mode 100644 rainbow/Framebuffer/Wnd.cpp create mode 100644 rainbow/Framebuffer/init create mode 100644 rainbow/Paint/Draw.cpp create mode 100644 rainbow/Paint/Paint.upp create mode 100644 rainbow/Paint/init diff --git a/rainbow/Framebuffer/After.h b/rainbow/Framebuffer/After.h new file mode 100644 index 000000000..d044658fd --- /dev/null +++ b/rainbow/Framebuffer/After.h @@ -0,0 +1,27 @@ +class ViewDraw : public SystemDraw { +public: + ViewDraw(Ctrl *ctrl); + ~ViewDraw(); +}; + +Vector& coreCmdLine__(); +Vector SplitCmdLine__(const char *cmd); + +#define GUI_APP_MAIN \ +void GuiMainFn_();\ +\ +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int nCmdShow) \ +{ \ + UPP::coreCmdLine__() = UPP::SplitCmdLine__(UPP::FromSystemCharset(lpCmdLine)); \ + UPP::AppInitEnvironment__(); \ + GuiMainFn_(); \ + UPP::Ctrl::CloseTopCtrls(); \ + UPP::UsrLog("---------- About to delete this log..."); \ + UPP::DeleteUsrLog(); \ + return UPP::GetExitCode(); \ +} \ +\ +void GuiMainFn_() + + +class DHCtrl : Ctrl {}; diff --git a/rainbow/Framebuffer/ChSysInit.cpp b/rainbow/Framebuffer/ChSysInit.cpp new file mode 100644 index 000000000..3f0c09a0f --- /dev/null +++ b/rainbow/Framebuffer/ChSysInit.cpp @@ -0,0 +1,16 @@ +#include + +#ifdef GUI_EMPTY + +NAMESPACE_UPP + +void ChSysInit() +{ + CtrlImg::Reset(); + CtrlsImg::Reset(); + ChReset(); +} + +END_UPP_NAMESPACE + +#endif diff --git a/rainbow/Framebuffer/Clip.cpp b/rainbow/Framebuffer/Clip.cpp new file mode 100644 index 000000000..50707b977 --- /dev/null +++ b/rainbow/Framebuffer/Clip.cpp @@ -0,0 +1,241 @@ +#include +#include + +#ifdef GUI_EMPTY + +NAMESPACE_UPP + +#define LLOG(x) // LOG(x) + +void ClearClipboard() +{ + GuiLock __; +} + +void AppendClipboard(int format, const byte *data, int length) +{ + GuiLock __; +} + +void AppendClipboard(const char *format, const byte *data, int length) +{ + GuiLock __; +} + +void AppendClipboard(const char *format, const String& data) +{ + GuiLock __; + AppendClipboard(format, data, data.GetLength()); +} + +void AppendClipboard(const char *format, const Value& data, String (*render)(const Value&)) +{ + GuiLock __; +} + +String ReadClipboard(const char *format) +{ + GuiLock __; + return Null; +} + +void AppendClipboardText(const String& s) +{ + AppendClipboard("text", ToSystemCharset(s)); +} + +void AppendClipboardUnicodeText(const WString& s) +{ + AppendClipboard("wtext", (byte *)~s, 2 * s.GetLength()); +} + +const char *ClipFmtsText() +{ + return "wtext;text"; +} + +String GetString(PasteClip& clip) +{ + GuiLock __; + if(clip.Accept("wtext")) { + String s = ~clip; + return WString((const wchar *)~s, wstrlen((const wchar *)~s)).ToString(); + } + if(clip.IsAvailable("text")) + return ~clip; + return Null; +} + +WString GetWString(PasteClip& clip) +{ + GuiLock __; + if(clip.Accept("wtext")) { + String s = ~clip; + return WString((const wchar *)~s, wstrlen((const wchar *)~s)); + } + if(clip.IsAvailable("text")) + return (~clip).ToWString(); + return Null; +} + + +bool AcceptText(PasteClip& clip) +{ + return clip.Accept(ClipFmtsText()); +} + +static String sText(const Value& data) +{ + return data; +} + +static String sWText(const Value& data) +{ + return Unicode__(WString(data)); +} + +void Append(VectorMap& data, const String& text) +{ + data.GetAdd("text", ClipData(text, sText)); + data.GetAdd("wtext", ClipData(text, sWText)); +} + +void Append(VectorMap& data, const WString& text) +{ + data.GetAdd("text", ClipData(text, sText)); + data.GetAdd("wtext", ClipData(text, sWText)); +} + +String GetTextClip(const WString& text, const String& fmt) +{ + if(fmt == "text") + return text.ToString(); + if(fmt == "wtext") + return Unicode__(text); + return Null; +} + +String GetTextClip(const String& text, const String& fmt) +{ + if(fmt == "text") + return text; + if(fmt == "wtext") + return Unicode__(text.ToWString()); + return Null; +} + +String ReadClipboardText() +{ + return ReadClipboardUnicodeText().ToString(); +} + +WString ReadClipboardUnicodeText() +{ + return Null; +} + +bool IsClipboardAvailable(const char *id) +{ + return false; +} + +bool IsClipboardAvailableText() +{ + return false; +} + +const char *ClipFmtsImage() +{ + static const char *q; + ONCELOCK { + static String s = "dib;" + ClipFmt(); + q = s; + } + return q; +} + +bool AcceptImage(PasteClip& clip) +{ + GuiLock __; + return clip.Accept(ClipFmtsImage()); +} + +Image GetImage(PasteClip& clip) +{ + GuiLock __; + Image m; + if(Accept(clip)) { + LoadFromString(m, ~clip); + if(!m.IsEmpty()) + return m; + } + return Null; +} + +Image ReadClipboardImage() +{ + GuiLock __; + PasteClip d = Ctrl::Clipboard(); + return GetImage(d); +} + +String sImage(const Value& image) +{ + Image img = image; + return StoreAsString(const_cast(img)); +} + +String GetImageClip(const Image& img, const String& fmt) +{ + GuiLock __; + if(img.IsEmpty()) return Null; + if(fmt == ClipFmt()) + return sImage(img); + return Null; +} + +void AppendClipboardImage(const Image& img) +{ + GuiLock __; + if(img.IsEmpty()) return; + AppendClipboard(ClipFmt(), img, sImage); +} + +bool AcceptFiles(PasteClip& clip) +{ + if(clip.Accept("files")) { + clip.SetAction(DND_COPY); + return true; + } + return false; +} + +bool IsAvailableFiles(PasteClip& clip) +{ + return clip.IsAvailable("files"); +} + +Vector GetFiles(PasteClip& clip) +{ + GuiLock __; + Vector f; + return f; +} + +bool PasteClip::IsAvailable(const char *fmt) const +{ + return false; +} + +String PasteClip::Get(const char *fmt) const +{ + return Null; +} + +void PasteClip::GuiPlatformConstruct() +{ +} + +END_UPP_NAMESPACE + +#endif diff --git a/rainbow/Framebuffer/Ctrl.cpp b/rainbow/Framebuffer/Ctrl.cpp new file mode 100644 index 000000000..9875d2277 --- /dev/null +++ b/rainbow/Framebuffer/Ctrl.cpp @@ -0,0 +1,99 @@ +#include + +#ifdef GUI_EMPTY + +#define LLOG(x) // DLOG(x) + +NAMESPACE_UPP + +void Ctrl::GuiPlatformConstruct() +{ +} + +void Ctrl::GuiPlatformDestruct() +{ +} + +void Ctrl::GuiPlatformRemove() +{ +} + +void Ctrl::GuiPlatformGetTopRect(Rect& r) const +{ +} + +bool Ctrl::GuiPlatformRefreshFrameSpecial(const Rect& r) +{ + return false; +} + +bool Ctrl::GuiPlatformSetFullRefreshSpecial() +{ + return false; +} + +void Ctrl::PaintCaret(SystemDraw& w) +{ +} + +String GuiPlatformGetKeyDesc(dword key) +{ + return Null; +} + +void Ctrl::GuiPlatformSelection(PasteClip&) +{ +} + +void GuiPlatformAdjustDragImage(ImageBuffer&) +{ +} + +bool GuiPlatformHasSizeGrip() +{ + return true; +} + +void GuiPlatformGripResize(TopWindow *q) +{ +} + +Color GuiPlatformGetScreenPixel(int x, int y) +{ + return Black; +} + +void GuiPlatformAfterMenuPopUp() +{ +} + +void Ctrl::SetCaret(int x, int y, int cx, int cy) +{ + GuiLock __; + caretx = x; + carety = y; + caretcx = cx; + caretcy = cy; + SyncCaret(); +} + +void Ctrl::SyncCaret() { + GuiLock __; + +} + +String Ctrl::Name() const { + GuiLock __; +#ifdef CPU_64 + String s = String(typeid(*this).name()) + " : 0x" + FormatIntHex(this); +#else + String s = String(typeid(*this).name()) + " : " + Format("0x%x", (int) this); +#endif + if(IsChild()) + s << "(parent " << String(typeid(*parent).name()) << ")"; + return s; +} + +END_UPP_NAMESPACE + +#endif diff --git a/rainbow/Framebuffer/Ctrl.h b/rainbow/Framebuffer/Ctrl.h new file mode 100644 index 000000000..cd2112445 --- /dev/null +++ b/rainbow/Framebuffer/Ctrl.h @@ -0,0 +1,3 @@ +//$ class Ctrl { + +//$ }; diff --git a/rainbow/Framebuffer/DnD.cpp b/rainbow/Framebuffer/DnD.cpp new file mode 100644 index 000000000..50543fea8 --- /dev/null +++ b/rainbow/Framebuffer/DnD.cpp @@ -0,0 +1,38 @@ +#include + +#ifdef GUI_EMPTY + +NAMESPACE_UPP + +#define LLOG(x) // LOG(x) + +// -------------------------------------------------------------------------------------------- + +Ptr sDnDSource; + +Ctrl * Ctrl::GetDragAndDropSource() +{ + return sDnDSource; +} + +Image MakeDragImage(const Image& arrow, Image sample); + +Image MakeDragImage(const Image& arrow, const Image& arrow98, Image sample) +{ + if(IsWin2K()) + return MakeDragImage(arrow, sample); + else + return arrow98; +} + +int Ctrl::DoDragAndDrop(const char *fmts, const Image& sample, dword actions, + const VectorMap& data) +{ + return DND_NONE; +} + +void Ctrl::SetSelectionSource(const char *fmts) {} + +END_UPP_NAMESPACE + +#endif diff --git a/rainbow/Framebuffer/Draw.cpp b/rainbow/Framebuffer/Draw.cpp new file mode 100644 index 000000000..22b14cfd0 --- /dev/null +++ b/rainbow/Framebuffer/Draw.cpp @@ -0,0 +1,62 @@ +#include + +#ifdef GUI_EMPTY + +NAMESPACE_UPP + +#define LLOG(x) // LOG(x) +#define LTIMING(x) // RTIMING(x) + +/*Rect SystemDraw::GetVirtualScreenArea() +{ + GuiLock __; +}*/ + +dword SystemDraw::GetInfo() const +{ + return NATIVE; +} + +Size SystemDraw::GetPageSize() const +{ + return Size(0, 0); +} + +Size SystemDraw::GetNativeDpi() const +{ + return Size(96, 96); +} + +void SystemDraw::BeginNative() +{ +} + +void SystemDraw::EndNative() +{ +} + +int SystemDraw::GetCloffLevel() const +{ + return 0; +} + +SystemDraw::~SystemDraw() { + GuiLock __; +} + +void BackDraw::Destroy() +{ + GuiLock __; +} + +void BackDraw::Create(SystemDraw& w, int cx, int cy) { + GuiLock __; +} + +void BackDraw::Put(SystemDraw& w, int x, int y) { + GuiLock __; +} + +END_UPP_NAMESPACE + +#endif diff --git a/rainbow/Framebuffer/DrawOp.cpp b/rainbow/Framebuffer/DrawOp.cpp new file mode 100644 index 000000000..b47cebaa4 --- /dev/null +++ b/rainbow/Framebuffer/DrawOp.cpp @@ -0,0 +1,99 @@ +#include + +#ifdef GUI_EMPTY + +NAMESPACE_UPP + +#define LLOG(x) // LOG(x) +#define LTIMING(x) // RTIMING(x) + +void SystemDraw::BeginOp() +{ + LTIMING("Begin"); + GuiLock __; +} + +void SystemDraw::OffsetOp(Point p) +{ + GuiLock __; +} + +bool SystemDraw::ClipOp(const Rect& r) +{ + GuiLock __; + return true; +} + +bool SystemDraw::ClipoffOp(const Rect& r) +{ + GuiLock __; + return true; +} + +void SystemDraw::EndOp() +{ + GuiLock __; +} + +bool SystemDraw::ExcludeClipOp(const Rect& r) +{ + GuiLock __; + return true; +} + +bool SystemDraw::IntersectClipOp(const Rect& r) +{ + GuiLock __; + return true; +} + +bool SystemDraw::IsPaintingOp(const Rect& r) const +{ + GuiLock __; + return true; +} + +Rect SystemDraw::GetPaintRect() const +{ + GuiLock __; + return Rect(0, 0, 10000, 1000); +} + +void SystemDraw::DrawRectOp(int x, int y, int cx, int cy, Color color) +{ + GuiLock __; +} + +void SystemDraw::DrawLineOp(int x1, int y1, int x2, int y2, int width, Color color) +{ + GuiLock __; +} + +void SystemDraw::DrawPolyPolylineOp(const Point *vertices, int vertex_count, + const int *counts, int count_count, + int width, Color color, Color doxor) +{ + GuiLock __; +} + +void SystemDraw::DrawPolyPolyPolygonOp(const Point *vertices, int vertex_count, + const int *subpolygon_counts, int subpolygon_count_count, + const int *disjunct_polygon_counts, int disjunct_polygon_count_count, + Color color, int width, Color outline, uint64 pattern, Color doxor) +{ + GuiLock __; +} + +void SystemDraw::DrawArcOp(const Rect& rc, Point start, Point end, int width, Color color) +{ + GuiLock __; +} + +void SystemDraw::DrawEllipseOp(const Rect& r, Color color, int width, Color pencolor) +{ + GuiLock __; +} + +END_UPP_NAMESPACE + +#endif diff --git a/rainbow/Framebuffer/DrawText.cpp b/rainbow/Framebuffer/DrawText.cpp new file mode 100644 index 000000000..b90cb7e94 --- /dev/null +++ b/rainbow/Framebuffer/DrawText.cpp @@ -0,0 +1,16 @@ +#include + +#ifdef GUI_EMPTY + +NAMESPACE_UPP + +#define LLOG(x) + +void SystemDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink, + int n, const int *dx) { + Std(font); +} + +END_UPP_NAMESPACE + +#endif diff --git a/rainbow/Framebuffer/Framebuffer.upp b/rainbow/Framebuffer/Framebuffer.upp new file mode 100644 index 000000000..59b6457ff --- /dev/null +++ b/rainbow/Framebuffer/Framebuffer.upp @@ -0,0 +1,22 @@ +description "Generic framebuffer GUI rainbow\377"; + +file + Skeleton.h, + After.h, + Keys.h, + DrawOp.cpp, + DrawText.cpp, + Draw.cpp, + Image.cpp, + Util.cpp, + Ctrl.h, + Ctrl.cpp, + Wnd.cpp, + Proc.cpp, + Top.h, + Top.cpp, + Clip.cpp, + DnD.cpp, + ChSysInit.cpp, + Msg.i; + diff --git a/rainbow/Framebuffer/Gui.h b/rainbow/Framebuffer/Gui.h new file mode 100644 index 000000000..057406baa --- /dev/null +++ b/rainbow/Framebuffer/Gui.h @@ -0,0 +1,358 @@ +#define GUI_EMPTY + +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/Framebuffer/Image.cpp b/rainbow/Framebuffer/Image.cpp new file mode 100644 index 000000000..efe04e4ae --- /dev/null +++ b/rainbow/Framebuffer/Image.cpp @@ -0,0 +1,92 @@ +#include + +#ifdef GUI_EMPTY + +#include + +NAMESPACE_UPP + +#define LTIMING(x) // RTIMING(x) + +void SetSurface(SystemDraw& w, int x, int y, int cx, int cy, const RGBA *pixels) +{ + GuiLock __; +} + +void SetSurface(SystemDraw& w, const Rect& dest, const RGBA *pixels, Size psz, Point poff) +{ + 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(); +} + +Image ImageDraw::GetStraight() const +{ + return Image(); +} + +ImageDraw::ImageDraw(Size sz) +{ +} + +ImageDraw::ImageDraw(int cx, int cy) +{ +} + +ImageDraw::~ImageDraw() +{ +} + +Image Image::Arrow() { return Null; } +Image Image::Wait() { return Null; } +Image Image::IBeam() { return Null; } +Image Image::No() { return Null; } +Image Image::SizeAll() { return Null; } +Image Image::SizeHorz() { return Null; } +Image Image::SizeVert() { return Null; } +Image Image::SizeTopLeft() { return Null; } +Image Image::SizeTop() { return Null; } +Image Image::SizeTopRight() { return Null; } +Image Image::SizeLeft() { return Null; } +Image Image::SizeRight() { return Null; } +Image Image::SizeBottomLeft() { return Null; } +Image Image::SizeBottom() { return Null; } +Image Image::SizeBottomRight() { return Null; } + +END_UPP_NAMESPACE + +#endif diff --git a/rainbow/Framebuffer/Keys.h b/rainbow/Framebuffer/Keys.h new file mode 100644 index 000000000..000cea433 --- /dev/null +++ b/rainbow/Framebuffer/Keys.h @@ -0,0 +1,109 @@ +K_BACK = VK_BACK + K_DELTA, +K_BACKSPACE = VK_BACK + K_DELTA, + +K_TAB = 9, + +K_SPACE = 32, + +K_RETURN = 13, +K_ENTER = K_RETURN, + +K_SHIFT_KEY = VK_SHIFT + K_DELTA, +K_CTRL_KEY = VK_CONTROL + K_DELTA, +K_ALT_KEY = VK_MENU + K_DELTA, +K_CAPSLOCK = VK_CAPITAL + K_DELTA, +K_ESCAPE = VK_ESCAPE + K_DELTA, +K_PRIOR = VK_PRIOR + K_DELTA, +K_PAGEUP = VK_PRIOR + K_DELTA, +K_NEXT = VK_NEXT + K_DELTA, +K_PAGEDOWN = VK_NEXT + K_DELTA, +K_END = VK_END + K_DELTA, +K_HOME = VK_HOME + K_DELTA, +K_LEFT = VK_LEFT + K_DELTA, +K_UP = VK_UP + K_DELTA, +K_RIGHT = VK_RIGHT + K_DELTA, +K_DOWN = VK_DOWN + K_DELTA, +K_INSERT = VK_INSERT + K_DELTA, +K_DELETE = VK_DELETE + K_DELTA, + +K_NUMPAD0 = VK_NUMPAD0 + K_DELTA, +K_NUMPAD1 = VK_NUMPAD1 + K_DELTA, +K_NUMPAD2 = VK_NUMPAD2 + K_DELTA, +K_NUMPAD3 = VK_NUMPAD3 + K_DELTA, +K_NUMPAD4 = VK_NUMPAD4 + K_DELTA, +K_NUMPAD5 = VK_NUMPAD5 + K_DELTA, +K_NUMPAD6 = VK_NUMPAD6 + K_DELTA, +K_NUMPAD7 = VK_NUMPAD7 + K_DELTA, +K_NUMPAD8 = VK_NUMPAD8 + K_DELTA, +K_NUMPAD9 = VK_NUMPAD9 + K_DELTA, +K_MULTIPLY = VK_MULTIPLY + K_DELTA, +K_ADD = VK_ADD + K_DELTA, +K_SEPARATOR = VK_SEPARATOR + K_DELTA, +K_SUBTRACT = VK_SUBTRACT + K_DELTA, +K_DECIMAL = VK_DECIMAL + K_DELTA, +K_DIVIDE = VK_DIVIDE + K_DELTA, +K_SCROLL = VK_SCROLL + K_DELTA, + +K_F1 = VK_F1 + K_DELTA, +K_F2 = VK_F2 + K_DELTA, +K_F3 = VK_F3 + K_DELTA, +K_F4 = VK_F4 + K_DELTA, +K_F5 = VK_F5 + K_DELTA, +K_F6 = VK_F6 + K_DELTA, +K_F7 = VK_F7 + K_DELTA, +K_F8 = VK_F8 + K_DELTA, +K_F9 = VK_F9 + K_DELTA, +K_F10 = VK_F10 + K_DELTA, +K_F11 = VK_F11 + K_DELTA, +K_F12 = VK_F12 + K_DELTA, + +K_A = 'A' + K_DELTA, +K_B = 'B' + K_DELTA, +K_C = 'C' + K_DELTA, +K_D = 'D' + K_DELTA, +K_E = 'E' + K_DELTA, +K_F = 'F' + K_DELTA, +K_G = 'G' + K_DELTA, +K_H = 'H' + K_DELTA, +K_I = 'I' + K_DELTA, +K_J = 'J' + K_DELTA, +K_K = 'K' + K_DELTA, +K_L = 'L' + K_DELTA, +K_M = 'M' + K_DELTA, +K_N = 'N' + K_DELTA, +K_O = 'O' + K_DELTA, +K_P = 'P' + K_DELTA, +K_Q = 'Q' + K_DELTA, +K_R = 'R' + K_DELTA, +K_S = 'S' + K_DELTA, +K_T = 'T' + K_DELTA, +K_U = 'U' + K_DELTA, +K_V = 'V' + K_DELTA, +K_W = 'W' + K_DELTA, +K_X = 'X' + K_DELTA, +K_Y = 'Y' + K_DELTA, +K_Z = 'Z' + K_DELTA, +K_0 = '0' + K_DELTA, +K_1 = '1' + K_DELTA, +K_2 = '2' + K_DELTA, +K_3 = '3' + K_DELTA, +K_4 = '4' + K_DELTA, +K_5 = '5' + K_DELTA, +K_6 = '6' + K_DELTA, +K_7 = '7' + K_DELTA, +K_8 = '8' + K_DELTA, +K_9 = '9' + K_DELTA, + +K_CTRL_LBRACKET = K_CTRL|219|K_DELTA, +K_CTRL_RBRACKET = K_CTRL|221|K_DELTA, +K_CTRL_MINUS = K_CTRL|0xbd|K_DELTA, +K_CTRL_GRAVE = K_CTRL|0xc0|K_DELTA, +K_CTRL_SLASH = K_CTRL|0xbf|K_DELTA, +K_CTRL_BACKSLASH = K_CTRL|0xdc|K_DELTA, +K_CTRL_COMMA = K_CTRL|0xbc|K_DELTA, +K_CTRL_PERIOD = K_CTRL|0xbe|K_DELTA, +K_CTRL_SEMICOLON = K_CTRL|0xbe|K_DELTA, +K_CTRL_EQUAL = K_CTRL|0xbb|K_DELTA, +K_CTRL_APOSTROPHE= K_CTRL|0xde|K_DELTA, + +K_BREAK = VK_CANCEL + K_DELTA, diff --git a/rainbow/Framebuffer/Msg.i b/rainbow/Framebuffer/Msg.i new file mode 100644 index 000000000..a578ff256 --- /dev/null +++ b/rainbow/Framebuffer/Msg.i @@ -0,0 +1,126 @@ +#pragma BLITZ_APPROVE + +x_MSG(WM_CREATE) +x_MSG(WM_DESTROY) +x_MSG(WM_MOVE) +x_MSG(WM_SIZE) +x_MSG(WM_ACTIVATE) +x_MSG(WM_SETFOCUS) +x_MSG(WM_KILLFOCUS) +x_MSG(WM_ENABLE) +x_MSG(WM_SETREDRAW) +x_MSG(WM_SETTEXT) +x_MSG(WM_GETTEXT) +x_MSG(WM_GETTEXTLENGTH) +x_MSG(WM_PAINT) +x_MSG(WM_CLOSE) +x_MSG(WM_QUIT) +x_MSG(WM_ERASEBKGND) +x_MSG(WM_SYSCOLORCHANGE) +x_MSG(WM_SHOWWINDOW) +x_MSG(WM_WININICHANGE) +x_MSG(WM_FONTCHANGE) +x_MSG(WM_NEXTDLGCTL) +x_MSG(WM_DRAWITEM) +x_MSG(WM_MEASUREITEM) +x_MSG(WM_DELETEITEM) +x_MSG(WM_VKEYTOITEM) +x_MSG(WM_CHARTOITEM) +x_MSG(WM_SETFONT) +x_MSG(WM_GETFONT) +x_MSG(WM_QUERYDRAGICON) +x_MSG(WM_COMPAREITEM) +x_MSG(WM_GETDLGCODE) +x_MSG(WM_KEYDOWN) +x_MSG(WM_KEYUP) +x_MSG(WM_CHAR) +x_MSG(WM_DEADCHAR) +x_MSG(WM_SYSKEYDOWN) +x_MSG(WM_SYSKEYUP) +x_MSG(WM_SYSCHAR) +x_MSG(WM_SYSDEADCHAR) +x_MSG(WM_KEYLAST) +x_MSG(WM_INITDIALOG) +x_MSG(WM_COMMAND) +x_MSG(WM_SYSCOMMAND) +x_MSG(WM_TIMER) +x_MSG(WM_HSCROLL) +x_MSG(WM_VSCROLL) +x_MSG(WM_INITMENUPOPUP) +x_MSG(WM_MENUCHAR) +x_MSG(WM_LBUTTONDOWN) +x_MSG(WM_LBUTTONUP) +x_MSG(WM_LBUTTONDBLCLK) +x_MSG(WM_RBUTTONDOWN) +x_MSG(WM_RBUTTONUP) +x_MSG(WM_RBUTTONDBLCLK) +x_MSG(WM_MBUTTONDOWN) +x_MSG(WM_MBUTTONUP) +x_MSG(WM_MBUTTONDBLCLK) +x_MSG(WM_MOUSEMOVE) +x_MSG(WM_CUT) +x_MSG(WM_COPY) +x_MSG(WM_PASTE) +x_MSG(WM_CLEAR) +x_MSG(WM_UNDO) +x_MSG(WM_RENDERFORMAT) +x_MSG(WM_RENDERALLFORMATS) +x_MSG(WM_DESTROYCLIPBOARD) +x_MSG(WM_QUERYNEWPALETTE) +x_MSG(WM_PALETTECHANGED) +x_MSG(WM_WINDOWPOSCHANGED) + +#ifndef PLATFORM_WINCE +x_MSG(WM_QUERYENDSESSION) +x_MSG(WM_ENDSESSION) +x_MSG(WM_QUERYOPEN) +x_MSG(WM_DEVMODECHANGE) +x_MSG(WM_ACTIVATEAPP) +x_MSG(WM_TIMECHANGE) +x_MSG(WM_MOUSEACTIVATE) +x_MSG(WM_CHILDACTIVATE) +x_MSG(WM_QUEUESYNC) +x_MSG(WM_GETMINMAXINFO) +x_MSG(WM_ICONERASEBKGND) +x_MSG(WM_SPOOLERSTATUS) +x_MSG(WM_COMPACTING) +x_MSG(WM_NCLBUTTONDOWN) +x_MSG(WM_NCLBUTTONUP) +x_MSG(WM_NCLBUTTONDBLCLK) +x_MSG(WM_NCRBUTTONDOWN) +x_MSG(WM_NCRBUTTONUP) +x_MSG(WM_NCRBUTTONDBLCLK) +x_MSG(WM_NCMBUTTONDOWN) +x_MSG(WM_NCMBUTTONUP) +x_MSG(WM_NCMBUTTONDBLCLK) +x_MSG(WM_NCCREATE) +x_MSG(WM_NCDESTROY) +x_MSG(WM_NCCALCSIZE) +x_MSG(WM_NCPAINT) +x_MSG(WM_NCACTIVATE) +x_MSG(WM_INITMENU) +x_MSG(WM_MENUSELECT) +x_MSG(WM_PARENTNOTIFY) +x_MSG(WM_MDICREATE) +x_MSG(WM_MDIDESTROY) +x_MSG(WM_MDIACTIVATE) +x_MSG(WM_MDIRESTORE) +x_MSG(WM_MDINEXT) +x_MSG(WM_MDIMAXIMIZE) +x_MSG(WM_MDITILE) +x_MSG(WM_MDICASCADE) +x_MSG(WM_MDIICONARRANGE) +x_MSG(WM_MDIGETACTIVE) +x_MSG(WM_MDISETMENU) +x_MSG(WM_DRAWCLIPBOARD) +x_MSG(WM_PAINTCLIPBOARD) +x_MSG(WM_VSCROLLCLIPBOARD) +x_MSG(WM_SIZECLIPBOARD) +x_MSG(WM_ASKCBFORMATNAME) +x_MSG(WM_CHANGECBCHAIN) +x_MSG(WM_HSCROLLCLIPBOARD) +x_MSG(WM_PALETTEISCHANGING) +x_MSG(WM_DROPFILES) +x_MSG(WM_POWER) +x_MSG(WM_WINDOWPOSCHANGING) +#endif diff --git a/rainbow/Framebuffer/Proc.cpp b/rainbow/Framebuffer/Proc.cpp new file mode 100644 index 000000000..242a3810e --- /dev/null +++ b/rainbow/Framebuffer/Proc.cpp @@ -0,0 +1,24 @@ +#include + +#ifdef GUI_EMPTY + +#include + +//#include "imm.h" + +NAMESPACE_UPP + +#define LLOG(x) // LOG(x) + +bool GetShift() { return false; } +bool GetCtrl() { return false; } +bool GetAlt() { return false; } +bool GetCapsLock() { return false; } +bool GetMouseLeft() { return false; } +bool GetMouseRight() { return false; } +bool GetMouseMiddle() { return false; } +Point GetMousePos() { return Point(0, 0); } + +END_UPP_NAMESPACE + +#endif diff --git a/rainbow/Framebuffer/Skeleton.h b/rainbow/Framebuffer/Skeleton.h new file mode 100644 index 000000000..e6012605f --- /dev/null +++ b/rainbow/Framebuffer/Skeleton.h @@ -0,0 +1,129 @@ +#define GUI_FRAMEBUFFER + +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; + + + virtual ~SystemDraw(); + + Point GetOffset() const { return Point(0, 0); } + bool CanSetSurface() { return false; } + static void Flush() {} +}; + +class BackDraw : public SystemDraw { + Size size; + Draw *painting; + Point painting_offset; + +public: + virtual bool IsPaintingOp(const Rect& r) const; + +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 { + SystemDraw alpha; + bool has_alpha; + Size size; + +public: + Draw& Alpha(); + + operator Image() const; + + Image GetStraight() const; + + ImageDraw(Size sz); + ImageDraw(int cx, int cy); + ~ImageDraw(); +}; + +void DrawDragRect(SystemDraw& w, const Rect& rect1, const Rect& rect2, const Rect& clip, int n, + Color color, uint64 pattern); + +#define GUIPLATFORM_KEYCODES_INCLUDE + +#define GUIPLATFORM_CTRL_TOP_DECLS + +#define GUIPLATFORM_CTRL_DECLS_INCLUDE + +#define GUIPLATFORM_PASTECLIP_DECLS + +#define GUIPLATFORM_TOPWINDOW_DECLS_INCLUDE + +class PrinterJob { + NilDraw nil; + Vector pages; + +public: + Draw& GetDraw() { return nil; } + operator Draw&() { return GetDraw(); } + const Vector& GetPages() const { return pages; } + int operator[](int i) const { return 0; } + int GetPageCount() const { return 0; } + + bool Execute() { return false; } + + PrinterJob& Landscape(bool b = true) { return *this; } + PrinterJob& MinMaxPage(int minpage, int maxpage) { return *this; } + PrinterJob& PageCount(int n) { return *this; } + PrinterJob& CurrentPage(int currentpage) { return *this; } + PrinterJob& Name(const char *_name) { return *this; } + + PrinterJob(const char *name = NULL) {} + ~PrinterJob() {} +}; + +END_UPP_NAMESPACE + +#define GUIPLATFORM_INCLUDE_AFTER diff --git a/rainbow/Framebuffer/Top.cpp b/rainbow/Framebuffer/Top.cpp new file mode 100644 index 000000000..ed61fcbc2 --- /dev/null +++ b/rainbow/Framebuffer/Top.cpp @@ -0,0 +1,81 @@ +#include + +#ifdef GUI_EMPTY + +NAMESPACE_UPP + +#define LLOG(x) // LOG(x) + +void TopWindow::SyncSizeHints() {} + +void TopWindow::SyncTitle0() +{ + GuiLock __; +} + +void TopWindow::SyncCaption0() +{ + GuiLock __; +} + +void TopWindow::Open(Ctrl *owner) +{ + GuiLock __; +} + +void TopWindow::Open() +{ +} + +void TopWindow::OpenMain() +{ +} + +void TopWindow::Minimize(bool effect) +{ + state = MINIMIZED; +} + +TopWindow& TopWindow::FullScreen(bool b) +{ + return *this; +} + +void TopWindow::Maximize(bool effect) +{ + state = MAXIMIZED; +} + +void TopWindow::Overlap(bool effect) +{ + GuiLock __; + state = OVERLAPPED; +} + +TopWindow& TopWindow::TopMost(bool b, bool stay_top) +{ + GuiLock __; + return *this; +} + +bool TopWindow::IsTopMost() const +{ + return true; +} + +void TopWindow::GuiPlatformConstruct() +{ +} + +void TopWindow::GuiPlatformDestruct() +{ +} + +void TopWindow::SerializePlacement(Stream& s, bool reminimize) +{ + GuiLock __; +} + +END_UPP_NAMESPACE + +#endif diff --git a/rainbow/Framebuffer/Top.h b/rainbow/Framebuffer/Top.h new file mode 100644 index 000000000..34f716a90 --- /dev/null +++ b/rainbow/Framebuffer/Top.h @@ -0,0 +1,3 @@ +//$ class TopWindow { + +//$ }; \ No newline at end of file diff --git a/rainbow/Framebuffer/Util.cpp b/rainbow/Framebuffer/Util.cpp new file mode 100644 index 000000000..47f1a6c16 --- /dev/null +++ b/rainbow/Framebuffer/Util.cpp @@ -0,0 +1,20 @@ +#include + +#ifdef GUI_EMPTY + +NAMESPACE_UPP + +void DrawDragRect(SystemDraw& w, const Rect& rect1, const Rect& rect2, const Rect& clip, int n, Color color, uint64 pattern) +{ +} + +/* +Size GetScreenSize() +{ + return ScreenInfo().GetPageSize(); +} +*/ + +END_UPP_NAMESPACE + +#endif diff --git a/rainbow/Framebuffer/Wnd.cpp b/rainbow/Framebuffer/Wnd.cpp new file mode 100644 index 000000000..4d25056ae --- /dev/null +++ b/rainbow/Framebuffer/Wnd.cpp @@ -0,0 +1,375 @@ +#include + +#ifdef GUI_EMPTY + +NAMESPACE_UPP + +#define LLOG(x) // LOG(x) +#define LOGTIMING 0 + +#ifdef _DEBUG +#define LOGMESSAGES 0 +#endif + +#define ELOGW(x) // RLOG(GetSysTime() << ": " << x) // Only activate in MT! +#define ELOG(x) // RLOG(GetSysTime() << ": " << x) + +bool Ctrl::IsAlphaSupported() +{ + return false; +} + +bool Ctrl::IsCompositedGui() +{ + return false; +} + +Vector Ctrl::GetTopCtrls() +{ + Vector h; + return h; +} + +void Ctrl::SetMouseCursor(const Image& image) +{ + GuiLock __; +} + +Ctrl *Ctrl::GetOwner() +{ + GuiLock __; + return NULL; +} + +Ctrl *Ctrl::GetActiveCtrl() +{ + GuiLock __; + return NULL; +} + +// Vector Ctrl::hotkey; + +int Ctrl::RegisterSystemHotKey(dword key, Callback cb) +{ +/* ASSERT(key >= K_DELTA); + int q = hotkey.GetCount(); + for(int i = 0; i < hotkey.GetCount(); i++) + if(!hotkey[i]) { + q = i; + break; + } + hotkey.At(q) = cb; + dword mod = 0; + if(key & K_ALT) + mod |= MOD_ALT; + if(key & K_SHIFT) + mod |= MOD_SHIFT; + if(key & K_CTRL) + mod |= MOD_CONTROL; + + return RegisterHotKey(NULL, q, mod, key & 0xffff) ? q : -1;*/ + return -1; +} + +void Ctrl::UnregisterSystemHotKey(int id) +{ +/* if(id >= 0 && id < hotkey.GetCount()) { + UnregisterHotKey(NULL, id); + hotkey[id].Clear(); + }*/ +} + +bool Ctrl::IsWaitingEvent() +{ + return false; +} + +bool Ctrl::ProcessEvent(bool *quit) +{ + ASSERT(IsMainThread()); + return false; +} + +void SweepMkImageCache(); + +bool Ctrl::ProcessEvents(bool *quit) +{ +/* if(ProcessEvent(quit)) { + while(ProcessEvent(quit) && (!LoopCtrl || LoopCtrl->InLoop())); // LoopCtrl-MF 071008 + TimerProc(GetTickCount()); + SweepMkImageCache(); + return true; + } + SweepMkImageCache(); + TimerProc(GetTickCount());*/ + return false; +} + + +void Ctrl::EventLoop0(Ctrl *ctrl) +{ + GuiLock __; +/* ASSERT(IsMainThread()); + ASSERT(LoopLevel == 0 || ctrl); + LoopLevel++; + LLOG("Entering event loop at level " << LoopLevel << BeginIndent); + Ptr ploop; + if(ctrl) { + ploop = LoopCtrl; + LoopCtrl = ctrl; + ctrl->inloop = true; + } + + bool quit = false; + ProcessEvents(&quit); + while(!EndSession() && !quit && ctrl ? ctrl->IsOpen() && ctrl->InLoop() : GetTopCtrls().GetCount()) + { +// LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / GuiSleep"); + SyncCaret(); + GuiSleep(1000); + if(EndSession()) break; +// LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / ProcessEvents"); + ProcessEvents(&quit); +// LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / after ProcessEvents"); + } + + if(ctrl) + LoopCtrl = ploop; + LoopLevel--; + LLOG(EndIndent << "Leaving event loop ");*/ +} + +void Ctrl::GuiSleep0(int ms) +{ + GuiLock __; +/* ASSERT(IsMainThread()); + ELOG("GuiSleep"); + if(EndSession()) + return; + ELOG("GuiSleep 2"); + int level = LeaveGMutexAll(); +#if !defined(flagDLL) && !defined(PLATFORM_WINCE) + if(!OverwatchThread) { + DWORD dummy; + OverwatchThread = CreateThread(NULL, 0x100000, Win32OverwatchThread, NULL, 0, &dummy); + ELOG("ExitLoopEventWait 1"); + ExitLoopEvent.Wait(); + } + HANDLE h[1]; + *h = ExitLoopEvent.GetHandle(); + ELOG("ExitLoopEventWait 2 " << (void *)*h); + MsgWaitForMultipleObjects(1, h, FALSE, ms, QS_ALLINPUT); +#else + MsgWaitForMultipleObjects(0, NULL, FALSE, ms, QS_ALLINPUT); +#endif + EnterGMutex(level);*/ +} + +Rect Ctrl::GetWndUpdateRect() const +{ + GuiLock __; + Rect r; + return r; +} + +Rect Ctrl::GetWndScreenRect() const +{ + GuiLock __; + Rect r; + return r; +} + +void Ctrl::WndShow0(bool b) +{ + GuiLock __; +} + +void Ctrl::WndUpdate0() +{ + GuiLock __; +} + +bool Ctrl::IsWndOpen() const { + GuiLock __; + return false; +} + +void Ctrl::SetAlpha(byte alpha) +{ + GuiLock __; +} + +Rect Ctrl::GetWorkArea() const +{ + GuiLock __; + return Rect(); +} + +void Ctrl::GetWorkArea(Array& rc) +{ + GuiLock __; +} + +Rect Ctrl::GetVirtualWorkArea() +{ + Rect out = GetPrimaryWorkArea(); + Array rc; + GetWorkArea(rc); + for(int i = 0; i < rc.GetCount(); i++) + out |= rc[i]; + return out; +} + +Rect Ctrl::GetWorkArea(Point pt) +{ + Array rc; + GetWorkArea(rc); + for(int i = 0; i < rc.GetCount(); i++) + if(rc[i].Contains(pt)) + return rc[i]; + return GetPrimaryWorkArea(); +} + +Rect Ctrl::GetVirtualScreenArea() +{ + GuiLock __; + return Rect(); +} + +Rect Ctrl::GetPrimaryWorkArea() +{ + Rect r; + return r; +} + +Rect Ctrl::GetPrimaryScreenArea() +{ + return Size(); +} + +int Ctrl::GetKbdDelay() +{ + GuiLock __; + return 500; +} + +int Ctrl::GetKbdSpeed() +{ + GuiLock __; + return 1000 / 32; +} + +void Ctrl::WndDestroy0() +{ +} + +void Ctrl::SetWndForeground0() +{ + GuiLock __; +} + +bool Ctrl::IsWndForeground() const +{ + GuiLock __; + return true; +} + +void Ctrl::WndEnable0(bool *b) +{ + GuiLock __; +} + +void Ctrl::SetWndFocus0(bool *b) +{ + GuiLock __; +} + +bool Ctrl::HasWndFocus() const +{ + GuiLock __; + return false; +} + +bool Ctrl::SetWndCapture() +{ + GuiLock __; + ASSERT(IsMainThread()); + return false; +} + +bool Ctrl::ReleaseWndCapture() +{ + GuiLock __; + ASSERT(IsMainThread()); + return false; +} + +bool Ctrl::HasWndCapture() const +{ + GuiLock __; + return false; +} + +void Ctrl::WndInvalidateRect0(const Rect& r) +{ + GuiLock __; +} + +void Ctrl::WndSetPos0(const Rect& rect) +{ + GuiLock __; +} + +void Ctrl::WndUpdate0r(const Rect& r) +{ + GuiLock __; + +} + +void Ctrl::WndScrollView0(const Rect& r, int dx, int dy) +{ + GuiLock __; +} + +void Ctrl::PopUp(Ctrl *owner, bool savebits, bool activate, bool dropshadow, bool topmost) +{ +} + +Rect Ctrl::GetDefaultWindowRect() { + return Rect(0, 0, 100, 100); +} + +ViewDraw::ViewDraw(Ctrl *ctrl) +{ + EnterGuiMutex(); +} + +ViewDraw::~ViewDraw() +{ + LeaveGuiMutex(); +} + +Vector SplitCmdLine__(const char *cmd) +{ + Vector out; + while(*cmd) + if((byte)*cmd <= ' ') + cmd++; + else if(*cmd == '\"') { + WString quoted; + while(*++cmd && (*cmd != '\"' || *++cmd == '\"')) + quoted.Cat(FromSystemCharset(String(cmd, 1)).ToWString()); + out.Add(quoted); + } + else { + const char *begin = cmd; + while((byte)*cmd > ' ') + cmd++; + out.Add(String(begin, cmd).ToWString()); + } + return out; +} + +END_UPP_NAMESPACE + +#endif diff --git a/rainbow/Framebuffer/init b/rainbow/Framebuffer/init new file mode 100644 index 000000000..c9a3a82a2 --- /dev/null +++ b/rainbow/Framebuffer/init @@ -0,0 +1,3 @@ +#ifndef _Skeleton_icpp_init_stub +#define _Skeleton_icpp_init_stub +#endif diff --git a/rainbow/Paint/Draw.cpp b/rainbow/Paint/Draw.cpp new file mode 100644 index 000000000..d63db5a4c --- /dev/null +++ b/rainbow/Paint/Draw.cpp @@ -0,0 +1,32 @@ +#include + +using namespace Upp; + +struct App : public TopWindow { + void Paint(Draw& w) + { + Size sz = GetSize(); + w.DrawRect(0, 0, sz.cx, sz.cy, SWhite); + w.DrawRect(10, 10, 30, 30, SRed); + w.DrawLine(45, 45, 80, 120, 4, Blue); + w.DrawLine(80, 90, 400, 0, PEN_DASHDOT); + w.DrawEllipse(200, 200, 50, 100, Green); + w.DrawImage(200, 10, CtrlImg::HandCursor()); + const char *text = "This text is centered"; + Size tsz = GetTextSize(text, Arial(25).Bold()); + w.DrawText((sz.cx - tsz.cx) / 2, (sz.cy - tsz.cy) / 2, text, Arial(27).Bold(), SBlue); + w.Clipoff(200, 50, 95, 100); + w.DrawText(0, 80, "CLIPPED", Roman(25)); + w.End(); + } + + App() + { + Sizeable(); + } +}; + +GUI_APP_MAIN +{ + App().Run(); +} diff --git a/rainbow/Paint/Paint.upp b/rainbow/Paint/Paint.upp new file mode 100644 index 000000000..8bb8821dc --- /dev/null +++ b/rainbow/Paint/Paint.upp @@ -0,0 +1,12 @@ +description "Paint method and Draw example\377"; + +uses + CtrlLib, + Framebuffer; + +file + Draw.cpp; + +mainconfig + "" = "GUI FB"; + diff --git a/rainbow/Paint/init b/rainbow/Paint/init new file mode 100644 index 000000000..7f24ec221 --- /dev/null +++ b/rainbow/Paint/init @@ -0,0 +1,5 @@ +#ifndef _Paint_icpp_init_stub +#define _Paint_icpp_init_stub +#include "CtrlLib/init" +#include "Framebuffer/init" +#endif diff --git a/rainbow/Skeleton/Skeleton.upp b/rainbow/Skeleton/Skeleton.upp index 460427f07..d6daa65da 100644 --- a/rainbow/Skeleton/Skeleton.upp +++ b/rainbow/Skeleton/Skeleton.upp @@ -1,3 +1,5 @@ +description "Skeleton rainbow code\377"; + file Skeleton.h, After.h, diff --git a/rainbow/guiplatform.h b/rainbow/guiplatform.h index f53e7b946..f9c58fbec 100644 --- a/rainbow/guiplatform.h +++ b/rainbow/guiplatform.h @@ -5,3 +5,7 @@ #ifdef flagWINALT #define GUIPLATFORM_INCLUDE #endif + +#ifdef flagFB +#define GUIPLATFORM_INCLUDE +#endif