home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / df3os2.zip / TEXTBOX.H < prev    next >
C/C++ Source or Header  |  1993-09-27  |  3KB  |  88 lines

  1. // ------------- textbox.h
  2.  
  3. #ifndef TEXTBOX_H
  4. #define TEXTBOX_H
  5.  
  6. #include "control.h"
  7.  
  8. const int SHORTCUTCHAR = '~';
  9.  
  10. class ScrollBar;
  11.  
  12. class TextBox : public Control    {
  13.     ScrollBar *hscrollbar;  // horizontal scroll bar
  14.     ScrollBar *vscrollbar;  // vertical scroll bar
  15.     unsigned *TextPointers; // -> list of line offsets
  16.     Bool resetscrollbox;
  17.     void OpenWindow();
  18. protected:
  19.     // ---- text buffer
  20.     String *text;           // window text
  21.     int wlines;             // number of lines of text
  22.     int textwidth;          // width of longest line in textbox
  23.     // ---- text display
  24.     int wtop;               // text line on top of display
  25.     int wleft;              // left position in window viewport
  26.     int BlkBegLine;         // beginning line of marked block
  27.     int BlkBegCol;          // beginning column of marked block
  28.     int BlkEndLine;         // ending line of marked block
  29.     int BlkEndCol;          // ending column of marked block
  30.     int shortcutfg;         // shortcut key color
  31.     const char *TextLine(int line)
  32.         { return (const char *)(*text) + *(TextPointers+line); }
  33.     int DisplayShortcutField(
  34.         String sc, int x, int y, int fg, int bg);
  35.     void WriteShortcutLine(int lno, int fg, int bg);
  36.     void WriteTextLine(int lno, int fg, int bg);
  37.     void BuildTextPointers();
  38.     void SetScrollBoxes();
  39. public:
  40.     TextBox(const char *ttl,int lf,int tp,int ht,int wd,DFWindow *par=0)
  41.                         : Control(ttl, lf, tp, ht, wd, par)
  42.             { OpenWindow(); }
  43.     TextBox(const char *ttl, int ht, int wd, DFWindow *par=0)
  44.                         : Control(ttl, ht, wd, par)
  45.             { OpenWindow(); }
  46.     TextBox(int lf, int tp, int ht, int wd, DFWindow *par=0)
  47.                         : Control(lf, tp, ht, wd, par)
  48.             { OpenWindow(); }
  49.     TextBox(int ht, int wd, DFWindow *par=0) : Control(ht,wd,par)
  50.             { OpenWindow(); }
  51.     TextBox(const char *ttl)    : Control(ttl)
  52.             { OpenWindow(); }
  53.     // -------- textbox API messages
  54.     virtual void ScrollUp();
  55.     virtual void ScrollDown();
  56.     virtual void ScrollRight();
  57.     virtual void ScrollLeft();
  58.     virtual void PageUp();
  59.     virtual void PageDown();
  60.     virtual void PageRight();
  61.     virtual void PageLeft();
  62.     virtual void Home();
  63.     virtual void End();
  64.     virtual void CloseWindow();
  65.     virtual void AddText(const char *txt);
  66.     virtual void SetText(const char *txt);
  67.     virtual void SetTextLength(unsigned int len);
  68.     virtual void ClearText();
  69.     virtual void Show();
  70.     virtual void Paint();
  71.     virtual void Keyboard(int key);
  72.     String ExtractTextLine(int lno);
  73.     virtual const String GetText() { return *text; }
  74.     unsigned int TextLength()
  75.         { return text ? text->Strlen() : 0; }
  76.     void ClearTextBlock()
  77.         { BlkBegLine=BlkEndLine=BlkBegCol=BlkEndCol=0; }
  78.     void HorizontalPagePosition(int pct);
  79.     void VerticalPagePosition(int pct);
  80.     int LineCount() { return wlines; }
  81.     int TextWidth() { return textwidth; }
  82.     virtual void SetScrollBars();
  83.     int LineLength(int lno);
  84. };
  85.  
  86. #endif
  87.  
  88.