source: vendor/emx/current/src/pmgdb/pmframe.cc

Last change on this file was 18, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 8.6 KB
Line 
1/* pmframe.cc
2 Copyright (c) 1996 Eberhard Mattes
3
4This file is part of pmgdb.
5
6pmgdb is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11pmgdb is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with pmgdb; see the file COPYING. If not, write to
18the Free Software Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
20
21
22#define INCL_DOS
23#define INCL_WIN
24#include <os2.h>
25#include <stdlib.h>
26#include <string.h>
27#include "string.h"
28#include "pmapp.h"
29#include "pmframe.h"
30
31// TODO
32static pmframe *pmframe_init_kludge;
33
34pmframe::pmframe (pmapp *in_app)
35{
36 app = in_app;
37 minimized = false;
38 hwndHelp = NULLHANDLE;
39 keys_help_id = 0;
40 tid = _gettid ();
41}
42
43
44void pmframe::create (const char *classname, unsigned id, ULONG frame_flags,
45 const SWP *pswp)
46{
47 WinRegisterClass (app->get_hab (), (PSZ)classname, pmframe_client_msg,
48 CS_SIZEREDRAW, sizeof (pmframe *));
49
50 frame_flags |= (FCF_TITLEBAR | FCF_SYSMENU |
51 FCF_SIZEBORDER | FCF_MINMAX |
52 FCF_MENU | FCF_ACCELTABLE |
53 FCF_VERTSCROLL | FCF_HORZSCROLL);
54
55 pmframe_init_kludge = this;
56 if (WinCreateStdWindow (HWND_DESKTOP, 0,
57 &frame_flags, (PSZ)classname,
58 NULL, 0L, 0, id, NULL) == NULLHANDLE)
59 {
60 win_error ();
61 abort ();
62 }
63 old_frame_msg = WinSubclassWindow (hwndFrame, pmframe_frame_msg);
64 if (pswp != NULL)
65 WinSetWindowPos (hwndFrame, HWND_DESKTOP, pswp->x, pswp->y,
66 pswp->cx, pswp->cy, SWP_MOVE | SWP_SIZE);
67}
68
69
70pmframe::~pmframe ()
71{
72 WinDestroyWindow (hwndFrame);
73}
74
75
76void pmframe::set_title (const char *title)
77{
78 WinSetWindowText (hwndFrame, (PCSZ)title);
79}
80
81
82void pmframe::repaint (RECTL *prcl)
83{
84 WinInvalidateRect (hwndClient, prcl, FALSE);
85}
86
87
88repaint (RECTL *prcl = NULL);
89
90
91MRESULT pmframe::wm_activate (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
92{
93 return WinDefWindowProc (hwnd, msg, mp1, mp2);
94}
95
96
97MRESULT pmframe::wm_button (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
98{
99 return WinDefWindowProc (hwnd, msg, mp1, mp2);
100}
101
102
103MRESULT pmframe::wm_char (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
104{
105 return WinDefWindowProc (hwnd, msg, mp1, mp2);
106}
107
108
109MRESULT pmframe::wm_close (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
110{
111 return WinDefWindowProc (hwnd, msg, mp1, mp2);
112}
113
114
115MRESULT pmframe::wm_command (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
116{
117 return WinDefWindowProc (hwnd, msg, mp1, mp2);
118}
119
120
121MRESULT pmframe::wm_create (HWND, ULONG, MPARAM, MPARAM)
122{
123 return FALSE;
124}
125
126
127MRESULT pmframe::wm_hscroll (HWND, ULONG, MPARAM, MPARAM)
128{
129 return 0;
130}
131
132
133MRESULT pmframe::wm_presparamchanged (HWND, ULONG, MPARAM, MPARAM)
134{
135 return 0;
136}
137
138
139MRESULT pmframe::wm_setfocus (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
140{
141 return WinDefWindowProc (hwnd, msg, mp1, mp2);
142}
143
144
145MRESULT pmframe::wm_size (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
146{
147 return WinDefWindowProc (hwnd, msg, mp1, mp2);
148}
149
150
151MRESULT pmframe::wm_timer (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
152{
153 return WinDefWindowProc (hwnd, msg, mp1, mp2);
154}
155
156
157bool pmframe::wm_user (HWND, ULONG, MPARAM, MPARAM)
158{
159 return false;
160}
161
162
163MRESULT pmframe::wm_vscroll (HWND, ULONG, MPARAM, MPARAM)
164{
165 return 0;
166}
167
168
169MRESULT pmframe::client_msg (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
170{
171 PSWP pswp;
172
173 switch (msg)
174 {
175 case WM_ACTIVATE:
176 return wm_activate (hwnd, msg, mp1, mp2);
177
178 case WM_BUTTON1DOWN:
179 case WM_BUTTON2DOWN:
180 case WM_BUTTON3DOWN:
181 case WM_BUTTON1CLICK:
182 case WM_BUTTON2CLICK:
183 case WM_BUTTON3CLICK:
184 case WM_BUTTON1DBLCLK:
185 case WM_BUTTON2DBLCLK:
186 case WM_BUTTON3DBLCLK:
187 return wm_button (hwnd, msg, mp1, mp2);
188
189 case WM_CHAR:
190 return wm_char (hwnd, msg, mp1, mp2);
191
192 case WM_CLOSE:
193 return wm_close (hwnd, msg, mp1, mp2);
194
195 case WM_COMMAND:
196 return wm_command (hwnd, msg, mp1, mp2);
197
198 case WM_CREATE:
199 hwndClient = hwnd;
200 hwndFrame = WinQueryWindow (hwnd, QW_PARENT);
201 hwndMenu = WinWindowFromID (hwndFrame, FID_MENU);
202
203 WinSetWindowPtr (hwndClient, QWL_USER, this);
204 WinSetWindowPtr (hwndFrame, QWL_USER, this);
205 return wm_create (hwnd, msg, mp1, mp2);
206
207 case WM_DESTROY:
208 if (hwndHelp != NULLHANDLE)
209 {
210 WinAssociateHelpInstance (NULLHANDLE, hwndFrame);
211 WinDestroyHelpInstance (hwndHelp);
212 }
213 return 0;
214
215 case WM_HSCROLL:
216 return wm_hscroll (hwnd, msg, mp1, mp2);
217
218 case WM_MINMAXFRAME:
219 pswp = (PSWP)mp1;
220 if (pswp->fl & SWP_MINIMIZE)
221 minimized = true;
222 else if (pswp->fl & (SWP_RESTORE | SWP_MAXIMIZE))
223 minimized = false;
224 return FALSE;
225
226 case WM_PAINT:
227 return wm_paint (hwnd, msg, mp1, mp2);
228
229 case WM_PRESPARAMCHANGED:
230 return wm_presparamchanged (hwnd, msg, mp1, mp2);
231
232 case WM_SETFOCUS:
233 return wm_setfocus (hwnd, msg, mp1, mp2);
234
235 case WM_SIZE:
236 return wm_size (hwnd, msg, mp1, mp2);
237
238 case WM_TIMER:
239 return wm_timer (hwnd, msg, mp1, mp2);
240
241 case WM_VSCROLL:
242 return wm_vscroll (hwnd, msg, mp1, mp2);
243
244 case HM_QUERY_KEYS_HELP:
245 return (MRESULT)keys_help_id;
246
247 default:
248 if (msg >= WM_USER)
249 {
250 wm_user (hwnd, msg, mp1, mp2);
251 return FALSE;
252 }
253 else
254 return WinDefWindowProc (hwnd, msg, mp1, mp2);
255 }
256}
257
258
259MRESULT pmframe::wm_querytrackinfo (HWND hwnd, ULONG msg, MPARAM mp1,
260 MPARAM mp2)
261{
262 return old_frame_msg (hwnd, msg, mp1, mp2);
263}
264
265
266
267
268MRESULT pmframe::frame_msg (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
269{
270 switch (msg)
271 {
272 case WM_QUERYTRACKINFO:
273 return wm_querytrackinfo (hwnd, msg, mp1, mp2);
274 }
275 return old_frame_msg (hwnd, msg, mp1, mp2);
276}
277
278
279MRESULT EXPENTRY
280pmframe_client_msg (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
281{
282 if (msg == WM_CREATE)
283 return pmframe_init_kludge->client_msg (hwnd, msg, mp1, mp2);
284 else
285 {
286 pmframe *p = (pmframe *)WinQueryWindowPtr (hwnd, QWL_USER);
287 return p->client_msg (hwnd, msg, mp1, mp2);
288 }
289}
290
291
292MRESULT EXPENTRY
293pmframe_frame_msg (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
294{
295 pmframe *p = (pmframe *)WinQueryWindowPtr (hwnd, QWL_USER);
296 return p->frame_msg (hwnd, msg, mp1, mp2);
297}
298
299
300void pmframe::focus () const
301{
302 WinSetActiveWindow (HWND_DESKTOP, hwndFrame);
303}
304
305
306void pmframe::top () const
307{
308 WinSetWindowPos (hwndFrame, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
309}
310
311
312void pmframe::show (bool visible) const
313{
314 if (visible)
315 WinSetWindowPos (hwndFrame, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE);
316 else
317 WinShowWindow (hwndFrame, FALSE);
318}
319
320
321void pmframe::menu_check (unsigned idm, bool on) const
322{
323 if (!WinSendMsg (hwndMenu, MM_SETITEMATTR,
324 MPFROM2SHORT (idm, TRUE),
325 MPFROM2SHORT (MIA_CHECKED, (on ? MIA_CHECKED : 0))))
326 WinAlarm (HWND_DESKTOP, WA_ERROR);
327}
328
329
330void pmframe::menu_enable (unsigned idm, bool on, bool silent) const
331{
332 if (!WinSendMsg (hwndMenu, MM_SETITEMATTR,
333 MPFROM2SHORT (idm, TRUE),
334 MPFROM2SHORT (MIA_DISABLED, (on ? 0 : MIA_DISABLED)))
335 && !silent)
336 WinAlarm (HWND_DESKTOP, WA_ERROR);
337}
338
339
340HWND pmframe::get_hwndMenu_from_id (unsigned idm) const
341{
342 MENUITEM mi;
343 MRESULT mr = WinSendMsg (hwndMenu, MM_QUERYITEM,
344 MPFROM2SHORT (idm, FALSE), (MPARAM)&mi);
345 return SHORT1FROMMR (mr) ? mi.hwndSubMenu : NULLHANDLE;
346}
347
348
349bool pmframe::is_visible () const
350{
351 return !minimized && WinIsWindowVisible (hwndClient);
352}
353
354
355bool pmframe::help_init (unsigned help_table_id, const char *title,
356 const char *file, unsigned in_keys_help_id)
357{
358 HELPINIT helpinit;
359 memset (&helpinit, 0, sizeof (helpinit));
360 helpinit.cb = sizeof (helpinit);
361 helpinit.pszTutorialName = NULL;
362 helpinit.phtHelpTable = (PHELPTABLE)MAKELONG (help_table_id, 0xFFFF);
363 helpinit.hmodHelpTableModule = 0;
364 helpinit.hmodAccelActionBarModule = 0;
365 helpinit.idActionBar = 0;
366 helpinit.pszHelpWindowTitle = (PSZ)title;
367 helpinit.fShowPanelId = CMIC_HIDE_PANEL_ID;
368 helpinit.pszHelpLibraryName = (PSZ)file;
369 hwndHelp = WinCreateHelpInstance (get_hab (), &helpinit);
370 if (hwndHelp != NULLHANDLE)
371 if (!WinAssociateHelpInstance (hwndHelp, hwndFrame))
372 hwndHelp = NULLHANDLE;
373 keys_help_id = in_keys_help_id;
374 return hwndHelp != NULLHANDLE;
375}
Note: See TracBrowser for help on using the repository browser.