1 | //
|
---|
2 | // TxWin, Textmode Windowing Library
|
---|
3 | //
|
---|
4 | // Original code Copyright (c) 1995-2005 Fsys Software and Jan van Wijk
|
---|
5 | //
|
---|
6 | // ==========================================================================
|
---|
7 | //
|
---|
8 | // This file contains Original Code and/or Modifications of Original Code as
|
---|
9 | // defined in and that are subject to the GNU Lesser General Public License.
|
---|
10 | // You may not use this file except in compliance with the License.
|
---|
11 | // BY USING THIS FILE YOU AGREE TO ALL TERMS AND CONDITIONS OF THE LICENSE.
|
---|
12 | // A copy of the License is provided with the Original Code and Modifications,
|
---|
13 | // and is also available at http://www.dfsee.com/txwin/lgpl.htm
|
---|
14 | //
|
---|
15 | // This library is free software; you can redistribute it and/or modify
|
---|
16 | // it under the terms of the GNU Lesser General Public License as published
|
---|
17 | // by the Free Software Foundation; either version 2.1 of the License,
|
---|
18 | // or (at your option) any later version.
|
---|
19 | //
|
---|
20 | // This library is distributed in the hope that it will be useful,
|
---|
21 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
22 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
23 | // See the GNU Lesser General Public License for more details.
|
---|
24 | //
|
---|
25 | // You should have received a copy of the GNU Lesser General Public License
|
---|
26 | // along with this library; (lgpl.htm) if not, write to the Free Software
|
---|
27 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
28 | //
|
---|
29 | // Questions on TxWin licensing can be directed to: txwin@fsys.nl
|
---|
30 | //
|
---|
31 | // ==========================================================================
|
---|
32 | //
|
---|
33 | // TX Windowed text, default window procedures
|
---|
34 | //
|
---|
35 | // Author: J. van Wijk
|
---|
36 | //
|
---|
37 | // JvW 05-09-2001 Added DefDlgProc and other Dlg functions
|
---|
38 | // JvW 15-07-1998 Initial version, split off from txwind
|
---|
39 |
|
---|
40 | #include <txlib.h> // public interface
|
---|
41 | #include <txwpriv.h> // private window interface
|
---|
42 |
|
---|
43 | // Generic window procedure, for any window-class including dialogs
|
---|
44 | static ULONG txwGenericWinProc // RET result
|
---|
45 | (
|
---|
46 | TXWHANDLE hwnd, // IN current window
|
---|
47 | ULONG msg, // IN message id
|
---|
48 | ULONG mp1, // IN msg param 1
|
---|
49 | ULONG mp2 // IN msg param 2
|
---|
50 | );
|
---|
51 |
|
---|
52 | static char txwam_move[] = "Use arrow keys to MOVE window; insert=SIZE, ENTER=end";
|
---|
53 | static char txwam_size[] = "Use arrow keys to SIZE window; insert=MOVE, ENTER=end";
|
---|
54 | static char txwam_color[] = "Use arrow keys to change; ENTER=end";
|
---|
55 | static TXTM txwam_custom;
|
---|
56 |
|
---|
57 | /*****************************************************************************/
|
---|
58 | // Default window procedure, for any window-class except dialogs
|
---|
59 | /*****************************************************************************/
|
---|
60 | ULONG txwDefWindowProc // RET result
|
---|
61 | (
|
---|
62 | TXWHANDLE hwnd, // IN current window
|
---|
63 | ULONG msg, // IN message id
|
---|
64 | ULONG mp1, // IN msg param 1
|
---|
65 | ULONG mp2 // IN msg param 2
|
---|
66 | )
|
---|
67 | {
|
---|
68 | ULONG rc = NO_ERROR;
|
---|
69 | TXWINBASE *wnd;
|
---|
70 | TXWINDOW *win;
|
---|
71 |
|
---|
72 | ENTER();
|
---|
73 | TRCMSG( hwnd, msg, mp1, mp2);
|
---|
74 | if ((wnd = txwValidateHandle( hwnd, &win)) != NULL)
|
---|
75 | {
|
---|
76 | TRCLAS( "DefWindowProc", hwnd);
|
---|
77 | switch (msg)
|
---|
78 | {
|
---|
79 | case TXWM_CLOSE:
|
---|
80 | if (wnd == txwa->desktop) // quit application
|
---|
81 | {
|
---|
82 | rc = txwPostMsg( hwnd, TXWM_QUIT, 0, 0);
|
---|
83 | }
|
---|
84 | else // delegate to owner
|
---|
85 | {
|
---|
86 | txwPostMsg((wnd->owner) ? (TXWHANDLE) wnd->owner
|
---|
87 | : TXHWND_DESKTOP, msg, mp1, mp2);
|
---|
88 | }
|
---|
89 | break;
|
---|
90 |
|
---|
91 | default:
|
---|
92 | rc = txwGenericWinProc( hwnd, msg, mp1, mp2);
|
---|
93 | break;
|
---|
94 | }
|
---|
95 | }
|
---|
96 | else
|
---|
97 | {
|
---|
98 | rc = TX_INVALID_HANDLE;
|
---|
99 | }
|
---|
100 | RETURN( rc);
|
---|
101 | } // end 'txwDefWindowProc'
|
---|
102 | /*---------------------------------------------------------------------------*/
|
---|
103 |
|
---|
104 |
|
---|
105 | /*****************************************************************************/
|
---|
106 | // Default window procedure, for dialogs including their control windows
|
---|
107 | /*****************************************************************************/
|
---|
108 | ULONG txwDefDlgProc // RET result
|
---|
109 | (
|
---|
110 | TXWHANDLE hwnd, // IN current window
|
---|
111 | ULONG msg, // IN message id
|
---|
112 | ULONG mp1, // IN msg param 1
|
---|
113 | ULONG mp2 // IN msg param 2
|
---|
114 | )
|
---|
115 | {
|
---|
116 | ULONG rc = NO_ERROR;
|
---|
117 | TXWINBASE *wnd;
|
---|
118 | TXWINDOW *win;
|
---|
119 |
|
---|
120 | ENTER();
|
---|
121 | TRCMSG( hwnd, msg, mp1, mp2);
|
---|
122 | if ((wnd = txwValidateHandle( hwnd, &win)) != NULL)
|
---|
123 | {
|
---|
124 | USHORT focusid = txwQueryWindowUShort( (TXWHANDLE) txwa->focus, TXQWS_ID);
|
---|
125 |
|
---|
126 | TRCLAS( "DefDlgProc", hwnd);
|
---|
127 | switch (msg)
|
---|
128 | {
|
---|
129 | case TXWM_CHAR:
|
---|
130 | switch (mp2) // key-value
|
---|
131 | {
|
---|
132 | case TXk_ESCAPE:
|
---|
133 | txwPostMsg( hwnd, TXWM_CLOSE, 0, 0);
|
---|
134 | break;
|
---|
135 |
|
---|
136 | case TXk_F4: //- unless captured higher up
|
---|
137 | txwDismissDlg( hwnd, TXDID_OK); //- handle as OK button
|
---|
138 | break;
|
---|
139 |
|
---|
140 | case TXk_ENTER:
|
---|
141 | if (txwIsMinimized( hwnd, TRUE) || // unless a parent or
|
---|
142 | txwIsMinimized( hwnd, FALSE) ) // this is minimized
|
---|
143 | {
|
---|
144 | rc = txwGenericWinProc( hwnd, msg, mp1, mp2); // restore
|
---|
145 | }
|
---|
146 | else // End the dialog, returning
|
---|
147 | { // the proper dialog-RC
|
---|
148 | switch (focusid)
|
---|
149 | {
|
---|
150 | case TXDID_CANCEL:
|
---|
151 | txwPostMsg( hwnd, TXWM_CLOSE, 0, 0);
|
---|
152 | break;
|
---|
153 |
|
---|
154 | default:
|
---|
155 | txwDismissDlg( hwnd, focusid);
|
---|
156 | break;
|
---|
157 | }
|
---|
158 | }
|
---|
159 | break;
|
---|
160 |
|
---|
161 | case TXc_UP: // special keys bounced by
|
---|
162 | case TXc_DOWN: // control to their owner
|
---|
163 | case TXc_LEFT:
|
---|
164 | case TXc_RIGHT:
|
---|
165 | case TXc_PGUP:
|
---|
166 | case TXc_PGDN:
|
---|
167 | case TXc_HOME:
|
---|
168 | case TXc_END:
|
---|
169 | case TXa_UP:
|
---|
170 | case TXa_DOWN:
|
---|
171 | case TXa_LEFT:
|
---|
172 | case TXa_RIGHT:
|
---|
173 | case TXa_PGUP:
|
---|
174 | case TXa_PGDN: // relay to scroll-buffer
|
---|
175 | case TXa_HOME:
|
---|
176 | case TXa_END:
|
---|
177 | case TXk_HOME:
|
---|
178 | case TXk_END:
|
---|
179 | txwPostMsg((TXWHANDLE) txwa->sbview, TXWM_CHAR, mp1, mp2);
|
---|
180 | break;
|
---|
181 |
|
---|
182 | default:
|
---|
183 | rc = txwGenericWinProc( hwnd, msg, mp1, mp2);
|
---|
184 | break;
|
---|
185 | }
|
---|
186 | break;
|
---|
187 |
|
---|
188 | case TXWM_CLOSE:
|
---|
189 | txwDismissDlg( hwnd, TXDID_CANCEL);
|
---|
190 | break;
|
---|
191 |
|
---|
192 | case TXWM_COMMAND:
|
---|
193 | switch (mp2) // command source
|
---|
194 | {
|
---|
195 | case TXCMDSRC_PUSHBUTTON: // if not captured by higher
|
---|
196 | txwDismissDlg( hwnd, mp1); // level, dismiss dialog on
|
---|
197 | break; // every pushbutton!
|
---|
198 |
|
---|
199 | default: // otherwise ignore the message
|
---|
200 | break;
|
---|
201 | }
|
---|
202 | break;
|
---|
203 |
|
---|
204 | case TXWM_INITDLG:
|
---|
205 | if (mp1 != 0)
|
---|
206 | {
|
---|
207 | txwSetFocus( (TXWHANDLE) mp1);
|
---|
208 | txwPostMsg( hwnd, TXWM_ACTIVATE, TRUE, 0);
|
---|
209 | }
|
---|
210 | break;
|
---|
211 |
|
---|
212 | default:
|
---|
213 | rc = txwGenericWinProc( hwnd, msg, mp1, mp2);
|
---|
214 | break;
|
---|
215 | }
|
---|
216 | }
|
---|
217 | else
|
---|
218 | {
|
---|
219 | rc = TX_INVALID_HANDLE;
|
---|
220 | }
|
---|
221 | RETURN( rc);
|
---|
222 | } // end 'txwDefDlgProc'
|
---|
223 | /*---------------------------------------------------------------------------*/
|
---|
224 |
|
---|
225 |
|
---|
226 | /*****************************************************************************/
|
---|
227 | // Default window procedure, for any window-class including dialogs
|
---|
228 | /*****************************************************************************/
|
---|
229 | static ULONG txwGenericWinProc // RET result
|
---|
230 | (
|
---|
231 | TXWHANDLE hwnd, // IN current window
|
---|
232 | ULONG msg, // IN message id
|
---|
233 | ULONG mp1, // IN msg param 1
|
---|
234 | ULONG mp2 // IN msg param 2
|
---|
235 | )
|
---|
236 | {
|
---|
237 | ULONG rc = NO_ERROR;
|
---|
238 | TXWINBASE *wnd = (TXWINBASE *) hwnd;
|
---|
239 | TXWINDOW *win = wnd->window;
|
---|
240 | TXWHANDLE parent = (TXWHANDLE) wnd->parent;
|
---|
241 | TXWHANDLE owner = (TXWHANDLE) wnd->owner;
|
---|
242 | USHORT flags = txwQueryWindowUShort( hwnd, TXQWS_FLAGS);
|
---|
243 | USHORT wid = txwQueryWindowUShort( hwnd, TXQWS_ID);
|
---|
244 | TXWHANDLE target;
|
---|
245 | TXSELIST *list;
|
---|
246 | ULONG altcol = 0;
|
---|
247 |
|
---|
248 | ENTER();
|
---|
249 | TRCMSG( (TXWHANDLE) wnd, msg, mp1, mp2);
|
---|
250 | TRCLAS( "GenericWinProc", hwnd);
|
---|
251 |
|
---|
252 | switch (msg)
|
---|
253 | {
|
---|
254 | case TXWM_ACTIVATE:
|
---|
255 | if ((BOOL) mp1) // set window active ?
|
---|
256 | {
|
---|
257 | flags |= TXFF_ACTIVE;
|
---|
258 | }
|
---|
259 | else
|
---|
260 | {
|
---|
261 | flags &= ~TXFF_ACTIVE;
|
---|
262 | }
|
---|
263 | txwSetWindowUShort( hwnd, TXQWS_FLAGS, flags);
|
---|
264 | txwInvalidateBorder( hwnd);
|
---|
265 | break;
|
---|
266 |
|
---|
267 | case TXWM_BORDER:
|
---|
268 | if (txwIsWindowShowing( hwnd))
|
---|
269 | {
|
---|
270 | txwPaintBorder( wnd, (wnd == txwa->focus));
|
---|
271 | }
|
---|
272 | break;
|
---|
273 |
|
---|
274 | case TXWM_CHAR:
|
---|
275 | if (txwa->arrowMode != TXW_ARROW_STD) // special arrow handling
|
---|
276 | {
|
---|
277 | TRACES(("Handling arrow mode: %8.8lx\n", txwa->arrowMode));
|
---|
278 | if ((mp2 == TXk_UP) || (mp2 == TXk_RIGHT) ||
|
---|
279 | (mp2 == TXk_DOWN) || (mp2 == TXk_LEFT) ||
|
---|
280 | (mp2 == TXk_PGUP) || (mp2 == TXk_PGDN) ||
|
---|
281 | (mp2 == TXk_HOME) || (mp2 == TXk_END ) ||
|
---|
282 | (mp2 == TXk_INSERT))
|
---|
283 | {
|
---|
284 | switch (txwa->arrowMode)
|
---|
285 | {
|
---|
286 | case TXW_ARROW_MOVE:
|
---|
287 | case TXW_ARROW_SIZE:
|
---|
288 | if (win->style & TXWS_MOVEABLE) // move & resize allowed
|
---|
289 | {
|
---|
290 | TXRECT psize; // parent pos & size
|
---|
291 | TXRECT wsize; // window pos & size
|
---|
292 | short delta;
|
---|
293 |
|
---|
294 | txwQueryWindowPos( parent, FALSE, &psize);
|
---|
295 | txwQueryWindowPos( hwnd, FALSE, &wsize);
|
---|
296 |
|
---|
297 | if (txwa->arrowMode == TXW_ARROW_MOVE)
|
---|
298 | {
|
---|
299 | switch (mp2)
|
---|
300 | {
|
---|
301 | case TXk_UP:
|
---|
302 | txwSetWindowPos( hwnd, 0, 0, -1, 0, 0,
|
---|
303 | TXSWP_MOVE | TXSWP_RELATIVE);
|
---|
304 | break;
|
---|
305 |
|
---|
306 | case TXk_DOWN:
|
---|
307 | txwSetWindowPos( hwnd, 0, 0, +1, 0, 0,
|
---|
308 | TXSWP_MOVE | TXSWP_RELATIVE);
|
---|
309 | break;
|
---|
310 |
|
---|
311 | case TXk_LEFT:
|
---|
312 | txwSetWindowPos( hwnd, 0, -1, 0, 0, 0,
|
---|
313 | TXSWP_MOVE | TXSWP_RELATIVE);
|
---|
314 | break;
|
---|
315 |
|
---|
316 | case TXk_RIGHT:
|
---|
317 | txwSetWindowPos( hwnd, 0, +1, 0, 0, 0,
|
---|
318 | TXSWP_MOVE | TXSWP_RELATIVE);
|
---|
319 | break;
|
---|
320 |
|
---|
321 | case TXk_PGUP:
|
---|
322 | delta = psize.top - wsize.top;
|
---|
323 | txwSetWindowPos( hwnd, 0, 0, delta, 0, 0,
|
---|
324 | TXSWP_MOVE | TXSWP_RELATIVE);
|
---|
325 | break;
|
---|
326 |
|
---|
327 | case TXk_PGDN:
|
---|
328 | delta = psize.bottom - wsize.bottom;
|
---|
329 | txwSetWindowPos( hwnd, 0, 0, delta, 0, 0,
|
---|
330 | TXSWP_MOVE | TXSWP_RELATIVE);
|
---|
331 | break;
|
---|
332 |
|
---|
333 | case TXk_HOME:
|
---|
334 | delta = psize.left - wsize.left;
|
---|
335 | txwSetWindowPos( hwnd, 0, delta, 0, 0, 0,
|
---|
336 | TXSWP_MOVE | TXSWP_RELATIVE);
|
---|
337 | break;
|
---|
338 |
|
---|
339 | case TXk_END:
|
---|
340 | delta = psize.right - wsize.right;
|
---|
341 | txwSetWindowPos( hwnd, 0, delta, 0, 0, 0,
|
---|
342 | TXSWP_MOVE | TXSWP_RELATIVE);
|
---|
343 | break;
|
---|
344 |
|
---|
345 | default:
|
---|
346 | txwa->arrowMode = TXW_ARROW_SIZE;
|
---|
347 | break;
|
---|
348 | }
|
---|
349 | }
|
---|
350 | else // size window
|
---|
351 | {
|
---|
352 | switch (mp2)
|
---|
353 | {
|
---|
354 | case TXk_UP:
|
---|
355 | txwSetWindowPos( hwnd, 0, 0, 0, 0, -1,
|
---|
356 | TXSWP_SIZE | TXSWP_RELATIVE);
|
---|
357 | break;
|
---|
358 |
|
---|
359 | case TXk_DOWN:
|
---|
360 | txwSetWindowPos( hwnd, 0, 0, 0, 0, +1,
|
---|
361 | TXSWP_SIZE | TXSWP_RELATIVE);
|
---|
362 | break;
|
---|
363 |
|
---|
364 | case TXk_LEFT:
|
---|
365 | txwSetWindowPos( hwnd, 0, 0, 0, -2, 0,
|
---|
366 | TXSWP_SIZE | TXSWP_RELATIVE);
|
---|
367 | break;
|
---|
368 |
|
---|
369 | case TXk_RIGHT:
|
---|
370 | txwSetWindowPos( hwnd, 0, 0, 0, +2, 0,
|
---|
371 | TXSWP_SIZE | TXSWP_RELATIVE);
|
---|
372 | break;
|
---|
373 |
|
---|
374 | case TXk_PGUP:
|
---|
375 | delta = wsize.top - wsize.bottom;
|
---|
376 | txwSetWindowPos( hwnd, 0, 0, 0, 0, delta,
|
---|
377 | TXSWP_SIZE | TXSWP_RELATIVE);
|
---|
378 | break;
|
---|
379 |
|
---|
380 | case TXk_PGDN:
|
---|
381 | delta = psize.bottom - wsize.bottom;
|
---|
382 | txwSetWindowPos( hwnd, 0, 0, 0, 0, delta,
|
---|
383 | TXSWP_SIZE | TXSWP_RELATIVE);
|
---|
384 | break;
|
---|
385 |
|
---|
386 | case TXk_HOME:
|
---|
387 | delta = wsize.left - wsize.right + 7;
|
---|
388 | txwSetWindowPos( hwnd, 0, 0, 0, delta, 0,
|
---|
389 | TXSWP_SIZE | TXSWP_RELATIVE);
|
---|
390 | break;
|
---|
391 |
|
---|
392 | case TXk_END:
|
---|
393 | delta = psize.right - wsize.right;
|
---|
394 | txwSetWindowPos( hwnd, 0, 0, 0, delta, 0,
|
---|
395 | TXSWP_SIZE | TXSWP_RELATIVE);
|
---|
396 | break;
|
---|
397 |
|
---|
398 | default:
|
---|
399 | txwa->arrowMode = TXW_ARROW_MOVE;
|
---|
400 | break;
|
---|
401 | }
|
---|
402 | }
|
---|
403 | if (txwa->arrowMode == TXW_ARROW_MOVE)
|
---|
404 | {
|
---|
405 | txwPostMsg( TXHWND_DESKTOP, TXWM_SETFOOTER, (ULONG) txwam_move, 0);
|
---|
406 | }
|
---|
407 | else
|
---|
408 | {
|
---|
409 | txwPostMsg( TXHWND_DESKTOP, TXWM_SETFOOTER, (ULONG) txwam_size, 0);
|
---|
410 | }
|
---|
411 | }
|
---|
412 | else
|
---|
413 | {
|
---|
414 | txwPostMsg( parent, msg, mp1, mp2);
|
---|
415 | }
|
---|
416 | break;
|
---|
417 |
|
---|
418 | case TXW_ARROW_COLOR:
|
---|
419 | switch (mp2)
|
---|
420 | {
|
---|
421 | case TXk_LEFT: // cycle through Scrollbuffer
|
---|
422 | case TXk_RIGHT: // color alternatives (8)
|
---|
423 | if (txwa->sbview)
|
---|
424 | {
|
---|
425 | TXWINDOW *sbwin = txwa->sbview->window;
|
---|
426 | if (mp2 == TXk_LEFT)
|
---|
427 | {
|
---|
428 | sbwin->sb.altcol--;
|
---|
429 | }
|
---|
430 | else
|
---|
431 | {
|
---|
432 | sbwin->sb.altcol++;
|
---|
433 | }
|
---|
434 | sbwin->sb.altcol &= TXSB_COLOR_MASK;
|
---|
435 | txwInvalidateWindow((TXWHANDLE) txwa->sbview, FALSE, FALSE);
|
---|
436 | }
|
---|
437 | break;
|
---|
438 |
|
---|
439 | default:
|
---|
440 | switch (mp2)
|
---|
441 | {
|
---|
442 | case TXk_UP:
|
---|
443 | txwColorScheme( TXWCS_PREV_SCHEME, NULL);
|
---|
444 | break;
|
---|
445 |
|
---|
446 | case TXk_DOWN:
|
---|
447 | txwColorScheme( TXWCS_NEXT_SCHEME, NULL);
|
---|
448 | break;
|
---|
449 |
|
---|
450 | case TXk_HOME:
|
---|
451 | txwColorScheme( TXWCS_FIRST_SCHEME, NULL);
|
---|
452 | break;
|
---|
453 |
|
---|
454 | case TXk_END:
|
---|
455 | txwColorScheme( TXWCS_LAST_SCHEME, NULL);
|
---|
456 | break;
|
---|
457 |
|
---|
458 | case TXk_PGUP:
|
---|
459 | if ((txwcs->linestyle--) == 0)
|
---|
460 | {
|
---|
461 | txwcs->linestyle = TXW_CS_LAST;
|
---|
462 | }
|
---|
463 | break;
|
---|
464 |
|
---|
465 | case TXk_PGDN:
|
---|
466 | if ((txwcs->linestyle++) == TXW_CS_LAST)
|
---|
467 | {
|
---|
468 | txwcs->linestyle = 0;
|
---|
469 | }
|
---|
470 | break;
|
---|
471 | }
|
---|
472 | txwInvalidateAll(); // redraw all windows
|
---|
473 | break;
|
---|
474 | }
|
---|
475 | if (txwa->sbview)
|
---|
476 | {
|
---|
477 | TXWINDOW *sbwin = txwa->sbview->window;
|
---|
478 | altcol = sbwin->sb.altcol;
|
---|
479 | }
|
---|
480 | sprintf( txwam_custom, "Colors: %19.19s %lu/%lu - %s",
|
---|
481 | txwcs->name, altcol, txwcs->linestyle, txwam_color);
|
---|
482 | txwPostMsg( TXHWND_DESKTOP, TXWM_SETFOOTER, (ULONG) txwam_custom, 0);
|
---|
483 | break;
|
---|
484 |
|
---|
485 | default:
|
---|
486 | break;
|
---|
487 | }
|
---|
488 | }
|
---|
489 | else // end arrow mode
|
---|
490 | {
|
---|
491 | txwa->arrowMode = TXW_ARROW_STD;
|
---|
492 | txwPostMsg( TXHWND_DESKTOP, TXWM_SETFOOTER, 0, 0);
|
---|
493 | if (mp2 != TXk_ENTER)
|
---|
494 | {
|
---|
495 | txwPostMsg(hwnd, msg, mp1, mp2); // exec end-key if not ENTER
|
---|
496 | }
|
---|
497 | }
|
---|
498 | }
|
---|
499 | else
|
---|
500 | {
|
---|
501 | switch (mp2) // key-value
|
---|
502 | {
|
---|
503 | case TXk_F3: // Close Owner (Dlg) or self
|
---|
504 | switch (win->class)
|
---|
505 | {
|
---|
506 | case TXW_SBVIEW: // should go to cmdline ...
|
---|
507 | txwPostMsg( hwnd, msg, mp1, TXk_TAB);
|
---|
508 | break;
|
---|
509 |
|
---|
510 | default:
|
---|
511 | txwPostMsg((owner != 0) ? owner : hwnd, TXWM_CLOSE, 0, 0);
|
---|
512 | break;
|
---|
513 | }
|
---|
514 | break;
|
---|
515 |
|
---|
516 | case TXa_F3: // application exit
|
---|
517 | case TXa_BACKQUOTE: // emergency exit
|
---|
518 | txwPostMsg( hwnd, TXWM_QUIT, 0, 0);
|
---|
519 | break;
|
---|
520 |
|
---|
521 | case TXs_F1: // HELP alternative, Linux GNOME
|
---|
522 | txwPostMsg( hwnd, TXWM_HELP, 0, 0);
|
---|
523 | break;
|
---|
524 |
|
---|
525 | case TXa_C:
|
---|
526 | //- to be refined, move code to a WM_COMMAND so it can be
|
---|
527 | // called from the menu too (using an accelerator ?)
|
---|
528 | txwa->arrowMode = TXW_ARROW_COLOR;
|
---|
529 | if (txwa->sbview)
|
---|
530 | {
|
---|
531 | TXWINDOW *sbwin = txwa->sbview->window;
|
---|
532 | altcol = sbwin->sb.altcol;
|
---|
533 | }
|
---|
534 | sprintf( txwam_custom, "Colors: %19.19s %lu/%lu - %s",
|
---|
535 | txwcs->name, altcol, txwcs->linestyle, txwam_color);
|
---|
536 | txwPostMsg( TXHWND_DESKTOP, TXWM_SETFOOTER, (ULONG) txwam_custom, 0);
|
---|
537 | break;
|
---|
538 |
|
---|
539 | case TXa_M:
|
---|
540 | txwa->arrowMode = TXW_ARROW_MOVE;
|
---|
541 | txwPostMsg( TXHWND_DESKTOP, TXWM_SETFOOTER, (ULONG) txwam_move, 0);
|
---|
542 | break;
|
---|
543 |
|
---|
544 | case TXk_INSERT:
|
---|
545 | txwa->insert = (txwa->insert) ? FALSE : TRUE;
|
---|
546 | txwSetCursorStyle( hwnd, txwa->insert);
|
---|
547 | break;
|
---|
548 |
|
---|
549 | case TXc_L: // Linux refresh screen
|
---|
550 | case TXc_R: // Standard Txlib repaint
|
---|
551 | TXSCREEN_FLUSH_CACHED(); // flush screen caches
|
---|
552 | txwInvalidateAll(); // logical redraw all windows
|
---|
553 | TXSCREEN_ENDOF_UPDATE(); // one extra, just to be sure
|
---|
554 | break;
|
---|
555 |
|
---|
556 | case TXa_SLASH: // toggle trace value
|
---|
557 | switch (TxTrLevel) // and slowdown delay
|
---|
558 | {
|
---|
559 | case 0:
|
---|
560 | TxTrLevel = 1;
|
---|
561 | break;
|
---|
562 |
|
---|
563 | case 1:
|
---|
564 | TxTrLevel = 100;
|
---|
565 | if (TxQueryLogFile( NULL, NULL) != NULL)
|
---|
566 | {
|
---|
567 | TXLN line;
|
---|
568 |
|
---|
569 | sprintf( line, "Tracing to: %s ", TxQueryLogName());
|
---|
570 | txwSetDesktopTopLine( line, cSchemeColor);
|
---|
571 | }
|
---|
572 | else if (TxTrLogOnly == FALSE)
|
---|
573 | {
|
---|
574 | txwSetDesktopTopLine( "Tracing to SCREEN ... ",
|
---|
575 | cSchemeColor);
|
---|
576 | }
|
---|
577 | else
|
---|
578 | {
|
---|
579 | txwSetDesktopTopLine( "Tracing to nowhere ... ",
|
---|
580 | cSchemeColor);
|
---|
581 | }
|
---|
582 | break;
|
---|
583 |
|
---|
584 | default:
|
---|
585 | TxTrLevel = 0;
|
---|
586 | TxTrSlowDown = 0;
|
---|
587 | txwSetDesktopTopLine( "Tracing stopped, no delay ... ",
|
---|
588 | cSchemeColor);
|
---|
589 | break;
|
---|
590 | }
|
---|
591 | break;
|
---|
592 |
|
---|
593 | case TXk_F12: // Minimize win to title only
|
---|
594 | case TXa_F9: // (or undo that)
|
---|
595 | if (win->style & TXWS_MOVEABLE) // move & resize allowed
|
---|
596 | {
|
---|
597 | if (flags & TXFF_MINIMIZED)
|
---|
598 | {
|
---|
599 | TRACES(("Set MINIMIZED OFF for window:%8.8lx\n", hwnd))
|
---|
600 | flags &= ~TXFF_MINIMIZED;
|
---|
601 | txwSetWindowUShort( hwnd, TXQWS_FLAGS, flags);
|
---|
602 | txwSetWindowPos( hwnd, 0,
|
---|
603 | wnd->restore.left, wnd->restore.top,
|
---|
604 | wnd->restore.right - wnd->restore.left +1,
|
---|
605 | wnd->restore.bottom - wnd->restore.top +1,
|
---|
606 | TXSWP_SIZE | TXSWP_MOVE | TXSWP_ABSOLUTE);
|
---|
607 | }
|
---|
608 | else // set to vertical size 0 or 1
|
---|
609 | {
|
---|
610 | TRACES(("Set MINIMIZED ON for window:%8.8lx\n", hwnd))
|
---|
611 | flags |= TXFF_MINIMIZED;
|
---|
612 | txwSetWindowUShort( hwnd, TXQWS_FLAGS, flags);
|
---|
613 |
|
---|
614 | wnd->restore = win->border; // new restore size/pos
|
---|
615 |
|
---|
616 | txwSetWindowPos( hwnd, 0, 0, 0,
|
---|
617 | win->border.right - win->border.left +1,
|
---|
618 | (win->style & TXWS_TITLEBORDER) ? 1 : 0,
|
---|
619 | TXSWP_SIZE | TXSWP_ABSOLUTE);
|
---|
620 | }
|
---|
621 | txwInvalidateAll();
|
---|
622 | }
|
---|
623 | else
|
---|
624 | {
|
---|
625 | TRACES(("window NOT movable, delegate MINIMIZE to parent ...\n"));
|
---|
626 | txwPostMsg( parent, msg, mp1, mp2);
|
---|
627 | }
|
---|
628 | break;
|
---|
629 |
|
---|
630 | case TXa_F10: // Maximize to parent
|
---|
631 | case TXa_F5: // restore size/position
|
---|
632 | if (win->style & TXWS_MOVEABLE) // move & resize allowed
|
---|
633 | {
|
---|
634 | TXRECT b = win->border; // current border
|
---|
635 | TXRECT rect = wnd->restore; // previous pos/size
|
---|
636 | BOOL update_restore = TRUE;
|
---|
637 |
|
---|
638 | TRECTA( "restore", (&rect));
|
---|
639 | TRECTA( "border ", (&b));
|
---|
640 |
|
---|
641 | if (flags & TXFF_MINIMIZED)
|
---|
642 | {
|
---|
643 | TRACES(("Set MINIMIZED OFF for window:%8.8lx\n", hwnd))
|
---|
644 | flags &= ~TXFF_MINIMIZED;
|
---|
645 | txwSetWindowUShort( hwnd, TXQWS_FLAGS, flags);
|
---|
646 | update_restore = FALSE; // never restore to MINIMIZED
|
---|
647 | }
|
---|
648 | if (mp2 == TXa_F10) // maximize to parent size
|
---|
649 | {
|
---|
650 | txwQueryWindowRect((TXWHANDLE) wnd->parent, FALSE, &rect);
|
---|
651 |
|
---|
652 | TRECTA( "parent ", (&rect));
|
---|
653 |
|
---|
654 | if (wnd != txwa->desktop)
|
---|
655 | {
|
---|
656 | if ((rect.bottom != (b.bottom - b.top +1)) ||
|
---|
657 | (rect.right != (b.right - b.left +1)) )
|
---|
658 | {
|
---|
659 | TRACES(("MAXIMIZE to parent for window:%8.8lx\n", hwnd))
|
---|
660 | if (update_restore)
|
---|
661 | {
|
---|
662 | wnd->restore = b; // new restore size/pos
|
---|
663 | }
|
---|
664 | txwSetWindowPos( hwnd, 0, 0, 0, rect.right, rect.bottom,
|
---|
665 | TXSWP_SIZE | TXSWP_MOVE);
|
---|
666 | }
|
---|
667 | }
|
---|
668 | }
|
---|
669 | else // restore to previous pos/size
|
---|
670 | {
|
---|
671 | if (update_restore)
|
---|
672 | {
|
---|
673 | wnd->restore = b; // to toggle back and forth ...
|
---|
674 | }
|
---|
675 | txwSetWindowPos( hwnd, 0,
|
---|
676 | rect.left, rect.top,
|
---|
677 | rect.right - rect.left +1,
|
---|
678 | rect.bottom - rect.top +1,
|
---|
679 | TXSWP_SIZE | TXSWP_MOVE | TXSWP_ABSOLUTE);
|
---|
680 | }
|
---|
681 | }
|
---|
682 | else
|
---|
683 | {
|
---|
684 | TRACES(("window NOT movable, delegate to parent ...\n"));
|
---|
685 | txwPostMsg( parent, msg, mp1, mp2);
|
---|
686 | }
|
---|
687 | break;
|
---|
688 |
|
---|
689 | case TXa_F12: // cycle through all SB styles
|
---|
690 | if (txwa->sbview)
|
---|
691 | {
|
---|
692 | TXWINDOW *sbwin = txwa->sbview->window;
|
---|
693 |
|
---|
694 | if ((sbwin->sb.altcol++) == TXSB_COLOR_MAXVAL)
|
---|
695 | {
|
---|
696 | sbwin->sb.altcol = TXSB_COLOR_NORMAL;
|
---|
697 | }
|
---|
698 | txwInvalidateWindow((TXWHANDLE) txwa->sbview, FALSE, FALSE);
|
---|
699 | }
|
---|
700 | break;
|
---|
701 |
|
---|
702 | default:
|
---|
703 | if (flags & TXFF_MINIMIZED) // un-collapse on other keys
|
---|
704 | { // (does NOT work on child!)
|
---|
705 | TRACES(("Set MINIMIZED OFF for window:%8.8lx\n", hwnd))
|
---|
706 | flags &= ~TXFF_MINIMIZED;
|
---|
707 | txwSetWindowUShort( hwnd, TXQWS_FLAGS, flags);
|
---|
708 | txwSetWindowPos( hwnd, 0,
|
---|
709 | wnd->restore.left, wnd->restore.top,
|
---|
710 | wnd->restore.right - wnd->restore.left +1,
|
---|
711 | wnd->restore.bottom - wnd->restore.top +1,
|
---|
712 | TXSWP_SIZE | TXSWP_MOVE | TXSWP_ABSOLUTE);
|
---|
713 | txwInvalidateAll();
|
---|
714 | }
|
---|
715 | else
|
---|
716 | {
|
---|
717 | if (txwIsMinimized( hwnd, TRUE)) // any parent minimized ?
|
---|
718 | {
|
---|
719 | txwPostMsg( parent, msg, mp1, mp2);
|
---|
720 | }
|
---|
721 | else // non move/size/exit keys
|
---|
722 | {
|
---|
723 | switch (mp2)
|
---|
724 | {
|
---|
725 | case TXk_TAB: // move to other window
|
---|
726 | case TXs_TAB:
|
---|
727 | target = (mp2 == TXs_TAB)
|
---|
728 | ? txwFindPrevFocus( hwnd, TRUE)
|
---|
729 | : txwFindNextFocus( hwnd, TRUE);
|
---|
730 | if (target != hwnd)
|
---|
731 | {
|
---|
732 | txwSetFocus( target);
|
---|
733 | break;
|
---|
734 | }
|
---|
735 | else if (win->style & TXWS_TAB_2_OWNER)
|
---|
736 | {
|
---|
737 | txwPostMsg( owner, msg, mp1, mp2);
|
---|
738 | break;
|
---|
739 | } // when no TAB action, allow
|
---|
740 | default: // class specific usage
|
---|
741 | switch (win->class)
|
---|
742 | {
|
---|
743 | case TXW_TEXTVIEW:
|
---|
744 | rc = txwIkeyTextview( hwnd, mp1, mp2);
|
---|
745 | break;
|
---|
746 |
|
---|
747 | case TXW_SBVIEW:
|
---|
748 | rc = txwIkeySbView( hwnd, mp1, mp2);
|
---|
749 | break;
|
---|
750 |
|
---|
751 | case TXW_ENTRYFIELD:
|
---|
752 | rc = txwIkeyEntryfield( hwnd, mp1, mp2);
|
---|
753 | break;
|
---|
754 |
|
---|
755 | case TXW_BUTTON:
|
---|
756 | rc = txwIkeyButton( hwnd, mp1, mp2);
|
---|
757 | break;
|
---|
758 |
|
---|
759 | case TXW_LISTBOX:
|
---|
760 | rc = txwIkeyListBox( hwnd, mp1, mp2);
|
---|
761 | break;
|
---|
762 |
|
---|
763 | case TXW_HEXEDIT:
|
---|
764 | rc = txwHexEditWinProc( hwnd, msg, mp1, mp2);
|
---|
765 | break;
|
---|
766 |
|
---|
767 | default:
|
---|
768 | txwPostMsg( owner, msg, mp1, mp2);
|
---|
769 | break;
|
---|
770 | }
|
---|
771 | break;
|
---|
772 | }
|
---|
773 | }
|
---|
774 | }
|
---|
775 | break;
|
---|
776 | }
|
---|
777 | }
|
---|
778 | break;
|
---|
779 |
|
---|
780 | #if defined (HAVEMOUSE)
|
---|
781 |
|
---|
782 | case TXWM_BUTTONDOWN: // Mouse button clicked
|
---|
783 | TRACES(( "Click:%4.4hx/%4.4hx on %8.8lx at % 3hd,%-3hd %s '%s'\n",
|
---|
784 | TXSH1FROMMP(mp2),
|
---|
785 | TXSH2FROMMP(mp2), hwnd,
|
---|
786 | TXSH1FROMMP(mp1) - win->client.left,
|
---|
787 | TXSH2FROMMP(mp1) - win->client.top,
|
---|
788 | txwClassDescription( hwnd),
|
---|
789 | (win->title) ? win->title : ""));
|
---|
790 |
|
---|
791 | if (TXMOUSEKEYSCA() == TXm_KS_NONE) // no shift/alt/ctrl keys
|
---|
792 | {
|
---|
793 | if (TXMOUSEBUTTON() == TXm_BUTTON2) // HELP, even on disabled
|
---|
794 | {
|
---|
795 | //- to be refined, might present a context-menu
|
---|
796 | //- where one of the options is the HELP screen
|
---|
797 |
|
---|
798 | txwPostMsg( hwnd, TXWM_HELP, 0, 0);
|
---|
799 | }
|
---|
800 | else // perform default actions
|
---|
801 | {
|
---|
802 | short col = TXMOUSECOL() - win->client.left; // relative to
|
---|
803 | short row = TXMOUSEROW() - win->client.top; // the window!
|
---|
804 | short sy = win->client.bottom - win->client.top +1;
|
---|
805 |
|
---|
806 | TRACES(( "col:% 3hd row:% 3hd sy:% 3hd\n", col, row, sy));
|
---|
807 | TRACES(( "FOCUS:%8.8lx owner:%8.8lx modality:%8.8lx maincmd:%8.8lx mainmenu:%8.8lx\n",
|
---|
808 | txwa->focus, txwa->focus->owner, txwa->modality, txwa->maincmd, txwa->mainmenu));
|
---|
809 |
|
---|
810 | if ((win->class == TXW_LISTBOX) && // is this a menu-heading ?
|
---|
811 | (win->style & TXLS_DROP_MENU)) // close any open (sub)menu
|
---|
812 | {
|
---|
813 | TRACES(( "Click on menu-heading, re-open menu at: '%s'\n",
|
---|
814 | (win->title) ? win->title : ""));
|
---|
815 |
|
---|
816 | txwa->reopenMenu = txwQueryWindowUShort( hwnd, TXQWS_ID);
|
---|
817 | txwPostMsg((TXWHANDLE) txwa->focus, TXWM_CHAR, 0, TXk_MENU);
|
---|
818 | }
|
---|
819 |
|
---|
820 | //- Close active popup-listbox when clicking outside of it
|
---|
821 | else if ((txwa->focus->window->class == TXW_LISTBOX) &&
|
---|
822 | (txwa->focus->owner->window->style & TXCS_LIST_POPUP) &&
|
---|
823 | (txwa->focus->owner == (TXWINBASE *) txwa->modality) &&
|
---|
824 | (txwIsDescendant( hwnd, txwa->modality) == FALSE))
|
---|
825 | {
|
---|
826 | TRACES(( "Close active listbox popup, and re-issue the message\n"));
|
---|
827 |
|
---|
828 | txwSendMsg((TXWHANDLE) txwa->focus->owner, TXWM_CLOSE, 0, 0);
|
---|
829 | txwPostMsg( hwnd, msg, mp1, mp2); // re-post this message
|
---|
830 | }
|
---|
831 |
|
---|
832 | //- toggle the main menu on a click anywhere on desktop-border
|
---|
833 | //- top lines of the scrollbuf, menu-canvas or cmdline (when menu up)
|
---|
834 | else if (((hwnd == (TXWHANDLE) txwa->desktop) && (col > 1)) ||
|
---|
835 | ((hwnd == (TXWHANDLE) txwa->sbview ) && (row <= 1)) ||
|
---|
836 | ((hwnd == txwa->maincmd) && (txwa->mainmenu != 0)) ||
|
---|
837 | (hwnd == txwa->mainmenu))
|
---|
838 | {
|
---|
839 | TRACES(( "Toggle main menu, click on desktop/scrollbuf-top etc\n"));
|
---|
840 |
|
---|
841 | txwPostMsg((TXWHANDLE) txwa->focus, TXWM_CHAR, 0, TXk_MENU);
|
---|
842 | }
|
---|
843 |
|
---|
844 | //- Close active dialog frame/canvas/textview on click closebutton [X]
|
---|
845 | else if ( (txwIsDescendant( hwnd, txwa->modality)) &&
|
---|
846 | (row < 0) && (TXMOUSECOL() > (win->client.right -3)) &&
|
---|
847 | (((win->class == TXW_FRAME) ||
|
---|
848 | (win->class == TXW_CANVAS) ||
|
---|
849 | (win->class == TXW_TEXTVIEW)) &&
|
---|
850 | ((win->style & TXCS_CLOSE_BUTTON))))
|
---|
851 | {
|
---|
852 | if (flags & TXFF_MINIMIZED)
|
---|
853 | {
|
---|
854 | TRACES(( "Undo minimized window [F12] button\n"));
|
---|
855 |
|
---|
856 | txwPostMsg( hwnd, TXWM_CHAR, 0, TXk_F12);
|
---|
857 | }
|
---|
858 | else
|
---|
859 | {
|
---|
860 | TRACES(( "Close dialog on click on [X] close button\n"));
|
---|
861 |
|
---|
862 | txwPostMsg( hwnd, TXWM_CLOSE, 0, 0);
|
---|
863 | }
|
---|
864 | }
|
---|
865 |
|
---|
866 | //- Translate click on 'scroll-bar' to UP/DOWN or PGUP/PGDN keys
|
---|
867 | else if ( (txwIsDescendant( hwnd, txwa->modality)) &&
|
---|
868 | (TXMOUSECOL() > (win->client.right)) &&
|
---|
869 | (((win->class == TXW_LISTBOX) ||
|
---|
870 | (win->class == TXW_TEXTVIEW)) ))
|
---|
871 | {
|
---|
872 | ULONG key = TXk_PGDN;
|
---|
873 |
|
---|
874 | if (TXMOUSEROW() == win->client.top) key = TXk_UP;
|
---|
875 | else if (TXMOUSEROW() == win->client.bottom) key = TXk_DOWN;
|
---|
876 | else if (row < (sy / 2)) key = TXk_PGUP;
|
---|
877 |
|
---|
878 | TRACES(( "Scrollbar click to key: %s\n", txwKeyDescription(key)));
|
---|
879 | txwPostMsg( hwnd, TXWM_CHAR, 0, key);
|
---|
880 | }
|
---|
881 |
|
---|
882 | //- other cases, try to switch focus, if OK, perform post-processing
|
---|
883 | else if (txwIsWindowEnabled(hwnd)) // enabled ?
|
---|
884 | {
|
---|
885 | if (txwSetFocus( hwnd) == NO_ERROR) // to window under mouse
|
---|
886 | {
|
---|
887 | TRACES(( "Changed focus to clicked window, post-process ...\n"));
|
---|
888 |
|
---|
889 | switch (win->class) // additional positioning
|
---|
890 | {
|
---|
891 | case TXW_ENTRYFIELD: // set cursor to mouse pos
|
---|
892 | {
|
---|
893 | TXENTRYFIELD *dat = &win->ef;
|
---|
894 |
|
---|
895 | if (dat->buf && strlen( dat->buf))
|
---|
896 | {
|
---|
897 | dat->curpos = min( col, txSlen(dat->buf) - dat->leftcol);
|
---|
898 | txwInvalidateWindow( hwnd, TRUE, TRUE);
|
---|
899 | }
|
---|
900 | }
|
---|
901 | break;
|
---|
902 |
|
---|
903 | case TXW_LISTBOX:
|
---|
904 | {
|
---|
905 | TXLISTBOX *dat = &win->lb;
|
---|
906 | TXSELIST *list = dat->list;
|
---|
907 |
|
---|
908 | TRACES(("Drop-value: %s\n", (win->style & TXLS_DROP_VALUE) ? "YES" : "NO"));
|
---|
909 | TRACES(("Drop-menu: %s\n", (win->style & TXLS_DROP_MENU ) ? "YES" : "NO"));
|
---|
910 |
|
---|
911 | if ((list != NULL) && (list->count != 0))
|
---|
912 | {
|
---|
913 | if (win->style & TXLS_DROP_VALUE)
|
---|
914 | {
|
---|
915 | if (TXMOUSECOL() > (win->client.right -2))
|
---|
916 | {
|
---|
917 | //- when at end of control, force a drop-down
|
---|
918 | txwPostMsg( hwnd, TXWM_CHAR, 0, TXa_ENTER);
|
---|
919 | }
|
---|
920 | }
|
---|
921 | else if (win->style & TXLS_DROP_MENU) // menu heading
|
---|
922 | {
|
---|
923 | }
|
---|
924 | else // multi-line, including menu
|
---|
925 | {
|
---|
926 | ULONG li = (ULONG) (list->top + row);
|
---|
927 |
|
---|
928 | TRACES(("Listbox style:%8.8lx li:%lu\n", win->style, li));
|
---|
929 |
|
---|
930 | if (li < list->count)
|
---|
931 | {
|
---|
932 | TXS_ITEM *item = list->items[li];
|
---|
933 |
|
---|
934 | TRACES(("Item: '%s' = '%s'\n", item->text, item->desc));
|
---|
935 | if ((item->flags & TXSF_DISABLED) == 0)
|
---|
936 | {
|
---|
937 | dat->cpos = row; //- Visual, and list position update
|
---|
938 | TxSelSetSelected( list, li, TX_TOGGLE, TXSF_MARK_STD);
|
---|
939 |
|
---|
940 | txwPostMsg( owner, TXWM_CONTROL,
|
---|
941 | TXMPFROM2SH(wid,TXLN_SELECT),
|
---|
942 | (ULONG) (list));
|
---|
943 |
|
---|
944 | txwInvalidateWindow( hwnd, TRUE, TRUE);
|
---|
945 |
|
---|
946 | //- execute the selected line in list
|
---|
947 | txwPostMsg( hwnd, TXWM_CHAR, 0, TXk_ENTER);
|
---|
948 | }
|
---|
949 | }
|
---|
950 | }
|
---|
951 | }
|
---|
952 | }
|
---|
953 | break;
|
---|
954 |
|
---|
955 | case TXW_BUTTON: // push the button
|
---|
956 | txwPostMsg( hwnd, TXWM_CHAR, 0, TXk_SPACE);
|
---|
957 | break;
|
---|
958 |
|
---|
959 | case TXW_HEXEDIT:
|
---|
960 | rc = txwHexEditWinProc( hwnd, msg, mp1, mp2);
|
---|
961 | break;
|
---|
962 |
|
---|
963 | default:
|
---|
964 | break;
|
---|
965 | }
|
---|
966 | }
|
---|
967 | }
|
---|
968 | }
|
---|
969 | }
|
---|
970 | break;
|
---|
971 |
|
---|
972 | case TXWM_BUTTONUP:
|
---|
973 | TRACES(( "BtnUP:%4.4hx/%4.4hx on %8.8lx at % 3hd,%-3hd %s '%s'\n",
|
---|
974 | TXSH1FROMMP(mp2),
|
---|
975 | TXSH2FROMMP(mp2), hwnd,
|
---|
976 | TXSH1FROMMP(mp1) - win->client.left,
|
---|
977 | TXSH2FROMMP(mp1) - win->client.top,
|
---|
978 | txwClassDescription( hwnd),
|
---|
979 | (win->title) ? win->title : ""));
|
---|
980 |
|
---|
981 | if (TXMOUSEKEYSCA() == TXm_KS_NONE) // no shift/alt/ctrl keys
|
---|
982 | {
|
---|
983 | if (txwQueryCapture() != TXHWND_NULL)
|
---|
984 | {
|
---|
985 | if (txwa->mDragFlags & TXSWP_MOVE)
|
---|
986 | {
|
---|
987 | txwSetWindowPos( hwnd, TXHWND_NULL,
|
---|
988 | TXMOUSECOL() - txwa->mDragCol,
|
---|
989 | TXMOUSEROW() - txwa->mDragRow,
|
---|
990 | 0, 0, TXSWP_MOVE | TXSWP_RELATIVE);
|
---|
991 | }
|
---|
992 | else
|
---|
993 | {
|
---|
994 | txwSetWindowPos( hwnd, TXHWND_NULL,
|
---|
995 | 0, 0,
|
---|
996 | TXMOUSECOL() - txwa->mDragCol,
|
---|
997 | TXMOUSEROW() - txwa->mDragRow,
|
---|
998 | TXSWP_SIZE | TXSWP_RELATIVE);
|
---|
999 | }
|
---|
1000 | txwSetCapture( TXHWND_NULL);
|
---|
1001 | }
|
---|
1002 | }
|
---|
1003 | break;
|
---|
1004 |
|
---|
1005 | case TXWM_MOUSEMOVE: // with button down (drag)
|
---|
1006 | TRACES(( "mMove:%4.4hx/%4.4hx on %8.8lx at % 3hd,%-3hd %s '%s'\n",
|
---|
1007 | TXSH1FROMMP(mp2),
|
---|
1008 | TXSH2FROMMP(mp2), hwnd,
|
---|
1009 | TXSH1FROMMP(mp1) - win->client.left,
|
---|
1010 | TXSH2FROMMP(mp1) - win->client.top,
|
---|
1011 | txwClassDescription( hwnd),
|
---|
1012 | (win->title) ? win->title : ""));
|
---|
1013 |
|
---|
1014 | if (TXMOUSEKEYSCA() == TXm_KS_NONE) // no shift/alt/ctrl keys
|
---|
1015 | {
|
---|
1016 | if ((TXMOUSEBUTTON() & TXm_BUTTON2) == 0) // no drag on help
|
---|
1017 | {
|
---|
1018 | short col = TXMOUSECOL(); // absolute mouse position!
|
---|
1019 | short row = TXMOUSEROW();
|
---|
1020 |
|
---|
1021 | if (txwQueryCapture() == TXHWND_NULL)
|
---|
1022 | {
|
---|
1023 | //- Note: buttons 1 and 3 perform same function,
|
---|
1024 | //- but button-1 does full-window drag too
|
---|
1025 |
|
---|
1026 | if ( txwIsDescendant( hwnd, txwa->modality) && // active
|
---|
1027 | ((row <= win->client.top) || // on window title line
|
---|
1028 | ((row >= win->client.bottom) &&
|
---|
1029 | (col >= win->client.right )))) // or lower-right corner
|
---|
1030 | {
|
---|
1031 | if (row <= win->client.top) // window move drag operation
|
---|
1032 | {
|
---|
1033 | txwa->mDragFlags = TXSWP_MOVE;
|
---|
1034 | }
|
---|
1035 | else // window resize drag operation
|
---|
1036 | {
|
---|
1037 | txwa->mDragFlags = TXSWP_SIZE;
|
---|
1038 | col &= 0xfffe; // size to EVEN column pos
|
---|
1039 | }
|
---|
1040 | if (win->style & TXWS_MOVEABLE) // frame itself movable
|
---|
1041 | {
|
---|
1042 | txwSetCapture( hwnd);
|
---|
1043 | txwa->mDragCol = col;
|
---|
1044 | txwa->mDragRow = row;
|
---|
1045 | }
|
---|
1046 | else if (((win->class == TXW_LISTBOX) ||
|
---|
1047 | (win->class == TXW_TEXTVIEW)) &&
|
---|
1048 | (wnd->owner->window->style & TXWS_MOVEABLE))
|
---|
1049 | {
|
---|
1050 | txwSetCapture( owner);
|
---|
1051 | txwa->mDragCol = col;
|
---|
1052 | txwa->mDragRow = row;
|
---|
1053 | }
|
---|
1054 | }
|
---|
1055 | }
|
---|
1056 | else // window is being dragged
|
---|
1057 | {
|
---|
1058 | if ((TXMOUSEBUTTON() & TXm_BUTTON1)) // full-window drag
|
---|
1059 | {
|
---|
1060 | if (txwa->mDragFlags & TXSWP_MOVE)
|
---|
1061 | {
|
---|
1062 | txwSetWindowPos( hwnd, TXHWND_NULL,
|
---|
1063 | col - txwa->mDragCol,
|
---|
1064 | row - txwa->mDragRow,
|
---|
1065 | 0, 0, TXSWP_MOVE | TXSWP_RELATIVE);
|
---|
1066 | }
|
---|
1067 | else // to allow 1/2 move/size
|
---|
1068 | { // of dialog-controls, only
|
---|
1069 | col &= 0xfffe; // size to EVEN column pos
|
---|
1070 | txwSetWindowPos( hwnd, TXHWND_NULL,
|
---|
1071 | 0, 0,
|
---|
1072 | col - txwa->mDragCol,
|
---|
1073 | row - txwa->mDragRow,
|
---|
1074 | TXSWP_SIZE | TXSWP_RELATIVE);
|
---|
1075 | }
|
---|
1076 | txwa->mDragCol = col; // set new reference position
|
---|
1077 | txwa->mDragRow = row;
|
---|
1078 | }
|
---|
1079 | }
|
---|
1080 | }
|
---|
1081 | }
|
---|
1082 | break;
|
---|
1083 |
|
---|
1084 | #endif
|
---|
1085 |
|
---|
1086 | case TXWM_CURSORVISIBLE:
|
---|
1087 | wnd->curvisible = (BOOL) mp1;
|
---|
1088 | txwSetCursorStyle( hwnd, txwa->insert);
|
---|
1089 | break;
|
---|
1090 |
|
---|
1091 | case TXWM_CREATE:
|
---|
1092 | txwSetCursorStyle( hwnd, txwa->insert);
|
---|
1093 | switch (win->class)
|
---|
1094 | {
|
---|
1095 | case TXW_SBVIEW:
|
---|
1096 | break;
|
---|
1097 |
|
---|
1098 | case TXW_ENTRYFIELD:
|
---|
1099 | if (win->style & TXES_MAIN_CMDLINE)
|
---|
1100 | {
|
---|
1101 | txwa->maincmd = hwnd; // ENTRYFIELD commandline
|
---|
1102 | TRACES(( "setting MAINCMD to: %8.8lx\n", txwa->maincmd));
|
---|
1103 | }
|
---|
1104 | break;
|
---|
1105 |
|
---|
1106 | case TXW_HEXEDIT:
|
---|
1107 | rc = txwHexEditWinProc( hwnd, msg, mp1, mp2);
|
---|
1108 | break;
|
---|
1109 |
|
---|
1110 | default:
|
---|
1111 | break;
|
---|
1112 | }
|
---|
1113 | break;
|
---|
1114 |
|
---|
1115 | case TXWM_DESTROY: // window will be destroyed
|
---|
1116 | switch (win->class)
|
---|
1117 | {
|
---|
1118 | case TXW_SBVIEW:
|
---|
1119 | txwa->sbview = NULL; // SBVIEW for debug status
|
---|
1120 | break;
|
---|
1121 |
|
---|
1122 | case TXW_ENTRYFIELD:
|
---|
1123 | if (win->style & TXES_MAIN_CMDLINE)
|
---|
1124 | {
|
---|
1125 | txwa->maincmd = TXHWND_NULL; // ENTRYFIELD for commandline
|
---|
1126 | TRACES(( "setting MAINCMD to: %8.8lx\n", txwa->maincmd));
|
---|
1127 | }
|
---|
1128 | break;
|
---|
1129 |
|
---|
1130 | case TXW_HEXEDIT:
|
---|
1131 | rc = txwHexEditWinProc( hwnd, msg, mp1, mp2);
|
---|
1132 | break;
|
---|
1133 |
|
---|
1134 | default:
|
---|
1135 | break;
|
---|
1136 | }
|
---|
1137 | break; // notification
|
---|
1138 |
|
---|
1139 | case TXWM_HELP: // context-sensitive help
|
---|
1140 | {
|
---|
1141 | ULONG helpid = TXWH_USE_WIN_HELP;
|
---|
1142 |
|
---|
1143 | switch (win->class)
|
---|
1144 | {
|
---|
1145 | case TXW_LISTBOX:
|
---|
1146 | if ((list = win->lb.list) != NULL)
|
---|
1147 | {
|
---|
1148 | ULONG li;
|
---|
1149 | TXS_ITEM *item;
|
---|
1150 |
|
---|
1151 | if ((list->selarray == NULL) && // NOT multiple select
|
---|
1152 | ((win->style & TXLS_DROP_MENU) == 0)) // no heading
|
---|
1153 | {
|
---|
1154 | li = (ULONG) (list->top + win->lb.cpos);
|
---|
1155 |
|
---|
1156 | if (li < list->count) // avoid empty list trap
|
---|
1157 | {
|
---|
1158 | item = list->items[li];
|
---|
1159 |
|
---|
1160 | if ((helpid = item->helpid) == TXWH_USE_CMD_CODE)
|
---|
1161 | {
|
---|
1162 | helpid = item->value; // use cmd value
|
---|
1163 | TRACES(("Using cmdcode %8.8lx as helpid\n", helpid));
|
---|
1164 | }
|
---|
1165 | else if (helpid == TXWH_USE_OWNER_HELP)
|
---|
1166 | {
|
---|
1167 | TRACES(("Delegate help to owner\n"));
|
---|
1168 | txwPostMsg( owner, msg, mp1, mp2);
|
---|
1169 | }
|
---|
1170 | }
|
---|
1171 | }
|
---|
1172 | }
|
---|
1173 | break;
|
---|
1174 |
|
---|
1175 | default:
|
---|
1176 | break;
|
---|
1177 | }
|
---|
1178 | TRACES(("helpid: %8.8lx = %lu\n", helpid, helpid));
|
---|
1179 | if (helpid != TXWH_USE_OWNER_HELP) // not delegated to owner ?
|
---|
1180 | {
|
---|
1181 | if (helpid == TXWH_USE_WIN_HELP) // not changed to specific ?
|
---|
1182 | {
|
---|
1183 | helpid = win->helpid; // use default window help
|
---|
1184 | }
|
---|
1185 | txwHelpDialog(helpid);
|
---|
1186 | TxCancelAbort(); // don't set global abort
|
---|
1187 | }
|
---|
1188 | }
|
---|
1189 | break; // after simple help screen
|
---|
1190 |
|
---|
1191 | case TXWM_MOVE: // window has been moved
|
---|
1192 | break; // notification
|
---|
1193 |
|
---|
1194 | case TXWM_PAINT: // window completely visible
|
---|
1195 | if (txwIsWindowShowing( hwnd) || // or scrollbuf, painting a
|
---|
1196 | (win->class == TXW_SBVIEW)) // partly covered window
|
---|
1197 | {
|
---|
1198 | rc = txwPaintWindow( wnd, mp1); // mp1 is border paint
|
---|
1199 | }
|
---|
1200 | break;
|
---|
1201 |
|
---|
1202 | case TXWM_SELECTED:
|
---|
1203 | if ((BOOL) mp1) // set window selected ?
|
---|
1204 | {
|
---|
1205 | flags |= TXFF_SELECTED;
|
---|
1206 | }
|
---|
1207 | else
|
---|
1208 | {
|
---|
1209 | flags &= ~TXFF_SELECTED;
|
---|
1210 | }
|
---|
1211 | txwSetWindowUShort( hwnd, TXQWS_FLAGS, flags);
|
---|
1212 | txwInvalidateBorder( hwnd);
|
---|
1213 | break;
|
---|
1214 |
|
---|
1215 | case TXWM_SETFOCUS:
|
---|
1216 | if (((BOOL) mp1) && // got focus, will be on top,
|
---|
1217 | (win->style & TXWS_FOCUS_PAINT)) // so can be repainted
|
---|
1218 | {
|
---|
1219 | txwInvalidateWindow( hwnd, TRUE, TRUE);
|
---|
1220 | }
|
---|
1221 | else // just update status part
|
---|
1222 | { // and borders
|
---|
1223 | if (txwIsWindowShowing( hwnd))
|
---|
1224 | {
|
---|
1225 | if (win->style & TXWS_FOCUS_PAINT)
|
---|
1226 | {
|
---|
1227 | txwInvalidateWindow( hwnd, TRUE, TRUE);
|
---|
1228 | }
|
---|
1229 | else
|
---|
1230 | {
|
---|
1231 | txwPaintBorder( wnd, (BOOL) mp1);
|
---|
1232 | }
|
---|
1233 | }
|
---|
1234 | txwPaintWinStatus( wnd, NULL, 0); // checks 'Showing' for status!
|
---|
1235 | }
|
---|
1236 | switch (win->class) // additional FOCUS processing
|
---|
1237 | { // for specific classes
|
---|
1238 | case TXW_LISTBOX:
|
---|
1239 | if ((list = win->lb.list) != NULL)
|
---|
1240 | {
|
---|
1241 | TRACES(("Drop-menu: %s\n", (win->style & TXLS_DROP_MENU ) ? "YES" : "NO"));
|
---|
1242 | TRACES(("Auto-drop: %s\n", (win->style & TXLS_AUTO_DROP ) ? "YES" : "NO"));
|
---|
1243 |
|
---|
1244 | if ((BOOL) mp1) // got focus
|
---|
1245 | {
|
---|
1246 | TRACES(("LB:%8.8lx L:%8.8lx f:%4.4x t:'%s' F:'%s'\n",
|
---|
1247 | win, list, flags, (win->title) ? win->title : "none",
|
---|
1248 | (win->footer) ? win->footer : "none"));
|
---|
1249 |
|
---|
1250 | if (win->style & TXLS_DROP_MENU)
|
---|
1251 | {
|
---|
1252 | txwPostMsg( TXHWND_DESKTOP, TXWM_SETFOOTER,
|
---|
1253 | (ULONG) win->footer, 0);
|
---|
1254 |
|
---|
1255 | if ((flags & TXFF_ACTIVE) == 0) // unless now dropped
|
---|
1256 | {
|
---|
1257 | if (win->style & TXLS_AUTO_DROP)
|
---|
1258 | {
|
---|
1259 | if (flags & TXFF_AUTODROPNEXT) // delay drop to next time
|
---|
1260 | {
|
---|
1261 | TRACES(("Autodrop menu delayed until next time ...\n"));
|
---|
1262 | flags &= ~TXFF_AUTODROPNEXT;
|
---|
1263 | txwSetWindowUShort( hwnd, TXQWS_FLAGS, flags);
|
---|
1264 | }
|
---|
1265 | else
|
---|
1266 | {
|
---|
1267 | txwPostMsg( hwnd, TXWM_CHAR, 0, TXa_ENTER); // forced drop
|
---|
1268 | }
|
---|
1269 | }
|
---|
1270 | }
|
---|
1271 | }
|
---|
1272 | else // signal select on get-focus
|
---|
1273 | {
|
---|
1274 | txwPostMsg( owner, TXWM_CONTROL,
|
---|
1275 | TXMPFROM2SH(wid,TXLN_SETFOCUS),
|
---|
1276 | (ULONG) (win->lb.list));
|
---|
1277 | }
|
---|
1278 | }
|
---|
1279 | else // lost focus
|
---|
1280 | {
|
---|
1281 | txwPostMsg( TXHWND_DESKTOP, TXWM_SETFOOTER, 0, 0); // reset description
|
---|
1282 | }
|
---|
1283 | if (list->flags & TXSL_MULTI_QUICK)
|
---|
1284 | {
|
---|
1285 | if (strlen( txwa->listmatch) != 0)
|
---|
1286 | {
|
---|
1287 | txwSetSbviewStatus( "", cSchemeColor);
|
---|
1288 | strcpy( txwa->listmatch, ""); // reset string
|
---|
1289 | }
|
---|
1290 | }
|
---|
1291 | }
|
---|
1292 | txwPostMsg( hwnd, TXWM_PAINT, FALSE, 0); // repaint, list-bar
|
---|
1293 | break;
|
---|
1294 |
|
---|
1295 | default:
|
---|
1296 | break;
|
---|
1297 | }
|
---|
1298 | break;
|
---|
1299 |
|
---|
1300 | case TXWM_SIZE: // window has been sized
|
---|
1301 | switch (win->class) // additional SIZE processing
|
---|
1302 | { // for specific classes
|
---|
1303 | case TXW_LISTBOX:
|
---|
1304 | if ((list = win->lb.list) != NULL)
|
---|
1305 | {
|
---|
1306 | if (win->style & TXLS_DROP_VALUE)
|
---|
1307 | {
|
---|
1308 | }
|
---|
1309 | else if (win->style & TXLS_DROP_MENU)
|
---|
1310 | {
|
---|
1311 | }
|
---|
1312 | else // multi-line or spin
|
---|
1313 | {
|
---|
1314 | list->vsize = (ULONG) (win->client.bottom - win->client.top +1);
|
---|
1315 | TRACES(("Updated list->vsize to %hu lines\n",
|
---|
1316 | win->client.bottom - win->client.top +1));
|
---|
1317 | }
|
---|
1318 | }
|
---|
1319 | break;
|
---|
1320 |
|
---|
1321 | case TXW_HEXEDIT:
|
---|
1322 | rc = txwHexEditWinProc( hwnd, msg, mp1, mp2);
|
---|
1323 | break;
|
---|
1324 |
|
---|
1325 | default:
|
---|
1326 | break;
|
---|
1327 | }
|
---|
1328 | break; // notification
|
---|
1329 |
|
---|
1330 | case TXWM_SHOW: // window visibility change
|
---|
1331 | break; // notification
|
---|
1332 |
|
---|
1333 | case TXWM_STATUS: // checks own visibility!
|
---|
1334 | rc = txwPaintWinStatus( wnd, (char *) mp1, (BYTE) mp2);
|
---|
1335 | break;
|
---|
1336 |
|
---|
1337 | case TXWM_SETFOOTER: // set/reset footer text
|
---|
1338 | if (mp1 != NULL)
|
---|
1339 | {
|
---|
1340 | win->footer = (char *) mp1; // set new footer text
|
---|
1341 | }
|
---|
1342 | else
|
---|
1343 | {
|
---|
1344 | win->footer = wnd->oldFooter; // reset to original
|
---|
1345 | }
|
---|
1346 | txwPaintBorder( wnd, // repaint will NOT check
|
---|
1347 | (wnd == txwa->focus)); // for border visibility!
|
---|
1348 | break;
|
---|
1349 |
|
---|
1350 | default:
|
---|
1351 | TRACES(("Warning: unhandled message in lowest level WinProc!\n"));
|
---|
1352 | break;
|
---|
1353 | }
|
---|
1354 | RETURN( rc);
|
---|
1355 | } // end 'txwGenericWinProc'
|
---|
1356 | /*---------------------------------------------------------------------------*/
|
---|
1357 |
|
---|
1358 |
|
---|
1359 | /*****************************************************************************/
|
---|
1360 | // Dismiss dialog and pass-on result code
|
---|
1361 | /*****************************************************************************/
|
---|
1362 | ULONG txwDismissDlg
|
---|
1363 | (
|
---|
1364 | TXWHANDLE hwnd, // IN dialog handle
|
---|
1365 | ULONG result // IN result code
|
---|
1366 | )
|
---|
1367 | {
|
---|
1368 | ULONG rc = NO_ERROR; // function return
|
---|
1369 | TXWINBASE *wnd;
|
---|
1370 | TXWINDOW *win;
|
---|
1371 |
|
---|
1372 | ENTER();
|
---|
1373 | TRACES(("Dismiss dlg %8.8lx with RC:%8.8lx = %lu\n", hwnd, result, result));
|
---|
1374 |
|
---|
1375 | if ((wnd = txwValidateHandle( hwnd, &win)) != NULL)
|
---|
1376 | {
|
---|
1377 | win->dlgResult = result;
|
---|
1378 | wnd->us[TXQWS_FLAGS] |= TXFF_DLGDISMISSED;
|
---|
1379 |
|
---|
1380 | txwShowWindow( hwnd, FALSE); // hide the window
|
---|
1381 | }
|
---|
1382 | else
|
---|
1383 | {
|
---|
1384 | rc = TX_INVALID_HANDLE;
|
---|
1385 | }
|
---|
1386 | #if defined (DEV32)
|
---|
1387 | txwInvalidateAll(); // avoid VIO 64Kb buffer bug
|
---|
1388 | #endif
|
---|
1389 | RETURN (rc);
|
---|
1390 | } // end 'txwDismissDlg'
|
---|
1391 | /*---------------------------------------------------------------------------*/
|
---|
1392 |
|
---|
1393 |
|
---|
1394 | /*****************************************************************************/
|
---|
1395 | // Create a Dialog from memory-structures (created frame + linked controls)
|
---|
1396 | /*****************************************************************************/
|
---|
1397 | TXWHANDLE txwCreateDlg
|
---|
1398 | (
|
---|
1399 | TXWHANDLE parent, // IN parent (ignored!)
|
---|
1400 | TXWHANDLE owner, // IN owner window
|
---|
1401 | TXWINPROC dlgproc, // IN dialog procedure
|
---|
1402 | TXWHANDLE dlg, // IN dialog frame window
|
---|
1403 | PVOID cData // IN user control data
|
---|
1404 | )
|
---|
1405 | {
|
---|
1406 | TXWHANDLE rc = 0; // function return
|
---|
1407 | TXWINBASE *wnd; // frame window (dialog)
|
---|
1408 | TXWINDOW *win;
|
---|
1409 |
|
---|
1410 | ENTER();
|
---|
1411 |
|
---|
1412 | TRACES(( "Frame hwnd:%8.8lx dlgproc:%8.8lx cData:%8.8lx\n", dlg, dlgproc, cData));
|
---|
1413 |
|
---|
1414 | //- to be refined (long term) create dialog from template instead of
|
---|
1415 | //- complete dialog frame + controls setup with CreateWindow
|
---|
1416 | //- until then, the parent specified here will be ignored (position)
|
---|
1417 |
|
---|
1418 | if ((wnd = txwValidateHandle( dlg, &win)) != NULL)
|
---|
1419 | {
|
---|
1420 | TXWHANDLE focus;
|
---|
1421 | TXWINBASE *vwnd; // validated winbase
|
---|
1422 |
|
---|
1423 | focus = txwWindowFromID( dlg, win->dlgFocusID);
|
---|
1424 |
|
---|
1425 | //- owner and dlgproc specified here overrule the template
|
---|
1426 | //- must be specified as 0 to CreateWindow (owner and winproc)
|
---|
1427 |
|
---|
1428 | if ((vwnd = txwValidateHandle( owner, NULL)) != NULL)
|
---|
1429 | {
|
---|
1430 | wnd->owner = vwnd;
|
---|
1431 | }
|
---|
1432 | else
|
---|
1433 | {
|
---|
1434 | wnd->owner = txwa->desktop;
|
---|
1435 | }
|
---|
1436 | wnd->winproc = dlgproc; // attach dialog procedure
|
---|
1437 |
|
---|
1438 | win->style &= ~TXWS_VISIBLE; //- set invisible
|
---|
1439 | wnd->us[TXQWS_FLAGS] &= ~TXFF_DLGDISMISSED; //- clear dismissed flag
|
---|
1440 |
|
---|
1441 | if (cData != NULL) // optional, USER PTR could be
|
---|
1442 | { // set by caller already!
|
---|
1443 | wnd->ul[TXQWP_USER] = (ULONG) cData;
|
---|
1444 | }
|
---|
1445 | txwPostMsg( (TXWHANDLE) wnd, TXWM_INITDLG, focus, (ULONG) cData);
|
---|
1446 |
|
---|
1447 | rc = dlg;
|
---|
1448 | }
|
---|
1449 | RETURN (rc);
|
---|
1450 | } // end 'txwCreateDlg'
|
---|
1451 | /*---------------------------------------------------------------------------*/
|
---|
1452 |
|
---|
1453 |
|
---|
1454 | /*****************************************************************************/
|
---|
1455 | // Process a (modal) dialog using a local msg-loop
|
---|
1456 | /*****************************************************************************/
|
---|
1457 | ULONG txwProcessDlg // RET dialog rc (dismiss)
|
---|
1458 | (
|
---|
1459 | TXWHANDLE hwnd // IN dialog handle
|
---|
1460 | )
|
---|
1461 | {
|
---|
1462 | ULONG rc = NO_ERROR; // function return
|
---|
1463 | TXWINBASE *wnd; // frame window (dialog)
|
---|
1464 | TXWINDOW *win;
|
---|
1465 |
|
---|
1466 | ENTER();
|
---|
1467 | TRWINS("ProcessDlg");
|
---|
1468 |
|
---|
1469 | if ((wnd = txwValidateHandle( hwnd, &win)) != NULL)
|
---|
1470 | {
|
---|
1471 | TXWQMSG qmsg;
|
---|
1472 | TXWHANDLE oldModality; // previous modality window
|
---|
1473 |
|
---|
1474 | //- Following is a workarround for focus/loose-focus paint problems
|
---|
1475 | oldModality = txwa->modality; // remember previous ...
|
---|
1476 | txwa->modality = TXHWND_DESKTOP; // temporary to desktop
|
---|
1477 | txwSetFocus( TXHWND_DESKTOP); // remove focus from current
|
---|
1478 | txwSendMsg( TXHWND_DESKTOP, // and from desktop too!
|
---|
1479 | TXWM_SETFOCUS, FALSE, 0);
|
---|
1480 |
|
---|
1481 | txwa->modality = hwnd; // and make dialog modal
|
---|
1482 |
|
---|
1483 | txwShowWindow( hwnd, TRUE); // make the dialog visible
|
---|
1484 |
|
---|
1485 | win->dlgResult = TXDID_CANCEL; // if not dismissed properly
|
---|
1486 |
|
---|
1487 | while (((wnd->us[TXQWS_FLAGS] & TXFF_DLGDISMISSED) == 0) &&
|
---|
1488 | (txwGetMsg( &qmsg)) )
|
---|
1489 | {
|
---|
1490 | txwDispatchMsg( &qmsg);
|
---|
1491 | }
|
---|
1492 |
|
---|
1493 | txwa->modality = oldModality; // restore previous
|
---|
1494 |
|
---|
1495 | if (qmsg.msg == TXWM_QUIT)
|
---|
1496 | { // signal program termination
|
---|
1497 | txwPostMsg( TXHWND_DESKTOP, // to the desktop window
|
---|
1498 | TXWM_QUIT, 0, 0); // in regular message loop
|
---|
1499 | }
|
---|
1500 | rc = win->dlgResult; // return dialog result
|
---|
1501 | }
|
---|
1502 | else
|
---|
1503 | {
|
---|
1504 | rc = TX_INVALID_HANDLE;
|
---|
1505 | }
|
---|
1506 | RETURN (rc);
|
---|
1507 | } // end 'txwProcessDlg'
|
---|
1508 | /*---------------------------------------------------------------------------*/
|
---|
1509 |
|
---|
1510 |
|
---|
1511 | /*****************************************************************************/
|
---|
1512 | // Create, Process and Destroy a (modal) dialog
|
---|
1513 | /*****************************************************************************/
|
---|
1514 | ULONG txwDlgBox // RET dialog rc (dismiss)
|
---|
1515 | (
|
---|
1516 | TXWHANDLE parent, // IN parent (ignored!)
|
---|
1517 | TXWHANDLE owner, // IN owner window
|
---|
1518 | TXWINPROC dlgproc, // IN dialog procedure
|
---|
1519 | TXWHANDLE dlg, // IN dialog frame window
|
---|
1520 | PVOID cData // IN user control data
|
---|
1521 | )
|
---|
1522 | {
|
---|
1523 | ULONG rc = NO_ERROR; // function return
|
---|
1524 | TXWINBASE *wnd; // frame window (dialog)
|
---|
1525 | TXWINDOW *win;
|
---|
1526 |
|
---|
1527 | ENTER();
|
---|
1528 |
|
---|
1529 | if ((wnd = txwValidateHandle( dlg, &win)) != NULL)
|
---|
1530 | {
|
---|
1531 | txwCreateDlg( parent, owner, dlgproc, dlg, cData);
|
---|
1532 |
|
---|
1533 | rc = txwProcessDlg( dlg);
|
---|
1534 |
|
---|
1535 | txwDestroyWindow( dlg);
|
---|
1536 | }
|
---|
1537 | else
|
---|
1538 | {
|
---|
1539 | rc = TX_INVALID_HANDLE;
|
---|
1540 | }
|
---|
1541 | RETURN (rc);
|
---|
1542 | } // end 'txwDlgBox'
|
---|
1543 | /*---------------------------------------------------------------------------*/
|
---|
1544 |
|
---|