home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 January / Chip_1997-01_cd.bin / ms95 / disk22 / dir02 / f015540.re_ / f015540.re
Text File  |  1996-04-02  |  9KB  |  219 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. |    $Logfile:   J:/mdl/examples/listbox/listbox.mcv  $
  18. |   $Workfile:   listbox.mc  $
  19. |   $Revision:   1.2  $
  20. |       $Date:   26 Jul 1995 07:04:16  $
  21. |                                    |
  22. +----------------------------------------------------------------------*/
  23. /*----------------------------------------------------------------------+
  24. |                                    |
  25. |   Function -                                |
  26. |                                    |
  27. |    MDL example to show new items                    |
  28. |                                    |
  29. |    main - Main entry point                        |
  30. |                                    |
  31. +----------------------------------------------------------------------*/
  32. /*----------------------------------------------------------------------+
  33. |                                    |
  34. |   Include Files                               |
  35. |                                    |
  36. +----------------------------------------------------------------------*/
  37. #include    <mdl.h>        /* MDL Library funcs structures & constants */
  38. #include    <dlogitem.h>    /* Dialog Box Manager structures & constants */
  39. #include    <userfnc.h>
  40. #include    <dlogids.h>
  41.  
  42. #include    <dlogman.fdf>   /* dialog box manager function prototypes */
  43. #include    <msrsrc.fdf>
  44. #include    <msparse.fdf>
  45. #include    <mssystem.fdf>
  46. #include    <mscexpr.fdf>
  47.  
  48. #include    "listbox.h"     /* dialog box example constants & structs */
  49. #include    "listbcmd.h"    /* dialog box command numbers */
  50.  
  51. #include    "listicon.fdf"  /* dialog hook function definitions */
  52. #include    "listsash.fdf"  /* dialog hook function definitions */
  53. #include    "listmult.fdf"  /* dialog hook function definitions */
  54. #include    "listcolr.fdf"  /* dialog hook function definitions */
  55.  
  56. /*----------------------------------------------------------------------+
  57. |                                    |
  58. |   Local defines                            |
  59. |                                    |
  60. +----------------------------------------------------------------------*/
  61.  
  62. /*----------------------------------------------------------------------+
  63. |                                    |
  64. |   Private Global variables                        |
  65. |                                    |
  66. +----------------------------------------------------------------------*/
  67. static DItem_PulldownMenuItem    gAppMenuItem;
  68. Public ListBoxGlobals           listboxGlobs;
  69.  
  70. /*----------------------------------------------------------------------+
  71. |                                                                       |
  72. |   Asynchronous Functions                        |
  73. |                                                                       |
  74. +----------------------------------------------------------------------*/ 
  75. /*----------------------------------------------------------------------+
  76. |                                                                       |
  77. | name          listbox_unloadFunction                    |
  78. |                                                                       |
  79. | author        BSI                                     05/95           |
  80. |                                                                       |
  81. +----------------------------------------------------------------------*/
  82. Private int listbox_unloadFunction
  83. (
  84. int unloadType
  85. )
  86.     {
  87.     /* no need to clean up menus if shutting down */
  88.     if (SYSTEM_TERMINATED_SHUTDOWN == unloadType)
  89.     return (0);
  90.  
  91.     mdlDialog_menuBarDeleteCmdWinMenu (&gAppMenuItem);
  92.     return (0);
  93.     }
  94.  
  95. /*----------------------------------------------------------------------+
  96. |                                    |
  97. |   Utility routines                            |
  98. |                                    |
  99. +----------------------------------------------------------------------*/
  100. /*----------------------------------------------------------------------+
  101. |                                                                       |
  102. | name          listbox_errorPrint -- print an error message into    |
  103. |                  Dialog Box Manager Messages dialog box    |
  104. |                                                                       |
  105. | author        BSI                                     05/95           |
  106. |                                                                       |
  107. +----------------------------------------------------------------------*/
  108. Public void listbox_errorPrint
  109. (
  110. int errorNumber            /* => number of error to print */
  111. )
  112.     {
  113.     char    errorMsg[80];
  114.  
  115.     if (SUCCESS != mdlResource_loadFromStringList (errorMsg, NULL,
  116.                 MESSAGELISTID_ListBox, errorNumber))
  117.         {
  118.         /* unable to find message with number "errorNumber" */
  119.     return;    
  120.     }
  121.  
  122.     mdlDialog_dmsgsPrint (errorMsg);
  123.     }
  124.  
  125. /*----------------------------------------------------------------------+
  126. |                                                                       |
  127. |       Command Handling routines                                       |
  128. |                                                                       |
  129. +----------------------------------------------------------------------*/
  130. /*----------------------------------------------------------------------+
  131. |                                                                       |
  132. | name          listbox_openDialogBox                    |
  133. |                                                                       |
  134. | author        BSI                                     05/95           |
  135. |                                                                       |
  136. +----------------------------------------------------------------------*/
  137. Private void listbox_openDialogBox
  138. (
  139. char    *unparsedP    /* => unparsed part of command */
  140. )
  141. cmdNumber   CMD_LISTBOX_OPEN_LISTICON, 
  142.         CMD_LISTBOX_OPEN_SASH,
  143.         CMD_LISTBOX_OPEN_COLORS, 
  144.         CMD_LISTBOX_OPEN_MULTILIST
  145.     {
  146.     long    dialogId;
  147.     DialogBox  *dbP;    /* a ptr to a dialog box */
  148.  
  149.     /* Find the dialog id from the command number */
  150.     dialogId = (mdlCommandNumber & 0xFF00) >> 8;
  151.     if (dialogId == 0)
  152.     return;
  153.  
  154.     /* open the newItems dialog box */
  155.     if (NULL == (dbP = mdlDialog_open (NULL, dialogId)))
  156.     listbox_errorPrint (MSGID_DialogBox);
  157.     }
  158.  
  159. /*----------------------------------------------------------------------+
  160. |                                    |
  161. | name        main                            |
  162. |                                    |
  163. | author    BSI                     05/95        |
  164. |                                    |
  165. +----------------------------------------------------------------------*/
  166. static DialogHookInfo uHooks[] =
  167.     {
  168.     {HOOKDIALOGID_ListIcon,            listicon_mainBoxHook},
  169.     {HOOKDIALOGID_DialogSash,            listsash_sashDialogHook},
  170.     {HOOKDIALOGID_MultiList,            listmult_multiListDialogHook},
  171.     {HOOKDIALOGID_Colors,            listcolr_colorsDialogHook},
  172.     {HOOKITEMID_ListIcon_FileListDirectory, listicon_iconListBoxHook},
  173.     {HOOKITEMID_CheckListBox,            listicon_checkListBoxHook},
  174.     {HOOKITEMID_Sash,                listsash_sashHook},
  175.     {HOOKITEMID_ListBoxSash,            listsash_sashListBoxHook},
  176.     {HOOKITEMID_ListBoxMulti,            listmult_multiListBoxHook},
  177.     {HOOKITEMID_PDMMultiListTests,        listmult_multiListTestsMenusHook},
  178.     {HOOKITEMID_ToggleBtnColor,            listcolr_colorsToggleBtnHook},
  179.     {HOOKITEMID_ColoredListBox,            listcolr_coloredListBoxHook},
  180.  
  181.     };
  182.  
  183.  
  184. Public void main
  185. (
  186. int   argc,        /* => number of args in next array */
  187. char *argv[]        /* => array of cmd line arguments */
  188. )
  189.     {
  190.     char           *setP;    /* ptr to "C expression symbol set" */
  191.     RscFileHandle        rscFileH;    /* a resource file handle */
  192.  
  193.     /* open the resource file that we came out of */
  194.     mdlResource_openFile (&rscFileH, NULL, 0);
  195.  
  196.     /* Load our command table */
  197.     if (NULL == mdlParse_loadCommandTable (NULL))
  198.     listbox_errorPrint(MSGID_CommandTable);
  199.  
  200.     /* Publish a function for the unload program event */
  201.     mdlSystem_setFunction (SYSTEM_UNLOAD_PROGRAM, listbox_unloadFunction);
  202.  
  203.     /* publish our hook functions */
  204.     mdlDialog_hookPublish (sizeof(uHooks)/sizeof(DialogHookInfo), uHooks);
  205.  
  206.     /* set up variables that will be evaluated within C expression strings */
  207.     setP = mdlCExpression_initializeSet (VISIBILITY_DIALOG_BOX, 0, FALSE);
  208.     mdlDialog_publishComplexVariable (setP, "listboxglobals", "listboxGlobs", &listboxGlobs);
  209.  
  210.     listcolr_initializeColorDescriptors (&listboxGlobs.localPalP, listboxGlobs.localColorsP, NLOCAL_COLORS);
  211.     
  212.     /* add our commands to the application menu */
  213.     mdlDialog_menuBarAddCmdWinMenu (&gAppMenuItem, PULLDOWNMENUID_ListBox, TRUE);
  214.  
  215.     mdlSystem_setFunction (SYSTEM_COLORMAP_CHANGE, listcolr_handleRemap);
  216.  
  217.     }
  218.  
  219.