From a3d8b25d99185a0b2bef5df35d04cb24a5471e18 Mon Sep 17 00:00:00 2001
From: Chris Tallon <chris@vomp.tv>
Date: Sun, 8 Jan 2006 23:02:26 +0000
Subject: [PATCH] More timers display code

---
 vtimerlist.cc | 87 ++++++++++++++++++++++++++++++++++++++-------------
 vtimerlist.h  |  4 +++
 wselectlist.h |  2 +-
 3 files changed, 71 insertions(+), 22 deletions(-)

diff --git a/vtimerlist.cc b/vtimerlist.cc
index 19ffbab..ad25bc9 100644
--- a/vtimerlist.cc
+++ b/vtimerlist.cc
@@ -29,6 +29,13 @@ VTimerList::VTimerList(RecTimerList* trtl)
   clockRegion.w = 150;
   clockRegion.h = 30;
 
+  indicatorsRegion.x = 6;
+  indicatorsRegion.y = 44;
+  indicatorsRegion.w = 18;
+  indicatorsRegion.h = 15 * (surface->getFontHeight() + 1);
+
+  flipflop = true;
+
   create(570, 420);
   if (Video::getInstance()->getFormat() == Video::PAL)
   {
@@ -46,8 +53,8 @@ VTimerList::VTimerList(RecTimerList* trtl)
   setTitleBarColour(Colour::TITLEBARBACKGROUND);
 
   sl.setSurface(surface);
-  sl.setSurfaceOffset(10, 30 + 5);
-  sl.setDimensions(area.w - 20, area.h - 30 - 15 - 30);
+  sl.setSurfaceOffset(30, 30 + 5);
+  sl.setDimensions(area.w - 40, area.h - 30 - 15 - 30);
 
   // Draw statics
 
@@ -78,6 +85,7 @@ VTimerList::VTimerList(RecTimerList* trtl)
   insertData();
   sl.draw();
   drawShowing();
+  drawIndicators();
   drawClock();
 }
 
@@ -100,14 +108,13 @@ void VTimerList::insertData()
 {
   char strA[300];
   char strB[300];
-  char status;
 
   struct tm* btime;
 
   // FIXME all drawing stuff in this class and sl.clear somewhere?!
 
   sl.addColumn(0);
-  sl.addColumn(130);
+  sl.addColumn(110);
 
   RecTimer* recTimer;
   int first = 1;
@@ -115,26 +122,10 @@ void VTimerList::insertData()
   for (UINT i = 0; i < recTimerList->size(); i++)
   {
     recTimer = (*recTimerList)[i];
-    if (recTimer->recording)
-    {
-      status = 'R';
-    }
-    else if (recTimer->pending)
-    {
-      status = 'X';
-    }
-    else if (recTimer->active == 0)
-    {
-      status = 'N';
-    }
-    else
-    {
-      status = 'O';
-    }
 
     btime = localtime((time_t*)&recTimer->startTime);
     strftime(strA, 299, "%d/%m %H:%M ", btime);
-    snprintf(strB, 299, "%c %s\t%s", status, strA, recTimer->getName());
+    snprintf(strB, 299, "%s\t%s", strA, recTimer->getName());
     recTimer->index = sl.addOption(strB, first);
     first = 0;
   }
@@ -166,10 +157,60 @@ void VTimerList::drawShowing()
   drawText(showing, 220, 385, Colour::LIGHTTEXT);
 }
 
+void VTimerList::drawIndicators()
+{
+  int top = sl.getTopOption();
+  int bottom = sl.getBottomOption();
+  int yinc = surface->getFontHeight() + 1;
+  RecTimer* recTimer;
+
+  rectangle(6, 44, 18, 15*yinc, Colour::VIEWBACKGROUND);
+
+  // The indexes recorded from the wselectlist into the index member of the RecTimer
+  // Is the same as the position in the vector of RecTimers
+  // Because they are in order, they don't change order and wselectlist starts from 0 up consecutively
+
+  int ypos = 44;
+  for (int current = top; current < bottom; current++)
+  {
+    recTimer = (*recTimerList)[current];
+
+    if (recTimer->recording) // Flashing red square
+    {
+      if (flipflop)
+      {
+        //rectangle(6, ypos, 18, 16, Colour::RED);
+        rectangle(6, ypos, 18, 16, Colour::RED);
+        drawText("R", 8, ypos-3, Colour::LIGHTTEXT);
+      }
+    }
+    else if (recTimer->pending)
+    {
+      rectangle(6, ypos, 18, 16, Colour::RED);
+      drawText("X", 8, ypos-3, Colour::BLACK);
+    }
+    else if (recTimer->active == 0)
+    {
+      rectangle(6, ypos, 18, 16, Colour::SELECTHIGHLIGHT);
+      drawText("X", 8, ypos-3, Colour::BLACK);
+    }
+    else
+    {
+//      if (flipflop) rectangle(6, ypos, 18, 16, Colour::GREEN);
+    }
+
+    ypos += yinc;
+  }
+}
+
 void VTimerList::timercall(int clientReference)
 {
   drawClock();
   ViewMan::getInstance()->updateView(this, &clockRegion);
+
+  flipflop = !flipflop;
+  drawIndicators();
+  ViewMan::getInstance()->updateView(this, &indicatorsRegion);
 }
 
 int VTimerList::handleCommand(int command)
@@ -182,6 +223,7 @@ int VTimerList::handleCommand(int command)
       sl.up();
       sl.draw();
       drawShowing();
+      drawIndicators();
       ViewMan::getInstance()->updateView(this);
       return 2;
     }
@@ -191,6 +233,7 @@ int VTimerList::handleCommand(int command)
       sl.down();
       sl.draw();
       drawShowing();
+      drawIndicators();
       ViewMan::getInstance()->updateView(this);
       return 2;
     }
@@ -199,6 +242,7 @@ int VTimerList::handleCommand(int command)
       sl.pageUp();
       sl.draw();
       drawShowing();
+      drawIndicators();
       ViewMan::getInstance()->updateView(this);
       return 2;
     }
@@ -207,6 +251,7 @@ int VTimerList::handleCommand(int command)
       sl.pageDown();
       sl.draw();
       drawShowing();
+      drawIndicators();
       ViewMan::getInstance()->updateView(this);
       return 2;
     }
diff --git a/vtimerlist.h b/vtimerlist.h
index 415f561..3fa0b81 100644
--- a/vtimerlist.h
+++ b/vtimerlist.h
@@ -55,8 +55,12 @@ class VTimerList : public View, public TimerReceiver
     void drawClock();
     void drawShowing();
     void drawData();
+    void drawIndicators();
 
     Region clockRegion;
+    Region indicatorsRegion;
+
+    bool flipflop;
 };
 
 #endif
diff --git a/wselectlist.h b/wselectlist.h
index c411cb7..a556af8 100644
--- a/wselectlist.h
+++ b/wselectlist.h
@@ -51,7 +51,7 @@ class WSelectList : public Widget
 
     int getTopOption();
     int getNumOptions();
-    int getBottomOption();
+    int getBottomOption();     // actually returns bottom + 1 i.e. the one just past display ?!
     int getCurrentOption();
 
     void hintSetCurrent(int index);
-- 
2.39.5