]> git.vomp.tv Git - vompclient.git/commitdiff
Columns in select lists. Looks better!
authorChris Tallon <chris@vomp.tv>
Sun, 14 Aug 2005 16:48:44 +0000 (16:48 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 14 Aug 2005 16:48:44 +0000 (16:48 +0000)
vchannellist.cc
vrecordinglist.cc
wselectlist.cc
wselectlist.h

index 4bbfdfc80f7e771f76d610cc883c7cf43b73eb64..81159f4c64357ff37b7fa16b65efdb3b2421f6bb 100644 (file)
@@ -68,6 +68,9 @@ void VChannelList::setList(List* tlist)
 {
   char str[500];
 
+  sl.addColumn(0);
+  sl.addColumn(50);
+
   chanList = tlist;
 
   Channel* chan;
@@ -78,7 +81,7 @@ void VChannelList::setList(List* tlist)
 
     while((chan = (Channel*)chanList->getCurrent()))
     {
-      sprintf(str, "%lu%s", chan->number, chan->name);
+      sprintf(str, "%lu\t%s", chan->number, chan->name);
       chan->index = sl.addOption(str, first);
       first = 0;
       chanList->next();
index 3c6b0a0e95c57bec73dee8ffe262aaaa01915feb..c8bd1e3b438c9f52b52347dbd6864d1ab89e3bd2 100644 (file)
@@ -71,6 +71,8 @@ void VRecordingList::setDir(Directory* tdir)
 void VRecordingList::drawData()
 {
   sl.clear();
+  sl.addColumn(0);
+  sl.addColumn(110);
 
   int first = 1;
 
@@ -78,10 +80,6 @@ void VRecordingList::drawData()
   char tempB[300]; // FIXME
   struct tm* btime;
 
-  char spaces[13];
-  char theNumber[10];
-  int theNumberLength;
-
   Directory* dir;
   recDir->dirList->reset();
   while((dir = (Directory*)recDir->dirList->getCurrent()))
@@ -92,14 +90,7 @@ void VRecordingList::drawData()
       continue;
     }
 
-    strcpy(spaces, "            ");
-    theNumberLength = snprintf(theNumber, 9, "%lu", dir->getNumRecordings());
-
-    spaces[11 - theNumberLength] = '\0';
-
-    //snprintf(tempA, 299, "<dir>            %s", dir->name);
-    snprintf(tempA, 299, "<dir> %s%s%s", theNumber, spaces, dir->name);
-    //int numSize = snprintf(tempA
+    snprintf(tempA, 299, "<dir> %lu\t%s", dir->getNumRecordings(), dir->name);
 
     dir->index = sl.addOption(tempA, first);
     first = 0;
@@ -119,7 +110,7 @@ void VRecordingList::drawData()
   {
     btime = localtime((time_t*)&rec->start);
     strftime(tempA, 299, "%0d/%0m %0H:%0M ", btime);
-    sprintf(tempB, "%s %s", tempA, rec->getProgName());
+    sprintf(tempB, "%s\t%s", tempA, rec->getProgName());
     rec->index = sl.addOption(tempB, first);
     first = 0;
     recList->next();
index c6e27f3a42f6109be03ac86381f026f1517ed5bc..101658c7b8fdcba33d1ca529e0af285a2b683c30 100644 (file)
@@ -26,6 +26,7 @@ WSelectList::WSelectList()
   selectedOption = 0;
   topOption = 0;
   numOptionsDisplayable = 0;
+  numColumns = 0;
 }
 
 WSelectList::~WSelectList()
@@ -44,6 +45,7 @@ void WSelectList::clear()
   selectedOption = 0;
   topOption = 0;
   numOptionsDisplayable = 0;
+  numColumns = 0;
 }
 
 void WSelectList::hintSetCurrent(int index)
@@ -98,16 +100,47 @@ void WSelectList::draw()
     if (i == selectedOption)
     {
       rectangle(0, ypos, width, fontHeight, Colour::SELECTHIGHLIGHT);
-      drawText(options[i], 5, ypos, Colour::DARKTEXT);
+      drawOptionLine(options[i], 5, ypos, Colour::DARKTEXT);
     }
     else
     {
-      drawText(options[i], 5, ypos, Colour::LIGHTTEXT);
+      drawOptionLine(options[i], 5, ypos, Colour::LIGHTTEXT);
     }
     ypos += ySeperation;
   }
 }
 
+void WSelectList::addColumn(int x)
+{
+  if (numColumns == 10) return;
+  columns[numColumns++] = x;
+}
+
+void WSelectList::drawOptionLine(char* text, int xpos, int ypos, Colour& colour)
+{
+  if (!numColumns)
+  {
+    drawText(text, xpos, ypos, colour);
+  }
+  else
+  {
+    char buffer[200];
+    strncpy(buffer, text, 199);
+    int currentColumn = 0;
+    char* pointer;
+
+    pointer = strtok(buffer, "\t");
+    while(pointer)
+    {
+      drawText(pointer, xpos + columns[currentColumn], ypos, colour);
+      currentColumn++;
+      if (currentColumn == 10) return;
+      pointer = strtok(NULL, "\t");
+    }
+  }
+}
+
+
 void WSelectList::up()
 {
   if (selectedOption > 0)
index 66d8e287be498478ab30286012c365c0ed277a54..23c6caebeb0d21a7a2b4044e5528504a56f03f85 100644 (file)
@@ -33,6 +33,7 @@ class WSelectList : public Box
     WSelectList();
     ~WSelectList();
     void clear();
+    void addColumn(int x);
 
     int addOption(char* text, int selected);
     void draw();
@@ -51,11 +52,15 @@ class WSelectList : public Box
     void hintSetTop(int index);
 
   private:
+    void drawOptionLine(char* text, int xpos, int ypos, Colour& colour);
+
     char* options[500];
     int numOptions;
     int selectedOption;
     int topOption;
     int numOptionsDisplayable;
+    int columns[10];
+    int numColumns;
 };
 
 #endif