1 #include <wx/mac/uma.h>
2 #include <wx/mac/aga.h>
9 pascal SInt32
AGAProgressBarDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
);
10 pascal SInt32
AGAPlacardDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
);
11 pascal SInt32
AGAStaticTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) ;
12 pascal SInt32
AGAListControlDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) ;
13 pascal SInt32
AGAEditTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) ;
14 pascal SInt32
AGAStaticGroupBoxTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) ;
19 SInt16 kAGARootControlProcID
;
20 int gAGABackgroundColor
= 0 ;
22 const RGBColor gAGAColorArray
[] = { {0xFFFF, 0xFFFF, 0xFFFF}, // W
23 {0xEEEE, 0xEEEE, 0xEEEE}, // 1
24 {0xDDDD, 0xDDDD, 0xDDDD}, // 2
25 {0xCCCC, 0xCCCC, 0xCCCC}, // 3
26 {0xBBBB, 0xBBBB, 0xBBBB}, // 4
27 {0xAAAA, 0xAAAA, 0xAAAA}, // 5
28 {0x9999, 0x9999, 0x9999}, // 6
29 {0x8888, 0x8888, 0x8888}, // 7
30 {0x7777, 0x7777, 0x7777}, // 8
31 {0x6666, 0x6666, 0x6666}, // 9
32 {0x5555, 0x5555, 0x5555}, // 10
33 {0x4444, 0x4444, 0x4444}, // 11
34 {0x2222, 0x2222, 0x2222}, // 12
35 {0x0000, 0x0000, 0x0000} // B
38 char LAGADefaultOutline_mCorners
[4][5][5] = {
41 { -1, -1, -1, 12, B
},
49 { B
, 12, -1, -1, -1 },
73 char LAGAPushButton_mCorners
[3][4][4][4] = {
169 RGBColor gAGARamp
[] =
174 { 65535 , 65535 , 65535 } ,
176 { 61166 , 61166 , 61166 } ,
178 { 56797 , 56797 , 56797 } ,
180 { 52428 , 52428 , 52428 } ,
182 { 48059 , 48059 , 48059 } ,
184 { 43690 , 43690 , 43690 } ,
186 { 39321 , 39321 , 39321 } ,
188 { 34952 , 34952 , 34952 } ,
190 { 30583 , 30583 , 30583 } ,
192 { 26214 , 26214 , 26214 } ,
194 { 21845 , 21845 , 21845 } ,
196 { 17476 , 17476 , 17476 } ,
198 { 13107 , 13107 , 13107 } ,
200 { 8738 , 8738 , 8738 } ,
202 { 4369 , 4369 , 4369 } ,
206 RGBColor gAGABlueRamp
[] =
211 { 65535 , 65535 , 65535 } ,
213 { 61166 , 61166 , 65535 } ,
215 { 56797 , 56797 , 65535 } ,
217 { 52428 , 52428 , 65535 } ,
219 { 48059 , 48059 , 65535 } ,
221 { 43690 , 43690 , 65535 } ,
223 { 39321 , 39321 , 65535 } ,
225 { 34952 , 34952 , 65535 } ,
227 { 30583 , 30583 , 65535 } ,
229 { 26214 , 26214 , 65535 } ,
231 { 21845 , 21845 , 65535 } ,
233 { 17476 , 17476 , 65535 } ,
235 { 13107 , 13107 , 65535 } ,
237 { 8738 , 8738 , 65535 } ,
239 { 4369 , 4369 , 65535 } ,
244 kAGATransparent
= -1 ,
265 kAGAStateEnabled
= 0 ,
266 kAGAStatePressed
= 1 ,
267 kAGAStateDisabled
= 2 ,
268 kAGAStateInactive
= 3
272 typedef struct sControlData
274 ControlPartCode m_part ;
279 OSErr AGAFindControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , long *outOffset) ;
280 OSErr AGAFindControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , long *outOffset)
282 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
284 long size = GetHandleSize( info->data ) ;
285 char* data = *(info->data) ;
286 sControlData* current ;
287 while( offset + sizeof( sControlData ) <= size )
289 current = (sControlData*) (data+offset ) ;
290 if ( ( inPart == kControlEntireControl || inPart == current->m_part ) && inTagName == current->m_tag )
292 *outOffset = offset ;
296 return errDataNotSupported ; // nothing found
299 OSErr AGARemoveControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName ) ;
300 OSErr AGARemoveControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName )
302 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
304 long size = GetHandleSize( info->data ) ;
305 char* data = *(info->data) ;
306 sControlData* current ;
307 while( offset + sizeof( sControlData ) <= size )
309 current = (sControlData*) (data+offset ) ;
310 if ( ( inPart == kControlEntireControl || inPart == current->m_part ) && inTagName == current->m_tag )
312 long chunkSize = current->m_size + sizeof ( sControlData ) ;
313 memcpy( data + offset , data + offset + chunkSize , size - offset - chunkSize ) ;
314 SetHandleSize( info->data , size - chunkSize ) ;
321 OSErr AGAAddControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , Size inSize, Ptr inData) ;
322 OSErr AGAAddControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , Size inSize, Ptr inData)
324 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
326 long size = GetHandleSize( info->data ) ;
327 SetHandleSize( info->data , size + sizeof( sControlData ) + inSize ) ;
328 if ( MemError() == noErr )
330 char* data = *(info->data) ;
331 sControlData* current = (sControlData*)( data + size ) ;
332 current->m_tag = inTagName ;
333 current->m_part = inPart ;
334 current->m_size = inSize ;
335 memcpy( data + size + sizeof( sControlData ) , inData , inSize ) ;
338 return errDataNotSupported ;
342 OSErr AGAGetControlDataSize (ControlHandle inControl,
343 ControlPartCode inPart,
348 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
349 char* data = *(info->data) ;
351 OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ;
354 sControlData* current = (sControlData*) (data+offset ) ;
355 *outMaxSize = current->m_size ;
360 OSErr AGAGetControlData (ControlHandle inControl,
361 ControlPartCode inPart,
365 Size * outActualSize)
368 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
369 char* data = *(info->data) ;
371 OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ;
374 sControlData* current = (sControlData*) (data+offset ) ;
375 *outActualSize = current->m_size ;
378 if ( inBufferSize <= current->m_size )
379 memcpy( outBuffer , data + offset + sizeof( sControlData ) , current->m_size ) ;
381 err = errDataNotSupported ;
387 OSErr AGASetControlData (ControlHandle inControl,
388 ControlPartCode inPart,
394 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
395 char* data = *(info->data) ;
397 OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ;
400 sControlData* current = (sControlData*) (data+offset ) ;
401 if ( current->m_size == inSize )
403 memcpy( data + offset + sizeof( sControlData ) , inData , inSize) ;
407 AGARemoveControlData( inControl , inPart , inTagName ) ;
408 AGAAddControlData( inControl , inPart , inTagName , inSize , inData ) ;
413 AGAAddControlData( inControl , inPart , inTagName , inSize , inData ) ;
419 OSErr
AGASetControlFontStyle (ControlHandle inControl
,
420 const ControlFontStyleRec
* inStyle
)
422 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
423 if ( inStyle
->flags
== 0 )
429 if ( inStyle
->flags
& kControlUseFontMask
)
431 info
->fontStyle
.font
= inStyle
->font
;
433 if ( inStyle
->flags
& kControlUseSizeMask
)
435 info
->fontStyle
.size
= inStyle
->size
;
437 if ( inStyle
->flags
& kControlUseFaceMask
)
439 info
->fontStyle
.style
= inStyle
->style
;
441 if ( inStyle
->flags
& kControlUseModeMask
)
443 info
->fontStyle
.mode
= inStyle
->mode
;
445 if ( inStyle
->flags
& kControlUseJustMask
)
447 info
->fontStyle
.just
= inStyle
->just
;
449 if ( inStyle
->flags
& kControlUseForeColorMask
)
451 info
->fontStyle
.foreColor
= inStyle
->foreColor
;
453 if ( inStyle
->flags
& kControlUseBackColorMask
)
455 info
->fontStyle
.backColor
= inStyle
->backColor
;
461 OSErr
AGASetControlData (ControlHandle inControl
,
462 ControlPartCode inPart
,
467 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
468 ControlDataAccessRec rec
;
470 rec
.tag
= inTagName
;
473 rec
.dataPtr
= inData
;
475 return info
->defProc( info
->procID
, inControl
, kControlMsgSetData
, (long) &rec
) ;
478 SInt16
AGAHandleControlKey (ControlHandle inControl
,
483 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
484 ControlKeyDownRec rec
;
486 rec
.modifiers
= inModifiers
;
487 rec
.keyCode
= inKeyCode
;
488 rec
.charCode
= inCharCode
;
490 return info
->defProc( info
->procID
, inControl
, kControlMsgKeyDown
, (long) &rec
) ;
493 ControlPartCode
AGAHandleControlClick (ControlHandle inControl
,
496 ControlActionUPP inAction
)
498 return TrackControl( inControl
, inWhere
, inAction
) ;
501 Boolean
AGATestForNewControl( ControlHandle inControl
)
503 if ( (**inControl
).contrlRfCon
> 0x100 && !( (**inControl
).contrlRfCon
% 2 ) )
505 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
506 return info
->magic
== kExtCDEFMagic
;
510 void AGAIdleControls (WindowPtr inWindow
)
512 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)inWindow
)->controlList
;
515 if ( AGATestForNewControl( iter
) )
517 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**iter
).contrlRfCon
;
518 if ( info
->defProc( info
->procID
, iter
, kControlMsgTestNewMsgSupport
, 0 ) == kControlSupportsNewMessages
)
520 if ( info
->defProc( info
->procID
, iter
, kControlMsgGetFeatures
, 0 ) & kControlWantsIdle
)
522 info
->defProc( info
->procID
, iter
, kControlMsgIdle
, 0 ) ;
527 iter
= (**iter
).nextControl
;
531 void AGAUpdateOneControl( ControlHandle control
, RgnHandle inRgn
)
533 DrawOneControl( control
) ;
534 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)(**control
).contrlOwner
)->controlList
;
537 if ( AGATestForNewControl( iter
) )
539 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**iter
).contrlRfCon
;
540 if ( info
->containerControl
== control
)
542 AGAUpdateOneControl( iter
, inRgn
) ;
546 iter
= (**iter
).nextControl
;
550 void AGAUpdateControls( WindowPtr inWindow
, RgnHandle inRgn
)
553 AGAGetRootControl( inWindow
, &root
) ;
554 AGAUpdateOneControl( root
, inRgn
) ;
556 // and then all others
558 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)inWindow
)->controlList
;
561 if ( AGATestForNewControl( iter
) )
566 DrawOneControl( iter
) ;
569 iter
= (**iter
).nextControl
;
573 OSErr
AGAGetRootControl( WindowPtr inWindow
, ControlHandle
*outControl
)
575 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)inWindow
)->controlList
;
578 if ( AGATestForNewControl( iter
) )
580 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**iter
).contrlRfCon
;
581 if ( info
->procID
== kAGARootControlProcID
)
588 iter
= (**iter
).nextControl
;
593 void AGADeactivateControl( ControlHandle inControl
)
595 if ( AGATestForNewControl( inControl
) )
597 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
598 if ( info
->defProc( info
->procID
, inControl
, kControlMsgTestNewMsgSupport
, 0 ) == kControlSupportsNewMessages
)
600 if ( info
->defProc( info
->procID
, inControl
, kControlMsgGetFeatures
, 0 ) & kControlWantsActivate
)
602 info
->defProc( info
->procID
, inControl
, kControlMsgActivate
, 0 ) ;
608 ::HiliteControl( inControl
, 255 ) ;
612 void AGAActivateControl( ControlHandle inControl
)
614 if ( AGATestForNewControl( inControl
) )
616 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
617 if ( info
->defProc( info
->procID
, inControl
, kControlMsgTestNewMsgSupport
, 0 ) == kControlSupportsNewMessages
)
619 if ( info
->defProc( info
->procID
, inControl
, kControlMsgGetFeatures
, 0 ) & kControlWantsActivate
)
621 info
->defProc( info
->procID
, inControl
, kControlMsgActivate
, 1 ) ;
627 ::HiliteControl( inControl
, 0 ) ;
631 OSErr
AGASetKeyboardFocus (WindowPtr inWindow
,
632 ControlHandle inControl
,
633 ControlFocusPart inPart
)
635 if ( AGATestForNewControl( inControl
) )
637 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
638 if ( info
->defProc( info
->procID
, inControl
, kControlMsgTestNewMsgSupport
, 0 ) == kControlSupportsNewMessages
)
640 if ( info
->defProc( info
->procID
, inControl
, kControlMsgGetFeatures
, 0 ) & kControlSupportsFocus
)
642 return info
->defProc( info
->procID
, inControl
, kControlMsgFocus
, inPart
) ;
646 return errControlDoesntSupportFocus
;
649 OSErr
AGAGetBestControlRect (ControlHandle inControl
,
651 SInt16
* outBaseLineOffset
)
653 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
654 ControlCalcSizeRec rec
;
655 rec
.width
= (**inControl
).contrlRect
.right
- (**inControl
).contrlRect
.left
;
656 rec
.height
= (**inControl
).contrlRect
.bottom
- (**inControl
).contrlRect
.top
;
659 OSErr err
= info
->defProc( info
->procID
, inControl
, kControlMsgCalcBestRect
, (long) &rec
) ;
662 outRect
->left
= outRect
->top
= 0 ;
663 outRect
->right
= rec
. width
;
664 outRect
->bottom
= rec
. height
;
665 *outBaseLineOffset
= rec
. baseLine
;
671 OSErr
AGAGetControlData (ControlHandle inControl
,
672 ControlPartCode inPart
,
676 Size
* outActualSize
)
678 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
679 ControlDataAccessRec rec
;
681 rec
.tag
= inTagName
;
683 rec
.size
= inBufferSize
;
684 rec
.dataPtr
= outBuffer
;
686 OSErr err
= info
->defProc( info
->procID
, inControl
, kControlMsgGetData
, (long) &rec
) ;
687 *outActualSize
= rec
.size
;
691 OSErr
AGAGetControlDataSize (ControlHandle inControl
,
692 ControlPartCode inPart
,
696 return AGAGetControlData( inControl
, inPart
, inTagName
, 0 , NULL
, outMaxSize
) ;
700 void NewExtCDEFInfo( ControlHandle theControl
, ControlDefProcPtr defproc
, SInt16 procID
, long refcon
)
702 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) malloc( sizeof( ExtCDEFInfo
) ) ;
703 info
->defProc
= defproc
;
704 info
->hasFocus
= false ;
705 info
->magic
= kExtCDEFMagic
;
706 info
->contrlRfCon
= refcon
;
707 info
->procID
= procID
;
708 info
->containerControl
= NULL
;
709 info
->children
= NewHandle(0) ;
710 info
->fontStyle
.flags
= 0 ;
711 info
->fontStyle
.font
= 0 ;
712 info
->fontStyle
.size
= 12 ;
713 info
->fontStyle
.style
= 0 ;
714 info
->fontStyle
.mode
= 0 ;
715 info
->fontStyle
.just
= 0 ;
716 info
->fontStyle
.foreColor
= gAGARamp
[ kAGABlack
] ;
717 info
->fontStyle
.backColor
= gAGARamp
[ kAGA2
] ;
718 (**theControl
).contrlRfCon
= (long) info
;
719 defproc( info
->procID
, theControl
, initCntl
, 0) ;
722 void DisposeExtCDEFInfo( ControlHandle theControl
)
724 if ( AGATestForNewControl( theControl
) )
726 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
729 DisposeHandle( info
->children
) ;
730 info
->children
= NULL
;
731 free( (void*) (**theControl
).contrlRfCon
) ;
732 (**theControl
).contrlRfCon
= NULL
;
737 const short kAGAProgressHeight
= 14 ;
739 void AGADrawRectPlacard( const Rect
*inRect
, eAGAState inState
, bool fill
= false ) ;
740 void AGADrawRectProgress( const Rect
*inRect
, eAGAState inState
, double percentage
) ;
742 void AGADrawRectPlacard( const Rect
*inRect
, eAGAState inState
, bool fill
)
744 Rect rect
= *inRect
;
745 RGBColor pixelColor
;
746 if ( inState
== kAGAStateInactive
)
748 RGBForeColor( &gAGARamp
[ kAGA10
] ) ;
752 InsetRect( &rect
, 1 , 1 ) ;
753 RGBForeColor( &gAGARamp
[ kAGA1
] ) ;
759 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
761 InsetRect( &rect
, 1 , 1 ) ;
763 if ( inState
== kAGAStateEnabled
|| inState
== kAGAStateDisabled
)
764 RGBForeColor( &gAGARamp
[ kAGAWhite
] ) ;
766 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
768 MoveTo( rect
.left
, rect
.bottom
- 1 -1 ) ;
769 LineTo( rect
.left
, rect
.top
) ;
770 LineTo( rect
.right
-1-1 , rect
.top
) ;
772 if ( inState
== kAGAStateEnabled
|| inState
== kAGAStateDisabled
)
773 pixelColor
= gAGARamp
[ kAGA2
] ;
775 pixelColor
= gAGARamp
[ kAGA8
] ;
777 SetCPixel( rect
.right
-1 , rect
.top
, &pixelColor
) ;
778 SetCPixel( rect
.left
, rect
.bottom
-1 , &pixelColor
) ;
780 if ( inState
== kAGAStateEnabled
)
781 RGBForeColor( &gAGARamp
[ kAGA5
] ) ;
782 else if ( inState
== kAGAStateDisabled
)
783 RGBForeColor( &gAGARamp
[ kAGA4
] ) ;
785 RGBForeColor( &gAGARamp
[ kAGA6
] ) ;
787 MoveTo( rect
.left
+ 1 , rect
.bottom
-1 ) ;
788 LineTo( rect
.right
-1 , rect
.bottom
-1 ) ;
789 LineTo( rect
.right
-1 , rect
.top
-1 ) ;
793 InsetRect( &rect
, 1 , 1 ) ;
794 if ( inState
== kAGAStateEnabled
|| inState
== kAGAStateDisabled
)
795 RGBForeColor( &gAGARamp
[ kAGA2
] ) ;
797 RGBForeColor( &gAGARamp
[ kAGA8
] ) ;
802 void AGADrawRectProgress( const Rect
*inRect
, eAGAState inState
, double percentage
)
804 Rect rect
= *inRect
;
805 rect
.bottom
= rect
.top
+ 14 ;
806 RGBColor pixelColor
;
808 RGBForeColor( &gAGARamp
[ kAGA5
]) ;
809 MoveTo( rect
.left
, rect
.bottom
- 1 -1 ) ;
810 LineTo( rect
.left
, rect
.top
) ;
811 LineTo( rect
.right
-1-1 , rect
.top
) ;
813 RGBForeColor( &gAGARamp
[ kAGAWhite
] ) ;
814 MoveTo( rect
.left
+ 1 , rect
.bottom
-1 ) ;
815 LineTo( rect
.right
-1 , rect
.bottom
-1 ) ;
816 LineTo( rect
.right
-1 , rect
.top
-1 ) ;
818 InsetRect( &rect
, 1 , 1 ) ;
819 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
821 Rect barLeft
= rect
, barRight
= rect
;
823 int position
= percentage
* ( rect
.right
- rect
.left
) ;
824 barLeft
.right
= barLeft
.left
+ position
;
825 barRight
.left
= barLeft
.left
+ position
;
826 FrameRect( &barLeft
) ;
827 FrameRect( &barRight
) ;
829 InsetRect( &barLeft
, 1 , 1 ) ;
831 InsetRect( &barRight
, 1 , 1 ) ;
833 if ( !EmptyRect( &barRight
) )
835 RGBForeColor( &gAGARamp
[ kAGA10
] ) ;
836 MoveTo( barRight
.left
, barRight
.bottom
-1 ) ;
837 LineTo( barRight
.left
, barRight
.top
) ;
839 if ( !EmptyRect( &barRight
) )
841 RGBForeColor( &gAGARamp
[ kAGA7
] ) ;
842 MoveTo( barRight
.left
, barRight
.bottom
-1 ) ;
843 LineTo( barRight
.left
, barRight
.top
) ;
844 LineTo( barRight
.right
-1-1 , barRight
.top
) ;
845 RGBForeColor( &gAGARamp
[ kAGA2
] ) ;
846 MoveTo( barRight
.left
+ 1 , barRight
.bottom
-1 ) ;
847 LineTo( barRight
.right
-1 , barRight
.bottom
-1 ) ;
848 LineTo( barRight
.right
-1 , barRight
.top
- 1) ;
849 pixelColor
= gAGARamp
[ kAGA4
] ;
850 SetCPixel( barRight
.right
-1 , barRight
.top
, &pixelColor
) ;
851 InsetRect( &barRight
, 1 , 1) ;
852 if ( !EmptyRect( &barRight
) )
854 RGBForeColor( &gAGARamp
[ kAGA4
] ) ;
855 PaintRect( &barRight
) ;
858 if ( !EmptyRect( &barLeft
) )
860 RGBForeColor( &gAGABlueRamp
[ kAGA8
] ) ;
861 MoveTo( barLeft
.left
, barLeft
.bottom
-1 ) ;
862 LineTo( barLeft
.left
, barLeft
.top
) ;
863 LineTo( barLeft
.left
+1 , barLeft
.top
) ;
864 RGBForeColor( &gAGABlueRamp
[ kAGA12
] ) ;
865 MoveTo( barLeft
.left
+ 2, barLeft
.bottom
-1 ) ;
866 LineTo( barLeft
.right
-1 , barLeft
.bottom
-1 ) ;
867 LineTo( barLeft
.right
-1 , barLeft
.top
-1 ) ;
868 RGBForeColor( &gAGABlueRamp
[ kAGA10
] ) ;
869 MoveTo( barLeft
.left
+ 2, barLeft
.top
) ;
870 LineTo( barLeft
.right
-1 , barLeft
.top
) ;
871 pixelColor
= gAGABlueRamp
[ kAGA10
] ;
872 SetCPixel( barLeft
.left
+ 1, barLeft
.bottom
-1 , &pixelColor
) ;
873 InsetRect( &barLeft
, 1 , 1 ) ;
874 if ( !EmptyRect( &barLeft
) )
877 RGBForeColor( &gAGABlueRamp
[ kAGA3
] ) ;
878 PaintRect( &barLeft
) ;
884 SInt32
AGAGetDataHelper( ControlDataAccessRec
*rec
, Size size
, Ptr data
) ;
885 SInt32
AGAGetDataHelper( ControlDataAccessRec
*rec
, Size size
, Ptr data
)
887 if ( rec
->dataPtr
== NULL
)
894 if ( rec
->size
< size
)
895 return errDataSizeMismatch
;
898 memcpy( rec
->dataPtr
, data
, size
) ;
903 void AGASetFontStyle( ControlFontStyleRec
*fontstyle
) ;
904 void AGASetFontStyle( ControlFontStyleRec
*fontstyle
)
906 if( fontstyle
->font
>= 0 )
908 ::TextFont( fontstyle
->font
) ;
909 ::TextSize( fontstyle
->size
) ;
910 ::TextFace( fontstyle
->style
) ;
914 switch( fontstyle
->font
)
916 case kControlFontBigSystemFont
:
917 ::TextFont( systemFont
) ;
921 case kControlFontSmallSystemFont
:
922 ::TextFont( kFontIDGeneva
) ;
926 case kControlFontSmallBoldSystemFont
:
927 ::TextFont( kFontIDGeneva
) ;
933 ::RGBForeColor( &fontstyle
->foreColor
) ;
934 ::RGBBackColor( &fontstyle
->backColor
) ;
937 pascal SInt32
AGAProgressBarDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
943 if (!(**theControl
).contrlVis
)
945 PenState oldPenState
;
946 RGBColor oldForeColor
;
947 RGBColor oldBackColor
;
951 GetPenState( &oldPenState
) ;
952 GetBackColor( &oldBackColor
) ;
953 GetForeColor( &oldForeColor
) ;
956 int theValue
= GetControlValue(theControl
) ;
957 int theMinimum
= GetControlMinimum(theControl
) ;
958 int theMaximum
= GetControlMaximum(theControl
) ;
960 AGADrawRectProgress( &(**theControl
).contrlRect
, kAGAStateEnabled
, (( double )( theValue
- theMinimum
)) / ( theMaximum
-theMinimum
) ) ;
963 RGBForeColor(&oldForeColor
);
964 RGBBackColor(&oldBackColor
);
965 SetPenState(&oldPenState
);
969 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
979 pascal SInt32
AGAPlacardDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
985 if (!(**theControl
).contrlVis
)
987 PenState oldPenState
;
988 RGBColor oldForeColor
;
989 RGBColor oldBackColor
;
993 GetPenState( &oldPenState
) ;
994 GetBackColor( &oldBackColor
) ;
995 GetForeColor( &oldForeColor
) ;
998 AGADrawRectPlacard( &(**theControl
).contrlRect
, kAGAStateEnabled
, true ) ;
1001 RGBForeColor(&oldForeColor
);
1002 RGBBackColor(&oldBackColor
);
1003 SetPenState(&oldPenState
);
1013 pascal SInt32
AGABevelButtonDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1015 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1019 info
->privateData
= (long) malloc( sizeof( ControlButtonContentInfo
) ) ;
1020 memset( (char*) info
->privateData
, 0 , sizeof( ControlButtonContentInfo
) ) ;
1023 free( (void*) info
->privateData
) ;
1025 case kControlMsgSetData
:
1027 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
1028 if ( rec
->tag
== kControlBevelButtonContentTag
)
1030 memcpy( (char*) info
->privateData
, rec
->dataPtr
, rec
->size
) ;
1033 return errDataNotSupported
;
1035 case kControlMsgCalcBestRect
:
1037 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1045 if (!(**theControl
).contrlVis
)
1049 AGAPortHelper
help((**theControl
).contrlOwner
) ;
1050 AGASetFontStyle( &info
->fontStyle
) ;
1051 Boolean mRadioBehavior
= false ;
1053 int mValue
= GetControlValue( theControl
) ;
1054 long theValue
= (mRadioBehavior
? mValue
: 0);
1055 Boolean inPushed
= (**theControl
).contrlHilite
;
1056 Boolean down
= inPushed
|| (theValue
!= 0);
1057 Boolean hasColor
= 1;
1059 int triState_Off
= 3 ;
1060 Boolean disabled
= (mEnabled
== triState_Off
);
1062 Rect frame
= (**theControl
).contrlRect
;
1064 // Draw the black frame;
1065 ::MoveTo(frame
.left
+ 1, frame
.top
);
1066 ::LineTo(frame
.right
- 2, frame
.top
);
1067 ::MoveTo(frame
.right
- 1, frame
.top
+ 1);
1068 ::LineTo(frame
.right
- 1, frame
.bottom
- 2);
1069 ::MoveTo(frame
.right
- 2, frame
.bottom
- 1);
1070 ::LineTo(frame
.left
+ 1, frame
.bottom
- 1);
1071 ::MoveTo(frame
.left
, frame
.bottom
- 2);
1072 ::LineTo(frame
.left
, frame
.top
+ 1);
1074 // Draw the inside (w/o the Icon)
1075 ::InsetRect(&frame
, 1, 1);
1078 AGASetFontStyle( &info
->fontStyle
) ;
1080 ::RGBBackColor(&gAGAColorArray
[4]);
1082 ::EraseRect(&frame
);
1087 ::RGBForeColor(&gAGAColorArray
[7]);
1090 ::MoveTo(frame
.left
, frame
.bottom
- 1);
1091 ::LineTo(frame
.left
, frame
.top
);
1092 ::LineTo(frame
.right
- 1, frame
.top
);
1096 ::MoveTo(frame
.right
- 1, frame
.top
);
1097 ::LineTo(frame
.right
- 1, frame
.bottom
- 1);
1098 ::LineTo(frame
.left
, frame
.bottom
- 1);
1099 ::MoveTo(frame
.right
- 2, frame
.top
+ 1);
1100 ::LineTo(frame
.right
- 2, frame
.bottom
- 2);
1101 ::LineTo(frame
.left
+ 1, frame
.bottom
- 2);
1102 ::ForeColor(whiteColor
);
1103 ::MoveTo(frame
.left
, frame
.bottom
- 2);
1104 ::LineTo(frame
.left
, frame
.top
);
1105 ::LineTo(frame
.right
- 2, frame
.top
);
1111 frame
= (**theControl
).contrlRect
;
1113 PicHandle thePict
= ((ControlButtonContentInfo
*) info
->privateData
)->u
.picture
;
1116 GetPictInfo( thePict
, &theInfo
, 0 , 0 , systemMethod
, 0 ) ;
1117 Rect bitmaprect
= { 0 , 0 , theInfo
.sourceRect
.bottom
- theInfo
.sourceRect
.top
,
1118 theInfo
.sourceRect
.right
- theInfo
.sourceRect
.left
} ;
1119 ::OffsetRect( &bitmaprect
, (frame
.right
+ frame
.left
)/2 - bitmaprect
.right
/ 2 , (frame
.bottom
+ frame
.top
) / 2 - bitmaprect
.bottom
/ 2 ) ;
1121 ::OffsetRect( &bitmaprect
, 1 , 1 ) ;
1122 ::DrawPicture( thePict
, &bitmaprect
) ;
1130 pt
.h
= LoWord( param
) ;
1131 pt
.v
= HiWord( param
) ;
1132 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1133 return kControlButtonPart
;
1139 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1144 pt
.h
= LoWord( param
) ;
1145 pt
.v
= HiWord( param
) ;
1146 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1147 return kControlButtonPart
;
1159 pascal SInt32
AGAButtonDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1161 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1165 (**theControl
).contrlData
= NULL
;
1167 case kControlMsgSetData
:
1169 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
1170 Boolean isDefault
= *((Boolean
*)rec
->dataPtr
) ;
1171 (**theControl
).contrlData
= (Handle
) isDefault
;
1175 case kControlMsgCalcBestRect
:
1177 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1185 if (!(**theControl
).contrlVis
)
1189 AGAPortHelper
help((**theControl
).contrlOwner
) ;
1190 AGASetFontStyle( &info
->fontStyle
) ;
1191 Boolean mRadioBehavior
= false ;
1193 Rect frame
, tempRect
;
1194 int mValue
= GetControlValue( theControl
) ;
1195 long theValue
= (mRadioBehavior
? mValue
: 0);
1196 Boolean inPushed
= (**theControl
).contrlHilite
;
1197 Boolean down
= inPushed
|| (theValue
!= 0);
1198 Boolean hasColor
= 1;
1200 int triState_Off
= 3 ;
1201 Boolean disabled
= (mEnabled
== triState_Off
);
1203 // theState.Normalize();
1204 // CalcLocalFrameRect(frame);
1205 frame
= (**theControl
).contrlRect
;
1207 if ( (**theControl
).contrlData
)
1209 InsetRect( &frame
, -3 , -3 ) ;
1211 ::MoveTo(frame
.left
+ 3, frame
.top
);
1212 ::LineTo(frame
.right
- 4, frame
.top
);
1213 ::LineTo(frame
.right
- 1, frame
.top
+ 3);
1214 ::LineTo(frame
.right
- 1, frame
.bottom
- 4);
1215 ::LineTo(frame
.right
- 4, frame
.bottom
- 1);
1216 ::LineTo(frame
.left
+ 3, frame
.bottom
- 1);
1217 ::LineTo(frame
.left
, frame
.bottom
- 4);
1218 ::LineTo(frame
.left
, frame
.top
+ 3);
1219 ::LineTo(frame
.left
+ 3, frame
.top
);
1223 const RGBColor
*col
= gAGAColorArray
;
1224 for (int i
= 0; i
< 5; i
++)
1225 for (int j
= 0; j
< 5; j
++)
1227 if (LAGADefaultOutline_mCorners
[0][i
][j
] != -1)
1228 ::SetCPixel(frame
.left
+ j
, frame
.top
+ i
, &col
[LAGADefaultOutline_mCorners
[0][i
][j
]]);
1229 if (LAGADefaultOutline_mCorners
[1][i
][j
] != -1)
1230 ::SetCPixel(frame
.right
- 5 + j
, frame
.top
+ i
, &col
[LAGADefaultOutline_mCorners
[1][i
][j
]]);
1231 if (LAGADefaultOutline_mCorners
[2][i
][j
] != -1)
1232 ::SetCPixel(frame
.left
+ j
, frame
.bottom
- 5 + i
, &col
[LAGADefaultOutline_mCorners
[2][i
][j
]]);
1233 if (LAGADefaultOutline_mCorners
[3][i
][j
] != -1)
1234 ::SetCPixel(frame
.right
- 5 + j
, frame
.bottom
- 5 + i
, &col
[LAGADefaultOutline_mCorners
[3][i
][j
]]);
1237 ::RGBForeColor(&gAGAColorArray
[2]);
1238 ::MoveTo(frame
.left
+ 1, frame
.top
+ 5);
1239 ::LineTo(frame
.left
+ 1, frame
.bottom
- 6);
1240 ::MoveTo(frame
.left
+ 5, frame
.top
+ 1);
1241 ::LineTo(frame
.right
- 6, frame
.top
+ 1);
1243 ::RGBForeColor(&gAGAColorArray
[5]);
1244 ::MoveTo(frame
.left
+ 4, frame
.top
+ 2);
1245 ::LineTo(frame
.right
- 5, frame
.top
+ 2);
1246 ::LineTo(frame
.right
- 3, frame
.top
+ 4);
1247 ::LineTo(frame
.right
- 3, frame
.bottom
- 5);
1248 ::LineTo(frame
.right
- 5, frame
.bottom
- 3);
1249 ::LineTo(frame
.left
+ 4, frame
.bottom
- 3);
1250 ::LineTo(frame
.left
+ 2, frame
.bottom
- 5);
1251 ::LineTo(frame
.left
+ 2, frame
.top
+ 4);
1252 ::LineTo(frame
.left
+ 4, frame
.top
+ 2);
1254 ::RGBForeColor(&gAGAColorArray
[8]);
1255 ::MoveTo(frame
.right
- 2, frame
.top
+ 5);
1256 ::LineTo(frame
.right
- 2, frame
.bottom
- 6);
1257 ::MoveTo(frame
.left
+ 5, frame
.bottom
- 2);
1258 ::LineTo(frame
.right
- 6, frame
.bottom
- 2);
1263 AGASetFontStyle( &info
->fontStyle
) ;
1264 frame
= (**theControl
).contrlRect
;
1267 ::InsetRect(&tempRect
, 1, 1);
1271 ::RGBBackColor(&gAGAColorArray
[4]);
1273 EraseRect(&tempRect
);
1279 ::RGBForeColor(&gAGAColorArray
[7]);
1283 ::MoveTo(frame
.left
+ 2, frame
.top
);
1284 ::LineTo(frame
.right
- 3, frame
.top
);
1285 ::LineTo(frame
.right
- 1, frame
.top
+ 2);
1286 ::LineTo(frame
.right
- 1, frame
.bottom
- 3);
1287 ::LineTo(frame
.right
- 3, frame
.bottom
- 1);
1288 ::LineTo(frame
.left
+ 2, frame
.bottom
- 1);
1289 ::LineTo(frame
.left
, frame
.bottom
- 3);
1290 ::LineTo(frame
.left
, frame
.top
+ 2);
1291 ::LineTo(frame
.left
+ 2, frame
.top
);
1292 if (disabled
&& !hasColor
)
1295 // Draw the four corners around
1298 short pattern
= (disabled
? 2 : (down
? 1 : 0));
1299 const RGBColor
*col
= gAGAColorArray
;
1300 for (int i
= 0; i
< 4; i
++)
1301 for (int j
= 0; j
< 4; j
++)
1303 if (LAGAPushButton_mCorners
[pattern
][0][i
][j
] != -1)
1304 ::SetCPixel(frame
.left
+ j
, frame
.top
+ i
, &col
[LAGAPushButton_mCorners
[pattern
][0][i
][j
]]);
1305 if (LAGAPushButton_mCorners
[pattern
][1][i
][j
] != -1)
1306 ::SetCPixel(frame
.right
- 4 + j
, frame
.top
+ i
, &col
[LAGAPushButton_mCorners
[pattern
][1][i
][j
]]);
1307 if (LAGAPushButton_mCorners
[pattern
][2][i
][j
] != -1)
1308 ::SetCPixel(frame
.left
+ j
, frame
.bottom
- 4 + i
, &col
[LAGAPushButton_mCorners
[pattern
][2][i
][j
]]);
1309 if (LAGAPushButton_mCorners
[pattern
][3][i
][j
] != -1)
1310 ::SetCPixel(frame
.right
- 4 + j
, frame
.bottom
- 4 + i
, &col
[LAGAPushButton_mCorners
[pattern
][3][i
][j
]]);
1314 ::RGBForeColor(&gAGAColorArray
[8]);
1316 ::RGBForeColor(&gAGAColorArray
[2]);
1317 ::MoveTo(frame
.left
+ 1, frame
.top
+ 4);
1318 ::LineTo(frame
.left
+ 1, frame
.bottom
- 5);
1319 ::MoveTo(frame
.left
+ 4, frame
.top
+ 1);
1320 ::LineTo(frame
.right
- 5, frame
.top
+ 1);
1325 ::RGBForeColor(&gAGAColorArray
[1]);
1327 ::ForeColor(whiteColor
);
1328 ::MoveTo(frame
.left
+ 2, frame
.bottom
- 5);
1329 ::LineTo(frame
.left
+ 2, frame
.top
+ 2);
1330 ::LineTo(frame
.right
- 5, frame
.top
+ 2);
1333 ::RGBForeColor(&gAGAColorArray
[5]);
1335 ::RGBForeColor(&gAGAColorArray
[8]);
1336 ::MoveTo(frame
.left
+ 4, frame
.bottom
- 2);
1337 ::LineTo(frame
.right
- 5, frame
.bottom
- 2);
1338 ::MoveTo(frame
.right
- 2, frame
.bottom
- 5);
1339 ::LineTo(frame
.right
- 2, frame
.top
+ 4);
1342 ::RGBForeColor(&gAGAColorArray
[4]);
1344 ::RGBForeColor(&gAGAColorArray
[5]);
1345 ::MoveTo(frame
.left
+ 4, frame
.bottom
- 3);
1346 ::LineTo(frame
.right
- 5, frame
.bottom
- 3);
1347 ::MoveTo(frame
.right
- 3, frame
.bottom
- 5);
1348 ::LineTo(frame
.right
- 3, frame
.top
+ 4);
1351 AGASetFontStyle( &info
->fontStyle
) ;
1352 int x
= ( (**theControl
).contrlRect
.left
+ (**theControl
).contrlRect
.right
) / 2 ;
1353 int y
= ( (**theControl
).contrlRect
.top
+ (**theControl
).contrlRect
.bottom
) / 2 ;
1355 ::GetFontInfo( &fi
) ;
1357 y
+= fi
.ascent
/ 2 ;
1358 int length
= (**theControl
).contrlTitle
[0] ;
1361 int width
= TextWidth( &(**theControl
).contrlTitle
[1] , 0, length
) ;
1364 ::DrawText( &(**theControl
).contrlTitle
[1] , 0, length
);
1373 pt
.h
= LoWord( param
) ;
1374 pt
.v
= HiWord( param
) ;
1375 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1376 return kControlButtonPart
;
1382 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1387 pt
.h
= LoWord( param
) ;
1388 pt
.v
= HiWord( param
) ;
1389 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1390 return kControlButtonPart
;
1402 const int kAGACheckBoxWidth
= 12 ;
1403 const int kAGACheckBoxHeigth
= 12 ;
1405 pascal SInt32
AGACheckBoxDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1407 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1412 if (!(**theControl
).contrlVis
)
1414 PenState oldPenState
;
1415 RGBColor oldForeColor
;
1416 RGBColor oldBackColor
;
1417 RGBColor backColor
;
1418 RGBColor foreColor
;
1422 if (!(**theControl
).contrlVis
)
1426 AGAPortHelper
help((**theControl
).contrlOwner
) ;
1427 Rect frame
= (**theControl
).contrlRect
;
1428 Boolean hasColor
= true;
1429 Boolean disabled
= (*theControl
)->contrlHilite
== 255 ;
1430 int mValue
= GetControlValue( theControl
) ;
1431 Boolean inPushed
= (**theControl
).contrlHilite
;
1433 int triState_Off
= 3 ;
1435 frame
.right
= frame
.left
+ kAGACheckBoxWidth
;
1436 frame
.bottom
= frame
.top
+ kAGACheckBoxHeigth
;
1438 // Draw the frame of the checkbox
1441 ::RGBForeColor(&gAGAColorArray
[7]);
1445 ::FrameRect(&frame
);
1450 ::InsetRect(&frame
, 1, 1);
1452 ::RGBBackColor(inPushed
? &gAGAColorArray
[8] : &gAGAColorArray
[2]);
1453 ::EraseRect(&frame
);
1458 ::RGBForeColor(&gAGAColorArray
[10]);
1460 ForeColor(whiteColor
);
1461 ::MoveTo(frame
.left
, frame
.bottom
- 2);
1462 ::LineTo(frame
.left
, frame
.top
);
1463 ::LineTo(frame
.right
- 2, frame
.top
);
1466 ::RGBForeColor(&gAGAColorArray
[6]);
1468 ::RGBForeColor(mEnabled
!= triState_Off
? &gAGAColorArray
[7] : &gAGAColorArray
[5]);
1469 ::MoveTo(frame
.left
+ 1, frame
.bottom
- 1);
1470 ::LineTo(frame
.right
- 1, frame
.bottom
- 1);
1471 ::LineTo(frame
.right
- 1, frame
.top
+ 1);
1481 ::RGBForeColor(inPushed
? &gAGAColorArray
[10] : &gAGAColorArray
[5]);
1482 ::MoveTo(frame
.left
+ 3, frame
.bottom
- 2);
1483 ::LineTo(frame
.right
- 2, frame
.top
+ 3);
1484 ::MoveTo(frame
.right
- 2, frame
.bottom
- 2);
1485 ::LineTo(frame
.right
- 2, frame
.bottom
- 2);
1487 if (mEnabled
!= triState_Off
)
1488 ::RGBForeColor(inPushed
? &gAGAColorArray
[11] : &gAGAColorArray
[8]);
1489 ::MoveTo(frame
.left
+ 3, frame
.bottom
- 3);
1490 ::LineTo(frame
.right
- 2, frame
.top
+ 2);
1491 ::MoveTo(frame
.right
- 2, frame
.bottom
- 3);
1492 ::LineTo(frame
.right
- 2, frame
.bottom
- 3);
1494 if (mEnabled
!= triState_Off
)
1495 ::ForeColor(blackColor
);
1497 ::RGBForeColor(&gAGAColorArray
[7]);
1499 ::MoveTo(frame
.left
+ 2, frame
.top
+ 1);
1500 ::LineTo(frame
.right
- 3, frame
.bottom
- 4);
1501 ::MoveTo(frame
.left
+ 2, frame
.top
+ 2);
1502 ::LineTo(frame
.right
- 3, frame
.bottom
- 3);
1503 ::MoveTo(frame
.left
+ 2, frame
.bottom
- 4);
1504 ::LineTo(frame
.right
- 3, frame
.top
+ 1);
1505 ::MoveTo(frame
.left
+ 2, frame
.bottom
- 3);
1506 ::LineTo(frame
.right
- 3, frame
.top
+ 2);
1513 ::RGBForeColor(inPushed
? &gAGAColorArray
[10] : &gAGAColorArray
[5]);
1514 ::MoveTo(frame
.left
+ 3, frame
.top
+ 6);
1515 ::LineTo(frame
.right
- 2, frame
.top
+ 6);
1516 ::LineTo(frame
.right
- 2, frame
.top
+ 4);
1518 if (mEnabled
!= triState_Off
)
1519 ::ForeColor(blackColor
);
1521 ::RGBForeColor(&gAGAColorArray
[7]);
1523 ::MoveTo(frame
.left
+ 2, frame
.top
+ 4);
1524 ::LineTo(frame
.right
- 3, frame
.top
+ 4);
1525 ::MoveTo(frame
.left
+ 2, frame
.top
+ 5);
1526 ::LineTo(frame
.right
- 3, frame
.top
+ 5);
1530 if (inPushed
&& !hasColor
)
1533 AGASetFontStyle( &info
->fontStyle
) ;
1534 int x
= (**theControl
).contrlRect
.left
+ kAGACheckBoxWidth
+ 5 ;
1535 int y
= ( (**theControl
).contrlRect
.top
+ (**theControl
).contrlRect
.bottom
) / 2 ;
1537 ::GetFontInfo( &fi
) ;
1539 y
+= fi
.ascent
/ 2 ;
1541 int length
= (**theControl
).contrlTitle
[0] ;
1544 ::DrawText( &(**theControl
).contrlTitle
[1] , 0, length
);
1554 pt
.h
= LoWord( param
) ;
1555 pt
.v
= HiWord( param
) ;
1556 if ( PtInRect( pt
, &(**theControl
).contrlRect
) && ((*theControl
)->contrlVis
!= 0) && ((*theControl
)->contrlHilite
!= 255) )
1557 return kControlCheckBoxPart
;
1565 pt
.h
= LoWord( param
) ;
1566 pt
.v
= HiWord( param
) ;
1567 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1569 if ( (**theControl
).contrlValue
)
1570 (**theControl
).contrlValue
= 0 ;
1572 (**theControl
).contrlValue
= 1 ;
1582 if ( !EmptyRect(&(**theControl
).contrlRect
) )
1583 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1585 case kControlMsgCalcBestRect
:
1587 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1588 rec
->width
= (**theControl
).contrlRect
.right
- (**theControl
).contrlRect
.left
;
1589 rec
->height
= kAGACheckBoxHeigth
;
1600 pascal SInt32
AGARadioButtonDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1603 /* ExtCDEFInfo* info = (ExtCDEFInfo* ) (**theControl).contrlRfCon ;
1608 if (!(**theControl).contrlVis)
1610 PenState oldPenState;
1611 RGBColor oldForeColor ;
1612 RGBColor oldBackColor ;
1613 RGBColor backColor ;
1614 RGBColor foreColor ;
1618 if (!(**theControl).contrlVis)
1622 AGAPortHelper help() ;
1623 Rect frame = (**theControl).contrlRect ;
1624 Boolean hasColor = true;
1625 Boolean disabled = (*theControl)->contrlHilite == 255 ;
1626 int mValue = GetControlValue( theControl ) ;
1627 Boolean inPushed = (**theControl).contrlHilite ;
1629 int triState_Off = 3 ;
1631 frame.right = frame.left + kAGACheckBoxWidth;
1632 frame.bottom = frame.top + kAGACheckBoxHeigth;
1634 // Draw the frame of the checkbox
1637 ::RGBForeColor(&gAGAColorArray[7]);
1641 ::FrameRect(&frame);
1646 ::InsetRect(&frame, 1, 1);
1648 ::RGBBackColor(inPushed ? &gAGAColorArray[8] : &gAGAColorArray[2]);
1649 ::EraseRect(&frame);
1654 ::RGBForeColor(&gAGAColorArray[10]);
1656 ForeColor(whiteColor);
1657 ::MoveTo(frame.left, frame.bottom - 2);
1658 ::LineTo(frame.left, frame.top);
1659 ::LineTo(frame.right - 2, frame.top);
1662 ::RGBForeColor(&gAGAColorArray[6]);
1664 ::RGBForeColor(mEnabled != triState_Off ? &gAGAColorArray[7] : &gAGAColorArray[5]);
1665 ::MoveTo(frame.left + 1, frame.bottom - 1);
1666 ::LineTo(frame.right - 1, frame.bottom - 1);
1667 ::LineTo(frame.right - 1, frame.top + 1);
1677 ::RGBForeColor(inPushed ? &gAGAColorArray[10] : &gAGAColorArray[5]);
1678 ::MoveTo(frame.left + 3, frame.bottom - 2);
1679 ::LineTo(frame.right - 2, frame.top + 3);
1680 ::MoveTo(frame.right - 2, frame.bottom - 2);
1681 ::LineTo(frame.right - 2, frame.bottom - 2);
1683 if (mEnabled != triState_Off)
1684 ::RGBForeColor(inPushed ? &gAGAColorArray[11] : &gAGAColorArray[8]);
1685 ::MoveTo(frame.left + 3, frame.bottom - 3);
1686 ::LineTo(frame.right - 2, frame.top + 2);
1687 ::MoveTo(frame.right - 2, frame.bottom - 3);
1688 ::LineTo(frame.right - 2, frame.bottom - 3);
1690 if (mEnabled != triState_Off)
1691 ::ForeColor(blackColor);
1693 ::RGBForeColor(&gAGAColorArray[7]);
1695 ::MoveTo(frame.left + 2, frame.top + 1);
1696 ::LineTo(frame.right - 3, frame.bottom - 4);
1697 ::MoveTo(frame.left + 2, frame.top + 2);
1698 ::LineTo(frame.right - 3, frame.bottom - 3);
1699 ::MoveTo(frame.left + 2, frame.bottom - 4);
1700 ::LineTo(frame.right - 3, frame.top + 1);
1701 ::MoveTo(frame.left + 2, frame.bottom - 3);
1702 ::LineTo(frame.right - 3, frame.top + 2);
1709 ::RGBForeColor(inPushed ? &gAGAColorArray[10] : &gAGAColorArray[5]);
1710 ::MoveTo(frame.left + 3, frame.top + 6);
1711 ::LineTo(frame.right - 2, frame.top + 6);
1712 ::LineTo(frame.right - 2, frame.top + 4);
1714 if (mEnabled != triState_Off)
1715 ::ForeColor(blackColor);
1717 ::RGBForeColor(&gAGAColorArray[7]);
1719 ::MoveTo(frame.left + 2, frame.top + 4);
1720 ::LineTo(frame.right - 3, frame.top + 4);
1721 ::MoveTo(frame.left + 2, frame.top + 5);
1722 ::LineTo(frame.right - 3, frame.top + 5);
1726 if (inPushed && !hasColor)
1729 AGASetFontStyle( &info->fontStyle ) ;
1730 int x = (**theControl).contrlRect.left + kAGACheckBoxWidth + 5 ;
1731 int y = ( (**theControl).contrlRect.top + (**theControl).contrlRect.bottom ) / 2 ;
1733 ::GetFontInfo( &fi ) ;
1735 y += fi.ascent / 2 ;
1737 int length = (**theControl).contrlTitle[0] ;
1740 ::DrawText( &(**theControl).contrlTitle[1] , 0, length);
1750 pt.h = LoWord( param ) ;
1751 pt.v = HiWord( param ) ;
1752 if ( PtInRect( pt , &(**theControl).contrlRect ) && ((*theControl)->contrlVis != 0) && ((*theControl)->contrlHilite != 255) )
1753 return kControlCheckBoxPart ;
1761 pt.h = LoWord( param ) ;
1762 pt.v = HiWord( param ) ;
1763 if ( PtInRect( pt , &(**theControl).contrlRect ) )
1765 if ( (**theControl).contrlValue )
1766 (**theControl).contrlValue = 0 ;
1768 (**theControl).contrlValue = 1 ;
1778 if ( !EmptyRect(&(**theControl).contrlRect ) )
1779 RectRgn((RgnHandle) param , &(**theControl).contrlRect ) ;
1781 case kControlMsgCalcBestRect :
1783 ControlCalcSizeRec *rec = (ControlCalcSizeRec *) param ;
1784 rec->width = (**theControl).contrlRect.right - (**theControl).contrlRect.left ;
1785 rec->height = kAGACheckBoxHeigth ;
1796 pascal SInt32
AGAStaticGroupBoxTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1798 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1808 if (!(**theControl
).contrlVis
)
1812 bool disabled
= false ;
1813 bool hasColor
= true ;
1814 AGAPortHelper
help((**theControl
).contrlOwner
) ;
1815 AGASetFontStyle( &info
->fontStyle
) ;
1817 ::GetFontInfo( &fi
) ;
1819 Rect labelRect
= (**theControl
).contrlRect
;
1820 Rect theFrame
= (**theControl
).contrlRect
;
1821 int width
= StringWidth((**theControl
).contrlTitle
) ;
1822 theFrame
.top
+= fi
.ascent
+ fi
.leading
>> 1 ;
1823 labelRect
.bottom
= theFrame
.top
+ 8 ;
1824 labelRect
.left
+= 10 ;
1825 labelRect
.right
=labelRect
.left
+ width
+ 6 ;
1832 RGBForeColor( &gAGAColorArray
[4] ) ;
1836 RGBForeColor( &gAGAColorArray
[7] ) ;
1838 FrameRect( &theFrame
) ;
1841 ::RGBForeColor(&gAGAColorArray
[1]);
1843 ::ForeColor(whiteColor
);
1844 ::MoveTo(theFrame
.left
+ 1, theFrame
.bottom
- 2);
1845 ::LineTo(theFrame
.left
+ 1, theFrame
.top
+ 1);
1846 ::LineTo(theFrame
.right
- 2, theFrame
.top
+ 1);
1847 ::MoveTo(theFrame
.left
, theFrame
.bottom
);
1848 ::LineTo(theFrame
.right
, theFrame
.bottom
);
1849 ::LineTo(theFrame
.right
, theFrame
.top
);
1851 AGASetFontStyle( &info
->fontStyle
) ;
1852 ::EraseRect( &labelRect
) ;
1853 ::MoveTo(labelRect
.left
+ 3, labelRect
.top
+ fi
.ascent
+ (fi
.leading
>> 1));
1854 ::DrawString((**theControl
).contrlTitle
);
1858 case kControlMsgCalcBestRect
:
1860 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1861 rec
->width
= (**theControl
).contrlRect
.right
- (**theControl
).contrlRect
.left
;
1862 rec
->height
= (**theControl
).contrlRect
.bottom
- (**theControl
).contrlRect
.top
;
1866 case kControlMsgSetData
:
1869 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1878 pascal SInt32
AGAStaticTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1880 Handle macText
= (**theControl
).contrlData
;
1881 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1887 macText
= NewHandle(0) ;
1888 (**theControl
).contrlData
= (Handle
) macText
;
1892 DisposeHandle( macText
) ;
1896 if (!(**theControl
).contrlVis
)
1900 AGAPortHelper
help((**theControl
).contrlOwner
) ;
1901 AGASetFontStyle( &info
->fontStyle
) ;
1902 int x
= (**theControl
).contrlRect
.left
;
1903 int y
= (**theControl
).contrlRect
.top
;
1906 ::GetFontInfo( &fi
) ;
1909 lineheight
= fi
.ascent
+ fi
.descent
+ fi
.leading
;
1910 int length
= GetHandleSize( macText
) ;
1916 RGBColor gray
= { 0xDDDD , 0xDDDD, 0xDDDD } ;
1917 ::RGBBackColor( &gray
) ;
1920 if ( (*macText
)[i
] == 0x0d )
1923 ::DrawText( *macText
, laststop
, i
-laststop
);
1930 ::DrawText( *macText
, laststop
, i
-laststop
);
1932 HUnlock( macText
) ;
1937 case kControlMsgCalcBestRect
:
1939 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1940 rec
->width
= (**theControl
).contrlRect
.right
- (**theControl
).contrlRect
.left
;
1941 rec
->height
= (**theControl
).contrlRect
.bottom
- (**theControl
).contrlRect
.top
;
1945 case kControlMsgSetData
:
1947 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
1948 if ( rec
->tag
== kControlStaticTextTextTag
)
1950 SetHandleSize( macText
, rec
->size
) ;
1951 memcpy( *macText
, rec
->dataPtr
, rec
->size
) ;
1954 return errDataNotSupported
;
1963 void AGAMoveControl(ControlHandle inControl
, short x
, short y
)
1965 if ( AGATestForNewControl( inControl
) )
1967 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
1968 if ( info
->magic
== kExtCDEFMagic
)
1970 if ( info
->procID
== kControlEditTextProc
)
1975 dx
= x
- (**inControl
).contrlRect
.left
;
1976 dy
= y
- (**inControl
).contrlRect
.top
;
1978 MoveControl( inControl
, x
,y
) ;
1981 macTE
= (TEHandle
) (**inControl
).contrlData
;
1982 (**macTE
).destRect
.left
+= dx
;
1983 (**macTE
).destRect
.top
+= dy
;
1984 (**macTE
).destRect
.right
+= dx
;
1985 (**macTE
).destRect
.bottom
+= dy
;
1986 (**macTE
).viewRect
.left
+= dx
;
1987 (**macTE
).viewRect
.top
+= dy
;
1988 (**macTE
).viewRect
.right
+= dx
;
1989 (**macTE
).viewRect
.bottom
+= dy
;
1992 if ( info
->procID
== kControlListBoxProc
)
1997 dx
= x
- (**inControl
).contrlRect
.left
;
1998 dy
= y
- (**inControl
).contrlRect
.top
;
2000 MoveControl( inControl
, x
,y
) ;
2001 ListHandle macList
;
2003 macList
= (ListHandle
) (**inControl
).contrlData
;
2004 (**macList
).rView
.left
+= dx
;
2005 (**macList
).rView
.top
+= dy
;
2006 (**macList
).rView
.right
+= dx
;
2007 (**macList
).rView
.bottom
+= dy
;
2012 MoveControl( inControl
, x
,y
) ;
2015 void AGASizeControl(ControlHandle inControl
, short x
, short y
)
2017 if ( AGATestForNewControl( inControl
) )
2019 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
2020 if ( info
->magic
== kExtCDEFMagic
)
2022 if ( info
->procID
== kControlEditTextProc
)
2027 dx
= x
- ( (**inControl
).contrlRect
.right
- (**inControl
).contrlRect
.left
) ;
2028 dy
= y
- ( (**inControl
).contrlRect
.bottom
- (**inControl
).contrlRect
.top
) ;
2030 SizeControl( inControl
, x
,y
) ;
2033 macTE
= (TEHandle
) (**inControl
).contrlData
;
2034 (**macTE
).destRect
.right
+= dx
;
2035 (**macTE
).destRect
.bottom
+= dy
;
2036 (**macTE
).viewRect
.right
+= dx
;
2037 (**macTE
).viewRect
.bottom
+= dy
;
2040 if ( info
->procID
== kControlListBoxProc
)
2045 dx
= x
- ( (**inControl
).contrlRect
.right
- (**inControl
).contrlRect
.left
) ;
2046 dy
= y
- ( (**inControl
).contrlRect
.bottom
- (**inControl
).contrlRect
.top
) ;
2048 SizeControl( inControl
, x
,y
) ;
2049 ListHandle macList
;
2051 macList
= (ListHandle
) (**inControl
).contrlData
;
2052 (**macList
).rView
.right
+= dx
;
2053 (**macList
).rView
.bottom
+= dy
;
2058 SizeControl( inControl
, x
,y
) ;
2061 pascal SInt32
AGARootControlDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
2063 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
2073 case kControlMsgCalcBestRect
:
2075 case kControlMsgSetData
:
2083 pascal SInt32
AGAEditTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
2085 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
2089 macTE
= (TEHandle
) (**theControl
).contrlData
;
2095 AGAPortHelper
help((**theControl
).contrlOwner
) ;
2096 SetPort( (**theControl
).contrlOwner
) ;
2097 ::TextFont( kFontIDGeneva
) ;
2100 RGBBackColor( &gAGARamp
[ kAGAWhite
] ) ;
2101 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
2102 Rect bounds
= (**theControl
).contrlRect
;
2103 InsetRect( &bounds
, 4 , 1 ) ;
2105 ::GetFontInfo( &fi
) ;
2107 bounds
.top
= bounds
.bottom
- abs( fi
.descent
) - fi
.ascent
- 3;
2108 macTE
= TENew( &bounds
, &bounds
) ;
2109 (**theControl
).contrlData
= (Handle
) macTE
;
2113 TEDispose( macTE
) ;
2117 AGAPortHelper
help((**theControl
).contrlOwner
) ;
2118 AGASetFontStyle( &info
->fontStyle
) ;
2119 SetPort( (**theControl
).contrlOwner
) ;
2120 RGBBackColor( &gAGARamp
[ kAGAWhite
] ) ;
2121 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
2122 EraseRect( &(**theControl
).contrlRect
) ;
2123 FrameRect( &(**theControl
).contrlRect
) ;
2124 TEUpdate( &(**theControl
).contrlRect
, macTE
) ;
2130 pt
.h
= LoWord( param
) ;
2131 pt
.v
= HiWord( param
) ;
2132 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
2133 return kControlButtonPart
;
2141 pt
.h
= LoWord( param
) ;
2142 pt
.v
= HiWord( param
) ;
2143 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
2145 TEClick( pt
, false , macTE
) ;
2149 case kControlMsgGetData
:
2151 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
2152 if ( rec
->tag
== kControlEditTextTEHandleTag
)
2154 return AGAGetDataHelper( rec
, sizeof( TEHandle
) , (char*) &macTE
) ;
2156 else if ( rec
->tag
== kControlEditTextTextTag
)
2158 return AGAGetDataHelper( rec
, (**macTE
).teLength
, (char*) *(**macTE
).hText
) ;
2160 else if ( rec
->tag
== kControlEditTextSelectionTag
)
2163 return errDataNotSupported
;
2166 case kControlMsgSetData
:
2168 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
2169 if ( rec
->tag
== kControlEditTextTextTag
)
2171 TESetText( rec
->dataPtr
, rec
->size
, macTE
) ;
2174 return errDataNotSupported
;
2176 case kControlMsgCalcBestRect
:
2178 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
2179 rec
->width
= (**theControl
).contrlRect
.right
- (**theControl
).contrlRect
.left
;
2180 rec
->height
= (**theControl
).contrlRect
.bottom
- (**theControl
).contrlRect
.top
;
2183 case kControlMsgFocus
:
2185 if ( param
== kControlFocusNoPart
)
2187 info
->hasFocus
= false ;
2188 TEDeactivate( macTE
) ;
2189 return kControlFocusNoPart
;
2191 else if ( param
== kControlFocusNextPart
|| param
== kControlFocusPrevPart
)
2193 if ( info
->hasFocus
)
2195 info
->hasFocus
= false ;
2196 TEDeactivate( macTE
) ;
2197 return kControlFocusNoPart
;
2201 info
->hasFocus
= true ;
2202 TEActivate( macTE
) ;
2203 return kControlEditTextPart
;
2206 else if ( param
== kControlEditTextPart
)
2208 if ( !info
->hasFocus
)
2210 info
->hasFocus
= true ;
2211 TEActivate( macTE
) ;
2212 return kControlEditTextPart
;
2217 case kControlMsgIdle
:
2222 case kControlMsgKeyDown
:
2224 AGAPortHelper
help( (**theControl
).contrlOwner
) ;
2225 AGASetFontStyle( &info
->fontStyle
) ;
2226 RGBBackColor( &gAGARamp
[ kAGAWhite
] ) ;
2227 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
2228 ControlKeyDownRec
* rec
= (ControlKeyDownRec
*) param
;
2229 TEKey( rec
->charCode
, macTE
) ;
2232 case kControlMsgActivate
:
2236 TEActivate( macTE ) ;
2238 TEDeactivate( macTE ) ;
2243 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
2245 case kControlMsgTestNewMsgSupport
:
2246 return kControlSupportsNewMessages
;
2247 case kControlMsgGetFeatures
:
2249 // kControlSupportsGhosting |
2250 // kControlSupportsEmbedding |
2251 kControlSupportsFocus
|
2253 kControlWantsActivate
|
2254 // kControlHandlesTracking |
2255 kControlSupportsDataAccess
|
2256 // kControlHasSpecialBackground |
2257 // kControlGetsFocusOnClick |
2258 kControlSupportsCalcBestRect
|
2259 // kControlSupportsLiveFeedback |
2260 // kControlHasRadioBehavior |
2269 pascal SInt32
AGAListControlDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
2272 ListHandle macList
;
2273 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
2275 macList
= (ListHandle
) (**theControl
).contrlData
;
2277 static inLoop
= false ;
2278 static lastClick
= NULL
;
2284 Rect databounds
= { 0,0,0,0} ;
2285 Point cellsize
= { 0,0} ;
2286 Rect listBounds
= (**theControl
).contrlRect
;
2288 InsetRect( &listBounds
, 1 , 1 ) ;
2290 macList
= LNew( &listBounds
, &databounds
, cellsize
, 128 ,
2291 (**theControl
).contrlOwner
, false /*drawit*/ , false /*hasGrow*/,
2292 false /* horzScroll */, true /*vertScroll*/ ) ;
2293 (**theControl
).contrlData
= (Handle
) macList
;
2294 info
->privateData
= NULL
;
2298 (**macList
).vScroll
= NULL
; // will be disposed by the window itself
2299 (**macList
).hScroll
= NULL
; // will be disposed by the window itself
2300 LDispose( macList
) ;
2303 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
2308 pt
.h
= LoWord( param
) ;
2309 pt
.v
= HiWord( param
) ;
2311 Rect allRect
= (**theControl
).contrlRect
;
2312 listRect
= allRect
;
2314 allRect
.right
+= 16 ;
2315 if ( PtInRect( pt
, &allRect
) )
2317 if ( !inLoop
&& StillDown() )
2320 LActivate( true , macList
) ;
2321 Boolean doubleClick
= LClick( pt
, 0 /* todo modifiers*/ , macList
) ;
2322 info
->privateData
= doubleClick
;
2325 return kControlListBoxPart
;
2333 AGAPortHelper
help((**theControl
).contrlOwner
) ;
2334 AGASetFontStyle( &info
->fontStyle
) ;
2335 RGBBackColor( &gAGARamp
[ kAGAWhite
] ) ;
2336 EraseRect( &(**theControl
).contrlRect
) ;
2337 FrameRect( &(**theControl
).contrlRect
) ;
2338 RgnHandle controlRgn
= NewRgn() ;
2339 SetRectRgn( controlRgn
, (**theControl
).contrlRect
.left
,
2340 (**theControl
).contrlRect
.top
,
2341 (**theControl
).contrlRect
.right
,
2342 (**theControl
).contrlRect
.bottom
) ;
2343 LUpdate( controlRgn
, macList
) ;
2349 pt
.h
= LoWord( param
) ;
2350 pt
.v
= HiWord( param
) ;
2352 Rect allRect
= (**theControl
).contrlRect
;
2353 listRect
= allRect
;
2354 allRect
.right
+= 16 ;
2355 if ( PtInRect( pt
, &listRect
) )
2357 if ( !inLoop
&& StillDown() )
2360 LActivate( true , macList
) ;
2361 Boolean doubleClick
= LClick( pt
, 0 /* todo modifiers*/ , macList
) ;
2362 info
->privateData
= doubleClick
;
2365 return kControlListBoxPart
;
2367 else if ( PtInRect( pt
, &allRect
) )
2369 if ( !inLoop
&& StillDown() )
2372 // LActivate( true , macList ) ;
2373 Boolean doubleClick
= LClick( pt
, 0 /* todo modifiers*/ , macList
) ;
2374 info
->privateData
= doubleClick
;
2377 return kControlPageDownPart
;
2383 case kControlMsgGetData
:
2385 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
2386 if ( rec
->tag
== kControlListBoxListHandleTag
)
2388 return AGAGetDataHelper( rec
, sizeof( ListHandle
) , (char*) &macList
) ;
2390 else if ( rec
->tag
== kControlListBoxDoubleClickTag
)
2392 Boolean doubleClick
= info
->privateData
;
2393 return AGAGetDataHelper( rec
, sizeof( Boolean
) , (char*) &doubleClick
) ;
2395 return errDataNotSupported
;
2405 OSErr
AGACreateRootControl (WindowPtr inWindow
,
2406 ControlHandle
* outControl
)
2408 ControlHandle theControl
= NULL
;
2410 SInt16 extCDEFID
= kExtCDEFID
<< 4 + 0 ;
2412 theControl
= NewControl( inWindow
, &inWindow
->portRect
, "\p" , true ,
2413 0 , 0 , 1 , extCDEFID
, 0 ) ;
2414 NewExtCDEFInfo( theControl
, AGARootControlDefProc
, kAGARootControlProcID
, 0 ) ;
2416 *outControl
= theControl
;
2420 OSErr
AGAEmbedControl (ControlHandle inControl
,
2421 ControlHandle inContainer
)
2423 if ( AGATestForNewControl( inControl
) )
2425 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
2426 info
->containerControl
= inContainer
;
2431 void AGADrawControl( ControlHandle control
)
2433 DrawOneControl( control
) ;
2434 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)(**control
).contrlOwner
)->controlList
;
2437 if ( AGATestForNewControl( iter
) )
2439 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**iter
).contrlRfCon
;
2440 if ( info
->containerControl
== control
)
2442 AGADrawControl( iter
) ;
2446 iter
= (**iter
).nextControl
;
2451 ControlHandle
AGANewControl(WindowPtr owningWindow
,
2452 const Rect
* bounds
,
2453 ConstStr255Param controlTitle
,
2454 Boolean initiallyVisible
,
2455 SInt16 initialValue
,
2456 SInt16 minimumValue
,
2457 SInt16 maximumValue
,
2459 SInt32 controlReference
)
2461 ControlHandle theControl
= NULL
;
2462 Rect boundsRect
= *bounds
;
2463 SInt16 extCDEFID
= kExtCDEFID
<< 4 + 0 ;
2464 SInt16 oldProcID
= extCDEFID
;
2467 case kControlScrollBarProc
:
2468 case kControlScrollBarLiveProc
:
2469 oldProcID
= scrollBarProc
;
2471 case kControlListBoxProc
:
2476 if ( oldProcID
== extCDEFID
&& procID
== kControlListBoxProc
)
2478 boundsRect
.right
-= 16 ;
2480 theControl
= NewControl( owningWindow
, &boundsRect
, controlTitle
, initiallyVisible
,
2481 initialValue
, minimumValue
, maximumValue
, oldProcID
, controlReference
) ;
2482 if ( oldProcID
== extCDEFID
)
2484 ControlDefProcPtr theProcPtr
= NULL
;
2485 SInt16 theVarCode
= 0 ;
2488 case kControlPushButtonProc
:
2489 theProcPtr
= AGAButtonDefProc
;
2491 case kControlCheckBoxProc
:
2492 theProcPtr
= AGACheckBoxDefProc
;
2494 case kControlRadioButtonProc
:
2495 theProcPtr
= AGARadioButtonDefProc
;
2497 case kControlProgressBarProc
:
2498 theProcPtr
= AGAProgressBarDefProc
;
2500 case kControlPlacardProc
:
2501 theProcPtr
= AGAPlacardDefProc
;
2503 case kControlStaticTextProc
:
2504 theProcPtr
= AGAStaticTextDefProc
;
2506 case kControlListBoxProc
:
2507 theProcPtr
= AGAListControlDefProc
;
2509 case kControlEditTextProc
:
2510 theProcPtr
= AGAEditTextDefProc
;
2512 case kControlGroupBoxTextTitleProc
:
2513 theProcPtr
= AGAStaticGroupBoxTextDefProc
;
2515 case kControlBevelButtonNormalBevelProc
:
2516 theProcPtr
= AGABevelButtonDefProc
;
2522 NewExtCDEFInfo( theControl
, theProcPtr
, procID
, controlReference
) ;
2528 void AGASetThemeWindowBackground (WindowRef inWindow
,
2534 SetPort( inWindow
) ;
2535 if ( inBrush
== kThemeBrushDialogBackgroundActive
)
2537 gAGABackgroundColor
= 2 ;
2541 gAGABackgroundColor
= 0 ;
2543 RGBBackColor( &gAGAColorArray
[gAGABackgroundColor
] ) ;
2547 void AGAApplyThemeBackground(ThemeBackgroundKind inKind
,
2548 const Rect
* bounds
,
2549 ThemeDrawState inState
,
2556 AGAPortHelper::AGAPortHelper( GrafPtr newport
)
2559 SetPort( newport
) ;
2560 // wxASSERT( newport->portRect.left == 0 && newport->portRect.top == 0 ) ;
2561 GetPenState( &oldPenState
) ;
2562 GetBackColor( &oldBackColor
) ;
2563 GetForeColor( &oldForeColor
) ;
2567 font
= GetPortTextFont( newport
);
2568 size
= GetPortTextSize( newport
);
2569 style
= GetPortTextFace( newport
);
2570 mode
= GetPortTextMode( newport
);
2574 AGAPortHelper::AGAPortHelper()
2578 void AGAPortHelper::Setup( GrafPtr newport
)
2581 SetPort( newport
) ;
2582 // wxASSERT( newport->portRect.left == 0 && newport->portRect.top == 0 ) ;
2583 GetPenState( &oldPenState
) ;
2584 GetBackColor( &oldBackColor
) ;
2585 GetForeColor( &oldForeColor
) ;
2589 font
= GetPortTextFont( newport
);
2590 size
= GetPortTextSize( newport
);
2591 style
= GetPortTextFace( newport
);
2592 mode
= GetPortTextMode( newport
);
2595 void AGAPortHelper::Clear()
2599 DisposeRgn( clip
) ;
2603 AGAPortHelper::~AGAPortHelper()
2609 DisposeRgn( clip
) ;
2610 RGBForeColor(&oldForeColor
);
2611 RGBBackColor(&oldBackColor
);
2612 SetPenState(&oldPenState
);
2618 SetOrigin( 0 , 0 ) ;