From fd835baf8311b2200e7cf47e357adc0bb18435fd Mon Sep 17 00:00:00 2001 From: Daniel Burrows Date: Wed, 3 Oct 2007 21:38:59 -0700 Subject: Use a signal instead of a virtual method to communicate changes in whether a tree item is highlighted. The original design required less memory, but it turns out that the common patterns of operation that I ended up using are much easier to implement using signals. In particular, some design work I've been doing to overhaul the configuration UI will be a LOT easier to implement with this change. --- src/pkg_subtree.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/pkg_subtree.h') diff --git a/src/pkg_subtree.h b/src/pkg_subtree.h index dc29c437..6fe3c0ab 100644 --- a/src/pkg_subtree.h +++ b/src/pkg_subtree.h @@ -1,6 +1,6 @@ // pkg_subtree.h (this is -*-c++-*-) // -// Copyright 1999-2002, 2004-2005 Daniel Burrows +// Copyright 1999-2002, 2004-2005, 2007 Daniel Burrows // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -33,6 +33,8 @@ class pkg_subtree:public vs_subtree, std::wstring description; // This is like a Description: field. sigc::signal1 *info_signal; + + void do_highlighted_changed(bool highlighted); protected: void set_label(const std::wstring &_name) {name=_name;} public: @@ -41,12 +43,15 @@ public: bool _expanded=false): vs_subtree(_expanded), name(_name), description(_description), info_signal(_info_signal) - {} + { + highlighted_changed.connect(sigc::mem_fun(this, &pkg_subtree::do_highlighted_changed)); + } pkg_subtree(std::wstring _name, bool _expanded): vs_subtree(_expanded), name(_name), description(L""), info_signal(NULL) { + highlighted_changed.connect(sigc::mem_fun(this, &pkg_subtree::do_highlighted_changed)); } virtual void paint(vs_tree *win, int y, bool hierarchical, @@ -62,9 +67,6 @@ public: virtual void reinstall(undo_group *undo); virtual void set_auto(bool isauto, undo_group *undo); - virtual void highlighted(vs_tree *win); - virtual void unhighlighted(vs_tree *win); - std::wstring get_name() {return name;} std::wstring get_description() {return description;} -- cgit v1.2.3