home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1998 February / PCOnline_02_1998.iso / filesbbs / dos / listz21s.exe / LSZ_AREA.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-07  |  2.3 KB  |  105 lines

  1. /*
  2.  * This file is part of Listerz v2.0 (VE)
  3.  *
  4.  * Copyright (C) 1995-1997 by Branislav L. Slantchev
  5.  * A Product of Silicon Creations, Inc.
  6.  *
  7.  * This file is distributed under the terms and conditions of the GNU
  8.  * General Public License. For more information, refer to the file
  9.  * Copying.Doc which is included in the archive.
  10. */
  11. #include "lsz_area.h"
  12. #include "lsz_appl.h"
  13. #include "str.h"
  14.  
  15. #ifndef PB_SDK
  16.     #include <string.h>
  17.     #include <conio.h>
  18. #else
  19.     #include "pblibc.h"
  20.     #include "pblsdk.h"
  21. #endif
  22.  
  23. // pointer to the current application
  24. // we use it to obtain the config record for colors
  25. extern Application *application;
  26.  
  27. static void
  28. DrawGroup(const char *name, short maxlen, Boolean off)
  29. {
  30.     char buf[255];
  31.  
  32.     if( off ) textattr(application->config()->lbox_Color);
  33.     else textattr(application->config()->lbox_Hilite);
  34.  
  35.     strcent(buf, name, maxlen);
  36.     buf[maxlen] = EOS;
  37.     cprintf(buf);
  38. }
  39.  
  40. static void
  41. DrawArea(const Area &area, short maxlen, Boolean off)
  42. {
  43.     FILECFG rec = (*(application->bucket()))[area.m_index];
  44.     char    buf[255];
  45.  
  46.     if( area.m_tagged )
  47.     {
  48.         if( off ) textattr(application->config()->lbox_TagColor);
  49.         else textattr(application->config()->lbox_TagHilite);
  50.         putch(application->config()->lbox_TagChar);
  51.     }
  52.  
  53.     if( off ) textattr(application->config()->lbox_Color);
  54.     else textattr(application->config()->lbox_Hilite);
  55.  
  56.     if( !area.m_tagged ) putch(' ');
  57.  
  58.     strcent(buf, rec.name, maxlen - 1);
  59.     buf[maxlen - 1] = EOS;
  60.     cprintf(buf);
  61. }
  62.  
  63. /*
  64.  ****************************************************************************
  65.  * the FILEGROUP class (nodes of this type used in the lz_GroupList)
  66. */
  67. Group::Group(short num, const GROUP_PB &group)
  68. {
  69.     strcpy(m_name, group.name);
  70.     m_num = num;
  71. }
  72.  
  73. void
  74. Group::select(const zPoint&, short maxlen, Boolean off)
  75. {
  76.     DrawGroup(m_name, maxlen, off);
  77. }
  78.  
  79. void
  80. Group::draw(const zPoint&, short maxlen)
  81. {
  82.     DrawGroup(m_name, maxlen, True);
  83. }
  84.  
  85. /*
  86.  ****************************************************************************
  87.  * the file Area class which only stores the index of the area in question
  88. */
  89. Area::Area(short index)
  90. {
  91.     m_index = index;
  92. }
  93.  
  94. void
  95. Area::select(const zPoint&, short maxlen, Boolean off)
  96. {
  97.     DrawArea(*this, maxlen, off);
  98. }
  99.  
  100. void
  101. Area::draw(const zPoint&, short maxlen)
  102. {
  103.     DrawArea(*this, maxlen, True);
  104. }
  105.