home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / demos / demobook / Question.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  8.3 KB  |  282 lines

  1. /*
  2.  * Copyright 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17.  
  18. /*******************************************************************************
  19.     Question.c
  20.  
  21. *******************************************************************************/
  22.  
  23. #include <stdio.h>
  24. #include <Xm/Xm.h>
  25. #include <Xm/DialogS.h>
  26. #include <Xm/MenuShell.h>
  27. #include "UxXt.h"
  28.  
  29. #include <Xm/MessageB.h>
  30.  
  31. /*******************************************************************************
  32.     Includes, Defines, and Global variables from the Declarations Editor:
  33. *******************************************************************************/
  34.  
  35. #include "exinterfmotif.h"
  36. #include "exglobals.h"
  37.  
  38. /*******************************************************************************
  39.     The definition of the context structure:
  40.     If you create multiple instances of your interface, the context
  41.     structure ensures that your callbacks use the variables for the
  42.     correct instance.
  43.  
  44.     For each Widget in the interface, each argument to the Interface
  45.     function, and each variable in the Instance Specific section of the
  46.     Declarations Editor, there is an entry in the context structure.
  47.     and a #define.  The #define makes the variable name refer to the
  48.     corresponding entry in the context structure.
  49. *******************************************************************************/
  50.  
  51. typedef    struct
  52. {
  53.     int    mumble;
  54. } _UxCQuestion;
  55.  
  56.  
  57. static _UxCQuestion    *UxQuestionContext;
  58.  
  59. Widget    Question;
  60.  
  61. /*******************************************************************************
  62.     Forward declarations of functions that are defined later in this file.
  63. *******************************************************************************/
  64.  
  65. Widget    create_Question();
  66.  
  67. /*******************************************************************************
  68.     The following are callback functions.
  69. *******************************************************************************/
  70.  
  71. static void    okCallback_Question( UxWidget, UxClientData, UxCallbackArg )
  72.     Widget        UxWidget;
  73.     XtPointer    UxClientData, UxCallbackArg;
  74. {
  75.     _UxCQuestion        *UxSaveCtx, *UxContext;
  76.  
  77.     UxSaveCtx = UxQuestionContext;
  78.     UxQuestionContext = UxContext =
  79.             (_UxCQuestion *) UxGetContext( UxWidget );
  80.  
  81.     {
  82.     if (DialogType == 2)
  83.       DeleteDemoFlag = True;
  84.     else if (DialogType == 3)
  85.       DeleteGroupFlag = True;
  86.     else if (DialogType == 4) {
  87.       RDwin = -1;
  88.       UxPopdownInterface(BookFile);
  89.       DialogType = 0;
  90.       write_file(FileName);
  91.     }
  92.     else if (DialogType == 5)
  93.       WantToEnterFilesFlag = True;
  94.     else if (DialogType == 6)
  95.       exit(1);
  96.     else if (DialogType == 7)
  97.       write_file(FileName);
  98.     DialogType = 0;
  99.     UxNotify();
  100.     }
  101.  
  102.     UxQuestionContext = UxSaveCtx;
  103. }
  104.  
  105. static void    cancelCB_Question( UxWidget, UxClientData, UxCallbackArg )
  106.     Widget        UxWidget;
  107.     XtPointer    UxClientData, UxCallbackArg;
  108. {
  109.     _UxCQuestion        *UxSaveCtx, *UxContext;
  110.  
  111.     UxSaveCtx = UxQuestionContext;
  112.     UxQuestionContext = UxContext =
  113.             (_UxCQuestion *) UxGetContext( UxWidget );
  114.  
  115.     {
  116.     if (DialogType == 2)
  117.       DeleteDemoFlag = False;
  118.     else if (DialogType == 3)
  119.       DeleteGroupFlag = False;
  120.     else if (DialogType == 5)
  121.       WantToEnterFilesFlag = False;
  122.     DialogType = 0;
  123.     UxNotify();
  124.     }
  125.  
  126.     UxQuestionContext = UxSaveCtx;
  127. }
  128.  
  129.  
  130. Widget    Question_shell;
  131.  
  132. static Widget    _Uxbuild_Question()
  133. {
  134.  
  135.     Question_shell = XtVaCreatePopupShell( "Question_shell",
  136.             xmDialogShellWidgetClass, DBtoplevel,
  137.             XmNx, 650,
  138.             XmNy, 670,
  139.             XmNwidth, 400,
  140.             XmNheight, 190,
  141.             XmNshellUnitType, XmPIXELS,
  142.             XmNtitle, "Question",
  143.             NULL );
  144.  
  145.     Question = XtVaCreateWidget( "Question",
  146.             xmMessageBoxWidgetClass, Question_shell,
  147.             RES_CONVERT( XmNcancelLabelString, "No" ),
  148.             XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
  149.             XmNdialogType, XmDIALOG_QUESTION,
  150.             RES_CONVERT( XmNtextFontList, "-Adobe-Courier-Bold-R-Normal--14-100-100-100-M-90-ISO8859-1" ),
  151.             RES_CONVERT( XmNokLabelString, "Yes" ),
  152.             RES_CONVERT( XmNmessageString,  " " ),
  153.             XmNmarginHeight, 12,
  154.             XmNmarginWidth, 20,
  155.             RES_CONVERT( XmNlabelFontList, "-Adobe-Helvetica-Bold-R-Normal--14-100-100-100-P-82-ISO8859-1" ),
  156.             RES_CONVERT( XmNdialogTitle, "Question" ),
  157.             RES_CONVERT( XmNbuttonFontList, "-Adobe-Helvetica-Bold-R-Normal--14-100-100-100-P-82-ISO8859-1" ),
  158. /*
  159.             XmNshadowThickness, 5,
  160.             RES_CONVERT( XmNforeground, "black" ),
  161.             RES_CONVERT( XmNtopShadowColor, "#e5e5e5" ),
  162.             RES_CONVERT( XmNbottomShadowColor, "#6c6c6c" ),
  163.             RES_CONVERT( XmNbackground, "#BBBBBB" ),
  164. */
  165.             XmNheight, 190,
  166.             XmNwidth, 400,
  167.             XmNunitType, XmPIXELS,
  168.             NULL );
  169.  
  170.     UxPutContext( Question, (char *) UxQuestionContext );
  171.  
  172.     XtAddCallback( Question, XmNdestroyCallback,
  173.             UxFreeClientDataCB,
  174.             (XtPointer) UxQuestionContext );
  175.  
  176.         XtAddCallback( Question, XmNokCallback,
  177.                         okCallback_Question,
  178.                         (XtPointer) UxQuestionContext );
  179.         XtAddCallback( Question, XmNcancelCallback,
  180.                         cancelCB_Question,
  181.                         (XtPointer) UxQuestionContext );
  182.  
  183.     XtRealizeWidget ( Question_shell );
  184.  
  185.     SetWMhints( Question_shell );
  186.  
  187.  
  188.     return ( Question );
  189. }
  190.  
  191. /*******************************************************************************
  192.     The following function includes the code that was entered
  193.     in the 'Initial Code' and 'Final Code' sections of the
  194.     Declarations Editor. This function is called from the
  195.     'Interface function' below.
  196. *******************************************************************************/
  197.  
  198. static Widget    _Ux_create_Question()
  199. {
  200.     Widget                 rtrn;
  201.     _UxCQuestion        *UxContext;
  202.  
  203.     UxQuestionContext = UxContext =
  204.         (_UxCQuestion *) XtMalloc( sizeof(_UxCQuestion) );
  205.  
  206.     rtrn = _Uxbuild_Question();
  207.  
  208.     XtUnmanageChild(XmMessageBoxGetChild
  209.       (Question, XmDIALOG_HELP_BUTTON));
  210.  
  211.     return(rtrn);
  212. }
  213.  
  214. /*******************************************************************************
  215.     The following is the 'Interface function' which is the
  216.     external entry point for creating this interface.
  217.     This function should be called from your application or from
  218.     a callback function.
  219. *******************************************************************************/
  220.  
  221. Widget    create_Question()
  222. {
  223.     Widget            _Uxrtrn;
  224.  
  225.     _Uxrtrn = _Ux_create_Question();
  226.  
  227.     return ( _Uxrtrn );
  228. }
  229.  
  230. popup_Question()
  231. {
  232.     char title_string[20];
  233.     char question_string[255];
  234.  
  235.     if (DialogType == 2) {
  236.       strcpy (title_string, "Delete Demo");
  237.       strcpy (question_string, "\nDo you want to delete\nthe demo, ");
  238.       strcat (question_string, msgstring);
  239.       strcat (question_string, " ?\n");
  240.     }
  241.     else if (DialogType == 3) {
  242.       strcpy (title_string, "Delete Book");
  243.       strcpy (question_string, "\nDo you want to delete\nthe book, ");
  244.       strcat (question_string, msgstring);
  245.       strcat (question_string, " ?\n");
  246.     }
  247.     else if (DialogType == 4) {
  248.       strcpy (title_string, "File Exists");
  249.       strcpy (question_string, "File already exists.\n\nDo you want to overwrite it?");
  250.     }
  251.     else if (DialogType == 5) {
  252.       strcpy (title_string, "No Files");
  253.       strcpy (question_string, "You have not entered any Executable or Data Files.\nYou will not be able to copy this demo onto tape.\n\nDo you want to enter the File Names now?");
  254.     }
  255.     else if (DialogType == 6) {
  256. printf(" dialog type 6 is not being used \n");
  257.     }
  258.     else if (DialogType == 7) {
  259.       strcpy (title_string, "Save Book File");
  260.       strcpy (question_string, "\nDo you want to save the book file\n");
  261.       strcat (question_string, FileName);
  262.       strcat (question_string, " ?\n");
  263.     }
  264.  
  265.     XtVaSetValues( Question_shell,
  266.             XmNtitle, title_string,
  267.             NULL );
  268.     XtVaSetValues( Question,
  269.             RES_CONVERT( XmNdialogTitle, title_string ),
  270.             NULL );
  271.     XtVaSetValues( Question,
  272.             RES_CONVERT( XmNmessageString,  question_string ),
  273.             NULL );
  274.  
  275.     UxPopupInterface(Question, exclusive_grab);
  276. }
  277.  
  278. /*******************************************************************************
  279.     END OF FILE
  280. *******************************************************************************/
  281.  
  282.