[Aptitude-svn-commit] r3362 - in branches/aptitude-0.3/aptitude: . src

Daniel Burrows dburrows@costa.debian.org
Tue, 07 Jun 2005 06:21:11 +0000


Author: dburrows
Date: Tue Jun  7 06:21:09 2005
New Revision: 3362

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/download_item.cc
   branches/aptitude-0.3/aptitude/src/download_item.h
Log:
Use styles instead of colors in the download item code.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Tue Jun  7 06:21:09 2005
@@ -1,5 +1,9 @@
 2005-06-06  Daniel Burrows  <dburrows@debian.org>
 
+	* src/download_item.cc:
+
+	Update the download item code to use styles instead of colors.
+
 	* src/download_bar.cc:
 
 	Update to use styles.

Modified: branches/aptitude-0.3/aptitude/src/download_item.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/download_item.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/download_item.cc	Tue Jun  7 06:21:09 2005
@@ -1,6 +1,6 @@
 // download_item.cc
 //
-//  Copyright 1999, 2004, 2005 Daniel Burrows
+//  Copyright 1999, 2004-2005 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
@@ -26,29 +26,30 @@
 
 #include "vscreen/vs_tree.h"
 
-int download_item::get_normal_attr()
+style download_item::get_normal_style()
 {
   switch(item.Owner->Status)
     {
     case pkgAcquire::Item::StatIdle:
-      return A_DIM|vs_treeitem::get_normal_attr();
+      return vs_treeitem::get_normal_style()+style_attrs_on(A_DIM);
     case pkgAcquire::Item::StatFetching:
-      return vs_treeitem::get_normal_attr();
+      return vs_treeitem::get_normal_style();
     case pkgAcquire::Item::StatDone:
       if(!hit)
-	return get_color("Progress");
+	return vs_treeitem::get_normal_style()+get_style("Progress");
       else
-	return get_color("DownloadHit");
+	return vs_treeitem::get_normal_style()+get_style("DownloadHit");
     case pkgAcquire::Item::StatError:
-      return get_color("Error");
+      return vs_treeitem::get_normal_style()+get_style("Error");
     case pkgAcquire::Item::StatAuthError:
-      return get_color("Error");
+      return vs_treeitem::get_normal_style()+get_style("Error");
     default:
       assert(0);
     }
 }
 
-void download_item::paint(vs_tree *win, int y, bool hierarchical)
+void download_item::paint(vs_tree *win, int y, bool hierarchical,
+			  const style &st)
   // A little confusing -- basically, there are two branches: either we display
   // a progress bar, or we don't.  If we don't, I can just display it as usual
   // (note, though, that I don't yet indent it according to the depth..); if we
@@ -60,6 +61,9 @@
 
   win->getmaxyx(height,width);
 
+  const style progress_style=st+get_style("DownloadProgress");
+  const style normal_style=st+get_normal_style();
+
   switch(item.Owner->Status)
     {
     case pkgAcquire::Item::StatIdle:
@@ -76,12 +80,12 @@
 	    {
 	      char intbuf[50]; // Waay more than enough.
 	      int barsize=(width*worker->CurrentSize)/worker->TotalSize;
-	      win->attrset(get_color("DownloadProgress"));
+	      win->apply_style(progress_style);
 
 	      if(barsize>width)
 		barsize=width;
 
-	      win->attrset(get_normal_attr());
+	      win->apply_style(get_normal_style());
 	      sprintf(intbuf,
 		      "%sB/%sB",
 		      SizeToStr(worker->CurrentSize).c_str(),
@@ -90,8 +94,8 @@
 	      win->show_string_as_progbar(0,
 					  y,
 					  output,
-					  get_color("DownloadProgress"),
-					  get_normal_attr(),
+					  progress_style.get_attrs(),
+					  normal_style.get_attrs(),
 					  barsize,
 					  width);
 	      return;

Modified: branches/aptitude-0.3/aptitude/src/download_item.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/download_item.h	(original)
+++ branches/aptitude-0.3/aptitude/src/download_item.h	Tue Jun  7 06:21:09 2005
@@ -1,6 +1,6 @@
 // download_item.h -- this is -*-c++-*-
 //
-//  Copyright 1999 Daniel Burrows
+//  Copyright 1999-2001, 2005 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
@@ -42,9 +42,10 @@
 public:
   download_item(const pkgAcquire::ItemDesc &_item):vs_treeitem(false), item(_item), worker(NULL) {}
 
-  int get_normal_attr();
+  style get_normal_style();
 
-  virtual void paint(vs_tree *win, int y, bool hierarchical);
+  virtual void paint(vs_tree *win, int y, bool hierarchical,
+		     const style &st);
 
   void download_done(bool _hit) {hit=_hit;}
   void set_worker(pkgAcquire::Worker *_worker) {worker=_worker;}