source: trunk/src/kernel32/conprop.cpp@ 8

Last change on this file since 8 was 8, checked in by phaller, 26 years ago

removed superfluous return() statement.

File size: 68.0 KB
Line 
1/* $Id: conprop.cpp,v 1.2 1999-05-25 19:29:30 phaller Exp $ */
2
3/*
4 *
5 * Project Odin Software License can be found in LICENSE.TXT
6 *
7 */
8/*
9 * Win32 Console API Translation for OS/2
10 *
11 * 1998/03/06 Patrick Haller (haller@zebra.fh-weingarten.de)
12 *
13 * @(#) conprop.cpp 1.0.0 1998/03/06 PH Start from scratch
14 */
15
16
17/*****************************************************************************
18 * Remark *
19 *****************************************************************************
20
21 - save / load properties from EAs
22
23 */
24
25
26/*****************************************************************************
27 * Includes *
28 *****************************************************************************/
29
30#define INCL_GPI
31#define INCL_WIN
32#define INCL_DOSMEMMGR
33#define INCL_DOSSEMAPHORES
34#define INCL_DOSERRORS
35#define INCL_DOSPROCESS
36#define INCL_DOSMODULEMGR
37#define INCL_VIO
38#define INCL_AVIO
39#include <os2.h>
40#include <builtin.h>
41
42#include <stdlib.h>
43#include <string.h>
44#include <stdarg.h>
45#include <stdio.h>
46#include "win32type.h"
47#include "misc.h"
48#include "console.h"
49#include "console2.h"
50#include "conprop.h"
51
52
53/*****************************************************************************
54 * Defines *
55 *****************************************************************************/
56
57
58
59#define HWNDERR( hwnd ) \
60 (ERRORIDERROR( WinGetLastError( WinQueryAnchorBlock( hwnd ) ) ))
61
62
63/*****************************************************************************
64 * Structures *
65 *****************************************************************************/
66
67typedef struct // VARIABLES USED FOR A NOTEBOOK PAGE
68{
69 ULONG ulID; // Resource ID for dialog page
70 PFNWP wpDlgProc; // dialog window procedure
71 PSZ szStatusLineText; // Text to go on status line
72 PSZ szTabText; // Text to go on major tab
73 ULONG idFocus; // ID of the control to get the focus first
74 BOOL fParent; // Is this a Parent page with minor pages
75 USHORT usTabType; // BKA_MAJOR or BKA_MINOR
76 USHORT fsPageStyles; // BKA_ styles for the page
77} NBPAGE, *PNBPAGE;
78
79#define TAB_WIDTH_MARGIN 10 // Padding for the width of a notebook tab
80#define TAB_HEIGHT_MARGIN 6 // Padding for the height of a notebook tab
81#define DEFAULT_NB_TAB_HEIGHT 16 // Default if Gpi calls fail
82
83#define PAGE_COUNT(a) (sizeof( a ) / sizeof( NBPAGE ))
84#define SPEAKERFREQ_LOW 200
85#define SPEAKERFREQ_HIGH 2000
86#define SPEAKERDUR_LOW 10
87#define SPEAKERDUR_HIGH 2000
88
89/**********************************************************************/
90/*----------------------- FUNCTION PROTOTYPES ------------------------*/
91/**********************************************************************/
92
93static VOID ErrorMsg( PSZ szFormat,
94 ... );
95
96
97static HWND NBCreateNotebook(HWND hwndClient,
98 ULONG id,
99 HMODULE hModule,
100 PNBPAGE pPage ,
101 ULONG ulPages,
102 PVOID pCreationParameters);
103
104static BOOL NBSetUpPage( HWND hwndClient,
105 HWND hwndNB,
106 HMODULE hModule,
107 PNBPAGE pPage,
108 PHWND phwnd,
109 PVOID pCreationParameters);
110
111static BOOL NBSetFramePos( HWND hwndFrame );
112
113static BOOL NBTurnToFirstPage( HWND hwndNB );
114
115static BOOL NBSetTabDimensions(HWND hwndNB);
116
117static VOID NBSetNBPage(HWND hwndClient,
118 HMODULE hModule,
119 PPAGESELECTNOTIFY ppsn,
120 PVOID pCreationParameters);
121
122static HWND NBCreateDialogPage(HWND hwndParent,
123 HWND hwndNB,
124 HMODULE hModule,
125 ULONG ulPageID,
126 ULONG idDlg,
127 FNWP fpDlg,
128 PVOID pCreationParameters);
129
130static MRESULT EXPENTRY wpDlgProcPage1(HWND hwnd,
131 ULONG ulMessage,
132 MPARAM mp1,
133 MPARAM mp2);
134
135static MRESULT EXPENTRY wpDlgProcPage2(HWND hwnd,
136 ULONG ulMessage,
137 MPARAM mp1,
138 MPARAM mp2);
139
140static MRESULT EXPENTRY wpDlgProcPage3(HWND hwnd,
141 ULONG ulMessage,
142 MPARAM mp1,
143 MPARAM mp2);
144
145static MRESULT EXPENTRY wpDlgProcPage4(HWND hwnd,
146 ULONG ulMessage,
147 MPARAM mp1,
148 MPARAM mp2);
149
150static MRESULT EXPENTRY wpDlgProcPage5(HWND hwnd,
151 ULONG ulMessage,
152 MPARAM mp1,
153 MPARAM mp2);
154
155static MRESULT EXPENTRY wpDlgProcPage6(HWND hwnd,
156 ULONG ulMessage,
157 MPARAM mp1,
158 MPARAM mp2);
159
160static INT WinGetStringSize(HPS hps,
161 PSZ szString );
162
163
164static APIRET ConPropPage1Set(HWND hwndDlg,
165 PCONSOLEOPTIONS pConsoleOptions);
166
167static APIRET ConPropPage2Set(HWND hwndDlg,
168 PCONSOLEOPTIONS pConsoleOptions);
169
170static APIRET ConPropPage3Set(HWND hwndDlg,
171 PCONSOLEOPTIONS pConsoleOptions);
172
173static APIRET ConPropPage4Set(HWND hwndDlg,
174 PCONSOLEOPTIONS pConsoleOptions);
175
176static APIRET ConPropPage5Set(HWND hwndDlg,
177 PCONSOLEOPTIONS pConsoleOptions);
178
179/****************************************************************************
180 * Module Global Variables *
181 ****************************************************************************/
182
183#define __PAGE__ 0, FALSE, BKA_MAJOR, BKA_AUTOPAGESIZE | BKA_STATUSTEXTON
184
185/* pfncreate, szStatusLineText, szTabText, idFocus, fParent, usTabType, fsPageStyles */
186static NBPAGE nbpage[] =
187{
188 {DLG_CONSOLE_PAGE1, wpDlgProcPage1, "General settings", "~Settings", __PAGE__ },
189 {DLG_CONSOLE_PAGE2, wpDlgProcPage2, "Speaker settings", "S~peaker", __PAGE__ },
190 {DLG_CONSOLE_PAGE3, wpDlgProcPage3, "Window position and size", "~Window", __PAGE__ },
191 {DLG_CONSOLE_PAGE4, wpDlgProcPage4, "Colors", "C~olors", __PAGE__ },
192 {DLG_CONSOLE_PAGE5, wpDlgProcPage5, "Priorities", "P~riority", __PAGE__ },
193 {DLG_CONSOLE_PAGE6, wpDlgProcPage6, "About ...", "~About", __PAGE__ }
194};
195
196static PSZ priorities[] = {"idle", "normal", "critical", "server"};
197#define NUMPRIORITIES 4
198
199/**********************************************************************/
200/*------------------------------- Msg --------------------------------*/
201/* */
202/* DISPLAY A MESSAGE TO THE USER. */
203/* */
204/* INPUT: a message in printf format with its parms */
205/* */
206/* 1. Format the message using vsprintf. */
207/* 2. Sound a warning sound. */
208/* 3. Display the message in a message box. */
209/* */
210/* OUTPUT: nothing */
211/* */
212/*--------------------------------------------------------------------*/
213/**********************************************************************/
214
215#define MESSAGE_SIZE 1024
216
217static VOID ErrorMsg( PSZ szFormat,
218 ... )
219{
220 PSZ szMsg;
221 va_list argptr;
222
223 if( (szMsg = (PSZ)malloc( MESSAGE_SIZE )) == NULL )
224 return;
225
226 va_start( argptr, szFormat );
227 vsprintf( szMsg, szFormat, argptr );
228 va_end( argptr );
229
230 szMsg[ MESSAGE_SIZE - 1 ] = 0;
231
232 (void) WinMessageBox( HWND_DESKTOP,
233 HWND_DESKTOP,
234 szMsg,
235 "Error ...",
236 1,
237 MB_OK | MB_MOVEABLE );
238 free( szMsg );
239}
240
241
242/*****************************************************************************
243 * Name : static MRESULT ConsolePropertyDlgProc
244 * Purpose : window procedure for the console property dialog
245 * Parameters: HWND hwndDialog
246 * ULONG ulMessage
247 * MPARAM mp1
248 * MPARAM mp2
249 * Variables :
250 * Result :
251 * Remark :
252 * Status : UNTESTED
253 *
254 * Autor : Patrick Haller [Wed, 1998/02/16 11:46]
255 *****************************************************************************/
256
257MRESULT EXPENTRY ConsolePropertyDlgProc(HWND hwnd,
258 ULONG ulMessage,
259 MPARAM mp1,
260 MPARAM mp2)
261{
262 switch (ulMessage)
263 {
264 /*************************************************************************
265 * initialize the dialog *
266 *************************************************************************/
267 case WM_INITDLG:
268 {
269 PCONSOLEOPTIONS pConsoleOptions = (PCONSOLEOPTIONS)mp2; /* save ptr */
270 HWND hwndNotebook; /* notebook window handle */
271
272 WinSetWindowULong (hwnd, /* store the data pointer in local */
273 QWL_USER, /* variable storage attached to the*/
274 (ULONG)pConsoleOptions); /* window itself. */
275
276 hwndNotebook = NBCreateNotebook(hwnd, /* fill notebook with pages */
277 NB_CONSOLE_NOTEBOOK,
278 pConsoleOptions->hmodResources,
279 nbpage,
280 PAGE_COUNT(nbpage),
281 (PVOID)NULL);
282
283 /* this message makes the client pages to write new values into their */
284 /* controls. */
285 WinBroadcastMsg(hwnd, /* broadcast to all dialogs */
286 UM_PROPERTY_UNDO,
287 (MPARAM)pConsoleOptions,
288 (MPARAM)NULL,
289 BMSG_SEND |
290 BMSG_DESCENDANTS);
291
292 return ((MPARAM)FALSE);
293 }
294
295
296 /*************************************************************************
297 * control command messages *
298 *************************************************************************/
299
300 case WM_COMMAND:
301 {
302 PCONSOLEOPTIONS pConsoleOptions; /* the console options structure */
303
304 pConsoleOptions = (PCONSOLEOPTIONS)
305 WinQueryWindowULong(hwnd, /* query pointer from wnd */
306 QWL_USER);
307
308 switch (SHORT1FROMMP(mp1))
309 {
310 case ID_BTN_UNDO:
311 /* broadcast user message UM_PROPERTY_UNDO */
312 WinBroadcastMsg(hwnd, /* broadcast to all dialogs */
313 UM_PROPERTY_UNDO,
314 (MPARAM)pConsoleOptions,
315 (MPARAM)NULL,
316 BMSG_SEND |
317 BMSG_DESCENDANTS);
318 return ( (MPARAM) FALSE);
319
320
321 case ID_BTN_APPLY:
322 WinBroadcastMsg(hwnd, /* broadcast to all dialogs */
323 UM_PROPERTY_APPLY,
324 (MPARAM)pConsoleOptions,
325 (MPARAM)NULL,
326 BMSG_SEND |
327 BMSG_DESCENDANTS);
328 /* WinDismissDlg(hwnd,
329 ID_BTN_APPLY);*/
330 return ( (MPARAM) FALSE);
331
332 case BS_HELP:
333 return ( (MPARAM) FALSE);
334 }
335 }
336 }
337
338 return WinDefDlgProc(hwnd, /* default message processing */
339 ulMessage,
340 mp1,
341 mp2);
342}
343
344
345/*****************************************************************************
346 * Name :
347 * Purpose :
348 * Parameters:
349 * Variables :
350 * Result :
351 * Remark :
352 * Status : UNTESTED
353 *
354 * Autor : Patrick Haller [Wed, 1998/03/07 11:46]
355 *****************************************************************************/
356
357static HWND NBCreateNotebook(HWND hwndClient,
358 ULONG id,
359 HMODULE hModule,
360 PNBPAGE pPage ,
361 ULONG ulPages,
362 PVOID pCreationParameters)
363{
364 BOOL fSuccess = TRUE;
365 HWND hwndNB;
366 INT i;
367 PNBPAGE pP; /* Zeiger auf die Seiten des Notebookes */
368
369
370 if (pPage == NULL) /* Parameterberprfung */
371 return ( NULLHANDLE );
372
373 hwndNB = WinWindowFromID(hwndClient, /* get notebook window handle */
374 id);
375
376 if( hwndNB )
377 {
378 // Set the page background color to grey so it is the same as a dlg box.
379 if( !WinSendMsg(hwndNB,
380 BKM_SETNOTEBOOKCOLORS,
381 MPFROMLONG( SYSCLR_FIELDBACKGROUND ),
382 MPFROMSHORT( BKA_BACKGROUNDPAGECOLORINDEX ) ) )
383 ErrorMsg("BKM_SETNOTEBOOKCOLORS failed! RC(%X)",
384 HWNDERR( hwndClient ));
385
386 // Insert all the pages into the notebook and configure them. The dialog
387 // boxes are not going to be loaded and associated with those pages yet.
388
389 for(i = 0,
390 pP = pPage;
391
392 (i < ulPages) &&
393 (fSuccess == TRUE);
394
395 i++,
396 pP++ )
397
398 if (NBSetUpPage(hwndClient,
399 hwndNB,
400 hModule,
401 pP,
402 NULL,
403 pCreationParameters) == NULLHANDLE)
404 fSuccess = FALSE;
405 }
406 else
407 {
408 fSuccess = FALSE;
409 ErrorMsg("Notebook creation failed! RC(%X)",
410 HWNDERR( hwndClient ) );
411 }
412
413 if (fSuccess == TRUE) /* set notebook tab dimensions */
414 if( !NBSetTabDimensions(hwndNB))
415 fSuccess = FALSE;
416
417
418 if (fSuccess == TRUE) /* Haben wir Erfolg gehabt ? */
419 return (hwndNB); /* Ja */
420 else
421 return ( NULLHANDLE ); /* Nein */
422}
423
424
425
426/*****************************************************************************
427 *----------------------------- SetUpPage ----------------------------
428 *
429 * SET UP A NOTEBOOK PAGE.
430 *
431 * INPUT: window handle of notebook control,
432 * index into nbpage array
433 *
434 * 1.
435 *
436 * OUTPUT: TRUE or FALSE if successful or not
437 *
438 *****************************************************************************/
439
440static BOOL NBSetUpPage( HWND hwndClient,
441 HWND hwndNB,
442 HMODULE hModule,
443 PNBPAGE pPage,
444 PHWND phwnd,
445 PVOID pCreationParameters)
446{
447 ULONG ulPageId;
448 BOOL fSuccess = TRUE;
449 HWND hwndPage = NULLHANDLE;
450
451
452 if (pPage == NULL) /* Parameterberprfung */
453 return (hwndPage); /* failed !*/
454
455 /* Insert a page into the notebook and store it in the array of page data. */
456 /* Specify that it is to have status text and the window associated with */
457 /* each page will be automatically sized by the notebook according to the */
458 /* size of the page. */
459
460 ulPageId = (ULONG) WinSendMsg( hwndNB,
461 BKM_INSERTPAGE,
462 NULL,
463 MPFROM2SHORT( pPage->usTabType |
464 pPage->fsPageStyles,
465 BKA_LAST ) );
466
467 if( ulPageId )
468 {
469 /* Insert a pointer to this page's info into the space available */
470 /* in each page (its PAGE DATA that is available to the application).*/
471 fSuccess = (BOOL) WinSendMsg( hwndNB, BKM_SETPAGEDATA,
472 MPFROMLONG( ulPageId ),
473 MPFROMP( pPage ) );
474
475 /* Set the text into the status line. */
476 if( fSuccess )
477 {
478 if( pPage->fsPageStyles & BKA_STATUSTEXTON )
479 {
480 fSuccess = (BOOL) WinSendMsg( hwndNB, BKM_SETSTATUSLINETEXT,
481 MPFROMP( ulPageId ),
482 MPFROMP( pPage->szStatusLineText ) );
483 if( !fSuccess ) /* check errors */
484 ErrorMsg("BKM_SETSTATUSLINETEXT RC(%X)",
485 HWNDERR(hwndNB) );
486
487 }
488 }
489 else
490 ErrorMsg("BKM_SETPAGEDATA RC(%X)",
491 HWNDERR(hwndNB) );
492
493 // Set the text into the tab for this page.
494 if( fSuccess )
495 {
496 fSuccess = (BOOL) WinSendMsg(hwndNB,
497 BKM_SETTABTEXT,
498 MPFROMP(ulPageId),
499 MPFROMP(pPage->szTabText) );
500 if(!fSuccess) /* check errors */
501 ErrorMsg("BKM_SETTABTEXT RC(%X)",
502 HWNDERR( hwndNB ) );
503 }
504
505
506 // Create the dialog
507 if (fSuccess)
508 {
509 hwndPage = (HWND) WinSendMsg( hwndNB, BKM_QUERYPAGEWINDOWHWND,
510 MPFROMLONG( ulPageId ), NULL );
511 if( hwndPage == (HWND) BOOKERR_INVALID_PARAMETERS )
512 {
513 hwndPage = NULLHANDLE;
514 ErrorMsg( "NBSetUpPage BKM_QUERYPAGEWINDOWHWND Invalid page specified" );
515 }
516 else
517 if( !hwndPage )
518 {
519 /* load dialog from resource */
520 hwndPage = NBCreateDialogPage(hwndClient,
521 hwndNB,
522 hModule,
523 ulPageId,
524 pPage->ulID,
525 pPage->wpDlgProc,
526 pCreationParameters);
527 if (phwnd != NULL)
528 *phwnd = hwndPage; /* RckgabeHWND liefern */
529
530 if (hwndPage == NULLHANDLE)
531 {
532 fSuccess = FALSE;
533 ErrorMsg( "pPage-pfncreate failed. RC(%X)", HWNDERR( hwndNB ) );
534 }
535 }
536 }
537
538 }
539 else
540 ErrorMsg( "BKM_INSERTPAGE RC(%X)", HWNDERR( hwndNB ) );
541
542 return (fSuccess);
543}
544
545
546/**********************************************************************/
547/*---------------------------- SetFramePos ---------------------------*/
548/* */
549/* SET THE FRAME ORIGIN AND SIZE. */
550/* */
551/* INPUT: frame window handle */
552/* */
553/* 1. */
554/* */
555/* OUTPUT: TRUE or FALSE if successful or not */
556/* */
557/*--------------------------------------------------------------------*/
558/**********************************************************************/
559
560static BOOL NBSetFramePos( HWND hwndFrame )
561{
562 BOOL fSuccess;
563 POINTL aptl[ 2 ];
564
565 // Convert origin and size from dialog units to pixels. We need to do this
566 // because dialog boxes are automatically sized to the display. Since the
567 // notebook contains these dialogs it must size itself accordingly so the
568 // dialogs fit in the notebook.
569
570/* @@@PH ??? */
571#define FRAME_X 4 // In dialog units!
572#define FRAME_Y 4 // In dialog units!
573#define FRAME_CX 275 // In dialog units!
574#define FRAME_CY 210 // In dialog units!
575
576 aptl[ 0 ].x = FRAME_X;
577 aptl[ 0 ].y = FRAME_Y;
578 aptl[ 1 ].x = FRAME_CX;
579 aptl[ 1 ].y = FRAME_CY;
580
581 fSuccess = WinMapDlgPoints(HWND_DESKTOP,
582 aptl,
583 2,
584 TRUE );
585 if( fSuccess )
586 {
587 fSuccess = WinSetWindowPos(hwndFrame,
588 NULLHANDLE,
589 aptl[ 0 ].x,
590 aptl[ 0 ].y,
591 aptl[ 1 ].x,
592 aptl[ 1 ].y,
593 SWP_SIZE |
594 SWP_MOVE |
595 SWP_SHOW |
596 SWP_ACTIVATE );
597 if( !fSuccess )
598 ErrorMsg( "SetFramePos WinSetWindowPos RC(%X)",
599 HWNDERR( hwndFrame ) );
600 }
601 else
602 ErrorMsg( "WinMapDlgPoints RC(%X)",
603 HWNDERR( hwndFrame ) );
604
605 return fSuccess;
606}
607
608
609/**********************************************************************/
610/*------------------------- TurnToFirstPage --------------------------*/
611/* */
612/* TURN TO THE FIRST PAGE IN THE NOTEBOOK. */
613/* */
614/* INPUT: notebook window handle */
615/* */
616/* 1. */
617/* */
618/* OUTPUT: TRUE or FALSE if successful or not */
619/* */
620/*--------------------------------------------------------------------*/
621/**********************************************************************/
622
623static BOOL NBTurnToFirstPage( HWND hwndNB )
624{
625 ULONG ulFirstPage = 0;
626 BOOL fSuccess = TRUE;
627
628 ulFirstPage = (ULONG) WinSendMsg( hwndNB,
629 BKM_QUERYPAGEID,
630 NULL,
631 (MPARAM)BKA_FIRST );
632 if( ulFirstPage )
633 {
634 fSuccess = (ULONG) WinSendMsg(hwndNB,
635 BKM_TURNTOPAGE,
636 MPFROMLONG(ulFirstPage ),
637 NULL );
638 if( !fSuccess )
639 ErrorMsg( "TurnToFirstPage BKM_TURNTOPAGE RC(%X)", HWNDERR( hwndNB ) );
640
641 }
642 else
643 {
644 fSuccess = FALSE;
645 ErrorMsg( "TurnToFirstPage BKM_QUERYPAGEID RC(%X)", HWNDERR( hwndNB ) );
646 }
647
648 return fSuccess;
649}
650
651
652/**********************************************************************/
653/*-------------------------- SetTabDimensions ------------------------*/
654/* */
655/* SET THE DIMENSIONS OF THE NOTEBOOK TABS. */
656/* */
657/* INPUT: window handle of notebook control */
658/* */
659/* 1. */
660/* */
661/* OUTPUT: TRUE or FALSE if successful or not */
662/* */
663/*--------------------------------------------------------------------*/
664/**********************************************************************/
665
666static BOOL NBSetTabDimensions(HWND hwndNB)
667{
668 BOOL fSuccess = TRUE; /* success status of this function */
669 HPS hps = WinGetPS( hwndNB ); /* presentation space handle */
670 FONTMETRICS fm; /* data about current font */
671 INT iSize, /* width of tab text */
672 iLongestText = 0;
673 BOOKTEXT Booktext; /* booktext structure for tab text */
674 ULONG ulPageId; /* id of notebook page */
675
676 if( !hps )
677 {
678 ErrorMsg( "SetTabDimensions WinGetPS RC(%X)",
679 HWNDERR( hwndNB ) );
680 return FALSE;
681 }
682
683 (void) memset( &fm, 0, sizeof( FONTMETRICS ) );
684
685 // Calculate the height of a tab as the height of an average font character
686 // plus a margin value.
687
688 if( GpiQueryFontMetrics( hps, sizeof( FONTMETRICS ), &fm ) )
689 fm.lMaxBaselineExt += (TAB_HEIGHT_MARGIN * 2);
690 else
691 {
692 fm.lMaxBaselineExt = DEFAULT_NB_TAB_HEIGHT + (TAB_HEIGHT_MARGIN * 2);
693
694 ErrorMsg( "SetTabDimensions GpiQueryFontMetrics RC(%X)", HWNDERR( hwndNB ) );
695 }
696
697 // First setup the BOOKTEXT structure
698 Booktext.pString = (PSZ)malloc(256);
699 Booktext.textLen = 256;
700
701 // disable window update
702 WinEnableWindowUpdate (hwndNB,
703 FALSE);
704
705 // Calculate the longest tab text for both the MAJOR and MINOR pages
706 // this means to browse through all pages in the notebook and check
707 // out the largest tab text size.
708 ulPageId = (ULONG) WinSendMsg (hwndNB,
709 BKM_QUERYPAGEID,
710 NULL,
711 (MPARAM)BKA_FIRST);
712 while ( (ulPageId != NULLHANDLE) &&
713 (ulPageId != (ULONG)BOOKERR_INVALID_PARAMETERS) )
714 {
715 // query pointer to tab text data
716 WinSendMsg (hwndNB,
717 BKM_QUERYTABTEXT,
718 (MPARAM)ulPageId,
719 (MPARAM)&Booktext);
720
721 // determine largest tab text size
722 iSize = WinGetStringSize(hps,
723 Booktext.pString );
724 if( iSize > iLongestText )
725 iLongestText = iSize;
726
727 ulPageId = (ULONG) WinSendMsg (hwndNB, /* query the handle for the next */
728 BKM_QUERYPAGEID, /* notebook page */
729 MPFROMLONG( ulPageId ),
730 (MPARAM)BKA_NEXT);
731 }
732
733
734 free (Booktext.pString); /* free allocated resources */
735 WinReleasePS( hps );
736
737 // Add a margin amount to the longest tab text
738
739 if( iLongestText )
740 iLongestText += TAB_WIDTH_MARGIN;
741
742 // Set the tab dimensions for the MAJOR and MINOR pages. Note that the
743 // docs as of this writing say to use BKA_MAJOR and BKA_MINOR in mp2 but
744 // you really need BKA_MAJORTAB and BKA_MINORTAB.
745
746 if( iLongestText )
747 {
748 fSuccess = (BOOL) WinSendMsg(hwndNB,
749 BKM_SETDIMENSIONS,
750 MPFROM2SHORT(iLongestText,
751 (SHORT)fm.lMaxBaselineExt ),
752 MPFROMSHORT( BKA_MAJORTAB ) );
753 if( !fSuccess )
754 ErrorMsg("BKM_SETDIMENSIONS(MAJOR) RC(%X)",
755 HWNDERR( hwndNB ) );
756 }
757
758 // enable window update
759 WinEnableWindowUpdate (hwndNB,
760 TRUE);
761
762 return fSuccess;
763}
764
765
766/**********************************************************************/
767/*---------------------------- SetNBPage -----------------------------*/
768/* */
769/* SET THE TOP PAGE IN THE NOTEBOOK CONTROL. */
770/* */
771/* INPUT: client window handle, */
772/* pointer to the PAGESELECTNOTIFY struct */
773/* */
774/* 1. */
775/* */
776/* OUTPUT: nothing */
777/* */
778/*--------------------------------------------------------------------*/
779/**********************************************************************/
780
781static VOID NBSetNBPage(HWND hwndClient,
782 HMODULE hModule,
783 PPAGESELECTNOTIFY ppsn,
784 PVOID pCreationParameters)
785{
786 HWND hwndPage;
787
788 // Get a pointer to the page information that is associated with this page.
789 // It was stored in the page's PAGE DATA in the SetUpPage function.
790 PNBPAGE pnbp = (PNBPAGE) WinSendMsg(ppsn->hwndBook,
791 BKM_QUERYPAGEDATA,
792 MPFROMLONG(ppsn->ulPageIdNew ),
793 NULL );
794
795 if( !pnbp )
796 return;
797 else
798 if( (MRESULT)pnbp == (MRESULT)BOOKERR_INVALID_PARAMETERS )
799 {
800 ErrorMsg( "SetNBPage BKM_QUERYPAGEDATA Invalid page id" );
801 return;
802 }
803
804 // If this is a BKA_MAJOR page and it is what this app terms a 'parent'
805 // page, that means when the user selects this page we actually want to go
806 // to its first MINOR page. So in effect the MAJOR page is just a dummy page
807 // that has a tab that acts as a placeholder for its MINOR pages. If the
808 // user is using the left arrow to scroll thru the pages and they hit this
809 // dummy MAJOR page, that means they have already been to its MINOR pages in
810 // reverse order. They would now expect to see the page before the dummy
811 // MAJOR page, so we skip the dummy page. Otherwise the user is going the
812 // other way and wants to see the first MINOR page associated with this
813 // 'parent' page so we skip the dummy page and show its first MINOR page.
814
815 if( pnbp->fParent )
816 {
817 ULONG ulPageFwd, ulPageNew;
818
819 ulPageFwd = (ULONG) WinSendMsg(ppsn->hwndBook,
820 BKM_QUERYPAGEID,
821 MPFROMLONG( ppsn->ulPageIdNew ),
822 MPFROM2SHORT(BKA_NEXT,
823 BKA_MINOR ) );
824
825 // If this is true, the user is going in reverse order
826 if( ulPageFwd == ppsn->ulPageIdCur )
827 ulPageNew = (ULONG) WinSendMsg(ppsn->hwndBook,
828 BKM_QUERYPAGEID,
829 MPFROMLONG(ppsn->ulPageIdNew ),
830 MPFROM2SHORT(BKA_PREV,
831 BKA_MAJOR) );
832 else
833 ulPageNew = ulPageFwd;
834 if( ulPageNew == (ULONG) BOOKERR_INVALID_PARAMETERS )
835 ErrorMsg( "SetNBPage BKM_QUERYPAGEID Invalid page specified" );
836 else
837 if( ulPageNew )
838 if( !WinSendMsg(ppsn->hwndBook,
839 BKM_TURNTOPAGE,
840 MPFROMLONG( ulPageNew ),
841 NULL ) )
842 ErrorMsg("BKM_TURNTOPAGE RC(%X)",
843 HWNDERR( ppsn->hwndBook ) );
844 }
845 else
846 {
847 hwndPage = (HWND) WinSendMsg(ppsn->hwndBook,
848 BKM_QUERYPAGEWINDOWHWND,
849 MPFROMLONG(ppsn->ulPageIdNew ),
850 NULL );
851 if( hwndPage == (HWND) BOOKERR_INVALID_PARAMETERS )
852 {
853 hwndPage = NULLHANDLE;
854 ErrorMsg( "SetNBPage BKM_QUERYPAGEWINDOWHWND Invalid page specified" );
855 }
856 else
857 if( !hwndPage )
858
859 // It is time to load this dialog because the user has flipped pages
860 // to a page that hasn't yet had the dialog associated with it.
861 hwndPage = NBCreateDialogPage(hwndClient,
862 ppsn->hwndBook,
863 hModule,
864 ppsn->ulPageIdNew,
865 pnbp->ulID,
866 pnbp->wpDlgProc,
867 pCreationParameters);
868 }
869
870 // Set focus to the first control in the dialog. This is not automatically
871 // done by the notebook.
872 if( !pnbp->fParent && hwndPage )
873 if(!WinSetFocus(HWND_DESKTOP,
874 pnbp->idFocus ?
875 WinWindowFromID(hwndPage,
876 pnbp->idFocus ) : hwndPage ) )
877 {
878 // Bug in 2.0! Developers left some debug code in there!
879 USHORT usErr = HWNDERR( ppsn->hwndBook );
880 ErrorMsg("SetNBPage WinSetFocus RC(%X)",
881 usErr );
882 }
883
884 return;
885}
886
887
888/**********************************************************************/
889/*------------------------ CreateDialogPage --------------------------*/
890/* */
891/* LOAD DIALOG AND ASSOCIATE IT WITH A NOTEBOOK PAGE */
892/* */
893/* INPUT: window handle of parent and owner, */
894/* notebook window handle, */
895/* notebook page ID */
896/* dialog resource ID */
897/* dialog window procedure */
898/* */
899/* 1. */
900/* */
901/* OUTPUT: client window handle */
902/* */
903/*--------------------------------------------------------------------*/
904/**********************************************************************/
905
906static HWND NBCreateDialogPage(HWND hwndParent,
907 HWND hwndNB,
908 HMODULE hModule,
909 ULONG ulPageID,
910 ULONG idDlg,
911 FNWP fpDlg,
912 PVOID pCreationParameters)
913{
914 HWND hwndDlg;
915
916
917 if (fpDlg == NULL) /* Parameterberprfung */
918 return (NULLHANDLE); /* Fehler signalisieren */
919
920 hwndDlg = WinLoadDlg( hwndParent,
921 hwndParent,
922 fpDlg,
923 hModule,
924 idDlg,
925 pCreationParameters);
926
927 if( hwndDlg ) /* check for valid window handle */
928 {
929 if( !WinSendMsg(hwndNB, /* attach hwnd to page */
930 BKM_SETPAGEWINDOWHWND,
931 MPFROMLONG( ulPageID ),
932 MPFROMLONG( hwndDlg ) ) )
933 {
934 WinDestroyWindow( hwndDlg ); /* destroy if attach failed */
935 hwndDlg = NULLHANDLE;
936 ErrorMsg( "NBCreateDialogPage SETPAGEWINDOWHWND RC(%X)",
937 HWNDERR( hwndNB ) );
938 }
939 }
940 else
941 ErrorMsg( "NBCreateDialogPage WinLoadDlg RC(%X)", HWNDERR( hwndNB ) );
942
943 return hwndDlg;
944}
945
946
947/*****************************************************************************
948 * Name : BOOL NBSetTabText
949 * Funktion : Setzt Tabtext einer Seite.
950 * Parameter : HWND hwndNB, ULONG ulPageId, PSZ pszTabtext
951 * Variablen :
952 * Ergebnis : Erfolgscode
953 * Bemerkung :
954 *
955 * Autor : Patrick Haller [, 24.09.1995 02.57.00]
956 *****************************************************************************/
957
958static BOOL NBSetTabText (HWND hwndNB,
959 ULONG ulPageId,
960 PSZ pszTabtext)
961{
962 BOOL fSuccess;
963
964 if (pszTabtext == NULL) /* Parameterberprfung */
965 return (FALSE);
966
967 fSuccess = (BOOL) WinSendMsg(hwndNB,
968 BKM_SETTABTEXT,
969 MPFROMP( ulPageId ),
970 MPFROMP( pszTabtext ) );
971 if( !fSuccess )
972 ErrorMsg("NBSetTabText::BKM_SETTABTEXT RC(%X)",
973 HWNDERR( hwndNB ) );
974
975 return (fSuccess); /* Rckgabewert liefern */
976} /* BOOL NBSetTabText */
977
978
979/***********************************************************************
980 * Name : BOOL NBSetStatuslineText
981 * Funktion : Setzt Statuslinetext einer Seite.
982 * Parameter : HWND hwndNB, ULONG ulPageId, PSZ pszStatuslinetext
983 * Variablen :
984 * Ergebnis : Erfolgscode
985 * Bemerkung :
986 *
987 * Autor : Patrick Haller [, 24.09.1995 02.57.00]
988 ***********************************************************************/
989
990static BOOL NBSetStatuslineText (HWND hwndNB,
991 ULONG ulPageId,
992 PSZ pszStatuslinetext)
993{
994 BOOL fSuccess;
995
996 if (pszStatuslinetext == NULL) /* Parameterberprfung */
997 return (FALSE);
998
999 fSuccess = (BOOL) WinSendMsg( hwndNB, BKM_SETSTATUSLINETEXT,
1000 MPFROMP( ulPageId ),
1001 MPFROMP( pszStatuslinetext ) );
1002 if( !fSuccess )
1003 ErrorMsg( "BKM_SETSTATUSLINETEXT RC(%X)", HWNDERR( hwndNB ) );
1004 return (fSuccess); /* Rckgabewert liefern */
1005} /* BOOL NBSetStatuslineText */
1006
1007
1008/***********************************************************************
1009 * Name : status MRESULT EXPENTRY wpDlgProcPage1
1010 * Funktion : dialog window procedure
1011 * Parameter : HWND hwnd
1012 * ULONG ulMessage
1013 * MPARAM mp1
1014 * MPARAM mp2
1015 * Variablen :
1016 * Ergebnis : MRESULT
1017 * Bemerkung :
1018 *
1019 * Autor : Patrick Haller [, 24.09.1995 02.57.00]
1020 ***********************************************************************/
1021
1022static MRESULT EXPENTRY wpDlgProcPage1(HWND hwnd,
1023 ULONG ulMessage,
1024 MPARAM mp1,
1025 MPARAM mp2)
1026{
1027 switch (ulMessage)
1028 {
1029 /*************************************************************************
1030 * user messages *
1031 *************************************************************************/
1032
1033 case UM_PROPERTY_UNDO:
1034 {
1035 PCONSOLEOPTIONS pOpt = (PCONSOLEOPTIONS)mp1; /* get pointer */
1036
1037 ConPropPage1Set(hwnd, /* set values */
1038 pOpt);
1039
1040 return ( (MPARAM) FALSE);
1041 }
1042
1043
1044 case UM_PROPERTY_APPLY:
1045 {
1046 PCONSOLEOPTIONS pOpt = (PCONSOLEOPTIONS)mp1; /* get pointer */
1047
1048 pOpt->fTerminateAutomatically = WinQueryButtonCheckstate(hwnd,
1049 CB_CONSOLE_CLOSEWINDOWONEXIT);
1050 pOpt->fInsertMode = WinQueryButtonCheckstate(hwnd,
1051 CB_CONSOLE_INSERTMODE);
1052 pOpt->fQuickInsert = WinQueryButtonCheckstate(hwnd,
1053 CB_CONSOLE_QUICKINSERT);
1054 pOpt->fToolbarActive = WinQueryButtonCheckstate(hwnd,
1055 CB_CONSOLE_TOOLBAR);
1056
1057 WinSendDlgItemMsg(hwnd, /* query the value */
1058 SPN_CONSOLE_TAB,
1059 SPBM_QUERYVALUE,
1060 MPFROMP(&pOpt->ulTabSize),
1061 MPFROM2SHORT(0,SPBQ_ALWAYSUPDATE)
1062 );
1063
1064 WinSendDlgItemMsg(hwnd, /* query the value */
1065 SPN_CONSOLE_CURSORBLINK,
1066 SPBM_QUERYVALUE,
1067 MPFROMP(&pOpt->ucCursorDivisor),
1068 MPFROM2SHORT(0,SPBQ_ALWAYSUPDATE)
1069 );
1070
1071 return ( (MPARAM) FALSE);
1072 }
1073 }
1074
1075
1076 return WinDefDlgProc(hwnd, /* default message processing */
1077 ulMessage,
1078 mp1,
1079 mp2);
1080}
1081
1082
1083/***********************************************************************
1084 * Name : status MRESULT EXPENTRY wpDlgProcPage2
1085 * Funktion : dialog window procedure
1086 * Parameter : HWND hwnd
1087 * ULONG ulMessage
1088 * MPARAM mp1
1089 * MPARAM mp2
1090 * Variablen :
1091 * Ergebnis : MRESULT
1092 * Bemerkung :
1093 *
1094 * Autor : Patrick Haller [, 24.09.1995 02.57.00]
1095 ***********************************************************************/
1096
1097static MRESULT EXPENTRY wpDlgProcPage2(HWND hwnd,
1098 ULONG ulMessage,
1099 MPARAM mp1,
1100 MPARAM mp2)
1101{
1102 switch (ulMessage)
1103 {
1104 /*************************************************************************
1105 * user messages *
1106 *************************************************************************/
1107
1108 case UM_PROPERTY_UNDO:
1109 {
1110 PCONSOLEOPTIONS pOpt = (PCONSOLEOPTIONS)mp1; /* get pointer */
1111
1112 ConPropPage2Set(hwnd, /* set values */
1113 pOpt);
1114
1115 return ( (MPARAM) FALSE);
1116 }
1117
1118
1119 case UM_PROPERTY_APPLY:
1120 {
1121 PCONSOLEOPTIONS pOpt = (PCONSOLEOPTIONS)mp1; /* get pointer */
1122
1123// pOpt->fTerminateAutomatically = WinQueryButtonCheckstate(hwnd,
1124// CB_CONSOLE_CLOSEWINDOWONEXIT);
1125
1126 return ( (MPARAM) FALSE);
1127 }
1128 }
1129
1130
1131 return WinDefDlgProc(hwnd, /* default message processing */
1132 ulMessage,
1133 mp1,
1134 mp2);
1135}
1136
1137
1138/***********************************************************************
1139 * Name : status MRESULT EXPENTRY wpDlgProcPage3
1140 * Funktion : dialog window procedure
1141 * Parameter : HWND hwnd
1142 * ULONG ulMessage
1143 * MPARAM mp1
1144 * MPARAM mp2
1145 * Variablen :
1146 * Ergebnis : MRESULT
1147 * Bemerkung :
1148 *
1149 * Autor : Patrick Haller [, 24.09.1995 02.57.00]
1150 ***********************************************************************/
1151
1152static MRESULT EXPENTRY wpDlgProcPage3(HWND hwnd,
1153 ULONG ulMessage,
1154 MPARAM mp1,
1155 MPARAM mp2)
1156{
1157 switch (ulMessage)
1158 {
1159 /*************************************************************************
1160 * user messages *
1161 *************************************************************************/
1162
1163 case UM_PROPERTY_UNDO:
1164 {
1165 PCONSOLEOPTIONS pOpt = (PCONSOLEOPTIONS)mp1; /* get pointer */
1166
1167 ConPropPage3Set(hwnd, /* set values */
1168 pOpt);
1169
1170 return ( (MPARAM) FALSE);
1171 }
1172
1173
1174 case UM_PROPERTY_APPLY:
1175 {
1176 PCONSOLEOPTIONS pOpt = (PCONSOLEOPTIONS)mp1; /* get pointer */
1177
1178// pOpt->fTerminateAutomatically = WinQueryButtonCheckstate(hwnd,
1179// CB_CONSOLE_CLOSEWINDOWONEXIT);
1180
1181 return ( (MPARAM) FALSE);
1182 }
1183 }
1184
1185
1186 return WinDefDlgProc(hwnd, /* default message processing */
1187 ulMessage,
1188 mp1,
1189 mp2);
1190}
1191
1192
1193/***********************************************************************
1194 * Name : status MRESULT EXPENTRY wpDlgProcPage4
1195 * Funktion : dialog window procedure
1196 * Parameter : HWND hwnd
1197 * ULONG ulMessage
1198 * MPARAM mp1
1199 * MPARAM mp2
1200 * Variablen :
1201 * Ergebnis : MRESULT
1202 * Bemerkung :
1203 *
1204 * Autor : Patrick Haller [, 24.09.1995 02.57.00]
1205 ***********************************************************************/
1206
1207static MRESULT EXPENTRY wpDlgProcPage4(HWND hwnd,
1208 ULONG ulMessage,
1209 MPARAM mp1,
1210 MPARAM mp2)
1211{
1212 switch (ulMessage)
1213 {
1214 /*************************************************************************
1215 * user messages *
1216 *************************************************************************/
1217
1218 case UM_PROPERTY_UNDO:
1219 {
1220 PCONSOLEOPTIONS pOpt = (PCONSOLEOPTIONS)mp1; /* get pointer */
1221
1222 ConPropPage4Set(hwnd, /* set values */
1223 pOpt);
1224
1225 return ( (MPARAM) FALSE);
1226 }
1227
1228
1229 case UM_PROPERTY_APPLY:
1230 {
1231 PCONSOLEOPTIONS pOpt = (PCONSOLEOPTIONS)mp1; /* get pointer */
1232
1233// pOpt->fTerminateAutomatically = WinQueryButtonCheckstate(hwnd,
1234// CB_CONSOLE_CLOSEWINDOWONEXIT);
1235
1236 return ( (MPARAM) FALSE);
1237 }
1238 }
1239
1240
1241 return WinDefDlgProc(hwnd, /* default message processing */
1242 ulMessage,
1243 mp1,
1244 mp2);
1245}
1246
1247
1248/***********************************************************************
1249 * Name : status MRESULT EXPENTRY wpDlgProcPage5
1250 * Funktion : dialog window procedure
1251 * Parameter : HWND hwnd
1252 * ULONG ulMessage
1253 * MPARAM mp1
1254 * MPARAM mp2
1255 * Variablen :
1256 * Ergebnis : MRESULT
1257 * Bemerkung :
1258 *
1259 * Autor : Patrick Haller [, 24.09.1995 02.57.00]
1260 ***********************************************************************/
1261
1262static MRESULT EXPENTRY wpDlgProcPage5(HWND hwnd,
1263 ULONG ulMessage,
1264 MPARAM mp1,
1265 MPARAM mp2)
1266{
1267 switch (ulMessage)
1268 {
1269 /*************************************************************************
1270 * user messages *
1271 *************************************************************************/
1272
1273 case UM_PROPERTY_UNDO:
1274 {
1275 PCONSOLEOPTIONS pOpt = (PCONSOLEOPTIONS)mp1; /* get pointer */
1276
1277 ConPropPage5Set(hwnd, /* set values */
1278 pOpt);
1279
1280 return ( (MPARAM) FALSE);
1281 }
1282
1283
1284 case UM_PROPERTY_APPLY:
1285 {
1286 PCONSOLEOPTIONS pOpt = (PCONSOLEOPTIONS)mp1; /* get pointer */
1287
1288// pOpt->fTerminateAutomatically = WinQueryButtonCheckstate(hwnd,
1289// CB_CONSOLE_CLOSEWINDOWONEXIT);
1290
1291 return ( (MPARAM) FALSE);
1292 }
1293 }
1294
1295
1296 return WinDefDlgProc(hwnd, /* default message processing */
1297 ulMessage,
1298 mp1,
1299 mp2);
1300}
1301
1302
1303/***********************************************************************
1304 * Name : status MRESULT EXPENTRY wpDlgProcPage6
1305 * Funktion : dialog window procedure
1306 * Parameter : HWND hwnd
1307 * ULONG ulMessage
1308 * MPARAM mp1
1309 * MPARAM mp2
1310 * Variablen :
1311 * Ergebnis : MRESULT
1312 * Bemerkung :
1313 *
1314 * Autor : Patrick Haller [, 24.09.1995 02.57.00]
1315 ***********************************************************************/
1316
1317static MRESULT EXPENTRY wpDlgProcPage6(HWND hwnd,
1318 ULONG ulMessage,
1319 MPARAM mp1,
1320 MPARAM mp2)
1321{
1322 /* since this dialog has no options, we're running the default message */
1323 /* processing only */
1324 /* we'll display a logo bitmap here shortly @@@PH */
1325
1326 return WinDefDlgProc(hwnd, /* default message processing */
1327 ulMessage,
1328 mp1,
1329 mp2);
1330}
1331
1332
1333/**********************************************************************/
1334/*-------------------------- GetStringSize ---------------------------*/
1335/* */
1336/* GET THE SIZE IN PIXELS OF A STRING. */
1337/* */
1338/* INPUT: presentation space handle, */
1339/* notebook window handle, */
1340/* pointer to string */
1341/* */
1342/* 1. */
1343/* */
1344/* OUTPUT: nothing */
1345/* */
1346/*--------------------------------------------------------------------*/
1347/**********************************************************************/
1348
1349static INT WinGetStringSize(HPS hps,
1350 PSZ szString )
1351{
1352 POINTL aptl[ TXTBOX_COUNT ];
1353
1354 if (szString == NULL) /* Parameterberprfung */
1355 return 0; /* Im Fehlerfall wird 0 zurckgegeben */
1356
1357
1358 /* Get the size, in pixels, of the string passed. */
1359 if( !GpiQueryTextBox( hps,
1360 strlen( szString ),
1361 szString,
1362 TXTBOX_COUNT,
1363 aptl ) )
1364 return 0; /* Im Fehlerfall wird 0 zurckgegeben */
1365 else
1366 return aptl[ TXTBOX_CONCAT ].x;
1367}
1368
1369
1370/*****************************************************************************
1371 * Name : static APIRET ConPropPage1Set
1372 * Funktion : setup dialog elements for page 1
1373 * Parameter :
1374 * Variablen :
1375 * Ergebnis : MRESULT
1376 * Bemerkung :
1377 *
1378 * Autor : Patrick Haller [1998/04/02 19:00]
1379 *****************************************************************************/
1380
1381static APIRET ConPropPage1Set(HWND hwndDlg,
1382 PCONSOLEOPTIONS pConsoleOptions)
1383{
1384 if (pConsoleOptions == NULL) /* check parameters */
1385 return (ERROR_INVALID_PARAMETER); /* raise error condition */
1386
1387 WinCheckButton(hwndDlg, /* auto-termination */
1388 CB_CONSOLE_CLOSEWINDOWONEXIT,
1389 pConsoleOptions->fTerminateAutomatically);
1390
1391 WinCheckButton(hwndDlg, /* insert mode */
1392 CB_CONSOLE_INSERTMODE,
1393 pConsoleOptions->fInsertMode);
1394
1395 WinCheckButton(hwndDlg, /* quick insert mode */
1396 CB_CONSOLE_QUICKINSERT,
1397 pConsoleOptions->fQuickInsert);
1398
1399 WinCheckButton(hwndDlg, /* console toolbar */
1400 CB_CONSOLE_TOOLBAR,
1401 pConsoleOptions->fToolbarActive);
1402
1403 /* set spin limits for the SPN_CONSOLE_TAB spinbutton */
1404 WinSendDlgItemMsg(hwndDlg,
1405 SPN_CONSOLE_TAB,
1406 SPBM_SETLIMITS,
1407 MPFROMSHORT(80),
1408 MPFROMSHORT(0));
1409
1410 WinSendDlgItemMsg (hwndDlg, /* set current value */
1411 SPN_CONSOLE_TAB,
1412 SPBM_SETCURRENTVALUE,
1413 MPFROMLONG(pConsoleOptions->ulTabSize),
1414 0);
1415
1416 /* set spin limits for the SPN_CONSOLE_CURSORBLINK spinbutton */
1417 WinSendDlgItemMsg(hwndDlg,
1418 SPN_CONSOLE_CURSORBLINK,
1419 SPBM_SETLIMITS,
1420 MPFROMSHORT(100),
1421 MPFROMSHORT(1));
1422
1423 WinSendDlgItemMsg (hwndDlg, /* set current value */
1424 SPN_CONSOLE_CURSORBLINK,
1425 SPBM_SETCURRENTVALUE,
1426 MPFROMLONG(pConsoleOptions->ucCursorDivisor),
1427 0);
1428
1429 return (NO_ERROR); /* OK */
1430}
1431
1432/*****************************************************************************
1433 * Name : static APIRET ConPropPage2Set
1434 * Funktion : setup dialog elements for page 2
1435 * Parameter :
1436 * Variablen :
1437 * Ergebnis : MRESULT
1438 * Bemerkung :
1439 *
1440 * Autor : Jochen Schaeuble [1998/04/29 23:20]
1441 *****************************************************************************/
1442
1443static APIRET ConPropPage2Set(HWND hwndDlg,
1444 PCONSOLEOPTIONS pConsoleOptions)
1445{
1446 int i;
1447 WNDPARAMS wp;
1448 SLDCDATA slcd;
1449
1450 if (pConsoleOptions == NULL) /* check parameters */
1451 return (ERROR_INVALID_PARAMETER); /* raise error condition */
1452
1453 WinCheckButton(hwndDlg, /* Enable speaker */
1454 CB_CONSOLE_SPEAKERENABLE,
1455 pConsoleOptions->fSpeakerEnabled);
1456
1457 /* frequency slider */
1458 slcd.cbSize = sizeof(SLDCDATA);
1459 wp.pCtlData = &slcd;
1460
1461 WinSendDlgItemMsg(hwndDlg,
1462 SLB_CONSOLE_SPEAKERFREQUENCY,
1463 WM_QUERYWINDOWPARAMS,
1464 (MPARAM)&wp,
1465 NULL);
1466
1467 slcd.usScale1Increments=9;
1468 slcd.usScale1Spacing=0;
1469
1470 WinSendDlgItemMsg(hwndDlg,
1471 SLB_CONSOLE_SPEAKERFREQUENCY,
1472 WM_SETWINDOWPARAMS,
1473 (MPARAM)&wp,
1474 NULL);
1475
1476 WinSendDlgItemMsg(hwndDlg,
1477 SLB_CONSOLE_SPEAKERFREQUENCY,
1478 SLM_SETTICKSIZE,
1479 MPFROM2SHORT(SMA_SETALLTICKS, 40),
1480 NULL);
1481
1482 /* duration slider */
1483 slcd.cbSize = sizeof(SLDCDATA);
1484 wp.pCtlData = &slcd;
1485
1486 WinSendDlgItemMsg(hwndDlg,
1487 SLB_CONSOLE_SPEAKERDURATION,
1488 WM_QUERYWINDOWPARAMS,
1489 (MPARAM)&wp,
1490 NULL);
1491
1492 slcd.usScale1Increments=9;
1493 slcd.usScale1Spacing=0;
1494
1495 WinSendDlgItemMsg(hwndDlg,
1496 SLB_CONSOLE_SPEAKERDURATION,
1497 WM_SETWINDOWPARAMS,
1498 (MPARAM)&wp,
1499 NULL);
1500
1501 WinSendDlgItemMsg(hwndDlg,
1502 SLB_CONSOLE_SPEAKERDURATION,
1503 SLM_SETTICKSIZE,
1504 MPFROM2SHORT(SMA_SETALLTICKS, 40),
1505 NULL);
1506
1507
1508 return (NO_ERROR); /* OK */
1509}
1510
1511/*****************************************************************************
1512 * Name : static APIRET ConPropPage3Set
1513 * Funktion : setup dialog elements for page 3
1514 * Parameter :
1515 * Variablen :
1516 * Ergebnis : MRESULT
1517 * Bemerkung :
1518 *
1519 * Autor : Jochen Schaeuble [1998/04/29 23:20]
1520 *****************************************************************************/
1521
1522static APIRET ConPropPage3Set(HWND hwndDlg,
1523 PCONSOLEOPTIONS pConsoleOptions)
1524{
1525 if (pConsoleOptions == NULL) /* check parameters */
1526 return (ERROR_INVALID_PARAMETER); /* raise error condition */
1527
1528 /* setup check-button */
1529
1530
1531 WinCheckButton(hwndDlg, /* Override default */
1532 CB_CONSOLE_WINDOWPOSITION,
1533 pConsoleOptions->fSetWindowPosition);
1534
1535 /* setup limits for spin-buttons */
1536
1537 WinSendDlgItemMsg(hwndDlg,
1538 SPN_CONSOLE_X,
1539 SPBM_SETLIMITS,
1540 MPFROMSHORT(WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN)-1),
1541 MPFROMSHORT(0));
1542
1543 WinSendDlgItemMsg(hwndDlg,
1544 SPN_CONSOLE_Y,
1545 SPBM_SETLIMITS,
1546 MPFROMSHORT(WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN)-1),
1547 MPFROMSHORT(0));
1548
1549 WinSendDlgItemMsg(hwndDlg,
1550 SPN_CONSOLE_DEFAULTWIDTH,
1551 SPBM_SETLIMITS,
1552 MPFROMSHORT(WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN)-1),
1553 MPFROMSHORT(0));
1554
1555 WinSendDlgItemMsg(hwndDlg,
1556 SPN_CONSOLE_DEFAULTHEIGHT,
1557 SPBM_SETLIMITS,
1558 MPFROMSHORT(WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN)-1),
1559 MPFROMSHORT(0));
1560
1561 /* setup active values */
1562
1563 WinSendDlgItemMsg(hwndDlg,
1564 SPN_CONSOLE_X,
1565 SPBM_SETCURRENTVALUE,
1566 MPFROMLONG(pConsoleOptions->coordDefaultPosition.X),
1567 0);
1568
1569 WinSendDlgItemMsg(hwndDlg,
1570 SPN_CONSOLE_Y,
1571 SPBM_SETCURRENTVALUE,
1572 MPFROMLONG(pConsoleOptions->coordDefaultPosition.Y),
1573 0);
1574
1575 WinSendDlgItemMsg(hwndDlg,
1576 SPN_CONSOLE_DEFAULTWIDTH,
1577 SPBM_SETCURRENTVALUE,
1578 MPFROMLONG(pConsoleOptions->coordDefaultPosition.X),
1579 0);
1580
1581 WinSendDlgItemMsg(hwndDlg,
1582 SPN_CONSOLE_DEFAULTHEIGHT,
1583 SPBM_SETCURRENTVALUE,
1584 MPFROMLONG(pConsoleOptions->coordDefaultPosition.Y),
1585 0);
1586
1587 return (NO_ERROR); /* OK */
1588}
1589
1590
1591/*****************************************************************************
1592 * Name : static APIRET ConPropPage4Set
1593 * Funktion : setup dialog elements for page 4
1594 * Parameter :
1595 * Variablen :
1596 * Ergebnis : MRESULT
1597 * Bemerkung :
1598 *
1599 * Autor : Patrick Haller [1998/06/13 23:20]
1600 *****************************************************************************/
1601
1602static APIRET ConPropPage4Set(HWND hwndDlg,
1603 PCONSOLEOPTIONS pConsoleOptions)
1604{
1605 ULONG ulColor; /* loop counter for the colors */
1606 ULONG ulRow;
1607 ULONG ulColumn;
1608
1609#define MAX_TRANSCOLORS 16
1610 static const ULONG TabColorTranslation[MAX_TRANSCOLORS] =
1611 { /* RRGGBB */
1612 /* 1 */ 0x00000000,
1613 /* 2 */ 0x0000007f,
1614 /* 3 */ 0x00007f00,
1615 /* 4 */ 0x007f0000,
1616 /* 5 */ 0x00007f7f,
1617 /* 6 */ 0x007f007f,
1618 /* 7 */ 0x007f7f00,
1619 /* 8 */ 0x007f7f7f,
1620 /* 9 */ 0x00808080,
1621 /* 10 */ 0x008080ff,
1622 /* 11 */ 0x0080ff80,
1623 /* 12 */ 0x00ff8080,
1624 /* 13 */ 0x0080ffff,
1625 /* 14 */ 0x00ff80ff,
1626 /* 15 */ 0x00ffff80,
1627 /* 16 */ 0x00ffffff
1628 };
1629
1630
1631 if (pConsoleOptions == NULL) /* check parameters */
1632 return (ERROR_INVALID_PARAMETER); /* raise error condition */
1633
1634 /* setup the value sets */
1635 for (ulColor = 0;
1636 ulColor < MAX_TRANSCOLORS;
1637 ulColor++)
1638 {
1639 ulRow = 1 + (ulColor & 0x01); /* calculate field index */
1640 ulColumn = 1 + (ulColor >> 1);
1641
1642 /* foreground */
1643 WinSendDlgItemMsg (hwndDlg,
1644 VS_CONSOLE_FOREGROUND,
1645 VM_SETITEMATTR,
1646 MPFROM2SHORT(ulRow, ulColumn),
1647 MPFROM2SHORT(VIA_RGB, TRUE) );
1648
1649 WinSendDlgItemMsg (hwndDlg,
1650 VS_CONSOLE_FOREGROUND,
1651 VM_SETITEM,
1652 MPFROM2SHORT(ulRow, ulColumn),
1653 (MPARAM) TabColorTranslation[ulColor] );
1654
1655 /* background */
1656 WinSendDlgItemMsg (hwndDlg,
1657 VS_CONSOLE_BACKGROUND,
1658 VM_SETITEMATTR,
1659 MPFROM2SHORT(ulRow, ulColumn),
1660 MPFROM2SHORT(VIA_RGB, TRUE) );
1661
1662 WinSendDlgItemMsg (hwndDlg,
1663 VS_CONSOLE_BACKGROUND,
1664 VM_SETITEM,
1665 MPFROM2SHORT(ulRow, ulColumn),
1666 (MPARAM) TabColorTranslation[ulColor] );
1667 }
1668
1669
1670 /* @@@PH fonts */
1671
1672 return (NO_ERROR); /* OK */
1673}
1674
1675
1676/*****************************************************************************
1677 * Name : static APIRET ConPropPage5Set
1678 * Funktion : setup dialog elements for page 5
1679 * Parameter :
1680 * Variablen :
1681 * Ergebnis : MRESULT
1682 * Bemerkung :
1683 *
1684 * Autor : Jochen Schaeuble [1998/04/29 23:20]
1685 *****************************************************************************/
1686
1687static APIRET ConPropPage5Set(HWND hwndDlg,
1688 PCONSOLEOPTIONS pConsoleOptions)
1689{
1690 if (pConsoleOptions == NULL) /* check parameters */
1691 return (ERROR_INVALID_PARAMETER); /* raise error condition */
1692// #define PRTYC_NOCHANGE 0
1693// #define PRTYC_IDLETIME 1
1694// #define PRTYC_REGULAR 2
1695// #define PRTYC_TIMECRITICAL 3
1696// #define PRTYC_FOREGROUNDSERVER 4
1697
1698// /* Priority deltas */
1699
1700// #define PRTYD_MINIMUM -31
1701// #define PRTYD_MAXIMUM 31
1702 /* setup application-priorities */
1703
1704 WinSendDlgItemMsg(hwndDlg,
1705 SPN_CONSOLE_APPPRIORITY,
1706 SPBM_SETARRAY,
1707 priorities,
1708 MPFROMLONG(NUMPRIORITIES));
1709
1710 WinSendDlgItemMsg(hwndDlg,
1711 SPN_CONSOLE_APPPRIORITY,
1712 SPBM_SETCURRENTVALUE,
1713 MPFROMLONG(pConsoleOptions->ulConsoleThreadPriorityClass-1),
1714 NULL);
1715
1716 WinSendDlgItemMsg(hwndDlg,
1717 SPN_CONSOLE_APPPRIODELTA,
1718 SPBM_SETLIMITS,
1719 MPFROMSHORT(PRTYD_MAXIMUM),
1720 MPFROMSHORT(0));
1721
1722
1723 WinSendDlgItemMsg(hwndDlg, /* set current value */
1724 SPN_CONSOLE_APPPRIODELTA,
1725 SPBM_SETCURRENTVALUE,
1726 MPFROMLONG(0),
1727 0);
1728
1729 /* setup console-priorities */
1730
1731 WinSendDlgItemMsg(hwndDlg,
1732 SPN_CONSOLE_CONSOLEPRIORITY,
1733 SPBM_SETARRAY,
1734 priorities,
1735 MPFROMLONG(NUMPRIORITIES));
1736
1737 WinSendDlgItemMsg(hwndDlg,
1738 SPN_CONSOLE_CONSOLEPRIORITY,
1739 SPBM_SETCURRENTVALUE,
1740 MPFROMLONG(pConsoleOptions->ulConsoleThreadPriorityClass-1),
1741 NULL);
1742
1743 WinSendDlgItemMsg(hwndDlg,
1744 SPN_CONSOLE_CONSOLEPRIODELTA,
1745 SPBM_SETLIMITS,
1746 MPFROMSHORT(PRTYD_MAXIMUM),
1747 MPFROMSHORT(0));
1748
1749
1750 WinSendDlgItemMsg(hwndDlg, /* set current value */
1751 SPN_CONSOLE_CONSOLEPRIODELTA,
1752 SPBM_SETCURRENTVALUE,
1753 MPFROMLONG(0),
1754 0);
1755
1756 WinSendDlgItemMsg(hwndDlg,
1757 SPN_CONSOLE_UPDATELIMIT,
1758 SPBM_SETLIMITS,
1759 MPFROMSHORT(50),
1760 MPFROMSHORT(0));
1761
1762 return (NO_ERROR); /* OK */
1763}
1764
1765
1766
1767
1768
1769
1770
1771
1772#if 0
1773typedef struct _Options
1774{
1775 HMODULE hmodResources; /* module handle for PM resources */
1776
1777 BOOL fSpeakerEnabled; /* whether we process BEL 0x07 or not */
1778 ULONG ulSpeakerDuration; /* duration and frequency for speaker beep */
1779 ULONG ulSpeakerFrequency;
1780 ULONG ulUpdateLimit; /* when exceeding this line counter, automatic */
1781 /* screen update is performed */
1782
1783 BOOL fSetWindowPosition; /* TRUE if window has to be positioned */
1784
1785 COORD coordDefaultPosition;
1786 COORD coordDefaultSize;
1787
1788 BOOL fMouseActions; /* like Warp 4's "mouse action" mode */
1789
1790 UCHAR ucDefaultAttribute; /* the default text attribute */
1791
1792 ULONG ulConsoleThreadPriorityClass; /* priority settings for message */
1793 ULONG ulConsoleThreadPriorityDelta; /* thread */
1794} CONSOLEOPTIONS, *PCONSOLEOPTIONS;
1795
1796
1797DLGTEMPLATE DLG_CONSOLE_PAGE1
1798 CONTROL "~Close window on exit", CB_CONSOLE_CLOSEWINDOWONEXIT, 5, 78, 196, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1799 CONTROL "~Insert mode enabled", CB_CONSOLE_INSERTMODE, 5, 62, 196, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1800 CONTROL "~Quickinsert enabled", CB_CONSOLE_QUICKINSERT, 5, 46, 196, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1801 CONTROL "Console ~toolbar", CB_CONSOLE_TOOLBAR, 5, 30, 196, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1802 CONTROL "tabwidth", SPN_CONSOLE_TAB, 122, 4, 55, 12, WC_SPINBUTTON, SPBS_MASTER | SPBS_NUMERICONLY | SPBS_JUSTLEFT | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1803 CONTROL "Tabulator ~width:", -1, 5, 4, 112, 8, WC_STATIC, SS_TEXT | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE | WS_GROUP
1804 CONTROL "tabwidth", SPN_CONSOLE_CURSORBLINK, 122, 17, 55, 12, WC_SPINBUTTON, SPBS_MASTER | SPBS_NUMERICONLY | SPBS_JUSTLEFT | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1805 CONTROL "Cursor blink ~frequency:", -1, 5, 17, 112, 8, WC_STATIC, SS_TEXT | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE | WS_GROUP
1806
1807DLGTEMPLATE DLG_CONSOLE_PAGE2
1808 CONTROL "~Enable speaker", CB_CONSOLE_SPEAKERENABLE, 6, 71, 195, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1809 CONTROL "Speaker frequency", SLB_CONSOLE_SPEAKERFREQUENCY, 92, 52, 111, 16, WC_SLIDER, SLS_HORIZONTAL | SLS_CENTER | SLS_HOMELEFT | SLS_PRIMARYSCALE1 | SLS_SNAPTOINCREMENT | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1810 CONTROL "Speaker duration", SBL_CONSOLE_SPEAKERDURATION, 92, 35, 111, 16, WC_SLIDER, SLS_HORIZONTAL | SLS_CENTER | SLS_HOMELEFT | SLS_PRIMARYSCALE1 | SLS_SNAPTOINCREMENT | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1811
1812DLGTEMPLATE DLG_CONSOLE_PAGE3
1813 CONTROL "Sample", SPN_CONSOLE_X, 49, 60, 48, 12, WC_SPINBUTTON, SPBS_MASTER | SPBS_NUMERICONLY | SPBS_JUSTLEFT | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1814 CONTROL "Sample", SPN_CONSOLE_Y, 49, 45, 48, 12, WC_SPINBUTTON, SPBS_MASTER | SPBS_NUMERICONLY | SPBS_JUSTLEFT | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1815 CONTROL "~Width:", -1, 118, 60, 30, 8, WC_STATIC, SS_TEXT | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE | WS_GROUP
1816 CONTROL "Sample", 102, 155, 60, 48, 12, WC_SPINBUTTON, SPBS_MASTER | SPBS_NUMERICONLY | SPBS_JUSTLEFT | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1817 CONTROL "~Height:", -1, 119, 45, 30, 8, WC_STATIC, SS_TEXT | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE | WS_GROUP
1818 CONTROL "Sample", 104, 155, 45, 48, 12, WC_SPINBUTTON, SPBS_MASTER | SPBS_NUMERICONLY | SPBS_JUSTLEFT | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1819 CONTROL "~Override default position and size", CB_CONSOLE_WINDOWPOSITION, 8, 80, 155, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1820 CONTROL "~Console buffer", -1, 2, 1, 205, 39, WC_STATIC, SS_GROUPBOX | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE | WS_GROUP
1821 CONTROL "~Width:", 101, 8, 19, 30, 8, WC_STATIC, SS_TEXT | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE | WS_GROUP
1822 CONTROL "Sample", 103, 49, 19, 48, 12, WC_SPINBUTTON, SPBS_MASTER | SPBS_NUMERICONLY | SPBS_JUSTLEFT | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1823 CONTROL "~Height:", 105, 119, 19, 30, 8, WC_STATIC, SS_TEXT | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE | WS_GROUP
1824 CONTROL "Sample", 106, 155, 19, 48, 12, WC_SPINBUTTON, SPBS_MASTER | SPBS_NUMERICONLY | SPBS_JUSTLEFT | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1825
1826DLGTEMPLATE DLG_CONSOLE_PAGE5
1827 CONTROL "Sample", SPN_CONSOLE_APPPRIORITY, 46, 52, 48, 12, WC_SPINBUTTON, SPBS_MASTER | SPBS_READONLY | SPBS_JUSTLEFT | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1828 CONTROL "Sample", SPN_CONSOLE_APPPRIODELTA, 154, 52, 48, 12, WC_SPINBUTTON, SPBS_MASTER | SPBS_ALLCHARACTERS | SPBS_JUSTLEFT | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1829 CONTROL "Sample", SPN_CONSOLE_CONSOLEPRIORITY, 46, 20, 48, 12, WC_SPINBUTTON, SPBS_MASTER | SPBS_ALLCHARACTERS | SPBS_JUSTLEFT | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1830 CONTROL "Sample", SPN_CONSOLE_CONSOLEPRIODELTA, 154, 20, 48, 12, WC_SPINBUTTON, SPBS_MASTER | SPBS_ALLCHARACTERS | SPBS_JUSTLEFT | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1831 CONTROL "Sample", SPN_CONSOLE_UPDATELIMIT, 113, 5, 89, 12, WC_SPINBUTTON, SPBS_MASTER | SPBS_ALLCHARACTERS | SPBS_JUSTLEFT | WS_VISIBLE | WS_GROUP | WS_TABSTOP
1832#endif
1833
Note: See TracBrowser for help on using the repository browser.