1 /* This file provides definitions for the C source and resource scripts
2    for support of operation under the Microsoft Windows environment on
3    an IBM-PC or compatible computer.
4 
5    Must be compiled with Borland C++ 2.0 or MSC 6.0 or later versions
6 
7    It should not be compiled if the WINDOW_MSWIN symbol is not set */
8 
9 /* compile flags */
10 #define GRINDERS    8   /* 0 to use the hourglass, 8 to use the animated
11                            grinder (8 is the number of animation steps) */
12 
13 #define MEMTRACE    1   /* adds a debugging trace to mswmem.c (used only
14                            if SUBALLOC (below) is 1) */
15 
16 /* The SUBALLOC #define implements malloc/free/realloc by segment
17    suballocation routines (needed for Borland C 2.0, but not necessary
18    under Borland C 3.0). Not needed under MSC 7.0 either. */
19 #if WINDOW_MSWIN32
20 	#define SUBALLOC    0
21 #else
22 	#if     TURBO
23 		#if         defined(__BORLANDC__) && (__TURBOC__<0x300)
24 			#define SUBALLOC    1   /* BC++ 2.0 */
25 		#else
26 			#define SUBALLOC    0   /* TC++ 1.0 or BC++ 3.x */
27 		#endif	/* defined(__BORLANDC__) && (__TURBOC__<0x300) */
28 	#endif	/* TURBO */
29 
30 	#if     MSC
31 		#if         _MSC_VER < 700
32 			#define SUBALLOC    1
33 		#else
34 			#define SUBALLOC    0
35 		#endif	/* _MSC_VER < 700 */
36 	#endif	/* MSC */
37 
38 #endif	/* WINDOW_MSWIN32 */
39 
40 #include    <shellapi.h>
41 
42 #include    "mswrid.h"  /* contains all the Resource IDs */
43 
44 #if WINDOW_MSWIN32
45 #define LPDATA(p) ((LPARAM)(LPSTR)(p))
46 #define HDROP HANDLE
47 #define NOTIFICATION_CODE HIWORD(wParam)    /* for WM_COMMAND parsing */
48 #else
49 #define LPDATA(p) ((LPSTR)(p))
50 #define NOTIFICATION_CODE HIWORD(lParam)
51 #define WNDPROC FARPROC
52 #endif
53 
54 /* macros */
55 #define MLSIZE  NSTRING         /* message line buffer size */
56 
57 /* offsets for the screen windows extra bytes */
58 #define GWL_SCRPTR  0                   /* SCREEN structure pointer */
59 #define GWW_SCRCX   (GWL_SCRPTR+sizeof(LONG))   /* client area width */
60 #define GWW_SCRCY   (GWW_SCRCX+sizeof(WORD))       /* client area height */
61 #define SCRWNDEXTRA (GWW_SCRCY+sizeof(WORD))
62 
63 /* offsets for the frame window extra bytes */
64 #define GWW_FRMID   0                   /* Id seen by other emacs apps */
65 #define FRMWNDEXTRA (GWW_FRMID+sizeof(WORD))
66 
67 /* structures */
68 typedef struct  CellMetrics {   /* coordinate-related parameters of a font */
69     short   OffsetX, OffsetY;  /* offset of column 0 or row 0, relative
70 				  to the client area upper left corner */
71     short   LeadingY, HalfLeadingY; /* external leading between rows */
72     short   SizeX, SizeY;       /* character cell size */
73     short   MLHeight;           /* height of the message line */
74 } CellMetrics;
75 
76 #ifdef  termdef     /* in mswdrv.c only */
77 char	IniFile[] = "EMACS.INI";
78 char    ProgName [] = PROGNAME;
79 int     CurrentRow = 0;
80 int     CurrentCol = 0;
81 BOOL    MouseTracking = FALSE;
82 BOOL    InternalRequest = FALSE;
83 BOOL    TakingANap = FALSE;
84 int	caret_shape = 0;
85 
86 /* Global uninitialized variables */
87 HWND    hFrameWnd;          /* main (frame) window */
88 HWND    hMDIClientWnd;      /* MDI client window */
89 HANDLE  hEmacsInstance;     /* module instance */
90 BOOL    Win386Enhanced;     /* Windows 386 enhanced mode */
91 BOOL    Win31API;           /* Windows 3.1 or later version */
92 HCURSOR hScreenCursor, hTrackCursor, hNotQuiescentCursor, hHourglass;
93 char    *ScreenClassName;   /* MDI childs class name */
94 char    *MLBuf;             /* message line buffer */
95 HFONT   hEmacsFont;         /* font used for display */
96 CellMetrics     EmacsCM;    /* cell metrics of that font */
97 
98 
99 #if GRINDERS != 0
100 HCURSOR GrinderCursor [GRINDERS];/* handles for the grinder animation */
101 int     GrinderIndex;
102 #endif
103 
104 char    *MainHelpFile;      /* Emac's help file name and useage flag */
105 BOOL    MainHelpUsed;
106 
107 char    HelpEngineFile [NFILEN];/* user help file and useage flag */
108 BOOL    ColorDisplay;       /* TRUE if the display is color-capable */
109 #else
110 extern char IniFile[DUMMYSZ];
111 extern char ProgName [DUMMYSZ];/* used all over the place for captions,
112 			          etc... */
113 extern int  CurrentRow;
114 extern int  CurrentCol;		/* caret positions (in text coordinates) */
115 extern BOOL MouseTracking;	/* TRUE if mouse in tracking/dragging mode */
116 extern BOOL InternalRequest;
117     /* TRUE for a request that originates from the mswxxx modules. This
118        is meant to avoid infinite recursions for requests that could
119        come from both MS-Windows or the editor's core (for instance
120        resizing, screen activation...) */
121 extern BOOL TakingANap;		/* TRUE during execution of TakeANap() */
122 extern int  caret_shape;	/* 0 = HorzBar, 1 = VertBar, 2 = CellSize */
123 
124 /* Global uninitialized variables */
125 extern HWND    hFrameWnd;          /* main (frame) window */
126 extern HWND    hMDIClientWnd;      /* MDI client window */
127 extern HANDLE  hEmacsInstance;     /* module instance */
128 extern BOOL    Win386Enhanced;     /* Windows 386 enhanced mode */
129 extern BOOL    Win31API;           /* Windows 3.1 or later version */
130 extern HCURSOR hScreenCursor, hTrackCursor, hNotQuiescentCursor, hHourglass;
131 extern char    *ScreenClassName;   /* MDI childs class name */
132 extern char    *MLBuf;             /* message line buffer */
133 extern HFONT   hEmacsFont;         /* font used for display */
134 extern CellMetrics     EmacsCM;    /* cell metrics of that font */
135 
136 #if GRINDERS != 0
137 extern HCURSOR GrinderCursor [GRINDERS];/* handles for the grinder animation */
138 extern int     GrinderIndex;
139 #endif
140 
141 extern char    *MainHelpFile;      /* Emac's help file name and useage flag */
142 extern BOOL    MainHelpUsed;
143 
144 extern char    HelpEngineFile [NFILEN];/* user help file and useage flag */
145 extern BOOL    ColorDisplay;       /* TRUE if the display is color-capable */
146 #endif
147 
148 /* input stream access functions */
149 void in_init (void);
150 BOOL in_room (int n);
151 BOOL in_check (void);
152 void in_put (int event);
153 int  in_get (void);
154 
155 /* Windows-implementation specific functions */
156 LONG EXPORT FAR PASCAL ScrWndProc (HWND hWnd, UINT wMsg, UINT wParam,
157 				   LONG lParam);
158 LONG EXPORT FAR PASCAL FrameWndProc (HWND hWnd, UINT wMsg, UINT wParam,
159 				     LONG lParam);
160 int FAR PASCAL GetInput (void);
161 int FAR PASCAL TakeANap (int t);
162 
163 void FAR PASCAL GenerateMenuSeq (UINT ID);
164 KEYTAB * FAR PASCAL FindKeyBinding (void *Func);
165 void FAR PASCAL InitMenuPopup (HMENU hMenu, LONG lParam);
166 BOOL FAR PASCAL MenuCommand (UINT wParam, LONG lParam);
167 HMENU FAR PASCAL GetScreenMenuHandle (void);
168 
169 BOOL FAR PASCAL EatKey (UINT MsgCode, UINT wParam, LONG lParam);
170 void FAR PASCAL MouseMessage (HWND hWnd, UINT wMsg, UINT wParam, LONG lParam);
171 void FAR PASCAL DropMessage (HWND hWnd, HANDLE hDrop);
172 
173 void FAR PASCAL BuildCellMetrics (CellMetrics *cm, HFONT hFont);
174 void FAR PASCAL InvalidateCells (HWND hWnd, int leftcol, int toprow,
175                                  int rightcol, int bottomrow);
176 void FAR PASCAL MinimumClientSize (HWND hWnd, int NCols, int NRows,
177 				   int *Width, int *Height);
178 int FAR PASCAL DisplayableRows (HWND hWnd, int Height, CellMetrics *cm);
179 int FAR PASCAL DisplayableColumns (HWND hWnd, int Width, CellMetrics *cm);
180 void FAR PASCAL EmacsCaret (BOOL Show);
181 void FAR PASCAL MoveEmacsCaret (HWND hWnd, int col, int row);
182 void FAR PASCAL ShowEmacsCaret (BOOL Show);
183 void FAR PASCAL CellToClient (HWND hWnd, POINT Cell, LPPOINT Client);
184 void FAR PASCAL ClientToCell (HWND hWnd, POINT Client, LPPOINT Cell);
185 void FAR PASCAL GetMinMaxInfo (HWND hWnd, LPPOINT rgpt);
186 BOOL FAR PASCAL ScrReSize (HWND hWnd, UINT wParam, WORD cx, WORD cy);
187 void FAR PASCAL ScrPaint (HWND hWnd);
188 void FAR PASCAL MLPaint (void);
189 
190 BOOL FAR PASCAL InMessageLine (void);
191 
192 void FAR PASCAL ClipboardCleanup (void);
193 void FAR PASCAL ScrollMessage (HWND hWnd, UINT wMsg, WORD ScrlCode, int Pos);
194 void FAR PASCAL ScrollBars (void);
195 
196 int FAR PASCAL SetWorkingDir (void);
197 
198 void FAR PASCAL InitializeFarStorage (void);
199 void FAR PASCAL JettisonFarStorage (void);
200 
201 HFONT FAR PASCAL SelectFont (HDC hDC, HFONT hFont);
202 BOOL FAR PASCAL PickEmacsFont (void);
203 void FAR PASCAL FontInit (void);
204