|
|
1.1 root 1: /*
2: dialogs.c Dialog procedures for PM Clock Application
3:
4: Created by Microsoft Corporation, 1989
5: */
6: #define INCL_WINDIALOGS
7: #define INCL_WINBUTTONS
8: #define INCL_WINSYS
9: #include <os2def.h>
10: #include <pmwin.h>
11: #include "dialogs.h"
12:
13: /* defined in paint.c */
14: extern USHORT usMajorTickPref ;
15: extern USHORT usMinorTickPref ;
16: extern LONG clrBackground ;
17: extern LONG clrFace ;
18: extern LONG clrHourHand ;
19: extern LONG clrMinuteHand ;
20:
21: /* defined in clock.c */
22: extern HWND hwndFrame ;
23:
24: /*
25: ClkAboutDlgProc() "About..." dialog
26:
27: Returns: MRESULT, 0 or return value from WinDefDlgProc
28: */
29: MRESULT CALLBACK ClkAboutDlgProc ( HWND hwnd , USHORT usMsg ,
30: MPARAM mp1 , MPARAM mp2 )
31: {
32: if ( usMsg == WM_COMMAND ) {
33: WinDismissDlg ( hwnd , TRUE ) ;
34: return 0L ;
35: }
36: else return WinDefDlgProc ( hwnd , usMsg , mp1 , mp2 ) ;
37: }
38:
39:
40: /*
41: ClkTicksDlgProc() "Ticks..." dialog
42:
43: Returns: MRESULT, 0 or return value from WinDefDlgProc
44: */
45: MRESULT CALLBACK ClkTicksDlgProc ( HWND hwnd , USHORT usMsg ,
46: MPARAM mp1 , MPARAM mp2 )
47: {
48: static USHORT usMajorTickSel ;
49: static USHORT usMinorTickSel ;
50: USHORT usButtonID ;
51:
52: switch ( usMsg ) {
53:
54: case WM_INITDLG :
55:
56: /* show the current major tick preference */
57: WinSendMsg ( WinWindowFromID ( hwnd ,
58: CLKTM_MAJOR | usMajorTickPref ) ,
59: BM_SETCHECK , MPFROM2SHORT ( TRUE , NULL ) , NULL ) ;
60:
61: /* show the current minor tick preference */
62: WinSendMsg ( WinWindowFromID ( hwnd ,
63: CLKTM_MINOR | usMinorTickPref ) ,
64: BM_SETCHECK , MPFROM2SHORT ( TRUE , NULL ) , NULL ) ;
65:
66: /* load the selection values from the preferences */
67: usMajorTickSel = usMajorTickPref ;
68: usMinorTickSel = usMinorTickPref ;
69:
70: /* let the default dialog procedure handle anything else */
71: break ;
72:
73: case WM_COMMAND :
74:
75: switch ( LOUSHORT ( mp1 ) ) {
76:
77: case DID_OK :
78:
79: /* store away selections as preferences */
80: usMajorTickPref = usMajorTickSel ;
81: usMinorTickPref = usMinorTickSel ;
82:
83: /* repaint with the new preferences */
84: WinInvalidateRect ( hwndFrame , NULL, TRUE ) ;
85:
86: case DID_CANCEL :
87: WinDismissDlg ( hwnd , TRUE ) ;
88: }
89:
90: return NULL ;
91:
92: case WM_CONTROL :
93:
94: if ( SHORT2FROMMP ( mp1 ) == BN_CLICKED ) {
95:
96: usButtonID = SHORT1FROMMP ( mp1 ) ;
97:
98: switch ( usButtonID & 0xff00 ) {
99:
100: case CLKTM_MAJOR :
101: usMajorTickSel = LOBYTE ( usButtonID ) ;
102: break ;
103:
104: case CLKTM_MINOR :
105: usMinorTickSel = LOBYTE ( usButtonID ) ;
106: break ;
107: }
108: }
109:
110: /* fall through to the default control processing */
111: }
112:
113: return WinDefDlgProc ( hwnd , usMsg , mp1 , mp2 ) ;
114: }
115:
116:
117: /*
118: ClkColorsDlgProc() "Clock Color Preferences" Dialog
119:
120: Returns: MRESULT, 0 or return value from WinDefDlgProc
121: */
122: MRESULT CALLBACK ClkColorsDlgProc ( HWND hwnd , USHORT usMsg ,
123: MPARAM mp1 , MPARAM mp2 )
124: {
125: USHORT usButtonID ;
126: static USHORT usCheckedButtonID ;
127: HWND hwndButton ;
128: RECTL rclButton , rclButtonInterior ;
129: static LONG clrBackgroundNew ;
130: static LONG clrFaceNew ;
131: static LONG clrHourHandNew ;
132: static LONG clrMinuteHandNew ;
133: static LONG * pclrNew ;
134:
135: switch ( usMsg ) {
136:
137: case WM_INITDLG :
138:
139: /* load the new values from the current ones */
140: clrBackgroundNew = clrBackground ;
141: clrFaceNew = clrFace ;
142: clrHourHandNew = clrHourHand ;
143: clrMinuteHandNew = clrMinuteHand ;
144:
145: /* click the "Background" radio button */
146: WinSendMsg ( WinWindowFromID ( hwnd , CLKCLR_BACKGROUND ) ,
147: BM_CLICK , MPFROMSHORT ( TRUE ) , NULL ) ;
148:
149: /* let the default dialog procedure handle anything else */
150: break ;
151:
152: case WM_COMMAND :
153:
154: switch ( LOUSHORT ( mp1 ) ) {
155: case DID_OK :
156:
157: /* store the new values */
158: clrBackground = clrBackgroundNew ;
159: clrFace = clrFaceNew ;
160: clrHourHand = clrHourHandNew ;
161: clrMinuteHand = clrMinuteHandNew ;
162:
163: /* repaint with the new colors */
164: WinInvalidateRect ( hwndFrame , NULL, TRUE ) ;
165:
166: case DID_CANCEL :
167:
168: WinDismissDlg ( hwnd , TRUE ) ;
169: }
170: return NULL ;
171:
172: case WM_CONTROL :
173:
174: usButtonID = SHORT1FROMMP ( mp1 ) ;
175:
176: /* selecting a new object */
177: if ( usButtonID & CLKCLR_OBJECTS ) {
178:
179: switch ( usButtonID ) {
180: case CLKCLR_BACKGROUND :
181: pclrNew = & clrBackgroundNew ;
182: break ;
183: case CLKCLR_FACE :
184: pclrNew = & clrFaceNew ;
185: break ;
186: case CLKCLR_HOURHAND :
187: pclrNew = & clrHourHandNew ;
188: break ;
189: case CLKCLR_MINUTEHAND :
190: pclrNew = & clrMinuteHandNew ;
191: }
192:
193: /* click the button for the new object's current color */
194: WinSendMsg (
195: WinWindowFromID ( hwnd ,
196: CLKCLR_BUTTONSHIFT + ( USHORT ) * pclrNew ) ,
197: BM_CLICK , MPFROMSHORT ( TRUE ) , NULL ) ;
198:
199: break ;
200: }
201:
202: switch ( SHORT2FROMMP ( mp1 ) ) {
203:
204: case BN_CLICKED :
205:
206: * pclrNew = ( LONG ) usButtonID - CLKCLR_BUTTONSHIFT ;
207:
208: /* turn off the check state of the previously checked
209: * button and turn on the check state of the button
210: * just clicked */
211:
212: WinSendMsg ( WinWindowFromID ( hwnd , usCheckedButtonID ) ,
213: BM_SETCHECK , MPFROM2SHORT ( FALSE , NULL ) ,
214: NULL ) ;
215: WinSendMsg ( WinWindowFromID ( hwnd , usButtonID ) ,
216: BM_SETCHECK , MPFROM2SHORT ( TRUE , NULL ) ,
217: NULL ) ;
218:
219: usCheckedButtonID = usButtonID ;
220:
221: break ;
222:
223: case BN_PAINT :
224:
225: /* fill only the interior of the button, so we don't
226: * conflict with the focus indicator */
227:
228: hwndButton = ( ( PUSERBUTTON ) mp2 ) -> hwnd ;
229: WinQueryWindowRect ( hwndButton , & rclButton ) ;
230: rclButton . xLeft ++ ;
231: rclButton . yBottom ++ ;
232: rclButton . xRight -- ;
233: rclButton . yTop -- ;
234: WinFillRect ( ( ( PUSERBUTTON ) mp2 ) -> hps ,
235: & rclButton ,
236: ( LONG ) usButtonID - CLKCLR_BUTTONSHIFT ) ;
237:
238: /* hollow out those buttons which aren't checked */
239: if ( ! WinSendMsg ( WinWindowFromID ( hwnd , usButtonID ) ,
240: BM_QUERYCHECK , NULL , NULL ) ) {
241: rclButtonInterior . xLeft = rclButton . xLeft + 4 ;
242: rclButtonInterior . yBottom = rclButton . yBottom + 4 ;
243: rclButtonInterior . xRight = rclButton . xRight - 4 ;
244: rclButtonInterior . yTop = rclButton . yTop - 4 ;
245: WinFillRect ( ( ( PUSERBUTTON ) mp2 ) -> hps ,
246: & rclButtonInterior , SYSCLR_WINDOW ) ;
247: }
248:
249: break ;
250: }
251:
252: /* fall through to the default control processing */
253: }
254:
255: return WinDefDlgProc ( hwnd , usMsg , mp1 , mp2 ) ;
256: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.