diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index 4c421f38e..efbb99b54 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -1213,6 +1213,8 @@ public: }; String GuiPlatformGetKeyDesc(dword key); +bool GuiPlatformHasSizeGrip(); +void GuiPlatformGripResize(TopWindow *q); Font FontZ(int face, int height = 0); diff --git a/uppsrc/CtrlCore/Win32Ctrl.cpp b/uppsrc/CtrlCore/Win32Ctrl.cpp index 448f4672b..ed30af026 100644 --- a/uppsrc/CtrlCore/Win32Ctrl.cpp +++ b/uppsrc/CtrlCore/Win32Ctrl.cpp @@ -1,130 +1,145 @@ -#include "CtrlCore.h" - -#ifdef GUI_WIN - -#define LLOG(x) // DLOG(x) - -NAMESPACE_UPP - -void Ctrl::GuiPlatformConstruct() -{ - activex = false; - isdhctrl = false; -} - -void Ctrl::GuiPlatformDestruct() -{ -} - -void Ctrl::GuiPlatformRemove() -{ -} - -void Ctrl::GuiPlatformGetTopRect(Rect& r) const -{ - if(activex) - r = GetWndScreenRect(); -} - -bool Ctrl::GuiPlatformRefreshFrameSpecial(const Rect& r) -{ - if(isdhctrl) { - InvalidateRect(((DHCtrl *)this)->GetHWND(), r, false); - return true; - } - return false; -} - -bool Ctrl::GuiPlatformSetFullRefreshSpecial() -{ - return isdhctrl; -} - -void Ctrl::PaintCaret(SystemDraw& w) -{ -} - -String GuiPlatformGetKeyDesc(dword key) -{ - static struct { - dword key; - const char *name; - } nkey[] = { - { 0x100c0, "[`]" }, { 0x100bd, "[-]" }, { 0x100bb, "[=]" }, { 0x100dc, "[\\]" }, - { 0x100db, "[[]" }, { 0x100dd, "[]]" }, - { 0x100ba, "[;]" }, { 0x100de, "[']" }, - { 0x100bc, "[,]" }, { 0x100be, "[.]" }, { 0x100bf, "[/]" }, - { 0, NULL } - }; - for(int i = 0; nkey[i].key; i++) - if(nkey[i].key == key) - return nkey[i].name; - return Null; -} - -void Ctrl::GuiPlatformSelection(PasteClip&) -{ -} - -void GuiPlatformAdjustDragImage(ImageBuffer&) -{ -} - -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 __; - Rect cr; - cr.Clear(); - if(focusCtrl && focusCtrl->IsVisible()) { - bool inframe = focusCtrl->InFrame(); - cr = focusCtrl->GetScreenView(); - cr = RectC(focusCtrl->caretx + cr.left, focusCtrl->carety + cr.top, - focusCtrl->caretcx, focusCtrl->caretcy) & cr; - for(Ctrl *q = focusCtrl->GetParent(); q; q = q->GetParent()) { - cr &= inframe ? q->GetScreenRect() : q->GetScreenView(); - inframe = q->InFrame(); - } - } - if(focusCtrl != caretCtrl || cr != caretRect) { - LLOG("Do SyncCaret focusCtrl: " << UPP::Name(focusCtrl) - << ", caretCtrl: " << UPP::Name(caretCtrl) - << ", cr: " << cr); - WndDestroyCaret(); - if(focusCtrl && !cr.IsEmpty()) - focusCtrl->GetTopCtrl()->WndCreateCaret(cr); - caretCtrl = focusCtrl; - caretRect = cr; - } -} - -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()) << ")"; - else - s << Format("(hwnd 0x%x)", (int)(intptr_t) GetHWND()); - return s; -} - -void Ctrl::WndCreateCaret(const Rect& cr) -{ - ICall(THISBACK1(WndCreateCaret0, cr)); -} - -END_UPP_NAMESPACE - -#endif +#include "CtrlCore.h" + +#ifdef GUI_WIN + +#define LLOG(x) // DLOG(x) + +NAMESPACE_UPP + +void Ctrl::GuiPlatformConstruct() +{ + activex = false; + isdhctrl = false; +} + +void Ctrl::GuiPlatformDestruct() +{ +} + +void Ctrl::GuiPlatformRemove() +{ +} + +void Ctrl::GuiPlatformGetTopRect(Rect& r) const +{ + if(activex) + r = GetWndScreenRect(); +} + +bool Ctrl::GuiPlatformRefreshFrameSpecial(const Rect& r) +{ + if(isdhctrl) { + InvalidateRect(((DHCtrl *)this)->GetHWND(), r, false); + return true; + } + return false; +} + +bool Ctrl::GuiPlatformSetFullRefreshSpecial() +{ + return isdhctrl; +} + +void Ctrl::PaintCaret(SystemDraw& w) +{ +} + +String GuiPlatformGetKeyDesc(dword key) +{ + static struct { + dword key; + const char *name; + } nkey[] = { + { 0x100c0, "[`]" }, { 0x100bd, "[-]" }, { 0x100bb, "[=]" }, { 0x100dc, "[\\]" }, + { 0x100db, "[[]" }, { 0x100dd, "[]]" }, + { 0x100ba, "[;]" }, { 0x100de, "[']" }, + { 0x100bc, "[,]" }, { 0x100be, "[.]" }, { 0x100bf, "[/]" }, + { 0, NULL } + }; + for(int i = 0; nkey[i].key; i++) + if(nkey[i].key == key) + return nkey[i].name; + return Null; +} + +void Ctrl::GuiPlatformSelection(PasteClip&) +{ +} + +void GuiPlatformAdjustDragImage(ImageBuffer&) +{ +} + +bool GuiPlatformHasSizeGrip() +{ + return true; +} + +void GuiPlatformGripResize(TopWindow *q) +{ + HWND hwnd = q->GetHWND(); + Point p = GetMousePos() - q->GetRect().TopLeft(); + if(hwnd) { + ::SendMessage(hwnd, WM_SYSCOMMAND, 0xf008, MAKELONG(p.x, p.y)); + ::SendMessage(hwnd, WM_LBUTTONUP, 0, MAKELONG(p.x, p.y)); + } +} + +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 __; + Rect cr; + cr.Clear(); + if(focusCtrl && focusCtrl->IsVisible()) { + bool inframe = focusCtrl->InFrame(); + cr = focusCtrl->GetScreenView(); + cr = RectC(focusCtrl->caretx + cr.left, focusCtrl->carety + cr.top, + focusCtrl->caretcx, focusCtrl->caretcy) & cr; + for(Ctrl *q = focusCtrl->GetParent(); q; q = q->GetParent()) { + cr &= inframe ? q->GetScreenRect() : q->GetScreenView(); + inframe = q->InFrame(); + } + } + if(focusCtrl != caretCtrl || cr != caretRect) { + LLOG("Do SyncCaret focusCtrl: " << UPP::Name(focusCtrl) + << ", caretCtrl: " << UPP::Name(caretCtrl) + << ", cr: " << cr); + WndDestroyCaret(); + if(focusCtrl && !cr.IsEmpty()) + focusCtrl->GetTopCtrl()->WndCreateCaret(cr); + caretCtrl = focusCtrl; + caretRect = cr; + } +} + +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()) << ")"; + else + s << Format("(hwnd 0x%x)", (int)(intptr_t) GetHWND()); + return s; +} + +void Ctrl::WndCreateCaret(const Rect& cr) +{ + ICall(THISBACK1(WndCreateCaret0, cr)); +} + +END_UPP_NAMESPACE + +#endif diff --git a/uppsrc/CtrlCore/X11Ctrl.cpp b/uppsrc/CtrlCore/X11Ctrl.cpp index 53ec66b54..1eff99ee0 100644 --- a/uppsrc/CtrlCore/X11Ctrl.cpp +++ b/uppsrc/CtrlCore/X11Ctrl.cpp @@ -1,116 +1,143 @@ -#include "CtrlCore.h" - -#ifdef GUI_X11 - -NAMESPACE_UPP - -void Ctrl::GuiPlatformConstruct() -{ -} - -void Ctrl::GuiPlatformDestruct() -{ -} - -void Ctrl::GuiPlatformRemove() -{ - if(popupgrab) { - EndPopupGrab(); - popupgrab = false; - } -} - -void Ctrl::GuiPlatformGetTopRect(Rect& r) const -{ -} - -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()) << ")"; - else - s << Format("(window 0x%x)", (int)(intptr_t) GetWindow()); - return s; -} - -bool Ctrl::GuiPlatformRefreshFrameSpecial(const Rect&) -{ - return false; -} - - -bool Ctrl::GuiPlatformSetFullRefreshSpecial() -{ - return false; -} - -String GuiPlatformGetKeyDesc(dword key) -{ - static struct { - dword key; - const char *name; - } nkey[] = { - { 0x10060, "[`]" }, { 0x1002d, "[-]" }, { 0x1003d, "[=]" }, { 0x1005c, "[\\]" }, - { 0x1005b, "[[]" }, { 0x1005d, "[]]" }, - { 0x1003b, "[;]" }, { 0x10027, "[']" }, - { 0x1002c, "[,]" }, { 0x1002e, "[.]" }, { 0x1005f, "[/]" }, - { 0, NULL } - }; - for(int i = 0; nkey[i].key; i++) - if(nkey[i].key == key) - return nkey[i].name; - return Null; -} - -void Ctrl::GuiPlatformSelection(PasteClip& d) -{ - d.fmt.Clear(); - d.type = 2; -} - -void GuiPlatformAdjustDragImage(ImageBuffer& b) -{ - if(Ctrl::IsCompositedGui()) { - Image h = Rescale(b, 64, 64); - b = h; - } -} - -void Ctrl::PaintCaret(SystemDraw& w) -{ - GuiLock __; - if(this == caretCtrl && WndCaretVisible) - w.DrawRect(caretx, carety, caretcx, caretcy, InvertColor); -} - -void Ctrl::SetCaret(int x, int y, int cx, int cy) -{ - GuiLock __; - if(this == caretCtrl) - RefreshCaret(); - caretx = x; - carety = y; - caretcx = cx; - caretcy = cy; - WndCaretTime = GetTickCount(); - if(this == caretCtrl) - RefreshCaret(); -} - -void Ctrl::SyncCaret() { - GuiLock __; - if(focusCtrl != caretCtrl) { - RefreshCaret(); - caretCtrl = focusCtrl; - RefreshCaret(); - } -} - -END_UPP_NAMESPACE - +#include "CtrlCore.h" + +#ifdef GUI_X11 + +NAMESPACE_UPP + +void Ctrl::GuiPlatformConstruct() +{ +} + +void Ctrl::GuiPlatformDestruct() +{ +} + +void Ctrl::GuiPlatformRemove() +{ + if(popupgrab) { + EndPopupGrab(); + popupgrab = false; + } +} + +void Ctrl::GuiPlatformGetTopRect(Rect& r) const +{ +} + +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()) << ")"; + else + s << Format("(window 0x%x)", (int)(intptr_t) GetWindow()); + return s; +} + +bool Ctrl::GuiPlatformRefreshFrameSpecial(const Rect&) +{ + return false; +} + + +bool Ctrl::GuiPlatformSetFullRefreshSpecial() +{ + return false; +} + +String GuiPlatformGetKeyDesc(dword key) +{ + static struct { + dword key; + const char *name; + } nkey[] = { + { 0x10060, "[`]" }, { 0x1002d, "[-]" }, { 0x1003d, "[=]" }, { 0x1005c, "[\\]" }, + { 0x1005b, "[[]" }, { 0x1005d, "[]]" }, + { 0x1003b, "[;]" }, { 0x10027, "[']" }, + { 0x1002c, "[,]" }, { 0x1002e, "[.]" }, { 0x1005f, "[/]" }, + { 0, NULL } + }; + for(int i = 0; nkey[i].key; i++) + if(nkey[i].key == key) + return nkey[i].name; + return Null; +} + +void Ctrl::GuiPlatformSelection(PasteClip& d) +{ + d.fmt.Clear(); + d.type = 2; +} + +void GuiPlatformAdjustDragImage(ImageBuffer& b) +{ + if(Ctrl::IsCompositedGui()) { + Image h = Rescale(b, 64, 64); + b = h; + } +} + +bool GuiPlatformHasSizeGrip() +{ + return _NET_Supported().Find(XAtom("_NET_WM_MOVERESIZE")) >= 0; +} + +void GuiPlatformGripResize(TopWindow *q) +{ + if(_NET_Supported().Find(XAtom("_NET_WM_MOVERESIZE")) >= 0) { + XUngrabPointer(Xdisplay, CurrentTime); // 2008-02-25 cxl/mdelfe... compiz fix... who has grabbed it anyway?... + XClientMessageEvent m; + m.type = ClientMessage; + m.serial = 0; + m.send_event = XTrue; + m.window = q->GetWindow(); + m.message_type = XAtom("_NET_WM_MOVERESIZE"); + m.format = 32; + p = GetMousePos(); + m.data.l[0] = p.x; + m.data.l[1] = p.y; + m.data.l[2] = 4; + m.data.l[3] = 0; + m.data.l[4] = 0; + XSendEvent(Xdisplay, Xroot, 0, SubstructureNotifyMask|SubstructureRedirectMask, + (XEvent*)&m); + } +} + +void Ctrl::PaintCaret(SystemDraw& w) +{ + GuiLock __; + if(this == caretCtrl && WndCaretVisible) + w.DrawRect(caretx, carety, caretcx, caretcy, InvertColor); +} + +void Ctrl::SetCaret(int x, int y, int cx, int cy) +{ + GuiLock __; + if(this == caretCtrl) + RefreshCaret(); + caretx = x; + carety = y; + caretcx = cx; + caretcy = cy; + WndCaretTime = GetTickCount(); + if(this == caretCtrl) + RefreshCaret(); +} + +void Ctrl::SyncCaret() { + GuiLock __; + if(focusCtrl != caretCtrl) { + RefreshCaret(); + caretCtrl = focusCtrl; + RefreshCaret(); + } +} + +END_UPP_NAMESPACE + #endif \ No newline at end of file diff --git a/uppsrc/CtrlLib/ScrollBar.cpp b/uppsrc/CtrlLib/ScrollBar.cpp index 3085dd2da..1bd0914c8 100644 --- a/uppsrc/CtrlLib/ScrollBar.cpp +++ b/uppsrc/CtrlLib/ScrollBar.cpp @@ -575,15 +575,11 @@ ScrollBar& ScrollBar::SetStyle(const Style& s) Image SizeGrip::CursorImage(Point p, dword) { -#ifdef PLATFORM_X11 - if(_NET_Supported().Find(XAtom("_NET_WM_MOVERESIZE")) >= 0) { -#endif + if(GuiPlatformHasSizeGrip()) { TopWindow *q = dynamic_cast(GetTopCtrl()); if(q && !q->IsMaximized() && q->IsSizeable()) return Image::SizeBottomRight(); -#ifdef PLATFORM_X11 } -#endif return Image::Arrow(); } @@ -591,21 +587,16 @@ CH_IMAGE(SizeGripImg, CtrlsImg::SizeGrip()); void SizeGrip::Paint(Draw& w) { - Size sz = GetSize(); - if(!IsTransparent()) - w.DrawRect(sz, SColorFace); -#ifdef PLATFORM_X11 - if(_NET_Supported().Find(XAtom("_NET_WM_MOVERESIZE")) >= 0) - { -#endif + Size sz = GetSize(); + if(!IsTransparent()) + w.DrawRect(sz, SColorFace); + if(GuiPlatformHasSizeGrip()) { TopWindow *q = dynamic_cast(GetTopCtrl()); if(q && !q->IsMaximized() && q->IsSizeable()) { Size isz = CtrlsImg::SizeGrip().GetSize(); w.DrawImage(sz.cx - isz.cx, sz.cy - isz.cy, CtrlsImg::SizeGrip()); } -#ifdef PLATFORM_X11 } -#endif } SizeGrip::SizeGrip() @@ -621,35 +612,8 @@ SizeGrip::~SizeGrip() {} void SizeGrip::LeftDown(Point p, dword flags) { TopWindow *q = dynamic_cast(GetTopCtrl()); - if(!q || q->IsMaximized() || !q->IsSizeable()) return; -#ifdef PLATFORM_WIN32 - HWND hwnd = q->GetHWND(); - p = GetMousePos() - q->GetRect().TopLeft(); - if(hwnd) { - ::SendMessage(hwnd, WM_SYSCOMMAND, 0xf008, MAKELONG(p.x, p.y)); - ::SendMessage(hwnd, WM_LBUTTONUP, 0, MAKELONG(p.x, p.y)); - } -#endif -#ifdef PLATFORM_X11 - if(_NET_Supported().Find(XAtom("_NET_WM_MOVERESIZE")) >= 0) { - XUngrabPointer(Xdisplay, CurrentTime); // 2008-02-25 cxl/mdelfe... compiz fix... who has grabbed it anyway?... - XClientMessageEvent m; - m.type = ClientMessage; - m.serial = 0; - m.send_event = XTrue; - m.window = q->GetWindow(); - m.message_type = XAtom("_NET_WM_MOVERESIZE"); - m.format = 32; - p = GetMousePos(); - m.data.l[0] = p.x; - m.data.l[1] = p.y; - m.data.l[2] = 4; - m.data.l[3] = 0; - m.data.l[4] = 0; - XSendEvent(Xdisplay, Xroot, 0, SubstructureNotifyMask|SubstructureRedirectMask, - (XEvent*)&m); - } -#endif + if(q && !q->IsMaximized() && q->IsSizeable()) + GuiPlatformGripResize(q); } void ScrollBars::Scroll() { diff --git a/uppsrc/CtrlLib/Text.cpp b/uppsrc/CtrlLib/Text.cpp index f7a332783..735254ae5 100644 --- a/uppsrc/CtrlLib/Text.cpp +++ b/uppsrc/CtrlLib/Text.cpp @@ -650,11 +650,7 @@ void TextCtrl::StdBar(Bar& menu) { t_("Copy"), CtrlImg::copy(), THISBACK(Copy)) .Key(K_CTRL_INSERT) .Key(K_CTRL_C); - menu.Add(IsEditable() - #ifdef PLATFORM_WIN32 - && ::IsClipboardFormatAvailable(CF_TEXT) - #endif - , + menu.Add(IsEditable() && IsClipboardAvailableText(), t_("Paste"), CtrlImg::paste(), THISBACK(DoPaste)) .Key(K_SHIFT_INSERT) .Key(K_CTRL_V); diff --git a/uppsrc/CtrlLib/Update.cpp b/uppsrc/CtrlLib/Update.cpp index 51398459d..170e42ec4 100644 --- a/uppsrc/CtrlLib/Update.cpp +++ b/uppsrc/CtrlLib/Update.cpp @@ -2,7 +2,7 @@ NAMESPACE_UPP -#ifdef PLATFORM_WIN32 +#ifdef GUI_WIN #ifndef PLATFORM_WINCE #define LLOG(x) diff --git a/uppsrc/CtrlLib/Win32.cpp b/uppsrc/CtrlLib/Win32.cpp index ecd1bae73..190500ffa 100644 --- a/uppsrc/CtrlLib/Win32.cpp +++ b/uppsrc/CtrlLib/Win32.cpp @@ -1,6 +1,6 @@ #include "CtrlLib.h" -#ifdef PLATFORM_WIN32 +#ifdef GUI_WIN #ifndef PLATFORM_WINCE #include @@ -12,7 +12,7 @@ NAMESPACE_UPP -#ifdef PLATFORM_WIN32 +#ifdef GUI_WIN #ifndef PLATFORM_WINCE