2 #include "wx/mac/uma.h"
3 #include "wx/mac/aga.h"
10 pascal SInt32
AGAProgressBarDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
);
11 pascal SInt32
AGAPlacardDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
);
12 pascal SInt32
AGAStaticTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) ;
13 pascal SInt32
AGAListControlDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) ;
14 pascal SInt32
AGAEditTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) ;
15 pascal SInt32
AGAStaticGroupBoxTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) ;
20 SInt16 kAGARootControlProcID
;
21 int gAGABackgroundColor
= 0 ;
23 const RGBColor gAGAColorArray
[] = {
24 {0xFFFF, 0xFFFF, 0xFFFF}, // W
25 {0xEEEE, 0xEEEE, 0xEEEE}, // 1
26 {0xDDDD, 0xDDDD, 0xDDDD}, // 2
27 {0xCCCC, 0xCCCC, 0xCCCC}, // 3
28 {0xBBBB, 0xBBBB, 0xBBBB}, // 4
29 {0xAAAA, 0xAAAA, 0xAAAA}, // 5
30 {0x9999, 0x9999, 0x9999}, // 6
31 {0x8888, 0x8888, 0x8888}, // 7
32 {0x7777, 0x7777, 0x7777}, // 8
33 {0x6666, 0x6666, 0x6666}, // 9
34 {0x5555, 0x5555, 0x5555}, // 10
35 {0x4444, 0x4444, 0x4444}, // 11
36 {0x2222, 0x2222, 0x2222}, // 12
37 {0x0000, 0x0000, 0x0000} // B
40 char LAGADefaultOutline_mCorners
[4][5][5] = {
43 { -1, -1, -1, 12, B
},
51 { B
, 12, -1, -1, -1 },
75 char LAGAPushButton_mCorners
[3][4][4][4] = {
171 RGBColor gAGARamp
[] =
176 { 65535 , 65535 , 65535 } ,
178 { 61166 , 61166 , 61166 } ,
180 { 56797 , 56797 , 56797 } ,
182 { 52428 , 52428 , 52428 } ,
184 { 48059 , 48059 , 48059 } ,
186 { 43690 , 43690 , 43690 } ,
188 { 39321 , 39321 , 39321 } ,
190 { 34952 , 34952 , 34952 } ,
192 { 30583 , 30583 , 30583 } ,
194 { 26214 , 26214 , 26214 } ,
196 { 21845 , 21845 , 21845 } ,
198 { 17476 , 17476 , 17476 } ,
200 { 13107 , 13107 , 13107 } ,
202 { 8738 , 8738 , 8738 } ,
204 { 4369 , 4369 , 4369 } ,
208 RGBColor gAGABlueRamp
[] =
213 { 65535 , 65535 , 65535 } ,
215 { 61166 , 61166 , 65535 } ,
217 { 56797 , 56797 , 65535 } ,
219 { 52428 , 52428 , 65535 } ,
221 { 48059 , 48059 , 65535 } ,
223 { 43690 , 43690 , 65535 } ,
225 { 39321 , 39321 , 65535 } ,
227 { 34952 , 34952 , 65535 } ,
229 { 30583 , 30583 , 65535 } ,
231 { 26214 , 26214 , 65535 } ,
233 { 21845 , 21845 , 65535 } ,
235 { 17476 , 17476 , 65535 } ,
237 { 13107 , 13107 , 65535 } ,
239 { 8738 , 8738 , 65535 } ,
241 { 4369 , 4369 , 65535 } ,
246 kAGATransparent
= -1 ,
267 kAGAStateEnabled
= 0 ,
268 kAGAStatePressed
= 1 ,
269 kAGAStateDisabled
= 2 ,
270 kAGAStateInactive
= 3
274 typedef struct sControlData
276 ControlPartCode m_part ;
281 OSErr AGAFindControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , long *outOffset) ;
282 OSErr AGAFindControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , long *outOffset)
284 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
286 long size = GetHandleSize( info->data ) ;
287 char* data = *(info->data) ;
288 sControlData* current ;
289 while( offset + sizeof( sControlData ) <= size )
291 current = (sControlData*) (data+offset ) ;
292 if ( ( inPart == kControlEntireControl || inPart == current->m_part ) && inTagName == current->m_tag )
294 *outOffset = offset ;
298 return errDataNotSupported ; // nothing found
301 OSErr AGARemoveControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName ) ;
302 OSErr AGARemoveControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName )
304 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
306 long size = GetHandleSize( info->data ) ;
307 char* data = *(info->data) ;
308 sControlData* current ;
309 while( offset + sizeof( sControlData ) <= size )
311 current = (sControlData*) (data+offset ) ;
312 if ( ( inPart == kControlEntireControl || inPart == current->m_part ) && inTagName == current->m_tag )
314 long chunkSize = current->m_size + sizeof ( sControlData ) ;
315 memcpy( data + offset , data + offset + chunkSize , size - offset - chunkSize ) ;
316 SetHandleSize( info->data , size - chunkSize ) ;
323 OSErr AGAAddControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , Size inSize, Ptr inData) ;
324 OSErr AGAAddControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , Size inSize, Ptr inData)
326 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
328 long size = GetHandleSize( info->data ) ;
329 SetHandleSize( info->data , size + sizeof( sControlData ) + inSize ) ;
330 if ( MemError() == noErr )
332 char* data = *(info->data) ;
333 sControlData* current = (sControlData*)( data + size ) ;
334 current->m_tag = inTagName ;
335 current->m_part = inPart ;
336 current->m_size = inSize ;
337 memcpy( data + size + sizeof( sControlData ) , inData , inSize ) ;
340 return errDataNotSupported ;
344 OSErr AGAGetControlDataSize (ControlHandle inControl,
345 ControlPartCode inPart,
350 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
351 char* data = *(info->data) ;
353 OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ;
356 sControlData* current = (sControlData*) (data+offset ) ;
357 *outMaxSize = current->m_size ;
362 OSErr AGAGetControlData (ControlHandle inControl,
363 ControlPartCode inPart,
367 Size * outActualSize)
370 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
371 char* data = *(info->data) ;
373 OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ;
376 sControlData* current = (sControlData*) (data+offset ) ;
377 *outActualSize = current->m_size ;
380 if ( inBufferSize <= current->m_size )
381 memcpy( outBuffer , data + offset + sizeof( sControlData ) , current->m_size ) ;
383 err = errDataNotSupported ;
389 OSErr AGASetControlData (ControlHandle inControl,
390 ControlPartCode inPart,
396 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
397 char* data = *(info->data) ;
399 OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ;
402 sControlData* current = (sControlData*) (data+offset ) ;
403 if ( current->m_size == inSize )
405 memcpy( data + offset + sizeof( sControlData ) , inData , inSize) ;
409 AGARemoveControlData( inControl , inPart , inTagName ) ;
410 AGAAddControlData( inControl , inPart , inTagName , inSize , inData ) ;
415 AGAAddControlData( inControl , inPart , inTagName , inSize , inData ) ;
421 OSErr
AGASetControlFontStyle (ControlHandle inControl
,
422 const ControlFontStyleRec
* inStyle
)
424 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
425 if ( inStyle
->flags
== 0 )
431 if ( inStyle
->flags
& kControlUseFontMask
)
433 info
->fontStyle
.font
= inStyle
->font
;
435 if ( inStyle
->flags
& kControlUseSizeMask
)
437 info
->fontStyle
.size
= inStyle
->size
;
439 if ( inStyle
->flags
& kControlUseFaceMask
)
441 info
->fontStyle
.style
= inStyle
->style
;
443 if ( inStyle
->flags
& kControlUseModeMask
)
445 info
->fontStyle
.mode
= inStyle
->mode
;
447 if ( inStyle
->flags
& kControlUseJustMask
)
449 info
->fontStyle
.just
= inStyle
->just
;
451 if ( inStyle
->flags
& kControlUseForeColorMask
)
453 info
->fontStyle
.foreColor
= inStyle
->foreColor
;
455 if ( inStyle
->flags
& kControlUseBackColorMask
)
457 info
->fontStyle
.backColor
= inStyle
->backColor
;
463 OSErr
AGASetControlData (ControlHandle inControl
,
464 ControlPartCode inPart
,
469 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
470 ControlDataAccessRec rec
;
472 rec
.tag
= inTagName
;
475 rec
.dataPtr
= inData
;
477 return info
->defProc( info
->procID
, inControl
, kControlMsgSetData
, (long) &rec
) ;
480 SInt16
AGAHandleControlKey (ControlHandle inControl
,
485 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
486 ControlKeyDownRec rec
;
488 rec
.modifiers
= inModifiers
;
489 rec
.keyCode
= inKeyCode
;
490 rec
.charCode
= inCharCode
;
492 return info
->defProc( info
->procID
, inControl
, kControlMsgKeyDown
, (long) &rec
) ;
495 ControlPartCode
AGAHandleControlClick (ControlHandle inControl
,
498 ControlActionUPP inAction
)
500 return TrackControl( inControl
, inWhere
, inAction
) ;
503 Boolean
AGATestForNewControl( ControlHandle inControl
)
505 if ( (**inControl
).contrlRfCon
> 0x100 && !( (**inControl
).contrlRfCon
% 2 ) )
507 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
508 return info
->magic
== kExtCDEFMagic
;
512 void AGAIdleControls (WindowPtr inWindow
)
514 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)inWindow
)->controlList
;
517 if ( AGATestForNewControl( iter
) )
519 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**iter
).contrlRfCon
;
520 if ( info
->defProc( info
->procID
, iter
, kControlMsgTestNewMsgSupport
, 0 ) == kControlSupportsNewMessages
)
522 if ( info
->defProc( info
->procID
, iter
, kControlMsgGetFeatures
, 0 ) & kControlWantsIdle
)
524 info
->defProc( info
->procID
, iter
, kControlMsgIdle
, 0 ) ;
529 iter
= (**iter
).nextControl
;
533 void AGAUpdateOneControl( ControlHandle control
, RgnHandle inRgn
)
535 DrawOneControl( control
) ;
536 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)(**control
).contrlOwner
)->controlList
;
539 if ( AGATestForNewControl( iter
) )
541 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**iter
).contrlRfCon
;
542 if ( info
->containerControl
== control
)
544 AGAUpdateOneControl( iter
, inRgn
) ;
548 iter
= (**iter
).nextControl
;
552 void AGAUpdateControls( WindowPtr inWindow
, RgnHandle inRgn
)
555 AGAGetRootControl( inWindow
, &root
) ;
556 AGAUpdateOneControl( root
, inRgn
) ;
558 // and then all others
560 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)inWindow
)->controlList
;
563 if ( AGATestForNewControl( iter
) )
568 DrawOneControl( iter
) ;
571 iter
= (**iter
).nextControl
;
575 OSErr
AGAGetRootControl( WindowPtr inWindow
, ControlHandle
*outControl
)
577 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)inWindow
)->controlList
;
580 if ( AGATestForNewControl( iter
) )
582 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**iter
).contrlRfCon
;
583 if ( info
->procID
== kAGARootControlProcID
)
590 iter
= (**iter
).nextControl
;
595 void AGADeactivateControl( ControlHandle inControl
)
597 if ( AGATestForNewControl( inControl
) )
599 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
600 if ( info
->defProc( info
->procID
, inControl
, kControlMsgTestNewMsgSupport
, 0 ) == kControlSupportsNewMessages
)
602 if ( info
->defProc( info
->procID
, inControl
, kControlMsgGetFeatures
, 0 ) & kControlWantsActivate
)
604 info
->defProc( info
->procID
, inControl
, kControlMsgActivate
, 0 ) ;
610 ::HiliteControl( inControl
, 255 ) ;
614 void AGAActivateControl( ControlHandle inControl
)
616 if ( AGATestForNewControl( inControl
) )
618 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
619 if ( info
->defProc( info
->procID
, inControl
, kControlMsgTestNewMsgSupport
, 0 ) == kControlSupportsNewMessages
)
621 if ( info
->defProc( info
->procID
, inControl
, kControlMsgGetFeatures
, 0 ) & kControlWantsActivate
)
623 info
->defProc( info
->procID
, inControl
, kControlMsgActivate
, 1 ) ;
629 ::HiliteControl( inControl
, 0 ) ;
633 OSErr
AGASetKeyboardFocus (WindowPtr inWindow
,
634 ControlHandle inControl
,
635 ControlFocusPart inPart
)
637 if ( AGATestForNewControl( inControl
) )
639 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
640 if ( info
->defProc( info
->procID
, inControl
, kControlMsgTestNewMsgSupport
, 0 ) == kControlSupportsNewMessages
)
642 if ( info
->defProc( info
->procID
, inControl
, kControlMsgGetFeatures
, 0 ) & kControlSupportsFocus
)
644 return info
->defProc( info
->procID
, inControl
, kControlMsgFocus
, inPart
) ;
648 return errControlDoesntSupportFocus
;
651 OSErr
AGAGetBestControlRect (ControlHandle inControl
,
653 SInt16
* outBaseLineOffset
)
655 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
656 ControlCalcSizeRec rec
;
657 rec
.width
= (**inControl
).contrlRect
.right
- (**inControl
).contrlRect
.left
;
658 rec
.height
= (**inControl
).contrlRect
.bottom
- (**inControl
).contrlRect
.top
;
661 OSErr err
= info
->defProc( info
->procID
, inControl
, kControlMsgCalcBestRect
, (long) &rec
) ;
664 outRect
->left
= outRect
->top
= 0 ;
665 outRect
->right
= rec
. width
;
666 outRect
->bottom
= rec
. height
;
667 *outBaseLineOffset
= rec
. baseLine
;
673 OSErr
AGAGetControlData (ControlHandle inControl
,
674 ControlPartCode inPart
,
678 Size
* outActualSize
)
680 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
681 ControlDataAccessRec rec
;
683 rec
.tag
= inTagName
;
685 rec
.size
= inBufferSize
;
686 rec
.dataPtr
= outBuffer
;
688 OSErr err
= info
->defProc( info
->procID
, inControl
, kControlMsgGetData
, (long) &rec
) ;
689 *outActualSize
= rec
.size
;
693 OSErr
AGAGetControlDataSize (ControlHandle inControl
,
694 ControlPartCode inPart
,
698 return AGAGetControlData( inControl
, inPart
, inTagName
, 0 , NULL
, outMaxSize
) ;
702 void NewExtCDEFInfo( ControlHandle theControl
, ControlDefProcPtr defproc
, SInt16 procID
, long refcon
)
704 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) malloc( sizeof( ExtCDEFInfo
) ) ;
705 info
->defProc
= defproc
;
706 info
->hasFocus
= false ;
707 info
->magic
= kExtCDEFMagic
;
708 info
->contrlRfCon
= refcon
;
709 info
->procID
= procID
;
710 info
->containerControl
= NULL
;
711 info
->children
= NewHandle(0) ;
712 info
->fontStyle
.flags
= 0 ;
713 info
->fontStyle
.font
= 0 ;
714 info
->fontStyle
.size
= 12 ;
715 info
->fontStyle
.style
= 0 ;
716 info
->fontStyle
.mode
= 0 ;
717 info
->fontStyle
.just
= 0 ;
718 info
->fontStyle
.foreColor
= gAGARamp
[ kAGABlack
] ;
719 info
->fontStyle
.backColor
= gAGARamp
[ kAGA2
] ;
720 (**theControl
).contrlRfCon
= (long) info
;
721 defproc( info
->procID
, theControl
, initCntl
, 0) ;
724 void DisposeExtCDEFInfo( ControlHandle theControl
)
726 if ( AGATestForNewControl( theControl
) )
728 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
731 DisposeHandle( info
->children
) ;
732 info
->children
= NULL
;
733 free( (void*) (**theControl
).contrlRfCon
) ;
734 (**theControl
).contrlRfCon
= NULL
;
739 const short kAGAProgressHeight
= 14 ;
741 void AGADrawRectPlacard( const Rect
*inRect
, eAGAState inState
, bool fill
= false ) ;
742 void AGADrawRectProgress( const Rect
*inRect
, eAGAState inState
, double percentage
) ;
744 void AGADrawRectPlacard( const Rect
*inRect
, eAGAState inState
, bool fill
)
746 Rect rect
= *inRect
;
747 RGBColor pixelColor
;
748 if ( inState
== kAGAStateInactive
)
750 RGBForeColor( &gAGARamp
[ kAGA10
] ) ;
754 InsetRect( &rect
, 1 , 1 ) ;
755 RGBForeColor( &gAGARamp
[ kAGA1
] ) ;
761 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
763 InsetRect( &rect
, 1 , 1 ) ;
765 if ( inState
== kAGAStateEnabled
|| inState
== kAGAStateDisabled
)
766 RGBForeColor( &gAGARamp
[ kAGAWhite
] ) ;
768 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
770 MoveTo( rect
.left
, rect
.bottom
- 1 -1 ) ;
771 LineTo( rect
.left
, rect
.top
) ;
772 LineTo( rect
.right
-1-1 , rect
.top
) ;
774 if ( inState
== kAGAStateEnabled
|| inState
== kAGAStateDisabled
)
775 pixelColor
= gAGARamp
[ kAGA2
] ;
777 pixelColor
= gAGARamp
[ kAGA8
] ;
779 SetCPixel( rect
.right
-1 , rect
.top
, &pixelColor
) ;
780 SetCPixel( rect
.left
, rect
.bottom
-1 , &pixelColor
) ;
782 if ( inState
== kAGAStateEnabled
)
783 RGBForeColor( &gAGARamp
[ kAGA5
] ) ;
784 else if ( inState
== kAGAStateDisabled
)
785 RGBForeColor( &gAGARamp
[ kAGA4
] ) ;
787 RGBForeColor( &gAGARamp
[ kAGA6
] ) ;
789 MoveTo( rect
.left
+ 1 , rect
.bottom
-1 ) ;
790 LineTo( rect
.right
-1 , rect
.bottom
-1 ) ;
791 LineTo( rect
.right
-1 , rect
.top
-1 ) ;
795 InsetRect( &rect
, 1 , 1 ) ;
796 if ( inState
== kAGAStateEnabled
|| inState
== kAGAStateDisabled
)
797 RGBForeColor( &gAGARamp
[ kAGA2
] ) ;
799 RGBForeColor( &gAGARamp
[ kAGA8
] ) ;
804 void AGADrawRectProgress( const Rect
*inRect
, eAGAState inState
, double percentage
)
806 Rect rect
= *inRect
;
807 rect
.bottom
= rect
.top
+ 14 ;
808 RGBColor pixelColor
;
810 RGBForeColor( &gAGARamp
[ kAGA5
]) ;
811 MoveTo( rect
.left
, rect
.bottom
- 1 -1 ) ;
812 LineTo( rect
.left
, rect
.top
) ;
813 LineTo( rect
.right
-1-1 , rect
.top
) ;
815 RGBForeColor( &gAGARamp
[ kAGAWhite
] ) ;
816 MoveTo( rect
.left
+ 1 , rect
.bottom
-1 ) ;
817 LineTo( rect
.right
-1 , rect
.bottom
-1 ) ;
818 LineTo( rect
.right
-1 , rect
.top
-1 ) ;
820 InsetRect( &rect
, 1 , 1 ) ;
821 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
823 Rect barLeft
= rect
, barRight
= rect
;
825 int position
= percentage
* ( rect
.right
- rect
.left
) ;
826 barLeft
.right
= barLeft
.left
+ position
;
827 barRight
.left
= barLeft
.left
+ position
;
828 FrameRect( &barLeft
) ;
829 FrameRect( &barRight
) ;
831 InsetRect( &barLeft
, 1 , 1 ) ;
833 InsetRect( &barRight
, 1 , 1 ) ;
835 if ( !EmptyRect( &barRight
) )
837 RGBForeColor( &gAGARamp
[ kAGA10
] ) ;
838 MoveTo( barRight
.left
, barRight
.bottom
-1 ) ;
839 LineTo( barRight
.left
, barRight
.top
) ;
841 if ( !EmptyRect( &barRight
) )
843 RGBForeColor( &gAGARamp
[ kAGA7
] ) ;
844 MoveTo( barRight
.left
, barRight
.bottom
-1 ) ;
845 LineTo( barRight
.left
, barRight
.top
) ;
846 LineTo( barRight
.right
-1-1 , barRight
.top
) ;
847 RGBForeColor( &gAGARamp
[ kAGA2
] ) ;
848 MoveTo( barRight
.left
+ 1 , barRight
.bottom
-1 ) ;
849 LineTo( barRight
.right
-1 , barRight
.bottom
-1 ) ;
850 LineTo( barRight
.right
-1 , barRight
.top
- 1) ;
851 pixelColor
= gAGARamp
[ kAGA4
] ;
852 SetCPixel( barRight
.right
-1 , barRight
.top
, &pixelColor
) ;
853 InsetRect( &barRight
, 1 , 1) ;
854 if ( !EmptyRect( &barRight
) )
856 RGBForeColor( &gAGARamp
[ kAGA4
] ) ;
857 PaintRect( &barRight
) ;
860 if ( !EmptyRect( &barLeft
) )
862 RGBForeColor( &gAGABlueRamp
[ kAGA8
] ) ;
863 MoveTo( barLeft
.left
, barLeft
.bottom
-1 ) ;
864 LineTo( barLeft
.left
, barLeft
.top
) ;
865 LineTo( barLeft
.left
+1 , barLeft
.top
) ;
866 RGBForeColor( &gAGABlueRamp
[ kAGA12
] ) ;
867 MoveTo( barLeft
.left
+ 2, barLeft
.bottom
-1 ) ;
868 LineTo( barLeft
.right
-1 , barLeft
.bottom
-1 ) ;
869 LineTo( barLeft
.right
-1 , barLeft
.top
-1 ) ;
870 RGBForeColor( &gAGABlueRamp
[ kAGA10
] ) ;
871 MoveTo( barLeft
.left
+ 2, barLeft
.top
) ;
872 LineTo( barLeft
.right
-1 , barLeft
.top
) ;
873 pixelColor
= gAGABlueRamp
[ kAGA10
] ;
874 SetCPixel( barLeft
.left
+ 1, barLeft
.bottom
-1 , &pixelColor
) ;
875 InsetRect( &barLeft
, 1 , 1 ) ;
876 if ( !EmptyRect( &barLeft
) )
879 RGBForeColor( &gAGABlueRamp
[ kAGA3
] ) ;
880 PaintRect( &barLeft
) ;
886 SInt32
AGAGetDataHelper( ControlDataAccessRec
*rec
, Size size
, Ptr data
) ;
887 SInt32
AGAGetDataHelper( ControlDataAccessRec
*rec
, Size size
, Ptr data
)
889 if ( rec
->dataPtr
== NULL
)
896 if ( rec
->size
< size
)
897 return errDataSizeMismatch
;
900 memcpy( rec
->dataPtr
, data
, size
) ;
905 void AGASetFontStyle( ControlFontStyleRec
*fontstyle
) ;
906 void AGASetFontStyle( ControlFontStyleRec
*fontstyle
)
908 if( fontstyle
->font
>= 0 )
910 ::TextFont( fontstyle
->font
) ;
911 ::TextSize( fontstyle
->size
) ;
912 ::TextFace( fontstyle
->style
) ;
916 switch( fontstyle
->font
)
918 case kControlFontBigSystemFont
:
919 ::TextFont( systemFont
) ;
923 case kControlFontSmallSystemFont
:
924 ::TextFont( kFontIDGeneva
) ;
928 case kControlFontSmallBoldSystemFont
:
929 ::TextFont( kFontIDGeneva
) ;
935 ::RGBForeColor( &fontstyle
->foreColor
) ;
936 ::RGBBackColor( &fontstyle
->backColor
) ;
939 pascal SInt32
AGAProgressBarDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
945 if (!(**theControl
).contrlVis
)
947 PenState oldPenState
;
948 RGBColor oldForeColor
;
949 RGBColor oldBackColor
;
953 GetPenState( &oldPenState
) ;
954 GetBackColor( &oldBackColor
) ;
955 GetForeColor( &oldForeColor
) ;
958 int theValue
= GetControlValue(theControl
) ;
959 int theMinimum
= GetControlMinimum(theControl
) ;
960 int theMaximum
= GetControlMaximum(theControl
) ;
962 AGADrawRectProgress( &(**theControl
).contrlRect
, kAGAStateEnabled
, (( double )( theValue
- theMinimum
)) / ( theMaximum
-theMinimum
) ) ;
965 RGBForeColor(&oldForeColor
);
966 RGBBackColor(&oldBackColor
);
967 SetPenState(&oldPenState
);
971 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
981 pascal SInt32
AGAPlacardDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
987 if (!(**theControl
).contrlVis
)
989 PenState oldPenState
;
990 RGBColor oldForeColor
;
991 RGBColor oldBackColor
;
995 GetPenState( &oldPenState
) ;
996 GetBackColor( &oldBackColor
) ;
997 GetForeColor( &oldForeColor
) ;
1000 AGADrawRectPlacard( &(**theControl
).contrlRect
, kAGAStateEnabled
, true ) ;
1003 RGBForeColor(&oldForeColor
);
1004 RGBBackColor(&oldBackColor
);
1005 SetPenState(&oldPenState
);
1015 pascal SInt32
AGABevelButtonDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1017 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1021 info
->privateData
= (long) malloc( sizeof( ControlButtonContentInfo
) ) ;
1022 memset( (char*) info
->privateData
, 0 , sizeof( ControlButtonContentInfo
) ) ;
1025 free( (void*) info
->privateData
) ;
1027 case kControlMsgSetData
:
1029 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
1030 if ( rec
->tag
== kControlBevelButtonContentTag
)
1032 memcpy( (char*) info
->privateData
, rec
->dataPtr
, rec
->size
) ;
1035 return errDataNotSupported
;
1037 case kControlMsgCalcBestRect
:
1039 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1047 if (!(**theControl
).contrlVis
)
1051 AGAPortHelper
help((**theControl
).contrlOwner
) ;
1052 AGASetFontStyle( &info
->fontStyle
) ;
1053 Boolean mRadioBehavior
= false ;
1055 int mValue
= GetControlValue( theControl
) ;
1056 long theValue
= (mRadioBehavior
? mValue
: 0);
1057 Boolean inPushed
= (**theControl
).contrlHilite
;
1058 Boolean down
= inPushed
|| (theValue
!= 0);
1059 Boolean hasColor
= 1;
1061 int triState_Off
= 3 ;
1062 Boolean disabled
= (mEnabled
== triState_Off
);
1064 Rect frame
= (**theControl
).contrlRect
;
1066 // Draw the black frame;
1067 ::MoveTo(frame
.left
+ 1, frame
.top
);
1068 ::LineTo(frame
.right
- 2, frame
.top
);
1069 ::MoveTo(frame
.right
- 1, frame
.top
+ 1);
1070 ::LineTo(frame
.right
- 1, frame
.bottom
- 2);
1071 ::MoveTo(frame
.right
- 2, frame
.bottom
- 1);
1072 ::LineTo(frame
.left
+ 1, frame
.bottom
- 1);
1073 ::MoveTo(frame
.left
, frame
.bottom
- 2);
1074 ::LineTo(frame
.left
, frame
.top
+ 1);
1076 // Draw the inside (w/o the Icon)
1077 ::InsetRect(&frame
, 1, 1);
1080 AGASetFontStyle( &info
->fontStyle
) ;
1082 ::RGBBackColor(&gAGAColorArray
[4]);
1084 ::EraseRect(&frame
);
1089 ::RGBForeColor(&gAGAColorArray
[7]);
1092 ::MoveTo(frame
.left
, frame
.bottom
- 1);
1093 ::LineTo(frame
.left
, frame
.top
);
1094 ::LineTo(frame
.right
- 1, frame
.top
);
1098 ::MoveTo(frame
.right
- 1, frame
.top
);
1099 ::LineTo(frame
.right
- 1, frame
.bottom
- 1);
1100 ::LineTo(frame
.left
, frame
.bottom
- 1);
1101 ::MoveTo(frame
.right
- 2, frame
.top
+ 1);
1102 ::LineTo(frame
.right
- 2, frame
.bottom
- 2);
1103 ::LineTo(frame
.left
+ 1, frame
.bottom
- 2);
1104 ::ForeColor(whiteColor
);
1105 ::MoveTo(frame
.left
, frame
.bottom
- 2);
1106 ::LineTo(frame
.left
, frame
.top
);
1107 ::LineTo(frame
.right
- 2, frame
.top
);
1113 frame
= (**theControl
).contrlRect
;
1115 PicHandle thePict
= ((ControlButtonContentInfo
*) info
->privateData
)->u
.picture
;
1118 GetPictInfo( thePict
, &theInfo
, 0 , 0 , systemMethod
, 0 ) ;
1119 Rect bitmaprect
= { 0 , 0 , theInfo
.sourceRect
.bottom
- theInfo
.sourceRect
.top
,
1120 theInfo
.sourceRect
.right
- theInfo
.sourceRect
.left
} ;
1121 ::OffsetRect( &bitmaprect
, (frame
.right
+ frame
.left
)/2 - bitmaprect
.right
/ 2 , (frame
.bottom
+ frame
.top
) / 2 - bitmaprect
.bottom
/ 2 ) ;
1123 ::OffsetRect( &bitmaprect
, 1 , 1 ) ;
1124 ::DrawPicture( thePict
, &bitmaprect
) ;
1132 pt
.h
= LoWord( param
) ;
1133 pt
.v
= HiWord( param
) ;
1134 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1135 return kControlButtonPart
;
1141 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1146 pt
.h
= LoWord( param
) ;
1147 pt
.v
= HiWord( param
) ;
1148 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1149 return kControlButtonPart
;
1161 pascal SInt32
AGAButtonDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1163 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1167 (**theControl
).contrlData
= NULL
;
1169 case kControlMsgSetData
:
1171 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
1172 Boolean isDefault
= *((Boolean
*)rec
->dataPtr
) ;
1173 (**theControl
).contrlData
= (Handle
) isDefault
;
1177 case kControlMsgCalcBestRect
:
1179 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1187 if (!(**theControl
).contrlVis
)
1191 AGAPortHelper
help((**theControl
).contrlOwner
) ;
1192 AGASetFontStyle( &info
->fontStyle
) ;
1193 Boolean mRadioBehavior
= false ;
1195 Rect frame
, tempRect
;
1196 int mValue
= GetControlValue( theControl
) ;
1197 long theValue
= (mRadioBehavior
? mValue
: 0);
1198 Boolean inPushed
= (**theControl
).contrlHilite
;
1199 Boolean down
= inPushed
|| (theValue
!= 0);
1200 Boolean hasColor
= 1;
1202 int triState_Off
= 3 ;
1203 Boolean disabled
= (mEnabled
== triState_Off
);
1205 // theState.Normalize();
1206 // CalcLocalFrameRect(frame);
1207 frame
= (**theControl
).contrlRect
;
1209 if ( (**theControl
).contrlData
)
1211 InsetRect( &frame
, -3 , -3 ) ;
1213 ::MoveTo(frame
.left
+ 3, frame
.top
);
1214 ::LineTo(frame
.right
- 4, frame
.top
);
1215 ::LineTo(frame
.right
- 1, frame
.top
+ 3);
1216 ::LineTo(frame
.right
- 1, frame
.bottom
- 4);
1217 ::LineTo(frame
.right
- 4, frame
.bottom
- 1);
1218 ::LineTo(frame
.left
+ 3, frame
.bottom
- 1);
1219 ::LineTo(frame
.left
, frame
.bottom
- 4);
1220 ::LineTo(frame
.left
, frame
.top
+ 3);
1221 ::LineTo(frame
.left
+ 3, frame
.top
);
1225 const RGBColor
*col
= gAGAColorArray
;
1226 for (int i
= 0; i
< 5; i
++)
1227 for (int j
= 0; j
< 5; j
++)
1229 if (LAGADefaultOutline_mCorners
[0][i
][j
] != -1)
1230 ::SetCPixel(frame
.left
+ j
, frame
.top
+ i
, &col
[LAGADefaultOutline_mCorners
[0][i
][j
]]);
1231 if (LAGADefaultOutline_mCorners
[1][i
][j
] != -1)
1232 ::SetCPixel(frame
.right
- 5 + j
, frame
.top
+ i
, &col
[LAGADefaultOutline_mCorners
[1][i
][j
]]);
1233 if (LAGADefaultOutline_mCorners
[2][i
][j
] != -1)
1234 ::SetCPixel(frame
.left
+ j
, frame
.bottom
- 5 + i
, &col
[LAGADefaultOutline_mCorners
[2][i
][j
]]);
1235 if (LAGADefaultOutline_mCorners
[3][i
][j
] != -1)
1236 ::SetCPixel(frame
.right
- 5 + j
, frame
.bottom
- 5 + i
, &col
[LAGADefaultOutline_mCorners
[3][i
][j
]]);
1239 ::RGBForeColor(&gAGAColorArray
[2]);
1240 ::MoveTo(frame
.left
+ 1, frame
.top
+ 5);
1241 ::LineTo(frame
.left
+ 1, frame
.bottom
- 6);
1242 ::MoveTo(frame
.left
+ 5, frame
.top
+ 1);
1243 ::LineTo(frame
.right
- 6, frame
.top
+ 1);
1245 ::RGBForeColor(&gAGAColorArray
[5]);
1246 ::MoveTo(frame
.left
+ 4, frame
.top
+ 2);
1247 ::LineTo(frame
.right
- 5, frame
.top
+ 2);
1248 ::LineTo(frame
.right
- 3, frame
.top
+ 4);
1249 ::LineTo(frame
.right
- 3, frame
.bottom
- 5);
1250 ::LineTo(frame
.right
- 5, frame
.bottom
- 3);
1251 ::LineTo(frame
.left
+ 4, frame
.bottom
- 3);
1252 ::LineTo(frame
.left
+ 2, frame
.bottom
- 5);
1253 ::LineTo(frame
.left
+ 2, frame
.top
+ 4);
1254 ::LineTo(frame
.left
+ 4, frame
.top
+ 2);
1256 ::RGBForeColor(&gAGAColorArray
[8]);
1257 ::MoveTo(frame
.right
- 2, frame
.top
+ 5);
1258 ::LineTo(frame
.right
- 2, frame
.bottom
- 6);
1259 ::MoveTo(frame
.left
+ 5, frame
.bottom
- 2);
1260 ::LineTo(frame
.right
- 6, frame
.bottom
- 2);
1265 AGASetFontStyle( &info
->fontStyle
) ;
1266 frame
= (**theControl
).contrlRect
;
1269 ::InsetRect(&tempRect
, 1, 1);
1273 ::RGBBackColor(&gAGAColorArray
[4]);
1275 EraseRect(&tempRect
);
1281 ::RGBForeColor(&gAGAColorArray
[7]);
1285 ::MoveTo(frame
.left
+ 2, frame
.top
);
1286 ::LineTo(frame
.right
- 3, frame
.top
);
1287 ::LineTo(frame
.right
- 1, frame
.top
+ 2);
1288 ::LineTo(frame
.right
- 1, frame
.bottom
- 3);
1289 ::LineTo(frame
.right
- 3, frame
.bottom
- 1);
1290 ::LineTo(frame
.left
+ 2, frame
.bottom
- 1);
1291 ::LineTo(frame
.left
, frame
.bottom
- 3);
1292 ::LineTo(frame
.left
, frame
.top
+ 2);
1293 ::LineTo(frame
.left
+ 2, frame
.top
);
1294 if (disabled
&& !hasColor
)
1297 // Draw the four corners around
1300 short pattern
= (disabled
? 2 : (down
? 1 : 0));
1301 const RGBColor
*col
= gAGAColorArray
;
1302 for (int i
= 0; i
< 4; i
++)
1303 for (int j
= 0; j
< 4; j
++)
1305 if (LAGAPushButton_mCorners
[pattern
][0][i
][j
] != -1)
1306 ::SetCPixel(frame
.left
+ j
, frame
.top
+ i
, &col
[LAGAPushButton_mCorners
[pattern
][0][i
][j
]]);
1307 if (LAGAPushButton_mCorners
[pattern
][1][i
][j
] != -1)
1308 ::SetCPixel(frame
.right
- 4 + j
, frame
.top
+ i
, &col
[LAGAPushButton_mCorners
[pattern
][1][i
][j
]]);
1309 if (LAGAPushButton_mCorners
[pattern
][2][i
][j
] != -1)
1310 ::SetCPixel(frame
.left
+ j
, frame
.bottom
- 4 + i
, &col
[LAGAPushButton_mCorners
[pattern
][2][i
][j
]]);
1311 if (LAGAPushButton_mCorners
[pattern
][3][i
][j
] != -1)
1312 ::SetCPixel(frame
.right
- 4 + j
, frame
.bottom
- 4 + i
, &col
[LAGAPushButton_mCorners
[pattern
][3][i
][j
]]);
1316 ::RGBForeColor(&gAGAColorArray
[8]);
1318 ::RGBForeColor(&gAGAColorArray
[2]);
1319 ::MoveTo(frame
.left
+ 1, frame
.top
+ 4);
1320 ::LineTo(frame
.left
+ 1, frame
.bottom
- 5);
1321 ::MoveTo(frame
.left
+ 4, frame
.top
+ 1);
1322 ::LineTo(frame
.right
- 5, frame
.top
+ 1);
1327 ::RGBForeColor(&gAGAColorArray
[1]);
1329 ::ForeColor(whiteColor
);
1330 ::MoveTo(frame
.left
+ 2, frame
.bottom
- 5);
1331 ::LineTo(frame
.left
+ 2, frame
.top
+ 2);
1332 ::LineTo(frame
.right
- 5, frame
.top
+ 2);
1335 ::RGBForeColor(&gAGAColorArray
[5]);
1337 ::RGBForeColor(&gAGAColorArray
[8]);
1338 ::MoveTo(frame
.left
+ 4, frame
.bottom
- 2);
1339 ::LineTo(frame
.right
- 5, frame
.bottom
- 2);
1340 ::MoveTo(frame
.right
- 2, frame
.bottom
- 5);
1341 ::LineTo(frame
.right
- 2, frame
.top
+ 4);
1344 ::RGBForeColor(&gAGAColorArray
[4]);
1346 ::RGBForeColor(&gAGAColorArray
[5]);
1347 ::MoveTo(frame
.left
+ 4, frame
.bottom
- 3);
1348 ::LineTo(frame
.right
- 5, frame
.bottom
- 3);
1349 ::MoveTo(frame
.right
- 3, frame
.bottom
- 5);
1350 ::LineTo(frame
.right
- 3, frame
.top
+ 4);
1353 AGASetFontStyle( &info
->fontStyle
) ;
1354 int x
= ( (**theControl
).contrlRect
.left
+ (**theControl
).contrlRect
.right
) / 2 ;
1355 int y
= ( (**theControl
).contrlRect
.top
+ (**theControl
).contrlRect
.bottom
) / 2 ;
1357 ::GetFontInfo( &fi
) ;
1359 y
+= fi
.ascent
/ 2 ;
1360 int length
= (**theControl
).contrlTitle
[0] ;
1363 int width
= TextWidth( &(**theControl
).contrlTitle
[1] , 0, length
) ;
1366 ::DrawText( &(**theControl
).contrlTitle
[1] , 0, length
);
1375 pt
.h
= LoWord( param
) ;
1376 pt
.v
= HiWord( param
) ;
1377 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1378 return kControlButtonPart
;
1384 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1389 pt
.h
= LoWord( param
) ;
1390 pt
.v
= HiWord( param
) ;
1391 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1392 return kControlButtonPart
;
1404 const int kAGACheckBoxWidth
= 12 ;
1405 const int kAGACheckBoxHeigth
= 12 ;
1407 pascal SInt32
AGACheckBoxDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1409 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1414 if (!(**theControl
).contrlVis
)
1416 PenState oldPenState
;
1417 RGBColor oldForeColor
;
1418 RGBColor oldBackColor
;
1419 RGBColor backColor
;
1420 RGBColor foreColor
;
1424 if (!(**theControl
).contrlVis
)
1428 AGAPortHelper
help((**theControl
).contrlOwner
) ;
1429 Rect frame
= (**theControl
).contrlRect
;
1430 Boolean hasColor
= true;
1431 Boolean disabled
= (*theControl
)->contrlHilite
== 255 ;
1432 int mValue
= GetControlValue( theControl
) ;
1433 Boolean inPushed
= (**theControl
).contrlHilite
;
1435 int triState_Off
= 3 ;
1437 frame
.right
= frame
.left
+ kAGACheckBoxWidth
;
1438 frame
.bottom
= frame
.top
+ kAGACheckBoxHeigth
;
1440 // Draw the frame of the checkbox
1443 ::RGBForeColor(&gAGAColorArray
[7]);
1447 ::FrameRect(&frame
);
1452 ::InsetRect(&frame
, 1, 1);
1454 ::RGBBackColor(inPushed
? &gAGAColorArray
[8] : &gAGAColorArray
[2]);
1455 ::EraseRect(&frame
);
1460 ::RGBForeColor(&gAGAColorArray
[10]);
1462 ForeColor(whiteColor
);
1463 ::MoveTo(frame
.left
, frame
.bottom
- 2);
1464 ::LineTo(frame
.left
, frame
.top
);
1465 ::LineTo(frame
.right
- 2, frame
.top
);
1468 ::RGBForeColor(&gAGAColorArray
[6]);
1470 ::RGBForeColor(mEnabled
!= triState_Off
? &gAGAColorArray
[7] : &gAGAColorArray
[5]);
1471 ::MoveTo(frame
.left
+ 1, frame
.bottom
- 1);
1472 ::LineTo(frame
.right
- 1, frame
.bottom
- 1);
1473 ::LineTo(frame
.right
- 1, frame
.top
+ 1);
1483 ::RGBForeColor(inPushed
? &gAGAColorArray
[10] : &gAGAColorArray
[5]);
1484 ::MoveTo(frame
.left
+ 3, frame
.bottom
- 2);
1485 ::LineTo(frame
.right
- 2, frame
.top
+ 3);
1486 ::MoveTo(frame
.right
- 2, frame
.bottom
- 2);
1487 ::LineTo(frame
.right
- 2, frame
.bottom
- 2);
1489 if (mEnabled
!= triState_Off
)
1490 ::RGBForeColor(inPushed
? &gAGAColorArray
[11] : &gAGAColorArray
[8]);
1491 ::MoveTo(frame
.left
+ 3, frame
.bottom
- 3);
1492 ::LineTo(frame
.right
- 2, frame
.top
+ 2);
1493 ::MoveTo(frame
.right
- 2, frame
.bottom
- 3);
1494 ::LineTo(frame
.right
- 2, frame
.bottom
- 3);
1496 if (mEnabled
!= triState_Off
)
1497 ::ForeColor(blackColor
);
1499 ::RGBForeColor(&gAGAColorArray
[7]);
1501 ::MoveTo(frame
.left
+ 2, frame
.top
+ 1);
1502 ::LineTo(frame
.right
- 3, frame
.bottom
- 4);
1503 ::MoveTo(frame
.left
+ 2, frame
.top
+ 2);
1504 ::LineTo(frame
.right
- 3, frame
.bottom
- 3);
1505 ::MoveTo(frame
.left
+ 2, frame
.bottom
- 4);
1506 ::LineTo(frame
.right
- 3, frame
.top
+ 1);
1507 ::MoveTo(frame
.left
+ 2, frame
.bottom
- 3);
1508 ::LineTo(frame
.right
- 3, frame
.top
+ 2);
1515 ::RGBForeColor(inPushed
? &gAGAColorArray
[10] : &gAGAColorArray
[5]);
1516 ::MoveTo(frame
.left
+ 3, frame
.top
+ 6);
1517 ::LineTo(frame
.right
- 2, frame
.top
+ 6);
1518 ::LineTo(frame
.right
- 2, frame
.top
+ 4);
1520 if (mEnabled
!= triState_Off
)
1521 ::ForeColor(blackColor
);
1523 ::RGBForeColor(&gAGAColorArray
[7]);
1525 ::MoveTo(frame
.left
+ 2, frame
.top
+ 4);
1526 ::LineTo(frame
.right
- 3, frame
.top
+ 4);
1527 ::MoveTo(frame
.left
+ 2, frame
.top
+ 5);
1528 ::LineTo(frame
.right
- 3, frame
.top
+ 5);
1532 if (inPushed
&& !hasColor
)
1535 AGASetFontStyle( &info
->fontStyle
) ;
1536 int x
= (**theControl
).contrlRect
.left
+ kAGACheckBoxWidth
+ 5 ;
1537 int y
= ( (**theControl
).contrlRect
.top
+ (**theControl
).contrlRect
.bottom
) / 2 ;
1539 ::GetFontInfo( &fi
) ;
1541 y
+= fi
.ascent
/ 2 ;
1543 int length
= (**theControl
).contrlTitle
[0] ;
1546 ::DrawText( &(**theControl
).contrlTitle
[1] , 0, length
);
1556 pt
.h
= LoWord( param
) ;
1557 pt
.v
= HiWord( param
) ;
1558 if ( PtInRect( pt
, &(**theControl
).contrlRect
) && ((*theControl
)->contrlVis
!= 0) && ((*theControl
)->contrlHilite
!= 255) )
1559 return kControlCheckBoxPart
;
1567 pt
.h
= LoWord( param
) ;
1568 pt
.v
= HiWord( param
) ;
1569 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1571 if ( (**theControl
).contrlValue
)
1572 (**theControl
).contrlValue
= 0 ;
1574 (**theControl
).contrlValue
= 1 ;
1584 if ( !EmptyRect(&(**theControl
).contrlRect
) )
1585 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1587 case kControlMsgCalcBestRect
:
1589 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1590 rec
->width
= (**theControl
).contrlRect
.right
- (**theControl
).contrlRect
.left
;
1591 rec
->height
= kAGACheckBoxHeigth
;
1602 pascal SInt32
AGARadioButtonDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1605 /* ExtCDEFInfo* info = (ExtCDEFInfo* ) (**theControl).contrlRfCon ;
1610 if (!(**theControl).contrlVis)
1612 PenState oldPenState;
1613 RGBColor oldForeColor ;
1614 RGBColor oldBackColor ;
1615 RGBColor backColor ;
1616 RGBColor foreColor ;
1620 if (!(**theControl).contrlVis)
1624 AGAPortHelper help() ;
1625 Rect frame = (**theControl).contrlRect ;
1626 Boolean hasColor = true;
1627 Boolean disabled = (*theControl)->contrlHilite == 255 ;
1628 int mValue = GetControlValue( theControl ) ;
1629 Boolean inPushed = (**theControl).contrlHilite ;
1631 int triState_Off = 3 ;
1633 frame.right = frame.left + kAGACheckBoxWidth;
1634 frame.bottom = frame.top + kAGACheckBoxHeigth;
1636 // Draw the frame of the checkbox
1639 ::RGBForeColor(&gAGAColorArray[7]);
1643 ::FrameRect(&frame);
1648 ::InsetRect(&frame, 1, 1);
1650 ::RGBBackColor(inPushed ? &gAGAColorArray[8] : &gAGAColorArray[2]);
1651 ::EraseRect(&frame);
1656 ::RGBForeColor(&gAGAColorArray[10]);
1658 ForeColor(whiteColor);
1659 ::MoveTo(frame.left, frame.bottom - 2);
1660 ::LineTo(frame.left, frame.top);
1661 ::LineTo(frame.right - 2, frame.top);
1664 ::RGBForeColor(&gAGAColorArray[6]);
1666 ::RGBForeColor(mEnabled != triState_Off ? &gAGAColorArray[7] : &gAGAColorArray[5]);
1667 ::MoveTo(frame.left + 1, frame.bottom - 1);
1668 ::LineTo(frame.right - 1, frame.bottom - 1);
1669 ::LineTo(frame.right - 1, frame.top + 1);
1679 ::RGBForeColor(inPushed ? &gAGAColorArray[10] : &gAGAColorArray[5]);
1680 ::MoveTo(frame.left + 3, frame.bottom - 2);
1681 ::LineTo(frame.right - 2, frame.top + 3);
1682 ::MoveTo(frame.right - 2, frame.bottom - 2);
1683 ::LineTo(frame.right - 2, frame.bottom - 2);
1685 if (mEnabled != triState_Off)
1686 ::RGBForeColor(inPushed ? &gAGAColorArray[11] : &gAGAColorArray[8]);
1687 ::MoveTo(frame.left + 3, frame.bottom - 3);
1688 ::LineTo(frame.right - 2, frame.top + 2);
1689 ::MoveTo(frame.right - 2, frame.bottom - 3);
1690 ::LineTo(frame.right - 2, frame.bottom - 3);
1692 if (mEnabled != triState_Off)
1693 ::ForeColor(blackColor);
1695 ::RGBForeColor(&gAGAColorArray[7]);
1697 ::MoveTo(frame.left + 2, frame.top + 1);
1698 ::LineTo(frame.right - 3, frame.bottom - 4);
1699 ::MoveTo(frame.left + 2, frame.top + 2);
1700 ::LineTo(frame.right - 3, frame.bottom - 3);
1701 ::MoveTo(frame.left + 2, frame.bottom - 4);
1702 ::LineTo(frame.right - 3, frame.top + 1);
1703 ::MoveTo(frame.left + 2, frame.bottom - 3);
1704 ::LineTo(frame.right - 3, frame.top + 2);
1711 ::RGBForeColor(inPushed ? &gAGAColorArray[10] : &gAGAColorArray[5]);
1712 ::MoveTo(frame.left + 3, frame.top + 6);
1713 ::LineTo(frame.right - 2, frame.top + 6);
1714 ::LineTo(frame.right - 2, frame.top + 4);
1716 if (mEnabled != triState_Off)
1717 ::ForeColor(blackColor);
1719 ::RGBForeColor(&gAGAColorArray[7]);
1721 ::MoveTo(frame.left + 2, frame.top + 4);
1722 ::LineTo(frame.right - 3, frame.top + 4);
1723 ::MoveTo(frame.left + 2, frame.top + 5);
1724 ::LineTo(frame.right - 3, frame.top + 5);
1728 if (inPushed && !hasColor)
1731 AGASetFontStyle( &info->fontStyle ) ;
1732 int x = (**theControl).contrlRect.left + kAGACheckBoxWidth + 5 ;
1733 int y = ( (**theControl).contrlRect.top + (**theControl).contrlRect.bottom ) / 2 ;
1735 ::GetFontInfo( &fi ) ;
1737 y += fi.ascent / 2 ;
1739 int length = (**theControl).contrlTitle[0] ;
1742 ::DrawText( &(**theControl).contrlTitle[1] , 0, length);
1752 pt.h = LoWord( param ) ;
1753 pt.v = HiWord( param ) ;
1754 if ( PtInRect( pt , &(**theControl).contrlRect ) && ((*theControl)->contrlVis != 0) && ((*theControl)->contrlHilite != 255) )
1755 return kControlCheckBoxPart ;
1763 pt.h = LoWord( param ) ;
1764 pt.v = HiWord( param ) ;
1765 if ( PtInRect( pt , &(**theControl).contrlRect ) )
1767 if ( (**theControl).contrlValue )
1768 (**theControl).contrlValue = 0 ;
1770 (**theControl).contrlValue = 1 ;
1780 if ( !EmptyRect(&(**theControl).contrlRect ) )
1781 RectRgn((RgnHandle) param , &(**theControl).contrlRect ) ;
1783 case kControlMsgCalcBestRect :
1785 ControlCalcSizeRec *rec = (ControlCalcSizeRec *) param ;
1786 rec->width = (**theControl).contrlRect.right - (**theControl).contrlRect.left ;
1787 rec->height = kAGACheckBoxHeigth ;
1798 pascal SInt32
AGAStaticGroupBoxTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1800 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1810 if (!(**theControl
).contrlVis
)
1814 bool disabled
= false ;
1815 bool hasColor
= true ;
1816 AGAPortHelper
help((**theControl
).contrlOwner
) ;
1817 AGASetFontStyle( &info
->fontStyle
) ;
1819 ::GetFontInfo( &fi
) ;
1821 Rect labelRect
= (**theControl
).contrlRect
;
1822 Rect theFrame
= (**theControl
).contrlRect
;
1823 int width
= StringWidth((**theControl
).contrlTitle
) ;
1824 theFrame
.top
+= fi
.ascent
+ fi
.leading
>> 1 ;
1825 labelRect
.bottom
= theFrame
.top
+ 8 ;
1826 labelRect
.left
+= 10 ;
1827 labelRect
.right
=labelRect
.left
+ width
+ 6 ;
1834 RGBForeColor( &gAGAColorArray
[4] ) ;
1838 RGBForeColor( &gAGAColorArray
[7] ) ;
1840 FrameRect( &theFrame
) ;
1843 ::RGBForeColor(&gAGAColorArray
[1]);
1845 ::ForeColor(whiteColor
);
1846 ::MoveTo(theFrame
.left
+ 1, theFrame
.bottom
- 2);
1847 ::LineTo(theFrame
.left
+ 1, theFrame
.top
+ 1);
1848 ::LineTo(theFrame
.right
- 2, theFrame
.top
+ 1);
1849 ::MoveTo(theFrame
.left
, theFrame
.bottom
);
1850 ::LineTo(theFrame
.right
, theFrame
.bottom
);
1851 ::LineTo(theFrame
.right
, theFrame
.top
);
1853 AGASetFontStyle( &info
->fontStyle
) ;
1854 ::EraseRect( &labelRect
) ;
1855 ::MoveTo(labelRect
.left
+ 3, labelRect
.top
+ fi
.ascent
+ (fi
.leading
>> 1));
1856 ::DrawString((**theControl
).contrlTitle
);
1860 case kControlMsgCalcBestRect
:
1862 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1863 rec
->width
= (**theControl
).contrlRect
.right
- (**theControl
).contrlRect
.left
;
1864 rec
->height
= (**theControl
).contrlRect
.bottom
- (**theControl
).contrlRect
.top
;
1868 case kControlMsgSetData
:
1871 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1880 pascal SInt32
AGAStaticTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1882 Handle macText
= (**theControl
).contrlData
;
1883 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1889 macText
= NewHandle(0) ;
1890 (**theControl
).contrlData
= (Handle
) macText
;
1894 DisposeHandle( macText
) ;
1898 if (!(**theControl
).contrlVis
)
1902 AGAPortHelper
help((**theControl
).contrlOwner
) ;
1903 AGASetFontStyle( &info
->fontStyle
) ;
1904 int x
= (**theControl
).contrlRect
.left
;
1905 int y
= (**theControl
).contrlRect
.top
;
1908 ::GetFontInfo( &fi
) ;
1911 lineheight
= fi
.ascent
+ fi
.descent
+ fi
.leading
;
1912 int length
= GetHandleSize( macText
) ;
1918 RGBColor gray
= { 0xDDDD , 0xDDDD, 0xDDDD } ;
1919 ::RGBBackColor( &gray
) ;
1922 if ( (*macText
)[i
] == 0x0d )
1925 ::DrawText( *macText
, laststop
, i
-laststop
);
1932 ::DrawText( *macText
, laststop
, i
-laststop
);
1934 HUnlock( macText
) ;
1939 case kControlMsgCalcBestRect
:
1941 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1942 rec
->width
= (**theControl
).contrlRect
.right
- (**theControl
).contrlRect
.left
;
1943 rec
->height
= (**theControl
).contrlRect
.bottom
- (**theControl
).contrlRect
.top
;
1947 case kControlMsgSetData
:
1949 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
1950 if ( rec
->tag
== kControlStaticTextTextTag
)
1952 SetHandleSize( macText
, rec
->size
) ;
1953 memcpy( *macText
, rec
->dataPtr
, rec
->size
) ;
1956 return errDataNotSupported
;
1965 void AGAMoveControl(ControlHandle inControl
, short x
, short y
)
1967 if ( AGATestForNewControl( inControl
) )
1969 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
1970 if ( info
->magic
== kExtCDEFMagic
)
1972 if ( info
->procID
== kControlEditTextProc
)
1977 dx
= x
- (**inControl
).contrlRect
.left
;
1978 dy
= y
- (**inControl
).contrlRect
.top
;
1980 MoveControl( inControl
, x
,y
) ;
1983 macTE
= (TEHandle
) (**inControl
).contrlData
;
1984 (**macTE
).destRect
.left
+= dx
;
1985 (**macTE
).destRect
.top
+= dy
;
1986 (**macTE
).destRect
.right
+= dx
;
1987 (**macTE
).destRect
.bottom
+= dy
;
1988 (**macTE
).viewRect
.left
+= dx
;
1989 (**macTE
).viewRect
.top
+= dy
;
1990 (**macTE
).viewRect
.right
+= dx
;
1991 (**macTE
).viewRect
.bottom
+= dy
;
1994 if ( info
->procID
== kControlListBoxProc
)
1999 dx
= x
- (**inControl
).contrlRect
.left
;
2000 dy
= y
- (**inControl
).contrlRect
.top
;
2002 MoveControl( inControl
, x
,y
) ;
2003 ListHandle macList
;
2005 macList
= (ListHandle
) (**inControl
).contrlData
;
2006 (**macList
).rView
.left
+= dx
;
2007 (**macList
).rView
.top
+= dy
;
2008 (**macList
).rView
.right
+= dx
;
2009 (**macList
).rView
.bottom
+= dy
;
2014 MoveControl( inControl
, x
,y
) ;
2017 void AGASizeControl(ControlHandle inControl
, short x
, short y
)
2019 if ( AGATestForNewControl( inControl
) )
2021 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
2022 if ( info
->magic
== kExtCDEFMagic
)
2024 if ( info
->procID
== kControlEditTextProc
)
2029 dx
= x
- ( (**inControl
).contrlRect
.right
- (**inControl
).contrlRect
.left
) ;
2030 dy
= y
- ( (**inControl
).contrlRect
.bottom
- (**inControl
).contrlRect
.top
) ;
2032 SizeControl( inControl
, x
,y
) ;
2035 macTE
= (TEHandle
) (**inControl
).contrlData
;
2036 (**macTE
).destRect
.right
+= dx
;
2037 (**macTE
).destRect
.bottom
+= dy
;
2038 (**macTE
).viewRect
.right
+= dx
;
2039 (**macTE
).viewRect
.bottom
+= dy
;
2042 if ( info
->procID
== kControlListBoxProc
)
2047 dx
= x
- ( (**inControl
).contrlRect
.right
- (**inControl
).contrlRect
.left
) ;
2048 dy
= y
- ( (**inControl
).contrlRect
.bottom
- (**inControl
).contrlRect
.top
) ;
2050 SizeControl( inControl
, x
,y
) ;
2051 ListHandle macList
;
2053 macList
= (ListHandle
) (**inControl
).contrlData
;
2054 (**macList
).rView
.right
+= dx
;
2055 (**macList
).rView
.bottom
+= dy
;
2060 SizeControl( inControl
, x
,y
) ;
2063 pascal SInt32
AGARootControlDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
2065 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
2075 case kControlMsgCalcBestRect
:
2077 case kControlMsgSetData
:
2085 pascal SInt32
AGAEditTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
2087 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
2091 macTE
= (TEHandle
) (**theControl
).contrlData
;
2097 AGAPortHelper
help((**theControl
).contrlOwner
) ;
2098 SetPort( (**theControl
).contrlOwner
) ;
2099 ::TextFont( kFontIDGeneva
) ;
2102 RGBBackColor( &gAGARamp
[ kAGAWhite
] ) ;
2103 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
2104 Rect bounds
= (**theControl
).contrlRect
;
2105 InsetRect( &bounds
, 4 , 1 ) ;
2107 ::GetFontInfo( &fi
) ;
2109 bounds
.top
= bounds
.bottom
- abs( fi
.descent
) - fi
.ascent
- 3;
2110 macTE
= TENew( &bounds
, &bounds
) ;
2111 (**theControl
).contrlData
= (Handle
) macTE
;
2115 TEDispose( macTE
) ;
2119 AGAPortHelper
help((**theControl
).contrlOwner
) ;
2120 AGASetFontStyle( &info
->fontStyle
) ;
2121 SetPort( (**theControl
).contrlOwner
) ;
2122 RGBBackColor( &gAGARamp
[ kAGAWhite
] ) ;
2123 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
2124 EraseRect( &(**theControl
).contrlRect
) ;
2125 FrameRect( &(**theControl
).contrlRect
) ;
2126 TEUpdate( &(**theControl
).contrlRect
, macTE
) ;
2132 pt
.h
= LoWord( param
) ;
2133 pt
.v
= HiWord( param
) ;
2134 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
2135 return kControlButtonPart
;
2143 pt
.h
= LoWord( param
) ;
2144 pt
.v
= HiWord( param
) ;
2145 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
2147 TEClick( pt
, false , macTE
) ;
2151 case kControlMsgGetData
:
2153 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
2154 if ( rec
->tag
== kControlEditTextTEHandleTag
)
2156 return AGAGetDataHelper( rec
, sizeof( TEHandle
) , (char*) &macTE
) ;
2158 else if ( rec
->tag
== kControlEditTextTextTag
)
2160 return AGAGetDataHelper( rec
, (**macTE
).teLength
, (char*) *(**macTE
).hText
) ;
2162 else if ( rec
->tag
== kControlEditTextSelectionTag
)
2165 return errDataNotSupported
;
2168 case kControlMsgSetData
:
2170 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
2171 if ( rec
->tag
== kControlEditTextTextTag
)
2173 TESetText( rec
->dataPtr
, rec
->size
, macTE
) ;
2176 return errDataNotSupported
;
2178 case kControlMsgCalcBestRect
:
2180 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
2181 rec
->width
= (**theControl
).contrlRect
.right
- (**theControl
).contrlRect
.left
;
2182 rec
->height
= (**theControl
).contrlRect
.bottom
- (**theControl
).contrlRect
.top
;
2185 case kControlMsgFocus
:
2187 if ( param
== kControlFocusNoPart
)
2189 info
->hasFocus
= false ;
2190 TEDeactivate( macTE
) ;
2191 return kControlFocusNoPart
;
2193 else if ( param
== kControlFocusNextPart
|| param
== kControlFocusPrevPart
)
2195 if ( info
->hasFocus
)
2197 info
->hasFocus
= false ;
2198 TEDeactivate( macTE
) ;
2199 return kControlFocusNoPart
;
2203 info
->hasFocus
= true ;
2204 TEActivate( macTE
) ;
2205 return kControlEditTextPart
;
2208 else if ( param
== kControlEditTextPart
)
2210 if ( !info
->hasFocus
)
2212 info
->hasFocus
= true ;
2213 TEActivate( macTE
) ;
2214 return kControlEditTextPart
;
2219 case kControlMsgIdle
:
2224 case kControlMsgKeyDown
:
2226 AGAPortHelper
help( (**theControl
).contrlOwner
) ;
2227 AGASetFontStyle( &info
->fontStyle
) ;
2228 RGBBackColor( &gAGARamp
[ kAGAWhite
] ) ;
2229 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
2230 ControlKeyDownRec
* rec
= (ControlKeyDownRec
*) param
;
2231 TEKey( rec
->charCode
, macTE
) ;
2234 case kControlMsgActivate
:
2238 TEActivate( macTE ) ;
2240 TEDeactivate( macTE ) ;
2245 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
2247 case kControlMsgTestNewMsgSupport
:
2248 return kControlSupportsNewMessages
;
2249 case kControlMsgGetFeatures
:
2251 // kControlSupportsGhosting |
2252 // kControlSupportsEmbedding |
2253 kControlSupportsFocus
|
2255 kControlWantsActivate
|
2256 // kControlHandlesTracking |
2257 kControlSupportsDataAccess
|
2258 // kControlHasSpecialBackground |
2259 // kControlGetsFocusOnClick |
2260 kControlSupportsCalcBestRect
|
2261 // kControlSupportsLiveFeedback |
2262 // kControlHasRadioBehavior |
2271 pascal SInt32
AGAListControlDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
2274 ListHandle macList
;
2275 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
2277 macList
= (ListHandle
) (**theControl
).contrlData
;
2279 static inLoop
= false ;
2280 static lastClick
= NULL
;
2286 Rect databounds
= { 0,0,0,0} ;
2287 Point cellsize
= { 0,0} ;
2288 Rect listBounds
= (**theControl
).contrlRect
;
2290 InsetRect( &listBounds
, 1 , 1 ) ;
2292 macList
= LNew( &listBounds
, &databounds
, cellsize
, 128 ,
2293 (**theControl
).contrlOwner
, false /*drawit*/ , false /*hasGrow*/,
2294 false /* horzScroll */, true /*vertScroll*/ ) ;
2295 (**theControl
).contrlData
= (Handle
) macList
;
2296 info
->privateData
= NULL
;
2300 (**macList
).vScroll
= NULL
; // will be disposed by the window itself
2301 (**macList
).hScroll
= NULL
; // will be disposed by the window itself
2302 LDispose( macList
) ;
2305 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
2310 pt
.h
= LoWord( param
) ;
2311 pt
.v
= HiWord( param
) ;
2313 Rect allRect
= (**theControl
).contrlRect
;
2314 listRect
= allRect
;
2316 allRect
.right
+= 16 ;
2317 if ( PtInRect( pt
, &allRect
) )
2319 if ( !inLoop
&& StillDown() )
2322 LActivate( true , macList
) ;
2323 Boolean doubleClick
= LClick( pt
, 0 /* todo modifiers*/ , macList
) ;
2324 info
->privateData
= doubleClick
;
2327 return kControlListBoxPart
;
2335 AGAPortHelper
help((**theControl
).contrlOwner
) ;
2336 AGASetFontStyle( &info
->fontStyle
) ;
2337 RGBBackColor( &gAGARamp
[ kAGAWhite
] ) ;
2338 EraseRect( &(**theControl
).contrlRect
) ;
2339 FrameRect( &(**theControl
).contrlRect
) ;
2340 RgnHandle controlRgn
= NewRgn() ;
2341 SetRectRgn( controlRgn
, (**theControl
).contrlRect
.left
,
2342 (**theControl
).contrlRect
.top
,
2343 (**theControl
).contrlRect
.right
,
2344 (**theControl
).contrlRect
.bottom
) ;
2345 LUpdate( controlRgn
, macList
) ;
2351 pt
.h
= LoWord( param
) ;
2352 pt
.v
= HiWord( param
) ;
2354 Rect allRect
= (**theControl
).contrlRect
;
2355 listRect
= allRect
;
2356 allRect
.right
+= 16 ;
2357 if ( PtInRect( pt
, &listRect
) )
2359 if ( !inLoop
&& StillDown() )
2362 LActivate( true , macList
) ;
2363 Boolean doubleClick
= LClick( pt
, 0 /* todo modifiers*/ , macList
) ;
2364 info
->privateData
= doubleClick
;
2367 return kControlListBoxPart
;
2369 else if ( PtInRect( pt
, &allRect
) )
2371 if ( !inLoop
&& StillDown() )
2374 // LActivate( true , macList ) ;
2375 Boolean doubleClick
= LClick( pt
, 0 /* todo modifiers*/ , macList
) ;
2376 info
->privateData
= doubleClick
;
2379 return kControlPageDownPart
;
2385 case kControlMsgGetData
:
2387 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
2388 if ( rec
->tag
== kControlListBoxListHandleTag
)
2390 return AGAGetDataHelper( rec
, sizeof( ListHandle
) , (char*) &macList
) ;
2392 else if ( rec
->tag
== kControlListBoxDoubleClickTag
)
2394 Boolean doubleClick
= info
->privateData
;
2395 return AGAGetDataHelper( rec
, sizeof( Boolean
) , (char*) &doubleClick
) ;
2397 return errDataNotSupported
;
2407 OSErr
AGACreateRootControl (WindowPtr inWindow
,
2408 ControlHandle
* outControl
)
2410 ControlHandle theControl
= NULL
;
2412 SInt16 extCDEFID
= kExtCDEFID
<< 4 + 0 ;
2414 theControl
= NewControl( inWindow
, &inWindow
->portRect
, "\p" , true ,
2415 0 , 0 , 1 , extCDEFID
, 0 ) ;
2416 NewExtCDEFInfo( theControl
, AGARootControlDefProc
, kAGARootControlProcID
, 0 ) ;
2418 *outControl
= theControl
;
2422 OSErr
AGAEmbedControl (ControlHandle inControl
,
2423 ControlHandle inContainer
)
2425 if ( AGATestForNewControl( inControl
) )
2427 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
2428 info
->containerControl
= inContainer
;
2433 void AGADrawControl( ControlHandle control
)
2435 DrawOneControl( control
) ;
2436 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)(**control
).contrlOwner
)->controlList
;
2439 if ( AGATestForNewControl( iter
) )
2441 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**iter
).contrlRfCon
;
2442 if ( info
->containerControl
== control
)
2444 AGADrawControl( iter
) ;
2448 iter
= (**iter
).nextControl
;
2453 ControlHandle
AGANewControl(WindowPtr owningWindow
,
2454 const Rect
* bounds
,
2455 ConstStr255Param controlTitle
,
2456 Boolean initiallyVisible
,
2457 SInt16 initialValue
,
2458 SInt16 minimumValue
,
2459 SInt16 maximumValue
,
2461 SInt32 controlReference
)
2463 ControlHandle theControl
= NULL
;
2464 Rect boundsRect
= *bounds
;
2465 SInt16 extCDEFID
= kExtCDEFID
<< 4 + 0 ;
2466 SInt16 oldProcID
= extCDEFID
;
2469 case kControlScrollBarProc
:
2470 case kControlScrollBarLiveProc
:
2471 oldProcID
= scrollBarProc
;
2473 case kControlListBoxProc
:
2478 if ( oldProcID
== extCDEFID
&& procID
== kControlListBoxProc
)
2480 boundsRect
.right
-= 16 ;
2482 theControl
= NewControl( owningWindow
, &boundsRect
, controlTitle
, initiallyVisible
,
2483 initialValue
, minimumValue
, maximumValue
, oldProcID
, controlReference
) ;
2484 if ( oldProcID
== extCDEFID
)
2486 ControlDefProcPtr theProcPtr
= NULL
;
2487 SInt16 theVarCode
= 0 ;
2490 case kControlPushButtonProc
:
2491 theProcPtr
= AGAButtonDefProc
;
2493 case kControlCheckBoxProc
:
2494 theProcPtr
= AGACheckBoxDefProc
;
2496 case kControlRadioButtonProc
:
2497 theProcPtr
= AGARadioButtonDefProc
;
2499 case kControlProgressBarProc
:
2500 theProcPtr
= AGAProgressBarDefProc
;
2502 case kControlPlacardProc
:
2503 theProcPtr
= AGAPlacardDefProc
;
2505 case kControlStaticTextProc
:
2506 theProcPtr
= AGAStaticTextDefProc
;
2508 case kControlListBoxProc
:
2509 theProcPtr
= AGAListControlDefProc
;
2511 case kControlEditTextProc
:
2512 theProcPtr
= AGAEditTextDefProc
;
2514 case kControlGroupBoxTextTitleProc
:
2515 theProcPtr
= AGAStaticGroupBoxTextDefProc
;
2517 case kControlBevelButtonNormalBevelProc
:
2518 theProcPtr
= AGABevelButtonDefProc
;
2524 NewExtCDEFInfo( theControl
, theProcPtr
, procID
, controlReference
) ;
2530 void AGASetThemeWindowBackground (WindowRef inWindow
,
2536 SetPort( inWindow
) ;
2537 if ( inBrush
== kThemeBrushDialogBackgroundActive
)
2539 gAGABackgroundColor
= 2 ;
2543 gAGABackgroundColor
= 0 ;
2545 RGBBackColor( &gAGAColorArray
[gAGABackgroundColor
] ) ;
2549 void AGAApplyThemeBackground(ThemeBackgroundKind inKind
,
2550 const Rect
* bounds
,
2551 ThemeDrawState inState
,
2557 #endif // !TARGET_CARBON
2559 AGAPortHelper::AGAPortHelper( GrafPtr newport
)
2562 SetPort( newport
) ;
2563 // wxASSERT( newport->portRect.left == 0 && newport->portRect.top == 0 ) ;
2564 GetPenState( &oldPenState
) ;
2565 GetBackColor( &oldBackColor
) ;
2566 GetForeColor( &oldForeColor
) ;
2570 font
= GetPortTextFont( newport
);
2571 size
= GetPortTextSize( newport
);
2572 style
= GetPortTextFace( newport
);
2573 mode
= GetPortTextMode( newport
);
2577 AGAPortHelper::AGAPortHelper()
2581 void AGAPortHelper::Setup( GrafPtr newport
)
2584 SetPort( newport
) ;
2585 // wxASSERT( newport->portRect.left == 0 && newport->portRect.top == 0 ) ;
2586 GetPenState( &oldPenState
) ;
2587 GetBackColor( &oldBackColor
) ;
2588 GetForeColor( &oldForeColor
) ;
2592 font
= GetPortTextFont( newport
);
2593 size
= GetPortTextSize( newport
);
2594 style
= GetPortTextFace( newport
);
2595 mode
= GetPortTextMode( newport
);
2598 void AGAPortHelper::Clear()
2602 DisposeRgn( clip
) ;
2606 AGAPortHelper::~AGAPortHelper()
2612 DisposeRgn( clip
) ;
2613 RGBForeColor(&oldForeColor
);
2614 RGBBackColor(&oldBackColor
);
2615 SetPenState(&oldPenState
);
2621 SetOrigin( 0 , 0 ) ;