diff --git a/reference/DockingExample1/main.cpp b/reference/DockingExample1/main.cpp index 3337a3b1c..bb8d5c8a4 100644 --- a/reference/DockingExample1/main.cpp +++ b/reference/DockingExample1/main.cpp @@ -36,7 +36,7 @@ DockingExample::DockingExample() // This a button so that we can open the Dock Manager Add(button.SetLabel("Manager").LeftPosZ(4, 100).TopPosZ(4, 23)); - button <<= THISBACK(DockManager); + button << [=] { DockManager(); }; // Now we just put some bogus data in our controls FillArray(arrayctrl1); diff --git a/reference/DockingExample2/docklayout.dat b/reference/DockingExample2/docklayout.dat index bf14be5df..3857a50df 100644 Binary files a/reference/DockingExample2/docklayout.dat and b/reference/DockingExample2/docklayout.dat differ diff --git a/reference/DockingExample2/main.cpp b/reference/DockingExample2/main.cpp index 66c1eb0eb..373406fdf 100644 --- a/reference/DockingExample2/main.cpp +++ b/reference/DockingExample2/main.cpp @@ -71,15 +71,15 @@ DockingExample::DockingExample() // Add our MenuBar using the standard Docking menu AddFrame(menu); // menu must be added before Set or it thinks it's a context menu - menu.Set(THISBACK(MainMenu)); + menu.Set(THISFN(MainMenu)); // Set Option callbacks. The option ctrls will permit/deny docking in different directions // for optionswindow only. The (int) is for the benefit of GCC // You can also do this for the whole window (see DockWindow::AllowDockLeft() etc) - optionswindow.dockleft <<= THISBACK2(OnDockAllow, (int)DOCK_LEFT, &optionswindow.dockleft); - optionswindow.docktop <<= THISBACK2(OnDockAllow, (int)DOCK_TOP, &optionswindow.docktop); - optionswindow.dockright <<= THISBACK2(OnDockAllow, (int)DOCK_RIGHT, &optionswindow.dockright); - optionswindow.dockbottom <<= THISBACK2(OnDockAllow, (int)DOCK_BOTTOM, &optionswindow.dockbottom); + optionswindow.dockleft << [=] { OnDockAllow((int)DOCK_LEFT, &optionswindow.dockleft); }; + optionswindow.docktop << [=] { OnDockAllow((int)DOCK_TOP, &optionswindow.docktop); }; + optionswindow.dockright << [=] { OnDockAllow((int)DOCK_RIGHT, &optionswindow.dockright); }; + optionswindow.dockbottom << [=] { OnDockAllow((int)DOCK_BOTTOM, &optionswindow.dockbottom); }; // Now we put some bogus data in our controls FillArray(arrayctrl1); @@ -88,7 +88,7 @@ DockingExample::DockingExample() FillTree(treectrl2); // And add the User-Guide button Add(button.SetLabel("User Guide").LeftPosZ(4, 100).TopPosZ(4, 23)); - button <<= THISBACK(OnUserGuide); + button << [=] { OnUserGuide(); }; } void DockingExample::DockInit() @@ -136,7 +136,7 @@ void DockingExample::MainMenu(Bar &bar) { // Add a Windows menu. // We're using a the standard DockWindow menu, though you can also roll your own. - bar.Add("Windows", Image(), THISBACK(DockWindowMenu)); + bar.Sub("Windows", Image(), [=](Bar& bar) { DockWindowMenu(bar); }); } void DockingExample::OnDockAllow(int align, Option *ctrl) diff --git a/reference/DropGridExample/main.cpp b/reference/DropGridExample/main.cpp index e80910876..bf1fadd61 100644 --- a/reference/DropGridExample/main.cpp +++ b/reference/DropGridExample/main.cpp @@ -4,20 +4,15 @@ using namespace Upp; struct App : public TopWindow { DropGrid drop; - - void Person() { PromptOK("Person!"); } - void Client() { PromptOK("Client!"); } - void Select() { PromptOK("Select!"); } - void List() { PromptOK(AsString(drop.GetKey())); } App() { Sizeable().Zoomable(); - SetRect(Size(600, 100)); + SetRect(Size(Zx(600), Zy(100))); Title("DropGrid"); drop.ClearButton(); - drop.AddPlus(THISBACK(Action)); + drop.AddPlus([=] { PromptOK("Action!"); }); Add(drop.LeftPosZ(20, 350).TopPosZ(20, 19)); @@ -25,9 +20,9 @@ struct App : public TopWindow { drop.AddColumn("Value"); drop.AddColumn("Description"); - drop.AddText("Add person", THISBACK(Person)); - drop.AddText("Add client", THISBACK(Client)).Left().SetImage(GridImg::Append()); - drop.AddSelect(THISBACK(Select)).Left(); + drop.AddText("Add person", [=] { PromptOK("Person!"); }); + drop.AddText("Add client", [=] { PromptOK("Client!"); }).Left().SetImage(GridImg::Append()); + drop.AddSelect([=] { PromptOK("Select!"); }).Left(); for(int i = 0; i < 20; i++) drop.Add(i, Format("Hello %d", i), Format("How are you mr Hello %d", i)); @@ -38,7 +33,7 @@ struct App : public TopWindow { drop.SetDropLines(15); drop.SetValueColumn(1); drop.AddValueColumn(0).AddValueColumn(1); - drop <<= THISBACK(List); + drop << [=] { PromptOK(AsString(drop.GetKey())); }; } typedef App CLASSNAME; diff --git a/reference/Framebuffer/After.h b/reference/Framebuffer/After.h deleted file mode 100644 index 11cd4fcc4..000000000 --- a/reference/Framebuffer/After.h +++ /dev/null @@ -1,17 +0,0 @@ -class ViewDraw : public SystemDraw { -public: - ViewDraw(Ctrl *ctrl); - ~ViewDraw(); -}; - - -/* -class ViewDraw : public SystemDraw { - Vector dummy; -public: - ViewDraw(Ctrl *) : SystemDraw(Ctrl::framebuffer, dummy) { dummy.Add(Rect(10, 10, 100, 100)); } -}; -*/ -class DHCtrl : Ctrl {}; - -#include FRAMEBUFFER_INCLUDE diff --git a/reference/Framebuffer/ChSysInit.cpp b/reference/Framebuffer/ChSysInit.cpp deleted file mode 100644 index e27a7685d..000000000 --- a/reference/Framebuffer/ChSysInit.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include - -#ifdef GUI_FB - -NAMESPACE_UPP - -void ChSysInit() -{ - CtrlImg::Reset(); - CtrlsImg::Reset(); - ChReset(); -} - -void ChHostSkin() -{ - ChSysInit(); -} - -END_UPP_NAMESPACE - -#endif diff --git a/reference/Framebuffer/Clip.cpp b/reference/Framebuffer/Clip.cpp deleted file mode 100644 index c588b5c64..000000000 --- a/reference/Framebuffer/Clip.cpp +++ /dev/null @@ -1,238 +0,0 @@ -#include "Fb.h" - -#ifdef GUI_FB - -NAMESPACE_UPP - -#define LLOG(x) // LOG(x) - -static VectorMap fbClipboard; - -void ClearClipboard() -{ - GuiLock __; - fbClipboard.Clear(); -} - -void AppendClipboard(const char *format, const Value& data, String (*render)(const Value&)) -{ - GuiLock __; - ClipData& cd = fbClipboard.GetAdd(format); - cd.data = data; - cd.render = render; -} - -static String sRawRender(const Value& v) -{ - return v; -} - -void AppendClipboard(const char *format, const String& data) -{ - GuiLock __; - AppendClipboard(format, data, sRawRender); -} - -void AppendClipboard(const char *format, const byte *data, int length) -{ - GuiLock __; - AppendClipboard(format, String(data, length)); -} - -String ReadClipboard(const char *format) -{ - GuiLock __; - int q = fbClipboard.Find(format); - return q >= 0 ? (*fbClipboard[q].render)(fbClipboard[q].data) : String(); -} - -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() -{ - String w = ReadClipboard("text"); - return w.GetCount() ? w : ReadClipboardUnicodeText().ToString(); -} - -WString ReadClipboardUnicodeText() -{ - String w = ReadClipboard("wtext"); - if(w.GetCount()) - return WString((const wchar *)~w, w.GetLength() / 2); - return ReadClipboard("text").ToWString(); -} - -bool IsClipboardAvailable(const char *id) -{ - return fbClipboard.Find(id) >= 0; -} - -bool IsClipboardAvailableText() -{ - return IsClipboardAvailable("text") || IsClipboardAvailable("wtext"); -} - -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; -} - -END_UPP_NAMESPACE - -#endif diff --git a/reference/Framebuffer/Ctrl.cpp b/reference/Framebuffer/Ctrl.cpp deleted file mode 100644 index 1b62e76ae..000000000 --- a/reference/Framebuffer/Ctrl.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "Fb.h" - -#ifdef GUI_FB - -#define LLOG(x) // DLOG(x) - -NAMESPACE_UPP - -void Ctrl::GuiPlatformConstruct() -{ -} - -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) -{ - q->GripResize(); -} - -Color GuiPlatformGetScreenPixel(int x, int y) -{ - return Ctrl::GetFrameBuffer()[y][x]; -} - -void GuiPlatformAfterMenuPopUp() -{ -} - -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/reference/Framebuffer/Ctrl.h b/reference/Framebuffer/Ctrl.h deleted file mode 100644 index ac2f22117..000000000 --- a/reference/Framebuffer/Ctrl.h +++ /dev/null @@ -1,86 +0,0 @@ -//$ class Ctrl { -private: - static Ptr desktop; - static Vector topctrl; - static ImageBuffer framebuffer; - static Vector invalid, update; - - static Point fbCursorPos; - static Image fbCursorImage; - - static Point fbCursorBakPos; - static Image fbCursorBak; - - static Rect fbCaretRect; - static Image fbCaretBak; - static int fbCaretTm; - - static int renderingMode; - - static bool fbEndSession; - static int64 fbEventLoop; - static int64 fbEndSessionLoop; - - static Image GetBak(Rect& tr); - static void RemoveCursor(); - static void RemoveCaret(); - static void CursorSync(); - - int FindTopCtrl() const; - static Rect GetClipBound(const Vector& inv, const Rect& r); - static void DoPaint(); - static void DoUpdate(); - static void SyncTopWindows(); - - static void AddInvalid(const Rect& rect); - - void DestroyWnd(); - - void NewTop() { top = new Top; top->owner_window = NULL; } - void PutForeground(); - static void MouseEventFB(Ptr t, int event, Point p, int zdelta); - Vector GetPaintRects(); - - static void DrawLine(const Vector& clip, int x, int y, int cx, int cy, bool horz, - const byte *pattern, int animation); - static void DragRectDraw0(const Vector& clip, const Rect& rect, int n, - const byte *pattern, int animation); - - friend struct PaintProxy__; - friend class TopWindowFrame; - friend class SystemDraw; - friend struct DnDLoop; - - void SetOpen(bool b) { isopen = b; } - -protected: - static int PaintLock; - -public: - static void DoMouseFB(int event, Point p, int zdelta = 0); - static bool DoKeyFB(dword key, int cnt); - - static void InitFB(); - static void ExitFB(); - static void EndSession(); - - static void SetDesktop(Ctrl& q); - static Ctrl *GetDesktop() { return desktop; } - static void SetFramebufferSize(Size sz); - - static const ImageBuffer& GetFrameBuffer() { return framebuffer; } - - static void SetRenderingMode(int mode); - - static void AddUpdate(const Rect& rect); - - void DragRectDraw(const Rect& rect1, const Rect& rect2, const Rect& clip, int n, - Color color, int type, int animation); - - static Ctrl *FindMouseTopCtrl(); - - static bool FullWindowDrag; - - enum { DRAWDRAGRECT_SCREEN = 0x8000 }; - -//$ }; diff --git a/reference/Framebuffer/DnD.cpp b/reference/Framebuffer/DnD.cpp deleted file mode 100644 index 945de0fd7..000000000 --- a/reference/Framebuffer/DnD.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include "Fb.h" - -#ifdef GUI_FB - -NAMESPACE_UPP - -#define LLOG(x) // DLOG(x) - -// -------------------------------------------------------------------------------------------- - -Ptr sDnDSource; - -Ctrl * Ctrl::GetDragAndDropSource() -{ - return sDnDSource; -} - -struct DnDLoop : LocalLoop { - const VectorMap *data; - Vector fmts; - - Image move, copy, reject; - Ptr target; - int action; - byte actions; - - void Sync(); - String GetData(const String& f); - void DnD(bool paste); - - virtual void LeftUp(Point, dword); - virtual bool Key(dword, int); - virtual void MouseMove(Point p, dword); - virtual Image CursorImage(Point, dword); -}; - -Ptr dndloop; - -bool PasteClip::IsAvailable(const char *fmt) const -{ - GuiLock __; - return dnd ? dndloop && FindIndex(dndloop->fmts, fmt) >= 0 - : IsClipboardAvailable(fmt); -} - -String DnDLoop::GetData(const String& f) -{ - GuiLock __; - int i = data->Find(f); - String d; - if(i >= 0) - d = (*data)[i].Render(); - else - if(sDnDSource) - d = sDnDSource->GetDropData(f); - return d; -} - -String PasteClip::Get(const char *fmt) const -{ - return dnd ? dndloop ? dndloop->GetData(fmt) : String() : ReadClipboard(fmt); -} - -void PasteClip::GuiPlatformConstruct() -{ - dnd = false; -} - -void DnDLoop::DnD(bool paste) -{ - PasteClip d; - d.paste = paste; - d.accepted = false; - d.allowed = (byte)actions; - d.action = GetCtrl() ? DND_COPY : DND_MOVE; - d.dnd = true; - if(target) - target->DnD(GetMousePos(), d); - action = d.IsAccepted() ? d.GetAction() : DND_NONE; -} - -void DnDLoop::Sync() -{ - GuiLock __; - Ptr t = FindMouseTopCtrl(); - if(t != target) - if(target) - target->DnDLeave(); - target = t; - DnD(false); -} - -void DnDLoop::LeftUp(Point, dword) -{ - GuiLock __; - LLOG("DnDLoop::LeftUp"); - DnD(true); - EndLoop(); -} - -void DnDLoop::MouseMove(Point p, dword) -{ - GuiLock __; - LLOG("DnDLoop::MouseMove"); - Sync(); -} - -bool DnDLoop::Key(dword, int) -{ - GuiLock __; - LLOG("DnDLoop::Key"); - Sync(); - return false; -} - -Image DnDLoop::CursorImage(Point, dword) -{ - GuiLock __; - return action == DND_MOVE ? move : action == DND_COPY ? copy : reject; -} - -int Ctrl::DoDragAndDrop(const char *fmts, const Image& sample, dword actions, - const VectorMap& data) -{ - GuiLock __; - DnDLoop d; - d.actions = (byte)actions; - d.reject = actions & DND_EXACTIMAGE ? CtrlCoreImg::DndNone() : MakeDragImage(CtrlCoreImg::DndNone(), sample); - if(actions & DND_COPY) - d.copy = actions & DND_EXACTIMAGE ? sample : MakeDragImage(CtrlCoreImg::DndCopy(), sample); - if(actions & DND_MOVE) - d.move = actions & DND_EXACTIMAGE ? sample : MakeDragImage(CtrlCoreImg::DndMoveX11(), sample); - d.SetMaster(*this); - d.data = &data; - d.action = DND_NONE; - d.fmts = Split(fmts, ';'); - dndloop = &d; - sDnDSource = this; - d.Run(); - sDnDSource = NULL; - SyncCaret(); - LLOG("DoDragAndDrop finished"); - return d.action; -} - -void Ctrl::SetSelectionSource(const char *fmts) {} - -END_UPP_NAMESPACE - -#endif diff --git a/reference/Framebuffer/Draw.cpp b/reference/Framebuffer/Draw.cpp deleted file mode 100644 index bca6767da..000000000 --- a/reference/Framebuffer/Draw.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include - -#ifdef GUI_FB - -NAMESPACE_UPP - -#define LLOG(x) // LOG(x) -#define LTIMING(x) // RTIMING(x) - -SystemDraw::SystemDraw() -: BufferPainter(Ctrl::framebuffer, Ctrl::renderingMode) -{ -} - -SystemDraw::~SystemDraw() -{ -} - - -void SystemDraw::Push() -{ - Point p = GetOffset(); - offset.Add(p); - BufferPainter::BeginOp(); -} - -void SystemDraw::Pop() -{ - if(offset.GetCount()) - offset.Drop(); - BufferPainter::EndOp(); -} - -Point SystemDraw::GetOffset() const -{ - return offset.GetCount() ? offset.Top() : Point(0, 0); -} - -void SystemDraw::BeginOp() -{ - Push(); -} - -void SystemDraw::EndOp() -{ - Pop(); -} - -void SystemDraw::OffsetOp(Point p) -{ - Push(); - offset.Top() += p; - Translate(p.x, p.y); -} - -bool SystemDraw::ClipOp(const Rect& r) -{ - Push(); - RectPath(r); - Painter::Clip(); - return true; -} - -bool SystemDraw::ClipoffOp(const Rect& r) -{ - Push(); - offset.Top() += r.TopLeft(); - RectPath(r); - Painter::Clip(); - Translate(r.left, r.top); - return true; -} - -bool SystemDraw::IsPaintingOp(const Rect& r) const -{ - Rect rr = r + GetOffset(); - for(int i = 0; i < Ctrl::invalid.GetCount(); i++) - if(Ctrl::invalid[i].Intersects(rr)) - return true; - return true; -} - -/*Rect SystemDraw::GetVirtualScreenArea() -{ - 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/reference/Framebuffer/Event.cpp b/reference/Framebuffer/Event.cpp deleted file mode 100644 index 64ad722ef..000000000 --- a/reference/Framebuffer/Event.cpp +++ /dev/null @@ -1,189 +0,0 @@ -#include "Fb.h" - -#ifdef GUI_FB - -NAMESPACE_UPP - -#define LLOG(x) //DLOG(x) -#define LDUMP(x) //DDUMP(x) - -static Point fbmousepos; - -Point GetMousePos() { - return fbmousepos; -} - -void Ctrl::MouseEventFB(Ptr t, int event, Point p, int zdelta) -{ - if(!t->IsEnabled()) - return; - Rect rr = t->GetRect(); - if((event & Ctrl::ACTION) == DOWN) { - Ptr q = t; - TopWindowFrame *wf = dynamic_cast(~t); - if(wf) - q = wf->window; - if(q) q->ClickActivateWnd(); - if(q) q->SetForeground(); - if(ignoreclick) - return; - } - if(t) - t->DispatchMouse(event, p - rr.TopLeft(), zdelta); - if(t) - t->PostInput(); -} - -Ctrl *Ctrl::FindMouseTopCtrl() -{ - for(int i = topctrl.GetCount() - 1; i >= 0; i--) { - Ctrl *t = topctrl[i]; - if(t->GetRect().Contains(fbmousepos)) - return t->IsEnabled() ? t : NULL; - } - return desktop->IsEnabled() ? desktop : NULL; -} - -void Ctrl::DoMouseFB(int event, Point p, int zdelta) -{ - fbmousepos = p; - int a = event & Ctrl::ACTION; - if(a == Ctrl::UP && Ctrl::ignoreclick) { - EndIgnore(); - return; - } - else - if(a == Ctrl::DOWN && ignoreclick) - return; - LLOG("### Mouse event: " << event << " position " << p << " zdelta " << zdelta << ", capture " << Upp::Name(captureCtrl)); - if(captureCtrl) - MouseEventFB(captureCtrl->GetTopCtrl(), event, p, zdelta); - else - for(int i = topctrl.GetCount() - 1; i >= 0; i--) { - Ptr t = topctrl[i]; - Rect rr = t->GetRect(); - if(rr.Contains(p)) { - MouseEventFB(t, event, p, zdelta); - return; - } - } - Ctrl *desktop = GetDesktop(); - if(desktop) { - desktop->DispatchMouse(event, p, zdelta); - desktop->PostInput(); - } -} - -bool Ctrl::DoKeyFB(dword key, int cnt) -{ - bool b = DispatchKey(key, cnt); - SyncCaret(); - Ctrl *desktop = GetDesktop(); - if(desktop) - desktop->PostInput(); - return b; -} - -Image Ctrl::GetBak(Rect& tr) -{ - Image bak; - tr.Intersect(framebuffer.GetSize()); - if(!tr.IsEmpty()) { - Image h = framebuffer; - bak = CreateImage(tr.GetSize(), Black); - Copy(bak, Point(0, 0), h, tr); - framebuffer = h; - } - return bak; -} - -void Ctrl::RemoveCursor() -{ - if(!IsNull(fbCursorBakPos)) { - Copy(framebuffer, fbCursorBakPos, fbCursorBak, fbCursorBak.GetSize()); - AddUpdate(Rect(fbCursorBakPos, fbCursorBak.GetSize())); - } - fbCursorPos = fbCursorBakPos = Null; - fbCursorBak = Null; -} - -void Ctrl::RemoveCaret() -{ - if(!IsNull(fbCaretRect)) { - Copy(framebuffer, fbCaretRect.TopLeft(), fbCaretBak, fbCaretBak.GetSize()); - AddUpdate(fbCaretRect); - } - fbCaretRect = Null; - fbCaretBak = Null; -} - -void Ctrl::SetCaret(int x, int y, int cx, int cy) -{ - GuiLock __; - caretx = x; - carety = y; - caretcx = cx; - caretcy = cy; - fbCaretTm = GetTickCount(); - SyncCaret(); -} - -void Ctrl::SyncCaret() -{ - GuiLock __; -} - -void Ctrl::CursorSync() -{ - LLOG("@ CursorSync"); - Point p = GetMousePos() - fbCursorImage.GetHotSpot(); - Rect cr = Null; - if(focusCtrl && (((GetTickCount() - fbCaretTm) / 500) & 1) == 0) - cr = (RectC(focusCtrl->caretx, focusCtrl->carety, focusCtrl->caretcx, focusCtrl->caretcy) - + focusCtrl->GetScreenView().TopLeft()) & focusCtrl->GetScreenView(); - LDUMP(GetTickCount()); - if(fbCursorPos != p || cr != fbCaretRect) { - LDUMP(fbCaretRect); - RemoveCursor(); - RemoveCaret(); - - fbCursorPos = p; - Size sz = fbCursorImage.GetSize(); - Rect tr(p, sz); - fbCursorBak = GetBak(tr); - fbCursorBakPos = tr.TopLeft(); - - fbCaretRect = cr; - if(!cr.IsEmpty()) { - fbCaretBak = GetBak(cr); - for(int y = cr.top; y < cr.bottom; y++) { - RGBA *s = framebuffer[y] + cr.left; - const RGBA *e = framebuffer[y] + cr.right; - while(s < e) { - s->r = ~s->r; - s->g = ~s->g; - s->b = ~s->b; - s++; - } - } - AddUpdate(fbCaretRect); - } - - Over(framebuffer, p, fbCursorImage, sz); - LLOG("Cursor: " << p << ", rect " << tr); - AddUpdate(tr); - } -} - -void Ctrl::SetMouseCursor(const Image& image) -{ - GuiLock __; - if(image.GetSerialId() != fbCursorImage.GetSerialId()) { - fbCursorImage = image; - fbCursorPos = Null; - } -} - -END_UPP_NAMESPACE - -#endif \ No newline at end of file diff --git a/reference/Framebuffer/FB.iml b/reference/Framebuffer/FB.iml deleted file mode 100644 index 08f565033..000000000 --- a/reference/Framebuffer/FB.iml +++ /dev/null @@ -1,59 +0,0 @@ -PREMULTIPLIED -IMAGE_ID(arrow) -IMAGE_ID(ibeam) -IMAGE_ID(wait) -IMAGE_ID(no) -IMAGE_ID(sizeall) -IMAGE_ID(sizehorz) -IMAGE_ID(sizeright) -IMAGE_ID(sizeleft) -IMAGE_ID(sizevert) -IMAGE_ID(sizetopleft) -IMAGE_ID(sizetop) -IMAGE_ID(sizetopright) -IMAGE_ID(sizebottomleft) -IMAGE_ID(sizebottom) -IMAGE_ID(sizebottomright) -IMAGE_ID(overlap) -IMAGE_ID(maximize) -IMAGE_ID(close) -IMAGE_ID(bgtitle) -IMAGE_ID(title) -IMAGE_ID(border) -IMAGE_ID(hand) - -IMAGE_BEGIN_DATA -IMAGE_DATA(120,156,237,90,205,75,84,81,20,191,101,163,6,74,72,180,115,209,166,77,127,66,4,109,91,6,22,4,209,38,23,209) -IMAGE_DATA(162,93,45,162,204,9,34,130,8,13,178,36,44,45,11,212,172,197,108,68,84,212,133,31,8,126,224,7,12,162,8,34) -IMAGE_DATA(136,136,160,43,221,157,238,140,51,227,245,188,251,206,61,231,206,27,43,120,231,113,208,247,238,239,119,238,57,191,115,222) -IMAGE_DATA(123,227,135,170,82,23,84,198,202,213,169,204,23,80,50,3,33,7,0,68,28,56,56,184,8,251,251,151,184,28,216,219) -IMAGE_DATA(187,2,187,187,215,96,103,231,58,135,3,219,219,55,96,107,235,38,108,110,222,129,245,245,122,23,7,54,54,234,53,238) -IMAGE_DATA(62,172,173,61,132,213,213,71,144,78,63,165,56,176,178,242,24,150,151,159,104,92,35,44,46,190,130,249,249,183,48,59) -IMAGE_DATA(219,28,198,129,165,165,151,176,176,240,26,230,230,154,96,102,166,21,166,166,58,97,114,242,59,76,76,180,219,56,26,211) -IMAGE_DATA(12,211,211,239,53,174,13,198,199,187,97,100,100,36,231,191,96,120,184,19,115,116,172,86,141,107,131,177,177,78,24,29) -IMAGE_DATA(253,93,192,171,163,94,154,28,141,249,172,189,3,134,134,126,192,224,224,79,232,239,79,145,245,14,12,180,67,95,223,215) -IMAGE_DATA(66,156,84,170,155,196,167,82,95,2,57,118,117,125,11,213,199,166,65,71,199,39,10,111,221,183,165,229,157,104,14,155) -IMAGE_DATA(154,222,136,103,61,153,124,46,218,163,161,225,153,120,15,1,54,104,9,117,78,157,86,21,89,87,168,241,42,123,179,30) -IMAGE_DATA(26,250,190,176,57,58,255,239,175,133,212,27,208,69,85,105,225,18,90,180,196,113,225,184,158,229,212,246,124,32,221,192) -IMAGE_DATA(158,4,158,228,88,176,161,28,2,27,224,48,176,5,142,4,235,147,139,79,173,62,90,254,133,254,202,230,179,70,31,149) -IMAGE_DATA(185,131,18,206,226,92,227,222,36,28,126,49,235,146,60,139,229,7,26,200,136,97,127,250,248,243,195,242,146,242,185,49) -IMAGE_DATA(36,235,174,61,56,57,82,117,82,230,210,88,194,183,229,36,153,21,219,53,95,62,55,142,207,125,231,115,223,186,98,217) -IMAGE_DATA(141,249,64,58,140,26,124,189,139,204,124,253,23,195,207,187,52,14,230,251,196,1,195,208,169,51,6,198,217,244,160,98) -IMAGE_DATA(133,225,57,215,204,235,56,111,91,45,24,139,249,62,110,139,227,147,71,84,122,68,213,23,91,44,91,45,46,46,222,31) -IMAGE_DATA(187,36,134,45,142,148,143,227,248,242,81,28,218,106,244,199,254,74,85,150,117,76,118,5,160,48,220,34,194,112,212,208) -IMAGE_DATA(218,76,169,147,191,121,56,121,68,165,135,185,238,213,151,184,209,113,163,253,2,50,19,118,225,138,21,216,188,230,227,182) -IMAGE_DATA(56,62,121,68,165,135,185,238,213,151,10,221,234,178,92,171,45,27,178,19,193,194,186,4,183,9,132,206,157,133,255,235) -IMAGE_DATA(107,84,125,148,46,148,158,156,92,140,245,35,171,214,71,121,238,8,100,130,68,39,2,146,73,185,56,46,124,177,28,44) -IMAGE_DATA(182,139,131,155,197,221,47,108,239,98,121,146,62,72,106,53,121,170,132,189,240,157,17,235,44,198,79,166,210,173,81,245) -IMAGE_DATA(81,186,80,122,114,114,49,214,143,204,124,50,81,22,200,18,53,132,216,236,68,159,66,92,14,22,223,197,161,26,201,197) -IMAGE_DATA(227,117,28,75,146,3,7,111,114,212,9,235,207,205,77,58,83,241,192,198,3,91,18,14,55,55,241,192,198,175,210,210) -IMAGE_DATA(173,81,245,81,186,80,122,114,114,49,214,143,44,254,144,31,228,224,102,113,247,11,219,187,88,158,164,15,146,90,77,158) -IMAGE_DATA(42,97,47,124,103,196,58,139,85,250,136,200,172,119,154,225,54,60,21,203,23,207,201,3,227,93,123,70,133,231,232,83) -IMAGE_DATA(42,93,204,107,146,62,241,45,130,97,114,37,39,17,203,134,137,241,209,227,37,253,226,91,20,79,166,171,213,213,161,155) -IMAGE_DATA(227,181,204,121,222,109,88,219,154,237,58,21,7,175,187,176,97,28,10,43,197,75,242,145,212,235,171,39,149,39,85,7) -IMAGE_DATA(105,103,244,145,183,186,186,86,184,253,160,23,238,190,232,133,123,31,123,65,122,94,8,86,150,253,219,76,18,206,94,238) -IMAGE_DATA(129,243,183,150,160,182,49,243,18,22,158,103,198,60,161,143,220,207,178,220,251,233,216,155,223,101,230,255,83,231,207,41) -IMAGE_DATA(79,38,147,49,190,68,248,252,185,203,125,102,33,59,76,142,95,140,80,159,94,48,14,210,233,244,177,175,97,88,140,51) -IMAGE_DATA(240,214,79,32,97,120,180,79,33,6,23,239,194,217,240,121,151,226,195,28,213,44,197,59,57,148,166,76,44,11,255,7) -IMAGE_DATA(113,204,146,74,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) -IMAGE_END_DATA(1056, 22) diff --git a/reference/Framebuffer/Fb.h b/reference/Framebuffer/Fb.h deleted file mode 100644 index fbcba1d77..000000000 --- a/reference/Framebuffer/Fb.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef _Framebuffer_Fb_h_ -#define _Framebuffer_Fb_h_ - -#include - -NAMESPACE_UPP - -class TopWindowFrame : public Ctrl { -public: - virtual void Layout(); - virtual void Paint(Draw& w); - virtual Image CursorImage(Point p, dword keyflags); - virtual void LeftDown(Point p, dword keyflags); - virtual void LeftHold(Point p, dword keyflags); - virtual void LeftDouble(Point p, dword keyflags); - virtual void MouseMove(Point p, dword keyflags); - virtual void CancelMode(); - virtual void LeftUp(Point p, dword keyflags); - -private: - Point dir; - Point startpos; - Rect startrect; - - bool maximized; - Rect overlapped; - - bool holding; - TimeCallback hold; - - Point GetDragMode(Point p); - Image GetDragImage(Point dragmode); - void StartDrag(); - Rect Margins() const; - Rect ComputeClient(Rect r); - void Hold(); - - typedef TopWindowFrame CLASSNAME; - -public: - String title; - Button close, maximize; - Image icon; - Size minsize; - bool sizeable; - TopWindow *window; - - void SetTitle(const String& s) { title = s; Refresh(); } - Rect GetClient() const; - void SetClient(Rect r); - void GripResize(); - - void Maximize(); - void Overlap(); - void ToggleMaximize(); - bool IsMaximized() const { return maximized; } - void SyncRect(); - - TopWindowFrame(); -}; - -END_UPP_NAMESPACE - -#endif diff --git a/reference/Framebuffer/Framebuffer.h b/reference/Framebuffer/Framebuffer.h deleted file mode 100644 index 4372e4470..000000000 --- a/reference/Framebuffer/Framebuffer.h +++ /dev/null @@ -1,141 +0,0 @@ -#define GUI_FB - -#include - -NAMESPACE_UPP - -#define IMAGECLASS FBImg -#define IMAGEFILE -#include - -class SystemDraw : public BufferPainter { -public: - 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 IsPaintingOp(const Rect& r) const; - -private: - Vector offset; - - void Push(); - void Pop(); - -public: - Point GetOffset() const; - bool CanSetSurface() { return false; } - bool Clip(const Rect& r) { return Draw::Clip(r); } - bool Clip(int x, int y, int cx, int cy) { return Draw::Clip(x, y, cx, cy); } - - static void Flush() {} - - SystemDraw(); - ~SystemDraw(); -}; - -struct BackDraw__ : public SystemDraw { - BackDraw__() : SystemDraw() {} -}; - -class BackDraw : public BackDraw__ { // Dummy only, as we are running in GlobalBackBuffer mode - Size size; - Draw *painting; - Point painting_offset; - ImageBuffer ib; - -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(); -}; - -struct ImageDraw__ { - ImageBuffer image; - ImageBuffer alpha; - - ImageDraw__(int cx, int cy) : image(cx, cy), alpha(cx, cy) {} -}; - -class ImageDraw : private ImageDraw__, public BufferPainter { - BufferPainter alpha_painter; - bool has_alpha; - - Image Get(bool pm) const; - -public: - Draw& Alpha(); - - operator Image() const { return Get(true); } - - Image GetStraight() const { return Get(false); } - - ImageDraw(Size sz); - ImageDraw(int cx, int cy); -}; - -void DrawDragRect(SystemDraw& w, const Rect& rect1, const Rect& rect2, const Rect& clip, int n, - Color color, uint64 pattern); - -class TopWindowFrame; - -#define GUIPLATFORM_CTRL_TOP_DECLS Ctrl *owner_window; - -#define GUIPLATFORM_CTRL_DECLS_INCLUDE - -#define GUIPLATFORM_PASTECLIP_DECLS \ - bool dnd; \ - friend struct DnDLoop; \ - -#define GUIPLATFORM_TOPWINDOW_DECLS_INCLUDE - -// to be implemented by final FB { - -bool FBIsWaitingEvent(); -bool FBProcessEvent(bool *quit); -void FBSleep(int ms); -void FBInitUpdate(); -void FBUpdate(const Rect& area); -void FBFlush(); -void FBQuitSession(); - -// } - -class PrinterJob { // Dummy only... - 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/reference/Framebuffer/Framebuffer.upp b/reference/Framebuffer/Framebuffer.upp deleted file mode 100644 index 6df6c1a8e..000000000 --- a/reference/Framebuffer/Framebuffer.upp +++ /dev/null @@ -1,25 +0,0 @@ -description "Generic framebuffer GUI rainbow\377"; - -uses - Painter, - CtrlLib; - -file - Framebuffer.h, - After.h, - Fb.h, - Draw.cpp, - Image.cpp, - Util.cpp, - FB.iml, - Ctrl.h, - Ctrl.cpp, - Wnd.cpp, - Event.cpp, - Top.h, - TopFrame.cpp, - Top.cpp, - Clip.cpp, - DnD.cpp, - ChSysInit.cpp; - diff --git a/reference/Framebuffer/Gui.h b/reference/Framebuffer/Gui.h deleted file mode 100644 index b99463c69..000000000 --- a/reference/Framebuffer/Gui.h +++ /dev/null @@ -1,358 +0,0 @@ -#define GUI_FB - -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/reference/Framebuffer/Image.cpp b/reference/Framebuffer/Image.cpp deleted file mode 100644 index c9befe96a..000000000 --- a/reference/Framebuffer/Image.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include - -#ifdef GUI_FB - -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 __; -} - -Image ImageDraw::Get(bool pm) const -{ - ImageBuffer result(image.GetSize()); - const RGBA *e = image.End(); - const RGBA *p = ~image; - RGBA *t = ~result; - if(has_alpha) { - const RGBA *a = ~alpha; - while(p < e) { - *t = *p++; - (t++)->a = (a++)->r; - } - if(pm) - Premultiply(result); - result.SetKind(IMAGE_ALPHA); - } - else { - while(p < e) { - *t = *p++; - (t++)->a = 255; - } - } - return result; -} - -Draw& ImageDraw::Alpha() -{ - has_alpha = true; - return alpha_painter; -} - - -ImageDraw::ImageDraw(Size sz) -: ImageDraw__(sz.cx, sz.cy), - BufferPainter(image), - alpha_painter(alpha) -{ - has_alpha = false; -} - -ImageDraw::ImageDraw(int cx, int cy) -: ImageDraw__(cx, cy), - BufferPainter(image), - alpha_painter(alpha) -{ - has_alpha = false; -} - -#define IMAGECLASS FBImg -#define IMAGEFILE -#include - -Image Image::Arrow() { return FBImg::arrow(); } -Image Image::Wait() { return FBImg::wait(); } -Image Image::IBeam() { return FBImg::ibeam(); } -Image Image::No() { return FBImg::no(); } -Image Image::SizeAll() { return FBImg::sizeall(); } -Image Image::SizeHorz() { return FBImg::sizehorz(); } -Image Image::SizeVert() { return FBImg::sizevert(); } -Image Image::SizeTopLeft() { return FBImg::sizetopleft(); } -Image Image::SizeTop() { return FBImg::sizetop(); } -Image Image::SizeTopRight() { return FBImg::sizetopright(); } -Image Image::SizeLeft() { return FBImg::sizeleft(); } -Image Image::SizeRight() { return FBImg::sizeright(); } -Image Image::SizeBottomLeft() { return FBImg::sizebottomleft(); } -Image Image::SizeBottom() { return FBImg::sizebottom(); } -Image Image::SizeBottomRight() { return FBImg::sizebottomright(); } -Image Image::Hand() { return FBImg::hand(); } - -END_UPP_NAMESPACE - -#endif diff --git a/reference/Framebuffer/Top.cpp b/reference/Framebuffer/Top.cpp deleted file mode 100644 index 988950a7c..000000000 --- a/reference/Framebuffer/Top.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include "Fb.h" - -#ifdef GUI_FB - -NAMESPACE_UPP - -#define LLOG(x) // LOG(x) - -void TopWindow::SyncFrameRect(const Rect& r) -{ - frame->SetClient(r); -} - -void TopWindow::DestroyFrame() -{ - if(frame->IsOpen()) - frame->DestroyWnd(); -} - -void TopWindow::GripResize() -{ - frame->GripResize(); -} - -void TopWindow::SyncSizeHints() -{ - SyncCaption0(); -} - -void TopWindow::SyncTitle0() -{ - SyncCaption0(); -} - -void TopWindow::SyncCaption0() -{ - GuiLock __; - frame->title = title.ToString(); - frame->minsize = minsize; - frame->close.Show(!noclosebox); - frame->maximize.Show(maximizebox); - frame->sizeable = sizeable; - frame->RefreshLayout(); - frame->Refresh(); - frame->close <<= Proxy(WhenClose); - frame->icon = icon; - frame->Enable(IsEnabled()); -} - -void TopWindow::State(int reason) -{ - SyncCaption0(); -} - -void TopWindow::SyncRect() -{ - frame->SyncRect(); - Rect r = frame->GetClient(); - if(r != GetRect()) { - SetRect(r); - } -} - -void TopWindow::Open(Ctrl *owner) -{ - GuiLock __; - LLOG("Open " << Upp::Name(owner)); - Rect r = GetRect(); - if(r.IsEmpty()) - SetRect(GetDefaultWindowRect()); - else - if(r.left == 0 && r.top == 0) - if(owner && center == 1) - SetRect(owner->GetRect().CenterRect(r.GetSize())); - else - if(center) - SetRect(GetWorkArea().CenterRect(r.GetSize())); - frame->SetClient(GetRect()); - frame->window = this; - frame->PopUp(owner, false, true); - PopUp(frame, false, true); - popup = false; - SetRect(frame->GetClient()); - SyncCaption0(); - if(state == MAXIMIZED) - frame->Maximize(); -} - -void TopWindow::Open() -{ - Open(GetActiveCtrl()); -} - -void TopWindow::OpenMain() -{ - Open(NULL); -} - -void TopWindow::Minimize(bool effect) -{ -// state = MINIMIZED; -} - -TopWindow& TopWindow::FullScreen(bool b) -{ - return *this; -} - -void TopWindow::Maximize(bool effect) -{ - state = MAXIMIZED; - frame->Maximize(); -} - -void TopWindow::Overlap(bool effect) -{ - GuiLock __; - state = OVERLAPPED; - frame->Overlap(); -} - -TopWindow& TopWindow::TopMost(bool b, bool stay_top) -{ - GuiLock __; - return *this; -} - -bool TopWindow::IsTopMost() const -{ - return true; -} - -void TopWindow::GuiPlatformConstruct() -{ - frame = new TopWindowFrame; -} - -void TopWindow::GuiPlatformDestruct() -{ - delete frame; -} - -void TopWindow::SerializePlacement(Stream& s, bool reminimize) -{ - GuiLock __; -} - -END_UPP_NAMESPACE - -#endif diff --git a/reference/Framebuffer/Top.h b/reference/Framebuffer/Top.h deleted file mode 100644 index 2e9b12c16..000000000 --- a/reference/Framebuffer/Top.h +++ /dev/null @@ -1,16 +0,0 @@ -//$ class TopWindow { -public: - virtual void State(int reason); - -private: - TopWindowFrame *frame; - - void SyncRect(); - void SyncFrameRect(const Rect& r); - void DestroyFrame(); - - friend class Ctrl; - -public: - void GripResize(); -//$ }; diff --git a/reference/Framebuffer/TopFrame.cpp b/reference/Framebuffer/TopFrame.cpp deleted file mode 100644 index 36bba5dac..000000000 --- a/reference/Framebuffer/TopFrame.cpp +++ /dev/null @@ -1,259 +0,0 @@ -#include "Fb.h" - -#ifdef GUI_FB - -NAMESPACE_UPP - -#define LLOG(x) // LOG(x) -#define LDUMP(x) //DDUMP(x) - -TopWindowFrame::TopWindowFrame() -{ - close.SetImage(FBImg::close()); - close.EdgeStyle(); - Add(close); - maximize.SetImage(FBImg::maximize()); - maximize.EdgeStyle(); - Add(maximize); - maximize <<= THISBACK(ToggleMaximize); - maximized = false; - sizeable = false; - holding = false; -} - -void TopWindowFrame::SyncRect() -{ - if(maximized) { - Size sz = framebuffer.GetSize(); - if(GetRect().GetSize() != sz) - SetRect(sz); - } -} - -void TopWindowFrame::Maximize() -{ - if(!maximized && maximize.IsShown()) { - maximized = true; - overlapped = GetRect(); - SetRect(framebuffer.GetSize()); - maximize.SetImage(FBImg::overlap()); - } -} - -void TopWindowFrame::Overlap() -{ - if(maximized && maximize.IsShown()) { - maximized = false; - SetRect(overlapped); - maximize.SetImage(FBImg::maximize()); - } -} - -void TopWindowFrame::ToggleMaximize() -{ - if(maximized) - Overlap(); - else - Maximize(); -} - -Rect TopWindowFrame::Margins() const -{ - return maximized ? Rect(0, 0, 0, 0) : ChMargins(FBImg::border()); -} - -void TopWindowFrame::Paint(Draw& w) -{ - Size sz = GetSize(); - Rect m = Margins(); - int c = GetStdFontCy() + 4; - ChPaintEdge(w, sz, FBImg::border()); - ChPaint(w, m.left, m.top, sz.cx - m.left - m.right, GetStdFontCy() + 4, - window->IsForeground() ? FBImg::title() : FBImg::bgtitle()); - int tx = m.left + 2; - int tcx = sz.cx - m.left - m.right - 4 - c * (close.IsShown() + maximize.IsShown()); - if(!IsNull(icon)) { - Image h = icon; - if(h.GetWidth() > c || h.GetHeight() > c) - h = Rescale(h, GetFitSize(h.GetSize(), Size(c))); - w.DrawImage(tx, m.top + 2, h); - tx += c; - tcx -= c; - } - DrawTextEllipsis(w, tx, m.top + 2, tcx, title, "..", StdFont(), SColorHighlightText()); -} - -void TopWindowFrame::Layout() -{ - Size sz = GetSize(); - Rect m = Margins(); - int c = GetStdFontCy() + 4; - int x = sz.cx - m.right; - if(close.IsShown()) - close.SetRect(x -= c, m.top, c, c); - if(maximize.IsShown()) - maximize.SetRect(x -= c, m.top, c, c); -} - -Rect TopWindowFrame::GetClient() const -{ - Rect r = GetRect(); - Rect m = Margins(); - r.left += m.left; - r.right -= m.right; - r.top += m.top; - r.bottom -= m.bottom; - r.top += GetStdFontCy() + 4; - return r; -} - -Rect TopWindowFrame::ComputeClient(Rect r) -{ - Rect m = Margins(); - r.left -= m.left; - r.right += m.right; - r.top -= m.top; - r.bottom += m.bottom; - r.top -= GetStdFontCy() + 4; - return r; -} - -void TopWindowFrame::SetClient(Rect r) -{ - SetRect(ComputeClient(r)); -} - -Point TopWindowFrame::GetDragMode(Point p) -{ - Size sz = GetSize(); - Rect m = ChMargins(FBImg::border()); - Point dir; - dir.y = p.y < m.top ? -1 : p.y > sz.cy - m.top ? 1 : 0; - dir.x = p.x < m.left ? -1 : p.x > sz.cx - m.right ? 1 : 0; - return dir; -} - -void TopWindowFrame::StartDrag() -{ - if(maximized) - return; - if(!sizeable && (dir.x || dir.y)) - return; - if(FullWindowDrag) { - SetCapture(); - startrect = GetRect(); - startpos = GetMousePos(); - } - else { - Rect r = GetScreenRect(); - RectTracker tr(*this); - tr.SetCursorImage(GetDragImage(dir)) - .MaxRect(framebuffer.GetSize()) - .MinSize(ComputeClient(minsize).GetSize()) - .Pattern(DRAWDRAGRECT_DASHED | DRAWDRAGRECT_SCREEN) - .Width(2) - .Animation(); - PaintLock++; - r = tr.Track(r, dir.x < 0 ? ALIGN_LEFT : dir.x > 0 ? ALIGN_RIGHT : ALIGN_CENTER, - dir.y < 0 ? ALIGN_TOP : dir.y > 0 ? ALIGN_BOTTOM : ALIGN_CENTER); - PaintLock--; - SetRect(r); - } - LLOG("START DRAG ---------------"); -} - -void TopWindowFrame::GripResize() -{ - dir = Point(1, 1); - StartDrag(); -} - -void TopWindowFrame::LeftDown(Point p, dword keyflags) -{ - dir = GetDragMode(p); - if(dir.x || dir.y || FullWindowDrag) - StartDrag(); - else { - SetCapture(); - holding = true; - hold.Set(GetKbdDelay() / 3, THISBACK(Hold)); - } -} - -void TopWindowFrame::CancelMode() -{ - holding = false; -} - -void TopWindowFrame::LeftUp(Point p, dword keyflags) -{ - holding = false; -} - -void TopWindowFrame::Hold() -{ - if(HasCapture()) { - if(HasMouse() && GetMouseLeft() && holding) - StartDrag(); - ReleaseCapture(); - holding = false; - } -} - -void TopWindowFrame::LeftHold(Point p, dword keyflags) -{ - if(HasCapture() || FullWindowDrag) - return; - dir = GetDragMode(p); - if(!dir.x && !dir.y) - StartDrag(); -} - -void TopWindowFrame::LeftDouble(Point p, dword keyflags) -{ - ToggleMaximize(); - IgnoreMouseUp(); -} - -void TopWindowFrame::MouseMove(Point, dword) -{ - LDUMP(HasWndCapture()); - LDUMP(HasCapture()); - if(!HasCapture() || holding) - return; - Size msz = ComputeClient(minsize).GetSize(); - Point p = GetMousePos() - startpos; - Rect r = startrect; - if(dir.x == -1) - r.left = min(r.left + p.x, startrect.right - msz.cx); - if(dir.x == 1) - r.right = max(r.right + p.x, startrect.left + msz.cx); - if(dir.y == -1) - r.top = min(r.top + p.y, startrect.bottom - msz.cy); - if(dir.y == 1) - r.bottom = max(r.bottom + p.y, startrect.top + msz.cy); - if(dir.y == 0 && dir.x == 0) - r.Offset(p); - SetRect(r); -} - -Image TopWindowFrame::GetDragImage(Point dir) -{ - static Image (*im[9])() = { - Image::SizeTopLeft, Image::SizeLeft, Image::SizeBottomLeft, - Image::SizeTop, Image::Arrow, Image::SizeBottom, - Image::SizeTopRight, Image::SizeRight, Image::SizeBottomRight, - }; - return (*im[(dir.x + 1) * 3 + (dir.y + 1)])(); -} - -Image TopWindowFrame::CursorImage(Point p, dword) -{ - if(!sizeable) - return Image::Arrow(); - return GetDragImage(HasCapture() ? dir : GetDragMode(p)); -} - -END_UPP_NAMESPACE - -#endif diff --git a/reference/Framebuffer/Util.cpp b/reference/Framebuffer/Util.cpp deleted file mode 100644 index fa47b449b..000000000 --- a/reference/Framebuffer/Util.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include - -#ifdef GUI_FB - -NAMESPACE_UPP - -/* -static void sRenderLine(SystemDraw& w, int x, int y, int dx, int dy, int cx, int cy, int len, byte pattern) -{ - DLOG(len); - for(int i = 0; i < len; i++) - if((128 >> (i & 7)) & pattern) - w.DrawRect(x + dx * i, y + dy * i, cx, cy, Black); - DDUMP("~sRenderLine"); -} - -static void sRenderRect(SystemDraw& w, const Rect& r, int n, byte pattern) -{ - sRenderLine(w, r.left, r.top, 1, 0, 1, n, r.GetWidth(), pattern); - sRenderLine(w, r.left, r.bottom - 1, 1, 0, 1, n, r.GetWidth(), pattern); - sRenderLine(w, r.left, r.top, 0, 1, n, 1, r.GetHeight(), pattern); - sRenderLine(w, r.right - 1, r.top, 0, 1, n, 1, r.GetHeight(), pattern); -} - -void DrawDragRect(SystemDraw& w, const Rect& rect1, const Rect& rect2, - const Rect& clip, int n, Color color, uint64 pattern) -{ - DLOG("@ DrawDragRect " << rect1 << " " << rect2 << ", clip: " << clip << ", pattern: " << pattern); - TIMING("DrawDrawRect"); - w.Clip(clip); - w.Invert(); - sRenderRect(w, rect1, n, (byte)pattern); - sRenderRect(w, rect2, n, (byte)pattern); - Ctrl::AddUpdate((rect1 | rect2).Offseted(w.GetOffset())); -// MemoryProfile mem; -// DDUMP(mem); - w.End(); -} - - - - -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; -} -*/ - - -/* -Size GetScreenSize() -{ - return ScreenInfo().GetPageSize(); -} -*/ - -void DrawDragRect(Ctrl& q, const Rect& rect1, const Rect& rect2, const Rect& clip, int n, - Color color, int type, int animation) -{ - q.DragRectDraw(rect1, rect2, clip, n, color, type, animation); -} - -END_UPP_NAMESPACE - -#endif diff --git a/reference/Framebuffer/Wnd.cpp b/reference/Framebuffer/Wnd.cpp deleted file mode 100644 index aab22e51d..000000000 --- a/reference/Framebuffer/Wnd.cpp +++ /dev/null @@ -1,760 +0,0 @@ -#include "Fb.h" - -#ifdef GUI_FB - -NAMESPACE_UPP - -#define LLOG(x) //DLOG(x) -#define LDUMP(x) //DDUMP(x) -#define LDUMPC(x) //DDUMPC(x) - -ImageBuffer Ctrl::framebuffer; -Vector Ctrl::invalid; -Vector Ctrl::update; - -Ptr Ctrl::desktop; -Vector Ctrl::topctrl; - -Point Ctrl::fbCursorPos = Null; -Image Ctrl::fbCursorImage; -Point Ctrl::fbCursorBakPos = Null; -Image Ctrl::fbCursorBak; -Rect Ctrl::fbCaretRect; -Image Ctrl::fbCaretBak; -int Ctrl::fbCaretTm; -int Ctrl::renderingMode = MODE_ANTIALIASED; -bool Ctrl::fbEndSession; -bool Ctrl::FullWindowDrag; -int Ctrl::PaintLock; - -void Ctrl::SetDesktop(Ctrl& q) -{ - desktop = &q; - desktop->SetRect(framebuffer.GetSize()); - desktop->SetOpen(true); - desktop->NewTop(); - invalid.Add(framebuffer.GetSize()); -} - -void Ctrl::SetRenderingMode(int mode) -{ - renderingMode = mode; - invalid.Add(framebuffer.GetSize()); -} - -void Ctrl::InitFB() -{ - Ctrl::GlobalBackBuffer(); - Ctrl::InitTimer(); - framebuffer.Create(1, 1); - -#ifdef PLATFORM_POSIX - SetStdFont(ScreenSans(12)); //FIXME general handling -#endif - ChStdSkin(); - - static StaticRect x; - x.Color(Cyan()); - SetDesktop(x); -} - -void Ctrl::EndSession() -{ - GuiLock __; - LLOG("Ctrl::EndSession"); - fbEndSession = true; - EndSessionLoopNo = EventLoopNo; -} - -void Ctrl::ExitFB() -{ - TopWindow::ShutdownWindows(); - Ctrl::CloseTopCtrls(); - if(fbEndSession) - FBQuitSession(); -} - -void Ctrl::SetFramebufferSize(Size sz) -{ - framebuffer.Create(sz); - if(desktop) - desktop->SetRect(sz); - invalid.Add(sz); - SyncTopWindows(); -} - -int Ctrl::FindTopCtrl() const -{ - for(int i = 0; i < topctrl.GetCount(); i++) - if(this == topctrl[i]) - return i; - return -1; -} - -bool Ctrl::IsAlphaSupported() -{ - return false; -} - -bool Ctrl::IsCompositedGui() -{ - return false; -} - -Vector Ctrl::GetTopCtrls() -{ - Vector ctrl; - if(desktop) - ctrl.Add(desktop); - for(int i = 0; i < topctrl.GetCount(); i++) - if(!dynamic_cast(topctrl[i])) - ctrl.Add(topctrl[i]); - return ctrl; -} - -Ctrl *Ctrl::GetOwner() -{ - GuiLock __; - int q = FindTopCtrl(); - if(q > 0 && topctrl[q]->top) { - Ctrl *x = topctrl[q]->top->owner_window; - LDUMP(Upp::Name(x)); - return dynamic_cast(x) ? x->GetOwner() : x; - } - return NULL; -} - -Ctrl *Ctrl::GetActiveCtrl() -{ - GuiLock __; - return focusCtrl ? focusCtrl->GetTopCtrl() : 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 FBIsWaitingEvent(); -} - -void Ctrl::AddUpdate(const Rect& rect) -{ - LLOG("@AddUpdate " << rect); - AddRefreshRect(update, rect); -} - -void Ctrl::AddInvalid(const Rect& rect) -{ - LLOG("@AddInvalid " << rect); - AddRefreshRect(invalid, rect); -} - -void Ctrl::SyncTopWindows() -{ - for(int i = 0; i < topctrl.GetCount(); i++) { - TopWindow *w = dynamic_cast(topctrl[i]); - if(w) - w->SyncRect(); - } -} - -bool Ctrl::ProcessEvent(bool *quit) -{ - LLOG("@ ProcessEvent"); - ASSERT(IsMainThread()); - if(!GetMouseLeft() && !GetMouseRight() && !GetMouseMiddle()) - ReleaseCtrlCapture(); - if(FBProcessEvent(quit)) { - LLOG("FBProcesEvent returned true"); - SyncTopWindows(); - DefferedFocusSync(); - SyncCaret(); - return true; - } - return false; -} - -Rect Ctrl::GetClipBound(const Vector& inv, const Rect& r) -{ - Rect ri = Null; - for(int j = 0; j < inv.GetCount(); j++) { - Rect rr = inv[j] & r; - if(!rr.IsEmpty()) - ri = IsNull(ri) ? rr : rr | ri; - } - return ri; -} - - -ViewDraw::ViewDraw(Ctrl *ctrl) -{ - if(Ctrl::invalid.GetCount()) - Ctrl::DoPaint(); - Ctrl::invalid.Clear(); - Ctrl::RemoveCursor(); - Ctrl::RemoveCaret(); - Rect r = ctrl->GetScreenView(); - Ctrl::invalid.Add(r); - Ctrl::AddUpdate(r); - for(int i = max(ctrl->GetTopCtrl()->FindTopCtrl() + 1, 0); i < Ctrl::topctrl.GetCount(); i++) { - Rect rr = Ctrl::topctrl[i]->GetScreenRect(); - ExcludeClip(rr); - Subtract(Ctrl::invalid, rr); - } - Offset(r.TopLeft()); -} - -ViewDraw::~ViewDraw() -{ - FBInitUpdate(); - Ctrl::DoUpdate(); - FBFlush(); -// Ctrl::invalid.Clear(); -} - -void Ctrl::DoUpdate() -{ - LLOG("DoUpdate"); - invalid.Clear(); - CursorSync(); - LDUMPC(update); -#if 0 - FBUpdate(framebuffer.GetSize()); -#else - for(int i = 0; i < update.GetCount(); i++) { - LDUMP(update[i]); - FBUpdate(update[i]); - } -#endif - update.Clear(); -// Sleep(1000); -} - -Vector Ctrl::GetPaintRects() -{ - Vector r; - int q = FindTopCtrl(); - r.Add(GetScreenRect()); - for(int i = max(FindTopCtrl() + 1, 0); i < topctrl.GetCount(); i++) - Subtract(r, topctrl[i]->GetScreenRect()); - return r; -} - - -void DDRect(RGBA *t, int dir, const byte *pattern, int pos, int count) -{ - while(count-- > 0) { - byte p = pattern[7 & pos++]; - t->r ^= p; - t->g ^= p; - t->b ^= p; - t += dir; - } -} - -void Ctrl::DrawLine(const Vector& clip, int x, int y, int cx, int cy, bool horz, const byte *pattern, int animation) -{ - if(cx <= 0 || cy <= 0) - return; - Vector rr = Intersection(clip, RectC(x, y, cx, cy)); - for(int i = 0; i < rr.GetCount(); i++) { - Rect r = rr[i]; - AddUpdate(r); - if(horz) - for(int y = r.top; y < r.bottom; y++) - DDRect(framebuffer[y] + r.left, 1, pattern, r.left + animation, r.GetWidth()); - else - for(int x = r.left; x < r.right; x++) - DDRect(framebuffer[r.top] + x, framebuffer.GetWidth(), pattern, r.top + animation, r.GetHeight()); - } -} - -void Ctrl::DragRectDraw0(const Vector& clip, const Rect& rect, int n, const byte *pattern, int animation) -{ - int hn = min(rect.GetHeight(), n); - int vn = min(rect.GetWidth(), n); - DrawLine(clip, rect.left, rect.top, rect.GetWidth(), hn, true, pattern, animation); - DrawLine(clip, rect.left, rect.top + hn, vn, rect.GetHeight() - hn, false, pattern, animation); - DrawLine(clip, rect.right - vn, rect.top + hn, vn, rect.GetHeight() - hn, false, pattern, animation); - DrawLine(clip, rect.left + vn, rect.bottom - hn, rect.GetWidth() - 2 * vn, hn, true, pattern, animation); -} - -void Ctrl::DragRectDraw(const Rect& rect1, const Rect& rect2, const Rect& clip, int n, - Color color, int type, int animation) -{ - static byte solid[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - static byte normal[] = { 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00 }; - static byte dashed[] = { 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }; - Point p = GetScreenView().TopLeft(); - Vector pr; - if(type & DRAWDRAGRECT_SCREEN) { - pr.Add(Rect(framebuffer.GetSize())); - type &= ~DRAWDRAGRECT_SCREEN; - p = Point(0, 0); - } - else - pr = Intersection(GetPaintRects(), clip.Offseted(p)); - const byte *pattern = type == DRAWDRAGRECT_DASHED ? dashed : - type == DRAWDRAGRECT_NORMAL ? normal : solid; - RemoveCursor(); - RemoveCaret(); - DragRectDraw0(pr, rect1.Offseted(p), n, pattern, animation); - DragRectDraw0(pr, rect2.Offseted(p), n, pattern, animation); -} - -void Ctrl::DoPaint() -{ - LLOG("@ DoPaint"); - if(!PaintLock) { - bool scroll = false; - if(desktop) - desktop->SyncScroll(); - for(int i = 0; i < topctrl.GetCount(); i++) - topctrl[i]->SyncScroll(); - if((invalid.GetCount() || scroll) && desktop) { - RemoveCursor(); - RemoveCaret(); - for(int phase = 0; phase < 2; phase++) { - LLOG("DoPaint invalid phase " << phase); - LDUMPC(invalid); - SystemDraw painter; - painter.Begin(); - for(int i = 0; i < invalid.GetCount(); i++) { - painter.RectPath(invalid[i]); - AddUpdate(invalid[i]); - } - painter.Painter::Clip(); - for(int i = topctrl.GetCount() - 1; i >= 0; i--) { - Rect r = topctrl[i]->GetRect(); - Rect ri = GetClipBound(invalid, r); - if(!IsNull(ri)) { - painter.Clipoff(r); - topctrl[i]->UpdateArea(painter, ri - r.TopLeft()); - painter.End(); - Subtract(invalid, r); - painter.ExcludeClip(r); - } - } - Rect ri = GetClipBound(invalid, framebuffer.GetSize()); - if(!IsNull(ri)) - desktop->UpdateArea(painter, ri); - } - } - } - DoUpdate(); -} - -void Ctrl::WndUpdate0r(const Rect& r) -{ - GuiLock __; - Rect rr = r + GetRect().TopLeft(); - bool dummy; - Vector h; - h <<= invalid; - invalid = Intersect(invalid, rr, dummy); - FBInitUpdate(); - DoPaint(); - invalid <<= h; - Subtract(invalid, rr); - FBFlush(); -} - -bool Ctrl::ProcessEvents(bool *quit) -{ - //LOGBLOCK("@ ProcessEvents"); -// MemoryCheckDebug(); - if(!ProcessEvent(quit)) - return false; - while(ProcessEvent(quit) && (!LoopCtrl || LoopCtrl->InLoop())); - TimeStop tm; - TimerProc(GetTickCount()); - LLOG("TimerProc elapsed: " << tm); - SweepMkImageCache(); - FBInitUpdate(); - DoPaint(); - FBFlush(); - return true; -} - -void Ctrl::EventLoop0(Ctrl *ctrl) -{ - GuiLock __; - ASSERT(IsMainThread()); - ASSERT(LoopLevel == 0 || ctrl); - LoopLevel++; - LLOG("Entering event loop at level " << LoopLevel << LOG_BEGIN); - Ptr ploop; - if(ctrl) { - ploop = LoopCtrl; - LoopCtrl = ctrl; - ctrl->inloop = true; - } - - bool quit = false; - int64 loopno = ++EventLoopNo; - ProcessEvents(&quit); - while(loopno > EndSessionLoopNo && !quit && (ctrl ? ctrl->IsOpen() && ctrl->InLoop() : GetTopCtrls().GetCount())) - { -// LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / GuiSleep"); - SyncCaret(); - GuiSleep(20); -// LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / ProcessEvents"); - ProcessEvents(&quit); -// LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / after ProcessEvents"); - LDUMP(loopno); - LDUMP(fbEndSessionLoop); - } - - if(ctrl) - LoopCtrl = ploop; - LoopLevel--; - LLOG(LOG_END << "Leaving event loop "); -} - -void Ctrl::GuiSleep0(int ms) -{ - GuiLock __; - ASSERT(IsMainThread()); - LLOG("GuiSleep"); - int level = LeaveGuiMutexAll(); - FBSleep(ms); - EnterGuiMutex(level); -} - -Rect Ctrl::GetWndScreenRect() const -{ - GuiLock __; - return GetRect(); -} - -void Ctrl::WndShow0(bool b) -{ - GuiLock __; -} - -void Ctrl::WndUpdate0() -{ - GuiLock __; -} - -bool Ctrl::IsWndOpen() const { - GuiLock __; - return FindTopCtrl() >= 0 || this == desktop; -} - -void Ctrl::SetAlpha(byte alpha) -{ - GuiLock __; -} - -Rect Ctrl::GetWorkArea() const -{ - GuiLock __; - return framebuffer.GetSize(); -} - -void Ctrl::GetWorkArea(Array& rc) -{ - GuiLock __; - Array r; - r.Add(framebuffer.GetSize()); -} - -Rect Ctrl::GetVirtualWorkArea() -{ - return framebuffer.GetSize(); -} - -Rect Ctrl::GetWorkArea(Point pt) -{ - return framebuffer.GetSize(); -} - -Rect Ctrl::GetVirtualScreenArea() -{ - GuiLock __; - return framebuffer.GetSize(); -} - -Rect Ctrl::GetPrimaryWorkArea() -{ - Rect r; - return framebuffer.GetSize(); -} - -Rect Ctrl::GetPrimaryScreenArea() -{ - return framebuffer.GetSize(); -} - -int Ctrl::GetKbdDelay() -{ - GuiLock __; - return 500; -} - -int Ctrl::GetKbdSpeed() -{ - GuiLock __; - return 1000 / 32; -} - -void Ctrl::DestroyWnd() -{ - for(int i = 0; i < topctrl.GetCount(); i++) - if(topctrl[i]->top && topctrl[i]->top->owner_window == this) - topctrl[i]->WndDestroy0(); - int q = FindTopCtrl(); - if(q >= 0) { - AddInvalid(GetRect()); - topctrl.Remove(q); - } - if(top) { - delete top; - top = NULL; - } - isopen = false; - TopWindow *win = dynamic_cast(this); - if(win) - win->DestroyFrame(); -} - -void Ctrl::WndDestroy0() -{ - DestroyWnd(); - if(topctrl.GetCount()) - topctrl.Top()->ActivateWnd(); -} - -void Ctrl::PutForeground() -{ - int q = FindTopCtrl(); - if(q >= 0) { - AddInvalid(GetRect()); - topctrl.Remove(q); - topctrl.Add(this); - } - Vector< Ptr > fw; - for(int i = 0; i < topctrl.GetCount(); i++) - if(topctrl[i] && topctrl[i]->top && topctrl[i]->top->owner_window == this && topctrl[i] != this) - fw.Add(topctrl[i]); - for(int i = 0; i < fw.GetCount(); i++) - if(fw[i]) - fw[i]->PutForeground(); -} - -void Ctrl::SetWndForeground0() -{ - GuiLock __; - ASSERT(IsOpen()); - if(IsWndForeground()) - return; - Ctrl *to = this; - while(to->top && to->top->owner_window) - to = to->top->owner_window; - to->PutForeground(); - if(this != focusCtrl) - ActivateWnd(); -} - -bool Ctrl::IsWndForeground() const -{ - GuiLock __; - bool b = false; - for(int i = 0; i < topctrl.GetCount(); i++) { - const TopWindow *tw = dynamic_cast(topctrl[i]); - if(tw) - b = tw == this; - } - return b; -} - -void Ctrl::WndEnable0(bool *b) -{ - GuiLock __; - *b = true; -} - -void Ctrl::SetWndFocus0(bool *b) -{ - GuiLock __; - *b = true; -} - -bool Ctrl::HasWndFocus() const -{ - GuiLock __; - return focusCtrl && focusCtrl->GetTopCtrl() == this; -} - -bool Ctrl::SetWndCapture() -{ - GuiLock __; - ASSERT(IsMainThread()); - return true; -} - -bool Ctrl::ReleaseWndCapture() -{ - GuiLock __; - ASSERT(IsMainThread()); - return true; -} - -bool Ctrl::HasWndCapture() const -{ - GuiLock __; - return captureCtrl && captureCtrl->GetTopCtrl() == this; -} - -void Ctrl::WndInvalidateRect(const Rect& r) -{ - GuiLock __; - int q = FindTopCtrl(); - if(q >= 0) - AddInvalid(r + topctrl[q]->GetRect().TopLeft()); - else - AddInvalid(r); -} - -void Ctrl::WndSetPos0(const Rect& rect) -{ - GuiLock __; - TopWindow *w = dynamic_cast(this); - if(w) - w->SyncFrameRect(rect); - invalid.Add(GetRect()); - SetWndRect(rect); - invalid.Add(rect); -} - -void Ctrl::WndScrollView0(const Rect& r, int dx, int dy) -{ - GuiLock __; - if(dx == 0 && dy == 0) - return; - if(dx && dy) { - Refresh(r); - return; - } - RemoveCursor(); - RemoveCaret(); - Rect sr = r.Offseted(GetScreenRect().TopLeft()); - Vector pr = Intersection(GetPaintRects(), sr); - for(int i = 0; i < pr.GetCount(); i++) { - Rect r = pr[i]; - if(dx) { - int n = r.GetWidth() - abs(dx); - if(n > 0) { - int to = r.left + dx * (dx > 0); - int from = r.left - dx * (dx < 0); - for(int y = r.top; y < r.bottom; y++) - memmove(framebuffer[y] + to, framebuffer[y] + from, n * sizeof(RGBA)); - } - n = min(abs(dx), r.GetWidth()); - Refresh(dx < 0 ? r.left : r.right - n, r.top, n, r.GetHeight()); - } - else { - int n = r.GetHeight() - abs(dy); - for(int y = 0; y < n; y++) - memmove(framebuffer[dy < 0 ? r.top + y : r.bottom - 1 - y] + r.left, - framebuffer[dy < 0 ? r.top + y - dy : r.bottom - 1 - y - dy] + r.left, - r.GetWidth() * sizeof(RGBA)); - n = min(abs(dy), r.GetHeight()); - Refresh(r.left, dy < 0 ? r.bottom - n : r.top, r.GetWidth(), n); - } - } - - Vector ur; - for(int i = 0; i < invalid.GetCount(); i++) - if(invalid[i].Intersects(sr)) - ur.Add(invalid[i]); - for(int i = 0; i < ur.GetCount(); i++) - AddInvalid(ur[i].Offseted(dx, dy)); -} - -void Ctrl::PopUp(Ctrl *owner, bool savebits, bool activate, bool dropshadow, bool topmost) -{ - ASSERT(!IsChild() && !IsOpen() && FindTopCtrl() < 0); - NewTop(); - if(owner) { - Ctrl *owner_window = owner->GetTopWindow(); - if(!owner_window) - owner_window = owner->GetTopCtrl(); - ASSERT(owner_window->IsOpen()); - if(owner_window != desktop) { - owner_window->SetForeground(); - top->owner_window = owner_window; - } - } - topctrl.Add(this); - popup = isopen = true; - RefreshLayoutDeep(); - if(activate) SetFocusWnd(); - AddInvalid(GetRect()); -} - -Rect Ctrl::GetDefaultWindowRect() { - GuiLock __; - static int ii = 0; - Size sz = framebuffer.GetSize(); - Rect rect = framebuffer.GetSize(); - rect.Deflate(sz / 10); - rect.Offset(Size(GetStdFontCy(), 2 * GetStdFontCy()) * (++ii % 8)); - return rect; -} - -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/reference/Layouts/layoutfile1.lay b/reference/Layouts/layoutfile1.lay index b03461c5b..982123638 100644 --- a/reference/Layouts/layoutfile1.lay +++ b/reference/Layouts/layoutfile1.lay @@ -1,9 +1,9 @@ LAYOUT(FirstTabLayout, 400, 200) - ITEM(Label, dv___0, SetLabel(t_("This is first layout")).LeftPosZ(12, 124).TopPosZ(8, 21)) - ITEM(Button, dialog, SetLabel(t_("Push to invoke dialog")).LeftPosZ(12, 128).TopPosZ(40, 24)) + ITEM(Upp::Label, dv___0, SetLabel(t_("This is first layout")).LeftPosZ(12, 124).TopPosZ(8, 21)) + ITEM(Upp::Button, dialog, SetLabel(t_("Push to invoke dialog")).LeftPosZ(12, 128).TopPosZ(40, 24)) END_LAYOUT LAYOUT(SecondTabLayout, 400, 200) - ITEM(Label, dv___0, SetLabel(t_("This is second layout")).LeftPosZ(12, 124).TopPosZ(8, 21)) + ITEM(Upp::Label, dv___0, SetLabel(t_("This is second layout")).LeftPosZ(12, 124).TopPosZ(8, 21)) END_LAYOUT diff --git a/reference/Layouts/main.cpp b/reference/Layouts/main.cpp index 5123abc2e..366416196 100644 --- a/reference/Layouts/main.cpp +++ b/reference/Layouts/main.cpp @@ -44,7 +44,7 @@ MainDlg::MainDlg() tabs.Add(tab1.SizePos(), "Tab1"); // SizePos() means dialog fills the whole are of tab tabs.Add(tab2.SizePos(), "Tab2"); - tab1.dialog <<= THISBACK(DoDialog); // When pushing 'dialog' button, DoDialog is invoked + tab1.dialog << [=] { DoDialog(); }; // When pushing 'dialog' button, DoDialog is invoked } GUI_APP_MAIN diff --git a/reference/MenuBarCheck/main.cpp b/reference/MenuBarCheck/main.cpp index 3ff635b79..dd9d73994 100644 --- a/reference/MenuBarCheck/main.cpp +++ b/reference/MenuBarCheck/main.cpp @@ -5,19 +5,13 @@ using namespace Upp; struct MyApp : TopWindow { typedef MyApp CLASSNAME; - bool check; - - void Check() { check = !check; } + bool check = false; void RightDown(Point p, dword) { MenuBar bar; - bar.Add("Check", THISBACK(Check)).Check(check); + bar.Add("Check", [=] { check = !check; }).Check(check); bar.Execute(); } - - MyApp() { - check = false; - } }; GUI_APP_MAIN diff --git a/reference/RegExp2/main.cpp b/reference/RegExp2/main.cpp index 004037ee8..e0a312930 100644 --- a/reference/RegExp2/main.cpp +++ b/reference/RegExp2/main.cpp @@ -12,11 +12,9 @@ class mainwindowDlg : public Withmainwindow { public: mainwindowDlg(); void RunRegExp(); - void clear_output(){t4.Clear();} - void d1_callback(){ Set_Examples((int)d1.GetData()); } void Set_Examples(int i); - void match_callback_fun(Vector& v){ + void match_callback_fun(Vector& v) { for(int i=0, i1=v.GetCount(); i -#include - -using namespace Upp; - -#define IMAGECLASS UWordImg -#define IMAGEFILE -#include - -FileSel& UWordFs() -{ - static FileSel fs; - return fs; -} - -FileSel& PdfFs() -{ - static FileSel fs; - return fs; -} - -class UWord : public TopWindow { -public: - virtual void DragAndDrop(Point, PasteClip& d); - virtual void FrameDragAndDrop(Point, PasteClip& d); - - virtual void ShutdownWindow(); - -protected: - RichEdit editor; - MenuBar menubar; - ToolBar toolbar; - StatusBar statusbar; - String filename; - - static LRUList& lrufile() { static LRUList l; return l; } - - void Load(const String& filename); - void OpenFile(const String& fn); - void New(); - void Open(); - void Save0(); - void Save(); - void SaveAs(); - void Print(); - void Pdf(); - void About(); - void Destroy(bool shutdown); - void SetBar(); - void FileBar(Bar& bar); - void AboutMenu(Bar& bar); - void MainMenu(Bar& bar); - void MainBar(Bar& bar); - -public: - typedef UWord CLASSNAME; - - static void SerializeApp(Stream& s); - - UWord(); -}; - -void UWord::FileBar(Bar& bar) -{ - bar.Add("New", CtrlImg::new_doc(), THISBACK(New)) - .Key(K_CTRL_N) - .Help("Open new window"); - bar.Add("Open..", CtrlImg::open(), THISBACK(Open)) - .Key(K_CTRL_O) - .Help("Open existing document"); - bar.Add(editor.IsModified(), "Save", CtrlImg::save(), THISBACK(Save)) - .Key(K_CTRL_S) - .Help("Save current document"); - bar.Add("SaveAs", CtrlImg::save_as(), THISBACK(SaveAs)) - .Help("Save current document with a new name"); - bar.ToolGap(); - bar.MenuSeparator(); - bar.Add("Print..", CtrlImg::print(), THISBACK(Print)) - .Key(K_CTRL_P) - .Help("Print document"); - bar.Add("Export to PDF..", UWordImg::pdf(), THISBACK(Pdf)) - .Help("Export document to PDF file"); - if(bar.IsMenuBar()) { - if(lrufile().GetCount()) - lrufile()(bar, THISBACK(OpenFile)); - bar.Separator(); - bar.Add("Exit", THISBACK1(Destroy, false)); - } -} - -void UWord::AboutMenu(Bar& bar) -{ - bar.Add("About..", THISBACK(About)); -} - -void UWord::MainMenu(Bar& bar) -{ - bar.Add("File", THISBACK(FileBar)); - bar.Add("Window", callback(WindowsMenu)); - bar.Add("Help", THISBACK(AboutMenu)); -} - -void UWord::New() -{ - new UWord; -} - -void UWord::Load(const String& name) -{ - lrufile().NewEntry(name); - editor.SetQTF(LoadFile(name)); - filename = name; - editor.ClearModify(); - Title(filename); -} - -void UWord::OpenFile(const String& fn) -{ - if(filename.IsEmpty() && !editor.IsModified()) - Load(fn); - else - (new UWord)->Load(fn); -} - -void UWord::Open() -{ - FileSel& fs = UWordFs(); - if(fs.ExecuteOpen()) - OpenFile(fs); - else - statusbar.Temporary("Loading aborted."); -} - -void UWord::DragAndDrop(Point, PasteClip& d) -{ - if(AcceptFiles(d)) { - Vector fn = GetFiles(d); - for(int i = 0; i < fn.GetCount(); i++) - if(FileExists(fn[i])) - OpenFile(fn[i]); - } -} - -void UWord::FrameDragAndDrop(Point p, PasteClip& d) -{ - DragAndDrop(p, d); -} - -void UWord::Save0() -{ - lrufile().NewEntry(filename); - if(filename.IsEmpty()) - SaveAs(); - else - if(SaveFile(filename, editor.GetQTF())) { - statusbar.Temporary("File " + filename + " was saved."); - ClearModify(); - } - else - Exclamation("Error saving the file [* " + DeQtf(filename) + "]!"); -} - -void UWord::Save() -{ - if(!editor.IsModified()) return; - Save0(); -} - -void UWord::SaveAs() -{ - FileSel& fs = UWordFs(); - if(fs.ExecuteSaveAs()) { - filename = fs; - Title(filename); - Save0(); - } -} - -void UWord::Print() -{ - editor.Print(); -} - -void UWord::Pdf() -{ - FileSel& fs = PdfFs(); - if(!fs.ExecuteSaveAs("Output PDF file")) - return; - Size page = Size(3968, 6074); - PdfDraw pdf; - UPP::Print(pdf, editor.Get(), page); - SaveFile(~fs, pdf.Finish()); -} - -void UWord::About() -{ - PromptOK("[A5 uWord]&Using [*^www://upp.sf.net^ Ultimate`+`+] technology."); -} - -void UWord::Destroy(bool shutdown) -{ - if(editor.IsModified()) { - switch((shutdown ? PromptYesNo : PromptYesNoCancel)("Do you want to save the changes to the document?")) { - case 1: - Save(); - break; - case -1: - return; - } - } - delete this; -} - -void UWord::ShutdownWindow() -{ - Destroy(true); -} - -void UWord::MainBar(Bar& bar) -{ - FileBar(bar); - bar.Separator(); - editor.DefaultBar(bar); -} - -void UWord::SetBar() -{ - toolbar.Set(THISBACK(MainBar)); -} - -UWord::UWord() -{ - AddFrame(menubar); - AddFrame(TopSeparatorFrame()); - AddFrame(toolbar); - AddFrame(statusbar); - Add(editor.SizePos()); - menubar.Set(THISBACK(MainMenu)); - Sizeable().Zoomable(); - WhenClose = THISBACK1(Destroy, false); - menubar.WhenHelp = toolbar.WhenHelp = statusbar; - static int doc; - Title(Format("Document%d", ++doc)); - Icon(CtrlImg::File()); - editor.ClearModify(); - SetBar(); - editor.WhenRefreshBar = THISBACK(SetBar); - OpenMain(); - ActiveFocus(editor); -} - -void UWord::SerializeApp(Stream& s) -{ - int version = 1; - s / version; - s % UWordFs() - % PdfFs(); - if(version >= 1) - s % lrufile(); -} - -GUI_APP_MAIN -{ - SetLanguage(LNG_ENGLISH); - SetDefaultCharset(CHARSET_UTF8); - - UWordFs().Type("QTF files", "*.qtf") - .AllFilesType() - .DefaultExt("qtf"); - PdfFs().Type("PDF files", "*.pdf") - .AllFilesType() - .DefaultExt("pdf"); - - LoadFromFile(callback(UWord::SerializeApp)); - new UWord; - Ctrl::EventLoop(); - StoreToFile(callback(UWord::SerializeApp)); -} diff --git a/reference/UWord_FB/UWord.iml b/reference/UWord_FB/UWord.iml deleted file mode 100644 index c5087e8d2..000000000 --- a/reference/UWord_FB/UWord.iml +++ /dev/null @@ -1,10 +0,0 @@ -PREMULTIPLIED -IMAGE_ID(pdf) - -IMAGE_BEGIN_DATA -IMAGE_DATA(120,156,157,146,129,13,192,32,8,4,29,193,1,216,67,23,113,16,55,112,186,14,226,34,212,198,154,98,85,16,63,33) -IMAGE_DATA(132,196,227,5,53,214,88,195,8,149,49,240,184,25,75,190,41,198,122,118,81,179,188,247,237,80,205,0,125,173,245,255) -IMAGE_DATA(231,222,31,6,158,206,42,251,103,210,99,206,79,238,67,120,36,61,242,193,254,145,244,240,111,214,254,131,22,151,115,206) -IMAGE_DATA(227,134,86,254,185,232,128,255,230,223,208,99,193,238,95,96,161,188,39,251,254,2,27,66,144,255,31,195,166,148,150,188) -IMAGE_DATA(38,110,182,2,234,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) -IMAGE_END_DATA(160, 1) diff --git a/reference/UWord_FB/UWord_FB.upp b/reference/UWord_FB/UWord_FB.upp deleted file mode 100644 index 502db3f47..000000000 --- a/reference/UWord_FB/UWord_FB.upp +++ /dev/null @@ -1,21 +0,0 @@ -description "Rainbow example, Framebuffer implementation of UWord\377"; - -uses - CtrlLib, - RichEdit, - PdfDraw, - plugin\jpg; - -uses(WINFB) WinFb; - -uses(LINUXFB) LinuxFb; - -file - UWord.cpp, - UWord.iml; - -mainconfig - "" = "GUI WINFB", - "" = "GUI LINUXFB", - "" = "GUI"; - diff --git a/reference/UWord_FB/icon.ico b/reference/UWord_FB/icon.ico deleted file mode 100644 index 4012786aa..000000000 Binary files a/reference/UWord_FB/icon.ico and /dev/null differ diff --git a/uppsrc/Core/src.tpp/Function_en-us.tpp b/uppsrc/Core/src.tpp/Function_en-us.tpp index 37fa414c3..9d940fee9 100644 --- a/uppsrc/Core/src.tpp/Function_en-us.tpp +++ b/uppsrc/Core/src.tpp/Function_en-us.tpp @@ -91,8 +91,8 @@ es]_[* operator()]([*@4 ArgTypes][@(0.0.255) ...]_args)_[@(0.0.255) const]&] return `'void`' and those that return `'bool`'. U`+`+ defines two convenience template aliases:&] [s0;%- &] -[s5;:Upp`:`:Event`:`:typedef:%- [@(0.0.255) template - using]_[* Event]_`=_Function<[@(0.0.255) void]_(ArgTypes[@(0.0.255) ...])>&] +[s5;:Upp`:`:Event:%- [@(0.0.255) template +using]_[* Event]_`=_Function<[@(0.0.255) void]_(ArgTypes[@(0.0.255) ...])>&] [s2; Creates alias for Function returning void. For example, [*C@5 Event] is equivalent of [*C@5 Function].&] [s3;%- &] @@ -121,9 +121,18 @@ and THISFN serve to reduce typing overhead.&] [s2; Equivalent of std`::mem`_fn returning U`+`+ Function. Creates Function that represents calling [%-*@3 member`_function] of instance [%-*@3 object].&] -[s3; &] +[s3;%- &] [s4;%- &] -[s5;:THISFN`(x`):%- [* THISFN](x)&] -[s2; This macro is defined a MemFn(this, `&CLASSNAME`::x).&] +[s5;:THISFN:%- [* THISFN](x)&] +[s2; This macro is defined a MemFn(this, `&CLASSNAME`::x). It is a +useful shortcut for converting member method to Function. If +a class has member function&] +[s2; &] +[s2; [C void Menu(Bar`&);]&] +[s2; &] +[s2; then following two lines are equivalent:&] +[s2; &] +[s2; [C menu.Set(`[`=`] (Bar`& bar) `{ Menu(bar); `});]&] +[s2; [C menu.Set(THISFN(Menu));]&] [s3;%- &] [s0;@(0.0.255)3%- ]] \ No newline at end of file diff --git a/uppsrc/CtrlCore/Ctrl.cpp b/uppsrc/CtrlCore/Ctrl.cpp index 1f3a52fa0..a12f62292 100644 --- a/uppsrc/CtrlCore/Ctrl.cpp +++ b/uppsrc/CtrlCore/Ctrl.cpp @@ -954,7 +954,7 @@ void Ctrl::ReSkin() win->RefreshLayoutDeep(); win->DoSkin(); win->RefreshFrame(); -#ifdef PLATFORM_WIN32 +#ifdef GUI_WIN32 win->UseImmersiveDarkModeForWindowBorder(); #endif } diff --git a/uppsrc/DropGrid/DropGrid.cpp b/uppsrc/DropGrid/DropGrid.cpp index cfe3a6322..d0b8aa661 100644 --- a/uppsrc/DropGrid/DropGrid.cpp +++ b/uppsrc/DropGrid/DropGrid.cpp @@ -592,7 +592,7 @@ GridCtrl::ItemRect& DropGrid::AddIndex(Id id) return list.AddIndex(id); } -MultiButton::SubButton& DropGrid::AddButton(int type, const Callback &cb) +MultiButton::SubButton& DropGrid::AddButton(int type, const Event<> &cb) { MultiButton::SubButton& btn = drop.InsertButton(1); @@ -627,17 +627,17 @@ MultiButton::SubButton& DropGrid::AddButton(int type, const Callback &cb) return btn; } -MultiButton::SubButton& DropGrid::AddSelect(const Callback &cb) +MultiButton::SubButton& DropGrid::AddSelect(const Event<> &cb) { return AddButton(BTN_SELECT, cb); } -MultiButton::SubButton& DropGrid::AddPlus(const Callback &cb) +MultiButton::SubButton& DropGrid::AddPlus(const Event<> &cb) { return AddButton(BTN_PLUS, cb); } -MultiButton::SubButton& DropGrid::AddEdit(const Callback &cb) +MultiButton::SubButton& DropGrid::AddEdit(const Event<> &cb) { return AddButton(BTN_RIGHT, cb); } @@ -647,7 +647,7 @@ MultiButton::SubButton& DropGrid::AddClear() return AddButton(BTN_CLEAN, THISBACK(ClearValue)); } -MultiButton::SubButton& DropGrid::AddText(const char* label, const Callback& cb) +MultiButton::SubButton& DropGrid::AddText(const char* label, const Event<>& cb) { MultiButton::SubButton& btn = drop.InsertButton(1); btn.SetLabel(label); diff --git a/uppsrc/DropGrid/DropGrid.h b/uppsrc/DropGrid/DropGrid.h index cecdf0455..9db351c03 100644 --- a/uppsrc/DropGrid/DropGrid.h +++ b/uppsrc/DropGrid/DropGrid.h @@ -28,10 +28,10 @@ class DropGrid : public Convert, public GridDisplay, public Ctrl void CloseData(); public: - Callback WhenPopDown; - Callback WhenClose; - Callback WhenCloseData; - Callback WhenCloseNoData; + Event<> WhenPopDown; + Event<> WhenClose; + Event<> WhenCloseData; + Event<> WhenCloseNoData; typedef PopUpGrid CLASSNAME; @@ -129,12 +129,12 @@ class DropGrid : public Convert, public GridDisplay, public Ctrl GridCtrl::ItemRect& AddIndex(const char *name = ""); GridCtrl::ItemRect& AddIndex(Id id); - MultiButton::SubButton& AddButton(int type, const Callback &cb); - MultiButton::SubButton& AddSelect(const Callback &cb); - MultiButton::SubButton& AddPlus(const Callback &cb); - MultiButton::SubButton& AddEdit(const Callback &cb); + MultiButton::SubButton& AddButton(int type, const Event<> &cb); + MultiButton::SubButton& AddSelect(const Event<> &cb); + MultiButton::SubButton& AddPlus(const Event<> &cb); + MultiButton::SubButton& AddEdit(const Event<> &cb); MultiButton::SubButton& AddClear(); - MultiButton::SubButton& AddText(const char* label, const Callback& cb); + MultiButton::SubButton& AddText(const char* label, const Event<>& cb); MultiButton::SubButton& GetButton(int n); int AddColumns(int cnt); @@ -213,8 +213,8 @@ class DropGrid : public Convert, public GridDisplay, public Ctrl virtual Value Format(const Value& q) const; - Callback WhenLeftDown; - Callback WhenDrop; + Event<> WhenLeftDown; + Event<> WhenDrop; GridCtrl::ItemRect& AddRow(int n = 1, int size = -1); DropGrid& Add() { AddRow(); return *this; }