home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / i18nv102.zip / SAMPLE / WORLD / WORLD.H < prev    next >
C/C++ Source or Header  |  1995-08-28  |  14KB  |  258 lines

  1. /*****************************************************************************/
  2. /***     Include files                                                     ***/
  3. /*****************************************************************************/
  4.  
  5. #define INCL_WIN                        /* Include the "win" OS2 calls.      */
  6. #include <os2.h>                        /* Include the OS2 toolkit defs.     */
  7.  
  8. #include <stdlib.h>                     /* Include the standard library.     */
  9. #include <stdio.h>                      /* Include standard input/output.    */
  10. #include <string.h>                     /* Include string functions.         */
  11. #include <time.h>                       /* Include basic date/time functions.*/
  12. #include <sys\types.h>                  /* Types for stat call.              */
  13. #include <sys\stat.h>                   /* Include file for stat call.       */
  14.  
  15. #include <wchar.h>                      /* Base XPG4 include file.           */
  16. #include <locale.h>                     /* Locale definitions.               */
  17.  
  18. #include "localpth.h"                   /* Definitions for locale path dialog*/
  19. #include "about.h"                      /* Definitions for about dialog box. */
  20.  
  21. /*****************************************************************************/
  22. /***     Catalog defines                                                   ***/
  23. /*****************************************************************************/
  24.  
  25.                                         /* This should be the define for the */
  26.                                         /*  message catalog name.            */
  27. /* #define CAT_NAME    "wrld.cat"                                            */
  28. /* #define ICON_NAME   "world.ico"                                           */
  29. #define CAT_NAME    "\\i18n\\messages\\%s\\wrld.cat"
  30. char t_cat_name[100];                   /* Needed for hacked solution.       */
  31.                                         /* Same scheme for icons.            */
  32. #define ICON_NAME   "\\i18n\\messages\\%s\\world.ico"
  33. char t_icon_name[100];
  34.  
  35. /*****************************************************************************/
  36. /***     Dialog defines                                                    ***/
  37. /*****************************************************************************/
  38.  
  39. #define COUNTRY_DIALOG           3000   /* Defines for controls in the       */
  40. #define COUNTRY_GROUP            3001   /*  dialog for each locale.          */
  41. #define COUNTRY_DATE             3002
  42. #define COUNTRY_TIME             3003
  43. #define COUNTRY_MONEY            3004
  44. #define COUNTRY_COLLATE          3005
  45. #define COUNTRY_COLL_BUTTON      3006
  46. #define COUNTRY_CANCEL_BUTTON    3007
  47. #define COUNTRY_DATE_LABEL       3008
  48. #define COUNTRY_TIME_LABEL       3009
  49. #define COUNTRY_MONEY_LABEL      3010
  50.  
  51. #define COUNTRY_TITLE_BASE       3020   /* Base of the titles of the locale  */
  52.                                         /*  names.                           */
  53.  
  54. #define MESSAGE_DIALOG           3100   /* Defines for the message dialog    */
  55. #define MESSAGE_TEXT             3101   /*  displayed instead of the non     */
  56. #define MESSAGE_OK               3102   /*  cultural "WinMessageBox"         */
  57.  
  58. /*****************************************************************************/
  59. /***     User defined messages                                             ***/
  60. /*****************************************************************************/
  61.  
  62. #define WM_REDRAW_NLS_TEXT       (WM_USER + 0)
  63.                                         /* This message is sent to any and   */
  64.                                         /*  modeless dialogs when the current*/
  65.                                         /*  language is dynamically changed. */
  66.                                         /*  The dialog is then responsible   */
  67.                                         /*  for changing all locale-depend   */
  68.                                         /*  strings.  The dialog can assume  */
  69.                                         /*  that the message catalog for the */
  70.                                         /*  new locale is open.  In this     */
  71.                                         /*  program, only the locale dialogs */
  72.                                         /*  are sent this message.           */
  73.  
  74. /*****************************************************************************/
  75. /***     Others                                                            ***/
  76. /*****************************************************************************/
  77.  
  78. #define RES_CLIENT               256    /* Client window define.             */
  79.  
  80. #define MENU_FILE                500    /* Items in the FILE menu.           */
  81. #define MENU_FILE_HELP           501
  82. #define MENU_FILE_ABOUT          502
  83.  
  84. #define MENU_LOCALE              510    /* Items in the locale menu.         */
  85. #define MENU_LOCALE_SET          511
  86.  
  87. #define MENU_OPTIONS             520    /* Items in the options menu.        */
  88. #define MENU_OPTIONS_ICON        521
  89.  
  90. #define MENU_LANGS               530    /* Items in the message language menu*/
  91. #define MENU_LANGS_LANG0         531
  92. #define MENU_LANGS_LANG1         532
  93. #define MENU_LANGS_LANG2         533
  94. #define MENU_LANGS_LANG3         534
  95. #define MENU_LANGS_LANG4         535
  96. #define MENU_LANGS_LANG5         536
  97. #define MENU_LANGS_LANG6         537
  98. #define MENU_LANGS_LANG7         538
  99. #define MENU_LANGS_LANG8         539
  100. #define MENU_LANGS_LANG9         540
  101. #define MENU_LANGS_LANG10        541
  102. #define MENU_LANGS_LANG11        542
  103.  
  104. #define BITMAP_WORLD             600    /* Define for the world bitmap.      */
  105.  
  106. #define BITMAP_LANG0             601    /* Bitmaps for the countries.        */
  107. #define BITMAP_LANG1             602
  108. #define BITMAP_LANG2             603
  109. #define BITMAP_LANG3             604
  110. #define BITMAP_LANG4             605
  111. #define BITMAP_LANG5             606
  112. #define BITMAP_LANG6             607
  113. #define BITMAP_LANG7             608
  114. #define BITMAP_LANG8             609
  115. #define BITMAP_LANG9             610
  116. #define BITMAP_LANG10            611
  117. #define BITMAP_LANG11            612
  118.  
  119. /*****************************************************************************/
  120. /***     Global code macros                                                ***/
  121. /*****************************************************************************/
  122.  
  123.                                         /* This macro is used to set the text*/
  124.                                         /*  for a menu item (for initializing*/
  125.                                         /*  the menu, and when we change     */
  126.                                         /*  message language.                */
  127. #define set_menu_text(item_id, catalog_id, def) \
  128.   WinSetMenuItemText(hwnd_menu, item_id, \
  129.                      catgets(msg_handle, MEN, catalog_id, def));
  130.  
  131. /*****************************************************************************/
  132. /***     Global type definitions                                           ***/
  133. /*****************************************************************************/
  134.  
  135. typedef UCHAR nam[10];                  /* New type of locale names.         */
  136. typedef UCHAR long_nam[100];            /* Long names for default locales.   */
  137.  
  138. /*****************************************************************************/
  139. /***     Global defines                                                    ***/
  140. /*****************************************************************************/
  141.  
  142. #define NLS_PATH       "NLSPATH"        /* Name of needed environment var.   */
  143.  
  144. #define NUM_LOCALES    12                /* How many locales are we showing   */
  145.                                         /*  on the world map?                */
  146.  
  147. #define LOCALE_EN_US   0                /* Defines for each of the locales.  */
  148. #define LOCALE_ES_ES   1
  149. #define LOCALE_DE_DE   2
  150. #define LOCALE_SV_SE   3
  151. #define LOCALE_FR_FR   4
  152. #define LOCALE_JA_JP   5
  153. #define LOCALE_EN_GB   6
  154. #define LOCALE_IT_IT   7
  155. #define LOCALE_AR_AA   8
  156. #define LOCALE_DA_DK   9
  157. #define LOCALE_PL_PL   10
  158. #define LOCALE_NO_NO   11
  159.  
  160. #define BELL           7                /* ASCII bell character.             */
  161.  
  162. #define EXIT_NORMAL    0                /* Exit the program with no errors.  */
  163.  
  164. #define FILE_NOT_FOUND -1               /* Flag for file open call.          */
  165.  
  166. #define CLS_CLIENT     "MyClass"        /* Default PM class to register.     */
  167.  
  168. #define WIN_WIDTH      557              /* Width and height of main window.  */
  169. #define WIN_HEIGHT     395
  170.  
  171. #define NUM_COLL_STRINGS 10             /* Number of strings in list box to  */
  172.                                         /*  collate.                         */
  173.  
  174. #define NO_LOCALE -1                    /* None of the locale menu items are */
  175.                                         /*  checked.                         */
  176.  
  177. #define e_accute 130                    /* Some defines for diacritic chars. */
  178. #define o_circumflex 147
  179.  
  180. /*****************************************************************************/
  181. /***     Global variables                                                  ***/
  182. /*****************************************************************************/
  183.  
  184. nl_catd msg_handle;                     /* Handle for message catalog.       */
  185.  
  186. int which_locale;                       /* Which locale has opened the       */
  187.                                         /*  country dialog?                  */
  188.  
  189.                                         /* NOTE: The following arrays MUST   */
  190.                                         /*        have the locales in the    */
  191.                                         /*        EXACT same order.          */
  192.                                         /* Array of locale names.            */
  193.                                         /* Array of locations to draw the    */
  194.                                         /*  locale dialog boxes.             */
  195.                                         /* Array of rectangles for hit       */
  196.                                         /*  testing when the mouse is clicked*/
  197. nam locale_names[NUM_LOCALES] = {"ENUS437", "ESES850", "DEDE850", "SVSE850",
  198.                                  "FRFR850", "JAJP932", "ENGB850", "ITIT850",
  199.                                  "ARAA1046", "DADK850", "PLPL852", "NONO850"};
  200. POINTL locale_locs[NUM_LOCALES] = {{5, 5}, {140, 5}, {90, 70}, {215, 70},
  201.                                    {275, 5}, {340, 70}, {0, 70}, {140, 105},
  202.                                    {275, 105}, {275, 105}, {275, 105},
  203.                                    {275, 105}};
  204. RECTL  locale_hit_locs[NUM_LOCALES] = {{109, 229, 116, 236},
  205.                                        {255, 249, 262, 256},
  206.                                        {282, 272, 289, 279},
  207.                                        {289, 285, 296, 292},
  208.                                        {265, 261, 272, 268},
  209.                                        {477, 239, 484, 246},
  210.                                        {262, 268, 269, 275},
  211.                                        {289, 242, 296, 249},
  212.                                        {307, 224, 314, 231},
  213.                                        {0, 0, 0, 0},
  214.                                        {0, 0, 0, 0},
  215.                                        {0, 0, 0, 0}};
  216.  
  217. HBITMAP locale_bitmaps[NUM_LOCALES];    /* Bitmaps for locales in menus.     */
  218. int locale_active[NUM_LOCALES];         /* Array to determine which locales  */
  219.                                         /*  are currently "active" (open).   */
  220. HWND locale_windows[NUM_LOCALES];       /* Array of window handles for locale*/
  221.                                         /*  dialogs.                         */
  222. HWND hwndFrame;                         /* Frame window handle for main win. */
  223. HWND hwndClient;                        /* Client window handle for main win.*/
  224.  
  225.                                         /* Two paths used for opening locale */
  226.                                         /*  .dll files.                      */
  227. UCHAR       locale_path[200] = "\\i18n\\locale";
  228. UCHAR       temp_locale_path[200];
  229.  
  230. struct stat stat_buffer;                /* Buffer to hold file status info.  */
  231.  
  232. nam coll_arr[NUM_COLL_STRINGS];         /* Array of strings to collate.      */
  233.  
  234. LONG screen_width, screen_height;       /* Width and height of screen.       */
  235.  
  236. HWND hwnd_menu;                         /* Handle to menu window for main    */
  237.                                         /*  window of program.               */
  238.  
  239. char *error_text, *error_title;         /* Pointers used for error routine.  */
  240.  
  241. int cur_mess_locale;                    /* Which locale is currently used    */
  242.                                         /*  for messages.                    */
  243.  
  244. int icons_in_menus;                     /* Are we showing icons in menus?    */
  245.  
  246. HPOINTER icon_pointer;                  /* Minimized icon's handle.          */
  247.  
  248.                                         /* Arrays of locales and country     */
  249.                                         /*  names for default (C) locale.    */
  250. long_nam def_locs[NUM_LOCALES] = {"English in USA", "Spanish in Spain",
  251.                                   "German in Germany", "Swedish in Sweden",
  252.                                   "French in France", "Japanese in Japan",
  253.                                   "English in Great Britain",
  254.                                   "Italian in Italy", "Arabic in Egypt"};
  255. long_nam def_cntry[NUM_LOCALES] = {"United States", "Spain", "Germany",
  256.                                    "Sweden", "France", "Japan", "Great Britain",
  257.                                    "Italy", "Egypt"};
  258.