home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 January / Chip_1997-01_cd.bin / ms95 / disk22 / dir02 / f015740.re_ / f015740.re
Text File  |  1996-04-02  |  11KB  |  234 lines

  1. /*----------------------------------------------------------------------+
  2. |                                    |
  3. |  Copyright (1995) Bentley Systems, Inc., All rights reserved.         |
  4. |                                    |
  5. |  "MicroStation" is a registered trademark and "MDL" and "MicroCSL"    |
  6. |  are trademarks of Bentley Systems, Inc.                    |
  7. |                                    |
  8. |  Limited permission is hereby granted to reproduce and modify this    |
  9. |  copyrighted material provided that the resulting code is used only     |
  10. |  in conjunction with Bentley Systems products under the terms of the    |
  11. |  license agreement provided therein, and that this notice is retained    |
  12. |  in its entirety in any such reproduction or modification.        |
  13. |                                    |
  14. +----------------------------------------------------------------------*/
  15. /*----------------------------------------------------------------------+
  16. |                                    |
  17. |   $Workfile:   mdlbasic.mc  $
  18. |   $Revision:   6.2  $
  19. |       $Date:   12 Sep 1995 17:36:14  $
  20. |                                    |
  21. +----------------------------------------------------------------------*/
  22. /*----------------------------------------------------------------------+
  23. |                                    |
  24. |   Include Files                               |
  25. |                                    |
  26. +----------------------------------------------------------------------*/
  27. #include <cexpr.h>
  28. #include <rscdefs.h>
  29. #include <cmdlist.h>            /* MicroStation Command List */
  30. #include <tcb.h>        /* Terminal Control Block */
  31.  
  32. #include <msoutput.fdf>
  33. #include <msbasic.fdf>
  34. #include <msdialog.fdf>
  35. #include <ditemlib.fdf>
  36. #include <mscexpr.fdf>
  37. #include <msrsrc.fdf>
  38. #include <mssystem.fdf>
  39. #include <msparse.fdf>
  40.  
  41. #include "mdlbacmd.h"        /* Command Table for MDLBasic */
  42. #include "mdlbasic.h"        /* Constants for MDL application */
  43. #include "mdlbadlg.h"        /* Dialog Box Constants */
  44.  
  45. /*----------------------------------------------------------------------+
  46. |                                    |
  47. |   Global Variables                            |
  48. |                                    |
  49. +----------------------------------------------------------------------*/
  50.     MdlTableParams  tableInfo;
  51.     char             fileName[255];
  52.  
  53. /*----------------------------------------------------------------------+
  54.  The following sequence of events occur:
  55.  1) The BASIC macro populates global variables with information and opens a dialog box
  56.  to display this information to the user.  If the user presses the OK
  57.  button, then the MDL application MDLBASIC is loaded.  
  58.  2) In MDL application:
  59.  The application gets the global information using mdlBasic_getPublicVariable and
  60.  displays it to the user in an MDL dialog box.  The user has the opportunity
  61.  to change the information.  If the user presses the OK button, then
  62.  the information is written back to the global variables with
  63.  mdlBasic_setPublicVariable.  The MDL application is unloaded.
  64.  3) In the BASIC macro:
  65.  The changed information is then displayed by this macro in the dialog box.
  66. +----------------------------------------------------------------------*/
  67.  
  68. /*----------------------------------------------------------------------+
  69. |                                    |
  70. | name       mdlBasicDraw                                |
  71. |                                    |
  72. | author   BSI                        6/95        |
  73. |                                    |
  74. +----------------------------------------------------------------------*/
  75. void    mdlBasicDraw
  76. (
  77. void
  78. )
  79. cmdNumber CMD_MDLBASIC_DRAW
  80. {
  81.     /*----------------------------------------------------------------------+
  82.     |
  83.     |    This routine accesses a group of public variables in the
  84.     |    MicroStation BASIC enviroment and opens a dialog box to display these
  85.     |   values. The modified values are then updated back into the 
  86.     |    MicroStation BASIC environment.
  87.     |
  88.     +-----------------------------------------------------------------------*/
  89.     int            status;         /* Status of Get/Set operations    */
  90.     boolean          status_TF;      /* Status of Open Modal True/False */
  91.     int                 lastAction;     /* Action Button Pressed on Modal */
  92.  
  93.     /* Get MicroStation BASIC variables */
  94.     /* Basic Variables must be retrived/set at the atomic level */
  95.     /* each item retrived from a MicroStation BASIC Public variable
  96.        must be a simple type no records */
  97.     status = mdlBasic_getPublicVariable (&tableInfo.columnWidth, sizeof(double), 
  98.                             "tableInfo.columnWidth");
  99.     status = mdlBasic_getPublicVariable (&tableInfo.rowHeight, sizeof(double),  
  100.                             "tableInfo.rowHeight");
  101.     status = mdlBasic_getPublicVariable (&tableInfo.textHeight, sizeof(double),  
  102.                             "tableInfo.textHeight");
  103.     status = mdlBasic_getPublicVariable (&tableInfo.textWidth, sizeof(double),  
  104.                             "tableInfo.textWidth");
  105.  
  106.     status = mdlBasic_getPublicVariable (&tableInfo.wantHdgSep, sizeof(short),  
  107.                             "tableInfo.wantHdgSep");
  108.     status = mdlBasic_getPublicVariable (&tableInfo.wantColSep, sizeof(short),  
  109.                             "tableInfo.wantColSep");
  110.     status = mdlBasic_getPublicVariable (&tableInfo.wantRowSep, sizeof(short),  
  111.                             "tableInfo.wantRowSep");
  112.  
  113.     status = mdlBasic_getPublicVariable (&tableInfo.lineSymb[1].color,  sizeof(short),  
  114.                             "lineSymb_outline.color");
  115.     status = mdlBasic_getPublicVariable (&tableInfo.lineSymb[1].weight, sizeof(short),  
  116.                             "lineSymb_outline.weight");
  117.     status = mdlBasic_getPublicVariable (&tableInfo.lineSymb[1].style,  sizeof(short),  
  118.                             "lineSymb_outline.style");
  119.     status = mdlBasic_getPublicVariable (&tableInfo.lineSymb[2].color,  sizeof(short),  
  120.                             "lineSymb_hdgsep.color");
  121.     status = mdlBasic_getPublicVariable (&tableInfo.lineSymb[2].weight, sizeof(short),  
  122.                             "lineSymb_hdgsep.weight");
  123.     status = mdlBasic_getPublicVariable (&tableInfo.lineSymb[2].style,  sizeof(short),  
  124.                             "lineSymb_hdgsep.style");
  125.     status = mdlBasic_getPublicVariable (&tableInfo.lineSymb[3].color,  sizeof(short),  
  126.                             "lineSymb_rowsep.color");
  127.     status = mdlBasic_getPublicVariable (&tableInfo.lineSymb[3].weight, sizeof(short),  
  128.                             "lineSymb_rowsep.weight");
  129.     status = mdlBasic_getPublicVariable (&tableInfo.lineSymb[3].style,  sizeof(short),  
  130.                             "lineSymb_rowsep.style");
  131.     status = mdlBasic_getPublicVariable (&tableInfo.lineSymb[4].color,  sizeof(short),  
  132.                             "lineSymb_colsep.color");
  133.     status = mdlBasic_getPublicVariable (&tableInfo.lineSymb[4].weight, sizeof(short),  
  134.                             "lineSymb_colsep.weight");
  135.     status = mdlBasic_getPublicVariable (&tableInfo.lineSymb[4].style,  sizeof(short),  
  136.                             "lineSymb_colsep.style");
  137.  
  138.     status = mdlBasic_getPublicVariable (fileName, sizeof(fileName),"fileName");
  139.  
  140.     /* open Dialog Box */
  141.     status_TF = mdlDialog_openModal (&lastAction, NULL, DIALOGID_Table);
  142.     if (ACTIONBUTTON_CANCEL == lastAction)
  143.         {
  144.     /* user pressed cancel - unload the application & return */
  145.         mdlDialog_cmdNumberQueue (FALSE, CMD_MDL_UNLOAD,
  146.                       mdlSystem_getCurrTaskID(), TRUE);
  147.     return;
  148.         }
  149.  
  150.     /* Return values to MicroStation BASIC */
  151.     status = mdlBasic_setPublicVariable (&tableInfo.columnWidth, sizeof(double),
  152.                                 "tableInfo.columnWidth");
  153.     status = mdlBasic_setPublicVariable (&tableInfo.rowHeight, sizeof(double), 
  154.                             "tableInfo.rowHeight");
  155.     status = mdlBasic_setPublicVariable (&tableInfo.textHeight, sizeof(double), 
  156.                                 "tableInfo.textHeight");
  157.     status = mdlBasic_setPublicVariable (&tableInfo.textWidth, sizeof(double), 
  158.                                 "tableInfo.textWidth");
  159.     status = mdlBasic_setPublicVariable (&tableInfo.wantHdgSep, sizeof(short), 
  160.                                 "tableInfo.wantHdgSep");
  161.     status = mdlBasic_setPublicVariable (&tableInfo.wantColSep, sizeof(short), 
  162.                                 "tableInfo.wantColSep");
  163.     status = mdlBasic_setPublicVariable (&tableInfo.wantRowSep, sizeof(short), 
  164.                                 "tableInfo.wantRowSep");
  165.  
  166.     status = mdlBasic_setPublicVariable (&tableInfo.lineSymb[1].color,  sizeof(short), 
  167.                                 "lineSymb_outline.color");
  168.     status = mdlBasic_setPublicVariable (&tableInfo.lineSymb[1].weight, sizeof(short), 
  169.                                 "lineSymb_outline.weight");
  170.     status = mdlBasic_setPublicVariable (&tableInfo.lineSymb[1].style,  sizeof(short), 
  171.                                 "lineSymb_outline.style");
  172.     status = mdlBasic_setPublicVariable (&tableInfo.lineSymb[2].color,  sizeof(short), 
  173.                                 "lineSymb_hdgsep.color");
  174.     status = mdlBasic_setPublicVariable (&tableInfo.lineSymb[2].weight, sizeof(short), 
  175.                                 "lineSymb_hdgsep.weight");
  176.     status = mdlBasic_setPublicVariable (&tableInfo.lineSymb[2].style,  sizeof(short), 
  177.                                 "lineSymb_hdgsep.style");
  178.     status = mdlBasic_setPublicVariable (&tableInfo.lineSymb[3].color,  sizeof(short), 
  179.                             "lineSymb_rowsep.color");
  180.     status = mdlBasic_setPublicVariable (&tableInfo.lineSymb[3].weight, sizeof(short), 
  181.                                 "lineSymb_rowsep.weight");
  182.     status = mdlBasic_setPublicVariable (&tableInfo.lineSymb[3].style,  sizeof(short), 
  183.                                 "lineSymb_rowsep.style");
  184.     status = mdlBasic_setPublicVariable (&tableInfo.lineSymb[4].color,  sizeof(short), 
  185.                                 "lineSymb_colsep.color");
  186.     status = mdlBasic_setPublicVariable (&tableInfo.lineSymb[4].weight, sizeof(short), 
  187.                                 "lineSymb_colsep.weight");
  188.     status = mdlBasic_setPublicVariable (&tableInfo.lineSymb[4].style,  sizeof(short), 
  189.                             "lineSymb_colsep.style");
  190.     status = mdlBasic_setPublicVariable (fileName, sizeof(fileName),"fileName");
  191.  
  192.     /* Unload this Application */
  193.     mdlDialog_cmdNumberQueue (FALSE, CMD_MDL_UNLOAD,
  194.                       mdlSystem_getCurrTaskID(), TRUE);
  195.     }
  196.  
  197. /*----------------------------------------------------------------------+
  198. |                                    |
  199. | name        main                            |
  200. |                                    |
  201. | author    BSI                    6/95        |
  202. |                                    |
  203. +----------------------------------------------------------------------*/
  204. Private void main
  205. (
  206. void
  207. )
  208.     {
  209.     RscFileHandle    rfHandle;  /* File Handle for Resource File */
  210.     char        *setP;     /* Published Variable Set Pointer */
  211.  
  212.  
  213.     mdlResource_openFile (&rfHandle, NULL, FALSE);
  214.  
  215.     /*    mdlParse_loadCommandTable: */
  216.     if (mdlParse_loadCommandTable (NULL) == NULL)
  217.         {
  218.     mdlOutput_rscPrintf (MSG_ERROR, NULL, MESSAGELISTID_Messages,
  219.             MSGID_LoadCmdTableError);
  220.         return;        
  221.         }
  222.  
  223.     /* Publish variables to allow dialog box manager to display values */
  224.     setP=mdlCExpression_initializeSet (VISIBILITY_DIALOG_BOX, 0, TRUE);
  225.     mdlDialog_publishComplexVariable (setP, "mdltableparams", "tableInfo", &tableInfo);
  226.     mdlDialog_publishBasicArray (setP, &charType, "fileName",
  227.                  fileName, sizeof(fileName));
  228.  
  229.     /* Queue a command to process information from the BASIC program */
  230.     mdlDialog_cmdNumberQueue (TRUE, CMD_MDLBASIC_DRAW,
  231.                       NULL, TRUE);
  232.  
  233.     }   
  234.