home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume3 / xdbx / part03 / windows.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-14  |  5.1 KB  |  174 lines

  1. /****************************************************************************** 
  2.  *
  3.  *  xdbx - X Window System interface to dbx
  4.  *
  5.  *  Copyright 1989 The University of Texas at Austin
  6.  *
  7.  *  Author:    Po Cheung
  8.  *  Date:    March 10, 1989
  9.  *
  10.  *  Permission to use, copy, modify, and distribute this software and
  11.  *  its documentation for any purpose and without fee is hereby granted,
  12.  *  provided that the above copyright notice appear in all copies and that
  13.  *  both that copyright notice and this permission notice appear in
  14.  *  supporting documentation.  The University of Texas at Austin makes no 
  15.  *  representations about the suitability of this software for any purpose.  
  16.  *  It is provided "as is" without express or implied warranty.
  17.  *
  18.  ******************************************************************************/
  19.  
  20.  
  21. #include "global.h"
  22.  
  23. /*
  24.  *  Private routines for creating various subwindows for xdbx.
  25.  */
  26.  
  27. static void CreateTitleBar(parent)
  28. Widget parent;
  29. {
  30.     Arg     args[MAXARGS];
  31.     Cardinal     n;
  32.  
  33.     n = 0;
  34.     XtSetArg(args[n], XtNlabel, (XtArgVal) TITLE);                   n++;
  35.     XtSetArg(args[n], XtNwidth, (XtArgVal) app_resources.shellWidth);     n++;
  36.     XtSetArg(args[n], XtNjustify, (XtArgVal) XtJustifyCenter);          n++;
  37.     XtSetArg(args[n], XtNresize, (XtArgVal) False);                  n++;
  38.     titleBar = XtCreateManagedWidget("titleBar", labelWidgetClass, parent,
  39.                      args, n);
  40. }
  41.  
  42. static void CreateFileLabel(parent)
  43. Widget parent;
  44. {
  45.     Arg     args[MAXARGS];
  46.     Cardinal     n;
  47.  
  48.     n = 0;
  49.     XtSetArg(args[n], XtNlabel, (XtArgVal) "No Source File");           n++;
  50.     XtSetArg(args[n], XtNwidth, (XtArgVal) app_resources.shellWidth);    n++;
  51.     XtSetArg(args[n], XtNborderWidth, (XtArgVal) 0);                   n++;
  52.     XtSetArg(args[n], XtNjustify, (XtArgVal) XtJustifyCenter);          n++;
  53.     XtSetArg(args[n], XtNresizable, (XtArgVal) False);              n++;
  54.     fileLabel = XtCreateManagedWidget("fileLabel", labelWidgetClass, 
  55.                       parent, args, n);
  56. }
  57.  
  58. static void CreateLineLabel(parent)
  59. Widget parent;
  60. {
  61.     Arg     args[MAXARGS];
  62.     Cardinal     n;
  63.     int     horizDistance;
  64.  
  65.     horizDistance = app_resources.shellWidth - app_resources.lineLabelWidth;
  66.     n = 0;
  67.     XtSetArg(args[n], XtNlabel, (XtArgVal) "");                   n++;
  68.     XtSetArg(args[n], XtNwidth, (XtArgVal) app_resources.lineLabelWidth); n++;
  69.     XtSetArg(args[n], XtNborderWidth, (XtArgVal) 0);                   n++;
  70.     XtSetArg(args[n], XtNresizable, (XtArgVal) False);              n++;
  71.     XtSetArg(args[n], XtNhorizDistance, (XtArgVal) horizDistance);      n++;
  72.     lineLabel = XtCreateManagedWidget("lineLabel", labelWidgetClass, 
  73.                       parent, args, n);
  74. }
  75.  
  76. static void CreateFileWindow(parent)
  77. Widget parent;
  78. {
  79.     Arg     args[MAXARGS];
  80.     Cardinal     n;
  81.  
  82.     n = 0;
  83.     XtSetArg(args[n], XtNdefaultDistance, 0);                           n++;
  84.     fileWindow = XtCreateManagedWidget("fileWindow", formWidgetClass, 
  85.                        parent, args, n);
  86.     CreateLineLabel(fileWindow);
  87.     CreateFileLabel(fileWindow);
  88. }
  89.  
  90. static void CreateMessageWindow(parent)
  91. Widget parent;
  92. {
  93.     Arg     args[MAXARGS];
  94.     Cardinal     n;
  95.  
  96.     n = 0;
  97.     XtSetArg(args[n], XtNlabel, (XtArgVal) "");             n++;
  98.     XtSetArg(args[n], XtNwidth, (XtArgVal) app_resources.shellWidth);    n++;
  99.     XtSetArg(args[n], XtNjustify, (XtArgVal) XtJustifyLeft);              n++;
  100.     XtSetArg(args[n], XtNresize, (XtArgVal) False);                  n++;
  101.     XtSetArg(args[n], XtNmin, (XtArgVal) app_resources.messageHeight);    n++;
  102.     XtSetArg(args[n], XtNmax, (XtArgVal) app_resources.messageHeight);    n++;
  103.     XtSetArg(args[n], XtNallowResize, (XtArgVal) False);              n++;
  104.     messageWindow = XtCreateManagedWidget("messageWindow", labelWidgetClass,
  105.                       parent, args, n);
  106. }
  107.  
  108. /*
  109.  *  Top level function for creating all the xdbx subwindows.
  110.  */
  111. void CreateSubWindows(parent)
  112. Widget parent;
  113. {
  114.     Arg     args[MAXARGS];
  115.     Cardinal     n;
  116.  
  117.     n = 0;
  118.     XtSetArg(args[n], XtNwidth, (XtArgVal) app_resources.shellWidth);    n++;
  119.     vpane = XtCreateManagedWidget("vpane", vPanedWidgetClass, parent, args, n);
  120.  
  121.     if (!app_resources.noTitleBar) CreateTitleBar(vpane);
  122.     CreateFileWindow(vpane);
  123.     CreateSourceWindow(vpane);
  124.     CreateMessageWindow(vpane);
  125.     CreateCommandPanel(vpane);
  126.     CreateDialogWindow(vpane);
  127.  
  128. /*
  129.  *  Public routines for updating fields for the filename and line number
  130.  *  in the file window, and the execution status in the message window.
  131.  */
  132.  
  133. void UpdateFileLabel(string)
  134. char *string;
  135. {
  136.     Arg     args[MAXARGS];
  137.     Cardinal     n;
  138.  
  139.     n = 0;
  140.     XtSetArg(args[n], XtNlabel, (XtArgVal) string);                n++;
  141.     XtSetValues(fileLabel, args, n);
  142. }
  143.  
  144. void UpdateLineLabel(line)
  145. Cardinal line;
  146. {
  147.     Arg     args[MAXARGS];
  148.     Cardinal     n;
  149.     char     string[10];
  150.  
  151.     n = 0;
  152.     if (line > 0)
  153.         sprintf(string, "%d", line);
  154.     else
  155.     strcpy(string, "");
  156.     XtSetArg(args[n], XtNlabel, (XtArgVal) string);                n++;
  157.     XtSetValues(lineLabel, args, n);
  158. }
  159.  
  160. void UpdateMessageWindow(message)
  161. char *message;
  162. {
  163.     char     string[LINESIZ];
  164.     Arg     args[MAXARGS];
  165.     Cardinal     n;
  166.  
  167.     strcpy(string, "  ");
  168.     strcat(string, message);
  169.     n = 0;
  170.     XtSetArg(args[n], XtNlabel, (XtArgVal) string);                n++;
  171.     XtSetValues(messageWindow, args, n);
  172. }
  173.