3 #include <wx/mac/uma.h> 
   4 #include <wx/mac/aga.h> 
   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
) ; 
  18 SInt16 kAGARootControlProcID 
; 
  19 int gAGABackgroundColor 
= 0 ; 
  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 
  37 char LAGADefaultOutline_mCorners
[4][5][5] =     { 
  40                                                                                                                                                                                                         { -1, -1, -1, 12,  B 
}, 
  48                                                                                                                                                                                                         {  B
, 12, -1, -1, -1 }, 
  72 char LAGAPushButton_mCorners
[3][4][4][4] =      { 
 168 RGBColor gAGARamp
[] = 
 173         { 65535 , 65535 , 65535 } , 
 175         { 61166 , 61166 , 61166 } , 
 177         { 56797 , 56797 , 56797 } , 
 179         { 52428 , 52428 , 52428 } , 
 181         { 48059 , 48059 , 48059 } , 
 183         { 43690 , 43690 , 43690 } , 
 185         { 39321 , 39321 , 39321 } , 
 187         { 34952 , 34952 , 34952 } , 
 189         { 30583 , 30583 , 30583 } , 
 191         { 26214 , 26214 , 26214 } , 
 193         { 21845 , 21845 , 21845 } , 
 195         { 17476 , 17476 , 17476 } , 
 197         { 13107 , 13107 , 13107 } , 
 199         { 8738 , 8738 , 8738 } , 
 201         { 4369 , 4369 , 4369 } , 
 205 RGBColor gAGABlueRamp
[] = 
 210         { 65535 , 65535 , 65535 } , 
 212         { 61166 , 61166 , 65535 } , 
 214         { 56797 , 56797 , 65535 } , 
 216         { 52428 , 52428 , 65535 } , 
 218         { 48059 , 48059 , 65535 } , 
 220         { 43690 , 43690 , 65535 } , 
 222         { 39321 , 39321 , 65535 } , 
 224         { 34952 , 34952 , 65535 } , 
 226         { 30583 , 30583 , 65535 } , 
 228         { 26214 , 26214 , 65535 } , 
 230         { 21845 , 21845 , 65535 } , 
 232         { 17476 , 17476 , 65535 } , 
 234         { 13107 , 13107 , 65535 } , 
 236         { 8738 , 8738 , 65535 } , 
 238         { 4369 , 4369 , 65535 } , 
 243         kAGATransparent 
= -1 , 
 264         kAGAStateEnabled 
= 0 , 
 265         kAGAStatePressed 
= 1 , 
 266         kAGAStateDisabled 
= 2 , 
 267         kAGAStateInactive 
= 3  
 271 typedef struct sControlData 
 273         ControlPartCode         m_part ; 
 278 OSErr AGAFindControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , long *outOffset) ; 
 279 OSErr AGAFindControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , long *outOffset)  
 281         ExtCDEFInfo* info = (ExtCDEFInfo* )  (**inControl).contrlRfCon ; 
 283         long size = GetHandleSize( info->data ) ; 
 284         char* data = *(info->data) ; 
 285         sControlData* current ; 
 286         while( offset + sizeof( sControlData ) <= size ) 
 288                 current = (sControlData*) (data+offset ) ; 
 289                 if ( ( inPart == kControlEntireControl || inPart == current->m_part ) && inTagName == current->m_tag ) 
 291                         *outOffset = offset ; 
 295         return errDataNotSupported ; // nothing found 
 298 OSErr AGARemoveControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName ) ; 
 299 OSErr AGARemoveControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName )  
 301         ExtCDEFInfo* info = (ExtCDEFInfo* )  (**inControl).contrlRfCon ; 
 303         long size = GetHandleSize( info->data ) ; 
 304         char* data = *(info->data) ; 
 305         sControlData* current ; 
 306         while( offset + sizeof( sControlData ) <= size ) 
 308                 current = (sControlData*) (data+offset ) ; 
 309                 if ( ( inPart == kControlEntireControl || inPart == current->m_part ) && inTagName == current->m_tag ) 
 311                         long chunkSize = current->m_size + sizeof ( sControlData ) ; 
 312                         memcpy( data + offset , data + offset + chunkSize , size - offset - chunkSize ) ; 
 313                         SetHandleSize( info->data , size - chunkSize ) ; 
 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)  
 323         ExtCDEFInfo* info = (ExtCDEFInfo* )  (**inControl).contrlRfCon ; 
 325         long size = GetHandleSize( info->data ) ; 
 326         SetHandleSize( info->data , size + sizeof( sControlData ) + inSize ) ; 
 327         if (  MemError() == noErr ) 
 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 ) ; 
 337         return errDataNotSupported ; 
 341 OSErr AGAGetControlDataSize                             (ControlHandle                  inControl, 
 342                                                                  ControlPartCode                inPart, 
 347         ExtCDEFInfo* info = (ExtCDEFInfo* )  (**inControl).contrlRfCon ; 
 348         char* data = *(info->data) ; 
 350         OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ; 
 353                 sControlData* current = (sControlData*) (data+offset ) ; 
 354                 *outMaxSize = current->m_size ; 
 359 OSErr AGAGetControlData                                 (ControlHandle                  inControl, 
 360                                                                  ControlPartCode                inPart, 
 364                                                                  Size *                                 outActualSize) 
 367         ExtCDEFInfo* info = (ExtCDEFInfo* )  (**inControl).contrlRfCon ; 
 368         char* data = *(info->data) ; 
 370         OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ; 
 373                 sControlData* current = (sControlData*) (data+offset ) ; 
 374                 *outActualSize = current->m_size ; 
 377                         if ( inBufferSize <= current->m_size ) 
 378                                 memcpy( outBuffer , data + offset + sizeof( sControlData )  , current->m_size ) ; 
 380                                 err = errDataNotSupported ; 
 386 OSErr AGASetControlData                                 (ControlHandle                  inControl, 
 387                                                                  ControlPartCode                inPart, 
 393         ExtCDEFInfo* info = (ExtCDEFInfo* )  (**inControl).contrlRfCon ; 
 394         char* data = *(info->data) ; 
 396         OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ; 
 399                 sControlData* current = (sControlData*) (data+offset ) ; 
 400                 if ( current->m_size == inSize ) 
 402                                 memcpy( data + offset + sizeof( sControlData )  , inData , inSize) ; 
 406                         AGARemoveControlData( inControl , inPart , inTagName ) ; 
 407                         AGAAddControlData( inControl , inPart , inTagName , inSize , inData ) ; 
 412                 AGAAddControlData( inControl , inPart , inTagName , inSize , inData ) ; 
 418 OSErr 
AGASetControlFontStyle                            (ControlHandle                  inControl
, 
 419                                                                  const ControlFontStyleRec 
* inStyle
)    
 421         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**inControl
).contrlRfCon 
; 
 422         if ( inStyle
->flags 
== 0 ) 
 428                 if ( inStyle
->flags 
& kControlUseFontMask 
) 
 430                         info
->fontStyle
.font 
= inStyle
->font 
; 
 432                 if ( inStyle
->flags 
& kControlUseSizeMask 
) 
 434                         info
->fontStyle
.size 
= inStyle
->size 
; 
 436                 if ( inStyle
->flags 
& kControlUseFaceMask 
) 
 438                         info
->fontStyle
.style 
= inStyle
->style 
; 
 440                 if ( inStyle
->flags 
& kControlUseModeMask 
) 
 442                         info
->fontStyle
.mode 
= inStyle
->mode 
; 
 444                 if ( inStyle
->flags 
& kControlUseJustMask 
) 
 446                         info
->fontStyle
.just 
= inStyle
->just 
; 
 448                 if ( inStyle
->flags 
& kControlUseForeColorMask 
) 
 450                         info
->fontStyle
.foreColor 
= inStyle
->foreColor 
; 
 452                 if ( inStyle
->flags 
& kControlUseBackColorMask 
) 
 454                         info
->fontStyle
.backColor 
= inStyle
->backColor 
; 
 460 OSErr 
AGASetControlData                                 (ControlHandle                  inControl
, 
 461                                                                  ControlPartCode                inPart
, 
 466         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**inControl
).contrlRfCon 
; 
 467         ControlDataAccessRec rec 
; 
 469         rec
.tag 
= inTagName 
; 
 472         rec
.dataPtr 
= inData 
; 
 474         return info
->defProc( info
->procID 
, inControl 
, kControlMsgSetData 
, (long) &rec 
) ; 
 477 SInt16 
AGAHandleControlKey                              (ControlHandle                  inControl
, 
 482         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**inControl
).contrlRfCon 
; 
 483         ControlKeyDownRec rec 
; 
 485         rec
.modifiers 
= inModifiers 
; 
 486         rec
.keyCode 
= inKeyCode 
; 
 487         rec
.charCode 
= inCharCode 
; 
 489         return info
->defProc( info
->procID 
, inControl 
, kControlMsgKeyDown 
, (long) &rec 
) ; 
 492 ControlPartCode 
AGAHandleControlClick                           (ControlHandle                  inControl
, 
 495                                                                  ControlActionUPP               inAction
)        
 497         return TrackControl( inControl 
, inWhere 
, inAction 
) ; 
 500 Boolean 
AGATestForNewControl( ControlHandle inControl 
) 
 502         if ( (**inControl
).contrlRfCon  
> 0x100 && !( (**inControl
).contrlRfCon 
% 2 ) ) 
 504                         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**inControl
).contrlRfCon 
; 
 505                         return info
->magic 
== kExtCDEFMagic 
; 
 509 void AGAIdleControls                                    (WindowPtr                              inWindow
)  
 511         ControlHandle iter 
= (ControlHandle
) ((WindowPeek
)inWindow
)->controlList 
;  
 514                 if ( AGATestForNewControl( iter 
) ) 
 516                         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**iter
).contrlRfCon 
; 
 517                         if ( info
->defProc( info
->procID 
, iter 
, kControlMsgTestNewMsgSupport 
, 0 ) == kControlSupportsNewMessages 
) 
 519                                 if ( info
->defProc( info
->procID 
, iter 
, kControlMsgGetFeatures 
, 0 ) & kControlWantsIdle 
) 
 521                                         info
->defProc( info
->procID 
, iter 
, kControlMsgIdle 
, 0 ) ; 
 526                 iter 
= (**iter
).nextControl 
; 
 530 void AGAUpdateOneControl( ControlHandle control 
, RgnHandle inRgn 
) 
 532         DrawOneControl( control 
) ; 
 533         ControlHandle iter 
= (ControlHandle
) ((WindowPeek
)(**control
).contrlOwner
)->controlList 
;  
 536                 if ( AGATestForNewControl( iter 
) ) 
 538                         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**iter
).contrlRfCon 
; 
 539                         if ( info
->containerControl 
== control 
) 
 541                                 AGAUpdateOneControl( iter 
, inRgn 
) ; 
 545                 iter 
= (**iter
).nextControl 
; 
 549 void AGAUpdateControls( WindowPtr inWindow 
, RgnHandle inRgn 
)  
 552         AGAGetRootControl( inWindow 
, &root 
) ; 
 553         AGAUpdateOneControl( root 
, inRgn 
) ; 
 555         // and then all others 
 557         ControlHandle iter 
= (ControlHandle
) ((WindowPeek
)inWindow
)->controlList 
;  
 560                 if ( AGATestForNewControl( iter 
) ) 
 565                         DrawOneControl( iter 
) ; 
 568                 iter 
= (**iter
).nextControl 
; 
 572 OSErr 
AGAGetRootControl( WindowPtr inWindow 
, ControlHandle 
*outControl 
)  
 574         ControlHandle iter 
= (ControlHandle
) ((WindowPeek
)inWindow
)->controlList 
;  
 577                 if ( AGATestForNewControl( iter 
) ) 
 579                         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**iter
).contrlRfCon 
; 
 580                         if ( info
->procID 
== kAGARootControlProcID 
) 
 587                 iter 
= (**iter
).nextControl 
; 
 592 void AGADeactivateControl( ControlHandle inControl 
)  
 594         if ( AGATestForNewControl( inControl 
) ) 
 596                 ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**inControl
).contrlRfCon 
; 
 597                 if ( info
->defProc( info
->procID 
, inControl 
, kControlMsgTestNewMsgSupport 
, 0 ) == kControlSupportsNewMessages 
) 
 599                         if ( info
->defProc( info
->procID 
, inControl 
, kControlMsgGetFeatures 
, 0 ) & kControlWantsActivate 
) 
 601                                 info
->defProc( info
->procID 
, inControl 
, kControlMsgActivate 
, 0 ) ; 
 607                 ::HiliteControl( inControl 
, 255 ) ; 
 611 void AGAActivateControl( ControlHandle inControl 
)  
 613         if ( AGATestForNewControl( inControl 
) ) 
 615                 ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**inControl
).contrlRfCon 
; 
 616                 if ( info
->defProc( info
->procID 
, inControl 
, kControlMsgTestNewMsgSupport 
, 0 ) == kControlSupportsNewMessages 
) 
 618                         if ( info
->defProc( info
->procID 
, inControl 
, kControlMsgGetFeatures 
, 0 ) & kControlWantsActivate 
) 
 620                                 info
->defProc( info
->procID 
, inControl 
, kControlMsgActivate 
, 1 ) ; 
 626                 ::HiliteControl( inControl 
, 0 ) ; 
 630 OSErr 
AGASetKeyboardFocus                               (WindowPtr                              inWindow
, 
 631                                                                  ControlHandle                  inControl
, 
 632                                                                  ControlFocusPart               inPart
) 
 634         if ( AGATestForNewControl( inControl 
) ) 
 636                 ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**inControl
).contrlRfCon 
; 
 637                 if ( info
->defProc( info
->procID 
, inControl 
, kControlMsgTestNewMsgSupport 
, 0 ) == kControlSupportsNewMessages 
) 
 639                         if ( info
->defProc( info
->procID 
, inControl 
, kControlMsgGetFeatures 
, 0 ) & kControlSupportsFocus 
) 
 641                                 return info
->defProc( info
->procID 
, inControl 
, kControlMsgFocus 
, inPart 
) ; 
 645         return errControlDoesntSupportFocus 
; 
 648 OSErr 
AGAGetBestControlRect                             (ControlHandle                  inControl
, 
 650                                                                  SInt16 
*                               outBaseLineOffset
) 
 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 
; 
 658         OSErr err 
= info
->defProc( info
->procID 
, inControl 
, kControlMsgCalcBestRect 
, (long) &rec 
) ; 
 661                 outRect
->left 
= outRect
->top 
= 0 ; 
 662                 outRect
->right 
= rec
. width 
; 
 663                 outRect
->bottom 
= rec
. height 
; 
 664                 *outBaseLineOffset 
= rec
. baseLine 
;             
 670 OSErr 
AGAGetControlData                                 (ControlHandle                  inControl
, 
 671                                                                  ControlPartCode                inPart
, 
 675                                                                  Size 
*                                 outActualSize
) 
 677         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**inControl
).contrlRfCon  
; 
 678         ControlDataAccessRec rec 
; 
 680         rec
.tag 
= inTagName 
; 
 682         rec
.size 
= inBufferSize 
; 
 683         rec
.dataPtr 
= outBuffer 
; 
 685         OSErr err 
= info
->defProc( info
->procID 
, inControl 
, kControlMsgGetData 
, (long) &rec 
) ; 
 686         *outActualSize 
= rec
.size 
; 
 690 OSErr 
AGAGetControlDataSize                             (ControlHandle                  inControl
, 
 691                                                                  ControlPartCode                inPart
, 
 695         return AGAGetControlData( inControl 
, inPart 
, inTagName 
, 0 , NULL 
, outMaxSize 
) ; 
 699 void NewExtCDEFInfo( ControlHandle theControl 
, ControlDefProcPtr defproc 
, SInt16 procID 
, long refcon 
)  
 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) ; 
 721 void DisposeExtCDEFInfo( ControlHandle theControl
)  
 723         if ( AGATestForNewControl( theControl 
) ) 
 725                 ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**theControl
).contrlRfCon 
; 
 728                         DisposeHandle( info
->children 
) ; 
 729                         info
->children 
= NULL 
; 
 730                         free( (void*) (**theControl
).contrlRfCon 
) ; 
 731                         (**theControl
).contrlRfCon 
= NULL 
; 
 736 const short kAGAProgressHeight 
= 14 ; 
 738 void AGADrawRectPlacard( const Rect 
*inRect 
, eAGAState inState 
, bool fill 
= false ) ; 
 739 void AGADrawRectProgress( const Rect 
*inRect 
, eAGAState inState 
, double percentage 
) ; 
 741 void AGADrawRectPlacard( const Rect 
*inRect 
, eAGAState inState 
, bool fill 
)  
 743         Rect rect 
= *inRect 
; 
 744         RGBColor pixelColor 
; 
 745         if ( inState 
== kAGAStateInactive 
) 
 747                 RGBForeColor( &gAGARamp
[ kAGA10 
] ) ; 
 751                         InsetRect( &rect 
, 1 , 1 ) ; 
 752                         RGBForeColor( &gAGARamp
[ kAGA1 
] ) ; 
 758         RGBForeColor( &gAGARamp
[ kAGABlack 
] ) ; 
 760         InsetRect( &rect 
, 1 , 1 ) ; 
 762         if ( inState 
== kAGAStateEnabled 
|| inState 
== kAGAStateDisabled 
) 
 763                 RGBForeColor( &gAGARamp
[ kAGAWhite 
] ) ; 
 765                 RGBForeColor( &gAGARamp
[ kAGABlack 
] ) ; 
 767         MoveTo( rect
.left 
, rect
.bottom 
- 1 -1 ) ; 
 768         LineTo( rect
.left 
, rect
.top 
) ; 
 769         LineTo( rect
.right
-1-1  , rect
.top 
) ; 
 771         if ( inState 
== kAGAStateEnabled 
|| inState 
== kAGAStateDisabled 
) 
 772                 pixelColor 
=  gAGARamp
[ kAGA2 
] ; 
 774                 pixelColor 
= gAGARamp
[ kAGA8 
] ; 
 776         SetCPixel( rect
.right
-1  , rect
.top 
, &pixelColor 
) ; 
 777         SetCPixel( rect
.left 
, rect
.bottom
-1  , &pixelColor 
) ; 
 779         if ( inState 
== kAGAStateEnabled 
) 
 780                 RGBForeColor( &gAGARamp
[ kAGA5 
] ) ; 
 781         else if ( inState 
== kAGAStateDisabled 
) 
 782                 RGBForeColor( &gAGARamp
[ kAGA4 
] ) ; 
 784                 RGBForeColor( &gAGARamp
[ kAGA6 
] ) ; 
 786         MoveTo( rect
.left 
+ 1 , rect
.bottom
-1  ) ; 
 787         LineTo( rect
.right
-1  , rect
.bottom
-1  ) ; 
 788         LineTo( rect
.right
-1  , rect
.top
-1 ) ; 
 792                 InsetRect( &rect 
, 1 , 1 ) ; 
 793                 if ( inState 
== kAGAStateEnabled 
|| inState 
== kAGAStateDisabled 
) 
 794                         RGBForeColor( &gAGARamp
[ kAGA2 
] ) ; 
 796                         RGBForeColor( &gAGARamp
[ kAGA8 
] ) ; 
 801 void AGADrawRectProgress( const Rect 
*inRect 
, eAGAState inState 
, double percentage 
)  
 803         Rect rect 
= *inRect 
; 
 804         rect
.bottom 
= rect
.top 
+ 14 ;  
 805         RGBColor pixelColor 
; 
 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 
) ; 
 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 ) ; 
 817         InsetRect( &rect 
, 1 , 1 ) ; 
 818         RGBForeColor( &gAGARamp
[ kAGABlack 
] ) ; 
 820         Rect barLeft 
= rect 
, barRight 
= rect 
; 
 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 
) ; 
 828         InsetRect( &barLeft 
, 1 , 1 ) ; 
 830         InsetRect( &barRight 
, 1 , 1 ) ; 
 832         if ( !EmptyRect( &barRight 
) ) 
 834                 RGBForeColor( &gAGARamp
[ kAGA10 
] ) ; 
 835                 MoveTo( barRight
.left 
, barRight
.bottom 
-1 ) ; 
 836                 LineTo( barRight
.left 
, barRight
.top 
) ; 
 838                 if ( !EmptyRect( &barRight 
) ) 
 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 
) ) 
 853                                 RGBForeColor( &gAGARamp
[ kAGA4 
] ) ; 
 854                                 PaintRect( &barRight 
) ; 
 857                 if ( !EmptyRect( &barLeft 
) ) 
 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 
) ) 
 876                                 RGBForeColor( &gAGABlueRamp
[ kAGA3 
] ) ; 
 877                                 PaintRect( &barLeft 
) ; 
 883 SInt32 
AGAGetDataHelper( ControlDataAccessRec 
*rec 
, Size size 
, Ptr data 
) ; 
 884 SInt32 
AGAGetDataHelper( ControlDataAccessRec 
*rec 
, Size size 
, Ptr data 
)  
 886         if ( rec
->dataPtr 
== NULL 
) 
 893                 if ( rec
->size 
< size 
) 
 894                         return errDataSizeMismatch 
; 
 897                 memcpy( rec
->dataPtr 
, data 
, size 
) ; 
 902 void AGASetFontStyle( ControlFontStyleRec 
*fontstyle 
) ; 
 903 void AGASetFontStyle( ControlFontStyleRec 
*fontstyle 
) 
 905                 if( fontstyle
->font 
>= 0 ) 
 907                         ::TextFont( fontstyle
->font 
) ; 
 908                         ::TextSize( fontstyle
->size 
) ; 
 909                         ::TextFace( fontstyle
->style 
) ; 
 913                         switch( fontstyle
->font 
) 
 915                                 case kControlFontBigSystemFont 
: 
 916                                         ::TextFont( systemFont 
) ;  
 920                                 case kControlFontSmallSystemFont 
: 
 921                                         ::TextFont( kFontIDGeneva 
) ;  
 925                                 case kControlFontSmallBoldSystemFont 
: 
 926                                         ::TextFont( kFontIDGeneva 
) ;  
 932                 ::RGBForeColor( &fontstyle
->foreColor 
) ; 
 933                 ::RGBBackColor( &fontstyle
->backColor 
) ; 
 936 pascal SInt32 
AGAProgressBarDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) 
 942                                 if (!(**theControl
).contrlVis
)                           
 944                                 PenState                oldPenState
; 
 945                                 RGBColor                oldForeColor 
; 
 946                                 RGBColor                oldBackColor 
; 
 950                                 GetPenState( &oldPenState 
) ; 
 951                                 GetBackColor( &oldBackColor 
) ; 
 952                                 GetForeColor( &oldForeColor 
) ; 
 955                                         int                     theValue 
= GetControlValue(theControl
) ; 
 956                                         int                     theMinimum 
= GetControlMinimum(theControl
) ; 
 957                                         int                     theMaximum 
= GetControlMaximum(theControl
) ; 
 959                                         AGADrawRectProgress( &(**theControl
).contrlRect 
, kAGAStateEnabled 
, (( double )( theValue 
- theMinimum 
)) / ( theMaximum
-theMinimum 
) ) ; 
 962                                 RGBForeColor(&oldForeColor
); 
 963                                 RGBBackColor(&oldBackColor
); 
 964                                 SetPenState(&oldPenState
);                               
 968                         RectRgn((RgnHandle
) param 
, &(**theControl
).contrlRect 
) ; 
 978 pascal SInt32 
AGAPlacardDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) 
 984                                 if (!(**theControl
).contrlVis
)                           
 986                                 PenState                oldPenState
; 
 987                                 RGBColor                oldForeColor 
; 
 988                                 RGBColor                oldBackColor 
; 
 992                                 GetPenState( &oldPenState 
) ; 
 993                                 GetBackColor( &oldBackColor 
) ; 
 994                                 GetForeColor( &oldForeColor 
) ; 
 997                                         AGADrawRectPlacard( &(**theControl
).contrlRect 
, kAGAStateEnabled 
, true  ) ; 
1000                                 RGBForeColor(&oldForeColor
); 
1001                                 RGBBackColor(&oldBackColor
); 
1002                                 SetPenState(&oldPenState
);                               
1012 pascal SInt32 
AGABevelButtonDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) 
1014         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**theControl
).contrlRfCon 
;        
1018                         info
->privateData 
= (long) malloc( sizeof( ControlButtonContentInfo 
) ) ; 
1019                         memset( (char*) info
->privateData 
, 0 , sizeof( ControlButtonContentInfo 
)  ) ; 
1022                         free( (void*) info
->privateData 
) ; 
1024                 case kControlMsgSetData 
: 
1026                                 ControlDataAccessRec 
*rec 
= (ControlDataAccessRec 
*) param 
; 
1027                                 if ( rec
->tag 
== kControlBevelButtonContentTag 
) 
1029                                         memcpy( (char*) info
->privateData 
, rec
->dataPtr 
, rec
->size 
) ; 
1032                                 return errDataNotSupported 
; 
1034                 case kControlMsgCalcBestRect 
: 
1036                                 ControlCalcSizeRec 
*rec 
= (ControlCalcSizeRec 
*) param 
; 
1044                                 if (!(**theControl
).contrlVis
)                           
1048                                         AGAPortHelper 
help((**theControl
).contrlOwner
) ; 
1049                                         AGASetFontStyle( &info
->fontStyle 
) ; 
1050                                         Boolean mRadioBehavior 
= false ; 
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; 
1058                                         int triState_Off 
= 3 ; 
1059                                         Boolean disabled 
= (mEnabled 
== triState_Off
); 
1061                                         Rect frame 
= (**theControl
).contrlRect 
; 
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); 
1073                                         //      Draw the inside (w/o the Icon) 
1074                                         ::InsetRect(&frame
, 1, 1); 
1077                                                         AGASetFontStyle( &info
->fontStyle 
) ; 
1079                                                                 ::RGBBackColor(&gAGAColorArray
[4]); 
1081                                         ::EraseRect(&frame
); 
1086                                                         ::RGBForeColor(&gAGAColorArray
[7]); 
1089                                                                         ::MoveTo(frame
.left
, frame
.bottom 
- 1); 
1090                                                                         ::LineTo(frame
.left
, frame
.top
); 
1091                                                                         ::LineTo(frame
.right 
- 1, frame
.top
); 
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
); 
1110                                         frame 
= (**theControl
).contrlRect 
; 
1112                                         PicHandle thePict 
= ((ControlButtonContentInfo
*) info
->privateData
)->u
.picture 
; 
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 ) ; 
1120                                                         ::OffsetRect( &bitmaprect 
, 1 , 1 ) ; 
1121                                                 ::DrawPicture( thePict 
, &bitmaprect 
) ; 
1129                           pt
.h 
= LoWord( param 
) ; 
1130                           pt
.v 
= HiWord( param 
) ; 
1131                           if ( PtInRect( pt 
, &(**theControl
).contrlRect  
) ) 
1132                                         return kControlButtonPart 
; 
1138                         RectRgn((RgnHandle
) param 
, &(**theControl
).contrlRect 
) ; 
1143                           pt
.h 
= LoWord( param 
) ; 
1144                           pt
.v 
= HiWord( param 
) ; 
1145                           if ( PtInRect( pt 
, &(**theControl
).contrlRect  
) ) 
1146                                         return kControlButtonPart 
; 
1158 pascal SInt32 
AGAButtonDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) 
1160         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**theControl
).contrlRfCon 
;        
1164                         (**theControl
).contrlData 
= NULL 
; 
1166                 case kControlMsgSetData 
: 
1168                                 ControlDataAccessRec 
*rec 
= (ControlDataAccessRec 
*) param 
; 
1169                                 Boolean isDefault 
= *((Boolean
*)rec
->dataPtr 
) ; 
1170                                 (**theControl
).contrlData 
= (Handle
) isDefault 
; 
1174                 case kControlMsgCalcBestRect 
: 
1176                                 ControlCalcSizeRec 
*rec 
= (ControlCalcSizeRec 
*) param 
; 
1184                                 if (!(**theControl
).contrlVis
)                           
1188                                         AGAPortHelper 
help((**theControl
).contrlOwner
) ; 
1189                                         AGASetFontStyle( &info
->fontStyle 
) ; 
1190                                         Boolean mRadioBehavior 
= false ; 
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; 
1199                                         int triState_Off 
= 3 ; 
1200                                         Boolean disabled 
= (mEnabled 
== triState_Off
); 
1202 //                                      theState.Normalize(); 
1203 //                                      CalcLocalFrameRect(frame); 
1204                                         frame
= (**theControl
).contrlRect 
; 
1206                                         if ( (**theControl
).contrlData 
) 
1208                                                 InsetRect( &frame 
, -3 , -3 ) ; 
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
); 
1222                                                                         const RGBColor 
*col 
= gAGAColorArray
; 
1223                                                                         for (int i 
= 0; i 
< 5; i
++) 
1224                                                                                 for (int j 
= 0; j 
< 5; j
++) 
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
]]); 
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); 
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); 
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); 
1262                                         AGASetFontStyle( &info
->fontStyle 
) ; 
1263                                         frame
= (**theControl
).contrlRect 
; 
1266                                         ::InsetRect(&tempRect
, 1, 1); 
1270                                                                 ::RGBBackColor(&gAGAColorArray
[4]); 
1272                                         EraseRect(&tempRect
); 
1278                                                                 ::RGBForeColor(&gAGAColorArray
[7]); 
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
) 
1294                                         //      Draw the four corners around 
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
++) 
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
]]); 
1313                                                                 ::RGBForeColor(&gAGAColorArray
[8]); 
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); 
1324                                                                                 ::RGBForeColor(&gAGAColorArray
[1]); 
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); 
1332                                                                                 ::RGBForeColor(&gAGAColorArray
[5]); 
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); 
1341                                                                                 ::RGBForeColor(&gAGAColorArray
[4]); 
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); 
1350                                         AGASetFontStyle( &info
->fontStyle 
) ; 
1351                                         int x 
= ( (**theControl
).contrlRect
.left 
+ (**theControl
).contrlRect
.right 
) / 2 ; 
1352                                         int y 
= ( (**theControl
).contrlRect
.top 
+       (**theControl
).contrlRect
.bottom 
) / 2 ; 
1354                                         ::GetFontInfo( &fi 
) ; 
1356                                         y 
+= fi
.ascent 
/ 2 ; 
1357                                         int length 
= (**theControl
).contrlTitle
[0] ; 
1360                                                 int width 
= TextWidth( &(**theControl
).contrlTitle
[1] , 0, length 
) ; 
1363                                                 ::DrawText( &(**theControl
).contrlTitle
[1] , 0, length
); 
1372                           pt
.h 
= LoWord( param 
) ; 
1373                           pt
.v 
= HiWord( param 
) ; 
1374                           if ( PtInRect( pt 
, &(**theControl
).contrlRect  
) ) 
1375                                         return kControlButtonPart 
; 
1381                         RectRgn((RgnHandle
) param 
, &(**theControl
).contrlRect 
) ; 
1386                           pt
.h 
= LoWord( param 
) ; 
1387                           pt
.v 
= HiWord( param 
) ; 
1388                           if ( PtInRect( pt 
, &(**theControl
).contrlRect  
) ) 
1389                                         return kControlButtonPart 
; 
1401 const int kAGACheckBoxWidth 
= 12 ; 
1402 const int kAGACheckBoxHeigth 
= 12 ; 
1404 pascal SInt32 
AGACheckBoxDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) 
1406         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**theControl
).contrlRfCon 
;        
1411                                 if (!(**theControl
).contrlVis
)                           
1413                                 PenState                oldPenState
; 
1414                                 RGBColor                oldForeColor 
; 
1415                                 RGBColor                oldBackColor 
; 
1416                                 RGBColor                backColor 
; 
1417                                 RGBColor                foreColor 
; 
1421                                         if (!(**theControl
).contrlVis
)                           
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 
; 
1432                                                 int triState_Off 
= 3 ; 
1434                                                 frame
.right 
= frame
.left 
+ kAGACheckBoxWidth
; 
1435                                                 frame
.bottom 
= frame
.top 
+ kAGACheckBoxHeigth
; 
1437                                                 //      Draw the frame of the checkbox 
1440                                                                         ::RGBForeColor(&gAGAColorArray
[7]); 
1444                                                 ::FrameRect(&frame
); 
1449                                                 ::InsetRect(&frame
, 1, 1); 
1451                                                         ::RGBBackColor(inPushed 
? &gAGAColorArray
[8] : &gAGAColorArray
[2]); 
1452                                                 ::EraseRect(&frame
); 
1457                                                                         ::RGBForeColor(&gAGAColorArray
[10]); 
1459                                                                         ForeColor(whiteColor
); 
1460                                                                 ::MoveTo(frame
.left
, frame
.bottom 
- 2); 
1461                                                                 ::LineTo(frame
.left
, frame
.top
); 
1462                                                                 ::LineTo(frame
.right 
- 2, frame
.top
); 
1465                                                                         ::RGBForeColor(&gAGAColorArray
[6]); 
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); 
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); 
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); 
1493                                                                                                 if (mEnabled 
!= triState_Off
) 
1494                                                                                                         ::ForeColor(blackColor
); 
1496                                                                                                         ::RGBForeColor(&gAGAColorArray
[7]); 
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); 
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); 
1517                                                                                                 if (mEnabled 
!= triState_Off
) 
1518                                                                                                         ::ForeColor(blackColor
); 
1520                                                                                                         ::RGBForeColor(&gAGAColorArray
[7]); 
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); 
1529                                                 if (inPushed 
&& !hasColor
) 
1532                                                 AGASetFontStyle( &info
->fontStyle 
) ; 
1533                                                 int x 
= (**theControl
).contrlRect
.left 
+ kAGACheckBoxWidth 
+ 5 ; 
1534                                                 int y 
= ( (**theControl
).contrlRect
.top 
+ (**theControl
).contrlRect
.bottom 
) / 2 ; 
1536                                                 ::GetFontInfo( &fi 
) ; 
1538                                                 y 
+= fi
.ascent 
/ 2 ; 
1540                                                 int length 
= (**theControl
).contrlTitle
[0] ; 
1543                                                         ::DrawText( &(**theControl
).contrlTitle
[1] , 0, length
); 
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 
; 
1564                           pt
.h 
= LoWord( param 
) ; 
1565                           pt
.v 
= HiWord( param 
) ; 
1566                           if ( PtInRect( pt 
, &(**theControl
).contrlRect  
) ) 
1568                                 if ( (**theControl
).contrlValue 
) 
1569                                         (**theControl
).contrlValue 
= 0 ; 
1571                                         (**theControl
).contrlValue 
= 1 ; 
1581                         if ( !EmptyRect(&(**theControl
).contrlRect 
) ) 
1582                                 RectRgn((RgnHandle
) param 
, &(**theControl
).contrlRect 
) ; 
1584                 case kControlMsgCalcBestRect 
: 
1586                                 ControlCalcSizeRec 
*rec 
= (ControlCalcSizeRec 
*) param 
; 
1587                                 rec
->width 
= (**theControl
).contrlRect
.right 
- (**theControl
).contrlRect
.left 
; 
1588                                 rec
->height 
= kAGACheckBoxHeigth 
; 
1599 pascal SInt32 
AGARadioButtonDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) 
1602 /*      ExtCDEFInfo* info = (ExtCDEFInfo* )  (**theControl).contrlRfCon ;        
1607                                 if (!(**theControl).contrlVis)                           
1609                                 PenState                oldPenState; 
1610                                 RGBColor                oldForeColor ; 
1611                                 RGBColor                oldBackColor ; 
1612                                 RGBColor                backColor ; 
1613                                 RGBColor                foreColor ; 
1617                                         if (!(**theControl).contrlVis)                           
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 ; 
1628                                                 int triState_Off = 3 ; 
1630                                                 frame.right = frame.left + kAGACheckBoxWidth; 
1631                                                 frame.bottom = frame.top + kAGACheckBoxHeigth; 
1633                                                 //      Draw the frame of the checkbox 
1636                                                                         ::RGBForeColor(&gAGAColorArray[7]); 
1640                                                 ::FrameRect(&frame); 
1645                                                 ::InsetRect(&frame, 1, 1); 
1647                                                         ::RGBBackColor(inPushed ? &gAGAColorArray[8] : &gAGAColorArray[2]); 
1648                                                 ::EraseRect(&frame); 
1653                                                                         ::RGBForeColor(&gAGAColorArray[10]); 
1655                                                                         ForeColor(whiteColor); 
1656                                                                 ::MoveTo(frame.left, frame.bottom - 2); 
1657                                                                 ::LineTo(frame.left, frame.top); 
1658                                                                 ::LineTo(frame.right - 2, frame.top); 
1661                                                                         ::RGBForeColor(&gAGAColorArray[6]); 
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); 
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); 
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); 
1689                                                                                                 if (mEnabled != triState_Off) 
1690                                                                                                         ::ForeColor(blackColor); 
1692                                                                                                         ::RGBForeColor(&gAGAColorArray[7]); 
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); 
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); 
1713                                                                                                 if (mEnabled != triState_Off) 
1714                                                                                                         ::ForeColor(blackColor); 
1716                                                                                                         ::RGBForeColor(&gAGAColorArray[7]); 
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); 
1725                                                 if (inPushed && !hasColor) 
1728                                                 AGASetFontStyle( &info->fontStyle ) ; 
1729                                                 int x = (**theControl).contrlRect.left + kAGACheckBoxWidth + 5 ; 
1730                                                 int y = ( (**theControl).contrlRect.top + (**theControl).contrlRect.bottom ) / 2 ; 
1732                                                 ::GetFontInfo( &fi ) ; 
1734                                                 y += fi.ascent / 2 ; 
1736                                                 int length = (**theControl).contrlTitle[0] ; 
1739                                                         ::DrawText( &(**theControl).contrlTitle[1] , 0, length); 
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 ; 
1760                           pt.h = LoWord( param ) ; 
1761                           pt.v = HiWord( param ) ; 
1762                           if ( PtInRect( pt , &(**theControl).contrlRect  ) ) 
1764                                 if ( (**theControl).contrlValue ) 
1765                                         (**theControl).contrlValue = 0 ; 
1767                                         (**theControl).contrlValue = 1 ; 
1777                         if ( !EmptyRect(&(**theControl).contrlRect ) ) 
1778                                 RectRgn((RgnHandle) param , &(**theControl).contrlRect ) ; 
1780                 case kControlMsgCalcBestRect : 
1782                                 ControlCalcSizeRec *rec = (ControlCalcSizeRec *) param ; 
1783                                 rec->width = (**theControl).contrlRect.right - (**theControl).contrlRect.left ; 
1784                                 rec->height = kAGACheckBoxHeigth ; 
1795 pascal SInt32 
AGAStaticGroupBoxTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) 
1797         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**theControl
).contrlRfCon 
;        
1807                                 if (!(**theControl
).contrlVis
)                           
1811                                         bool disabled 
= false ; 
1812                                         bool hasColor 
= true ; 
1813                                         AGAPortHelper 
help((**theControl
).contrlOwner
) ; 
1814                                         AGASetFontStyle( &info
->fontStyle 
) ; 
1816                                         ::GetFontInfo( &fi 
) ; 
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 ; 
1831                                                 RGBForeColor( &gAGAColorArray
[4] ) ; 
1835                                                 RGBForeColor( &gAGAColorArray
[7] ) ; 
1837                                         FrameRect( &theFrame 
) ; 
1840                                                 ::RGBForeColor(&gAGAColorArray
[1]); 
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
); 
1850                                         AGASetFontStyle( &info
->fontStyle 
) ; 
1851                                         ::EraseRect( &labelRect 
) ; 
1852                                         ::MoveTo(labelRect
.left 
+ 3, labelRect
.top 
+ fi
.ascent 
+ (fi
.leading 
>> 1)); 
1853                                         ::DrawString((**theControl
).contrlTitle
); 
1857                 case kControlMsgCalcBestRect 
: 
1859                                 ControlCalcSizeRec 
*rec 
= (ControlCalcSizeRec 
*) param 
; 
1860                                 rec
->width 
= (**theControl
).contrlRect
.right 
- (**theControl
).contrlRect
.left 
; 
1861                                 rec
->height 
= (**theControl
).contrlRect
.bottom 
- (**theControl
).contrlRect
.top  
; 
1865                 case kControlMsgSetData 
: 
1868                         RectRgn((RgnHandle
) param 
, &(**theControl
).contrlRect 
) ; 
1877 pascal SInt32 
AGAStaticTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) 
1879         Handle macText 
= (**theControl
).contrlData 
; 
1880         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**theControl
).contrlRfCon 
;        
1886                                 macText 
= NewHandle(0) ; 
1887                                  (**theControl
).contrlData 
= (Handle
) macText 
; 
1891                         DisposeHandle( macText 
) ; 
1895                                 if (!(**theControl
).contrlVis
)                           
1899                                         AGAPortHelper 
help((**theControl
).contrlOwner
) ; 
1900                                         AGASetFontStyle( &info
->fontStyle 
) ; 
1901                                         int x 
= (**theControl
).contrlRect
.left 
; 
1902                                         int y 
= (**theControl
).contrlRect
.top 
; 
1905                                         ::GetFontInfo( &fi 
) ; 
1908                                         lineheight 
= fi
.ascent 
+ fi
.descent 
+ fi
.leading 
; 
1909                                         int length 
= GetHandleSize( macText 
) ; 
1915                                                 RGBColor gray 
= { 0xDDDD , 0xDDDD, 0xDDDD } ; 
1916                                                 ::RGBBackColor( &gray 
) ; 
1919                                                         if ( (*macText
)[i
] == 0x0d ) 
1922                                                                 ::DrawText( *macText 
, laststop
, i
-laststop
); 
1929                                                 ::DrawText( *macText 
, laststop
, i
-laststop
); 
1931                                                 HUnlock( macText 
) ; 
1936                 case kControlMsgCalcBestRect 
: 
1938                                 ControlCalcSizeRec 
*rec 
= (ControlCalcSizeRec 
*) param 
; 
1939                                 rec
->width 
= (**theControl
).contrlRect
.right 
- (**theControl
).contrlRect
.left 
; 
1940                                 rec
->height 
= (**theControl
).contrlRect
.bottom 
- (**theControl
).contrlRect
.top  
; 
1944                 case kControlMsgSetData 
: 
1946                                 ControlDataAccessRec 
*rec 
= (ControlDataAccessRec 
*) param 
; 
1947                                 if ( rec
->tag 
== kControlStaticTextTextTag 
) 
1949                                         SetHandleSize( macText 
, rec
->size 
) ; 
1950                                         memcpy( *macText 
, rec
->dataPtr 
, rec
->size 
) ; 
1953                                 return errDataNotSupported 
; 
1962 void AGAMoveControl(ControlHandle inControl 
, short x 
, short y 
)  
1964         if ( AGATestForNewControl( inControl 
) ) 
1966                 ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**inControl
).contrlRfCon 
;         
1967                 if ( info
->magic 
== kExtCDEFMagic 
) 
1969                         if ( info
->procID 
== kControlEditTextProc
) 
1974                                 dx
= x 
- (**inControl
).contrlRect
.left  
; 
1975                                 dy
= y 
- (**inControl
).contrlRect
.top 
; 
1977                                 MoveControl( inControl 
, x 
,y  
) ; 
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 
; 
1991                         if ( info
->procID 
== kControlListBoxProc
) 
1996                                 dx
= x 
- (**inControl
).contrlRect
.left  
; 
1997                                 dy
= y 
- (**inControl
).contrlRect
.top 
; 
1999                                 MoveControl( inControl 
, x 
,y  
) ; 
2000                                 ListHandle macList 
; 
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 
; 
2011         MoveControl( inControl 
, x 
,y  
) ; 
2014 void AGASizeControl(ControlHandle inControl 
, short x 
, short y 
)  
2016         if ( AGATestForNewControl( inControl 
) ) 
2018                 ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**inControl
).contrlRfCon 
;         
2019                 if ( info
->magic 
== kExtCDEFMagic 
) 
2021                         if ( info
->procID 
== kControlEditTextProc
) 
2026                                 dx
= x 
- ( (**inControl
).contrlRect
.right 
- (**inControl
).contrlRect
.left 
) ; 
2027                                 dy
= y 
- ( (**inControl
).contrlRect
.bottom 
- (**inControl
).contrlRect
.top 
) ; 
2029                                 SizeControl( inControl 
, x 
,y  
) ; 
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 
; 
2039                         if ( info
->procID 
== kControlListBoxProc
) 
2044                                 dx
= x 
- ( (**inControl
).contrlRect
.right 
- (**inControl
).contrlRect
.left 
) ; 
2045                                 dy
= y 
- ( (**inControl
).contrlRect
.bottom 
- (**inControl
).contrlRect
.top 
) ; 
2047                                 SizeControl( inControl 
, x 
,y  
) ; 
2048                                 ListHandle macList 
; 
2050                                 macList 
= (ListHandle
) (**inControl
).contrlData 
; 
2051                                 (**macList
).rView
.right 
+= dx 
; 
2052                                 (**macList
).rView
.bottom 
+= dy 
; 
2057         SizeControl( inControl 
, x 
,y  
) ; 
2060 pascal SInt32 
AGARootControlDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) 
2062         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**theControl
).contrlRfCon 
;        
2072                 case kControlMsgCalcBestRect 
: 
2074                 case kControlMsgSetData 
: 
2082 pascal SInt32 
AGAEditTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) 
2084         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**theControl
).contrlRfCon 
;        
2088         macTE 
= (TEHandle
) (**theControl
).contrlData 
; 
2094                                 AGAPortHelper 
help((**theControl
).contrlOwner
) ; 
2095                                 SetPort( (**theControl
).contrlOwner 
) ; 
2096                                 ::TextFont( kFontIDGeneva 
) ;  
2099                                 RGBBackColor( &gAGARamp
[ kAGAWhite 
] ) ; 
2100                                 RGBForeColor( &gAGARamp
[ kAGABlack 
] ) ; 
2101                                 Rect bounds 
=  (**theControl
).contrlRect 
;                               
2102                                 InsetRect( &bounds 
, 4 , 1 ) ; 
2104                                 ::GetFontInfo( &fi 
) ; 
2106                                 bounds
.top 
= bounds
.bottom 
- abs( fi
.descent 
) - fi
.ascent 
- 3; 
2107                                 macTE 
= TENew( &bounds 
, &bounds
) ; 
2108                                  (**theControl
).contrlData 
= (Handle
) macTE 
; 
2112                         TEDispose( macTE 
) ; 
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 
) ; 
2129                           pt
.h 
= LoWord( param 
) ; 
2130                           pt
.v 
= HiWord( param 
) ; 
2131                           if ( PtInRect( pt 
, &(**theControl
).contrlRect  
) ) 
2132                                         return kControlButtonPart 
; 
2140                           pt
.h 
= LoWord( param 
) ; 
2141                           pt
.v 
= HiWord( param 
) ; 
2142                           if ( PtInRect( pt 
, &(**theControl
).contrlRect  
) ) 
2144                                 TEClick( pt 
, false , macTE 
) ; 
2148                 case kControlMsgGetData 
: 
2150                                 ControlDataAccessRec 
*rec 
= (ControlDataAccessRec 
*) param 
; 
2151                                 if ( rec
->tag 
== kControlEditTextTEHandleTag 
) 
2153                                         return AGAGetDataHelper( rec 
, sizeof( TEHandle 
) , (char*) &macTE 
) ; 
2155                                 else if ( rec
->tag 
== kControlEditTextTextTag 
) 
2157                                         return AGAGetDataHelper( rec 
, (**macTE
).teLength 
, (char*) *(**macTE
).hText 
) ; 
2159                                 else if ( rec
->tag 
== kControlEditTextSelectionTag 
) 
2162                                 return errDataNotSupported 
; 
2165                 case kControlMsgSetData 
: 
2167                                 ControlDataAccessRec 
*rec 
= (ControlDataAccessRec 
*) param 
; 
2168                                 if ( rec
->tag 
== kControlEditTextTextTag 
) 
2170                                         TESetText( rec
->dataPtr 
, rec
->size 
,  macTE 
) ; 
2173                                 return errDataNotSupported 
; 
2175                 case kControlMsgCalcBestRect 
: 
2177                                 ControlCalcSizeRec 
*rec 
= (ControlCalcSizeRec 
*) param 
; 
2178                                 rec
->width 
= (**theControl
).contrlRect
.right 
- (**theControl
).contrlRect
.left 
; 
2179                                 rec
->height 
= (**theControl
).contrlRect
.bottom 
- (**theControl
).contrlRect
.top  
; 
2182                 case kControlMsgFocus 
: 
2184                                 if ( param 
== kControlFocusNoPart 
) 
2186                                         info
->hasFocus 
= false ; 
2187                                         TEDeactivate( macTE 
) ; 
2188                                         return kControlFocusNoPart 
; 
2190                                 else if ( param 
== kControlFocusNextPart 
|| param 
== kControlFocusPrevPart 
) 
2192                                         if ( info
->hasFocus 
) 
2194                                                 info
->hasFocus 
= false ; 
2195                                                 TEDeactivate( macTE 
) ; 
2196                                                 return kControlFocusNoPart 
; 
2200                                                 info
->hasFocus 
= true ; 
2201                                                 TEActivate( macTE 
) ; 
2202                                                 return kControlEditTextPart 
; 
2205                                 else if ( param 
== kControlEditTextPart 
) 
2207                                         if ( !info
->hasFocus 
) 
2209                                                 info
->hasFocus 
= true ; 
2210                                                 TEActivate( macTE 
) ; 
2211                                                 return kControlEditTextPart 
; 
2216                 case kControlMsgIdle 
: 
2221                 case kControlMsgKeyDown 
: 
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 
) ; 
2231                 case kControlMsgActivate 
: 
2235                                         TEActivate( macTE ) ; 
2237                                         TEDeactivate( macTE ) ; 
2242                         RectRgn((RgnHandle
) param 
, &(**theControl
).contrlRect 
) ; 
2244                 case kControlMsgTestNewMsgSupport 
: 
2245                         return kControlSupportsNewMessages 
; 
2246                 case kControlMsgGetFeatures 
: 
2248 //                              kControlSupportsGhosting | 
2249 //                              kControlSupportsEmbedding | 
2250                                 kControlSupportsFocus 
|  
2252                                 kControlWantsActivate 
|  
2253 //                              kControlHandlesTracking | 
2254                                 kControlSupportsDataAccess 
| 
2255 //                              kControlHasSpecialBackground | 
2256 //                              kControlGetsFocusOnClick | 
2257                                 kControlSupportsCalcBestRect 
| 
2258 //                              kControlSupportsLiveFeedback | 
2259 //                              kControlHasRadioBehavior | 
2268 pascal SInt32 
AGAListControlDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) 
2271         ListHandle macList 
; 
2272         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**theControl
).contrlRfCon 
;        
2274         macList 
= (ListHandle
) (**theControl
).contrlData 
; 
2276         static inLoop 
= false ; 
2277         static lastClick 
= NULL 
; 
2283                                 Rect databounds 
= { 0,0,0,0} ; 
2284                                 Point cellsize 
= { 0,0} ; 
2285                                 Rect listBounds 
=  (**theControl
).contrlRect 
; 
2287                                 InsetRect( &listBounds 
, 1 , 1 ) ; 
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 
; 
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 
) ; 
2302                         RectRgn((RgnHandle
) param 
, &(**theControl
).contrlRect 
) ; 
2307                           pt
.h 
= LoWord( param 
) ; 
2308                           pt
.v 
= HiWord( param 
) ; 
2310                           Rect  allRect 
= (**theControl
).contrlRect 
; 
2311                           listRect 
= allRect 
; 
2313                                         allRect
.right 
+= 16 ; 
2314                           if ( PtInRect( pt 
, &allRect 
) ) 
2316                                 if ( !inLoop 
&& StillDown() ) 
2319                                         LActivate( true , macList 
) ; 
2320                                         Boolean doubleClick 
= LClick( pt 
, 0 /* todo modifiers*/ , macList 
) ; 
2321                                         info
->privateData 
= doubleClick 
; 
2324                                 return kControlListBoxPart 
; 
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 
) ; 
2348                           pt
.h 
= LoWord( param 
) ; 
2349                           pt
.v 
= HiWord( param 
) ; 
2351                           Rect  allRect 
= (**theControl
).contrlRect 
; 
2352                           listRect 
= allRect 
; 
2353                           allRect
.right 
+= 16 ; 
2354                           if ( PtInRect( pt 
, &listRect 
) ) 
2356                                 if ( !inLoop 
&& StillDown() ) 
2359                                         LActivate( true , macList 
) ; 
2360                                                 Boolean doubleClick 
= LClick( pt 
, 0 /* todo modifiers*/ , macList 
) ; 
2361                                                 info
->privateData 
= doubleClick 
; 
2364                                         return kControlListBoxPart 
; 
2366                                 else if ( PtInRect( pt 
, &allRect 
) ) 
2368                                 if ( !inLoop 
&& StillDown() ) 
2371                                         // LActivate( true , macList ) ; 
2372                                                 Boolean doubleClick 
= LClick( pt 
, 0 /* todo modifiers*/ , macList 
) ; 
2373                                                 info
->privateData 
= doubleClick 
; 
2376                                         return kControlPageDownPart 
; 
2382                 case kControlMsgGetData 
: 
2384                                 ControlDataAccessRec 
*rec 
= (ControlDataAccessRec 
*) param 
; 
2385                                 if ( rec
->tag 
== kControlListBoxListHandleTag 
) 
2387                                         return AGAGetDataHelper( rec 
, sizeof( ListHandle 
) , (char*) &macList 
) ; 
2389                                 else if ( rec
->tag 
== kControlListBoxDoubleClickTag 
) 
2391                                         Boolean doubleClick 
= info
->privateData 
; 
2392                                         return AGAGetDataHelper( rec 
, sizeof( Boolean 
) , (char*) &doubleClick 
) ; 
2394                                 return errDataNotSupported 
; 
2404 OSErr 
AGACreateRootControl                              (WindowPtr                              inWindow
, 
2405                                                                  ControlHandle 
*                outControl
)  
2407         ControlHandle theControl 
= NULL 
; 
2409         SInt16 extCDEFID 
= kExtCDEFID 
<< 4 + 0 ; 
2411         theControl 
= NewControl( inWindow 
, &inWindow
->portRect 
, "\p" , true , 
2412                         0 , 0 , 1 , extCDEFID 
, 0 ) ; 
2413         NewExtCDEFInfo( theControl 
, AGARootControlDefProc 
, kAGARootControlProcID 
, 0 ) ; 
2415         *outControl 
= theControl 
; 
2419 OSErr 
AGAEmbedControl                                   (ControlHandle                  inControl
, 
2420                                                                  ControlHandle                  inContainer
)  
2422         if ( AGATestForNewControl( inControl 
) ) 
2424                 ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**inControl
).contrlRfCon 
;         
2425                 info
->containerControl 
= inContainer 
; 
2430 void AGADrawControl( ControlHandle control 
) 
2432         DrawOneControl( control 
) ; 
2433         ControlHandle iter 
= (ControlHandle
) ((WindowPeek
)(**control
).contrlOwner
)->controlList 
;  
2436                 if ( AGATestForNewControl( iter 
) ) 
2438                         ExtCDEFInfo
* info 
= (ExtCDEFInfo
* )  (**iter
).contrlRfCon 
; 
2439                         if ( info
->containerControl 
== control 
) 
2441                                 AGADrawControl( iter  
) ; 
2445                 iter 
= (**iter
).nextControl 
; 
2450 ControlHandle 
AGANewControl(WindowPtr                           owningWindow
, 
2451                                                                  const Rect 
*                   bounds
, 
2452                                                                  ConstStr255Param               controlTitle
, 
2453                                                                  Boolean                                initiallyVisible
, 
2454                                                                  SInt16                                 initialValue
, 
2455                                                                  SInt16                                 minimumValue
, 
2456                                                                  SInt16                                 maximumValue
, 
2458                                                                  SInt32                                 controlReference
) 
2460         ControlHandle theControl 
= NULL 
; 
2461         Rect boundsRect 
= *bounds 
; 
2462         SInt16 extCDEFID 
= kExtCDEFID 
<< 4 + 0 ; 
2463         SInt16 oldProcID 
= extCDEFID 
; 
2466                 case kControlScrollBarProc 
: 
2467                 case kControlScrollBarLiveProc 
: 
2468                         oldProcID 
= scrollBarProc 
; 
2470                 case kControlListBoxProc 
: 
2475         if ( oldProcID 
== extCDEFID 
&& procID 
== kControlListBoxProc 
) 
2477                 boundsRect
.right 
-= 16 ; 
2479         theControl 
= NewControl( owningWindow 
, &boundsRect 
, controlTitle 
, initiallyVisible 
, 
2480                         initialValue 
, minimumValue 
, maximumValue 
, oldProcID 
, controlReference 
) ; 
2481         if ( oldProcID 
== extCDEFID 
) 
2483                 ControlDefProcPtr theProcPtr 
= NULL 
; 
2484                 SInt16 theVarCode 
= 0 ; 
2487                         case kControlPushButtonProc 
: 
2488                                 theProcPtr 
= AGAButtonDefProc 
; 
2490                         case kControlCheckBoxProc 
: 
2491                                 theProcPtr 
= AGACheckBoxDefProc 
; 
2493                         case kControlRadioButtonProc 
: 
2494                                 theProcPtr 
= AGARadioButtonDefProc 
; 
2496                         case kControlProgressBarProc 
: 
2497                                 theProcPtr 
= AGAProgressBarDefProc 
; 
2499                         case kControlPlacardProc 
: 
2500                                 theProcPtr 
= AGAPlacardDefProc 
; 
2502                         case kControlStaticTextProc 
: 
2503                                 theProcPtr 
= AGAStaticTextDefProc 
; 
2505                         case kControlListBoxProc 
: 
2506                                 theProcPtr 
= AGAListControlDefProc 
; 
2508                         case kControlEditTextProc 
: 
2509                                 theProcPtr 
= AGAEditTextDefProc 
; 
2511                         case kControlGroupBoxTextTitleProc 
: 
2512                                 theProcPtr 
= AGAStaticGroupBoxTextDefProc 
; 
2514                         case kControlBevelButtonNormalBevelProc 
: 
2515                                 theProcPtr 
= AGABevelButtonDefProc 
; 
2521                         NewExtCDEFInfo( theControl 
, theProcPtr 
, procID 
, controlReference 
) ; 
2527 void                    AGASetThemeWindowBackground             (WindowRef                              inWindow
, 
2533         SetPort( inWindow 
) ; 
2534         if ( inBrush 
== kThemeBrushDialogBackgroundActive 
) 
2536                         gAGABackgroundColor 
= 2 ; 
2540                         gAGABackgroundColor 
= 0 ; 
2542         RGBBackColor( &gAGAColorArray
[gAGABackgroundColor
] ) ; 
2546 void AGAApplyThemeBackground(ThemeBackgroundKind        inKind
, 
2547                                                                  const Rect 
*                   bounds
, 
2548                                                                  ThemeDrawState                 inState
, 
2555 AGAPortHelper::AGAPortHelper( GrafPtr newport
)  
2558         SetPort( newport 
) ; 
2559 //      wxASSERT( newport->portRect.left == 0 && newport->portRect.top == 0 ) ;  
2560         GetPenState( &oldPenState 
) ; 
2561         GetBackColor( &oldBackColor 
) ; 
2562         GetForeColor( &oldForeColor 
) ; 
2566         font 
= GetPortTextFont( newport
); 
2567         size 
= GetPortTextSize( newport
); 
2568         style 
= GetPortTextFace( newport
); 
2569         mode 
= GetPortTextMode( newport
);        
2573 AGAPortHelper::AGAPortHelper() 
2577 void AGAPortHelper::Setup( GrafPtr newport 
) 
2580         SetPort( newport 
) ; 
2581 //      wxASSERT( newport->portRect.left == 0 && newport->portRect.top == 0 ) ;  
2582         GetPenState( &oldPenState 
) ; 
2583         GetBackColor( &oldBackColor 
) ; 
2584         GetForeColor( &oldForeColor 
) ; 
2588         font 
= GetPortTextFont( newport
); 
2589         size 
= GetPortTextSize( newport
); 
2590         style 
= GetPortTextFace( newport
); 
2591         mode 
= GetPortTextMode( newport
);        
2594 void AGAPortHelper::Clear() 
2598                 DisposeRgn( clip 
) ; 
2602 AGAPortHelper::~AGAPortHelper() 
2608                 DisposeRgn( clip 
) ; 
2609                 RGBForeColor(&oldForeColor
); 
2610                 RGBBackColor(&oldBackColor
); 
2611                 SetPenState(&oldPenState
);