diff --git a/uppsrc/CtrlCore/Coco.h b/uppsrc/CtrlCore/Coco.h new file mode 100644 index 000000000..7a25a8005 --- /dev/null +++ b/uppsrc/CtrlCore/Coco.h @@ -0,0 +1,133 @@ +#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 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, + 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); + +#ifndef PLATFORM_WIN32 +#include +#endif + +#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/uppsrc/CtrlCore/CocoAfter.h b/uppsrc/CtrlCore/CocoAfter.h new file mode 100644 index 000000000..4f36409d6 --- /dev/null +++ b/uppsrc/CtrlCore/CocoAfter.h @@ -0,0 +1,44 @@ +class ViewDraw : public SystemDraw { +public: + ViewDraw(Ctrl *ctrl); + ~ViewDraw(); +}; + +Vector& coreCmdLine__(); +Vector SplitCmdLine__(const char *cmd); + +#ifdef PLATFORM_WIN32 + +#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(); \ + return UPP::GetExitCode(); \ +} \ +\ +void GuiMainFn_() + +#endif + +#ifdef PLATFORM_POSIX +#define GUI_APP_MAIN \ +void GuiMainFn_(); \ +\ +int main(int argc, const char **argv, const char **envptr) { \ + UPP::AppInit__(argc, argv, envptr); \ + GuiMainFn_(); \ + UPP::Ctrl::CloseTopCtrls(); \ + UPP::AppExit__(); \ + return UPP::GetExitCode(); \ +} \ + \ +void GuiMainFn_() + +#endif + +class DHCtrl : Ctrl {}; diff --git a/uppsrc/CtrlCore/CocoChSysInit.cpp b/uppsrc/CtrlCore/CocoChSysInit.cpp new file mode 100644 index 000000000..4bfbe1898 --- /dev/null +++ b/uppsrc/CtrlCore/CocoChSysInit.cpp @@ -0,0 +1,16 @@ +#include + +#ifdef GUI_SKELETON + +NAMESPACE_UPP + +void ChSysInit() +{ + CtrlImg::Reset(); + CtrlsImg::Reset(); + ChReset(); +} + +END_UPP_NAMESPACE + +#endif diff --git a/uppsrc/CtrlCore/CocoClip.cpp b/uppsrc/CtrlCore/CocoClip.cpp new file mode 100644 index 000000000..8eb5c257e --- /dev/null +++ b/uppsrc/CtrlCore/CocoClip.cpp @@ -0,0 +1,241 @@ +#include +#include + +#ifdef GUI_SKELETON + +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/uppsrc/CtrlCore/CocoCtrl.cpp b/uppsrc/CtrlCore/CocoCtrl.cpp new file mode 100644 index 000000000..dcbe2470b --- /dev/null +++ b/uppsrc/CtrlCore/CocoCtrl.cpp @@ -0,0 +1,111 @@ +#include + +#ifdef GUI_SKELETON + +#define LLOG(x) // DLOG(x) + +NAMESPACE_UPP + +void ChHostSkin(void) +{ +} + +void WakeUpGuiThread(void) +{ +} + +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; +} + +void Ctrl::InstallPanicBox() +{ +} + +END_UPP_NAMESPACE + +#endif diff --git a/uppsrc/CtrlCore/CocoCtrl.h b/uppsrc/CtrlCore/CocoCtrl.h new file mode 100644 index 000000000..38d87eb7f --- /dev/null +++ b/uppsrc/CtrlCore/CocoCtrl.h @@ -0,0 +1,5 @@ +//$ class Ctrl { +public: + static void EndSession() {} + static bool IsEndSession() { return false; } +//$ }; diff --git a/uppsrc/CtrlCore/CocoDnD.cpp b/uppsrc/CtrlCore/CocoDnD.cpp new file mode 100644 index 000000000..85831d58e --- /dev/null +++ b/uppsrc/CtrlCore/CocoDnD.cpp @@ -0,0 +1,40 @@ +#include + +#ifdef GUI_SKELETON + +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) +{ +#ifdef PLATFORM_WIN32 + if(IsWin2K()) + return MakeDragImage(arrow, sample); + else +#endif + 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/uppsrc/CtrlCore/CocoDraw.cpp b/uppsrc/CtrlCore/CocoDraw.cpp new file mode 100644 index 000000000..14b487a5a --- /dev/null +++ b/uppsrc/CtrlCore/CocoDraw.cpp @@ -0,0 +1,62 @@ +#include + +#ifdef GUI_SKELETON + +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/uppsrc/CtrlCore/CocoDrawOp.cpp b/uppsrc/CtrlCore/CocoDrawOp.cpp new file mode 100644 index 000000000..dcd6a2d14 --- /dev/null +++ b/uppsrc/CtrlCore/CocoDrawOp.cpp @@ -0,0 +1,104 @@ +#include + +#ifdef GUI_SKELETON + +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::SysDrawImageOp(int x, int y, const Image& img, const Rect& src, 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/uppsrc/CtrlCore/CocoDrawText.cpp b/uppsrc/CtrlCore/CocoDrawText.cpp new file mode 100644 index 000000000..058400c05 --- /dev/null +++ b/uppsrc/CtrlCore/CocoDrawText.cpp @@ -0,0 +1,16 @@ +#include + +#ifdef GUI_SKELETON + +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/uppsrc/CtrlCore/CocoImage.cpp b/uppsrc/CtrlCore/CocoImage.cpp new file mode 100644 index 000000000..2bbf591ec --- /dev/null +++ b/uppsrc/CtrlCore/CocoImage.cpp @@ -0,0 +1,71 @@ +#include + +#ifdef GUI_SKELETON + +//#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 __; +} + +ImageDraw::operator Image() const +{ + return Image(); +} + +Image ImageDraw::GetStraight() const +{ + return Image(); +} + +Draw& ImageDraw::Alpha() +{ + if(!has_alpha) { + alpha.DrawRect(size, GrayColor(0)); + has_alpha = true; + } + return alpha; +} + +ImageDraw::ImageDraw(Size sz) +{ +} + +ImageDraw::ImageDraw(int cx, int cy) +{ +} + +ImageDraw::~ImageDraw() +{ +} + +Image Image::Arrow() { return Null; } +Image Image::Hand() { 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/uppsrc/CtrlCore/CocoKeys.h b/uppsrc/CtrlCore/CocoKeys.h new file mode 100644 index 000000000..d1fa2f84c --- /dev/null +++ b/uppsrc/CtrlCore/CocoKeys.h @@ -0,0 +1,121 @@ +K_BACK = 53000, +K_BACKSPACE, + +K_TAB, + +K_SPACE, + +K_RETURN, +K_ENTER, + +K_SHIFT_KEY, +K_CTRL_KEY, +K_ALT_KEY, +K_CAPSLOCK, +K_ESCAPE, +K_PRIOR, +K_PAGEUP, +K_NEXT, +K_PAGEDOWN, +K_END, +K_HOME, +K_LEFT, +K_UP, +K_RIGHT, +K_DOWN, +K_INSERT, +K_DELETE, + +K_NUMPAD0, +K_NUMPAD1, +K_NUMPAD2, +K_NUMPAD3, +K_NUMPAD4, +K_NUMPAD5, +K_NUMPAD6, +K_NUMPAD7, +K_NUMPAD8, +K_NUMPAD9, +K_MULTIPLY, +K_ADD, +K_SEPARATOR, +K_SUBTRACT, +K_DECIMAL, +K_DIVIDE, +K_SCROLL, + +K_F1, +K_F2, +K_F3, +K_F4, +K_F5, +K_F6, +K_F7, +K_F8, +K_F9, +K_F10, +K_F11, +K_F12, + +K_A, +K_B, +K_C, +K_D, +K_E, +K_F, +K_G, +K_H, +K_I, +K_J, +K_K, +K_L, +K_M, +K_N, +K_O, +K_P, +K_Q, +K_R, +K_S, +K_T, +K_U, +K_V, +K_W, +K_X, +K_Y, +K_Z, +K_0, +K_1, +K_2, +K_3, +K_4, +K_5, +K_6, +K_7, +K_8, +K_9, + +K_CTRL_LBRACKET, +K_CTRL_RBRACKET, +K_CTRL_MINUS, +K_CTRL_GRAVE, +K_CTRL_SLASH, +K_CTRL_BACKSLASH, +K_CTRL_COMMA, +K_CTRL_PERIOD, +K_CTRL_SEMICOLON, +K_CTRL_EQUAL, +K_CTRL_APOSTROPHE, + +K_BREAK, + +K_PLUS = 0, // not yet defined +K_MINUS = 0, // not yet defined +K_COMMA = 0, // not yet defined +K_PERIOD = 0, // not yet defined +K_SEMICOLON = 0, // not yet defined +K_SLASH = 0, // not yet defined +K_GRAVE = 0, // not yet defined +K_LBRACKET = 0, // not yet defined +K_BACKSLASH = 0, // not yet defined +K_RBRACKET = 0, // not yet defined +K_QUOTEDBL = 0, // not yet defined diff --git a/uppsrc/CtrlCore/CocoProc.cpp b/uppsrc/CtrlCore/CocoProc.cpp new file mode 100644 index 000000000..da4e3c8f4 --- /dev/null +++ b/uppsrc/CtrlCore/CocoProc.cpp @@ -0,0 +1,24 @@ +#include + +#ifdef GUI_SKELETON + +//#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/uppsrc/CtrlCore/CocoTop.cpp b/uppsrc/CtrlCore/CocoTop.cpp new file mode 100644 index 000000000..54d78799a --- /dev/null +++ b/uppsrc/CtrlCore/CocoTop.cpp @@ -0,0 +1,81 @@ +#include + +#ifdef GUI_SKELETON + +NAMESPACE_UPP + +#define LLOG(x) // LOG(x) + +void TopWindow::SyncSizeHints() {} + +void TopWindow::SyncTitle() +{ + GuiLock __; +} + +void TopWindow::SyncCaption() +{ + 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/uppsrc/CtrlCore/CocoTop.h b/uppsrc/CtrlCore/CocoTop.h new file mode 100644 index 000000000..34f716a90 --- /dev/null +++ b/uppsrc/CtrlCore/CocoTop.h @@ -0,0 +1,3 @@ +//$ class TopWindow { + +//$ }; \ No newline at end of file diff --git a/uppsrc/CtrlCore/CocoUtil.cpp b/uppsrc/CtrlCore/CocoUtil.cpp new file mode 100644 index 000000000..6e04c6b22 --- /dev/null +++ b/uppsrc/CtrlCore/CocoUtil.cpp @@ -0,0 +1,40 @@ +#include + +#ifdef GUI_SKELETON + +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(); +} +*/ + +static uint64 sGetAniPat(uint64 src, int pos) +{ + uint64 out = 0; + pos &= 7; + for(int i = 8; --i >= 0;) { + byte sr = (byte)(src >> (8 * ((7 - i - pos) & 7))); + out = (out << 8) | (byte)((sr | (sr << 8)) >> pos); + } + return out; +} + +void DrawDragRect(Ctrl& q, const Rect& rect1, const Rect& rect2, const Rect& clip, int n, + Color color, int type, int animation) +{ + ViewDraw w(&q); + uint64 pattern = type == DRAWDRAGRECT_DASHED ? I64(0xf0783c1e0f87c3e1) : + type == DRAWDRAGRECT_NORMAL ? I64(0x55aa55aa55aa55aa) : 0; + DrawDragRect(w, rect1, rect2, clip, n, color, sGetAniPat(pattern, animation)); +} + +END_UPP_NAMESPACE + +#endif diff --git a/uppsrc/CtrlCore/CocoWnd.cpp b/uppsrc/CtrlCore/CocoWnd.cpp new file mode 100644 index 000000000..5b304598c --- /dev/null +++ b/uppsrc/CtrlCore/CocoWnd.cpp @@ -0,0 +1,367 @@ +#include + +#ifdef GUI_SKELETON + +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, Function 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::EventLoop(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::GuiSleep(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::GetWndScreenRect() const +{ + GuiLock __; + Rect r; + return r; +} + +void Ctrl::WndShow(bool b) +{ + GuiLock __; +} + +void Ctrl::WndUpdate() +{ + 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::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::WndDestroy() +{ +} + +void Ctrl::SetWndForeground() +{ + GuiLock __; +} + +bool Ctrl::IsWndForeground() const +{ + GuiLock __; + return true; +} + +void Ctrl::WndEnable(bool) +{ + GuiLock __; +} + +bool Ctrl::SetWndFocus() +{ + GuiLock __; + return true; +} + +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::WndInvalidateRect(const Rect& r) +{ + GuiLock __; +} + +void Ctrl::WndSetPos(const Rect& rect) +{ + GuiLock __; +} + +void Ctrl::WndUpdate(const Rect& r) +{ + GuiLock __; + +} + +void Ctrl::WndScrollView(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; +} + +void Ctrl::SysEndLoop() +{ +} + +void FinishDragRect(Ctrl& q) +{ +} + +END_UPP_NAMESPACE + +#endif diff --git a/uppsrc/CtrlCore/CtrlCore.upp b/uppsrc/CtrlCore/CtrlCore.upp index e23dc1d41..3f0a088e4 100644 --- a/uppsrc/CtrlCore/CtrlCore.upp +++ b/uppsrc/CtrlCore/CtrlCore.upp @@ -121,6 +121,24 @@ file GtkClip.cpp, GtkDnD.cpp, GtkApp.cpp, + Cocoa readonly separator, + Coco.h, + CocoAfter.h, + CocoChSysInit.cpp, + CocoClip.cpp, + CocoCtrl.cpp, + CocoCtrl.h, + CocoDnD.cpp, + CocoDraw.cpp, + CocoDrawOp.cpp, + CocoDrawText.cpp, + CocoImage.cpp, + CocoKeys.h, + CocoProc.cpp, + CocoTop.cpp, + CocoTop.h, + CocoUtil.cpp, + CocoWnd.cpp, "RTF support" readonly separator, ParseRTF.cpp, EncodeRTF.cpp,