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