]>
Commit | Line | Data |
---|---|---|
03e11df5 GD |
1 | #include "wx/mac/uma.h" |
2 | #include "wx/mac/aga.h" | |
30b72134 GD |
3 | |
4 | #if !TARGET_CARBON | |
5 | ||
72582399 UJ |
6 | #include <extcdef.h> |
7 | #include <PictUtils.h> | |
8 | ||
9 | pascal SInt32 AGAProgressBarDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param); | |
10 | pascal SInt32 AGAPlacardDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param); | |
11 | pascal SInt32 AGAStaticTextDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) ; | |
12 | pascal SInt32 AGAListControlDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) ; | |
13 | pascal SInt32 AGAEditTextDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) ; | |
14 | pascal SInt32 AGAStaticGroupBoxTextDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) ; | |
15 | ||
03e11df5 GD |
16 | #define B 13 |
17 | #define W 0 | |
72582399 UJ |
18 | |
19 | SInt16 kAGARootControlProcID ; | |
20 | int gAGABackgroundColor = 0 ; | |
21 | ||
03e11df5 GD |
22 | const RGBColor gAGAColorArray[] = { |
23 | {0xFFFF, 0xFFFF, 0xFFFF}, // W | |
24 | {0xEEEE, 0xEEEE, 0xEEEE}, // 1 | |
25 | {0xDDDD, 0xDDDD, 0xDDDD}, // 2 | |
26 | {0xCCCC, 0xCCCC, 0xCCCC}, // 3 | |
27 | {0xBBBB, 0xBBBB, 0xBBBB}, // 4 | |
28 | {0xAAAA, 0xAAAA, 0xAAAA}, // 5 | |
29 | {0x9999, 0x9999, 0x9999}, // 6 | |
30 | {0x8888, 0x8888, 0x8888}, // 7 | |
31 | {0x7777, 0x7777, 0x7777}, // 8 | |
32 | {0x6666, 0x6666, 0x6666}, // 9 | |
33 | {0x5555, 0x5555, 0x5555}, // 10 | |
34 | {0x4444, 0x4444, 0x4444}, // 11 | |
35 | {0x2222, 0x2222, 0x2222}, // 12 | |
36 | {0x0000, 0x0000, 0x0000} // B | |
30b72134 | 37 | }; |
72582399 UJ |
38 | |
39 | char LAGADefaultOutline_mCorners[4][5][5] = { | |
30b72134 GD |
40 | // topleft |
41 | { | |
42 | { -1, -1, -1, 12, B }, | |
43 | { -1, -1, B, 2, 2 }, | |
44 | { -1, B, 2, 2, 5 }, | |
45 | { 12, 2, 2, 2, 8 }, | |
46 | { B, 2, 5, 8, -1 } | |
47 | }, | |
48 | // topright | |
49 | { | |
50 | { B, 12, -1, -1, -1 }, | |
51 | { 2, 3, B, -1, -1 }, | |
52 | { 5, 5, 4, B, -1 }, | |
53 | { 8, 5, 5, 7, 12 }, | |
54 | { -1, 8, 5, 8, B } | |
55 | }, | |
56 | // bottomleft | |
57 | { | |
58 | { B, 2, 5, 8, -1 }, | |
59 | { 12, 3, 5, 5, 8 }, | |
60 | { -1, B, 4, 5, 5 }, | |
61 | { -1, -1, B, 7, 8 }, | |
62 | { -1, -1, -1, 12, B } | |
63 | }, | |
64 | // bottomright | |
65 | { | |
66 | { -1, 8, 5, 8, B }, | |
67 | { 8, 5, 7, 8, 12 }, | |
68 | { 5, 7, 8, B, -1 }, | |
69 | { 8, 8, B, -1, -1 }, | |
70 | { B, 12, -1, -1, -1 } | |
71 | } | |
72 | }; | |
72582399 UJ |
73 | |
74 | char LAGAPushButton_mCorners[3][4][4][4] = { | |
30b72134 GD |
75 | // Enabled |
76 | { | |
77 | // topleft | |
78 | { | |
79 | { -1, -1, 12, B }, | |
80 | { -1, B, 4, 2 }, | |
81 | { 12, 4, W, W }, | |
82 | { B, 2, W, W } | |
83 | }, | |
84 | // topright | |
85 | { | |
86 | { B, 12, -1, -1 }, | |
87 | { 2, 4, B, -1 }, | |
88 | { W, 2, 5, 12 }, | |
89 | { 2, 5, 8, B } | |
90 | }, | |
91 | // bottomleft | |
92 | { | |
93 | { B, 2, W, 2 }, | |
94 | { 12, 4, 2, 5 }, | |
95 | { -1, B, 4, 8 }, | |
96 | { -1, -1, 12, B } | |
97 | }, | |
98 | // bottomright | |
99 | { | |
100 | { 5, 5, 8, B }, | |
101 | { 5, 8, 8, 12 }, | |
102 | { 8, 8, B, -1 }, | |
103 | { B, 12, -1, -1 } | |
104 | } | |
105 | }, | |
106 | // Pressed | |
107 | { | |
108 | // topleft | |
109 | { | |
110 | { -1, -1, 12, B }, | |
111 | { -1, B, 10, 8 }, | |
112 | { 12, 10, 8, 4 }, | |
113 | { B, 8, 4, 4 } | |
114 | }, | |
115 | // topright | |
116 | { | |
117 | { B, 12, -1, -1 }, | |
118 | { 8, 10, B, -1 }, | |
119 | { 4, 4, 8, 12 }, | |
120 | { 4, 4, 4, B } | |
121 | }, | |
122 | // bottomleft | |
123 | { | |
124 | { B, 8, 4, 4 }, | |
125 | { 12, 10, 4, 4 }, | |
126 | { -1, B, 10, 4 }, | |
127 | { -1, -1, 12, B } | |
128 | }, | |
129 | // bottomright | |
130 | { | |
131 | { 4, 4, 4, B }, | |
132 | { 4, 4, 10, 12 }, | |
133 | { 4, 10, B, -1 }, | |
134 | { B, 12, -1, -1 } | |
135 | } | |
136 | }, | |
137 | // Disabled | |
138 | { | |
139 | // topleft | |
140 | { | |
141 | { -1, -1, 7, 7 }, | |
142 | { -1, 7, 4, 2 }, | |
143 | { 7, 4, 1, 1 }, | |
144 | { 7, 2, 1, 1 } | |
145 | }, | |
146 | // topright | |
147 | { | |
148 | { 7, 7, -1, -1 }, | |
149 | { 2, 4, 7, -1 }, | |
150 | { 1, 2, 4, 7 }, | |
151 | { 2, 4, 5, 7 } | |
152 | }, | |
153 | // bottomleft | |
154 | { | |
155 | { 7, 2, 1, 2 }, | |
156 | { 7, 4, 2, 4 }, | |
157 | { -1, 7, 4, 5 }, | |
158 | { -1, -1, 7, 7 } | |
159 | }, | |
160 | // bottomright | |
161 | { | |
162 | { 4, 4, 5, 7 }, | |
163 | { 4, 5, 5, 7 }, | |
164 | { 5, 5, 7, -1 }, | |
165 | { 7, 7, -1, -1 } | |
166 | } | |
167 | } | |
168 | }; | |
72582399 UJ |
169 | |
170 | RGBColor gAGARamp[] = | |
171 | { | |
172 | /* black */ | |
173 | { 0 , 0 , 0 } , | |
174 | /* white */ | |
175 | { 65535 , 65535 , 65535 } , | |
176 | /* 1 */ | |
177 | { 61166 , 61166 , 61166 } , | |
178 | /* 2 */ | |
179 | { 56797 , 56797 , 56797 } , | |
180 | /* 3 */ | |
181 | { 52428 , 52428 , 52428 } , | |
182 | /* 4 */ | |
183 | { 48059 , 48059 , 48059 } , | |
184 | /* 5 */ | |
185 | { 43690 , 43690 , 43690 } , | |
186 | /* 6 */ | |
187 | { 39321 , 39321 , 39321 } , | |
188 | /* 7 */ | |
189 | { 34952 , 34952 , 34952 } , | |
190 | /* 8 */ | |
191 | { 30583 , 30583 , 30583 } , | |
192 | /* 9 */ | |
193 | { 26214 , 26214 , 26214 } , | |
194 | /* 10 */ | |
195 | { 21845 , 21845 , 21845 } , | |
196 | /* 11 */ | |
197 | { 17476 , 17476 , 17476 } , | |
198 | /* 12 */ | |
199 | { 13107 , 13107 , 13107 } , | |
200 | /* A1 */ | |
201 | { 8738 , 8738 , 8738 } , | |
202 | /* A2 */ | |
203 | { 4369 , 4369 , 4369 } , | |
204 | ||
205 | } ; | |
206 | ||
207 | RGBColor gAGABlueRamp[] = | |
208 | { | |
209 | /* black */ | |
210 | { 0 , 0 , 0 } , | |
211 | /* white */ | |
212 | { 65535 , 65535 , 65535 } , | |
213 | /* 1 */ | |
214 | { 61166 , 61166 , 65535 } , | |
215 | /* 2 */ | |
216 | { 56797 , 56797 , 65535 } , | |
217 | /* 3 */ | |
218 | { 52428 , 52428 , 65535 } , | |
219 | /* 4 */ | |
220 | { 48059 , 48059 , 65535 } , | |
221 | /* 5 */ | |
222 | { 43690 , 43690 , 65535 } , | |
223 | /* 6 */ | |
224 | { 39321 , 39321 , 65535 } , | |
225 | /* 7 */ | |
226 | { 34952 , 34952 , 65535 } , | |
227 | /* 8 */ | |
228 | { 30583 , 30583 , 65535 } , | |
229 | /* 9 */ | |
230 | { 26214 , 26214 , 65535 } , | |
231 | /* 10 */ | |
232 | { 21845 , 21845 , 65535 } , | |
233 | /* 11 */ | |
234 | { 17476 , 17476 , 65535 } , | |
235 | /* 12 */ | |
236 | { 13107 , 13107 , 65535 } , | |
237 | /* A1 */ | |
238 | { 8738 , 8738 , 65535 } , | |
239 | /* A2 */ | |
240 | { 4369 , 4369 , 65535 } , | |
241 | ||
242 | } ; | |
243 | ||
244 | enum eAGARampColor { | |
245 | kAGATransparent = -1 , | |
246 | kAGABlack = 0 , | |
247 | kAGAWhite = 1 , | |
248 | kAGA1 = 2 , | |
249 | kAGA2 = 3 , | |
250 | kAGA3 = 4 , | |
251 | kAGA4 = 5 , | |
252 | kAGA5 = 6 , | |
253 | kAGA6 = 7 , | |
254 | kAGA7 = 8 , | |
255 | kAGA8 = 9 , | |
256 | kAGA9 = 10 , | |
257 | kAGA10 = 11 , | |
258 | kAGA11 = 12 , | |
259 | kAGA12 = 13 , | |
260 | kAGAA1 = 14 , | |
261 | kAGAA2 = 15 , | |
262 | } ; | |
263 | // defprocs | |
264 | ||
265 | enum eAGAState { | |
266 | kAGAStateEnabled = 0 , | |
267 | kAGAStatePressed = 1 , | |
268 | kAGAStateDisabled = 2 , | |
269 | kAGAStateInactive = 3 | |
270 | } ; | |
271 | ||
272 | /* | |
273 | typedef struct sControlData | |
274 | { | |
275 | ControlPartCode m_part ; | |
276 | ResType m_tag ; | |
277 | Size m_size ; | |
278 | } ; | |
279 | ||
280 | OSErr AGAFindControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , long *outOffset) ; | |
281 | OSErr AGAFindControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , long *outOffset) | |
282 | { | |
283 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
284 | long offset = 0 ; | |
285 | long size = GetHandleSize( info->data ) ; | |
286 | char* data = *(info->data) ; | |
287 | sControlData* current ; | |
288 | while( offset + sizeof( sControlData ) <= size ) | |
289 | { | |
290 | current = (sControlData*) (data+offset ) ; | |
291 | if ( ( inPart == kControlEntireControl || inPart == current->m_part ) && inTagName == current->m_tag ) | |
292 | { | |
293 | *outOffset = offset ; | |
294 | return noErr ; | |
295 | } | |
296 | } | |
297 | return errDataNotSupported ; // nothing found | |
298 | } | |
299 | ||
300 | OSErr AGARemoveControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName ) ; | |
301 | OSErr AGARemoveControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName ) | |
302 | { | |
303 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
304 | long offset = 0 ; | |
305 | long size = GetHandleSize( info->data ) ; | |
306 | char* data = *(info->data) ; | |
307 | sControlData* current ; | |
308 | while( offset + sizeof( sControlData ) <= size ) | |
309 | { | |
310 | current = (sControlData*) (data+offset ) ; | |
311 | if ( ( inPart == kControlEntireControl || inPart == current->m_part ) && inTagName == current->m_tag ) | |
312 | { | |
313 | long chunkSize = current->m_size + sizeof ( sControlData ) ; | |
314 | memcpy( data + offset , data + offset + chunkSize , size - offset - chunkSize ) ; | |
315 | SetHandleSize( info->data , size - chunkSize ) ; | |
316 | return noErr ; | |
317 | } | |
318 | } | |
319 | return noErr ; | |
320 | } | |
321 | ||
322 | OSErr AGAAddControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , Size inSize, Ptr inData) ; | |
323 | OSErr AGAAddControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , Size inSize, Ptr inData) | |
324 | { | |
325 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
326 | long offset = 0 ; | |
327 | long size = GetHandleSize( info->data ) ; | |
328 | SetHandleSize( info->data , size + sizeof( sControlData ) + inSize ) ; | |
329 | if ( MemError() == noErr ) | |
330 | { | |
331 | char* data = *(info->data) ; | |
332 | sControlData* current = (sControlData*)( data + size ) ; | |
333 | current->m_tag = inTagName ; | |
334 | current->m_part = inPart ; | |
335 | current->m_size = inSize ; | |
336 | memcpy( data + size + sizeof( sControlData ) , inData , inSize ) ; | |
337 | return noErr ; | |
338 | } | |
339 | return errDataNotSupported ; | |
340 | } | |
341 | ||
342 | ||
343 | OSErr AGAGetControlDataSize (ControlHandle inControl, | |
344 | ControlPartCode inPart, | |
345 | ResType inTagName, | |
346 | Size * outMaxSize) | |
347 | { | |
348 | long offset ; | |
349 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
350 | char* data = *(info->data) ; | |
351 | ||
352 | OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ; | |
353 | if ( !err ) | |
354 | { | |
355 | sControlData* current = (sControlData*) (data+offset ) ; | |
356 | *outMaxSize = current->m_size ; | |
357 | } | |
358 | return err ; | |
359 | } | |
360 | ||
361 | OSErr AGAGetControlData (ControlHandle inControl, | |
362 | ControlPartCode inPart, | |
363 | ResType inTagName, | |
364 | Size inBufferSize, | |
365 | Ptr outBuffer, | |
366 | Size * outActualSize) | |
367 | { | |
368 | long offset ; | |
369 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
370 | char* data = *(info->data) ; | |
371 | ||
372 | OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ; | |
373 | if ( !err ) | |
374 | { | |
375 | sControlData* current = (sControlData*) (data+offset ) ; | |
376 | *outActualSize = current->m_size ; | |
377 | if ( outBuffer ) | |
378 | { | |
379 | if ( inBufferSize <= current->m_size ) | |
380 | memcpy( outBuffer , data + offset + sizeof( sControlData ) , current->m_size ) ; | |
381 | else | |
382 | err = errDataNotSupported ; | |
383 | } | |
384 | } | |
385 | return err ; | |
386 | } | |
387 | ||
388 | OSErr AGASetControlData (ControlHandle inControl, | |
389 | ControlPartCode inPart, | |
390 | ResType inTagName, | |
391 | Size inSize, | |
392 | Ptr inData) | |
393 | { | |
394 | long offset ; | |
395 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
396 | char* data = *(info->data) ; | |
397 | ||
398 | OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ; | |
399 | if ( !err ) | |
400 | { | |
401 | sControlData* current = (sControlData*) (data+offset ) ; | |
402 | if ( current->m_size == inSize ) | |
403 | { | |
404 | memcpy( data + offset + sizeof( sControlData ) , inData , inSize) ; | |
405 | } | |
406 | else | |
407 | { | |
408 | AGARemoveControlData( inControl , inPart , inTagName ) ; | |
409 | AGAAddControlData( inControl , inPart , inTagName , inSize , inData ) ; | |
410 | } | |
411 | } | |
412 | else | |
413 | { | |
414 | AGAAddControlData( inControl , inPart , inTagName , inSize , inData ) ; | |
415 | } | |
416 | return err ; | |
417 | } | |
418 | */ | |
419 | ||
420 | OSErr AGASetControlFontStyle (ControlHandle inControl, | |
421 | const ControlFontStyleRec * inStyle) | |
422 | { | |
423 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
424 | if ( inStyle->flags == 0 ) | |
425 | { | |
426 | // back to defaults | |
427 | } | |
428 | else | |
429 | { | |
430 | if ( inStyle->flags & kControlUseFontMask ) | |
431 | { | |
432 | info->fontStyle.font = inStyle->font ; | |
433 | } | |
434 | if ( inStyle->flags & kControlUseSizeMask ) | |
435 | { | |
436 | info->fontStyle.size = inStyle->size ; | |
437 | } | |
438 | if ( inStyle->flags & kControlUseFaceMask ) | |
439 | { | |
440 | info->fontStyle.style = inStyle->style ; | |
441 | } | |
442 | if ( inStyle->flags & kControlUseModeMask ) | |
443 | { | |
444 | info->fontStyle.mode = inStyle->mode ; | |
445 | } | |
446 | if ( inStyle->flags & kControlUseJustMask ) | |
447 | { | |
448 | info->fontStyle.just = inStyle->just ; | |
449 | } | |
450 | if ( inStyle->flags & kControlUseForeColorMask ) | |
451 | { | |
452 | info->fontStyle.foreColor = inStyle->foreColor ; | |
453 | } | |
454 | if ( inStyle->flags & kControlUseBackColorMask ) | |
455 | { | |
456 | info->fontStyle.backColor = inStyle->backColor ; | |
457 | } | |
458 | } | |
459 | return noErr ; | |
460 | } | |
461 | ||
462 | OSErr AGASetControlData (ControlHandle inControl, | |
463 | ControlPartCode inPart, | |
464 | ResType inTagName, | |
465 | Size inSize, | |
466 | Ptr inData) | |
467 | { | |
468 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
469 | ControlDataAccessRec rec ; | |
470 | ||
471 | rec.tag = inTagName ; | |
472 | rec.part = inPart ; | |
473 | rec.size = inSize ; | |
474 | rec.dataPtr = inData ; | |
475 | ||
476 | return info->defProc( info->procID , inControl , kControlMsgSetData , (long) &rec ) ; | |
477 | } | |
478 | ||
479 | SInt16 AGAHandleControlKey (ControlHandle inControl, | |
480 | SInt16 inKeyCode, | |
481 | SInt16 inCharCode, | |
482 | SInt16 inModifiers) | |
483 | { | |
484 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
485 | ControlKeyDownRec rec ; | |
486 | ||
487 | rec.modifiers = inModifiers ; | |
488 | rec.keyCode = inKeyCode ; | |
489 | rec.charCode = inCharCode ; | |
490 | ||
491 | return info->defProc( info->procID , inControl , kControlMsgKeyDown , (long) &rec ) ; | |
492 | } | |
493 | ||
494 | ControlPartCode AGAHandleControlClick (ControlHandle inControl, | |
495 | Point inWhere, | |
496 | SInt16 inModifiers, | |
497 | ControlActionUPP inAction) | |
498 | { | |
499 | return TrackControl( inControl , inWhere , inAction ) ; | |
500 | } | |
501 | ||
502 | Boolean AGATestForNewControl( ControlHandle inControl ) | |
503 | { | |
504 | if ( (**inControl).contrlRfCon > 0x100 && !( (**inControl).contrlRfCon % 2 ) ) | |
505 | { | |
506 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
507 | return info->magic == kExtCDEFMagic ; | |
508 | } | |
509 | return FALSE ; | |
510 | } | |
511 | void AGAIdleControls (WindowPtr inWindow) | |
512 | { | |
513 | ControlHandle iter = (ControlHandle) ((WindowPeek)inWindow)->controlList ; | |
514 | while ( iter ) | |
515 | { | |
516 | if ( AGATestForNewControl( iter ) ) | |
517 | { | |
518 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**iter).contrlRfCon ; | |
519 | if ( info->defProc( info->procID , iter , kControlMsgTestNewMsgSupport , 0 ) == kControlSupportsNewMessages ) | |
520 | { | |
521 | if ( info->defProc( info->procID , iter , kControlMsgGetFeatures , 0 ) & kControlWantsIdle ) | |
522 | { | |
523 | info->defProc( info->procID , iter , kControlMsgIdle , 0 ) ; | |
524 | } | |
525 | } | |
526 | } | |
527 | ||
528 | iter = (**iter).nextControl ; | |
529 | } | |
530 | } | |
531 | ||
532 | void AGAUpdateOneControl( ControlHandle control , RgnHandle inRgn ) | |
533 | { | |
534 | DrawOneControl( control ) ; | |
535 | ControlHandle iter = (ControlHandle) ((WindowPeek)(**control).contrlOwner)->controlList ; | |
536 | while ( iter ) | |
537 | { | |
538 | if ( AGATestForNewControl( iter ) ) | |
539 | { | |
540 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**iter).contrlRfCon ; | |
541 | if ( info->containerControl == control ) | |
542 | { | |
543 | AGAUpdateOneControl( iter , inRgn ) ; | |
544 | } | |
545 | } | |
546 | ||
547 | iter = (**iter).nextControl ; | |
548 | } | |
549 | } | |
550 | ||
551 | void AGAUpdateControls( WindowPtr inWindow , RgnHandle inRgn ) | |
552 | { | |
553 | ControlHandle root ; | |
554 | AGAGetRootControl( inWindow , &root ) ; | |
555 | AGAUpdateOneControl( root , inRgn ) ; | |
556 | ||
557 | // and then all others | |
558 | ||
559 | ControlHandle iter = (ControlHandle) ((WindowPeek)inWindow)->controlList ; | |
560 | while ( iter ) | |
561 | { | |
562 | if ( AGATestForNewControl( iter ) ) | |
563 | { | |
564 | } | |
565 | else | |
566 | { | |
567 | DrawOneControl( iter ) ; | |
568 | } | |
569 | ||
570 | iter = (**iter).nextControl ; | |
571 | } | |
572 | } | |
573 | ||
574 | OSErr AGAGetRootControl( WindowPtr inWindow , ControlHandle *outControl ) | |
575 | { | |
576 | ControlHandle iter = (ControlHandle) ((WindowPeek)inWindow)->controlList ; | |
577 | while ( iter ) | |
578 | { | |
579 | if ( AGATestForNewControl( iter ) ) | |
580 | { | |
581 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**iter).contrlRfCon ; | |
582 | if ( info->procID == kAGARootControlProcID ) | |
583 | { | |
584 | *outControl = iter ; | |
585 | return noErr ; | |
586 | } | |
587 | } | |
588 | ||
589 | iter = (**iter).nextControl ; | |
590 | } | |
591 | return -1 ; | |
592 | } | |
593 | ||
594 | void AGADeactivateControl( ControlHandle inControl ) | |
595 | { | |
596 | if ( AGATestForNewControl( inControl ) ) | |
597 | { | |
598 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
599 | if ( info->defProc( info->procID , inControl , kControlMsgTestNewMsgSupport , 0 ) == kControlSupportsNewMessages ) | |
600 | { | |
601 | if ( info->defProc( info->procID , inControl , kControlMsgGetFeatures , 0 ) & kControlWantsActivate ) | |
602 | { | |
603 | info->defProc( info->procID , inControl , kControlMsgActivate , 0 ) ; | |
604 | } | |
605 | } | |
606 | } | |
2f1ae414 SC |
607 | else |
608 | { | |
609 | ::HiliteControl( inControl , 255 ) ; | |
610 | } | |
72582399 UJ |
611 | } |
612 | ||
613 | void AGAActivateControl( ControlHandle inControl ) | |
614 | { | |
615 | if ( AGATestForNewControl( inControl ) ) | |
616 | { | |
617 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
618 | if ( info->defProc( info->procID , inControl , kControlMsgTestNewMsgSupport , 0 ) == kControlSupportsNewMessages ) | |
619 | { | |
620 | if ( info->defProc( info->procID , inControl , kControlMsgGetFeatures , 0 ) & kControlWantsActivate ) | |
621 | { | |
622 | info->defProc( info->procID , inControl , kControlMsgActivate , 1 ) ; | |
623 | } | |
624 | } | |
625 | } | |
2f1ae414 SC |
626 | else |
627 | { | |
628 | ::HiliteControl( inControl , 0 ) ; | |
629 | } | |
72582399 UJ |
630 | } |
631 | ||
632 | OSErr AGASetKeyboardFocus (WindowPtr inWindow, | |
633 | ControlHandle inControl, | |
634 | ControlFocusPart inPart) | |
635 | { | |
636 | if ( AGATestForNewControl( inControl ) ) | |
637 | { | |
638 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
639 | if ( info->defProc( info->procID , inControl , kControlMsgTestNewMsgSupport , 0 ) == kControlSupportsNewMessages ) | |
640 | { | |
641 | if ( info->defProc( info->procID , inControl , kControlMsgGetFeatures , 0 ) & kControlSupportsFocus ) | |
642 | { | |
643 | return info->defProc( info->procID , inControl , kControlMsgFocus , inPart ) ; | |
644 | } | |
645 | } | |
646 | } | |
647 | return errControlDoesntSupportFocus ; | |
648 | } | |
649 | ||
650 | OSErr AGAGetBestControlRect (ControlHandle inControl, | |
651 | Rect * outRect, | |
652 | SInt16 * outBaseLineOffset) | |
653 | { | |
654 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
655 | ControlCalcSizeRec rec ; | |
656 | rec.width = (**inControl).contrlRect.right - (**inControl).contrlRect.left ; | |
657 | rec.height = (**inControl).contrlRect.bottom - (**inControl).contrlRect.top ; | |
658 | rec.baseLine = 0; | |
659 | ||
660 | OSErr err = info->defProc( info->procID , inControl , kControlMsgCalcBestRect , (long) &rec ) ; | |
661 | if ( !err ) | |
662 | { | |
663 | outRect->left = outRect->top = 0 ; | |
664 | outRect->right = rec. width ; | |
665 | outRect->bottom = rec. height ; | |
666 | *outBaseLineOffset = rec. baseLine ; | |
667 | } | |
668 | return err ; | |
669 | } | |
670 | ||
671 | ||
672 | OSErr AGAGetControlData (ControlHandle inControl, | |
673 | ControlPartCode inPart, | |
674 | ResType inTagName, | |
675 | Size inBufferSize, | |
676 | Ptr outBuffer, | |
677 | Size * outActualSize) | |
678 | { | |
679 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
680 | ControlDataAccessRec rec ; | |
681 | ||
682 | rec.tag = inTagName ; | |
683 | rec.part = inPart ; | |
684 | rec.size = inBufferSize ; | |
685 | rec.dataPtr = outBuffer ; | |
686 | ||
687 | OSErr err = info->defProc( info->procID , inControl , kControlMsgGetData , (long) &rec ) ; | |
688 | *outActualSize = rec.size ; | |
689 | return err ; | |
690 | } | |
691 | ||
692 | OSErr AGAGetControlDataSize (ControlHandle inControl, | |
693 | ControlPartCode inPart, | |
694 | ResType inTagName, | |
695 | Size * outMaxSize) | |
696 | { | |
697 | return AGAGetControlData( inControl , inPart , inTagName , 0 , NULL , outMaxSize ) ; | |
698 | } | |
699 | ||
700 | ||
701 | void NewExtCDEFInfo( ControlHandle theControl , ControlDefProcPtr defproc , SInt16 procID , long refcon ) | |
702 | { | |
703 | ExtCDEFInfo* info = (ExtCDEFInfo* ) malloc( sizeof( ExtCDEFInfo ) ) ; | |
704 | info->defProc = defproc ; | |
705 | info->hasFocus = false ; | |
706 | info->magic = kExtCDEFMagic ; | |
707 | info->contrlRfCon = refcon ; | |
708 | info->procID = procID ; | |
709 | info->containerControl = NULL ; | |
710 | info->children = NewHandle(0) ; | |
711 | info->fontStyle.flags = 0 ; | |
712 | info->fontStyle.font = 0 ; | |
713 | info->fontStyle.size = 12 ; | |
714 | info->fontStyle.style = 0 ; | |
715 | info->fontStyle.mode = 0 ; | |
716 | info->fontStyle.just = 0 ; | |
717 | info->fontStyle.foreColor = gAGARamp[ kAGABlack ] ; | |
718 | info->fontStyle.backColor = gAGARamp[ kAGA2 ] ; | |
719 | (**theControl).contrlRfCon = (long) info ; | |
720 | defproc( info->procID, theControl, initCntl, 0) ; | |
721 | } | |
722 | ||
723 | void DisposeExtCDEFInfo( ControlHandle theControl) | |
724 | { | |
725 | if ( AGATestForNewControl( theControl ) ) | |
726 | { | |
727 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**theControl).contrlRfCon ; | |
728 | if ( info ) | |
729 | { | |
730 | DisposeHandle( info->children ) ; | |
731 | info->children = NULL ; | |
732 | free( (void*) (**theControl).contrlRfCon ) ; | |
2f1ae414 | 733 | (**theControl).contrlRfCon = NULL ; |
72582399 UJ |
734 | } |
735 | } | |
736 | } | |
737 | ||
738 | const short kAGAProgressHeight = 14 ; | |
739 | ||
740 | void AGADrawRectPlacard( const Rect *inRect , eAGAState inState , bool fill = false ) ; | |
741 | void AGADrawRectProgress( const Rect *inRect , eAGAState inState , double percentage ) ; | |
742 | ||
743 | void AGADrawRectPlacard( const Rect *inRect , eAGAState inState , bool fill ) | |
744 | { | |
745 | Rect rect = *inRect ; | |
746 | RGBColor pixelColor ; | |
747 | if ( inState == kAGAStateInactive ) | |
748 | { | |
749 | RGBForeColor( &gAGARamp[ kAGA10 ] ) ; | |
750 | FrameRect( &rect ) ; | |
751 | if ( fill ) | |
752 | { | |
753 | InsetRect( &rect , 1 , 1 ) ; | |
754 | RGBForeColor( &gAGARamp[ kAGA1 ] ) ; | |
755 | PaintRect( &rect ) ; | |
756 | } | |
757 | return ; | |
758 | } | |
759 | ||
760 | RGBForeColor( &gAGARamp[ kAGABlack ] ) ; | |
761 | FrameRect( &rect ) ; | |
762 | InsetRect( &rect , 1 , 1 ) ; | |
763 | ||
764 | if ( inState == kAGAStateEnabled || inState == kAGAStateDisabled ) | |
765 | RGBForeColor( &gAGARamp[ kAGAWhite ] ) ; | |
766 | else | |
767 | RGBForeColor( &gAGARamp[ kAGABlack ] ) ; | |
768 | ||
769 | MoveTo( rect.left , rect.bottom - 1 -1 ) ; | |
770 | LineTo( rect.left , rect.top ) ; | |
771 | LineTo( rect.right-1-1 , rect.top ) ; | |
772 | ||
773 | if ( inState == kAGAStateEnabled || inState == kAGAStateDisabled ) | |
774 | pixelColor = gAGARamp[ kAGA2 ] ; | |
775 | else | |
776 | pixelColor = gAGARamp[ kAGA8 ] ; | |
777 | ||
778 | SetCPixel( rect.right-1 , rect.top , &pixelColor ) ; | |
779 | SetCPixel( rect.left , rect.bottom-1 , &pixelColor ) ; | |
780 | ||
781 | if ( inState == kAGAStateEnabled ) | |
782 | RGBForeColor( &gAGARamp[ kAGA5 ] ) ; | |
783 | else if ( inState == kAGAStateDisabled ) | |
784 | RGBForeColor( &gAGARamp[ kAGA4 ] ) ; | |
785 | else | |
786 | RGBForeColor( &gAGARamp[ kAGA6 ] ) ; | |
787 | ||
788 | MoveTo( rect.left + 1 , rect.bottom-1 ) ; | |
789 | LineTo( rect.right-1 , rect.bottom-1 ) ; | |
790 | LineTo( rect.right-1 , rect.top-1 ) ; | |
791 | ||
792 | if ( fill ) | |
793 | { | |
794 | InsetRect( &rect , 1 , 1 ) ; | |
795 | if ( inState == kAGAStateEnabled || inState == kAGAStateDisabled ) | |
796 | RGBForeColor( &gAGARamp[ kAGA2 ] ) ; | |
797 | else | |
798 | RGBForeColor( &gAGARamp[ kAGA8 ] ) ; | |
799 | PaintRect( &rect ) ; | |
800 | } | |
801 | } | |
802 | ||
803 | void AGADrawRectProgress( const Rect *inRect , eAGAState inState , double percentage ) | |
804 | { | |
805 | Rect rect = *inRect ; | |
806 | rect.bottom = rect.top + 14 ; | |
807 | RGBColor pixelColor ; | |
808 | ||
809 | RGBForeColor( &gAGARamp[ kAGA5 ]) ; | |
810 | MoveTo( rect.left , rect.bottom - 1 -1 ) ; | |
811 | LineTo( rect.left , rect.top ) ; | |
812 | LineTo( rect.right-1-1 , rect.top ) ; | |
813 | ||
814 | RGBForeColor( &gAGARamp[ kAGAWhite ] ) ; | |
815 | MoveTo( rect.left + 1 , rect.bottom -1 ) ; | |
816 | LineTo( rect.right-1 , rect.bottom -1 ) ; | |
817 | LineTo( rect.right-1 , rect.top-1 ) ; | |
818 | ||
819 | InsetRect( &rect , 1 , 1 ) ; | |
820 | RGBForeColor( &gAGARamp[ kAGABlack ] ) ; | |
821 | ||
822 | Rect barLeft = rect , barRight = rect ; | |
823 | ||
824 | int position = percentage * ( rect.right - rect.left ) ; | |
825 | barLeft.right = barLeft.left + position ; | |
826 | barRight.left = barLeft.left + position ; | |
827 | FrameRect( &barLeft ) ; | |
828 | FrameRect( &barRight ) ; | |
829 | ||
830 | InsetRect( &barLeft , 1 , 1 ) ; | |
831 | ||
832 | InsetRect( &barRight , 1 , 1 ) ; | |
833 | ||
834 | if ( !EmptyRect( &barRight ) ) | |
835 | { | |
836 | RGBForeColor( &gAGARamp[ kAGA10 ] ) ; | |
837 | MoveTo( barRight.left , barRight.bottom -1 ) ; | |
838 | LineTo( barRight.left , barRight.top ) ; | |
839 | barRight.left += 1 ; | |
840 | if ( !EmptyRect( &barRight ) ) | |
841 | { | |
842 | RGBForeColor( &gAGARamp[ kAGA7 ] ) ; | |
843 | MoveTo( barRight.left , barRight.bottom-1 ) ; | |
844 | LineTo( barRight.left , barRight.top ) ; | |
845 | LineTo( barRight.right-1-1 , barRight.top ) ; | |
846 | RGBForeColor( &gAGARamp[ kAGA2 ] ) ; | |
847 | MoveTo( barRight.left + 1 , barRight.bottom -1 ) ; | |
848 | LineTo( barRight.right-1 , barRight.bottom -1 ) ; | |
849 | LineTo( barRight.right-1 , barRight.top - 1) ; | |
850 | pixelColor = gAGARamp[ kAGA4 ] ; | |
851 | SetCPixel( barRight.right-1 , barRight.top , &pixelColor ) ; | |
852 | InsetRect( &barRight , 1 , 1) ; | |
853 | if ( !EmptyRect( &barRight ) ) | |
854 | { | |
855 | RGBForeColor( &gAGARamp[ kAGA4 ] ) ; | |
856 | PaintRect( &barRight ) ; | |
857 | } | |
858 | } | |
859 | if ( !EmptyRect( &barLeft ) ) | |
860 | { | |
861 | RGBForeColor( &gAGABlueRamp[ kAGA8 ] ) ; | |
862 | MoveTo( barLeft.left , barLeft.bottom -1 ) ; | |
863 | LineTo( barLeft.left , barLeft.top ) ; | |
864 | LineTo( barLeft.left+1 , barLeft.top ) ; | |
865 | RGBForeColor( &gAGABlueRamp[ kAGA12 ] ) ; | |
866 | MoveTo( barLeft.left + 2, barLeft.bottom-1 ) ; | |
867 | LineTo( barLeft.right-1 , barLeft.bottom-1 ) ; | |
868 | LineTo( barLeft.right-1 , barLeft.top -1 ) ; | |
869 | RGBForeColor( &gAGABlueRamp[ kAGA10 ] ) ; | |
870 | MoveTo( barLeft.left + 2, barLeft.top ) ; | |
871 | LineTo( barLeft.right-1 , barLeft.top ) ; | |
872 | pixelColor = gAGABlueRamp[ kAGA10] ; | |
873 | SetCPixel( barLeft.left + 1, barLeft.bottom-1 , &pixelColor ) ; | |
874 | InsetRect( &barLeft , 1 , 1 ) ; | |
875 | if ( !EmptyRect( &barLeft ) ) | |
876 | { | |
877 | // do more here | |
878 | RGBForeColor( &gAGABlueRamp[ kAGA3 ] ) ; | |
879 | PaintRect( &barLeft ) ; | |
880 | } | |
881 | } | |
882 | } | |
883 | } | |
884 | ||
885 | SInt32 AGAGetDataHelper( ControlDataAccessRec *rec , Size size , Ptr data ) ; | |
886 | SInt32 AGAGetDataHelper( ControlDataAccessRec *rec , Size size , Ptr data ) | |
887 | { | |
888 | if ( rec->dataPtr == NULL ) | |
889 | { | |
890 | rec->size = size ; | |
891 | return noErr ; | |
892 | } | |
893 | else | |
894 | { | |
895 | if ( rec->size < size ) | |
896 | return errDataSizeMismatch ; | |
897 | ||
898 | rec->size = size ; | |
899 | memcpy( rec->dataPtr , data , size ) ; | |
900 | return noErr ; | |
901 | } | |
902 | } | |
903 | ||
904 | void AGASetFontStyle( ControlFontStyleRec *fontstyle ) ; | |
905 | void AGASetFontStyle( ControlFontStyleRec *fontstyle ) | |
906 | { | |
907 | if( fontstyle->font >= 0 ) | |
908 | { | |
909 | ::TextFont( fontstyle->font ) ; | |
910 | ::TextSize( fontstyle->size ) ; | |
911 | ::TextFace( fontstyle->style ) ; | |
912 | } | |
913 | else | |
914 | { | |
915 | switch( fontstyle->font ) | |
916 | { | |
917 | case kControlFontBigSystemFont : | |
918 | ::TextFont( systemFont ) ; | |
919 | ::TextSize( 12 ) ; | |
920 | ::TextFace( 0 ) ; | |
921 | break ; | |
922 | case kControlFontSmallSystemFont : | |
923 | ::TextFont( kFontIDGeneva ) ; | |
924 | ::TextSize( 10 ) ; | |
925 | ::TextFace( 0 ) ; | |
926 | break ; | |
927 | case kControlFontSmallBoldSystemFont : | |
928 | ::TextFont( kFontIDGeneva ) ; | |
929 | ::TextSize( 10 ) ; | |
930 | ::TextFace( bold ) ; | |
931 | break ; | |
932 | } | |
933 | } | |
934 | ::RGBForeColor( &fontstyle->foreColor ) ; | |
935 | ::RGBBackColor( &fontstyle->backColor ) ; | |
936 | } ; | |
937 | ||
72582399 UJ |
938 | pascal SInt32 AGAProgressBarDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) |
939 | { | |
940 | switch( message ) | |
941 | { | |
942 | case drawCntl : | |
943 | { | |
944 | if (!(**theControl).contrlVis) | |
945 | return 0 ; | |
946 | PenState oldPenState; | |
947 | RGBColor oldForeColor ; | |
948 | RGBColor oldBackColor ; | |
949 | RGBColor backColor ; | |
950 | RGBColor foreColor ; | |
951 | ||
952 | GetPenState( &oldPenState ) ; | |
953 | GetBackColor( &oldBackColor ) ; | |
954 | GetForeColor( &oldForeColor ) ; | |
955 | ||
956 | { | |
957 | int theValue = GetControlValue(theControl) ; | |
958 | int theMinimum = GetControlMinimum(theControl) ; | |
959 | int theMaximum = GetControlMaximum(theControl) ; | |
960 | ||
961 | AGADrawRectProgress( &(**theControl).contrlRect , kAGAStateEnabled , (( double )( theValue - theMinimum )) / ( theMaximum-theMinimum ) ) ; | |
962 | } | |
963 | ||
964 | RGBForeColor(&oldForeColor); | |
965 | RGBBackColor(&oldBackColor); | |
966 | SetPenState(&oldPenState); | |
967 | } | |
968 | break ; | |
969 | case calcCntlRgn : | |
970 | RectRgn((RgnHandle) param , &(**theControl).contrlRect ) ; | |
971 | break ; | |
972 | default : | |
973 | break ; | |
974 | } | |
975 | ||
976 | return 0 ; | |
977 | } | |
978 | ||
979 | ||
980 | pascal SInt32 AGAPlacardDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) | |
981 | { | |
982 | switch( message ) | |
983 | { | |
984 | case drawCntl : | |
985 | { | |
986 | if (!(**theControl).contrlVis) | |
987 | return 0 ; | |
988 | PenState oldPenState; | |
989 | RGBColor oldForeColor ; | |
990 | RGBColor oldBackColor ; | |
991 | RGBColor backColor ; | |
992 | RGBColor foreColor ; | |
993 | ||
994 | GetPenState( &oldPenState ) ; | |
995 | GetBackColor( &oldBackColor ) ; | |
996 | GetForeColor( &oldForeColor ) ; | |
997 | ||
998 | { | |
999 | AGADrawRectPlacard( &(**theControl).contrlRect , kAGAStateEnabled , true ) ; | |
1000 | } | |
1001 | ||
1002 | RGBForeColor(&oldForeColor); | |
1003 | RGBBackColor(&oldBackColor); | |
1004 | SetPenState(&oldPenState); | |
1005 | } | |
1006 | break ; | |
1007 | default : | |
1008 | break ; | |
1009 | } | |
1010 | ||
1011 | return 0 ; | |
1012 | } | |
1013 | ||
1014 | pascal SInt32 AGABevelButtonDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) | |
1015 | { | |
1016 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**theControl).contrlRfCon ; | |
1017 | switch( message ) | |
1018 | { | |
1019 | case initCntl : | |
1020 | info->privateData = (long) malloc( sizeof( ControlButtonContentInfo ) ) ; | |
1021 | memset( (char*) info->privateData , 0 , sizeof( ControlButtonContentInfo ) ) ; | |
1022 | break ; | |
1023 | case dispCntl : | |
1024 | free( (void*) info->privateData ) ; | |
1025 | break ; | |
1026 | case kControlMsgSetData : | |
1027 | { | |
1028 | ControlDataAccessRec *rec = (ControlDataAccessRec *) param ; | |
1029 | if ( rec->tag == kControlBevelButtonContentTag ) | |
1030 | { | |
1031 | memcpy( (char*) info->privateData , rec->dataPtr , rec->size ) ; | |
1032 | return noErr ; | |
1033 | } | |
1034 | return errDataNotSupported ; | |
1035 | } | |
1036 | case kControlMsgCalcBestRect : | |
1037 | { | |
1038 | ControlCalcSizeRec *rec = (ControlCalcSizeRec *) param ; | |
1039 | rec->width = 0 ; | |
1040 | rec->height = 20 ; | |
1041 | rec->baseLine = 0; | |
1042 | } | |
1043 | break ; | |
1044 | case drawCntl : | |
1045 | { | |
1046 | if (!(**theControl).contrlVis) | |
1047 | return 0 ; | |
1048 | ||
1049 | { | |
2f1ae414 | 1050 | AGAPortHelper help((**theControl).contrlOwner) ; |
72582399 UJ |
1051 | AGASetFontStyle( &info->fontStyle ) ; |
1052 | Boolean mRadioBehavior = false ; | |
1053 | ||
1054 | int mValue = GetControlValue( theControl ) ; | |
1055 | long theValue = (mRadioBehavior ? mValue : 0); | |
1056 | Boolean inPushed = (**theControl).contrlHilite ; | |
1057 | Boolean down = inPushed || (theValue != 0); | |
1058 | Boolean hasColor = 1; | |
1059 | int mEnabled = 1 ; | |
1060 | int triState_Off = 3 ; | |
1061 | Boolean disabled = (mEnabled == triState_Off); | |
1062 | ||
1063 | Rect frame = (**theControl).contrlRect ; | |
1064 | ||
1065 | // Draw the black frame; | |
1066 | ::MoveTo(frame.left + 1, frame.top); | |
1067 | ::LineTo(frame.right - 2, frame.top); | |
1068 | ::MoveTo(frame.right - 1, frame.top + 1); | |
1069 | ::LineTo(frame.right - 1, frame.bottom - 2); | |
1070 | ::MoveTo(frame.right - 2, frame.bottom - 1); | |
1071 | ::LineTo(frame.left + 1, frame.bottom - 1); | |
1072 | ::MoveTo(frame.left, frame.bottom - 2); | |
1073 | ::LineTo(frame.left, frame.top + 1); | |
1074 | ||
1075 | // Draw the inside (w/o the Icon) | |
1076 | ::InsetRect(&frame, 1, 1); | |
1077 | if (hasColor) | |
1078 | { | |
1079 | AGASetFontStyle( &info->fontStyle ) ; | |
1080 | if (down) | |
1081 | ::RGBBackColor(&gAGAColorArray[4]); | |
1082 | } | |
1083 | ::EraseRect(&frame); | |
1084 | ||
1085 | // Draw the shadows | |
1086 | if (hasColor) | |
1087 | { | |
1088 | ::RGBForeColor(&gAGAColorArray[7]); | |
1089 | if (down) | |
1090 | { | |
1091 | ::MoveTo(frame.left, frame.bottom - 1); | |
1092 | ::LineTo(frame.left, frame.top); | |
1093 | ::LineTo(frame.right - 1, frame.top); | |
1094 | } | |
1095 | else | |
1096 | { | |
1097 | ::MoveTo(frame.right - 1, frame.top); | |
1098 | ::LineTo(frame.right - 1, frame.bottom - 1); | |
1099 | ::LineTo(frame.left, frame.bottom - 1); | |
1100 | ::MoveTo(frame.right - 2, frame.top + 1); | |
1101 | ::LineTo(frame.right - 2, frame.bottom - 2); | |
1102 | ::LineTo(frame.left + 1, frame.bottom - 2); | |
1103 | ::ForeColor(whiteColor); | |
1104 | ::MoveTo(frame.left, frame.bottom - 2); | |
1105 | ::LineTo(frame.left, frame.top); | |
1106 | ::LineTo(frame.right - 2, frame.top); | |
1107 | } | |
1108 | } | |
1109 | ||
1110 | // Draw the Icon | |
1111 | ||
1112 | frame = (**theControl).contrlRect ; | |
1113 | PictInfo theInfo ; | |
1114 | PicHandle thePict = ((ControlButtonContentInfo*) info->privateData)->u.picture ; | |
1115 | if ( thePict ) | |
1116 | { | |
1117 | GetPictInfo( thePict , &theInfo , 0 , 0 , systemMethod , 0 ) ; | |
1118 | Rect bitmaprect = { 0 , 0 , theInfo.sourceRect.bottom - theInfo.sourceRect.top , | |
1119 | theInfo.sourceRect.right - theInfo.sourceRect.left } ; | |
1120 | ::OffsetRect( &bitmaprect , (frame.right + frame.left)/2 - bitmaprect.right / 2 , (frame.bottom + frame.top) / 2 - bitmaprect.bottom / 2 ) ; | |
1121 | if (inPushed) | |
1122 | ::OffsetRect( &bitmaprect , 1 , 1 ) ; | |
1123 | ::DrawPicture( thePict , &bitmaprect ) ; | |
1124 | } | |
1125 | } | |
1126 | } | |
1127 | break ; | |
1128 | case testCntl : | |
1129 | { | |
1130 | Point pt ; | |
1131 | pt.h = LoWord( param ) ; | |
1132 | pt.v = HiWord( param ) ; | |
1133 | if ( PtInRect( pt , &(**theControl).contrlRect ) ) | |
1134 | return kControlButtonPart ; | |
1135 | else | |
1136 | return NULL ; | |
1137 | } | |
1138 | break ; | |
1139 | case calcCntlRgn : | |
1140 | RectRgn((RgnHandle) param , &(**theControl).contrlRect ) ; | |
1141 | break ; | |
1142 | case posCntl : | |
1143 | { | |
1144 | Point pt ; | |
1145 | pt.h = LoWord( param ) ; | |
1146 | pt.v = HiWord( param ) ; | |
1147 | if ( PtInRect( pt , &(**theControl).contrlRect ) ) | |
1148 | return kControlButtonPart ; | |
1149 | else | |
1150 | return NULL ; | |
1151 | } | |
1152 | break ; | |
1153 | default : | |
1154 | break ; | |
1155 | } | |
1156 | ||
1157 | return 0 ; | |
1158 | } | |
1159 | ||
1160 | pascal SInt32 AGAButtonDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) | |
1161 | { | |
1162 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**theControl).contrlRfCon ; | |
1163 | switch( message ) | |
1164 | { | |
1165 | case initCntl : | |
1166 | (**theControl).contrlData = NULL ; | |
1167 | break ; | |
1168 | case kControlMsgSetData : | |
1169 | { | |
1170 | ControlDataAccessRec *rec = (ControlDataAccessRec *) param ; | |
1171 | Boolean isDefault = *((Boolean*)rec->dataPtr ) ; | |
1172 | (**theControl).contrlData = (Handle) isDefault ; | |
1173 | return noErr ; | |
1174 | } | |
1175 | break ; | |
1176 | case kControlMsgCalcBestRect : | |
1177 | { | |
1178 | ControlCalcSizeRec *rec = (ControlCalcSizeRec *) param ; | |
1179 | rec->width = 0 ; | |
1180 | rec->height = 20 ; | |
1181 | rec->baseLine = 0; | |
1182 | } | |
1183 | break ; | |
1184 | case drawCntl : | |
1185 | { | |
1186 | if (!(**theControl).contrlVis) | |
1187 | return 0 ; | |
1188 | ||
1189 | { | |
2f1ae414 | 1190 | AGAPortHelper help((**theControl).contrlOwner) ; |
72582399 UJ |
1191 | AGASetFontStyle( &info->fontStyle ) ; |
1192 | Boolean mRadioBehavior = false ; | |
1193 | ||
1194 | Rect frame, tempRect; | |
1195 | int mValue = GetControlValue( theControl ) ; | |
1196 | long theValue = (mRadioBehavior ? mValue : 0); | |
1197 | Boolean inPushed = (**theControl).contrlHilite ; | |
1198 | Boolean down = inPushed || (theValue != 0); | |
1199 | Boolean hasColor = 1; | |
1200 | int mEnabled = 1 ; | |
1201 | int triState_Off = 3 ; | |
1202 | Boolean disabled = (mEnabled == triState_Off); | |
1203 | ||
1204 | // theState.Normalize(); | |
1205 | // CalcLocalFrameRect(frame); | |
1206 | frame= (**theControl).contrlRect ; | |
1207 | ||
1208 | if ( (**theControl).contrlData ) | |
1209 | { | |
1210 | InsetRect( &frame , -3 , -3 ) ; | |
1211 | { | |
1212 | ::MoveTo(frame.left + 3, frame.top); | |
1213 | ::LineTo(frame.right - 4, frame.top); | |
1214 | ::LineTo(frame.right - 1, frame.top + 3); | |
1215 | ::LineTo(frame.right - 1, frame.bottom - 4); | |
1216 | ::LineTo(frame.right - 4, frame.bottom - 1); | |
1217 | ::LineTo(frame.left + 3, frame.bottom - 1); | |
1218 | ::LineTo(frame.left, frame.bottom - 4); | |
1219 | ::LineTo(frame.left, frame.top + 3); | |
1220 | ::LineTo(frame.left + 3, frame.top); | |
1221 | ||
1222 | if (hasColor) | |
1223 | { | |
1224 | const RGBColor *col = gAGAColorArray; | |
1225 | for (int i = 0; i < 5; i++) | |
1226 | for (int j = 0; j < 5; j++) | |
1227 | { | |
1228 | if (LAGADefaultOutline_mCorners[0][i][j] != -1) | |
1229 | ::SetCPixel(frame.left + j, frame.top + i, &col[LAGADefaultOutline_mCorners[0][i][j]]); | |
1230 | if (LAGADefaultOutline_mCorners[1][i][j] != -1) | |
1231 | ::SetCPixel(frame.right - 5 + j, frame.top + i, &col[LAGADefaultOutline_mCorners[1][i][j]]); | |
1232 | if (LAGADefaultOutline_mCorners[2][i][j] != -1) | |
1233 | ::SetCPixel(frame.left + j, frame.bottom - 5 + i, &col[LAGADefaultOutline_mCorners[2][i][j]]); | |
1234 | if (LAGADefaultOutline_mCorners[3][i][j] != -1) | |
1235 | ::SetCPixel(frame.right - 5 + j, frame.bottom - 5 + i, &col[LAGADefaultOutline_mCorners[3][i][j]]); | |
1236 | } | |
1237 | ||
1238 | ::RGBForeColor(&gAGAColorArray[2]); | |
1239 | ::MoveTo(frame.left + 1, frame.top + 5); | |
1240 | ::LineTo(frame.left + 1, frame.bottom - 6); | |
1241 | ::MoveTo(frame.left + 5, frame.top + 1); | |
1242 | ::LineTo(frame.right - 6, frame.top + 1); | |
1243 | ||
1244 | ::RGBForeColor(&gAGAColorArray[5]); | |
1245 | ::MoveTo(frame.left + 4, frame.top + 2); | |
1246 | ::LineTo(frame.right - 5, frame.top + 2); | |
1247 | ::LineTo(frame.right - 3, frame.top + 4); | |
1248 | ::LineTo(frame.right - 3, frame.bottom - 5); | |
1249 | ::LineTo(frame.right - 5, frame.bottom - 3); | |
1250 | ::LineTo(frame.left + 4, frame.bottom - 3); | |
1251 | ::LineTo(frame.left + 2, frame.bottom - 5); | |
1252 | ::LineTo(frame.left + 2, frame.top + 4); | |
1253 | ::LineTo(frame.left + 4, frame.top + 2); | |
1254 | ||
1255 | ::RGBForeColor(&gAGAColorArray[8]); | |
1256 | ::MoveTo(frame.right - 2, frame.top + 5); | |
1257 | ::LineTo(frame.right - 2, frame.bottom - 6); | |
1258 | ::MoveTo(frame.left + 5, frame.bottom - 2); | |
1259 | ::LineTo(frame.right - 6, frame.bottom - 2); | |
1260 | } | |
1261 | } | |
1262 | } | |
1263 | ||
1264 | AGASetFontStyle( &info->fontStyle ) ; | |
1265 | frame= (**theControl).contrlRect ; | |
1266 | ||
1267 | tempRect = frame; | |
1268 | ::InsetRect(&tempRect, 1, 1); | |
1269 | if (hasColor) | |
1270 | { | |
1271 | if (down) | |
1272 | ::RGBBackColor(&gAGAColorArray[4]); | |
1273 | } | |
1274 | EraseRect(&tempRect); | |
1275 | ||
1276 | // Draw the frame; | |
1277 | if (disabled) | |
1278 | { | |
1279 | if (hasColor) | |
1280 | ::RGBForeColor(&gAGAColorArray[7]); | |
1281 | else | |
1282 | ::PenPat(&qd.gray); | |
1283 | } | |
1284 | ::MoveTo(frame.left + 2, frame.top); | |
1285 | ::LineTo(frame.right - 3, frame.top); | |
1286 | ::LineTo(frame.right - 1, frame.top + 2); | |
1287 | ::LineTo(frame.right - 1, frame.bottom - 3); | |
1288 | ::LineTo(frame.right - 3, frame.bottom - 1); | |
1289 | ::LineTo(frame.left + 2, frame.bottom - 1); | |
1290 | ::LineTo(frame.left, frame.bottom - 3); | |
1291 | ::LineTo(frame.left, frame.top + 2); | |
1292 | ::LineTo(frame.left + 2, frame.top); | |
1293 | if (disabled && !hasColor) | |
1294 | ::PenNormal(); | |
1295 | ||
1296 | // Draw the four corners around | |
1297 | if (hasColor) | |
1298 | { | |
1299 | short pattern = (disabled ? 2 : (down ? 1 : 0)); | |
1300 | const RGBColor *col = gAGAColorArray; | |
1301 | for (int i = 0; i < 4; i++) | |
1302 | for (int j = 0; j < 4; j++) | |
1303 | { | |
1304 | if (LAGAPushButton_mCorners[pattern][0][i][j] != -1) | |
1305 | ::SetCPixel(frame.left + j, frame.top + i, &col[LAGAPushButton_mCorners[pattern][0][i][j]]); | |
1306 | if (LAGAPushButton_mCorners[pattern][1][i][j] != -1) | |
1307 | ::SetCPixel(frame.right - 4 + j, frame.top + i, &col[LAGAPushButton_mCorners[pattern][1][i][j]]); | |
1308 | if (LAGAPushButton_mCorners[pattern][2][i][j] != -1) | |
1309 | ::SetCPixel(frame.left + j, frame.bottom - 4 + i, &col[LAGAPushButton_mCorners[pattern][2][i][j]]); | |
1310 | if (LAGAPushButton_mCorners[pattern][3][i][j] != -1) | |
1311 | ::SetCPixel(frame.right - 4 + j, frame.bottom - 4 + i, &col[LAGAPushButton_mCorners[pattern][3][i][j]]); | |
1312 | } | |
1313 | ||
1314 | if (down) | |
1315 | ::RGBForeColor(&gAGAColorArray[8]); | |
1316 | else | |
1317 | ::RGBForeColor(&gAGAColorArray[2]); | |
1318 | ::MoveTo(frame.left + 1, frame.top + 4); | |
1319 | ::LineTo(frame.left + 1, frame.bottom - 5); | |
1320 | ::MoveTo(frame.left + 4, frame.top + 1); | |
1321 | ::LineTo(frame.right - 5, frame.top + 1); | |
1322 | ||
1323 | if (!down) | |
1324 | { | |
1325 | if (disabled) | |
1326 | ::RGBForeColor(&gAGAColorArray[1]); | |
1327 | else | |
1328 | ::ForeColor(whiteColor); | |
1329 | ::MoveTo(frame.left + 2, frame.bottom - 5); | |
1330 | ::LineTo(frame.left + 2, frame.top + 2); | |
1331 | ::LineTo(frame.right - 5, frame.top + 2); | |
1332 | ||
1333 | if (disabled) | |
1334 | ::RGBForeColor(&gAGAColorArray[5]); | |
1335 | else | |
1336 | ::RGBForeColor(&gAGAColorArray[8]); | |
1337 | ::MoveTo(frame.left + 4, frame.bottom - 2); | |
1338 | ::LineTo(frame.right - 5, frame.bottom - 2); | |
1339 | ::MoveTo(frame.right - 2, frame.bottom - 5); | |
1340 | ::LineTo(frame.right - 2, frame.top + 4); | |
1341 | ||
1342 | if (disabled) | |
1343 | ::RGBForeColor(&gAGAColorArray[4]); | |
1344 | else | |
1345 | ::RGBForeColor(&gAGAColorArray[5]); | |
1346 | ::MoveTo(frame.left + 4, frame.bottom - 3); | |
1347 | ::LineTo(frame.right - 5, frame.bottom - 3); | |
1348 | ::MoveTo(frame.right - 3, frame.bottom - 5); | |
1349 | ::LineTo(frame.right - 3, frame.top + 4); | |
1350 | } | |
1351 | } | |
1352 | AGASetFontStyle( &info->fontStyle ) ; | |
1353 | int x = ( (**theControl).contrlRect.left + (**theControl).contrlRect.right ) / 2 ; | |
1354 | int y = ( (**theControl).contrlRect.top + (**theControl).contrlRect.bottom ) / 2 ; | |
1355 | FontInfo fi ; | |
1356 | ::GetFontInfo( &fi ) ; | |
1357 | ||
1358 | y += fi.ascent / 2 ; | |
1359 | int length = (**theControl).contrlTitle[0] ; | |
1360 | if ( length ) | |
1361 | { | |
1362 | int width = TextWidth( &(**theControl).contrlTitle[1] , 0, length ) ; | |
1363 | x -= width / 2 ; | |
1364 | ::MoveTo( x , y ); | |
1365 | ::DrawText( &(**theControl).contrlTitle[1] , 0, length); | |
1366 | } | |
1367 | ||
1368 | } | |
1369 | } | |
1370 | break ; | |
1371 | case testCntl : | |
1372 | { | |
1373 | Point pt ; | |
1374 | pt.h = LoWord( param ) ; | |
1375 | pt.v = HiWord( param ) ; | |
1376 | if ( PtInRect( pt , &(**theControl).contrlRect ) ) | |
1377 | return kControlButtonPart ; | |
1378 | else | |
1379 | return NULL ; | |
1380 | } | |
1381 | break ; | |
1382 | case calcCntlRgn : | |
1383 | RectRgn((RgnHandle) param , &(**theControl).contrlRect ) ; | |
1384 | break ; | |
1385 | case posCntl : | |
1386 | { | |
1387 | Point pt ; | |
1388 | pt.h = LoWord( param ) ; | |
1389 | pt.v = HiWord( param ) ; | |
1390 | if ( PtInRect( pt , &(**theControl).contrlRect ) ) | |
1391 | return kControlButtonPart ; | |
1392 | else | |
1393 | return NULL ; | |
1394 | } | |
1395 | break ; | |
1396 | default : | |
1397 | break ; | |
1398 | } | |
1399 | ||
1400 | return 0 ; | |
1401 | } | |
1402 | ||
1403 | const int kAGACheckBoxWidth = 12 ; | |
1404 | const int kAGACheckBoxHeigth = 12 ; | |
1405 | ||
1406 | pascal SInt32 AGACheckBoxDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) | |
1407 | { | |
1408 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**theControl).contrlRfCon ; | |
1409 | switch( message ) | |
1410 | { | |
1411 | case drawCntl : | |
1412 | { | |
1413 | if (!(**theControl).contrlVis) | |
1414 | return 0 ; | |
1415 | PenState oldPenState; | |
1416 | RGBColor oldForeColor ; | |
1417 | RGBColor oldBackColor ; | |
1418 | RGBColor backColor ; | |
1419 | RGBColor foreColor ; | |
1420 | ||
1421 | ||
1422 | { | |
1423 | if (!(**theControl).contrlVis) | |
1424 | return 0 ; | |
1425 | ||
1426 | { | |
2f1ae414 | 1427 | AGAPortHelper help((**theControl).contrlOwner) ; |
72582399 UJ |
1428 | Rect frame = (**theControl).contrlRect ; |
1429 | Boolean hasColor = true; | |
1430 | Boolean disabled = (*theControl)->contrlHilite == 255 ; | |
1431 | int mValue = GetControlValue( theControl ) ; | |
1432 | Boolean inPushed = (**theControl).contrlHilite ; | |
1433 | int mEnabled = 1 ; | |
1434 | int triState_Off = 3 ; | |
1435 | ||
1436 | frame.right = frame.left + kAGACheckBoxWidth; | |
1437 | frame.bottom = frame.top + kAGACheckBoxHeigth; | |
1438 | ||
1439 | // Draw the frame of the checkbox | |
1440 | if (disabled) | |
1441 | if (hasColor) | |
1442 | ::RGBForeColor(&gAGAColorArray[7]); | |
1443 | else | |
1444 | PenPat(&qd.gray); | |
1445 | ||
1446 | ::FrameRect(&frame); | |
1447 | ||
1448 | if (!hasColor) | |
1449 | PenNormal(); | |
1450 | ||
1451 | ::InsetRect(&frame, 1, 1); | |
1452 | if (hasColor) | |
1453 | ::RGBBackColor(inPushed ? &gAGAColorArray[8] : &gAGAColorArray[2]); | |
1454 | ::EraseRect(&frame); | |
1455 | ||
1456 | if (hasColor) | |
1457 | { | |
1458 | if (inPushed) | |
1459 | ::RGBForeColor(&gAGAColorArray[10]); | |
1460 | else | |
1461 | ForeColor(whiteColor); | |
1462 | ::MoveTo(frame.left, frame.bottom - 2); | |
1463 | ::LineTo(frame.left, frame.top); | |
1464 | ::LineTo(frame.right - 2, frame.top); | |
1465 | ||
1466 | if (inPushed) | |
1467 | ::RGBForeColor(&gAGAColorArray[6]); | |
1468 | else | |
1469 | ::RGBForeColor(mEnabled != triState_Off ? &gAGAColorArray[7] : &gAGAColorArray[5]); | |
1470 | ::MoveTo(frame.left + 1, frame.bottom - 1); | |
1471 | ::LineTo(frame.right - 1, frame.bottom - 1); | |
1472 | ::LineTo(frame.right - 1, frame.top + 1); | |
1473 | } | |
1474 | ||
1475 | if (mValue) | |
1476 | { | |
1477 | if (mValue == 1) | |
1478 | { | |
1479 | // Checked state | |
1480 | if (hasColor) | |
1481 | { | |
1482 | ::RGBForeColor(inPushed ? &gAGAColorArray[10] : &gAGAColorArray[5]); | |
1483 | ::MoveTo(frame.left + 3, frame.bottom - 2); | |
1484 | ::LineTo(frame.right - 2, frame.top + 3); | |
1485 | ::MoveTo(frame.right - 2, frame.bottom - 2); | |
1486 | ::LineTo(frame.right - 2, frame.bottom - 2); | |
1487 | ||
1488 | if (mEnabled != triState_Off) | |
1489 | ::RGBForeColor(inPushed ? &gAGAColorArray[11] : &gAGAColorArray[8]); | |
1490 | ::MoveTo(frame.left + 3, frame.bottom - 3); | |
1491 | ::LineTo(frame.right - 2, frame.top + 2); | |
1492 | ::MoveTo(frame.right - 2, frame.bottom - 3); | |
1493 | ::LineTo(frame.right - 2, frame.bottom - 3); | |
1494 | ||
1495 | if (mEnabled != triState_Off) | |
1496 | ::ForeColor(blackColor); | |
1497 | else | |
1498 | ::RGBForeColor(&gAGAColorArray[7]); | |
1499 | } | |
1500 | ::MoveTo(frame.left + 2, frame.top + 1); | |
1501 | ::LineTo(frame.right - 3, frame.bottom - 4); | |
1502 | ::MoveTo(frame.left + 2, frame.top + 2); | |
1503 | ::LineTo(frame.right - 3, frame.bottom - 3); | |
1504 | ::MoveTo(frame.left + 2, frame.bottom - 4); | |
1505 | ::LineTo(frame.right - 3, frame.top + 1); | |
1506 | ::MoveTo(frame.left + 2, frame.bottom - 3); | |
1507 | ::LineTo(frame.right - 3, frame.top + 2); | |
1508 | } | |
1509 | else | |
1510 | { | |
1511 | // Mixed state | |
1512 | if (hasColor) | |
1513 | { | |
1514 | ::RGBForeColor(inPushed ? &gAGAColorArray[10] : &gAGAColorArray[5]); | |
1515 | ::MoveTo(frame.left + 3, frame.top + 6); | |
1516 | ::LineTo(frame.right - 2, frame.top + 6); | |
1517 | ::LineTo(frame.right - 2, frame.top + 4); | |
1518 | ||
1519 | if (mEnabled != triState_Off) | |
1520 | ::ForeColor(blackColor); | |
1521 | else | |
1522 | ::RGBForeColor(&gAGAColorArray[7]); | |
1523 | } | |
1524 | ::MoveTo(frame.left + 2, frame.top + 4); | |
1525 | ::LineTo(frame.right - 3, frame.top + 4); | |
1526 | ::MoveTo(frame.left + 2, frame.top + 5); | |
1527 | ::LineTo(frame.right - 3, frame.top + 5); | |
1528 | } | |
1529 | } | |
1530 | ||
1531 | if (inPushed && !hasColor) | |
1532 | InvertRect(&frame); | |
1533 | ||
1534 | AGASetFontStyle( &info->fontStyle ) ; | |
1535 | int x = (**theControl).contrlRect.left + kAGACheckBoxWidth + 5 ; | |
1536 | int y = ( (**theControl).contrlRect.top + (**theControl).contrlRect.bottom ) / 2 ; | |
1537 | FontInfo fi ; | |
1538 | ::GetFontInfo( &fi ) ; | |
1539 | ||
1540 | y += fi.ascent / 2 ; | |
1541 | ::MoveTo( x , y ); | |
1542 | int length = (**theControl).contrlTitle[0] ; | |
1543 | if ( length ) | |
1544 | { | |
1545 | ::DrawText( &(**theControl).contrlTitle[1] , 0, length); | |
1546 | } | |
1547 | } | |
1548 | } | |
1549 | ||
1550 | } | |
1551 | break ; | |
1552 | case testCntl : | |
1553 | { | |
1554 | Point pt ; | |
1555 | pt.h = LoWord( param ) ; | |
1556 | pt.v = HiWord( param ) ; | |
1557 | if ( PtInRect( pt , &(**theControl).contrlRect ) && ((*theControl)->contrlVis != 0) && ((*theControl)->contrlHilite != 255) ) | |
1558 | return kControlCheckBoxPart ; | |
1559 | else | |
1560 | return NULL ; | |
1561 | } | |
1562 | break ; | |
1563 | case posCntl : | |
1564 | { | |
1565 | Point pt ; | |
1566 | pt.h = LoWord( param ) ; | |
1567 | pt.v = HiWord( param ) ; | |
1568 | if ( PtInRect( pt , &(**theControl).contrlRect ) ) | |
1569 | { | |
1570 | if ( (**theControl).contrlValue ) | |
1571 | (**theControl).contrlValue = 0 ; | |
1572 | else | |
1573 | (**theControl).contrlValue = 1 ; | |
1574 | ||
1575 | return 0 ; | |
1576 | } | |
1577 | else | |
1578 | return 0 ; | |
1579 | } | |
1580 | break ; | |
1581 | case calcThumbRgn : | |
1582 | case calcCntlRgn : | |
1583 | if ( !EmptyRect(&(**theControl).contrlRect ) ) | |
1584 | RectRgn((RgnHandle) param , &(**theControl).contrlRect ) ; | |
1585 | break ; | |
1586 | case kControlMsgCalcBestRect : | |
1587 | { | |
1588 | ControlCalcSizeRec *rec = (ControlCalcSizeRec *) param ; | |
1589 | rec->width = (**theControl).contrlRect.right - (**theControl).contrlRect.left ; | |
1590 | rec->height = kAGACheckBoxHeigth ; | |
1591 | rec->baseLine = 0; | |
1592 | } | |
1593 | break ; | |
1594 | default : | |
1595 | break ; | |
1596 | } | |
1597 | ||
1598 | return 0 ; | |
1599 | } | |
1600 | ||
1601 | pascal SInt32 AGARadioButtonDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) | |
1602 | { | |
1603 | //TO DO | |
1604 | /* ExtCDEFInfo* info = (ExtCDEFInfo* ) (**theControl).contrlRfCon ; | |
1605 | switch( message ) | |
1606 | { | |
1607 | case drawCntl : | |
1608 | { | |
1609 | if (!(**theControl).contrlVis) | |
1610 | return 0 ; | |
1611 | PenState oldPenState; | |
1612 | RGBColor oldForeColor ; | |
1613 | RGBColor oldBackColor ; | |
1614 | RGBColor backColor ; | |
1615 | RGBColor foreColor ; | |
1616 | ||
1617 | ||
1618 | { | |
1619 | if (!(**theControl).contrlVis) | |
1620 | return 0 ; | |
1621 | ||
1622 | { | |
1623 | AGAPortHelper help() ; | |
1624 | Rect frame = (**theControl).contrlRect ; | |
1625 | Boolean hasColor = true; | |
1626 | Boolean disabled = (*theControl)->contrlHilite == 255 ; | |
1627 | int mValue = GetControlValue( theControl ) ; | |
1628 | Boolean inPushed = (**theControl).contrlHilite ; | |
1629 | int mEnabled = 1 ; | |
1630 | int triState_Off = 3 ; | |
1631 | ||
1632 | frame.right = frame.left + kAGACheckBoxWidth; | |
1633 | frame.bottom = frame.top + kAGACheckBoxHeigth; | |
1634 | ||
1635 | // Draw the frame of the checkbox | |
1636 | if (disabled) | |
1637 | if (hasColor) | |
1638 | ::RGBForeColor(&gAGAColorArray[7]); | |
1639 | else | |
1640 | PenPat(&qd.gray); | |
1641 | ||
1642 | ::FrameRect(&frame); | |
1643 | ||
1644 | if (!hasColor) | |
1645 | PenNormal(); | |
1646 | ||
1647 | ::InsetRect(&frame, 1, 1); | |
1648 | if (hasColor) | |
1649 | ::RGBBackColor(inPushed ? &gAGAColorArray[8] : &gAGAColorArray[2]); | |
1650 | ::EraseRect(&frame); | |
1651 | ||
1652 | if (hasColor) | |
1653 | { | |
1654 | if (inPushed) | |
1655 | ::RGBForeColor(&gAGAColorArray[10]); | |
1656 | else | |
1657 | ForeColor(whiteColor); | |
1658 | ::MoveTo(frame.left, frame.bottom - 2); | |
1659 | ::LineTo(frame.left, frame.top); | |
1660 | ::LineTo(frame.right - 2, frame.top); | |
1661 | ||
1662 | if (inPushed) | |
1663 | ::RGBForeColor(&gAGAColorArray[6]); | |
1664 | else | |
1665 | ::RGBForeColor(mEnabled != triState_Off ? &gAGAColorArray[7] : &gAGAColorArray[5]); | |
1666 | ::MoveTo(frame.left + 1, frame.bottom - 1); | |
1667 | ::LineTo(frame.right - 1, frame.bottom - 1); | |
1668 | ::LineTo(frame.right - 1, frame.top + 1); | |
1669 | } | |
1670 | ||
1671 | if (mValue) | |
1672 | { | |
1673 | if (mValue == 1) | |
1674 | { | |
1675 | // Checked state | |
1676 | if (hasColor) | |
1677 | { | |
1678 | ::RGBForeColor(inPushed ? &gAGAColorArray[10] : &gAGAColorArray[5]); | |
1679 | ::MoveTo(frame.left + 3, frame.bottom - 2); | |
1680 | ::LineTo(frame.right - 2, frame.top + 3); | |
1681 | ::MoveTo(frame.right - 2, frame.bottom - 2); | |
1682 | ::LineTo(frame.right - 2, frame.bottom - 2); | |
1683 | ||
1684 | if (mEnabled != triState_Off) | |
1685 | ::RGBForeColor(inPushed ? &gAGAColorArray[11] : &gAGAColorArray[8]); | |
1686 | ::MoveTo(frame.left + 3, frame.bottom - 3); | |
1687 | ::LineTo(frame.right - 2, frame.top + 2); | |
1688 | ::MoveTo(frame.right - 2, frame.bottom - 3); | |
1689 | ::LineTo(frame.right - 2, frame.bottom - 3); | |
1690 | ||
1691 | if (mEnabled != triState_Off) | |
1692 | ::ForeColor(blackColor); | |
1693 | else | |
1694 | ::RGBForeColor(&gAGAColorArray[7]); | |
1695 | } | |
1696 | ::MoveTo(frame.left + 2, frame.top + 1); | |
1697 | ::LineTo(frame.right - 3, frame.bottom - 4); | |
1698 | ::MoveTo(frame.left + 2, frame.top + 2); | |
1699 | ::LineTo(frame.right - 3, frame.bottom - 3); | |
1700 | ::MoveTo(frame.left + 2, frame.bottom - 4); | |
1701 | ::LineTo(frame.right - 3, frame.top + 1); | |
1702 | ::MoveTo(frame.left + 2, frame.bottom - 3); | |
1703 | ::LineTo(frame.right - 3, frame.top + 2); | |
1704 | } | |
1705 | else | |
1706 | { | |
1707 | // Mixed state | |
1708 | if (hasColor) | |
1709 | { | |
1710 | ::RGBForeColor(inPushed ? &gAGAColorArray[10] : &gAGAColorArray[5]); | |
1711 | ::MoveTo(frame.left + 3, frame.top + 6); | |
1712 | ::LineTo(frame.right - 2, frame.top + 6); | |
1713 | ::LineTo(frame.right - 2, frame.top + 4); | |
1714 | ||
1715 | if (mEnabled != triState_Off) | |
1716 | ::ForeColor(blackColor); | |
1717 | else | |
1718 | ::RGBForeColor(&gAGAColorArray[7]); | |
1719 | } | |
1720 | ::MoveTo(frame.left + 2, frame.top + 4); | |
1721 | ::LineTo(frame.right - 3, frame.top + 4); | |
1722 | ::MoveTo(frame.left + 2, frame.top + 5); | |
1723 | ::LineTo(frame.right - 3, frame.top + 5); | |
1724 | } | |
1725 | } | |
1726 | ||
1727 | if (inPushed && !hasColor) | |
1728 | InvertRect(&frame); | |
1729 | ||
1730 | AGASetFontStyle( &info->fontStyle ) ; | |
1731 | int x = (**theControl).contrlRect.left + kAGACheckBoxWidth + 5 ; | |
1732 | int y = ( (**theControl).contrlRect.top + (**theControl).contrlRect.bottom ) / 2 ; | |
1733 | FontInfo fi ; | |
1734 | ::GetFontInfo( &fi ) ; | |
1735 | ||
1736 | y += fi.ascent / 2 ; | |
1737 | ::MoveTo( x , y ); | |
1738 | int length = (**theControl).contrlTitle[0] ; | |
1739 | if ( length ) | |
1740 | { | |
1741 | ::DrawText( &(**theControl).contrlTitle[1] , 0, length); | |
1742 | } | |
1743 | } | |
1744 | } | |
1745 | ||
1746 | } | |
1747 | break ; | |
1748 | case testCntl : | |
1749 | { | |
1750 | Point pt ; | |
1751 | pt.h = LoWord( param ) ; | |
1752 | pt.v = HiWord( param ) ; | |
1753 | if ( PtInRect( pt , &(**theControl).contrlRect ) && ((*theControl)->contrlVis != 0) && ((*theControl)->contrlHilite != 255) ) | |
1754 | return kControlCheckBoxPart ; | |
1755 | else | |
1756 | return NULL ; | |
1757 | } | |
1758 | break ; | |
1759 | case posCntl : | |
1760 | { | |
1761 | Point pt ; | |
1762 | pt.h = LoWord( param ) ; | |
1763 | pt.v = HiWord( param ) ; | |
1764 | if ( PtInRect( pt , &(**theControl).contrlRect ) ) | |
1765 | { | |
1766 | if ( (**theControl).contrlValue ) | |
1767 | (**theControl).contrlValue = 0 ; | |
1768 | else | |
1769 | (**theControl).contrlValue = 1 ; | |
1770 | ||
1771 | return 0 ; | |
1772 | } | |
1773 | else | |
1774 | return 0 ; | |
1775 | } | |
1776 | break ; | |
1777 | case calcThumbRgn : | |
1778 | case calcCntlRgn : | |
1779 | if ( !EmptyRect(&(**theControl).contrlRect ) ) | |
1780 | RectRgn((RgnHandle) param , &(**theControl).contrlRect ) ; | |
1781 | break ; | |
1782 | case kControlMsgCalcBestRect : | |
1783 | { | |
1784 | ControlCalcSizeRec *rec = (ControlCalcSizeRec *) param ; | |
1785 | rec->width = (**theControl).contrlRect.right - (**theControl).contrlRect.left ; | |
1786 | rec->height = kAGACheckBoxHeigth ; | |
1787 | rec->baseLine = 0; | |
1788 | } | |
1789 | break ; | |
1790 | default : | |
1791 | break ; | |
1792 | } | |
1793 | */ | |
1794 | return 0 ; | |
1795 | } | |
1796 | ||
1797 | pascal SInt32 AGAStaticGroupBoxTextDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) | |
1798 | { | |
1799 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**theControl).contrlRfCon ; | |
1800 | ||
1801 | switch( message ) | |
1802 | { | |
1803 | case initCntl : | |
1804 | break ; | |
1805 | case dispCntl : | |
1806 | break ; | |
1807 | case drawCntl : | |
1808 | { | |
1809 | if (!(**theControl).contrlVis) | |
1810 | return 0 ; | |
1811 | ||
1812 | { | |
1813 | bool disabled = false ; | |
1814 | bool hasColor = true ; | |
2f1ae414 | 1815 | AGAPortHelper help((**theControl).contrlOwner) ; |
72582399 UJ |
1816 | AGASetFontStyle( &info->fontStyle ) ; |
1817 | FontInfo fi ; | |
1818 | ::GetFontInfo( &fi ) ; | |
1819 | ||
1820 | Rect labelRect = (**theControl).contrlRect ; | |
1821 | Rect theFrame = (**theControl).contrlRect ; | |
1822 | int width = StringWidth((**theControl).contrlTitle) ; | |
1823 | theFrame.top += fi.ascent + fi.leading >> 1 ; | |
1824 | labelRect.bottom = theFrame.top + 8 ; | |
1825 | labelRect.left += 10 ; | |
1826 | labelRect.right =labelRect.left + width + 6 ; | |
1827 | ||
1828 | theFrame.bottom--; | |
1829 | theFrame.right--; | |
1830 | ||
1831 | if (disabled) | |
1832 | { | |
1833 | RGBForeColor( &gAGAColorArray[4] ) ; | |
1834 | } | |
1835 | else | |
1836 | { | |
1837 | RGBForeColor( &gAGAColorArray[7] ) ; | |
1838 | } | |
1839 | FrameRect( &theFrame ) ; | |
1840 | ||
1841 | if (disabled) | |
1842 | ::RGBForeColor(&gAGAColorArray[1]); | |
1843 | else | |
1844 | ::ForeColor(whiteColor); | |
1845 | ::MoveTo(theFrame.left + 1, theFrame.bottom - 2); | |
1846 | ::LineTo(theFrame.left + 1, theFrame.top + 1); | |
1847 | ::LineTo(theFrame.right - 2, theFrame.top + 1); | |
1848 | ::MoveTo(theFrame.left , theFrame.bottom); | |
1849 | ::LineTo(theFrame.right, theFrame.bottom); | |
1850 | ::LineTo(theFrame.right, theFrame.top); | |
1851 | ||
1852 | AGASetFontStyle( &info->fontStyle ) ; | |
1853 | ::EraseRect( &labelRect ) ; | |
1854 | ::MoveTo(labelRect.left + 3, labelRect.top + fi.ascent + (fi.leading >> 1)); | |
1855 | ::DrawString((**theControl).contrlTitle); | |
1856 | } | |
1857 | } | |
1858 | break ; | |
1859 | case kControlMsgCalcBestRect : | |
1860 | { | |
1861 | ControlCalcSizeRec *rec = (ControlCalcSizeRec *) param ; | |
1862 | rec->width = (**theControl).contrlRect.right - (**theControl).contrlRect.left ; | |
1863 | rec->height = (**theControl).contrlRect.bottom - (**theControl).contrlRect.top ; | |
1864 | rec->baseLine = 0; | |
1865 | } | |
1866 | break ; | |
1867 | case kControlMsgSetData : | |
1868 | break ; | |
1869 | case calcCntlRgn : | |
1870 | RectRgn((RgnHandle) param , &(**theControl).contrlRect ) ; | |
1871 | break ; | |
1872 | default : | |
1873 | break ; | |
1874 | } | |
1875 | ||
1876 | return 0 ; | |
1877 | } | |
1878 | ||
1879 | pascal SInt32 AGAStaticTextDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) | |
1880 | { | |
1881 | Handle macText = (**theControl).contrlData ; | |
1882 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**theControl).contrlRfCon ; | |
1883 | ||
1884 | switch( message ) | |
1885 | { | |
1886 | case initCntl : | |
1887 | { | |
1888 | macText = NewHandle(0) ; | |
1889 | (**theControl).contrlData = (Handle) macText ; | |
1890 | } | |
1891 | break ; | |
1892 | case dispCntl : | |
1893 | DisposeHandle( macText ) ; | |
1894 | break ; | |
1895 | case drawCntl : | |
1896 | { | |
1897 | if (!(**theControl).contrlVis) | |
1898 | return 0 ; | |
1899 | ||
1900 | { | |
2f1ae414 | 1901 | AGAPortHelper help((**theControl).contrlOwner) ; |
72582399 UJ |
1902 | AGASetFontStyle( &info->fontStyle ) ; |
1903 | int x = (**theControl).contrlRect.left ; | |
1904 | int y = (**theControl).contrlRect.top ; | |
1905 | int lineheight ; | |
1906 | FontInfo fi ; | |
1907 | ::GetFontInfo( &fi ) ; | |
1908 | ||
1909 | y += fi.ascent ; | |
1910 | lineheight = fi.ascent + fi.descent + fi.leading ; | |
1911 | int length = GetHandleSize( macText ) ; | |
1912 | if ( length ) | |
1913 | { | |
1914 | int laststop = 0 ; | |
1915 | int i = 0 ; | |
1916 | HLock( macText ) ; | |
1917 | RGBColor gray = { 0xDDDD , 0xDDDD, 0xDDDD } ; | |
1918 | ::RGBBackColor( &gray ) ; | |
1919 | while( i < length ) | |
1920 | { | |
1921 | if ( (*macText)[i] == 0x0d ) | |
1922 | { | |
1923 | ::MoveTo( x , y ); | |
1924 | ::DrawText( *macText , laststop, i-laststop); | |
1925 | laststop = i+1 ; | |
1926 | y += lineheight ; | |
1927 | } | |
1928 | i++ ; | |
1929 | } | |
1930 | ::MoveTo( x , y ); | |
1931 | ::DrawText( *macText , laststop, i-laststop); | |
1932 | laststop = i+1 ; | |
1933 | HUnlock( macText ) ; | |
1934 | } | |
1935 | } | |
1936 | } | |
1937 | break ; | |
1938 | case kControlMsgCalcBestRect : | |
1939 | { | |
1940 | ControlCalcSizeRec *rec = (ControlCalcSizeRec *) param ; | |
1941 | rec->width = (**theControl).contrlRect.right - (**theControl).contrlRect.left ; | |
1942 | rec->height = (**theControl).contrlRect.bottom - (**theControl).contrlRect.top ; | |
1943 | rec->baseLine = 0; | |
1944 | } | |
1945 | break ; | |
1946 | case kControlMsgSetData : | |
1947 | { | |
1948 | ControlDataAccessRec *rec = (ControlDataAccessRec *) param ; | |
1949 | if ( rec->tag == kControlStaticTextTextTag ) | |
1950 | { | |
1951 | SetHandleSize( macText , rec->size ) ; | |
1952 | memcpy( *macText , rec->dataPtr , rec->size ) ; | |
1953 | return noErr ; | |
1954 | } | |
1955 | return errDataNotSupported ; | |
1956 | } | |
1957 | default : | |
1958 | break ; | |
1959 | } | |
1960 | ||
1961 | return 0 ; | |
1962 | } | |
1963 | ||
1964 | void AGAMoveControl(ControlHandle inControl , short x , short y ) | |
1965 | { | |
1966 | if ( AGATestForNewControl( inControl ) ) | |
1967 | { | |
1968 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
1969 | if ( info->magic == kExtCDEFMagic ) | |
1970 | { | |
1971 | if ( info->procID == kControlEditTextProc) | |
1972 | { | |
1973 | int dx ; | |
1974 | int dy ; | |
1975 | ||
1976 | dx= x - (**inControl).contrlRect.left ; | |
1977 | dy= y - (**inControl).contrlRect.top ; | |
1978 | ||
1979 | MoveControl( inControl , x ,y ) ; | |
1980 | TEHandle macTE ; | |
1981 | ||
1982 | macTE = (TEHandle) (**inControl).contrlData ; | |
1983 | (**macTE).destRect.left += dx ; | |
1984 | (**macTE).destRect.top += dy ; | |
1985 | (**macTE).destRect.right += dx ; | |
1986 | (**macTE).destRect.bottom += dy ; | |
1987 | (**macTE).viewRect.left += dx ; | |
1988 | (**macTE).viewRect.top += dy ; | |
1989 | (**macTE).viewRect.right += dx ; | |
1990 | (**macTE).viewRect.bottom += dy ; | |
1991 | return ; | |
1992 | } | |
1993 | if ( info->procID == kControlListBoxProc) | |
1994 | { | |
1995 | int dx ; | |
1996 | int dy ; | |
1997 | ||
1998 | dx= x - (**inControl).contrlRect.left ; | |
1999 | dy= y - (**inControl).contrlRect.top ; | |
2000 | ||
2001 | MoveControl( inControl , x ,y ) ; | |
2002 | ListHandle macList ; | |
2003 | ||
2004 | macList = (ListHandle) (**inControl).contrlData ; | |
2005 | (**macList).rView.left += dx ; | |
2006 | (**macList).rView.top += dy ; | |
2007 | (**macList).rView.right += dx ; | |
2008 | (**macList).rView.bottom += dy ; | |
2009 | return ; | |
2010 | } | |
2011 | } | |
2012 | } | |
2013 | MoveControl( inControl , x ,y ) ; | |
2014 | } | |
2015 | ||
2016 | void AGASizeControl(ControlHandle inControl , short x , short y ) | |
2017 | { | |
2018 | if ( AGATestForNewControl( inControl ) ) | |
2019 | { | |
2020 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
2021 | if ( info->magic == kExtCDEFMagic ) | |
2022 | { | |
2023 | if ( info->procID == kControlEditTextProc) | |
2024 | { | |
2025 | int dx ; | |
2026 | int dy ; | |
2027 | ||
2028 | dx= x - ( (**inControl).contrlRect.right - (**inControl).contrlRect.left ) ; | |
2029 | dy= y - ( (**inControl).contrlRect.bottom - (**inControl).contrlRect.top ) ; | |
2030 | ||
2031 | SizeControl( inControl , x ,y ) ; | |
2032 | TEHandle macTE ; | |
2033 | ||
2034 | macTE = (TEHandle) (**inControl).contrlData ; | |
2035 | (**macTE).destRect.right += dx ; | |
2036 | (**macTE).destRect.bottom += dy ; | |
2037 | (**macTE).viewRect.right += dx ; | |
2038 | (**macTE).viewRect.bottom += dy ; | |
2039 | return ; | |
2040 | } | |
2041 | if ( info->procID == kControlListBoxProc) | |
2042 | { | |
2043 | int dx ; | |
2044 | int dy ; | |
2045 | ||
2046 | dx= x - ( (**inControl).contrlRect.right - (**inControl).contrlRect.left ) ; | |
2047 | dy= y - ( (**inControl).contrlRect.bottom - (**inControl).contrlRect.top ) ; | |
2048 | ||
2049 | SizeControl( inControl , x ,y ) ; | |
2050 | ListHandle macList ; | |
2051 | ||
2052 | macList = (ListHandle) (**inControl).contrlData ; | |
2053 | (**macList).rView.right += dx ; | |
2054 | (**macList).rView.bottom += dy ; | |
2055 | return ; | |
2056 | } | |
2057 | } | |
2058 | } | |
2059 | SizeControl( inControl , x ,y ) ; | |
2060 | } | |
2061 | ||
2062 | pascal SInt32 AGARootControlDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) | |
2063 | { | |
2064 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**theControl).contrlRfCon ; | |
2065 | ||
2066 | switch( message ) | |
2067 | { | |
2068 | case initCntl : | |
2069 | break ; | |
2070 | case dispCntl : | |
2071 | break ; | |
2072 | case drawCntl : | |
2073 | break ; | |
2074 | case kControlMsgCalcBestRect : | |
2075 | break ; | |
2076 | case kControlMsgSetData : | |
2077 | default : | |
2078 | break ; | |
2079 | } | |
2080 | ||
2081 | return 0 ; | |
2082 | } | |
2083 | ||
2084 | pascal SInt32 AGAEditTextDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) | |
2085 | { | |
2086 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**theControl).contrlRfCon ; | |
2087 | Size result ; | |
2088 | TEHandle macTE ; | |
2089 | ||
2090 | macTE = (TEHandle) (**theControl).contrlData ; | |
2091 | ||
2092 | switch( message ) | |
2093 | { | |
2094 | case initCntl : | |
2095 | { | |
2f1ae414 | 2096 | AGAPortHelper help((**theControl).contrlOwner) ; |
72582399 UJ |
2097 | SetPort( (**theControl).contrlOwner ) ; |
2098 | ::TextFont( kFontIDGeneva ) ; | |
2099 | ::TextSize( 10 ) ; | |
2100 | ::TextFace( 0 ) ; | |
2101 | RGBBackColor( &gAGARamp[ kAGAWhite ] ) ; | |
2102 | RGBForeColor( &gAGARamp[ kAGABlack ] ) ; | |
2103 | Rect bounds = (**theControl).contrlRect ; | |
2104 | InsetRect( &bounds , 4 , 1 ) ; | |
2105 | FontInfo fi ; | |
2106 | ::GetFontInfo( &fi ) ; | |
2107 | ||
2108 | bounds.top = bounds.bottom - abs( fi.descent ) - fi.ascent - 3; | |
2109 | macTE = TENew( &bounds , &bounds) ; | |
2110 | (**theControl).contrlData = (Handle) macTE ; | |
2111 | } | |
2112 | break ; | |
2113 | case dispCntl : | |
2114 | TEDispose( macTE ) ; | |
2115 | break ; | |
2116 | case drawCntl : | |
2117 | { | |
2f1ae414 | 2118 | AGAPortHelper help((**theControl).contrlOwner) ; |
72582399 UJ |
2119 | AGASetFontStyle( &info->fontStyle ) ; |
2120 | SetPort( (**theControl).contrlOwner ) ; | |
2121 | RGBBackColor( &gAGARamp[ kAGAWhite ] ) ; | |
2122 | RGBForeColor( &gAGARamp[ kAGABlack ] ) ; | |
2123 | EraseRect( &(**theControl).contrlRect ) ; | |
2124 | FrameRect( &(**theControl).contrlRect ) ; | |
2125 | TEUpdate( &(**theControl).contrlRect , macTE ) ; | |
2126 | } | |
2127 | break ; | |
2128 | case testCntl : | |
2129 | { | |
2130 | Point pt ; | |
2131 | pt.h = LoWord( param ) ; | |
2132 | pt.v = HiWord( param ) ; | |
2133 | if ( PtInRect( pt , &(**theControl).contrlRect ) ) | |
2134 | return kControlButtonPart ; | |
2135 | else | |
2136 | return NULL ; | |
2137 | } | |
2138 | break ; | |
2139 | case posCntl : | |
2140 | { | |
2141 | Point pt ; | |
2142 | pt.h = LoWord( param ) ; | |
2143 | pt.v = HiWord( param ) ; | |
2144 | if ( PtInRect( pt , &(**theControl).contrlRect ) ) | |
2145 | { | |
2146 | TEClick( pt , false , macTE ) ; | |
2147 | } | |
2148 | } | |
2149 | break ; | |
2150 | case kControlMsgGetData : | |
2151 | { | |
2152 | ControlDataAccessRec *rec = (ControlDataAccessRec *) param ; | |
2153 | if ( rec->tag == kControlEditTextTEHandleTag ) | |
2154 | { | |
2155 | return AGAGetDataHelper( rec , sizeof( TEHandle ) , (char*) &macTE ) ; | |
2156 | } | |
2157 | else if ( rec->tag == kControlEditTextTextTag ) | |
2158 | { | |
2159 | return AGAGetDataHelper( rec , (**macTE).teLength , (char*) *(**macTE).hText ) ; | |
2160 | } | |
2161 | else if ( rec->tag == kControlEditTextSelectionTag ) | |
2162 | { | |
2163 | } | |
2164 | return errDataNotSupported ; | |
2165 | } | |
2166 | break ; | |
2167 | case kControlMsgSetData : | |
2168 | { | |
2169 | ControlDataAccessRec *rec = (ControlDataAccessRec *) param ; | |
2170 | if ( rec->tag == kControlEditTextTextTag ) | |
2171 | { | |
2172 | TESetText( rec->dataPtr , rec->size , macTE ) ; | |
2173 | return noErr ; | |
2174 | } | |
2175 | return errDataNotSupported ; | |
2176 | } | |
2177 | case kControlMsgCalcBestRect : | |
2178 | { | |
2179 | ControlCalcSizeRec *rec = (ControlCalcSizeRec *) param ; | |
2180 | rec->width = (**theControl).contrlRect.right - (**theControl).contrlRect.left ; | |
2181 | rec->height = (**theControl).contrlRect.bottom - (**theControl).contrlRect.top ; | |
2182 | rec->baseLine = 0; | |
2183 | } | |
2184 | case kControlMsgFocus : | |
2185 | { | |
2186 | if ( param == kControlFocusNoPart ) | |
2187 | { | |
2188 | info->hasFocus = false ; | |
2189 | TEDeactivate( macTE ) ; | |
2190 | return kControlFocusNoPart ; | |
2191 | } | |
2192 | else if ( param == kControlFocusNextPart || param == kControlFocusPrevPart ) | |
2193 | { | |
2194 | if ( info->hasFocus ) | |
2195 | { | |
2196 | info->hasFocus = false ; | |
2197 | TEDeactivate( macTE ) ; | |
2198 | return kControlFocusNoPart ; | |
2199 | } | |
2200 | else | |
2201 | { | |
2202 | info->hasFocus = true ; | |
2203 | TEActivate( macTE ) ; | |
2204 | return kControlEditTextPart ; | |
2205 | } | |
2206 | } | |
2207 | else if ( param == kControlEditTextPart ) | |
2208 | { | |
2209 | if ( !info->hasFocus ) | |
2210 | { | |
2211 | info->hasFocus = true ; | |
2212 | TEActivate( macTE ) ; | |
2213 | return kControlEditTextPart ; | |
2214 | } | |
2215 | } | |
2216 | } | |
2217 | break ; | |
2218 | case kControlMsgIdle : | |
2219 | { | |
2220 | TEIdle( macTE ) ; | |
2221 | } | |
2222 | break ; | |
2223 | case kControlMsgKeyDown : | |
2224 | { | |
2f1ae414 | 2225 | AGAPortHelper help( (**theControl).contrlOwner ) ; |
72582399 | 2226 | AGASetFontStyle( &info->fontStyle ) ; |
72582399 UJ |
2227 | RGBBackColor( &gAGARamp[ kAGAWhite ] ) ; |
2228 | RGBForeColor( &gAGARamp[ kAGABlack ] ) ; | |
2229 | ControlKeyDownRec * rec = (ControlKeyDownRec*) param ; | |
2230 | TEKey( rec->charCode , macTE ) ; | |
2231 | } | |
2232 | break ; | |
2233 | case kControlMsgActivate : | |
2234 | { | |
2235 | /* | |
2236 | if ( param ) | |
2237 | TEActivate( macTE ) ; | |
2238 | else | |
2239 | TEDeactivate( macTE ) ; | |
2240 | */ | |
2241 | } | |
2242 | break ; | |
2243 | case calcCntlRgn : | |
2244 | RectRgn((RgnHandle) param , &(**theControl).contrlRect ) ; | |
2245 | break ; | |
2246 | case kControlMsgTestNewMsgSupport : | |
2247 | return kControlSupportsNewMessages ; | |
2248 | case kControlMsgGetFeatures : | |
2249 | return | |
2250 | // kControlSupportsGhosting | | |
2251 | // kControlSupportsEmbedding | | |
2252 | kControlSupportsFocus | | |
2253 | kControlWantsIdle | | |
2254 | kControlWantsActivate | | |
2255 | // kControlHandlesTracking | | |
2256 | kControlSupportsDataAccess | | |
2257 | // kControlHasSpecialBackground | | |
2258 | // kControlGetsFocusOnClick | | |
2259 | kControlSupportsCalcBestRect | | |
2260 | // kControlSupportsLiveFeedback | | |
2261 | // kControlHasRadioBehavior | | |
2262 | 0 ; | |
2263 | default : | |
2264 | break ; | |
2265 | } | |
2266 | ||
2267 | return 0 ; | |
2268 | } | |
2269 | ||
2270 | pascal SInt32 AGAListControlDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) | |
2271 | { | |
2272 | Size result ; | |
2273 | ListHandle macList ; | |
2274 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**theControl).contrlRfCon ; | |
2275 | ||
2276 | macList = (ListHandle) (**theControl).contrlData ; | |
2277 | ||
2278 | static inLoop = false ; | |
2279 | static lastClick = NULL ; | |
2280 | ||
2281 | switch( message ) | |
2282 | { | |
2283 | case initCntl : | |
2284 | { | |
2285 | Rect databounds = { 0,0,0,0} ; | |
2286 | Point cellsize = { 0,0} ; | |
2287 | Rect listBounds = (**theControl).contrlRect ; | |
2288 | ||
2289 | InsetRect( &listBounds , 1 , 1 ) ; | |
2290 | ||
2291 | macList = LNew( &listBounds , &databounds , cellsize , 128 , | |
2292 | (**theControl).contrlOwner , false /*drawit*/ , false /*hasGrow*/, | |
2293 | false /* horzScroll */, true /*vertScroll*/ ) ; | |
2294 | (**theControl).contrlData = (Handle) macList ; | |
2295 | info->privateData = NULL ; | |
2296 | } | |
2297 | break ; | |
2298 | case dispCntl : | |
2299 | (**macList).vScroll = NULL ; // will be disposed by the window itself | |
2300 | (**macList).hScroll = NULL ; // will be disposed by the window itself | |
2301 | LDispose( macList ) ; | |
2302 | break ; | |
2303 | case calcCntlRgn : | |
2304 | RectRgn((RgnHandle) param , &(**theControl).contrlRect ) ; | |
2305 | break ; | |
2306 | case testCntl : | |
2307 | { | |
2308 | Point pt ; | |
2309 | pt.h = LoWord( param ) ; | |
2310 | pt.v = HiWord( param ) ; | |
2311 | Rect listRect ; | |
2312 | Rect allRect = (**theControl).contrlRect ; | |
2313 | listRect = allRect ; | |
2314 | if ( !inLoop ) | |
2315 | allRect.right += 16 ; | |
2316 | if ( PtInRect( pt , &allRect ) ) | |
2317 | { | |
2318 | if ( !inLoop && StillDown() ) | |
2319 | { | |
2320 | inLoop = true ; | |
2321 | LActivate( true , macList ) ; | |
2322 | Boolean doubleClick = LClick( pt , 0 /* todo modifiers*/ , macList ) ; | |
2323 | info->privateData = doubleClick ; | |
2324 | inLoop = false ; | |
2325 | } | |
2326 | return kControlListBoxPart ; | |
2327 | } | |
2328 | else | |
2329 | return NULL ; | |
2330 | } | |
2331 | break ; | |
2332 | case drawCntl : | |
2333 | { | |
2f1ae414 | 2334 | AGAPortHelper help((**theControl).contrlOwner) ; |
72582399 UJ |
2335 | AGASetFontStyle( &info->fontStyle ) ; |
2336 | RGBBackColor( &gAGARamp[ kAGAWhite ] ) ; | |
2337 | EraseRect( &(**theControl).contrlRect ) ; | |
2338 | FrameRect( &(**theControl).contrlRect ) ; | |
2339 | RgnHandle controlRgn = NewRgn() ; | |
2340 | SetRectRgn( controlRgn, (**theControl).contrlRect.left , | |
2341 | (**theControl).contrlRect.top, | |
2342 | (**theControl).contrlRect.right, | |
2343 | (**theControl).contrlRect.bottom ) ; | |
2344 | LUpdate( controlRgn, macList ) ; | |
2345 | } | |
2346 | break ; | |
2347 | case posCntl : | |
2348 | { | |
2349 | Point pt ; | |
2350 | pt.h = LoWord( param ) ; | |
2351 | pt.v = HiWord( param ) ; | |
2352 | Rect listRect ; | |
2353 | Rect allRect = (**theControl).contrlRect ; | |
2354 | listRect = allRect ; | |
2355 | allRect.right += 16 ; | |
2356 | if ( PtInRect( pt , &listRect ) ) | |
2357 | { | |
2358 | if ( !inLoop && StillDown() ) | |
2359 | { | |
2360 | inLoop = true ; | |
2361 | LActivate( true , macList ) ; | |
2362 | Boolean doubleClick = LClick( pt , 0 /* todo modifiers*/ , macList ) ; | |
2363 | info->privateData = doubleClick ; | |
2364 | inLoop = false ; | |
2365 | } | |
2366 | return kControlListBoxPart ; | |
2367 | } | |
2368 | else if ( PtInRect( pt , &allRect ) ) | |
2369 | { | |
2370 | if ( !inLoop && StillDown() ) | |
2371 | { | |
2372 | inLoop = true ; | |
2373 | // LActivate( true , macList ) ; | |
2374 | Boolean doubleClick = LClick( pt , 0 /* todo modifiers*/ , macList ) ; | |
2375 | info->privateData = doubleClick ; | |
2376 | inLoop = false ; | |
2377 | } | |
2378 | return kControlPageDownPart ; | |
2379 | } | |
2380 | else | |
2381 | return NULL ; | |
2382 | } | |
2383 | break ; | |
2384 | case kControlMsgGetData : | |
2385 | { | |
2386 | ControlDataAccessRec *rec = (ControlDataAccessRec *) param ; | |
2387 | if ( rec->tag == kControlListBoxListHandleTag ) | |
2388 | { | |
2389 | return AGAGetDataHelper( rec , sizeof( ListHandle ) , (char*) &macList ) ; | |
2390 | } | |
2391 | else if ( rec->tag == kControlListBoxDoubleClickTag ) | |
2392 | { | |
2393 | Boolean doubleClick = info->privateData ; | |
2394 | return AGAGetDataHelper( rec , sizeof( Boolean ) , (char*) &doubleClick ) ; | |
2395 | } | |
2396 | return errDataNotSupported ; | |
2397 | } | |
2398 | break ; | |
2399 | default : | |
2400 | break ; | |
2401 | } | |
2402 | ||
2403 | return 0 ; | |
2404 | } | |
2405 | ||
2406 | OSErr AGACreateRootControl (WindowPtr inWindow, | |
2407 | ControlHandle * outControl) | |
2408 | { | |
2409 | ControlHandle theControl = NULL ; | |
2410 | ||
2411 | SInt16 extCDEFID = kExtCDEFID << 4 + 0 ; | |
2412 | ||
2413 | theControl = NewControl( inWindow , &inWindow->portRect , "\p" , true , | |
2414 | 0 , 0 , 1 , extCDEFID , 0 ) ; | |
2415 | NewExtCDEFInfo( theControl , AGARootControlDefProc , kAGARootControlProcID , 0 ) ; | |
2416 | ||
2417 | *outControl = theControl ; | |
2418 | return noErr ; | |
2419 | } | |
2420 | ||
2421 | OSErr AGAEmbedControl (ControlHandle inControl, | |
2422 | ControlHandle inContainer) | |
2423 | { | |
2424 | if ( AGATestForNewControl( inControl ) ) | |
2425 | { | |
2426 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ; | |
2427 | info->containerControl = inContainer ; | |
2428 | } | |
2429 | return noErr ; | |
2430 | } | |
2431 | ||
2432 | void AGADrawControl( ControlHandle control ) | |
2433 | { | |
2434 | DrawOneControl( control ) ; | |
2435 | ControlHandle iter = (ControlHandle) ((WindowPeek)(**control).contrlOwner)->controlList ; | |
2436 | while ( iter ) | |
2437 | { | |
2438 | if ( AGATestForNewControl( iter ) ) | |
2439 | { | |
2440 | ExtCDEFInfo* info = (ExtCDEFInfo* ) (**iter).contrlRfCon ; | |
2441 | if ( info->containerControl == control ) | |
2442 | { | |
2443 | AGADrawControl( iter ) ; | |
2444 | } | |
2445 | } | |
2446 | ||
2447 | iter = (**iter).nextControl ; | |
2448 | } | |
2449 | } | |
2450 | ||
2451 | ||
2452 | ControlHandle AGANewControl(WindowPtr owningWindow, | |
2453 | const Rect * bounds, | |
2454 | ConstStr255Param controlTitle, | |
2455 | Boolean initiallyVisible, | |
2456 | SInt16 initialValue, | |
2457 | SInt16 minimumValue, | |
2458 | SInt16 maximumValue, | |
2459 | SInt16 procID, | |
2460 | SInt32 controlReference) | |
2461 | { | |
2462 | ControlHandle theControl = NULL ; | |
2463 | Rect boundsRect = *bounds ; | |
2464 | SInt16 extCDEFID = kExtCDEFID << 4 + 0 ; | |
2465 | SInt16 oldProcID = extCDEFID ; | |
2466 | switch( procID ) | |
2467 | { | |
2468 | case kControlScrollBarProc : | |
2469 | case kControlScrollBarLiveProc : | |
2470 | oldProcID = scrollBarProc ; | |
2471 | break ; | |
2472 | case kControlListBoxProc : | |
2473 | initialValue = 0 ; | |
2474 | default : | |
2475 | break ; | |
2476 | } | |
2477 | if ( oldProcID == extCDEFID && procID == kControlListBoxProc ) | |
2478 | { | |
2479 | boundsRect.right -= 16 ; | |
2480 | } | |
2481 | theControl = NewControl( owningWindow , &boundsRect , controlTitle , initiallyVisible , | |
2482 | initialValue , minimumValue , maximumValue , oldProcID , controlReference ) ; | |
2483 | if ( oldProcID == extCDEFID ) | |
2484 | { | |
2485 | ControlDefProcPtr theProcPtr = NULL ; | |
2486 | SInt16 theVarCode = 0 ; | |
2487 | switch( procID ) | |
2488 | { | |
2489 | case kControlPushButtonProc : | |
2490 | theProcPtr = AGAButtonDefProc ; | |
2491 | break ; | |
2492 | case kControlCheckBoxProc : | |
2493 | theProcPtr = AGACheckBoxDefProc ; | |
2494 | break ; | |
2495 | case kControlRadioButtonProc : | |
2496 | theProcPtr = AGARadioButtonDefProc ; | |
2497 | break ; | |
2498 | case kControlProgressBarProc : | |
2499 | theProcPtr = AGAProgressBarDefProc ; | |
2500 | break ; | |
2501 | case kControlPlacardProc : | |
2502 | theProcPtr = AGAPlacardDefProc ; | |
2503 | break ; | |
2504 | case kControlStaticTextProc : | |
2505 | theProcPtr = AGAStaticTextDefProc ; | |
2506 | break ; | |
2507 | case kControlListBoxProc : | |
2508 | theProcPtr = AGAListControlDefProc ; | |
2509 | break ; | |
2510 | case kControlEditTextProc : | |
2511 | theProcPtr = AGAEditTextDefProc ; | |
2512 | break ; | |
2513 | case kControlGroupBoxTextTitleProc : | |
2514 | theProcPtr = AGAStaticGroupBoxTextDefProc ; | |
2515 | break ; | |
2516 | case kControlBevelButtonNormalBevelProc : | |
2517 | theProcPtr = AGABevelButtonDefProc ; | |
2518 | break ; | |
2519 | } | |
2520 | ||
2521 | if ( theProcPtr ) | |
2522 | { | |
2523 | NewExtCDEFInfo( theControl , theProcPtr , procID , controlReference ) ; | |
2524 | } | |
2525 | } | |
2526 | return theControl ; | |
2527 | } | |
2528 | ||
2529 | void AGASetThemeWindowBackground (WindowRef inWindow, | |
2530 | ThemeBrush inBrush, | |
2531 | Boolean inUpdate) | |
2532 | { | |
2533 | GrafPtr port ; | |
2534 | GetPort( &port ) ; | |
2535 | SetPort( inWindow ) ; | |
2536 | if ( inBrush == kThemeBrushDialogBackgroundActive ) | |
2537 | { | |
2538 | gAGABackgroundColor = 2 ; | |
2539 | } | |
2540 | else | |
2541 | { | |
2542 | gAGABackgroundColor = 0 ; | |
2543 | } | |
2544 | RGBBackColor( &gAGAColorArray[gAGABackgroundColor] ) ; | |
2545 | SetPort( port ) ; | |
2546 | } | |
2547 | ||
2f1ae414 SC |
2548 | void AGAApplyThemeBackground(ThemeBackgroundKind inKind, |
2549 | const Rect * bounds, | |
2550 | ThemeDrawState inState, | |
2551 | SInt16 inDepth, | |
2552 | Boolean inColorDev) | |
2553 | { | |
2554 | } | |
2555 | ||
03e11df5 GD |
2556 | #endif // !TARGET_CARBON |
2557 | ||
2f1ae414 SC |
2558 | AGAPortHelper::AGAPortHelper( GrafPtr newport) |
2559 | { | |
2560 | GetPort( &port ) ; | |
2561 | SetPort( newport ) ; | |
2562 | // wxASSERT( newport->portRect.left == 0 && newport->portRect.top == 0 ) ; | |
2563 | GetPenState( &oldPenState ) ; | |
2564 | GetBackColor( &oldBackColor ) ; | |
2565 | GetForeColor( &oldForeColor ) ; | |
2566 | ||
2567 | clip = NewRgn() ; | |
2568 | GetClip( clip ); | |
2569 | font = GetPortTextFont( newport); | |
2570 | size = GetPortTextSize( newport); | |
2571 | style = GetPortTextFace( newport); | |
2572 | mode = GetPortTextMode( newport); | |
2573 | nport = newport ; | |
2574 | ||
2575 | } | |
2576 | AGAPortHelper::AGAPortHelper() | |
2577 | { | |
2578 | clip = NULL ; | |
2579 | } | |
2580 | void AGAPortHelper::Setup( GrafPtr newport ) | |
2581 | { | |
2582 | GetPort( &port ) ; | |
2583 | SetPort( newport ) ; | |
2584 | // wxASSERT( newport->portRect.left == 0 && newport->portRect.top == 0 ) ; | |
2585 | GetPenState( &oldPenState ) ; | |
2586 | GetBackColor( &oldBackColor ) ; | |
2587 | GetForeColor( &oldForeColor ) ; | |
2588 | ||
2589 | clip = NewRgn() ; | |
2590 | GetClip( clip ); | |
2591 | font = GetPortTextFont( newport); | |
2592 | size = GetPortTextSize( newport); | |
2593 | style = GetPortTextFace( newport); | |
2594 | mode = GetPortTextMode( newport); | |
2595 | nport = newport ; | |
2596 | } | |
2597 | void AGAPortHelper::Clear() | |
2598 | { | |
2599 | if ( clip ) | |
2600 | { | |
2601 | DisposeRgn( clip ) ; | |
2602 | clip = NULL ; | |
2603 | } | |
2604 | } | |
2605 | AGAPortHelper::~AGAPortHelper() | |
2606 | { | |
2607 | if ( clip ) | |
2608 | { | |
2609 | SetPort( nport ) ; | |
2610 | SetClip( clip ) ; | |
2611 | DisposeRgn( clip ) ; | |
2612 | RGBForeColor(&oldForeColor); | |
2613 | RGBBackColor(&oldBackColor); | |
2614 | SetPenState(&oldPenState); | |
2615 | ||
2616 | TextFont( font ); | |
2617 | TextSize( size ); | |
2618 | TextFace( style ); | |
2619 | TextMode( mode ); | |
5b781a67 | 2620 | SetOrigin( 0 , 0 ) ; |
2f1ae414 | 2621 | SetPort( port ) ; |
b89dac78 | 2622 | wxDC::MacInvalidateSetup() ; |
2f1ae414 SC |
2623 | } |
2624 | } | |
72582399 | 2625 |