localemgr.pp 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. (******************************************************************************
  2. *
  3. * Copyright (c) 2000 Palm, Inc. or its subsidiaries.
  4. * All rights reserved.
  5. *
  6. * File: LocaleMgr.h
  7. *
  8. * Release: Palm OS SDK 4.0 (63220)
  9. *
  10. * Description:
  11. * Public header for routines that support locales (information specific
  12. * to locales and regions).
  13. *
  14. * History:
  15. * 04/28/00 CS Created by Chris Schneider.
  16. * 05/16/00 CS LmCountryType/LmLanguageType are now back to
  17. * CountryType/LanguageType.
  18. * 05/31/00 CS Moved country and language codes to new Locale.h and removed
  19. * kLanguageFirst, etc.
  20. * 06/06/00 kwk Made _LmLocaleType's language & country fields be UInt16's,
  21. * so that it's binary compatible with OmLocaleType.
  22. * 07/28/00 CS Replaced lmChoiceMinutesWestOfGMT & lmChoiceDaylightSavings
  23. * selectors with lmChoiceTimeZone.
  24. * 08/08/00 CS Renamed LmGetLocaleSetting's <iMaxSize> parameter <iValueSize>
  25. * to reflect the fact that the routine now checks to make sure
  26. * that <oValue> is the correct size for all fixed-size settings.
  27. * 09/29/00 CS Made iLocale parm of LmLocaleToIndex const.
  28. * 11/17/00 CS Removed support for lmChoiceLanguage & lmChoiceCountry,
  29. * since these guys were returning UInt8's, which probably
  30. * won't cut it at some point in the future. Callers can use
  31. * lmChoiceLocale, which returns an LmLocaleType struct that
  32. * places the country and language into UInt16 fields.
  33. * CS Defined lmAnyCountry & lmAnyLanguage, which can now be passed
  34. * in LmLocaleToIndex's iLocale parameter (as wildcards).
  35. *
  36. *****************************************************************************)
  37. unit localemgr;
  38. interface
  39. uses palmos, coretraps, errorbase;
  40. // Supporting lmChoiceLanguageName would add over 3K to the 'locs' resource.
  41. // DOLATER CS - either do it or punt.
  42. const
  43. SUPPORT_LANGUAGE_NAME = 0;
  44. (***********************************************************************
  45. * Locale Manager errors
  46. **********************************************************************)
  47. // Locale not found in 'locs' resource.
  48. const
  49. lmErrUnknownLocale = lmErrorClass or 1;
  50. // Locale index >= LmGetNumLocales().
  51. lmErrBadLocaleIndex = lmErrorClass or 2;
  52. // LmLocaleSettingChoice out of bounds.
  53. lmErrBadLocaleSettingChoice = lmErrorClass or 3;
  54. // Data for locale setting too big for destination.
  55. lmErrSettingDataOverflow = lmErrorClass or 4;
  56. (***********************************************************************
  57. * Locale Manager settings (pass to LmGetLocaleSetting)
  58. **********************************************************************)
  59. type
  60. LmLocaleSettingChoice = UInt16;
  61. // LmLocaleType
  62. const
  63. lmChoiceLocale = LmLocaleSettingChoice(1);
  64. // Char[kMaxLanguageNameLen+1] - Name of the language spoken there (localized)
  65. const
  66. lmChoiceLanguageName = LmLocaleSettingChoice(4);
  67. // Char[kMaxCountryNameLen+1] - Name of the country (localized)
  68. lmChoiceCountryName = LmLocaleSettingChoice(5);
  69. // DateFormatType
  70. lmChoiceDateFormat = LmLocaleSettingChoice(6);
  71. // DateFormatType
  72. lmChoiceLongDateFormat = LmLocaleSettingChoice(7);
  73. // TimeFormatType
  74. lmChoiceTimeFormat = LmLocaleSettingChoice(8);
  75. // UInt16 - Weekday for calendar column 1 (sunday=0, monday=1, etc.)
  76. lmChoiceWeekStartDay = LmLocaleSettingChoice(9);
  77. // Int16 - Default GMT offset minutes, + for east of GMT, - for west
  78. lmChoiceTimeZone = LmLocaleSettingChoice(10);
  79. // NumberFormatType - Specifies decimal and thousands separator characters
  80. lmChoiceNumberFormat = LmLocaleSettingChoice(11);
  81. // Char[kMaxCurrencyNameLen+1] - Name of local currency (e.g., "US Dollar")
  82. lmChoiceCurrencyName = LmLocaleSettingChoice(12);
  83. // Char[kMaxCurrencySymbolLen+1] - Currency symbol (e.g., "$")
  84. lmChoiceCurrencySymbol = LmLocaleSettingChoice(13);
  85. // Char[kMaxCurrencySymbolLen+1] - Unique currency symbol (e.g., "US$")
  86. lmChoiceUniqueCurrencySymbol = LmLocaleSettingChoice(14);
  87. // UInt16 - Number of decimals for currency (e.g., 2 for $10.12)
  88. lmChoiceCurrencyDecimalPlaces = LmLocaleSettingChoice(15);
  89. // MeasurementSystemType - Metric, English, etc.
  90. lmChoiceMeasurementSystem = LmLocaleSettingChoice(16);
  91. (***********************************************************************
  92. * Locale Manager constants
  93. **********************************************************************)
  94. const
  95. lmAnyCountry = Word(65535); // Pass LmLocaleToIndex's iLocale
  96. lmAnyLanguage = Word(65535); // Pass LmLocaleToIndex's iLocale
  97. const
  98. kMaxCountryNameLen = 19;
  99. kMaxLanguageNameLen = 19;
  100. kMaxCurrencyNameLen = 19;
  101. kMaxCurrencySymbolLen = 5;
  102. (***********************************************************************
  103. * Selectors & macros used for calling Locale Manager routines
  104. **********************************************************************)
  105. // Selectors used for getting to the right Locale Manager routine via
  106. // the LmDispatch trap.
  107. // DOLATER:jwm: remove me after fixing LocaleMgr.c:PrvSelectorError
  108. type
  109. LmRoutineSelector = UInt16;
  110. const
  111. lmInit = 0;
  112. lmGetNumLocales_ = 1;
  113. lmLocaleToIndex_ = 2;
  114. lmGetLocaleSetting_ = 3;
  115. const
  116. lmMaxRoutineSelector = lmGetLocaleSetting_;
  117. (***********************************************************************
  118. * Locale Manager types
  119. **********************************************************************)
  120. type
  121. LanguageType = UInt8;
  122. CountryType = UInt8;
  123. _LmLocaleType = record
  124. language: UInt16; // Language spoken in locale (LanguageType)
  125. country: UInt16; // Specifies "dialect" of language (CountryType)
  126. end;
  127. LmLocaleType = _LmLocaleType;
  128. LmLocalePtr = ^LmLocaleType;
  129. (***********************************************************************
  130. * Locale Manager routines
  131. **********************************************************************)
  132. // Return the number of known locales (maximum locale index + 1).
  133. function LmGetNumLocales: UInt16; // syscall sysTrapLmDispatch, lmGetNumLocales_;
  134. // Convert <iLocale> to <oLocaleIndex> by locating it within the set of known
  135. // locales.
  136. function LmLocaleToIndex({const} var iLocale: LmLocaleType; var oLocaleIndex: UInt16): Err; // syscall sysTrapLmDispatch, lmLocaleToIndex_;
  137. // Return in <oValue> the setting identified by <iChoice> which is appropriate for
  138. // the locale identified by <iLocaleIndex>. Return lmErrSettingDataOverflow if the
  139. // data for <iChoice> occupies more than <iValueSize> bytes. Display a non-fatal
  140. // error if <iValueSize> is larger than the data for a fixed-size setting.
  141. function LmGetLocaleSetting(iLocaleIndex: UInt16; iChoice: LmLocaleSettingChoice;
  142. oValue: Pointer; iValueSize: UInt16): Err; // syscall sysTrapLmDispatch, lmGetLocaleSetting_;
  143. implementation
  144. function __LmGetNumLocales: UInt16; syscall sysTrapLmDispatch;
  145. function __LmLocaleToIndex(var iLocale: LmLocaleType; var oLocaleIndex: UInt16): Err; syscall SysTrapLmDispatch;
  146. function __LmGetLocaleSetting(iLocaleIndex: UInt16; iChoice: LmLocaleSettingChoice;
  147. oValue: Pointer; iValueSize: UInt16): Err; syscall sysTrapLmDispatch;
  148. function LmGetNumLocales: UInt16; // syscall sysTrapLmDispatch, lmGetNumLocales_;
  149. begin
  150. asm
  151. move.l #$lmGetNumLocales_, d2;
  152. end;
  153. LmGetNumLocales := __LmGetNumLocales;
  154. end;
  155. function LmLocaleToIndex({const} var iLocale: LmLocaleType; var oLocaleIndex: UInt16): Err; // syscall sysTrapLmDispatch, lmLocaleToIndex_;
  156. begin
  157. asm
  158. MOVE.L #$lmLocaleToIndex_, d2;
  159. end;
  160. LmLocaleToIndex := __LmLocaleToIndex(iLocale, oLocaleIndex);
  161. end;
  162. function LmGetLocaleSetting(iLocaleIndex: UInt16; iChoice: LmLocaleSettingChoice;
  163. oValue: Pointer; iValueSize: UInt16): Err; // syscall sysTrapLmDispatch, lmGetLocaleSetting_;
  164. begin
  165. asm
  166. MOVE.L #$lmGetLocaleSetting_, d2;
  167. end;
  168. LmGetLocaleSetting := __LmGetLocaleSetting(iLocaleIndex, iChoice, oValue, iValueSize);
  169. end;
  170. end.