diff --git a/uppsrc/CtrlCore/Coco.h b/uppsrc/CtrlCore/Coco.h index 2a617ac16..18ba69726 100644 --- a/uppsrc/CtrlCore/Coco.h +++ b/uppsrc/CtrlCore/Coco.h @@ -45,6 +45,7 @@ private: void *handle; + RectCG MakeRectCG(const Rect& r); void ClipCG(const Rect& r); void FlipY(int& y) { y = top - y; } Rect GetClip() const { return clip.GetCount() ? clip.Top() : Rect(-999999, -999999, 999999, 999999); } diff --git a/uppsrc/CtrlCore/CocoApp.mm b/uppsrc/CtrlCore/CocoApp.mm index 8f1808580..7b045385e 100644 --- a/uppsrc/CtrlCore/CocoApp.mm +++ b/uppsrc/CtrlCore/CocoApp.mm @@ -2,7 +2,7 @@ #ifdef PLATFORM_COCOA -#define LLOG(x) DLOG(x) +#define LLOG(x) // DLOG(x) int Upp::Ctrl::WndCaretTime; bool Upp::Ctrl::WndCaretVisible; @@ -51,10 +51,6 @@ void Upp::CocoInit(int argc, const char **argv, const char **envptr) Font::SetDefaultFont(Arial(12)); // TODO: Read from NSFont! NSFont *sysfont = [NSFont systemFontOfSize:0]; - DDUMP(Upp::ToString((CFStringRef)[sysfont familyName])); - DDUMP(Upp::ToString((CFStringRef)[sysfont displayName])); - DDUMP(Upp::ToString((CFStringRef)[sysfont fontName])); - DDUMP([sysfont pointSize]); Font::SetFace(0, Upp::ToString((CFStringRef)[sysfont familyName]), Font::TTF); Font::SetDefaultFont(StdFont(fround([sysfont pointSize]))); // TODO: Read from NSFont! } diff --git a/uppsrc/CtrlCore/CocoCreate.mm b/uppsrc/CtrlCore/CocoCreate.mm index 431319856..ddc557a24 100644 --- a/uppsrc/CtrlCore/CocoCreate.mm +++ b/uppsrc/CtrlCore/CocoCreate.mm @@ -48,9 +48,10 @@ void Upp::Ctrl::Create(dword style) void Upp::Ctrl::WndDestroy() { + DLOG("WndDestroy " << this); if(!top) return; - [top->coco->window release]; + [top->coco->window close]; delete top->coco; delete top; top = NULL; diff --git a/uppsrc/CtrlCore/CocoDraw.mm b/uppsrc/CtrlCore/CocoDraw.mm index 209de3768..8a7340986 100644 --- a/uppsrc/CtrlCore/CocoDraw.mm +++ b/uppsrc/CtrlCore/CocoDraw.mm @@ -98,11 +98,16 @@ RectCG SystemDraw::Convert(const Rect& r) return Convert(r.left, r.top, r.GetWidth(), r.GetHeight()); } +RectCG SystemDraw::MakeRectCG(const Rect& r) +{ + Size sz = r.GetSize(); + return RectCG(r.left, top - r.top - sz.cy, sz.cx, sz.cy); +} void SystemDraw::ClipCG(const Rect& r) { - Size sz = r.GetSize(); - CGContextClipToRect(cgHandle, CGRectMake(r.left, top - r.top - sz.cy, sz.cx, sz.cy)); + DLOG("ClipCG " << r); + CGContextClipToRect(cgHandle, MakeRectCG(r)); } bool SystemDraw::ClipOp(const Rect& r) @@ -122,9 +127,15 @@ bool SystemDraw::ClipoffOp(const Rect& r) return true; } -bool SystemDraw::ExcludeClipOp(const Rect& r) +bool SystemDraw::ExcludeClipOp(const Rect& r_) { - // TODO, perhaps use CGContextClipToRects + CGRect cgr[4]; + Rect r = r_.Offseted(GetOffset()); + cgr[0] = MakeRectCG(Rect(0, 0, 9999, r.top)); + cgr[1] = MakeRectCG(Rect(0, r.bottom, 9999, 9999)); + cgr[2] = MakeRectCG(Rect(0, 0, r.left, 9999)); + cgr[3] = MakeRectCG(Rect(r.right, 0, 9999, 9999)); + CGContextClipToRects(cgHandle, cgr, 4); return true; } @@ -149,6 +160,8 @@ Rect SystemDraw::GetPaintRect() const void SystemDraw::DrawRectOp(int x, int y, int cx, int cy, Color color) { + if(IsNull(color)) + return; CGRect cgr = Convert(x, y, cx, cy); if(color == InvertColor()) { Set(White()); diff --git a/uppsrc/CtrlCore/CocoDrawText.mm b/uppsrc/CtrlCore/CocoDrawText.mm index 0766b8e15..294b111e8 100644 --- a/uppsrc/CtrlCore/CocoDrawText.mm +++ b/uppsrc/CtrlCore/CocoDrawText.mm @@ -132,7 +132,7 @@ void RenderCharacterSys(FontGlyphConsumer& sw, double x, double y, int ch, Font void SystemDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink, int n, const int *dx) { - DLOG("angle " << angle << ", text " << text << ", ink " << ink); +// DLOG("angle " << angle << ", text " << text << ", ink " << ink); Set(ink); // needs to be here because rotation saves context... if(angle) { // TODO: Fix this! diff --git a/uppsrc/CtrlCore/CocoKeys.h b/uppsrc/CtrlCore/CocoKeys.h index 34f64bdb8..6978c23fc 100644 --- a/uppsrc/CtrlCore/CocoKeys.h +++ b/uppsrc/CtrlCore/CocoKeys.h @@ -24,7 +24,7 @@ K_LEFT = kVK_LeftArrow|K_DELTA, K_UP = kVK_UpArrow|K_DELTA, K_RIGHT = kVK_RightArrow|K_DELTA, K_DOWN = kVK_DownArrow|K_DELTA, -K_INSERT = 999999999, // kVK_Insert|K_DELTA, // TODO +K_INSERT = kVK_Help|K_DELTA, // Code is this for external keyboard.. K_DELETE = kVK_ForwardDelete|K_DELTA, K_NUMPAD0 = kVK_ANSI_Keypad0|K_DELTA, @@ -106,11 +106,11 @@ K_CTRL_COMMA = kVK_ANSI_Comma|K_DELTA|K_CTRL, K_CTRL_PERIOD = kVK_ANSI_Period|K_DELTA|K_CTRL, K_CTRL_SEMICOLON = kVK_ANSI_Semicolon|K_DELTA|K_CTRL, K_CTRL_EQUAL = kVK_ANSI_Equal|K_DELTA|K_CTRL, -K_CTRL_APOSTROPHE, +K_CTRL_APOSTROPHE, // TODO -K_BREAK, +K_BREAK, // TODO -K_PLUS = 999999999, +K_PLUS = 999999997, K_MINUS = kVK_ANSI_Minus|K_DELTA, K_COMMA = kVK_ANSI_Comma|K_DELTA, K_PERIOD = kVK_ANSI_Period|K_DELTA, @@ -120,4 +120,4 @@ K_GRAVE = kVK_ANSI_Grave|K_DELTA, K_LBRACKET = kVK_ANSI_LeftBracket|K_DELTA, K_BACKSLASH = kVK_ANSI_Backslash|K_DELTA, K_RBRACKET = kVK_ANSI_RightBracket|K_DELTA, -K_QUOTEDBL = 999999999, +K_QUOTEDBL = 999999996, diff --git a/uppsrc/CtrlCore/CtrlCore.upp b/uppsrc/CtrlCore/CtrlCore.upp index 3c227d044..dda1f3623 100644 --- a/uppsrc/CtrlCore/CtrlCore.upp +++ b/uppsrc/CtrlCore/CtrlCore.upp @@ -33,8 +33,6 @@ library(POSIX !NOGTK !RAINBOW GUI !OSX11) notify; library(DRAGONFLY) "Xext Xinerama"; -link(MACOSX) " -framework Foundation -framework Cocoa"; - file Core readonly separator, CtrlCore.h options(BUILDER_OPTION) PCH, diff --git a/uppsrc/CtrlCore/CtrlDraw.cpp b/uppsrc/CtrlCore/CtrlDraw.cpp index 054a2d961..7c0997c25 100644 --- a/uppsrc/CtrlCore/CtrlDraw.cpp +++ b/uppsrc/CtrlCore/CtrlDraw.cpp @@ -2,7 +2,7 @@ namespace Upp { -#define LLOG(x) // DLOG(x) +#define LLOG(x) DLOG(x) #define LTIMING(x) // TIMING(x) bool Ctrl::globalbackpaint; @@ -351,8 +351,12 @@ void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) { LTIMING("CtrlPaint"); Rect rect = GetRect().GetSize(); Rect orect = rect.Inflated(overpaint); + DDUMP(Name()); + DDUMP(orect); + DDUMP(clip); if(!IsShown() || orect.IsEmpty() || clip.IsEmpty() || !clip.Intersects(orect)) return; + DLOG("2"); Ctrl *q; Rect view = rect; for(int i = 0; i < frame.GetCount(); i++) { @@ -592,7 +596,7 @@ void Ctrl::UpdateArea0(SystemDraw& draw, const Rect& clip, int backpaint) { GuiLock __; LTIMING("UpdateArea"); - LLOG("========== UPDATE AREA " << UPP::Name(this) << " =========="); + LLOG("========== UPDATE AREA " << UPP::Name(this) << " " << clip << " =========="); ExcludeDHCtrls(draw, GetRect().GetSize(), clip); if(globalbackbuffer) { CtrlPaint(draw, clip); diff --git a/uppsrc/CtrlCore/cocotodo.txt b/uppsrc/CtrlCore/cocotodo.txt index d08e0906b..c473e217b 100644 --- a/uppsrc/CtrlCore/cocotodo.txt +++ b/uppsrc/CtrlCore/cocotodo.txt @@ -1,12 +1,12 @@ sooner: - minimize, maximaze - Open/OpenMain variants -- LabelBox is wrong +- closing it - initial focus - SerializePlacement +- Switch does not seem to work for some reason later: -DrawDragRect - fullscreen - missing cursors (add to iml, use undocumented cursor) - X11 on option @@ -16,7 +16,6 @@ DrawDragRect - CommonFontInfo GetFontInfoSys(Font font) metrics - ROTATED TEXT - GetGlyphInfoSys metrics -- Default gui font (also in GetAllFacesSys) - EndSession ? - Image::Arrow etc... - ignoreclick @@ -46,3 +45,5 @@ done: - implement standard cursors - backspace and delete not working - Enter Up +- LabelBox is wrong +- Default gui font (also in GetAllFacesSys)