home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / MODEM / UWPC201.ZIP / UW-SRC.ZIP / DISPLAY.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-31  |  6.2 KB  |  192 lines

  1. //-------------------------------------------------------------------------
  2. //
  3. // DISPLAY.H - Classes for handling the display of window information.
  4. // 
  5. //  This file is part of UW/PC - a multi-window comms package for the PC.
  6. //  Copyright (C) 1990-1991  Rhys Weatherley
  7. //
  8. //  This program is free software; you can redistribute it and/or modify
  9. //  it under the terms of the GNU General Public License as published by
  10. //  the Free Software Foundation; either version 1, or (at your option)
  11. //  any later version.
  12. //
  13. //  This program is distributed in the hope that it will be useful,
  14. //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. //  GNU General Public License for more details.
  17. //
  18. //  You should have received a copy of the GNU General Public License
  19. //  along with this program; if not, write to the Free Software
  20. //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. //
  22. // Revision History:
  23. // ================
  24. //
  25. //  Version  DD/MM/YY  By  Description
  26. //  -------  --------  --  --------------------------------------
  27. //    1.0    20/03/91  RW  Original Version of DISPLAY.H
  28. //    1.1    05/05/91  RW  Start adding Windows 3.0 information.
  29. //    1.2    08/06/91  RW  Add support for cut and paste.
  30. //
  31. // You may contact the author by:
  32. // =============================
  33. //
  34. //  e-mail: rhys@cs.uq.oz.au
  35. //    mail: Rhys Weatherley
  36. //          5 Horizon Drive
  37. //          Jamboree Heights
  38. //          Queensland 4074
  39. //        Australia
  40. //
  41. //-------------------------------------------------------------------------
  42.  
  43. #ifndef __DISPLAY_H__
  44. #define    __DISPLAY_H__
  45.  
  46. #include "extern.h"        // External DOS and Windows 3.0 declarations.
  47.  
  48. //
  49. // Define the available clearing types for "UWDisplay::clear".
  50. //
  51. #define    CLR_ALL        0        // Clear the whole screen.
  52. #define    CLR_END_LINE    1        // Clear to end of current line.
  53. #define CLR_END_SCREEN    2        // Clear to end of screen.
  54. #define CLR_ST_LINE    3        // Clear to start of current line.
  55. #define CLR_ST_SCREEN    4        // Clear to start of screen.
  56.  
  57. //
  58. // Define the general window display class that provides all of
  59. // the facilities for processing a displayed UW window.  If the
  60. // "width" attribute is zero after object creation, then not
  61. // enough memory was available for the display.
  62. //
  63. class    UWDisplay {
  64.  
  65. protected:
  66.  
  67.     unsigned *screen;        // Screen RAM buffer.
  68.     int    attop;            // Non-zero when top-most display.
  69.     int    attr,scrollattr;    // Normal and scrolling attributes.
  70.     int    wrap52;            // Non-zero for a VT52 wrap.
  71.  
  72. #ifdef    UWPC_WINDOWS
  73.     int    curson;            // Non-zero if the cursor is on.
  74.  
  75.     // Repaint and area of the current window.  If hDC    //
  76.     // is NULL, then GetDC will be used to get a context. //
  77.     void    repaint (int x1,int y1,int x2,int y2,HDC hDC=NULL);
  78.  
  79.     // Turn the cursor off while performing some window update //
  80.     void    cursoroff (void);
  81.  
  82.     // Turn the cursor back on now //
  83.     void    cursoron  (void);
  84. #endif
  85.  
  86.     // Define some internal screen manipulation routines //
  87.     void    show    (int X,int Y,unsigned pair);
  88.     void    scroll    (int x1,int y1,int x2,int y2,int lines,int attribute);
  89.     void    setcurs    (void);
  90.  
  91. public:
  92.  
  93.     int    width,height;        // Size of the display.
  94.     int    x,y;            // Current cursor position.
  95.  
  96. #ifdef    UWPC_WINDOWS
  97.     int    wNumber;        // Window number.
  98.     HWND    hWnd;            // Window's handle.
  99. #endif
  100.  
  101.     UWDisplay (int number);
  102.     ~UWDisplay (void);
  103.  
  104.     // Bring the display to the top on the screen, or
  105.     // disable it from being the top display.  This must
  106.     // only be called by the UW protocol handling classes,
  107.     // never by clients.
  108.     void    top    (int bringup);
  109.  
  110.     // Send a character to the display directly with no
  111.     // translation of control characters.  If 'vt52wrap'
  112.     // is non-zero, the VT52 line wrapping scheme is used.
  113.     void    send    (int ch,int vt52wrap=0);
  114.  
  115.     // Perform a carriage return operation on the display.
  116.     void    cr    (void);
  117.  
  118.     // Perform a line feed operation on the display.  When
  119.     // the cursor is on the last display line, the display
  120.     // will be scrolled one line up in the scrolling colour.
  121.     void    lf    (void);
  122.  
  123.     // Move back one position on the display.  If 'wrap'
  124.     // is non-zero, wrap to previous lines as well.
  125.     void    bs    (int wrap=1);
  126.  
  127.     // Tab across to the next tab stop of the supplied size.
  128.     void    tab    (int vt52wrap=0,int tabsize=8);
  129.  
  130.     // Ring the terminal bell - this directly calls
  131.     // the hardware routines to ring it.
  132.     void    bell    (void);
  133.  
  134.     // Move the cursor to a new position on the display.
  135.     // The origin is at (0,0).
  136.     void    move    (int newx,int newy);
  137.  
  138.     // Clear the display according to a particular clearing
  139.     // type.  This function does not move the cursor position.
  140.     void    clear    (int clrtype=CLR_ALL);
  141.  
  142.     // Insert a new line on the display.
  143.     void    insline    (void);
  144.  
  145.     // Delete the current line from the display.
  146.     void    delline    (void);
  147.  
  148.     // Insert a new character into the current line.
  149.     // If 'ch' is -1, then insert a blank and don't move cursor.
  150.     void    inschar    (int ch);
  151.  
  152.     // Delete the current character, and append the given
  153.     // character to the current line.
  154.     void    delchar    (int ch=' ');
  155.  
  156.     // Set the normal printing attribute.
  157.     void    setattr    (int attribute)
  158.           { attr = attribute; };
  159.  
  160.     // Get the normal printing attribute.
  161.     int    getattr (void) { return (attr); };
  162.  
  163.     // Set the scrolling attribute for printing.
  164.     void    setscroll (int attribute)
  165.           { scrollattr = attribute; };
  166.  
  167.     // Scroll the screen up or down one line.
  168.     void    scrollscreen (int up);
  169.  
  170.     // If the screen has a status line, then set it to the
  171.     // given string, otherwise ignore the request.  If "str"
  172.     // is NULL, then clear the status line (i.e. don't display).
  173.     void    status    (char *str,int length);
  174.  
  175.     // Mark a rectangle on the screen for cut-and-paste.
  176.     // Two calls to this routine will remove the mark.
  177.     void    markcut    (int x1,int y1,int x2,int y2);
  178.  
  179.     // Copy screen data into a clipboard buffer.  The
  180.     // length of the written data is returned.
  181.     int    copycut    (int x1,int y1,int x2,int y2,char *buffer);
  182.  
  183. #ifdef    UWPC_WINDOWS
  184.     // Process the messages for a display window.
  185.     // This is a catch-all after the master routine
  186.     // processes the messages.
  187.     LONG    mesgs    (WORD message,WORD wParam,LONG lParam);
  188. #endif
  189. };
  190.  
  191. #endif    /* __DISPLAY_H__ */
  192.