home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume8 / xdbx / part01 / windows.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-28  |  6.5 KB  |  224 lines

  1. /*****************************************************************************
  2.  *
  3.  *  xdbx - X Window System interface to dbx
  4.  *
  5.  *  Copyright 1989, 1990 The University of Texas at Austin
  6.  *
  7.  *  Permission to use, copy, modify, and distribute this software and its
  8.  *  documentation for any purpose and without fee is hereby granted,
  9.  *  provided that the above copyright notice appear in all copies and that
  10.  *  both that copyright notice and this permission notice appear in
  11.  *  supporting documentation, and that the name of The University of Texas
  12.  *  not be used in advertising or publicity pertaining to distribution of
  13.  *  the software without specific, written prior permission.  The
  14.  *  University of Texas makes no representations about the suitability of
  15.  *  this software for any purpose.  It is provided "as is" without express
  16.  *  or implied warranty.
  17.  *
  18.  *  THE UNIVERSITY OF TEXAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  19.  *  SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  20.  *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS BE LIABLE FOR ANY
  21.  *  SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  22.  *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  23.  *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  24.  *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  25.  *
  26.  *  Author:      Po Cheung, The University of Texas at Austin
  27.  *  Created:       March 10, 1989
  28.  *
  29.  *****************************************************************************/
  30.  
  31. /*  windows.c:
  32.  *
  33.  *    CreateTitleBar() :    Create title bar.
  34.  *    CreateFileLabel() :    Create file label in file window.
  35.  *    CreateLineLabel() :    Create line label in file window.
  36.  *    CreateFileWindow() :    Create file window.
  37.  *    CreateMessageWindow() :    Create message window.
  38.  *    CreateDisplayWindow() :    Create display window.
  39.  *    CreateSubWindows() :    Create the subwindows.
  40.  *    UpdateFileLabel() :    Update file label.
  41.  *    UpdateLineLabel() :    Update line label.
  42.  *    UpdateMessageWindow() :    Update message window.
  43.  */
  44.  
  45. #include "global.h"
  46.  
  47. Widget    fileWindow,            /* parent of fileLabel and lineLabel */
  48.     messageWindow,            /* window for displaying messages */
  49.     separator,            /* separator in vpane */
  50.     displayWindow;            /* area for displaying variables */
  51.  
  52. static Widget     fileLabel,        /* filename of displayed text */
  53.         lineLabel;        /* line number of caret position */
  54.  
  55. /*
  56.  *  Private routines for creating various subwindows for xdbx.
  57.  */
  58.  
  59. static void CreateFileLabel(parent)
  60. Widget parent;
  61. {
  62.     Arg     args[MAXARGS];
  63.     Cardinal     n;
  64.  
  65.     n = 0;
  66.     XtSetArg(args[n], XtNlabel, (XtArgVal) "No Source File");           n++;
  67.     XtSetArg(args[n], XtNborderWidth, (XtArgVal) 0);                   n++;
  68.     fileLabel = XtCreateManagedWidget("fileLabel", labelWidgetClass, 
  69.                       parent, args, n);
  70. }
  71.  
  72. static void CreateLineLabel(parent)
  73. Widget parent;
  74. {
  75.     Arg     args[MAXARGS];
  76.     Cardinal     n;
  77.  
  78.     n = 0;
  79.     XtSetArg(args[n], XtNlabel, (XtArgVal) "");                   n++;
  80.     XtSetArg(args[n], XtNborderWidth, (XtArgVal) 0);                   n++;
  81.     XtSetArg(args[n], XtNfromHoriz, (XtArgVal) fileLabel);              n++;
  82.     XtSetArg(args[n], XtNhorizDistance, (XtArgVal) 0);              n++;
  83.     lineLabel = XtCreateManagedWidget("lineLabel", labelWidgetClass, 
  84.                       parent, args, n);
  85. }
  86.  
  87. static void CreateFileWindow(parent)
  88. Widget parent;
  89. {
  90.     Arg     args[MAXARGS];
  91.     Cardinal     n;
  92.  
  93.     n = 0;
  94.     XtSetArg(args[n], XtNshowGrip, (XtArgVal) False);            n++;
  95.     fileWindow = XtCreateManagedWidget("fileWindow", formWidgetClass, 
  96.                        parent, args, n);
  97.     CreateFileLabel(fileWindow);
  98.     CreateLineLabel(fileWindow);
  99. }
  100.  
  101. static void CreateMessageWindow(parent)
  102. Widget parent;
  103. {
  104.     Arg     args[MAXARGS];
  105.     Cardinal     n;
  106.  
  107.     n = 0;
  108.     XtSetArg(args[n], XtNlabel, (XtArgVal) "");             n++;
  109.     XtSetArg(args[n], XtNjustify, (XtArgVal) XtJustifyLeft);              n++;
  110.     XtSetArg(args[n], XtNshowGrip, (XtArgVal) False);            n++;
  111.     messageWindow = XtCreateManagedWidget("messageWindow", labelWidgetClass,
  112.                       parent, args, n);
  113. }
  114.  
  115. /*  Create a window for displaying variables as specified by the display
  116.  *  command in dbx.
  117.  */
  118. static void CreateDisplayWindow(parent)
  119. Widget parent;
  120. {
  121.     Arg     args[MAXARGS];
  122.     Cardinal     n;
  123.  
  124.     n = 0;
  125.     XtSetArg(args[n], XtNborderWidth, (XtArgVal) 0);                    n++;
  126.     XtSetArg(args[n], XtNmin, (XtArgVal) 2);                 n++;
  127.     XtSetArg(args[n], XtNmax, (XtArgVal) 2);                 n++;
  128.     XtSetArg(args[n], XtNshowGrip, (XtArgVal) False);            n++;
  129.     separator = XtCreateWidget("", labelWidgetClass, parent, args, n);
  130.  
  131.     n = 0;
  132.     XtSetArg(args[n], XtNeditType, (XtArgVal) XawtextRead);        n++;
  133.     displayWindow = XtCreateWidget("displayWindow", asciiTextWidgetClass, 
  134.                    parent, args, n);
  135.  
  136.     if (app_resources.displayWindow) {
  137.     XtManageChild(separator);
  138.     XtManageChild(displayWindow);
  139.     }
  140. }
  141.  
  142.  
  143. /*  PUBLIC ROUTINES */
  144. /*
  145.  *  Top level function for creating all the xdbx subwindows.
  146.  */
  147. void CreateSubWindows(parent)
  148. Widget parent;
  149. {
  150.     Widget    vpane;        /* outer widget containing various subwindows */
  151.     Arg     args[MAXARGS];
  152.     Cardinal     n;
  153.  
  154.     n = 0;
  155.     vpane = XtCreateManagedWidget("vpane", panedWidgetClass, parent, args, n);
  156.  
  157.     CreateFileWindow(vpane);
  158.     CreateSourceWindow(vpane);
  159.     CreateMessageWindow(vpane);
  160.     CreateCommandPanel(vpane);
  161.     CreateDialogWindow(vpane);
  162. #ifndef BSD
  163.     CreateDisplayWindow(vpane);
  164. #endif
  165.  
  166. /*
  167.  *  Routines for updating fields for the filename and line number
  168.  *  in the file window, and the execution status in the message window.
  169.  */
  170.  
  171. void UpdateFileLabel(string)
  172. char *string;
  173. {
  174.     Arg     args[MAXARGS];
  175.     Cardinal     n;
  176.  
  177.     n = 0;
  178.     XtSetArg(args[n], XtNlabel, (XtArgVal) string);                n++;
  179.     XtSetValues(fileLabel, args, n);
  180. }
  181.  
  182. void UpdateLineLabel(line)
  183. Cardinal line;
  184. {
  185.     Arg     args[MAXARGS];
  186.     Cardinal     n;
  187.     char     string[10];
  188.  
  189.     n = 0;
  190.     if (line > 0)
  191.         sprintf(string, "%d", line);
  192.     else
  193.     strcpy(string, "");
  194.     XtSetArg(args[n], XtNlabel, (XtArgVal) string);            n++;
  195.     XtSetValues(lineLabel, args, n);
  196. }
  197.  
  198. void UpdateMessageWindow(format, arg)
  199. char *format, *arg;
  200. {
  201.     char     message[LINESIZ], string[LINESIZ];
  202.     Arg     args[MAXARGS];
  203.     Cardinal     n;
  204.  
  205.     strcpy(message, "  ");
  206.     sprintf(string, format, arg);
  207.     strcat(message, string);
  208.     n = 0;
  209.     XtSetArg(args[n], XtNlabel, (XtArgVal) message);        n++;
  210.     XtSetValues(messageWindow, args, n);
  211. }
  212.  
  213. void ClearMessageWindow()
  214. {
  215.     Arg     args[MAXARGS];
  216.     Cardinal     n;
  217.  
  218.     n = 0;
  219.     XtSetArg(args[n], XtNlabel, (XtArgVal) "");            n++;
  220.     XtSetValues(messageWindow, args, n);
  221. }
  222.  
  223.