windows.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002  *  Based on
00003  *  xdbx - X Window System interface to dbx
00004  *
00005  *  Copyright 1989, 1990 The University of Texas at Austin
00006  *
00007  *  Permission to use, copy, modify, and distribute this software and its
00008  *  documentation for any purpose and without fee is hereby granted,
00009  *  provided that the above copyright notice appear in all copies and that
00010  *  both that copyright notice and this permission notice appear in
00011  *  supporting documentation, and that the name of The University of Texas
00012  *  not be used in advertising or publicity pertaining to distribution of
00013  *  the software without specific, written prior permission.  The
00014  *  University of Texas makes no representations about the suitability of
00015  *  this software for any purpose.  It is provided "as is" without express
00016  *  or implied warranty.
00017  *
00018  *  THE UNIVERSITY OF TEXAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
00019  *  SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
00020  *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS BE LIABLE FOR ANY
00021  *  SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
00022  *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
00023  *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
00024  *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00025  *
00026  *  Author:     Po Cheung, The University of Texas at Austin
00027  *  Created:    March 10, 1989
00028  *
00029  *****************************************************************************/
00030 
00031 /*  windows.c:
00032  *
00033  *    CreateTitleBar() :        Create title bar.
00034  *    CreateFileLabel() :       Create file label in file window.
00035  *    CreateLineLabel() :       Create line label in file window.
00036  *    CreateFileWindow() :      Create file window.
00037  *    CreateMessageWindow() :   Create message window.
00038  *    CreateSubWindows() :      Create the subwindows.
00039  *    UpdateFileLabel() :       Update file label.
00040  *    UpdateLineLabel() :       Update line label.
00041  *    UpdateMessageWindow() :   Update message window.
00042  */
00043 
00044 #include "x_ptyx.h"
00045 #include "x_data.h"
00046 #include "global.h"
00047 #include "version.h"
00048 
00049 extern Widget realToplevel;
00050 
00051 Widget  fileWindow,                     /* parent of fileLabel and lineLabel */
00052         messageWindow,                  /* window for displaying messages */
00053         separator;                      /* separator in vpane */
00054 
00060 static void CreateMessageWindow  __PARAMS((Widget parent));  
00061 
00062 XtermWidget CreateTermWindow(Widget parent);
00063 XtermWidget CreateSubWindows(Widget parent);
00064 
00065 static Widget   fileLabel,              /* filename of displayed text */
00066                 lineLabel;              /* line number of caret position */
00067 
00068 /*
00069  *  Private routines for creating various subwindows for xdbx.
00070  */
00100 /**** 
00101 static void CreateFileWindow(parent)
00102      Widget parent;
00103 {
00104     Arg         args[MAXARGS];
00105     Cardinal    n;
00106     n = 0;
00107     XtSetArg(args[n], XtNshowGrip, (XtArgVal) False);                   n++;
00108     fileWindow = XtCreateManagedWidget("fileWindow", formWidgetClass, 
00109                                        parent, args, n);
00110     CreateFileLabel(fileWindow);
00111     CreateLineLabel(fileWindow);
00112 }
00113 **/
00114 
00115 
00116 static void CreateMessageWindow(parent)
00117 Widget parent;
00118 {
00119     Arg         args[MAXARGS];
00120     Widget      fm;
00121     Cardinal    n=0;
00122     fm = XtCreateManagedWidget("msWindow",formWidgetClass,
00123                                           parent, args, n);
00124     n = 0;
00125     XtSetArg(args[n], XtNlabel, (XtArgVal) SCI_VERSION_STRING); n++;
00126     XtCreateManagedWidget("logoWindow",labelWidgetClass,
00127                                           fm, args, n);
00128     XtSetArg(args[n], XtNlabel, (XtArgVal) DEFAULT_SCI_VERSION_MESSAGE); n++;
00129     messageWindow = XtCreateManagedWidget("messageWindow",labelWidgetClass,
00130                                           fm, args, n);
00131 }
00132 
00133 void DefaultMessageWindow()
00134 {
00135     Arg         args[MAXARGS];
00136     Cardinal    n=0;
00137     XtSetArg(args[n], XtNlabel,(XtArgVal) DEFAULT_SCI_VERSION_MESSAGE); n++;
00138     XtSetValues(messageWindow, args, n);
00139 }
00140 
00141 
00142 
00143 /*  PUBLIC ROUTINES */
00144 /*
00145  *  Top level function for creating all the xdbx subwindows.
00146  */
00147 
00148 extern WidgetClass xtermWidgetClass;
00149 
00150 XtermWidget CreateSubWindows(Widget parent)
00151 {
00152   Arg   args[1];
00153   Cardinal n=0;
00154   XtermWidget CreateTermWindow();
00155   Widget        vpane;   /* outer widget containing various subwindows */
00156   vpane = XtCreateManagedWidget("vpane", panedWidgetClass, parent, args, n);
00157   AddAcceptMessage(parent);
00158   CreateMessageWindow(vpane);
00159   CreateCommandPanel(vpane);
00160   return(CreateTermWindow(vpane));
00161 } 
00162 
00163 /******************
00164  * icon 
00165  *****************/
00166 
00167 #include "x_xbas.icon.X" 
00168 
00169 void set_scilab_icon()
00170 {
00173   XWMHints wm_hints;
00174   Pixmap        sci_icon;
00175   
00176   sci_icon = XCreateBitmapFromData
00177     (XtDisplay(realToplevel),
00178      RootWindow(XtDisplay(realToplevel),
00179                 DefaultScreen(XtDisplay(realToplevel))),
00180      (char *) sci_bits, sci_width, sci_height);
00181   
00182   /*  n = 0;
00183       XtSetArg(args[n], XtNiconPixmap, sci_icon); n++;
00184       XtSetValues(realToplevel, args, n);*/
00185 
00186   wm_hints.icon_pixmap = sci_icon;
00187   wm_hints.flags = IconPixmapHint;
00188   XSetWMHints (XtDisplay(realToplevel), XtWindow(realToplevel), 
00189                      &wm_hints);
00190 }
00191 
00192 
00195 Atom   NewGraphWindowMessageAtom;
00196 
00197 XtEventHandler UseMessage(w, child, e)
00198      Widget w;
00199      Widget child;
00200      XClientMessageEvent *e;
00201 {
00202   if (e->type == ClientMessage 
00203       && e->message_type == NewGraphWindowMessageAtom)
00204       {
00205         /*
00206           fprintf(stderr,"It was a Client Message Of the Good Type \n");
00207           fprintf(stderr,"I Need to Create Window %d",e->data.l[0]);
00208         */
00209       }
00210   return(0);
00211 }
00212 
00213 static Widget WidgetUseMessage ;
00214 
00215 void AddAcceptMessage(parent)
00216      Widget parent;
00217 {
00218   WidgetUseMessage=parent ;
00219   XtAddEventHandler(parent,ClientMessage, True, (XtEventHandler) UseMessage,(XtPointer) 0);  
00220 }
00221 
00222 void ReAcceptMessage()
00223 {
00224   XtAddEventHandler(WidgetUseMessage,ClientMessage, True, (XtEventHandler) UseMessage,(XtPointer) 0);  
00225 }
00226 
00227 XtermWidget CreateTermWindow(Widget parent)
00228 {
00229   XtermWidget term1;
00230   Arg   args[MAXARGS];
00231   Cardinal      n=0;
00236   term1 = (XtermWidget) XtCreateManagedWidget("Vtsci", xtermWidgetClass, parent, args,n);
00237   return(term1);
00238 }
00239 
00240 /*
00241  *  Routines for updating fields for the filename and line number
00242  *  in the file window, and the execution status in the message window.
00243  */
00244 
00245 void UpdateFileLabel(string)
00246 char *string;
00247 {
00248     Arg         args[MAXARGS];
00249     Cardinal    n;
00250     n = 0;
00251     XtSetArg(args[n], XtNlabel, (XtArgVal) string);                     n++;
00252     XtSetValues(fileLabel, args, n);
00253 }
00254 
00255 void UpdateLineLabel(line)
00256 Cardinal line;
00257 {
00258     Arg         args[MAXARGS];
00259     Cardinal    n;
00260     char        string[10];
00261     n = 0;
00262     if (line > n)
00263         sprintf(string, "%d", line);
00264     else
00265         strcpy(string, "");
00266     XtSetArg(args[n], XtNlabel, (XtArgVal) string);             n++;
00267     XtSetValues(lineLabel, args, n);
00268 }
00269 
00270 void UpdateMessageWindow(format, arg)
00271 char *format, *arg;
00272 {
00273     char        message[LINESIZ], string[LINESIZ];
00274     Arg         args[MAXARGS];
00275     Cardinal    n;
00276 
00277     strcpy(message, "  ");
00278     sprintf(string, format, arg);
00279     strcat(message, string);
00280     n = 0;
00281     XtSetArg(args[n], XtNlabel, (XtArgVal) message);            n++;
00282     XtSetValues(messageWindow, args, n);
00283 }

Generated on Sun Mar 4 15:03:56 2007 for Scilab [trunk] by  doxygen 1.5.1