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

Last change on this file since 4 was 4, checked in by ktk, 26 years ago

Import

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