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