home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pcmagazi / 1992 / 04 / scroller.h < prev    next >
C/C++ Source or Header  |  1992-01-27  |  3KB  |  80 lines

  1. // scroller.h RHS 10/15/91
  2.  
  3. #if !defined(SCROLLER_H)
  4. #define SCROLLER_H
  5.  
  6. #include"window.h"
  7.  
  8. enum { SCROLL_HOME, SCROLL_END, SCROLL_PGUP, SCROLL_PGDN, 
  9.     SCROLL_UP, SCROLL_DN };
  10.  
  11. const BYTE SCROLLER_NORMAL  = 0x00;
  12. const BYTE SCROLLER_CURRENT = 0x01;
  13. const BYTE SCROLLER_SELECTED_NORMAL = 0x02;
  14. const BYTE SCROLLER_SELECTED_CURRENT = (SCROLLER_SELECTED_NORMAL | SCROLLER_CURRENT);
  15. const BYTE SCROLLER_DELETED = 0x04;
  16. const BYTE SCROLLER_DELETED_CURRENT = (SCROLLER_DELETED | SCROLLER_CURRENT);
  17.  
  18. const BYTE SCROLLER_NORMAL_COLORS = MakeBG(VID_BLUE)+VID_WHITE;
  19. const BYTE SCROLLER_CURRENT_COLORS = MakeBG(VID_LIGHTGRAY)+VID_WHITE;
  20. const BYTE SCROLLER_SELECTED_NORMAL_COLORS = MakeBG(VID_BLUE)+VID_YELLOW;
  21. const BYTE SCROLLER_SELECTED_CURRENT_COLORS = MakeBG(VID_LIGHTGRAY)+VID_YELLOW;
  22. const BYTE SCROLLER_DELETED_NORMAL_COLORS = MakeBG(VID_BLUE)+VID_LIGHTGRAY;
  23. const BYTE SCROLLER_DELETED_CURRENT_COLORS = MakeBG(VID_LIGHTGRAY)+VID_DARKGRAY;
  24.        
  25. class Scroller : public Window 
  26.     {
  27. private:
  28.     int bufsize;
  29.     BYTE ScrColors[6];
  30. protected:
  31.     int startBuf;               // first buffer displayed
  32.     int endBuf;                 // last buffer displayed
  33.     int curBuf;                 // current buffer
  34.     int numbuffers;             // total buffers created
  35.     BOOL buffer_changed;
  36.  
  37.     void DispBuffer(int line, int bufnum, BYTE attribute = SCROLLER_NORMAL);
  38.     virtual BYTE Colors(BYTE color_offset)  {   return ScrColors[color_offset]; }
  39.     virtual void BufMgt(int action) = 0;
  40.  
  41. public:
  42.     Scroller(char *title, DWORD position, BYTE colors, 
  43.         int numbuffers, int bufsize);
  44.     Scroller(char *title, DWORD position, BYTE colors = SCROLLER_NORMAL_COLORS);
  45.     int Init(int num, int size);
  46.     void Open(void);
  47.     void Paint(void);
  48.  
  49.     void Home(void);
  50.     void End(void);
  51.     void PgUp(void);
  52.     void PgDn(void);
  53.     void Up(void);
  54.     void Down(void);
  55.  
  56.     void SetColors(
  57.         BYTE current        =   SCROLLER_CURRENT_COLORS,
  58.         BYTE select_current =   SCROLLER_SELECTED_CURRENT_COLORS,
  59.         BYTE select_normal  =   SCROLLER_SELECTED_NORMAL_COLORS,
  60.         BYTE normal         =   SCROLLER_NORMAL_COLORS,
  61.         BYTE del            =   SCROLLER_DELETED_NORMAL_COLORS,
  62.         BYTE del_cur        =   SCROLLER_DELETED_CURRENT_COLORS
  63.         );
  64.  
  65.     BYTE Select(void);          // strictly a toggle
  66.     int NumBufs(void)           {   return numbuffers;      }
  67.  
  68.     virtual char *GetBuffer(int bufnum) = 0; 
  69.     virtual BYTE GetAttribute(int bufnum) = 0; 
  70.     virtual void SetBuffer(int bufnum, char *newbuf) = 0;
  71.     virtual void SetAttribute(int bufnum, BYTE newattrib) = 0;
  72.     virtual int MaxBufs(void) = 0;
  73. #ifdef NOTYET
  74.     void Delete(void);
  75. #endif
  76.     };
  77.  
  78. #endif
  79.  
  80.