[Aptitude-svn-commit] r3291 - in branches/aptitude-0.3/aptitude: . src/vscreen
Daniel Burrows
dburrows@costa.debian.org
Fri, 27 May 2005 02:39:44 +0000
Author: dburrows
Date: Fri May 27 02:39:42 2005
New Revision: 3291
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.cc
branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.h
Log:
Add a per-widget stack of styles.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Fri May 27 02:39:42 2005
@@ -1,5 +1,10 @@
2005-05-26 Daniel Burrows <dburrows@debian.org>
+ * src/vscreen/vscreen_widget.h:
+
+ Add in a per-widget stack of styles to be used when drawing the
+ widget.
+
* src/vscreen/config/style.h:
Take the color data into account when generating attrs from a
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.cc Fri May 27 02:39:42 2005
@@ -42,6 +42,28 @@
assert(!owner);
}
+void vscreen_widget::set_bg_style(const style &new_style)
+{
+ assert(style_stack.empty());
+
+ bg_style=new_style;
+ if(win)
+ win.setattr(bg_style.get_attr());
+}
+
+void vscreen_widget::push_style(const style &new_style)
+{
+ style_stack.push_back(get_style()+new_style);
+
+ win->setattr(style_stack.back().get_attrs());
+}
+
+void vscreen_widget::pop_style()
+{
+ style_stack.pop_back();
+}
+
+
void vscreen_widget::set_isfocussed(bool _isfocussed)
{
isfocussed=_isfocussed;
@@ -172,12 +194,6 @@
paint();
}
-void vscreen_widget::set_bg(int _bgattr)
-{
- // Should I queue a redraw? Right now I'm not doing that..
- bgattr=_bgattr;
-}
-
bool vscreen_widget::focus_me()
{
return !auxillary_bindings.empty();
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.h (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.h Fri May 27 02:39:42 2005
@@ -20,10 +20,13 @@
#define VSCREEN_WIDGET_H
#include <list>
+#include <vector>
+
#include <sigc++/signal.h>
#include <sigc++/trackable.h>
#include "curses++.h"
+#include "config/style.h"
class vs_container;
@@ -53,7 +56,7 @@
{
friend class vs_container;
- // FIXME: trim this list :P
+ // Too many friends..
friend bool vscreen_poll();
friend void vscreen_mainloop(int);
friend void vscreen_redraw();
@@ -94,8 +97,13 @@
// answers the question "should this widget have a window?")
bool visible;
- // The background to paint before drawing.
- int bgattr;
+ /** The basic style attached to this widget. */
+ style bg_style;
+
+ /** A stack of additional styles that have been overlaid (if
+ * empty, the current style is bg_style).
+ */
+ std::vector<style> style_stack;
// Tracks whether or not we have the focus.
bool isfocussed;
@@ -305,8 +313,33 @@
return false;
}
- void set_bg(int _bgattr);
- int get_bg() {return bgattr;}
+ /** Update this widget's basic style to the given value. The style
+ * stack must be empty.
+ */
+ void set_bg_style(const style &new_style);
+
+ /** \return a reference to this widget's current style, valid until
+ * the widget is destroyed or a style is pushed/popped.
+ */
+ const style &get_style()
+ {
+ if(style_stack.empty())
+ return bg_style;
+ else
+ return style_stack.back();
+ }
+
+ /** Apply the given style to the current style, pushing the result
+ * onto the style stack. This should only be called from drawing
+ * routines; other routines should use set_bg_style to set the
+ * basic style of this widget.
+ */
+ void push_style(const style &new_style);
+
+ /** Pop the most recently pushed style from the style stack (the
+ * stack must of course be nonempty).
+ */
+ void pop_style();
typedef std::list<binding_connection>::iterator key_connection;
// This can be used to connect to a pseudo-signal for keypresses.