diff --git a/bazaar/Docking/DockCont.cpp b/bazaar/Docking/DockCont.cpp index a05506bca..77686c47c 100644 --- a/bazaar/Docking/DockCont.cpp +++ b/bazaar/Docking/DockCont.cpp @@ -235,11 +235,11 @@ void DockCont::ChildAdded(Ctrl *child) return; else if (DockableCtrl *dc = dynamic_cast(child)) { Value v = ValueCast(dc); - tabbar.Insert(0, v, Null, dc->GetGroup(), true); + tabbar.InsertKey(0, v, dc->GetTitle(), Null, dc->GetGroup(), true); } else if (DockCont *dc = dynamic_cast(child)) { Value v = ValueCast(dc); - tabbar.Insert(0, v, Null, Null, true); + tabbar.InsertKey(0, v, dc->GetTitle(), Null, Null, true); } else return; @@ -332,9 +332,8 @@ void DockCont::TabSelected() if (IsTabbed()) { DockCont *c = static_cast(GetParent()); - c->tabbar.SyncRepos(); + c->ChildTitleChanged(*this); c->TabSelected(); - c->RefreshFrame(); } else handle.Refresh(); @@ -516,7 +515,8 @@ void DockCont::State(DockWindow& dock, DockCont::DockState state) void DockCont::SignalStateChange() { - SignalStateChange(GetCount()-1, 0); + if (GetCount()) + SignalStateChange(GetCount()-1, 0); } void DockCont::SignalStateChange(int from, int to) @@ -743,11 +743,25 @@ WString DockCont::GetTitle(bool force_count) const return GetCurrent().GetTitle(); } -void DockCont::ChildTitleChanged() +void DockCont::ChildTitleChanged(DockableCtrl &dc) { - tabbar.SyncRepos(); + ChildTitleChanged(&dc, dc.GetTitle(), dc.GetIcon()); +} + +void DockCont::ChildTitleChanged(DockCont &dc) +{ + ChildTitleChanged(&dc, dc.GetTitle(), Null); +} + +void DockCont::ChildTitleChanged(Ctrl *child, WString title, Image icon) +{ + for (int i = 0; i < tabbar.GetCount(); i++) + if (CtrlCast(tabbar.GetKey(i)) == child) { + tabbar.Set(i, tabbar.GetKey(i), title, icon); + break; + } if (!GetParent()) - Title(GetTitle()); + Title(GetTitle()); RefreshFrame(); } diff --git a/bazaar/Docking/DockCont.h b/bazaar/Docking/DockCont.h index 79698b1b8..bd4b44356 100644 --- a/bazaar/Docking/DockCont.h +++ b/bazaar/Docking/DockCont.h @@ -39,7 +39,7 @@ public: /* 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()); }*/ + virtual void LostFocus() { handle.RefreshFocus(HasFocusDeep()); } */ public: #if defined(PLATFORM_WIN32) virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); @@ -132,6 +132,7 @@ private: 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); @@ -209,7 +210,8 @@ public: void SyncUserSize(bool h, bool v); WString GetTitle(bool force_count = false) const; - void ChildTitleChanged(); + void ChildTitleChanged(DockableCtrl &dc); + void ChildTitleChanged(DockCont &dc); bool IsDockAllowed(int align, int dc_ix = -1) const; diff --git a/bazaar/Docking/DockTabBar.cpp b/bazaar/Docking/DockTabBar.cpp index 6747c82af..b45980946 100644 --- a/bazaar/Docking/DockTabBar.cpp +++ b/bazaar/Docking/DockTabBar.cpp @@ -22,47 +22,10 @@ void DockTabBar::FrameAddSize(Size& sz) TabBar::FrameAddSize(sz); } -void DockTabBar::PaintTab(Draw& w, const Rect &r, const Tab& tab, const Font &font, Color ink, dword style) -{ - DockableCtrl *d; - WString txt; - const Value &q = tab.value; - - ink = (style == CTRL_DISABLED) ? SColorDisabled : ink; - - if (IsTypeRaw(q)) { - DockCont *c = ValueTo(q); - d = &c->GetCurrent(); - txt = c->GetTitle(); - } - else { - ASSERT(IsTypeRaw(q)); - d = ValueTo(q); - txt = d->GetTitle(); - } - - Size isz(0, 0); - - if(icons) - { - const Image& icon = (style == CTRL_DISABLED) ? DisabledImage(d->GetIcon()) : d->GetIcon(); - if (!icon.IsEmpty()) { - isz = icon.GetSize(); - Point ip = GetImagePosition(r, isz.cx, isz.cy, TB_SPACEICON, LEFT); - w.DrawImage(ip.x, ip.y, icon); - } - } - if (showtext) - { - Point p = GetTextPosition(r, GetTextSize(txt, font).cy, isz.cx > 0 ? isz.cx + TB_SPACEICON + TB_MARGIN : TB_MARGIN); - w.DrawText(p.x, p.y, GetTextAngle(), txt, font, ink); - } -} - Size DockTabBar::GetStdSize(const Tab &t) { DockableCtrl *d; - const Value &q = t.value; + const Value &q = t.key; Value v; if (IsTypeRaw(q)) { DockCont *c = ValueTo(q); @@ -290,6 +253,43 @@ void AutoHideBar::TabDrag(int ix) GetCtrl(ix)->MoveBegin(); } +void AutoHideBar::PaintTab(Draw& w, const Rect &r, const Tab& tab, const Font &font, Color ink, dword style) +{ + DockableCtrl *d; + WString txt; + const Value &q = tab.value; + + ink = (style == CTRL_DISABLED) ? SColorDisabled : ink; + + if (IsTypeRaw(q)) { + DockCont *c = ValueTo(q); + d = &c->GetCurrent(); + txt = c->GetTitle(); + } + else { + ASSERT(IsTypeRaw(q)); + d = ValueTo(q); + txt = d->GetTitle(); + } + + Size isz(0, 0); + + if(icons) + { + const Image& icon = (style == CTRL_DISABLED) ? DisabledImage(d->GetIcon()) : d->GetIcon(); + if (!icon.IsEmpty()) { + isz = icon.GetSize(); + Point ip = GetImagePosition(r, isz.cx, isz.cy, TB_SPACEICON, LEFT); + w.DrawImage(ip.x, ip.y, icon); + } + } + if (showtext) + { + Point p = GetTextPosition(r, GetTextSize(txt, font).cy, isz.cx > 0 ? isz.cx + TB_SPACEICON + TB_MARGIN : TB_MARGIN); + w.DrawText(p.x, p.y, GetTextAngle(), txt, font, ink); + } +} + AutoHideBar::AutoHideBar() { ctrl = NULL; diff --git a/bazaar/Docking/DockTabBar.h b/bazaar/Docking/DockTabBar.h index d9402a3f1..fff475575 100644 --- a/bazaar/Docking/DockTabBar.h +++ b/bazaar/Docking/DockTabBar.h @@ -31,8 +31,6 @@ protected: bool icons:1; bool showtext:1; - virtual void PaintTab(Draw& w, const Rect &r, const Tab& tab, - const Font &font, Color ink, dword style); virtual Size GetStdSize(const Tab &t); virtual void RightDown(Point p, dword keyflags); @@ -63,6 +61,9 @@ public: static void SetTimeout(int delay_ms) { ASSERT(delay_ms > 0); autohide_timeout = delay_ms; } AutoHideBar(); + + virtual void PaintTab(Draw& w, const Rect &r, const Tab& tab, + const Font &font, Color ink, dword style); private: static int autohide_timeout; @@ -87,6 +88,11 @@ private: void AdjustSize(Rect& r, const Size& sz); }; +struct DockTabable +{ + virtual Value GetSortValue() = 0; +}; + END_UPP_NAMESPACE #endif \ No newline at end of file diff --git a/bazaar/Docking/DockableCtrl.cpp b/bazaar/Docking/DockableCtrl.cpp index 82a1bcc32..9cb55464b 100644 --- a/bazaar/Docking/DockableCtrl.cpp +++ b/bazaar/Docking/DockableCtrl.cpp @@ -31,7 +31,18 @@ DockableCtrl& DockableCtrl::SizeHint(const Size& min, const Size& max, const Si DockableCtrl& DockableCtrl::Title(const WString& _title) { - title = _title; if (GetContainer()) GetContainer()->ChildTitleChanged(); return *this; + title = _title; + if (GetContainer()) + GetContainer()->ChildTitleChanged(*this); + return *this; +} + +DockableCtrl& DockableCtrl::Icon(const Image& m) +{ + icon = m; + if (GetContainer()) + GetContainer()->ChildTitleChanged(*this); + return *this; } bool DockableCtrl::IsFloating() const diff --git a/bazaar/Docking/DockableCtrl.h b/bazaar/Docking/DockableCtrl.h index 081ef5407..30d28751e 100644 --- a/bazaar/Docking/DockableCtrl.h +++ b/bazaar/Docking/DockableCtrl.h @@ -53,7 +53,7 @@ public: virtual void WindowMenu(Bar& bar) { WhenMenuBar(bar); } const Image& GetIcon() { return icon; } - DockableCtrl& Icon(const Image& m) { icon = m; return *this; } + DockableCtrl& Icon(const Image& m); DockableCtrl& Title(const char *_title) { return Title((WString)_title); } DockableCtrl& Title(const WString& _title); const WString& GetTitle() { return title; } @@ -102,6 +102,8 @@ public: void Highlight(); void TimedHighlight(int ms); + virtual Value GetSortValue() { return GetTitle(); } + DockableCtrl(); }; diff --git a/bazaar/TabBar/TabBar.cpp b/bazaar/TabBar/TabBar.cpp index 1dfc8a63c..90b2082a7 100644 --- a/bazaar/TabBar/TabBar.cpp +++ b/bazaar/TabBar/TabBar.cpp @@ -1632,13 +1632,17 @@ void TabBar::SetData(const Value &key) } } +void TabBar::Set(int n, const Value &newkey, const Value &newvalue) +{ + Set(n, newkey, newvalue, tabs[n].img); +} + void TabBar::Set(int n, const Value &newkey, const Value &newvalue, Image icon) { ASSERT(n >= 0 && n < tabs.GetCount()); tabs[n].key = newkey; tabs[n].value = newvalue; - if (IsNull(icon)) - tabs[n].img = icon; + tabs[n].img = icon; if (stacking) { String id = tabs[n].stackid; tabs[n].stackid = GetStackId(tabs[n]); @@ -1651,16 +1655,21 @@ void TabBar::Set(int n, const Value &newkey, const Value &newvalue, Image icon) Refresh(); } -void TabBar::Set(const Value &key, const Value &newvalue, Image icon) +void TabBar::SetValue(const Value &key, const Value &newvalue) { Set(FindKey(key), key, newvalue); } -void TabBar::Set(int n, const Value &newvalue, Image icon) +void TabBar::SetValue(int n, const Value &newvalue) { Set(n, tabs[n].key, newvalue); } +void TabBar::SetKey(int n, const Value &newkey) +{ + Set(n, newkey, tabs[n].value); +} + void TabBar::SetIcon(int n, Image icon) { ASSERT(n >= 0 && n < tabs.GetCount()); diff --git a/bazaar/TabBar/TabBar.h b/bazaar/TabBar/TabBar.h index 9eb389c43..67d5110df 100644 --- a/bazaar/TabBar/TabBar.h +++ b/bazaar/TabBar/TabBar.h @@ -403,9 +403,11 @@ public: Value GetKey(int n) const { ASSERT(n >= 0 && n < tabs.GetCount()); return tabs[n].key;} Value GetValue(int n) const { ASSERT(n >= 0 && n < tabs.GetCount()); return tabs[n].value;} Value Get(const Value& key) const { return GetValue(FindKey(key)); } - void Set(int n, const Value& newkey, const Value& newvalue, Image icon = Null); - void Set(const Value &key, const Value& newvalue, Image icon = Null); - void Set(int n, const Value& newvalue, Image icon = Null); + void Set(int n, const Value& newkey, const Value& newvalue); + void Set(int n, const Value& newkey, const Value& newvalue, Image icon); + void SetValue(const Value &key, const Value &newvalue); + void SetValue(int n, const Value &newvalue); + void SetKey(int n, const Value &newkey); void SetIcon(int n, Image icon); void SetTabGroup(int n, const String& group);