home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / MODEM / UWPC201.ZIP / UW-SRC.ZIP / DIALOG.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-06  |  4.1 KB  |  144 lines

  1. //-------------------------------------------------------------------------
  2. //
  3. // DIALOG.H - Declarations for creating dialog boxes.  Only one dialog
  4. //          box can be active at any time, corresponding to the current
  5. //          window.  The code ensures that keys for changing windows
  6. //          will never be passed through to the default handlers.
  7. // 
  8. //  This file is part of UW/PC - a multi-window comms package for the PC.
  9. //  Copyright (C) 1990-1991  Rhys Weatherley
  10. //
  11. //  This program is free software; you can redistribute it and/or modify
  12. //  it under the terms of the GNU General Public License as published by
  13. //  the Free Software Foundation; either version 1, or (at your option)
  14. //  any later version.
  15. //
  16. //  This program is distributed in the hope that it will be useful,
  17. //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. //  GNU General Public License for more details.
  20. //
  21. //  You should have received a copy of the GNU General Public License
  22. //  along with this program; if not, write to the Free Software
  23. //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. //
  25. // Revision History:
  26. // ================
  27. //
  28. //  Version  DD/MM/YY  By  Description
  29. //  -------  --------  --  --------------------------------------
  30. //    1.0    11/04/91  RW  Original Version of DIALOG.H
  31. //
  32. // You may contact the author by:
  33. // =============================
  34. //
  35. //  e-mail: rhys@cs.uq.oz.au
  36. //    mail: Rhys Weatherley
  37. //          5 Horizon Drive
  38. //          Jamboree Heights
  39. //          Queensland 4074
  40. //        Australia
  41. //
  42. //-------------------------------------------------------------------------
  43.  
  44. #ifndef __DIALOG_H__
  45. #define    __DIALOG_H__
  46.  
  47. #include "client.h"        // Client processing routines.
  48.  
  49. //
  50. // Define the structure of a client dialog box handler.  Note
  51. // that a dialog box must always have a specified underlying client.
  52. // This default client will terminate whenever a key is pressed.
  53. //
  54. class    UWDialogBox : public UWClient {
  55.  
  56. protected:
  57.  
  58.     int    dx1,dy1,dx2,dy2;    // Corners of dialog box.
  59.     int    cleared;        // Non-zero when mark is cleared.
  60.  
  61.     // Terminate this dialog box and return to the previously
  62.     // active client in this window.
  63.     void    terminate (void);
  64.  
  65.     // Show a string on the screen in the dialog box.
  66.     void    showstring (int x,int y,char *str);
  67.  
  68. public:
  69.  
  70.     UWDialogBox (UWDisplay *wind,int x1,int y1,int x2,int y2);
  71.     ~UWDialogBox (void);
  72.  
  73.     virtual    char far *name    () { if (underneath)
  74.                        return (underneath -> name ());
  75.                       else
  76.                        return ((char far *)" DLG"); };
  77.     virtual    void    key    (int keypress);
  78.     virtual    void    remote    (int ch) { if (underneath)
  79.                          underneath -> remote (ch); };
  80.  
  81. };
  82.  
  83. //
  84. // Declare the structure of the dialog box to display UW/PC's help.
  85. //
  86. class    UWHelpBox : public UWDialogBox {
  87.  
  88. public:
  89.  
  90.     UWHelpBox (UWDisplay *wind);
  91.  
  92. };
  93.  
  94. //
  95. // Declare the structure of a query box (single character answers).
  96. //
  97. class    UWQueryBox : public UWDialogBox {
  98.  
  99. protected:
  100.  
  101.     char    *anschars;        // Answer characters.
  102.  
  103. public:
  104.  
  105.     // Create a query dialog box.  If "answers" is NULL,
  106.     // then the default answer string "yYnN\033" is used.
  107.     UWQueryBox (UWDisplay *wind,char *query,int qlen,char *answers=0);
  108.  
  109.     virtual    void    key    (int keypress);
  110.  
  111.     // Process the character provided by the user if it
  112.     // is in the answer string.  The string index is provided.
  113.     virtual    void    process    (int index);
  114.  
  115. };
  116.  
  117. //
  118. // Declare the structure of a pop-up line editing box.
  119. //
  120. #define    MAX_EDIT_SIZE    70
  121. class    UWEditBox : public UWDialogBox {
  122.  
  123. protected:
  124.  
  125.     char    buffer[MAX_EDIT_SIZE + 1];    // Buffer for the answer.
  126.     int    size;                // Size of edit area.
  127.     int    posn;                // Current editing position.
  128.     int    length;                // Current buffer length.
  129.  
  130. public:
  131.  
  132.     // Create a editing dialog box to get a string //
  133.     UWEditBox (UWDisplay *wind,char *prompt,int editsize);
  134.  
  135.     virtual    void    key    (int keypress);
  136.  
  137.     // Process a fully entered line.  If 'esc' is non-zero
  138.     // then the ESC key was pressed to abort the editing.
  139.     virtual    void    process    (int esc);
  140.  
  141. };
  142.  
  143. #endif    /* __DIALOG_H__ */
  144.