home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_09 / 1109051a < prev    next >
Text File  |  1993-07-08  |  2KB  |  86 lines

  1. //  CStrWnd.h
  2.  
  3. /*
  4. This window class is a derivation of CMDIChildWnd
  5. which provides the following additional
  6. functionality:
  7.  
  8.     1.  It provides a text buffer in the form of a
  9.     CStringArray, which is displayed in the window.
  10.  
  11.     2.  Scrolling and cursor key functions are
  12.     provided to navigate around the contents of the
  13.     text buffer.
  14.  
  15. Derived classes must provide routines for loading
  16. and managing the text buffer.
  17. */
  18.  
  19. #if !defined (_CSTRWND_H_)
  20. #define     _CSTRWND_H_
  21.  
  22. class CStrWnd : public CMDIChildWnd
  23. {
  24. public:
  25. CStrWnd (const char * window_name);
  26.  
  27. virtual afx_msg void OnPaint ();
  28. virtual afx_msg void OnVScroll
  29.         (UINT nSBCode, UINT npos,
  30.          CScrollBar * pScrollBar);
  31. virtual afx_msg void OnHScroll
  32.         (UINT nSBCode, UINT npos,
  33.          CScrollBar * pScrollBar);
  34. virtual afx_msg void OnKeyDown
  35.         (UINT nChar, UINT nRepCnt, UINT nFlags);
  36.  
  37. virtual afx_msg void OnDocStart ();
  38.         // Called when CNTL-HOME pressed
  39. virtual afx_msg void OnDocEnd ();
  40.         // Called when CNTL-END pressed
  41. virtual afx_msg void OnLineRight ();
  42.         //  Called when CNTL-RIGHT pressed
  43. virtual afx_msg void OnLineLeft ();
  44.         //  Called when CNTL-LEFT pressed
  45.  
  46. DECLARE_MESSAGE_MAP ();
  47.  
  48. //  Functions for accessing and managing text_buffer
  49.  
  50. int BufAddAtEnd (const char * line)
  51.     //  Adds a line to the end of text_buffer
  52.     //  and returns its index
  53.     {return text_buffer.Add (line);}
  54.  
  55. void UpdateScreen ();
  56.     //  Provided for derived classes to request a
  57.     //  screen update.  Ensures that the last line
  58.     //  of the buffer is always on the screen.
  59.  
  60. protected:
  61. CStringArray text_buffer;
  62.  
  63. private:
  64. void SetVerticalScroll ();
  65.  
  66. int current_first_row;
  67.         //  The first row of text_buffer
  68.         //  displayed on the screen
  69. int current_first_col;
  70.         //  The first column of text_buffer
  71.         //  displayed on the screen
  72. int no_of_lines;
  73.         //  Number of lines in the window
  74. int no_of_chars_in_line;
  75.         //  Max no of chars that will fit on a line
  76. int h_scroll_flag;
  77.         //  Non-zero if a horizontal scroll bar has
  78.         //  been enabled.  Once enabled, the bar
  79.         //  is  never disabled.
  80. int length_of_longest_line;
  81.         //  The longest line found so far in the text
  82.         //  being displayed.  Used for horizontal
  83.         //  scrolling control.
  84. };
  85. #endif
  86.