DEFINITION MODULE NLS;

(************************************************************************
  OS/2 2.0 interface for Presentation Manager DBCS.

  Note: OS/2 2.0 as shipped in Europe currently has no library
        exporting the necessary DBCS functions, hence cannot be
        resolved by LINK386.EXE!

  Copyright (c) 1992 by Juergen Neuhoff
*************************************************************************)

(*$XL+       Modula-2 language extensions: '_' allowed for symbol names *)
(*$CDECL+    C-style procedures                                         *)
(*$A         default alignment for record fields                        *)

IMPORT SYSTEM;
FROM   OS2DEF  IMPORT PSZ, TYPEPREFIX, HAB, HWND;

CONST (* resource ID offset for bi-lingual system resources (menu & string) *)
  RID_DBE_OFFSET             = 1000H;
  STR_DBE_OFFSET             = 1000H;

CONST(* definition of Virtual key values for DBCS *)
  VK_DBE_FIRST               = 080H; (* VK_DBCSFIRST *)
  VK_DBE_LAST                = 0FFH; (* VK_DBCSLAST  *)
  VK_DBE_IMEFIRST            = 0A0H; (* VK_DBE_FIRST + 20H *)
  VK_DBE_IMELAST             = 0FFH; (* VK_DBE_LAST *)

CONST (* OEM keyboard support including PS/2 keyboard *)
  VK_DBE_OEMFIRST            = 0C0H;
  VK_DBE_OEMLAST             = 0CFH;

CONST (* for codepage 932 *)
  VK_DBE_ALPHANUMERIC        = 80H; (* VK_DBE_FIRST + 00H *)
  VK_DBE_KATAKANA            = 81H; (* VK_DBE_FIRST + 01H *)
  VK_DBE_HIRAGANA            = 82H; (* VK_DBE_FIRST + 02H *)
  VK_DBE_SBCSCHAR            = 83H; (* VK_DBE_FIRST + 03H *)
  VK_DBE_DBCSCHAR            = 84H; (* VK_DBE_FIRST + 04H *)
  VK_DBE_SBCSDBCSCHAR        = 85H; (* VK_DBE_FIRST + 05H *)
  VK_DBE_ROMAN               = 86H; (* VK_DBE_FIRST + 06H *)

CONST (* for codepage 934 *)
  VK_DBE_HANJA               = 87H; (* VK_DBE_FIRST + 07H *)
  VK_DBE_HANGEUL             = 88H; (* VK_DBE_FIRST + 08H *)
  VK_DBE_JAMO                = 89H; (* VK_DBE_FIRST + 09H *)

CONST (* for codepage 936 *)
  VK_DBE_HANZI               = 8AH; (* VK_DBE_FIRST + 0AH *)

CONST (* for codepage 938 *)
  VK_DBE_TSANGJYE            = 08CH; (* VK_DBE_FIRST + 0CH *)
  VK_DBE_PHONETIC            = 08DH; (* VK_DBE_FIRST + 0DH *)
  VK_DBE_KANJI               = 0A0H; (* VK_DBE_IMEFIRST + 00H *)
  VK_DBE_IMEACTIVATE         = 0A0H; (* VK_DBE_IMEFIRST + 00H *)
  VK_DBE_CONV                = 0A1H; (* VK_DBE_IMEFIRST + 01H *)
  VK_DBE_NOCONV              = 0A2H; (* VK_DBE_IMEFIRST + 02H *)
  VK_DBE_TANGO               = 0A3H; (* VK_DBE_IMEFIRST + 03H *)
  VK_DBE_WORDREGISTER        = 0A3H; (* VK_DBE_IMEFIRST + 03H *)
  VK_DBE_IMEDIALOG           = 0A4H; (* VK_DBE_IMEFIRST + 04H *)
  VK_DBE_IME_MBSELECTED      = 0A5H; (* VK_DBE_IMEFIRST + 05H *)
  VK_DBE_IME_LBSELECTED      = 0A6H; (* VK_DBE_IMEFIRST + 06H *)
  VK_DBE_CODEINPUT           = 0A7H; (* VK_DBE_IMEFIRST + 07H *)
  VK_DBE_ALLCANDIDATE        = 0A8H; (* VK_DBE_IMEFIRST + 08H *)
  VK_DBE_PREVCANDIDATE       = 0A9H; (* VK_DBE_IMEFIRST + 09H *)
  VK_DBE_IMEDEACTIVATE       = 0AAH; (* VK_DBE_IMEFIRST + 0AH *)
  VK_DBE_IME_WORDREGISTED    = 0ABH; (* VK_DBE_IMEFIRST + 0BH *)
  VK_DBE_IMECONTROL          = 0ACH; (* VK_DBE_IMEFIRST + 0CH *)
  VK_DBE_IME_FREEPS          = 0ADH; (* VK_DBE_IMEFIRST + 0DH *)
  VK_DBE_IMEMODEEXIT         = 0AEH; (* VK_DBE_IMEFIRST + 0EH *)

CONST (* Window Class definitoin for DBCS (migration) *)
  WC_DBE_APPSTAT             = PSZ( 0FFFF0010H ); (* WC_APPSTAT *)
  WC_DBE_KBDSTAT             = PSZ( 0FFFF0011H ); (* WC_KBDSTAT *)
  WC_DBE_PECIC               = PSZ( 0FFFF0012H ); (* WC_PECIC   *)

CONST (* Double byte character set messages *)
  WM_DBE_SETAPPLSTAT         = 00B6H;
  WM_DBE_KKCPARAMS           = 00BCH;

CONST (* DBCS unique statndsrd Frame Create Flag (migration) *)
  FCF_DBE_STATAREA           = 80000000H; (* FCF_DBE_APPSTAT *)

TYPE (* WM_SETWINDOWPARAM ctldata of DBCS status area *)
  KEYSTSDATA                 = RECORD       (* keysts *)
    CASE                       : TYPEPREFIX OF
    | TRUE                     :
      wpmctlflag               : LONGCARD;
      textlength               : LONGCARD;
      pTextString              : PSZ;
      pAttrString              : PSZ;
      pRomanString             : PSZ;
    | FALSE                    :
      WPMCtlFlag               : LONGCARD;
      TextLength               : LONGCARD;
      TextString               : PSZ;
      AttrString               : PSZ;
      RomanString              : PSZ;
    END;                       END;
  PKEYSTSDATA                = POINTER TO KEYSTSDATA;
  WPMCTLPARAMS               = RECORD   (* wpmctlprm - old definition *)
    CASE                       : TYPEPREFIX OF
    | TRUE                     :
      wpmctlflag               : LONGCARD;
      textlength               : LONGCARD;
      pTextString              : PSZ;
      pAttrString              : PSZ;
    | FALSE                    :
      WPMCtlFlag               : LONGCARD;
      TextLength               : LONGCARD;
      TextString               : PSZ;
      AttrString               : PSZ;
    END;                       END;
  PWPMCTLPARAMS              = POINTER TO WPMCTLPARAMS;

CONST (* wpmctlflag value definition *)
  DBE_KSF_ALPHANUMERIC       = 0001H;
  DBE_KSF_KATAKANA           = 0002H;
  DBE_KSF_HIRAGANA           = 0004H;
  DBE_KSF_CAPS               = 0008H;
  DBE_KSF_ROMAN              = 0010H;
  DBE_KSF_HANKAKU            = 0020H;
  DBE_KSF_ZENKAKU            = 0040H;
  DBE_KSF_SBCS               = DBE_KSF_HANKAKU;
  DBE_KSF_DBCS               = DBE_KSF_ZENKAKU;
  DBE_KSF_UPPER              = 0080H;
  DBE_KSF_LOWER              = 0100H;
  DBE_KSF_TEXT               = 0200H;
  DBE_KSF_NOROMAN            = 0400H;
  DBE_KSF_DISABLEONTHESPOT   = 0800H;
  DBE_KSF_ROMANTEXT          = 1000H;

CONST (* For Code Page 934(Korea) wpmctlflag value definition  *)
  DBE_KSF_JAMO               = 0002H;
  DBE_KSF_HANGEUL            = 0004H;

CONST (* For Code Page 938(Taiwan) wpmctlflag value definition  *)
  DBE_KSF_PHONETIC           = 0002H;
  DBE_KSF_TSANGJYE           = 0004H;

TYPE (* WM_SETWINDOWPARAM ctldata of Pecic control *)
  PECICDATA                  = RECORD     (* pecicdata *)
    CASE                       : TYPEPREFIX OF
    | TRUE                     :
      wpmctlflag               : LONGCARD;
      textlength               : LONGCARD;
      pTextString              : PSZ;
      pAttrString              : PSZ;
    | FALSE                    :
      WPMCtlFlag               : LONGCARD;
      TextLength               : LONGCARD;
      TextString               : PSZ;
      AttrString               : PSZ;
    END;
    CursorPos                  : LONGCARD;
    CursorAttr                 : LONGCARD;
                               END;
  PPECICDATA                 = POINTER TO PECICDATA;

CONST (* wndparams definition of WM_DBE_APPLSTAT *)
  DBE_WPM_APPLSTAT_VISIBILITY = 0004H;

CONST (* ctldata of DBE_WPM_APPLSTAT_VISIBLITY *)
  DBE_AS_APPLTOP             = 0001H;
  DBE_AS_KBDTOP              = 0002H;
  DBE_AS_PECICTOP            = 0004H;
  DBE_AS_APPLBOTTOM          = 0008H;

TYPE (** WM_DBE_KKCPARAMS definition **)
     (* mp1(lpkkcparams) *)
  KKCPARAMS                  = RECORD   (* kkcparams *)
    CASE                       : TYPEPREFIX OF
    | TRUE                     :
      lenKKCParams             : LONGCARD;
      fRequest                 : LONGCARD;
      fKKCParams               : LONGCARD;
      pKKCData                 : SYSTEM.ADDRESS;
    | FALSE                    :
      KKCParamsLen             : LONGCARD;
      RequestFlags             : LONGCARD;
      KKCParamsFlags           : LONGCARD;
      KKCData                  : SYSTEM.ADDRESS;
    END;
    Reserved                   : LONGCARD;
                               END;
  PKKCPARAMS                 = POINTER TO KKCPARAMS;

CONST (* fRequest *)
  DBE_KKCPARAMS_SET          = 0001H;
  DBE_KKCPARAMS_QUERY        = 0002H;

CONST (* fKKCParams *)
  DBE_KKCPARAMS_PHYSICALATTRIBUTE = 0001H;
  DBE_KKCPARAMS_PECICCURSORPOS    = 0002H;

TYPE  (* Level format for ColorLookUpTable *)
   (*$A1 BVYTE alignment for record fields *)
   LEVEL                     = RECORD   (* Level *)
    CASE                       : TYPEPREFIX OF
    | TRUE                     :
      attri1                   : SHORTCARD;  (** 1st Attribute         **)
      attri2                   : SHORTCARD;  (** 2nd Attribute         **)
    | FALSE                    :
      Attri1                   : SHORTCARD;  (** 1st Attribute         **)
      Attri2                   : SHORTCARD;  (** 2nd Attribute         **)
    END;                       END;
  PLEVEL                     = POINTER TO LEVEL;
  (*$A restore default alignment for record fields *)

TYPE (* Color Look Up Table format *)
  COLORLOOKUPTBL             = RECORD (* ColorLookUpTable *)
    CASE                       : TYPEPREFIX OF
    | TRUE                     :
      nAttr                    : LONGCARD;  (* number of Attribute *)
    | FALSE                    :
      AttrNumber               : LONGCARD;  (* number of Attribute *)
    END;
    PhysicalLevel              : ARRAY [0..31] OF LEVEL; (* Levels *)
                               END;
  PCOLORLOOKUPTBL            = POINTER TO COLORLOOKUPTBL;

 (** WinDBCSIMEControl() Definition & Prototype **)

CONST (* type *)
  DBE_IMCTL_QUERY            = 0001H;
  DBE_IMCTL_SET              = 0002H;

TYPE
  IMEMODE                    = RECORD (* imemode *)
    CASE                       : TYPEPREFIX OF
    | TRUE                     :
      lenIMEMODE               : LONGCARD;
      fIMEMode                 : LONGCARD;
      hIME                     : LONGCARD; (* query mode only valid *)
      hModIME                  : LONGCARD; (* query mode only valid *)
    | FALSE                    :
      IMEModeLen               : LONGCARD;
      IMEModeFlags             : LONGCARD;
      IMEHandle                : LONGCARD; (* query mode only valid *)
      ModIMEHandle             : LONGCARD; (* query mode only valid *)
    END;                       END;
  PIMEMODE                   = POINTER TO IMEMODE;

CONST (* definition of fIMEMode *)
  DBE_IMCTL_IMEENABLE        = 0001H;
  DBE_IMCTL_IMEDISABLE       = 0002H;
  DBE_IMCTL_IMEMODE          = 0004H;
  DBE_IMCTL_NOTIMEMODE       = 0008H;
  DBE_IMCTL_INHERIT_PFRAME   = 0100H;
  DBE_IMCTL_INTERIMREQUEST   = 8000H;

PROCEDURE WinDBCSIMEControl
( AnchorBlockHandle          : HAB;
  FrameWinHandle             : HWND;
  Type                       : LONGCARD;
  VAR IMEMode                : IMEMODE
)                            : LONGCARD;


CONST (* WinDBCSModeControl() Type *)
  DBE_MCTL_QUERY             = 0001H;
  DBE_MCTL_SET               = 0002H;

CONST (* WinDBCSModeControl() Arg *)
  DBE_MCTL_INPUTMODEREQUEST  = 0001H;
  DBE_MCTL_JAPANREQ          = 0001H;   (* migration *)

CONST (* WinDBCSModeControl() Parm - MCTL_JAPAN *)
  DBE_MCTL_ALPHANUMERIC      = 0001H;
  DBE_MCTL_KATAKANA          = 0002H;
  DBE_MCTL_HIRAGANA          = 0004H;
  DBE_MCTL_SBCSCHAR          = 0008H;
  DBE_MCTL_DBCSCHAR          = 0010H;
  DBE_MCTL_ROMAN             = 0020H;
  DBE_MCTL_NOROMAN           = 0040H;
  DBE_MCTL_KKCREQ            = 1000H;
  DBE_MCTL_CP932REQ          = 0001H;
  DBE_MCTL_KKCENABLE         = 1000H;
  DBE_MCTL_KKCDISABLE        = 2000H;
  DBE_MCTL_HANKAKU           = 0008H;
  DBE_MCTL_ZENKAKU           = 0010H;

CONST (* WinDBCSModeControl() Parm  - MCTL_KOREA *)
  DBE_MCTL_JAMO              = 0002H;
  DBE_MCTL_HANGEUL           = 0004H;
  DBE_MCTL_INTERIMREQUEST    = 0080H;

CONST (* WinDBCSModeControl() Parm - MCTL_TCHINESE *)
  DBE_MCTL_PHONETIC          = 0002H;
  DBE_MCTL_TSANGJYE          = 0004H;

CONST (* for MDI support *)
  DBE_MCTL_INHERIT_PFRAME    = 0100H;

PROCEDURE WinDBCSModeControl
( AnchorBlockHandle          : HAB;
  FrameWinHandle             : HWND;
  Type                       : LONGCARD;
  Arg                        : LONGCARD;
  VAR Parm                   : LONGCARD
)                            : LONGCARD;

TYPE (* Font Driver Description structure  *)
  FD_DESC                    = RECORD   (* fd_desc *)
    CASE                       : TYPEPREFIX OF
    | TRUE                     :
      flType                   : LONGCARD;
      str64Desc                : ARRAY [0..63] OF CHAR;
    | FALSE                    :
      TypeFlags                : LONGCARD;
      Desc                     : ARRAY [0..63] OF CHAR;
    END;                       END;
  PFD_DESC                   = POINTER TO FD_DESC;

(* Font Driver functions *)

PROCEDURE WinDBCSLoadFontDriver
( AnchorBlockHandle          : HAB;
  DriverName                 : ARRAY OF CHAR
)                            : BOOLEAN;

PROCEDURE WinDBCSUnloadFontDriver
( AnchorBlockHandle          : HAB;
  DriverName                 : ARRAY OF CHAR
)                            : BOOLEAN;

PROCEDURE WinDBCSQueryFDDescription
( AnchorBlockHandle          : HAB;
  DriverName                 : ARRAY OF CHAR;
  VAR FontDriverDesc         : FD_DESC
)                            : BOOLEAN;

CONST (* fd_type definition *)
  DBE_FD_DESC_SYSTEM         = 0001H;
  DBE_FD_DESC_PUBLIC         = 0002H;
  DBE_FD_DESC_PRIVATE        = 0004H;

CONST (* System menu item number ID in MENUITEM for DBCS unique function *)
  SC_DBE_IME                 = 8018H;
  SC_DBE_IMESEPARATOR        = 8019H;

END NLS.
