From ce2ed1a301005eaf5000a06c67db9dd549bdf0b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20R=C4=99bacz?= Date: Sun, 15 Feb 2026 11:19:40 +0100 Subject: [PATCH] Docking: fix all red formating warnings for DockCont and DockableCtrl. --- uppsrc/Docking/DockCont.cpp | 184 ++++++++++++------------- uppsrc/Docking/DockCont.h | 236 ++++++++++++++++---------------- uppsrc/Docking/DockableCtrl.cpp | 31 +++-- uppsrc/Docking/DockableCtrl.h | 110 +++++++-------- 4 files changed, 278 insertions(+), 283 deletions(-) diff --git a/uppsrc/Docking/DockCont.cpp b/uppsrc/Docking/DockCont.cpp index f67a6a2bd..2c188bd22 100644 --- a/uppsrc/Docking/DockCont.cpp +++ b/uppsrc/Docking/DockCont.cpp @@ -17,18 +17,12 @@ void ImgButton::Paint(Draw &w) } // DockContHandle frame -int DockCont::DockContHandle::GetHandleSize(const DockableCtrl::Style &s) const +int DockCont::DockContHandle::GetHandleSize(const DockableCtrl::Style& s) const { - return (IsNull(s.title_font) ? DPI(12) : s.title_font.GetCy() + DPI(2)) - + (s.handle_vert ? s.handle_margins.GetWidth() : s.handle_margins.GetHeight()); + return (IsNull(s.title_font) ? DPI(12) : s.title_font.GetCy() + DPI(2)) + + (s.handle_vert ? s.handle_margins.GetWidth() : s.handle_margins.GetHeight()); } -/* -void DockCont::DockContHandle::RefreshFocus(bool _focus) -{ - if (focus != _focus) - { focus = _focus; Refresh(); } -} -*/ + void DockCont::DockContHandle::FrameLayout(Rect& r) { if (!dc || !IsShown()) return; @@ -80,7 +74,7 @@ void DockCont::DockContHandle::Paint(Draw& w) p.x += isz + 2; } } - if (!IsNull(s.title_font)) { + if (!IsNull(s.title_font)) { Ctrl *c = GetLastChild(); while (c && !c->IsShown() && c->GetParent()) c = c->GetPrev(); @@ -93,7 +87,7 @@ void DockCont::DockContHandle::Paint(Draw& w) w.DrawText(p.x, p.y, s.handle_vert ? 900 : 0, text, s.title_font, s.title_ink[0/*focus*/]); w.End(); } - } + } } void DockCont::Layout() @@ -131,20 +125,20 @@ void DockCont::ChildRemoved(Ctrl *child) void DockCont::ChildAdded(Ctrl *child) { - if (child->GetParent() != this) + if (child->GetParent() != this) return; - else if (DockableCtrl *dc = dynamic_cast(child)) { + else if (DockableCtrl *dc = dynamic_cast(child)) { Value v = ValueCast(dc); tabbar.InsertKey(0, v, dc->GetTitle(), dc->GetIcon(), dc->GetGroup(), true); - } - else if (DockCont *dc = dynamic_cast(child)) { + } + else if (DockCont *dc = dynamic_cast(child)) { Value v = ValueCast(dc); tabbar.InsertKey(0, v, dc->GetTitle(), Null, Null, true); - } - else - return; + } + else + return; child->SizePos(); - TabSelected(); + TabSelected(); if (GetCount() >= 2) RefreshLayout(); } @@ -158,25 +152,25 @@ bool DockCont::Key(dword key, int count) // The use of Single<> here is bad form, but I am unable to declare it a // member in the header (dependencies) and I can't think of a better way void DockCont::MoveBegin() -{ +{ static bool in_move = false; - if (!in_move && !base->IsLocked()) { - in_move = true; - base->SaveDockerPos(GetCurrent(), Single()); - base->ContainerDragStart(*this); + if (!in_move && !base->IsLocked()) { + in_move = true; + base->SaveDockerPos(GetCurrent(), Single()); + base->ContainerDragStart(*this); in_move = false; - } + } } -void DockCont::Moving() { - if (!base->IsLocked()) base->ContainerDragMove(*this); +void DockCont::Moving() { + if (!base->IsLocked()) base->ContainerDragMove(*this); } -void DockCont::MoveEnd() { - if (!base->IsLocked()) { - SetAllDockerPos(); - base->ContainerDragEnd(*this); - } +void DockCont::MoveEnd() { + if (!base->IsLocked()) { + SetAllDockerPos(); + base->ContainerDragEnd(*this); + } } void DockCont::WindowMenu() @@ -192,7 +186,7 @@ void DockCont::WindowMenu() void DockCont::Animate(Rect target, int ticks, int interval) { if (!IsOpen() || GetParent()) return; - animating = true; + animating = true; Rect dr = GetRect(); target -= dr; #ifdef PLATFORM_WIN32 @@ -208,11 +202,11 @@ void DockCont::Animate(Rect target, int ticks, int interval) Sync(); ProcessEvents(); Sleep(interval); - } - animating = false; + } + animating = false; } -void DockCont::TabSelected() +void DockCont::TabSelected() { int ix = tabbar.GetCursor(); if (ix >= 0) { @@ -221,7 +215,7 @@ void DockCont::TabSelected() Ctrl *ctrl = GetCtrl(ix); for (Ctrl *c = FindFirstChild(); c; c = c->GetNext()) - if (c != ctrl && !c->InFrame()) + if (c != ctrl && !c->InFrame()) c->Hide(); ctrl->Show(); @@ -260,16 +254,17 @@ void DockCont::TabDragged(int ix) c->Remove(); base->FloatFromTab(*this, *c); } - if (tabbar.IsAutoHide()) - RefreshLayout(); + if (tabbar.IsAutoHide()) + RefreshLayout(); } } void DockCont::TabContext(int ix) { - MenuBar bar; - DockContMenu menu(base); - DockMenu tabmenu(base); + MenuBar bar; + DockContMenu menu(base); + DockMenu tabmenu(base); + if (ix >= 0) { Value v = tabbar.GetKey(ix); if (IsDockCont(v)) @@ -296,7 +291,7 @@ void DockCont::TabClosed0(Value v) DockableCtrl *c = DockCast(v); base->SaveDockerPos(*c); c->Remove(); - c->WhenState(); + c->WhenState(); } waitsync = true; } @@ -305,7 +300,7 @@ void DockCont::TabClosed(Value v) { TabClosed0(v); Layout(); - if (tabbar.GetCount() == 1) + if (tabbar.GetCount() == 1) RefreshLayout(); } @@ -314,8 +309,8 @@ void DockCont::TabsClosed(ValueArray vv) for (int i = vv.GetCount()-1; i >= 0 ; --i) TabClosed0(vv[i]); Layout(); - if (tabbar.GetCount() == 1) - RefreshLayout(); + if (tabbar.GetCount() == 1) + RefreshLayout(); } void DockCont::SortTabs(bool b) @@ -365,10 +360,10 @@ void DockCont::AutoHideAlign(int align) if (IsAutoHide()) { if (align == DockWindow::DOCK_NONE) base->FloatContainer(*this, Null, false); - else - base->DockContainer(align, *this); + else + base->DockContainer(align, *this); } - else + else base->AutoHideContainer((align == DockWindow::DOCK_NONE) ? DockWindow::DOCK_TOP : align, *this); } @@ -385,8 +380,8 @@ void DockCont::AddFrom(DockCont& cont, int except) if (i != except) { Ctrl *c = cont.GetCtrl(i); c->Remove(); - Add(*c); - } + Add(*c); + } if (all) cont.tabbar.Clear(); SignalStateChange(ix, GetCount()-1); @@ -395,8 +390,8 @@ void DockCont::AddFrom(DockCont& cont, int except) void DockCont::Clear() { if (tabbar.GetCount()) { - // Copy tabbar values and clear to prevent this being called multple times if child - // if destroyed on closing. pfft + // Copy tabbar values and clear to prevent this being called multple times if child + // if destroyed on closing. pfft Vector v; v.SetCount(tabbar.GetCount()); for (int i = 0; i < tabbar.GetCount(); i++) @@ -404,7 +399,7 @@ void DockCont::Clear() tabbar.Clear(); // Remove ctrls and signal correct state change for (int i = 0; i < v.GetCount(); i++) { - if (IsDockCont(v[i])) { + if (IsDockCont(v[i])) { DockCont *dc = ContCast(v[i]); dc->Remove(); dc->State(*base, STATE_NONE); @@ -414,7 +409,7 @@ void DockCont::Clear() dc->Remove(); dc->WhenState(); } - } + } } handle.dc = NULL; @@ -423,10 +418,10 @@ void DockCont::Clear() void DockCont::State(DockWindow& dock, DockCont::DockState state) { base = &dock; - dockstate = state; + dockstate = state; SyncFrames(); SyncButtons(); - Show(); + Show(); SignalStateChange(); } @@ -456,7 +451,7 @@ void DockCont::SyncButtons(DockableCtrl& dc) Logc& inc = s.handle_vert ? lp.y : lp.x; lp.x = s.handle_vert ? Ctrl::Logc(ALIGN_LEFT, 1, btnsize) : Ctrl::Logc(ALIGN_RIGHT, 1, btnsize); - lp.y = Ctrl::Logc(ALIGN_TOP, 1, btnsize); + lp.y = Ctrl::Logc(ALIGN_TOP, 1, btnsize); if (close.GetParent()) { close.SetLook(s.close).SetPos(lp).Show(); @@ -466,7 +461,7 @@ void DockCont::SyncButtons(DockableCtrl& dc) autohide.Show(ah); if (ah && autohide.GetParent()) { autohide.SetLook(IsAutoHide() ? s.pin : s.autohide).SetPos(lp); - inc.SetA(inc.GetA() + btnsize + 1); + inc.SetA(inc.GetA() + btnsize + 1); } if (windowpos.GetParent()) windowpos.SetLook(s.windowpos).SetPos(lp).Show(); @@ -494,7 +489,7 @@ Ctrl * DockCont::FindFirstChild() const void DockCont::SetCursor(Ctrl& c) { - for (int i = 0; i < GetCount(); i++) + for (int i = 0; i < GetCount(); i++) if (GetCtrl(i) == &c) return SetCursor(i); } @@ -525,7 +520,7 @@ void DockCont::GetGroups(Vector& groups) } if (!found) groups.Add(g); - } + } } } } @@ -560,16 +555,16 @@ void DockCont::WindowButtons(bool menu, bool hide, bool _close) void DockCont::AddRemoveButton(Ctrl& c, bool state) { - if (state && !c.GetParent()) - handle.Add(c); - else if (!state) - c.Remove(); + if (state && !c.GetParent()) + handle.Add(c); + else if (!state) + c.Remove(); } void DockCont::Highlight() { if (!GetCount() || (!IsOpen() && !IsPopUp() && !GetParent())) return; - ViewDraw v(this); + ViewDraw v(this); ChPaint(v, GetSize(), GetCurrent().GetStyle().highlight[1]); } @@ -592,7 +587,7 @@ Image DockCont::GetHighlightImage() Size DockCont::GetMinSize() const { if (animating) return Size(0, 0); - Size sz = tabbar.GetCount() ? GetCurrent().GetMinSize() : Size(0, 0); + Size sz = tabbar.GetCount() ? GetCurrent().GetMinSize() : Size(0, 0); sz = AddFrameSize(sz); return sz; } @@ -623,12 +618,12 @@ void DockCont::SyncUserSize(bool h, bool v) int DockCont::GetDockAlign() const { - return base->GetDockAlign(*this); + return base->GetDockAlign(*this); } int DockCont::GetAutoHideAlign() const { - return base->GetAutoHideAlign(*this); + return base->GetAutoHideAlign(*this); } bool DockCont::IsDockAllowed(int align, int dc_ix) const @@ -647,17 +642,18 @@ bool DockCont::IsDockAllowed0(int align, const Value& v) const } DockableCtrl * DockCont::Get0(int ix) const -{ +{ if (ix < 0 || ix > tabbar.GetCount()) return NULL; - Value v = tabbar.GetKey(ix); - return IsDockCont(v) ? ContCast(v)->GetCurrent0() : DockCast(v); + Value v = tabbar.GetKey(ix); + return IsDockCont(v) ? ContCast(v)->GetCurrent0() : DockCast(v); } WString DockCont::GetTitle(bool force_count) const { - if ((IsTabbed() || force_count) && tabbar.GetCount() > 1) - return (WString)Format("%s (%d/%d)", GetCurrent().GetTitle(), tabbar.GetCursor()+1, tabbar.GetCount()); - return GetCurrent().GetTitle(); + if((IsTabbed() || force_count) && tabbar.GetCount() > 1) + return (WString)Format("%s (%d/%d)", GetCurrent().GetTitle(), tabbar.GetCursor() + 1, + tabbar.GetCount()); + return GetCurrent().GetTitle(); } void DockCont::ChildTitleChanged(DockableCtrl &dc) @@ -677,7 +673,7 @@ void DockCont::ChildTitleChanged(Ctrl *child, WString title, Image icon) tabbar.Set(i, tabbar.GetKey(i), title, icon); break; } - if (!GetParent()) + if (!GetParent()) Title(GetTitle()); RefreshFrame(); } @@ -688,7 +684,7 @@ void DockCont::Serialize(Stream& s) int cont = 'C'; const Vector& dcs = base->GetDockableCtrls(); - if (s.IsStoring()) { + if (s.IsStoring()) { if (GetCount() == 1 && IsDockCont(tabbar.GetKey(0))) return ContCast(tabbar.GetKey(0))->Serialize(s); @@ -700,8 +696,8 @@ void DockCont::Serialize(Stream& s) else { DockableCtrl *dc = DockCast(tabbar.GetKey(i)); int ix = base->FindDocker(dc); - s / ctrl / ix; - } + s / ctrl / ix; + } } int cursor = tabbar.GetCursor(); int groupix = tabbar.GetGroup(); @@ -729,14 +725,14 @@ void DockCont::Serialize(Stream& s) Add(*dcs[ix]); } else - ASSERT(false); + ASSERT(false); } int cursor, groupix; s / cursor / groupix; tabbar.SetGroup(groupix); tabbar.SetCursor(min(tabbar.GetCount()-1, cursor)); TabSelected(); - } + } } void DockCont::DockContMenu::ContainerMenu(Bar& bar, DockCont *c, bool withgroups) { @@ -747,7 +743,7 @@ void DockCont::DockContMenu::ContainerMenu(Bar& bar, DockCont *c, bool withgroup withgroups = false; // If grouping, find all groups - DockMenu::WindowMenu(bar, dc); + DockMenu::WindowMenu(bar, dc); if (withgroups && dock->IsGrouping()) { Vector groups; cont->GetGroups(groups); @@ -756,7 +752,7 @@ void DockCont::DockContMenu::ContainerMenu(Bar& bar, DockCont *c, bool withgroup Sort(groups); for (int i = 0; i < groups.GetCount(); i++) bar.Add(groups[i], THISBACK1(GroupWindowsMenu, groups[i])); - bar.Add(t_("All"), THISBACK1(GroupWindowsMenu, String(Null))); + bar.Add(t_("All"), THISBACK1(GroupWindowsMenu, String(Null))); } } } @@ -784,8 +780,8 @@ void DockCont::DockContMenu::MenuClose(DockableCtrl *dc) void DockCont::Lock(bool lock) { tabbar.Crosses(!lock && base && base->HasCloseButtons()); - tabbar.WhenDrag = lock ? Callback1() : THISBACK(TabDragged); - tabbar.WhenContext = lock ? Callback1() : THISBACK(TabContext); + tabbar.WhenDrag = lock ? Callback1() : THISBACK(TabDragged); + tabbar.WhenContext = lock ? Callback1() : THISBACK(TabContext); SyncFrames(lock && !base->IsShowingLockedHandles()); RefreshLayout(); } @@ -801,7 +797,7 @@ void DockCont::SyncFrames(bool hidehandle) handle.Show(frames); if (frames) SetFrame(0, Single()); - else + else SetFrame(0, NullFrame()); } @@ -809,7 +805,7 @@ DockCont::DockCont() { dockstate = STATE_NONE; base = NULL; - waitsync = false; + waitsync = false; animating = false; usersize.cx = usersize.cy = Null; NoCenter(); @@ -821,7 +817,7 @@ DockCont::DockCont() tabbar<<= THISBACK(TabSelected); tabbar.WhenClose = THISBACK(TabClosed); tabbar.WhenCloseSome = THISBACK(TabsClosed); - tabbar.SetBottom(); + tabbar.SetBottom(); WhenClose = THISBACK(CloseAll); @@ -829,15 +825,15 @@ DockCont::DockCont() handle.WhenContext = THISBACK(WindowMenu); handle.WhenLeftDrag = THISBACK(MoveBegin); handle.WhenLeftDouble = THISBACK(RestoreCurrent); - close.Tip(t_("Close")) <<= THISBACK(CloseAll); - autohide.Tip(t_("Auto-Hide")) <<= THISBACK(AutoHide); - windowpos.Tip(t_("Window Menu")) <<= THISBACK(WindowMenu); - + close.Tip(t_("Close")) <<= THISBACK(CloseAll); + autohide.Tip(t_("Auto-Hide")) <<= THISBACK(AutoHide); + windowpos.Tip(t_("Window Menu")) <<= THISBACK(WindowMenu); + AddFrame(NullFrame()); AddFrame(tabbar); AddFrame(handle); - Lock(false); + Lock(false); } } diff --git a/uppsrc/Docking/DockCont.h b/uppsrc/Docking/DockCont.h index 92636f4f5..61efcec9a 100644 --- a/uppsrc/Docking/DockCont.h +++ b/uppsrc/Docking/DockCont.h @@ -1,40 +1,35 @@ class DockWindow; struct ImgButton : public Pusher { - private: - const Value *look; - Image img; - public: - ImgButton() { Transparent(true); } - virtual void Paint(Draw& w); - virtual void MouseEnter(Point p, dword kflags) { Refresh(); Pusher::MouseEnter(p, kflags); } - virtual void MouseLeave() { Refresh(); Pusher::MouseLeave(); } +private: + const Value *look; + Image img; +public: + ImgButton() { Transparent(true); } + virtual void Paint(Draw& w); + virtual void MouseEnter(Point p, dword kflags) { Refresh(); Pusher::MouseEnter(p, kflags); } + virtual void MouseLeave() { Refresh(); Pusher::MouseLeave(); } - ImgButton& SetImage(const Image& _img) { img = _img; Refresh(); return *this; } - ImgButton& SetLook(const Value *_look) { look = _look; Refresh(); return *this; } + ImgButton& SetImage(const Image& _img) { img = _img; Refresh(); return *this; } + ImgButton& SetLook(const Value *_look) { look = _look; Refresh(); return *this; } }; class DockCont : public ToolWin { public: typedef DockCont CLASSNAME; - virtual void RightDown(Point p, dword keyflags) { WindowMenu(); } + virtual void RightDown(Point p, dword keyflags) { WindowMenu(); } virtual void Layout(); virtual void ChildRemoved(Ctrl *child); virtual void ChildAdded(Ctrl *child); virtual bool Key(dword key, int count); - -/* virtual void ChildGotFocus() { handle.RefreshFocus(true); TopWindow::ChildGotFocus(); } - virtual void ChildLostFocus() { handle.RefreshFocus(HasFocusDeep()); TopWindow::ChildLostFocus(); } - virtual void GotFocus() { handle.RefreshFocus(true); } - virtual void LostFocus() { handle.RefreshFocus(HasFocusDeep()); } */ public: enum DockState { STATE_NONE = -1, STATE_FLOATING, - STATE_DOCKED, + STATE_DOCKED, STATE_AUTOHIDE, STATE_TABBED }; @@ -48,12 +43,12 @@ private: DockContMenu(DockWindow *dockwindow = NULL) : DockMenu(dockwindow) { }; void ContainerMenu(Bar& bar, DockCont *c, bool withgroups = true); - private: + private: virtual void MenuDock(int align, DockableCtrl *dc); virtual void MenuFloat(DockableCtrl *dc); - virtual void MenuAutoHide(int align, DockableCtrl *dc); - virtual void MenuClose(DockableCtrl *dc); - }; + virtual void MenuAutoHide(int align, DockableCtrl *dc); + virtual void MenuClose(DockableCtrl *dc); + }; friend class DockContMenu; class DockContFrame : public CtrlFrame { @@ -63,144 +58,145 @@ private: DrawFrame(w, r.Deflated(1), SColorPaper); } virtual void FrameAddSize(Size& sz) { sz += 4; } - }; + }; struct DockContHandle : public FrameCtrl { Callback WhenContext; Callback WhenLeftDrag; Callback WhenLeftDouble; - DockContHandle() { dc = NULL; /*focus = false;*/ } + DockContHandle() { dc = NULL; } DockableCtrl *dc; -// bool focus; + virtual void FrameLayout(Rect& r); virtual void FrameAddSize(Size& sz); virtual void Paint(Draw& w); - virtual void LeftDrag(Point p, dword keyflags) { /*RefreshFocus(true);*/ WhenLeftDrag(); } - virtual void LeftDouble(Point p, dword keyflags) { /*RefreshFocus(true);*/ WhenLeftDouble(); } - virtual void RightDown(Point p, dword keyflags) { /*RefreshFocus(true);*/ WhenContext(); } + virtual void LeftDrag(Point p, dword keyflags) { WhenLeftDrag(); } + virtual void LeftDouble(Point p, dword keyflags) { WhenLeftDouble(); } + virtual void RightDown(Point p, dword keyflags) { WhenContext(); } - //void RefreshFocus(bool _focus); int GetHandleSize(const DockableCtrl::Style& s) const; }; - DockState dockstate; - DockTabBar tabbar; - DockContHandle handle; - ImgButton close, autohide, windowpos; - Size usersize; - bool waitsync:1; - bool animating:1; - DockWindow * base; + DockState dockstate; + DockTabBar tabbar; + DockContHandle handle; + ImgButton close, autohide, windowpos; + Size usersize; + bool waitsync:1; + bool animating:1; + DockWindow *base; const DockableCtrl::Style *style; // Callbacks // Tab callbacks - void TabSelected(); - void TabDragged(int ix); - void TabContext(int ix); - void TabClosed0(Value v); - void TabClosed(Value v); - void TabsClosed(ValueArray vv); + void TabSelected(); + void TabDragged(int ix); + void TabContext(int ix); + void TabClosed0(Value v); + void TabClosed(Value v); + void TabsClosed(ValueArray vv); + // Menus/Buttons - void Float(); - void Dock(int align); - void AutoHide(); - void AutoHideAlign(int align); - void RestoreCurrent(); + void Float(); + void Dock(int align); + void AutoHide(); + void AutoHideAlign(int align); + void RestoreCurrent(); - void CloseAll(); + void CloseAll(); - DockableCtrl *Get0(int ix) const; - DockableCtrl *GetCurrent0() const { return Get0(tabbar.GetCursor()); } - - void AddRemoveButton(Ctrl& c, bool state); - bool IsDockAllowed0(int align, const Value& v) const; - void SyncButtons(DockableCtrl& dc); - Ctrl *FindFirstChild() const; - void ChildTitleChanged(Ctrl *child, WString title, Image icon); + DockableCtrl* Get0(int ix) const; + DockableCtrl* GetCurrent0() const { return Get0(tabbar.GetCursor()); } - void State(DockWindow& dock, DockCont::DockState state); + void AddRemoveButton(Ctrl& c, bool state); + bool IsDockAllowed0(int align, const Value& v) const; + void SyncButtons(DockableCtrl& dc); + Ctrl* FindFirstChild() const; + void ChildTitleChanged(Ctrl *child, WString title, Image icon); + + void State(DockWindow& dock, DockCont::DockState state); + + static Ctrl* CtrlCast(const Value& v) { return IsDockCont(v) ? (Ctrl *)ContCast(v) : (Ctrl *)DockCast(v); } + static DockCont* ContCast(const Value& v) { return ValueTo(v); } + static DockableCtrl* DockCast(const Value& v) { return ValueTo(v); } + static bool IsDockCont(const Value& v) { return IsType(v); } + Ctrl* GetCtrl(int ix) const { return CtrlCast(tabbar.GetKey(ix)); } + static Value ValueCast(DockableCtrl *dc) { return RawToValue(dc); } + static Value ValueCast(DockCont *dc) { return RawToValue(dc); } - static Ctrl *CtrlCast(const Value& v) { return IsDockCont(v) ? (Ctrl *)ContCast(v) : (Ctrl *)DockCast(v); } - static DockCont *ContCast(const Value& v) { return ValueTo(v); } - static DockableCtrl *DockCast(const Value& v) { return ValueTo(v); } - static bool IsDockCont(const Value& v) { return IsType(v); } - Ctrl *GetCtrl(int ix) const { return CtrlCast(tabbar.GetKey(ix)); } - static Value ValueCast(DockableCtrl *dc) { return RawToValue(dc); } - static Value ValueCast(DockCont *dc) { return RawToValue(dc); } public: - void SetCursor(int ix) { tabbar.SetCursor(ix); TabSelected(); } - void SetCursor(Ctrl& c); - int GetCursor() const { return tabbar.GetCursor(); } - DockableCtrl& Get(int ix) const { return *Get0(ix); } - DockableCtrl& GetCurrent() const { return Get(tabbar.GetCursor()); } - void AddFrom(DockCont& cont, int except = -1); + void SetCursor(int ix) { tabbar.SetCursor(ix); TabSelected(); } + void SetCursor(Ctrl& c); + int GetCursor() const { return tabbar.GetCursor(); } + DockableCtrl& Get(int ix) const { return *Get0(ix); } + DockableCtrl& GetCurrent() const { return Get(tabbar.GetCursor()); } + void AddFrom(DockCont& cont, int except = -1); int GetCount() const { return tabbar.GetCount(); } - void Clear(); + void Clear(); - void SortTabs(bool b); - void SortTabs(ValueOrder &sorter); - void SortTabsOnce(); - void SortTabsOnce(ValueOrder &sorter); + void SortTabs(bool b); + void SortTabs(ValueOrder &sorter); + void SortTabsOnce(); + void SortTabsOnce(ValueOrder &sorter); - virtual void MoveBegin(); - virtual void Moving(); - virtual void MoveEnd(); - virtual void WindowMenu(); + virtual void MoveBegin(); + virtual void Moving(); + virtual void MoveEnd(); + virtual void WindowMenu(); - void Animate(Rect target, int ticks, int interval = 0); + void Animate(Rect target, int ticks, int interval = 0); - bool IsDocked() const { return dockstate == STATE_DOCKED; } - int GetDockAlign() const; - int GetAutoHideAlign() const; - bool IsFloating() const { return dockstate == STATE_FLOATING; } - bool IsAutoHide() const { return dockstate == STATE_AUTOHIDE; } - bool IsTabbed() const { return dockstate == STATE_TABBED; } - bool IsDockedAny() const { return dockstate != STATE_FLOATING && dockstate != STATE_NONE; } - bool IsHidden() const { return dockstate == STATE_NONE; } - DockState GetDockState() const { return dockstate; } + bool IsDocked() const { return dockstate == STATE_DOCKED; } + int GetDockAlign() const; + int GetAutoHideAlign() const; + bool IsFloating() const { return dockstate == STATE_FLOATING; } + bool IsAutoHide() const { return dockstate == STATE_AUTOHIDE; } + bool IsTabbed() const { return dockstate == STATE_TABBED; } + bool IsDockedAny() const { return dockstate != STATE_FLOATING && dockstate != STATE_NONE; } + bool IsHidden() const { return dockstate == STATE_NONE; } + DockState GetDockState() const { return dockstate; } - void StateNotDocked(DockWindow *dock = NULL) { if (dock) base = dock; dockstate = STATE_NONE; } - void StateDocked(DockWindow& dock) { State(dock, STATE_DOCKED); } - void StateFloating(DockWindow& dock) { State(dock, STATE_FLOATING); Title(GetTitle()); } - void StateAutoHide(DockWindow& dock) { State(dock, STATE_AUTOHIDE); Hide(); } - void StateTabbed(DockWindow& dock) { State(dock, STATE_TABBED); Hide(); } + void StateNotDocked(DockWindow *dock = NULL) { if (dock) base = dock; dockstate = STATE_NONE; } + void StateDocked(DockWindow& dock) { State(dock, STATE_DOCKED); } + void StateFloating(DockWindow& dock) { State(dock, STATE_FLOATING); Title(GetTitle()); } + void StateAutoHide(DockWindow& dock) { State(dock, STATE_AUTOHIDE); Hide(); } + void StateTabbed(DockWindow& dock) { State(dock, STATE_TABBED); Hide(); } void SetAllDockerPos(); - DockWindow *GetDockWindow() const { return base; } - void SyncButtons() { if (GetCount()) SyncButtons(GetCurrent()); } - void SyncTabs(int align, bool text); - void Lock(bool lock); - void SyncFrames(); - void SyncFrames(bool hidehandle); - void SignalStateChange(); - void SignalStateChange(int from, int to); + DockWindow* GetDockWindow() const { return base; } + void SyncButtons() { if (GetCount()) SyncButtons(GetCurrent()); } + void SyncTabs(int align, bool text); + void Lock(bool lock); + void SyncFrames(); + void SyncFrames(bool hidehandle); + void SignalStateChange(); + void SignalStateChange(int from, int to); - void Grouping(bool grouping) { tabbar.Grouping(grouping); GroupRefresh(); } - void GroupRefresh(); - void GetGroups(Vector& groups); + void Grouping(bool grouping) { tabbar.Grouping(grouping); GroupRefresh(); } + void GroupRefresh(); + void GetGroups(Vector& groups); - void WindowButtons(bool menu, bool hide, bool close); + void WindowButtons(bool menu, bool hide, bool close); - void Highlight(); - Image GetHighlightImage(); + void Highlight(); + Image GetHighlightImage(); - virtual Size GetMinSize() const; - virtual Size GetMaxSize() const; - virtual Size GetStdSize() const; - Size GetUserSize() const { return usersize; } - void SetUserSize(Size sz) { usersize = sz; } - void SyncUserSize(bool h, bool v); + virtual Size GetMinSize() const; + virtual Size GetMaxSize() const; + virtual Size GetStdSize() const; + Size GetUserSize() const { return usersize; } + void SetUserSize(Size sz) { usersize = sz; } + void SyncUserSize(bool h, bool v); - WString GetTitle(bool force_count = false) const; - void ChildTitleChanged(DockableCtrl &dc); - void ChildTitleChanged(DockCont &dc); + WString GetTitle(bool force_count = false) const; + void ChildTitleChanged(DockableCtrl &dc); + void ChildTitleChanged(DockCont &dc); - bool IsDockAllowed(int align, int dc_ix = -1) const; + bool IsDockAllowed(int align, int dc_ix = -1) const; - virtual void Serialize(Stream& s); + virtual void Serialize(Stream& s); - DockCont(); + DockCont(); }; diff --git a/uppsrc/Docking/DockableCtrl.cpp b/uppsrc/Docking/DockableCtrl.cpp index f55ef9000..3386de8b2 100644 --- a/uppsrc/Docking/DockableCtrl.cpp +++ b/uppsrc/Docking/DockableCtrl.cpp @@ -18,30 +18,31 @@ DockableCtrl& DockableCtrl::Set(const Image& _icon, const char *_title, String bool DockableCtrl::IsHotKey(dword key) { - return (keycode == key || (keyinfo && - (key == keyinfo().key[0] || key == keyinfo().key[1] || key == keyinfo().key[2] || key == keyinfo().key[3]))); + return (keycode == key || + (keyinfo && (key == keyinfo().key[0] || key == keyinfo().key[1] || + key == keyinfo().key[2] || key == keyinfo().key[3]))); } DockableCtrl& DockableCtrl::SizeHint(const Size& min, const Size& max, const Size& std) { minsize = min; maxsize = max; stdsize = std; - return *this; + return *this; } DockableCtrl& DockableCtrl::Title(const WString& _title) { - title = _title; - if (GetContainer()) - GetContainer()->ChildTitleChanged(*this); + title = _title; + if (GetContainer()) + GetContainer()->ChildTitleChanged(*this); return *this; } DockableCtrl& DockableCtrl::Icon(const Image& m) { icon = m; - if (GetContainer()) + if (GetContainer()) GetContainer()->ChildTitleChanged(*this); - return *this; + return *this; } bool DockableCtrl::IsFloating() const @@ -59,19 +60,19 @@ bool DockableCtrl::IsDocked() const bool DockableCtrl::IsAutoHide() const { DockCont *c = GetContainer(); - return c && c->IsAutoHide(); + return c && c->IsAutoHide(); } bool DockableCtrl::IsTabbed() const { DockCont *c = GetContainer(); - return c && (c->IsTabbed() || c->GetCount() > 1); + return c && (c->IsTabbed() || c->GetCount() > 1); } bool DockableCtrl::IsHidden() const { DockCont *c = GetContainer(); - return !c || c->IsHidden(); + return !c || c->IsHidden(); } int DockableCtrl::GetDockAlign() const @@ -91,8 +92,8 @@ DockableCtrl& DockableCtrl::SetGroup(const String& g) void DockableCtrl::Highlight() { if (!GetParent() || !IsOpen()) return; - ViewDraw v(this); - ChPaint(v, GetSize(), GetStyle().highlight[1]); + ViewDraw v(this); + ChPaint(v, GetSize(), GetStyle().highlight[1]); } void DockableCtrl::TimedHighlight(int ms) @@ -172,8 +173,8 @@ CH_STYLE(DockableCtrl, Style, StyleDefault) handle_vert = false; title_font = StdFont(); - title_ink[0] = SColorInfoText(); // No focus - title_ink[1] = SColorHighlightText(); // Focus + title_ink[0] = SColorInfoText(); // No focus + title_ink[1] = SColorHighlightText(); // Focus DockableCtrlImgsLook(close, DockingImg::I_DClosed, 4); DockableCtrlImgsLook(windowpos, DockingImg::I_DMenud, 4); diff --git a/uppsrc/Docking/DockableCtrl.h b/uppsrc/Docking/DockableCtrl.h index eabc07c50..e4dd56484 100644 --- a/uppsrc/Docking/DockableCtrl.h +++ b/uppsrc/Docking/DockableCtrl.h @@ -19,84 +19,86 @@ public: Value autohide[4]; Value pin[4]; Value highlight[2]; // Opaque, transparent - }; - static const Style& StyleDefault(); - static const Style& StyleDefaultVert(); + }; + static const Style& StyleDefault(); + static const Style& StyleDefaultVert(); enum { TIMEID_HIGHLIGHT = ParentCtrl::TIMEID_COUNT, TIMEID_COUNT }; private: - Size minsize; + Size minsize; Size maxsize; Size stdsize; - Image icon; - WString title; - String group; - bool dockable[4]; - dword keycode; - KeyInfo&(* keyinfo)(); + Image icon; + WString title; + String group; + bool dockable[4]; + dword keycode; + KeyInfo& (*keyinfo)(); const Style *style; - void StopHighlight() { Refresh(); } + void StopHighlight() { Refresh(); } + protected: DockCont *GetContainer() const; + public: Callback1 WhenMenuBar; Callback WhenState; - virtual void WindowMenu(Bar& bar) { WhenMenuBar(bar); } + virtual void WindowMenu(Bar& bar) { WhenMenuBar(bar); } - const Image& GetIcon() { return icon; } - DockableCtrl& Icon(const Image& m); - DockableCtrl& Title(const char *_title) { return Title((WString)_title); } - DockableCtrl& Title(const WString& _title); - const WString& GetTitle() { return title; } + const Image& GetIcon() { return icon; } + DockableCtrl& Icon(const Image& m); + DockableCtrl& Title(const char *_title) { return Title((WString)_title); } + DockableCtrl& Title(const WString& _title); + const WString& GetTitle() { return title; } - DockableCtrl& Set(const Image& icon, const char *_title, String group = Null); - DockableCtrl& SetHotKey(dword key) { keycode = key; return *this; } - DockableCtrl& SetHotKey(KeyInfo&(*key)()) { keyinfo = key; return *this; } - bool IsHotKey(dword key); + DockableCtrl& Set(const Image& icon, const char *_title, String group = Null); + DockableCtrl& SetHotKey(dword key) { keycode = key; return *this; } + DockableCtrl& SetHotKey(KeyInfo&(*key)()) { keyinfo = key; return *this; } + bool IsHotKey(dword key); - DockableCtrl& SizeHint(const Size& min, const Size& max = Null, const Size& std = Null); - void SetMinSize(Size sz) { minsize = sz; } - void SetMaxSize(Size sz) { maxsize = sz; } - void SetStdSize(Size sz) { stdsize = sz; } - virtual Size GetMinSize() const { return minsize; } - virtual Size GetMaxSize() const { return maxsize.IsNullInstance() ? Ctrl::GetMaxSize() : maxsize; } - virtual Size GetStdSize() const { return stdsize.IsNullInstance() ? minsize : stdsize; } + DockableCtrl& SizeHint(const Size& min, const Size& max = Null, const Size& std = Null); + void SetMinSize(Size sz) { minsize = sz; } + void SetMaxSize(Size sz) { maxsize = sz; } + void SetStdSize(Size sz) { stdsize = sz; } + virtual Size GetMinSize() const { return minsize; } + virtual Size GetMaxSize() const { return maxsize.IsNullInstance() ? Ctrl::GetMaxSize() : maxsize; } + virtual Size GetStdSize() const { return stdsize.IsNullInstance() ? minsize : stdsize; } - DockableCtrl& SetStyle(const Style& s) { style = &s; RefreshParentLayout(); return *this; } - const Style& GetStyle() { return style ? *style : StyleDefault(); } + DockableCtrl& SetStyle(const Style& s) { style = &s; RefreshParentLayout(); return *this; } + const Style& GetStyle() { return style ? *style : StyleDefault(); } - virtual const String& GetGroup() const { return group; } + virtual const String& GetGroup() const { return group; } virtual DockableCtrl& SetGroup(const String& g); - DockableCtrl& AllowDockAll() { return AllowDockLeft().AllowDockRight().AllowDockTop().AllowDockBottom(); } - DockableCtrl& AllowDockNone() { return AllowDockLeft(false).AllowDockRight(false).AllowDockTop(false).AllowDockBottom(false); } - DockableCtrl& AllowDockLeft(bool v = true) { dockable[0] = v; return *this; } - DockableCtrl& AllowDockTop(bool v = true) { dockable[1] = v; return *this; } - DockableCtrl& AllowDockRight(bool v = true) { dockable[2] = v; return *this; } - DockableCtrl& AllowDockBottom(bool v = true) { dockable[3] = v; return *this; } - DockableCtrl& AllowDock(int a, bool v = true) { ASSERT(a >= 0 && a < 4); dockable[a] = v; return *this; } - bool IsDockAllowed(int a) const { ASSERT(a >= 0 && a < 4); return dockable[a]; } - bool IsDockAllowedLeft() const { return dockable[0]; } - bool IsDockAllowedTop() const { return dockable[1]; } - bool IsDockAllowedRight() const { return dockable[2]; } - bool IsDockAllowedBottom() const { return dockable[3]; } - bool IsDockAllowedAny() const { return dockable[0] || dockable[1] || dockable[2] || dockable[3]; } - bool IsDockAllowedNone() const { return !IsDockAllowedAny(); } + DockableCtrl& AllowDockAll() { return AllowDockLeft().AllowDockRight().AllowDockTop().AllowDockBottom(); } + DockableCtrl& AllowDockNone() { return AllowDockLeft(false).AllowDockRight(false).AllowDockTop(false).AllowDockBottom(false); } + DockableCtrl& AllowDockLeft(bool v = true) { dockable[0] = v; return *this; } + DockableCtrl& AllowDockTop(bool v = true) { dockable[1] = v; return *this; } + DockableCtrl& AllowDockRight(bool v = true) { dockable[2] = v; return *this; } + DockableCtrl& AllowDockBottom(bool v = true) { dockable[3] = v; return *this; } + DockableCtrl& AllowDock(int a, bool v = true) { ASSERT(a >= 0 && a < 4); dockable[a] = v; return *this; } + bool IsDockAllowed(int a) const { ASSERT(a >= 0 && a < 4); return dockable[a]; } + bool IsDockAllowedLeft() const { return dockable[0]; } + bool IsDockAllowedTop() const { return dockable[1]; } + bool IsDockAllowedRight() const { return dockable[2]; } + bool IsDockAllowedBottom() const { return dockable[3]; } + bool IsDockAllowedAny() const { return dockable[0] || dockable[1] || dockable[2] || dockable[3]; } + bool IsDockAllowedNone() const { return !IsDockAllowedAny(); } - bool IsFloating() const; - bool IsDocked() const; - bool IsAutoHide() const; - bool IsTabbed() const; - bool IsHidden() const; - int GetDockAlign() const; + bool IsFloating() const; + bool IsDocked() const; + bool IsAutoHide() const; + bool IsTabbed() const; + bool IsHidden() const; + int GetDockAlign() const; - void Highlight(); - void TimedHighlight(int ms); + void Highlight(); + void TimedHighlight(int ms); - virtual Value GetSortValue() { return GetTitle(); } + virtual Value GetSortValue() { return GetTitle(); } DockableCtrl(); };