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
[] = {
23 {0xFFFF, 0xFFFF, 0xFFFF}, // W
24 {0xEEEE, 0xEEEE, 0xEEEE}, // 1
25 {0xDDDD, 0xDDDD, 0xDDDD}, // 2
26 {0xCCCC, 0xCCCC, 0xCCCC}, // 3
27 {0xBBBB, 0xBBBB, 0xBBBB}, // 4
28 {0xAAAA, 0xAAAA, 0xAAAA}, // 5
29 {0x9999, 0x9999, 0x9999}, // 6
30 {0x8888, 0x8888, 0x8888}, // 7
31 {0x7777, 0x7777, 0x7777}, // 8
32 {0x6666, 0x6666, 0x6666}, // 9
33 {0x5555, 0x5555, 0x5555}, // 10
34 {0x4444, 0x4444, 0x4444}, // 11
35 {0x2222, 0x2222, 0x2222}, // 12
36 {0x0000, 0x0000, 0x0000} // B
39 char LAGADefaultOutline_mCorners
[4][5][5] = {
42 { -1, -1, -1, 12, B
},
50 { B
, 12, -1, -1, -1 },
74 char LAGAPushButton_mCorners
[3][4][4][4] = {
170 RGBColor gAGARamp
[] =
175 { 65535 , 65535 , 65535 } ,
177 { 61166 , 61166 , 61166 } ,
179 { 56797 , 56797 , 56797 } ,
181 { 52428 , 52428 , 52428 } ,
183 { 48059 , 48059 , 48059 } ,
185 { 43690 , 43690 , 43690 } ,
187 { 39321 , 39321 , 39321 } ,
189 { 34952 , 34952 , 34952 } ,
191 { 30583 , 30583 , 30583 } ,
193 { 26214 , 26214 , 26214 } ,
195 { 21845 , 21845 , 21845 } ,
197 { 17476 , 17476 , 17476 } ,
199 { 13107 , 13107 , 13107 } ,
201 { 8738 , 8738 , 8738 } ,
203 { 4369 , 4369 , 4369 } ,
207 RGBColor gAGABlueRamp
[] =
212 { 65535 , 65535 , 65535 } ,
214 { 61166 , 61166 , 65535 } ,
216 { 56797 , 56797 , 65535 } ,
218 { 52428 , 52428 , 65535 } ,
220 { 48059 , 48059 , 65535 } ,
222 { 43690 , 43690 , 65535 } ,
224 { 39321 , 39321 , 65535 } ,
226 { 34952 , 34952 , 65535 } ,
228 { 30583 , 30583 , 65535 } ,
230 { 26214 , 26214 , 65535 } ,
232 { 21845 , 21845 , 65535 } ,
234 { 17476 , 17476 , 65535 } ,
236 { 13107 , 13107 , 65535 } ,
238 { 8738 , 8738 , 65535 } ,
240 { 4369 , 4369 , 65535 } ,
245 kAGATransparent
= -1 ,
266 kAGAStateEnabled
= 0 ,
267 kAGAStatePressed
= 1 ,
268 kAGAStateDisabled
= 2 ,
269 kAGAStateInactive
= 3
273 typedef struct sControlData
275 ControlPartCode m_part ;
280 OSErr AGAFindControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , long *outOffset) ;
281 OSErr AGAFindControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , long *outOffset)
283 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
285 long size = GetHandleSize( info->data ) ;
286 char* data = *(info->data) ;
287 sControlData* current ;
288 while( offset + sizeof( sControlData ) <= size )
290 current = (sControlData*) (data+offset ) ;
291 if ( ( inPart == kControlEntireControl || inPart == current->m_part ) && inTagName == current->m_tag )
293 *outOffset = offset ;
297 return errDataNotSupported ; // nothing found
300 OSErr AGARemoveControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName ) ;
301 OSErr AGARemoveControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName )
303 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
305 long size = GetHandleSize( info->data ) ;
306 char* data = *(info->data) ;
307 sControlData* current ;
308 while( offset + sizeof( sControlData ) <= size )
310 current = (sControlData*) (data+offset ) ;
311 if ( ( inPart == kControlEntireControl || inPart == current->m_part ) && inTagName == current->m_tag )
313 long chunkSize = current->m_size + sizeof ( sControlData ) ;
314 memcpy( data + offset , data + offset + chunkSize , size - offset - chunkSize ) ;
315 SetHandleSize( info->data , size - chunkSize ) ;
322 OSErr AGAAddControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , Size inSize, Ptr inData) ;
323 OSErr AGAAddControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , Size inSize, Ptr inData)
325 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
327 long size = GetHandleSize( info->data ) ;
328 SetHandleSize( info->data , size + sizeof( sControlData ) + inSize ) ;
329 if ( MemError() == noErr )
331 char* data = *(info->data) ;
332 sControlData* current = (sControlData*)( data + size ) ;
333 current->m_tag = inTagName ;
334 current->m_part = inPart ;
335 current->m_size = inSize ;
336 memcpy( data + size + sizeof( sControlData ) , inData , inSize ) ;
339 return errDataNotSupported ;
343 OSErr AGAGetControlDataSize (ControlHandle inControl,
344 ControlPartCode inPart,
349 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
350 char* data = *(info->data) ;
352 OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ;
355 sControlData* current = (sControlData*) (data+offset ) ;
356 *outMaxSize = current->m_size ;
361 OSErr AGAGetControlData (ControlHandle inControl,
362 ControlPartCode inPart,
366 Size * outActualSize)
369 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
370 char* data = *(info->data) ;
372 OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ;
375 sControlData* current = (sControlData*) (data+offset ) ;
376 *outActualSize = current->m_size ;
379 if ( inBufferSize <= current->m_size )
380 memcpy( outBuffer , data + offset + sizeof( sControlData ) , current->m_size ) ;
382 err = errDataNotSupported ;
388 OSErr AGASetControlData (ControlHandle inControl,
389 ControlPartCode inPart,
395 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
396 char* data = *(info->data) ;
398 OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ;
401 sControlData* current = (sControlData*) (data+offset ) ;
402 if ( current->m_size == inSize )
404 memcpy( data + offset + sizeof( sControlData ) , inData , inSize) ;
408 AGARemoveControlData( inControl , inPart , inTagName ) ;
409 AGAAddControlData( inControl , inPart , inTagName , inSize , inData ) ;
414 AGAAddControlData( inControl , inPart , inTagName , inSize , inData ) ;
420 OSErr
AGASetControlFontStyle (ControlHandle inControl
,
421 const ControlFontStyleRec
* inStyle
)
423 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
424 if ( inStyle
->flags
== 0 )
430 if ( inStyle
->flags
& kControlUseFontMask
)
432 info
->fontStyle
.font
= inStyle
->font
;
434 if ( inStyle
->flags
& kControlUseSizeMask
)
436 info
->fontStyle
.size
= inStyle
->size
;
438 if ( inStyle
->flags
& kControlUseFaceMask
)
440 info
->fontStyle
.style
= inStyle
->style
;
442 if ( inStyle
->flags
& kControlUseModeMask
)
444 info
->fontStyle
.mode
= inStyle
->mode
;
446 if ( inStyle
->flags
& kControlUseJustMask
)
448 info
->fontStyle
.just
= inStyle
->just
;
450 if ( inStyle
->flags
& kControlUseForeColorMask
)
452 info
->fontStyle
.foreColor
= inStyle
->foreColor
;
454 if ( inStyle
->flags
& kControlUseBackColorMask
)
456 info
->fontStyle
.backColor
= inStyle
->backColor
;
462 OSErr
AGASetControlData (ControlHandle inControl
,
463 ControlPartCode inPart
,
468 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
469 ControlDataAccessRec rec
;
471 rec
.tag
= inTagName
;
474 rec
.dataPtr
= inData
;
476 return info
->defProc( info
->procID
, inControl
, kControlMsgSetData
, (long) &rec
) ;
479 SInt16
AGAHandleControlKey (ControlHandle inControl
,
484 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
485 ControlKeyDownRec rec
;
487 rec
.modifiers
= inModifiers
;
488 rec
.keyCode
= inKeyCode
;
489 rec
.charCode
= inCharCode
;
491 return info
->defProc( info
->procID
, inControl
, kControlMsgKeyDown
, (long) &rec
) ;
494 ControlPartCode
AGAHandleControlClick (ControlHandle inControl
,
497 ControlActionUPP inAction
)
499 return TrackControl( inControl
, inWhere
, inAction
) ;
502 Boolean
AGATestForNewControl( ControlHandle inControl
)
504 if ( (**inControl
).contrlRfCon
> 0x100 && !( (**inControl
).contrlRfCon
% 2 ) )
506 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
507 return info
->magic
== kExtCDEFMagic
;
511 void AGAIdleControls (WindowPtr inWindow
)
513 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)inWindow
)->controlList
;
516 if ( AGATestForNewControl( iter
) )
518 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**iter
).contrlRfCon
;
519 if ( info
->defProc( info
->procID
, iter
, kControlMsgTestNewMsgSupport
, 0 ) == kControlSupportsNewMessages
)
521 if ( info
->defProc( info
->procID
, iter
, kControlMsgGetFeatures
, 0 ) & kControlWantsIdle
)
523 info
->defProc( info
->procID
, iter
, kControlMsgIdle
, 0 ) ;
528 iter
= (**iter
).nextControl
;
532 void AGAUpdateOneControl( ControlHandle control
, RgnHandle inRgn
)
534 DrawOneControl( control
) ;
535 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)(**control
).contrlOwner
)->controlList
;
538 if ( AGATestForNewControl( iter
) )
540 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**iter
).contrlRfCon
;
541 if ( info
->containerControl
== control
)
543 AGAUpdateOneControl( iter
, inRgn
) ;
547 iter
= (**iter
).nextControl
;
551 void AGAUpdateControls( WindowPtr inWindow
, RgnHandle inRgn
)
554 AGAGetRootControl( inWindow
, &root
) ;
555 AGAUpdateOneControl( root
, inRgn
) ;
557 // and then all others
559 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)inWindow
)->controlList
;
562 if ( AGATestForNewControl( iter
) )
567 DrawOneControl( iter
) ;
570 iter
= (**iter
).nextControl
;
574 OSErr
AGAGetRootControl( WindowPtr inWindow
, ControlHandle
*outControl
)
576 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)inWindow
)->controlList
;
579 if ( AGATestForNewControl( iter
) )
581 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**iter
).contrlRfCon
;
582 if ( info
->procID
== kAGARootControlProcID
)
589 iter
= (**iter
).nextControl
;
594 void AGADeactivateControl( ControlHandle inControl
)
596 if ( AGATestForNewControl( inControl
) )
598 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
599 if ( info
->defProc( info
->procID
, inControl
, kControlMsgTestNewMsgSupport
, 0 ) == kControlSupportsNewMessages
)
601 if ( info
->defProc( info
->procID
, inControl
, kControlMsgGetFeatures
, 0 ) & kControlWantsActivate
)
603 info
->defProc( info
->procID
, inControl
, kControlMsgActivate
, 0 ) ;
609 ::HiliteControl( inControl
, 255 ) ;
613 void AGAActivateControl( ControlHandle inControl
)
615 if ( AGATestForNewControl( inControl
) )
617 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
618 if ( info
->defProc( info
->procID
, inControl
, kControlMsgTestNewMsgSupport
, 0 ) == kControlSupportsNewMessages
)
620 if ( info
->defProc( info
->procID
, inControl
, kControlMsgGetFeatures
, 0 ) & kControlWantsActivate
)
622 info
->defProc( info
->procID
, inControl
, kControlMsgActivate
, 1 ) ;
628 ::HiliteControl( inControl
, 0 ) ;
632 OSErr
AGASetKeyboardFocus (WindowPtr inWindow
,
633 ControlHandle inControl
,
634 ControlFocusPart inPart
)
636 if ( AGATestForNewControl( inControl
) )
638 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
639 if ( info
->defProc( info
->procID
, inControl
, kControlMsgTestNewMsgSupport
, 0 ) == kControlSupportsNewMessages
)
641 if ( info
->defProc( info
->procID
, inControl
, kControlMsgGetFeatures
, 0 ) & kControlSupportsFocus
)
643 return info
->defProc( info
->procID
, inControl
, kControlMsgFocus
, inPart
) ;
647 return errControlDoesntSupportFocus
;
650 OSErr
AGAGetBestControlRect (ControlHandle inControl
,
652 SInt16
* outBaseLineOffset
)
654 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
655 ControlCalcSizeRec rec
;
656 rec
.width
= (**inControl
).contrlRect
.right
- (**inControl
).contrlRect
.left
;
657 rec
.height
= (**inControl
).contrlRect
.bottom
- (**inControl
).contrlRect
.top
;
660 OSErr err
= info
->defProc( info
->procID
, inControl
, kControlMsgCalcBestRect
, (long) &rec
) ;
663 outRect
->left
= outRect
->top
= 0 ;
664 outRect
->right
= rec
. width
;
665 outRect
->bottom
= rec
. height
;
666 *outBaseLineOffset
= rec
. baseLine
;
672 OSErr
AGAGetControlData (ControlHandle inControl
,
673 ControlPartCode inPart
,
677 Size
* outActualSize
)
679 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
680 ControlDataAccessRec rec
;
682 rec
.tag
= inTagName
;
684 rec
.size
= inBufferSize
;
685 rec
.dataPtr
= outBuffer
;
687 OSErr err
= info
->defProc( info
->procID
, inControl
, kControlMsgGetData
, (long) &rec
) ;
688 *outActualSize
= rec
.size
;
692 OSErr
AGAGetControlDataSize (ControlHandle inControl
,
693 ControlPartCode inPart
,
697 return AGAGetControlData( inControl
, inPart
, inTagName
, 0 , NULL
, outMaxSize
) ;
701 void NewExtCDEFInfo( ControlHandle theControl
, ControlDefProcPtr defproc
, SInt16 procID
, long refcon
)
703 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) malloc( sizeof( ExtCDEFInfo
) ) ;
704 info
->defProc
= defproc
;
705 info
->hasFocus
= false ;
706 info
->magic
= kExtCDEFMagic
;
707 info
->contrlRfCon
= refcon
;
708 info
->procID
= procID
;
709 info
->containerControl
= NULL
;
710 info
->children
= NewHandle(0) ;
711 info
->fontStyle
.flags
= 0 ;
712 info
->fontStyle
.font
= 0 ;
713 info
->fontStyle
.size
= 12 ;
714 info
->fontStyle
.style
= 0 ;
715 info
->fontStyle
.mode
= 0 ;
716 info
->fontStyle
.just
= 0 ;
717 info
->fontStyle
.foreColor
= gAGARamp
[ kAGABlack
] ;
718 info
->fontStyle
.backColor
= gAGARamp
[ kAGA2
] ;
719 (**theControl
).contrlRfCon
= (long) info
;
720 defproc( info
->procID
, theControl
, initCntl
, 0) ;
723 void DisposeExtCDEFInfo( ControlHandle theControl
)
725 if ( AGATestForNewControl( theControl
) )
727 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
730 DisposeHandle( info
->children
) ;
731 info
->children
= NULL
;
732 free( (void*) (**theControl
).contrlRfCon
) ;
733 (**theControl
).contrlRfCon
= NULL
;
738 const short kAGAProgressHeight
= 14 ;
740 void AGADrawRectPlacard( const Rect
*inRect
, eAGAState inState
, bool fill
= false ) ;
741 void AGADrawRectProgress( const Rect
*inRect
, eAGAState inState
, double percentage
) ;
743 void AGADrawRectPlacard( const Rect
*inRect
, eAGAState inState
, bool fill
)
745 Rect rect
= *inRect
;
746 RGBColor pixelColor
;
747 if ( inState
== kAGAStateInactive
)
749 RGBForeColor( &gAGARamp
[ kAGA10
] ) ;
753 InsetRect( &rect
, 1 , 1 ) ;
754 RGBForeColor( &gAGARamp
[ kAGA1
] ) ;
760 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
762 InsetRect( &rect
, 1 , 1 ) ;
764 if ( inState
== kAGAStateEnabled
|| inState
== kAGAStateDisabled
)
765 RGBForeColor( &gAGARamp
[ kAGAWhite
] ) ;
767 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
769 MoveTo( rect
.left
, rect
.bottom
- 1 -1 ) ;
770 LineTo( rect
.left
, rect
.top
) ;
771 LineTo( rect
.right
-1-1 , rect
.top
) ;
773 if ( inState
== kAGAStateEnabled
|| inState
== kAGAStateDisabled
)
774 pixelColor
= gAGARamp
[ kAGA2
] ;
776 pixelColor
= gAGARamp
[ kAGA8
] ;
778 SetCPixel( rect
.right
-1 , rect
.top
, &pixelColor
) ;
779 SetCPixel( rect
.left
, rect
.bottom
-1 , &pixelColor
) ;
781 if ( inState
== kAGAStateEnabled
)
782 RGBForeColor( &gAGARamp
[ kAGA5
] ) ;
783 else if ( inState
== kAGAStateDisabled
)
784 RGBForeColor( &gAGARamp
[ kAGA4
] ) ;
786 RGBForeColor( &gAGARamp
[ kAGA6
] ) ;
788 MoveTo( rect
.left
+ 1 , rect
.bottom
-1 ) ;
789 LineTo( rect
.right
-1 , rect
.bottom
-1 ) ;
790 LineTo( rect
.right
-1 , rect
.top
-1 ) ;
794 InsetRect( &rect
, 1 , 1 ) ;
795 if ( inState
== kAGAStateEnabled
|| inState
== kAGAStateDisabled
)
796 RGBForeColor( &gAGARamp
[ kAGA2
] ) ;
798 RGBForeColor( &gAGARamp
[ kAGA8
] ) ;
803 void AGADrawRectProgress( const Rect
*inRect
, eAGAState inState
, double percentage
)
805 Rect rect
= *inRect
;
806 rect
.bottom
= rect
.top
+ 14 ;
807 RGBColor pixelColor
;
809 RGBForeColor( &gAGARamp
[ kAGA5
]) ;
810 MoveTo( rect
.left
, rect
.bottom
- 1 -1 ) ;
811 LineTo( rect
.left
, rect
.top
) ;
812 LineTo( rect
.right
-1-1 , rect
.top
) ;
814 RGBForeColor( &gAGARamp
[ kAGAWhite
] ) ;
815 MoveTo( rect
.left
+ 1 , rect
.bottom
-1 ) ;
816 LineTo( rect
.right
-1 , rect
.bottom
-1 ) ;
817 LineTo( rect
.right
-1 , rect
.top
-1 ) ;
819 InsetRect( &rect
, 1 , 1 ) ;
820 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
822 Rect barLeft
= rect
, barRight
= rect
;
824 int position
= percentage
* ( rect
.right
- rect
.left
) ;
825 barLeft
.right
= barLeft
.left
+ position
;
826 barRight
.left
= barLeft
.left
+ position
;
827 FrameRect( &barLeft
) ;
828 FrameRect( &barRight
) ;
830 InsetRect( &barLeft
, 1 , 1 ) ;
832 InsetRect( &barRight
, 1 , 1 ) ;
834 if ( !EmptyRect( &barRight
) )
836 RGBForeColor( &gAGARamp
[ kAGA10
] ) ;
837 MoveTo( barRight
.left
, barRight
.bottom
-1 ) ;
838 LineTo( barRight
.left
, barRight
.top
) ;
840 if ( !EmptyRect( &barRight
) )
842 RGBForeColor( &gAGARamp
[ kAGA7
] ) ;
843 MoveTo( barRight
.left
, barRight
.bottom
-1 ) ;
844 LineTo( barRight
.left
, barRight
.top
) ;
845 LineTo( barRight
.right
-1-1 , barRight
.top
) ;
846 RGBForeColor( &gAGARamp
[ kAGA2
] ) ;
847 MoveTo( barRight
.left
+ 1 , barRight
.bottom
-1 ) ;
848 LineTo( barRight
.right
-1 , barRight
.bottom
-1 ) ;
849 LineTo( barRight
.right
-1 , barRight
.top
- 1) ;
850 pixelColor
= gAGARamp
[ kAGA4
] ;
851 SetCPixel( barRight
.right
-1 , barRight
.top
, &pixelColor
) ;
852 InsetRect( &barRight
, 1 , 1) ;
853 if ( !EmptyRect( &barRight
) )
855 RGBForeColor( &gAGARamp
[ kAGA4
] ) ;
856 PaintRect( &barRight
) ;
859 if ( !EmptyRect( &barLeft
) )
861 RGBForeColor( &gAGABlueRamp
[ kAGA8
] ) ;
862 MoveTo( barLeft
.left
, barLeft
.bottom
-1 ) ;
863 LineTo( barLeft
.left
, barLeft
.top
) ;
864 LineTo( barLeft
.left
+1 , barLeft
.top
) ;
865 RGBForeColor( &gAGABlueRamp
[ kAGA12
] ) ;
866 MoveTo( barLeft
.left
+ 2, barLeft
.bottom
-1 ) ;
867 LineTo( barLeft
.right
-1 , barLeft
.bottom
-1 ) ;
868 LineTo( barLeft
.right
-1 , barLeft
.top
-1 ) ;
869 RGBForeColor( &gAGABlueRamp
[ kAGA10
] ) ;
870 MoveTo( barLeft
.left
+ 2, barLeft
.top
) ;
871 LineTo( barLeft
.right
-1 , barLeft
.top
) ;
872 pixelColor
= gAGABlueRamp
[ kAGA10
] ;
873 SetCPixel( barLeft
.left
+ 1, barLeft
.bottom
-1 , &pixelColor
) ;
874 InsetRect( &barLeft
, 1 , 1 ) ;
875 if ( !EmptyRect( &barLeft
) )
878 RGBForeColor( &gAGABlueRamp
[ kAGA3
] ) ;
879 PaintRect( &barLeft
) ;
885 SInt32
AGAGetDataHelper( ControlDataAccessRec
*rec
, Size size
, Ptr data
) ;
886 SInt32
AGAGetDataHelper( ControlDataAccessRec
*rec
, Size size
, Ptr data
)
888 if ( rec
->dataPtr
== NULL
)
895 if ( rec
->size
< size
)
896 return errDataSizeMismatch
;
899 memcpy( rec
->dataPtr
, data
, size
) ;
904 void AGASetFontStyle( ControlFontStyleRec
*fontstyle
) ;
905 void AGASetFontStyle( ControlFontStyleRec
*fontstyle
)
907 if( fontstyle
->font
>= 0 )
909 ::TextFont( fontstyle
->font
) ;
910 ::TextSize( fontstyle
->size
) ;
911 ::TextFace( fontstyle
->style
) ;
915 switch( fontstyle
->font
)
917 case kControlFontBigSystemFont
:
918 ::TextFont( systemFont
) ;
922 case kControlFontSmallSystemFont
:
923 ::TextFont( kFontIDGeneva
) ;
927 case kControlFontSmallBoldSystemFont
:
928 ::TextFont( kFontIDGeneva
) ;
934 ::RGBForeColor( &fontstyle
->foreColor
) ;
935 ::RGBBackColor( &fontstyle
->backColor
) ;
938 pascal SInt32
AGAProgressBarDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
944 if (!(**theControl
).contrlVis
)
946 PenState oldPenState
;
947 RGBColor oldForeColor
;
948 RGBColor oldBackColor
;
952 GetPenState( &oldPenState
) ;
953 GetBackColor( &oldBackColor
) ;
954 GetForeColor( &oldForeColor
) ;
957 int theValue
= GetControlValue(theControl
) ;
958 int theMinimum
= GetControlMinimum(theControl
) ;
959 int theMaximum
= GetControlMaximum(theControl
) ;
961 AGADrawRectProgress( &(**theControl
).contrlRect
, kAGAStateEnabled
, (( double )( theValue
- theMinimum
)) / ( theMaximum
-theMinimum
) ) ;
964 RGBForeColor(&oldForeColor
);
965 RGBBackColor(&oldBackColor
);
966 SetPenState(&oldPenState
);
970 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
980 pascal SInt32
AGAPlacardDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
986 if (!(**theControl
).contrlVis
)
988 PenState oldPenState
;
989 RGBColor oldForeColor
;
990 RGBColor oldBackColor
;
994 GetPenState( &oldPenState
) ;
995 GetBackColor( &oldBackColor
) ;
996 GetForeColor( &oldForeColor
) ;
999 AGADrawRectPlacard( &(**theControl
).contrlRect
, kAGAStateEnabled
, true ) ;
1002 RGBForeColor(&oldForeColor
);
1003 RGBBackColor(&oldBackColor
);
1004 SetPenState(&oldPenState
);
1014 pascal SInt32
AGABevelButtonDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1016 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1020 info
->privateData
= (long) malloc( sizeof( ControlButtonContentInfo
) ) ;
1021 memset( (char*) info
->privateData
, 0 , sizeof( ControlButtonContentInfo
) ) ;
1024 free( (void*) info
->privateData
) ;
1026 case kControlMsgSetData
:
1028 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
1029 if ( rec
->tag
== kControlBevelButtonContentTag
)
1031 memcpy( (char*) info
->privateData
, rec
->dataPtr
, rec
->size
) ;
1034 return errDataNotSupported
;
1036 case kControlMsgCalcBestRect
:
1038 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1046 if (!(**theControl
).contrlVis
)
1050 AGAPortHelper
help((**theControl
).contrlOwner
) ;
1051 AGASetFontStyle( &info
->fontStyle
) ;
1052 Boolean mRadioBehavior
= false ;
1054 int mValue
= GetControlValue( theControl
) ;
1055 long theValue
= (mRadioBehavior
? mValue
: 0);
1056 Boolean inPushed
= (**theControl
).contrlHilite
;
1057 Boolean down
= inPushed
|| (theValue
!= 0);
1058 Boolean hasColor
= 1;
1060 int triState_Off
= 3 ;
1061 Boolean disabled
= (mEnabled
== triState_Off
);
1063 Rect frame
= (**theControl
).contrlRect
;
1065 // Draw the black frame;
1066 ::MoveTo(frame
.left
+ 1, frame
.top
);
1067 ::LineTo(frame
.right
- 2, frame
.top
);
1068 ::MoveTo(frame
.right
- 1, frame
.top
+ 1);
1069 ::LineTo(frame
.right
- 1, frame
.bottom
- 2);
1070 ::MoveTo(frame
.right
- 2, frame
.bottom
- 1);
1071 ::LineTo(frame
.left
+ 1, frame
.bottom
- 1);
1072 ::MoveTo(frame
.left
, frame
.bottom
- 2);
1073 ::LineTo(frame
.left
, frame
.top
+ 1);
1075 // Draw the inside (w/o the Icon)
1076 ::InsetRect(&frame
, 1, 1);
1079 AGASetFontStyle( &info
->fontStyle
) ;
1081 ::RGBBackColor(&gAGAColorArray
[4]);
1083 ::EraseRect(&frame
);
1088 ::RGBForeColor(&gAGAColorArray
[7]);
1091 ::MoveTo(frame
.left
, frame
.bottom
- 1);
1092 ::LineTo(frame
.left
, frame
.top
);
1093 ::LineTo(frame
.right
- 1, frame
.top
);
1097 ::MoveTo(frame
.right
- 1, frame
.top
);
1098 ::LineTo(frame
.right
- 1, frame
.bottom
- 1);
1099 ::LineTo(frame
.left
, frame
.bottom
- 1);
1100 ::MoveTo(frame
.right
- 2, frame
.top
+ 1);
1101 ::LineTo(frame
.right
- 2, frame
.bottom
- 2);
1102 ::LineTo(frame
.left
+ 1, frame
.bottom
- 2);
1103 ::ForeColor(whiteColor
);
1104 ::MoveTo(frame
.left
, frame
.bottom
- 2);
1105 ::LineTo(frame
.left
, frame
.top
);
1106 ::LineTo(frame
.right
- 2, frame
.top
);
1112 frame
= (**theControl
).contrlRect
;
1114 PicHandle thePict
= ((ControlButtonContentInfo
*) info
->privateData
)->u
.picture
;
1117 GetPictInfo( thePict
, &theInfo
, 0 , 0 , systemMethod
, 0 ) ;
1118 Rect bitmaprect
= { 0 , 0 , theInfo
.sourceRect
.bottom
- theInfo
.sourceRect
.top
,
1119 theInfo
.sourceRect
.right
- theInfo
.sourceRect
.left
} ;
1120 ::OffsetRect( &bitmaprect
, (frame
.right
+ frame
.left
)/2 - bitmaprect
.right
/ 2 , (frame
.bottom
+ frame
.top
) / 2 - bitmaprect
.bottom
/ 2 ) ;
1122 ::OffsetRect( &bitmaprect
, 1 , 1 ) ;
1123 ::DrawPicture( thePict
, &bitmaprect
) ;
1131 pt
.h
= LoWord( param
) ;
1132 pt
.v
= HiWord( param
) ;
1133 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1134 return kControlButtonPart
;
1140 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1145 pt
.h
= LoWord( param
) ;
1146 pt
.v
= HiWord( param
) ;
1147 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1148 return kControlButtonPart
;
1160 pascal SInt32
AGAButtonDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1162 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1166 (**theControl
).contrlData
= NULL
;
1168 case kControlMsgSetData
:
1170 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
1171 Boolean isDefault
= *((Boolean
*)rec
->dataPtr
) ;
1172 (**theControl
).contrlData
= (Handle
) isDefault
;
1176 case kControlMsgCalcBestRect
:
1178 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1186 if (!(**theControl
).contrlVis
)
1190 AGAPortHelper
help((**theControl
).contrlOwner
) ;
1191 AGASetFontStyle( &info
->fontStyle
) ;
1192 Boolean mRadioBehavior
= false ;
1194 Rect frame
, tempRect
;
1195 int mValue
= GetControlValue( theControl
) ;
1196 long theValue
= (mRadioBehavior
? mValue
: 0);
1197 Boolean inPushed
= (**theControl
).contrlHilite
;
1198 Boolean down
= inPushed
|| (theValue
!= 0);
1199 Boolean hasColor
= 1;
1201 int triState_Off
= 3 ;
1202 Boolean disabled
= (mEnabled
== triState_Off
);
1204 // theState.Normalize();
1205 // CalcLocalFrameRect(frame);
1206 frame
= (**theControl
).contrlRect
;
1208 if ( (**theControl
).contrlData
)
1210 InsetRect( &frame
, -3 , -3 ) ;
1212 ::MoveTo(frame
.left
+ 3, frame
.top
);
1213 ::LineTo(frame
.right
- 4, frame
.top
);
1214 ::LineTo(frame
.right
- 1, frame
.top
+ 3);
1215 ::LineTo(frame
.right
- 1, frame
.bottom
- 4);
1216 ::LineTo(frame
.right
- 4, frame
.bottom
- 1);
1217 ::LineTo(frame
.left
+ 3, frame
.bottom
- 1);
1218 ::LineTo(frame
.left
, frame
.bottom
- 4);
1219 ::LineTo(frame
.left
, frame
.top
+ 3);
1220 ::LineTo(frame
.left
+ 3, frame
.top
);
1224 const RGBColor
*col
= gAGAColorArray
;
1225 for (int i
= 0; i
< 5; i
++)
1226 for (int j
= 0; j
< 5; j
++)
1228 if (LAGADefaultOutline_mCorners
[0][i
][j
] != -1)
1229 ::SetCPixel(frame
.left
+ j
, frame
.top
+ i
, &col
[LAGADefaultOutline_mCorners
[0][i
][j
]]);
1230 if (LAGADefaultOutline_mCorners
[1][i
][j
] != -1)
1231 ::SetCPixel(frame
.right
- 5 + j
, frame
.top
+ i
, &col
[LAGADefaultOutline_mCorners
[1][i
][j
]]);
1232 if (LAGADefaultOutline_mCorners
[2][i
][j
] != -1)
1233 ::SetCPixel(frame
.left
+ j
, frame
.bottom
- 5 + i
, &col
[LAGADefaultOutline_mCorners
[2][i
][j
]]);
1234 if (LAGADefaultOutline_mCorners
[3][i
][j
] != -1)
1235 ::SetCPixel(frame
.right
- 5 + j
, frame
.bottom
- 5 + i
, &col
[LAGADefaultOutline_mCorners
[3][i
][j
]]);
1238 ::RGBForeColor(&gAGAColorArray
[2]);
1239 ::MoveTo(frame
.left
+ 1, frame
.top
+ 5);
1240 ::LineTo(frame
.left
+ 1, frame
.bottom
- 6);
1241 ::MoveTo(frame
.left
+ 5, frame
.top
+ 1);
1242 ::LineTo(frame
.right
- 6, frame
.top
+ 1);
1244 ::RGBForeColor(&gAGAColorArray
[5]);
1245 ::MoveTo(frame
.left
+ 4, frame
.top
+ 2);
1246 ::LineTo(frame
.right
- 5, frame
.top
+ 2);
1247 ::LineTo(frame
.right
- 3, frame
.top
+ 4);
1248 ::LineTo(frame
.right
- 3, frame
.bottom
- 5);
1249 ::LineTo(frame
.right
- 5, frame
.bottom
- 3);
1250 ::LineTo(frame
.left
+ 4, frame
.bottom
- 3);
1251 ::LineTo(frame
.left
+ 2, frame
.bottom
- 5);
1252 ::LineTo(frame
.left
+ 2, frame
.top
+ 4);
1253 ::LineTo(frame
.left
+ 4, frame
.top
+ 2);
1255 ::RGBForeColor(&gAGAColorArray
[8]);
1256 ::MoveTo(frame
.right
- 2, frame
.top
+ 5);
1257 ::LineTo(frame
.right
- 2, frame
.bottom
- 6);
1258 ::MoveTo(frame
.left
+ 5, frame
.bottom
- 2);
1259 ::LineTo(frame
.right
- 6, frame
.bottom
- 2);
1264 AGASetFontStyle( &info
->fontStyle
) ;
1265 frame
= (**theControl
).contrlRect
;
1268 ::InsetRect(&tempRect
, 1, 1);
1272 ::RGBBackColor(&gAGAColorArray
[4]);
1274 EraseRect(&tempRect
);
1280 ::RGBForeColor(&gAGAColorArray
[7]);
1284 ::MoveTo(frame
.left
+ 2, frame
.top
);
1285 ::LineTo(frame
.right
- 3, frame
.top
);
1286 ::LineTo(frame
.right
- 1, frame
.top
+ 2);
1287 ::LineTo(frame
.right
- 1, frame
.bottom
- 3);
1288 ::LineTo(frame
.right
- 3, frame
.bottom
- 1);
1289 ::LineTo(frame
.left
+ 2, frame
.bottom
- 1);
1290 ::LineTo(frame
.left
, frame
.bottom
- 3);
1291 ::LineTo(frame
.left
, frame
.top
+ 2);
1292 ::LineTo(frame
.left
+ 2, frame
.top
);
1293 if (disabled
&& !hasColor
)
1296 // Draw the four corners around
1299 short pattern
= (disabled
? 2 : (down
? 1 : 0));
1300 const RGBColor
*col
= gAGAColorArray
;
1301 for (int i
= 0; i
< 4; i
++)
1302 for (int j
= 0; j
< 4; j
++)
1304 if (LAGAPushButton_mCorners
[pattern
][0][i
][j
] != -1)
1305 ::SetCPixel(frame
.left
+ j
, frame
.top
+ i
, &col
[LAGAPushButton_mCorners
[pattern
][0][i
][j
]]);
1306 if (LAGAPushButton_mCorners
[pattern
][1][i
][j
] != -1)
1307 ::SetCPixel(frame
.right
- 4 + j
, frame
.top
+ i
, &col
[LAGAPushButton_mCorners
[pattern
][1][i
][j
]]);
1308 if (LAGAPushButton_mCorners
[pattern
][2][i
][j
] != -1)
1309 ::SetCPixel(frame
.left
+ j
, frame
.bottom
- 4 + i
, &col
[LAGAPushButton_mCorners
[pattern
][2][i
][j
]]);
1310 if (LAGAPushButton_mCorners
[pattern
][3][i
][j
] != -1)
1311 ::SetCPixel(frame
.right
- 4 + j
, frame
.bottom
- 4 + i
, &col
[LAGAPushButton_mCorners
[pattern
][3][i
][j
]]);
1315 ::RGBForeColor(&gAGAColorArray
[8]);
1317 ::RGBForeColor(&gAGAColorArray
[2]);
1318 ::MoveTo(frame
.left
+ 1, frame
.top
+ 4);
1319 ::LineTo(frame
.left
+ 1, frame
.bottom
- 5);
1320 ::MoveTo(frame
.left
+ 4, frame
.top
+ 1);
1321 ::LineTo(frame
.right
- 5, frame
.top
+ 1);
1326 ::RGBForeColor(&gAGAColorArray
[1]);
1328 ::ForeColor(whiteColor
);
1329 ::MoveTo(frame
.left
+ 2, frame
.bottom
- 5);
1330 ::LineTo(frame
.left
+ 2, frame
.top
+ 2);
1331 ::LineTo(frame
.right
- 5, frame
.top
+ 2);
1334 ::RGBForeColor(&gAGAColorArray
[5]);
1336 ::RGBForeColor(&gAGAColorArray
[8]);
1337 ::MoveTo(frame
.left
+ 4, frame
.bottom
- 2);
1338 ::LineTo(frame
.right
- 5, frame
.bottom
- 2);
1339 ::MoveTo(frame
.right
- 2, frame
.bottom
- 5);
1340 ::LineTo(frame
.right
- 2, frame
.top
+ 4);
1343 ::RGBForeColor(&gAGAColorArray
[4]);
1345 ::RGBForeColor(&gAGAColorArray
[5]);
1346 ::MoveTo(frame
.left
+ 4, frame
.bottom
- 3);
1347 ::LineTo(frame
.right
- 5, frame
.bottom
- 3);
1348 ::MoveTo(frame
.right
- 3, frame
.bottom
- 5);
1349 ::LineTo(frame
.right
- 3, frame
.top
+ 4);
1352 AGASetFontStyle( &info
->fontStyle
) ;
1353 int x
= ( (**theControl
).contrlRect
.left
+ (**theControl
).contrlRect
.right
) / 2 ;
1354 int y
= ( (**theControl
).contrlRect
.top
+ (**theControl
).contrlRect
.bottom
) / 2 ;
1356 ::GetFontInfo( &fi
) ;
1358 y
+= fi
.ascent
/ 2 ;
1359 int length
= (**theControl
).contrlTitle
[0] ;
1362 int width
= TextWidth( &(**theControl
).contrlTitle
[1] , 0, length
) ;
1365 ::DrawText( &(**theControl
).contrlTitle
[1] , 0, length
);
1374 pt
.h
= LoWord( param
) ;
1375 pt
.v
= HiWord( param
) ;
1376 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1377 return kControlButtonPart
;
1383 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1388 pt
.h
= LoWord( param
) ;
1389 pt
.v
= HiWord( param
) ;
1390 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1391 return kControlButtonPart
;
1403 const int kAGACheckBoxWidth
= 12 ;
1404 const int kAGACheckBoxHeigth
= 12 ;
1406 pascal SInt32
AGACheckBoxDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1408 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1413 if (!(**theControl
).contrlVis
)
1415 PenState oldPenState
;
1416 RGBColor oldForeColor
;
1417 RGBColor oldBackColor
;
1418 RGBColor backColor
;
1419 RGBColor foreColor
;
1423 if (!(**theControl
).contrlVis
)
1427 AGAPortHelper
help((**theControl
).contrlOwner
) ;
1428 Rect frame
= (**theControl
).contrlRect
;
1429 Boolean hasColor
= true;
1430 Boolean disabled
= (*theControl
)->contrlHilite
== 255 ;
1431 int mValue
= GetControlValue( theControl
) ;
1432 Boolean inPushed
= (**theControl
).contrlHilite
;
1434 int triState_Off
= 3 ;
1436 frame
.right
= frame
.left
+ kAGACheckBoxWidth
;
1437 frame
.bottom
= frame
.top
+ kAGACheckBoxHeigth
;
1439 // Draw the frame of the checkbox
1442 ::RGBForeColor(&gAGAColorArray
[7]);
1446 ::FrameRect(&frame
);
1451 ::InsetRect(&frame
, 1, 1);
1453 ::RGBBackColor(inPushed
? &gAGAColorArray
[8] : &gAGAColorArray
[2]);
1454 ::EraseRect(&frame
);
1459 ::RGBForeColor(&gAGAColorArray
[10]);
1461 ForeColor(whiteColor
);
1462 ::MoveTo(frame
.left
, frame
.bottom
- 2);
1463 ::LineTo(frame
.left
, frame
.top
);
1464 ::LineTo(frame
.right
- 2, frame
.top
);
1467 ::RGBForeColor(&gAGAColorArray
[6]);
1469 ::RGBForeColor(mEnabled
!= triState_Off
? &gAGAColorArray
[7] : &gAGAColorArray
[5]);
1470 ::MoveTo(frame
.left
+ 1, frame
.bottom
- 1);
1471 ::LineTo(frame
.right
- 1, frame
.bottom
- 1);
1472 ::LineTo(frame
.right
- 1, frame
.top
+ 1);
1482 ::RGBForeColor(inPushed
? &gAGAColorArray
[10] : &gAGAColorArray
[5]);
1483 ::MoveTo(frame
.left
+ 3, frame
.bottom
- 2);
1484 ::LineTo(frame
.right
- 2, frame
.top
+ 3);
1485 ::MoveTo(frame
.right
- 2, frame
.bottom
- 2);
1486 ::LineTo(frame
.right
- 2, frame
.bottom
- 2);
1488 if (mEnabled
!= triState_Off
)
1489 ::RGBForeColor(inPushed
? &gAGAColorArray
[11] : &gAGAColorArray
[8]);
1490 ::MoveTo(frame
.left
+ 3, frame
.bottom
- 3);
1491 ::LineTo(frame
.right
- 2, frame
.top
+ 2);
1492 ::MoveTo(frame
.right
- 2, frame
.bottom
- 3);
1493 ::LineTo(frame
.right
- 2, frame
.bottom
- 3);
1495 if (mEnabled
!= triState_Off
)
1496 ::ForeColor(blackColor
);
1498 ::RGBForeColor(&gAGAColorArray
[7]);
1500 ::MoveTo(frame
.left
+ 2, frame
.top
+ 1);
1501 ::LineTo(frame
.right
- 3, frame
.bottom
- 4);
1502 ::MoveTo(frame
.left
+ 2, frame
.top
+ 2);
1503 ::LineTo(frame
.right
- 3, frame
.bottom
- 3);
1504 ::MoveTo(frame
.left
+ 2, frame
.bottom
- 4);
1505 ::LineTo(frame
.right
- 3, frame
.top
+ 1);
1506 ::MoveTo(frame
.left
+ 2, frame
.bottom
- 3);
1507 ::LineTo(frame
.right
- 3, frame
.top
+ 2);
1514 ::RGBForeColor(inPushed
? &gAGAColorArray
[10] : &gAGAColorArray
[5]);
1515 ::MoveTo(frame
.left
+ 3, frame
.top
+ 6);
1516 ::LineTo(frame
.right
- 2, frame
.top
+ 6);
1517 ::LineTo(frame
.right
- 2, frame
.top
+ 4);
1519 if (mEnabled
!= triState_Off
)
1520 ::ForeColor(blackColor
);
1522 ::RGBForeColor(&gAGAColorArray
[7]);
1524 ::MoveTo(frame
.left
+ 2, frame
.top
+ 4);
1525 ::LineTo(frame
.right
- 3, frame
.top
+ 4);
1526 ::MoveTo(frame
.left
+ 2, frame
.top
+ 5);
1527 ::LineTo(frame
.right
- 3, frame
.top
+ 5);
1531 if (inPushed
&& !hasColor
)
1534 AGASetFontStyle( &info
->fontStyle
) ;
1535 int x
= (**theControl
).contrlRect
.left
+ kAGACheckBoxWidth
+ 5 ;
1536 int y
= ( (**theControl
).contrlRect
.top
+ (**theControl
).contrlRect
.bottom
) / 2 ;
1538 ::GetFontInfo( &fi
) ;
1540 y
+= fi
.ascent
/ 2 ;
1542 int length
= (**theControl
).contrlTitle
[0] ;
1545 ::DrawText( &(**theControl
).contrlTitle
[1] , 0, length
);
1555 pt
.h
= LoWord( param
) ;
1556 pt
.v
= HiWord( param
) ;
1557 if ( PtInRect( pt
, &(**theControl
).contrlRect
) && ((*theControl
)->contrlVis
!= 0) && ((*theControl
)->contrlHilite
!= 255) )
1558 return kControlCheckBoxPart
;
1566 pt
.h
= LoWord( param
) ;
1567 pt
.v
= HiWord( param
) ;
1568 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1570 if ( (**theControl
).contrlValue
)
1571 (**theControl
).contrlValue
= 0 ;
1573 (**theControl
).contrlValue
= 1 ;
1583 if ( !EmptyRect(&(**theControl
).contrlRect
) )
1584 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1586 case kControlMsgCalcBestRect
:
1588 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1589 rec
->width
= (**theControl
).contrlRect
.right
- (**theControl
).contrlRect
.left
;
1590 rec
->height
= kAGACheckBoxHeigth
;
1601 pascal SInt32
AGARadioButtonDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1604 /* ExtCDEFInfo* info = (ExtCDEFInfo* ) (**theControl).contrlRfCon ;
1609 if (!(**theControl).contrlVis)
1611 PenState oldPenState;
1612 RGBColor oldForeColor ;
1613 RGBColor oldBackColor ;
1614 RGBColor backColor ;
1615 RGBColor foreColor ;
1619 if (!(**theControl).contrlVis)
1623 AGAPortHelper help() ;
1624 Rect frame = (**theControl).contrlRect ;
1625 Boolean hasColor = true;
1626 Boolean disabled = (*theControl)->contrlHilite == 255 ;
1627 int mValue = GetControlValue( theControl ) ;
1628 Boolean inPushed = (**theControl).contrlHilite ;
1630 int triState_Off = 3 ;
1632 frame.right = frame.left + kAGACheckBoxWidth;
1633 frame.bottom = frame.top + kAGACheckBoxHeigth;
1635 // Draw the frame of the checkbox
1638 ::RGBForeColor(&gAGAColorArray[7]);
1642 ::FrameRect(&frame);
1647 ::InsetRect(&frame, 1, 1);
1649 ::RGBBackColor(inPushed ? &gAGAColorArray[8] : &gAGAColorArray[2]);
1650 ::EraseRect(&frame);
1655 ::RGBForeColor(&gAGAColorArray[10]);
1657 ForeColor(whiteColor);
1658 ::MoveTo(frame.left, frame.bottom - 2);
1659 ::LineTo(frame.left, frame.top);
1660 ::LineTo(frame.right - 2, frame.top);
1663 ::RGBForeColor(&gAGAColorArray[6]);
1665 ::RGBForeColor(mEnabled != triState_Off ? &gAGAColorArray[7] : &gAGAColorArray[5]);
1666 ::MoveTo(frame.left + 1, frame.bottom - 1);
1667 ::LineTo(frame.right - 1, frame.bottom - 1);
1668 ::LineTo(frame.right - 1, frame.top + 1);
1678 ::RGBForeColor(inPushed ? &gAGAColorArray[10] : &gAGAColorArray[5]);
1679 ::MoveTo(frame.left + 3, frame.bottom - 2);
1680 ::LineTo(frame.right - 2, frame.top + 3);
1681 ::MoveTo(frame.right - 2, frame.bottom - 2);
1682 ::LineTo(frame.right - 2, frame.bottom - 2);
1684 if (mEnabled != triState_Off)
1685 ::RGBForeColor(inPushed ? &gAGAColorArray[11] : &gAGAColorArray[8]);
1686 ::MoveTo(frame.left + 3, frame.bottom - 3);
1687 ::LineTo(frame.right - 2, frame.top + 2);
1688 ::MoveTo(frame.right - 2, frame.bottom - 3);
1689 ::LineTo(frame.right - 2, frame.bottom - 3);
1691 if (mEnabled != triState_Off)
1692 ::ForeColor(blackColor);
1694 ::RGBForeColor(&gAGAColorArray[7]);
1696 ::MoveTo(frame.left + 2, frame.top + 1);
1697 ::LineTo(frame.right - 3, frame.bottom - 4);
1698 ::MoveTo(frame.left + 2, frame.top + 2);
1699 ::LineTo(frame.right - 3, frame.bottom - 3);
1700 ::MoveTo(frame.left + 2, frame.bottom - 4);
1701 ::LineTo(frame.right - 3, frame.top + 1);
1702 ::MoveTo(frame.left + 2, frame.bottom - 3);
1703 ::LineTo(frame.right - 3, frame.top + 2);
1710 ::RGBForeColor(inPushed ? &gAGAColorArray[10] : &gAGAColorArray[5]);
1711 ::MoveTo(frame.left + 3, frame.top + 6);
1712 ::LineTo(frame.right - 2, frame.top + 6);
1713 ::LineTo(frame.right - 2, frame.top + 4);
1715 if (mEnabled != triState_Off)
1716 ::ForeColor(blackColor);
1718 ::RGBForeColor(&gAGAColorArray[7]);
1720 ::MoveTo(frame.left + 2, frame.top + 4);
1721 ::LineTo(frame.right - 3, frame.top + 4);
1722 ::MoveTo(frame.left + 2, frame.top + 5);
1723 ::LineTo(frame.right - 3, frame.top + 5);
1727 if (inPushed && !hasColor)
1730 AGASetFontStyle( &info->fontStyle ) ;
1731 int x = (**theControl).contrlRect.left + kAGACheckBoxWidth + 5 ;
1732 int y = ( (**theControl).contrlRect.top + (**theControl).contrlRect.bottom ) / 2 ;
1734 ::GetFontInfo( &fi ) ;
1736 y += fi.ascent / 2 ;
1738 int length = (**theControl).contrlTitle[0] ;
1741 ::DrawText( &(**theControl).contrlTitle[1] , 0, length);
1751 pt.h = LoWord( param ) ;
1752 pt.v = HiWord( param ) ;
1753 if ( PtInRect( pt , &(**theControl).contrlRect ) && ((*theControl)->contrlVis != 0) && ((*theControl)->contrlHilite != 255) )
1754 return kControlCheckBoxPart ;
1762 pt.h = LoWord( param ) ;
1763 pt.v = HiWord( param ) ;
1764 if ( PtInRect( pt , &(**theControl).contrlRect ) )
1766 if ( (**theControl).contrlValue )
1767 (**theControl).contrlValue = 0 ;
1769 (**theControl).contrlValue = 1 ;
1779 if ( !EmptyRect(&(**theControl).contrlRect ) )
1780 RectRgn((RgnHandle) param , &(**theControl).contrlRect ) ;
1782 case kControlMsgCalcBestRect :
1784 ControlCalcSizeRec *rec = (ControlCalcSizeRec *) param ;
1785 rec->width = (**theControl).contrlRect.right - (**theControl).contrlRect.left ;
1786 rec->height = kAGACheckBoxHeigth ;
1797 pascal SInt32
AGAStaticGroupBoxTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1799 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1809 if (!(**theControl
).contrlVis
)
1813 bool disabled
= false ;
1814 bool hasColor
= true ;
1815 AGAPortHelper
help((**theControl
).contrlOwner
) ;
1816 AGASetFontStyle( &info
->fontStyle
) ;
1818 ::GetFontInfo( &fi
) ;
1820 Rect labelRect
= (**theControl
).contrlRect
;
1821 Rect theFrame
= (**theControl
).contrlRect
;
1822 int width
= StringWidth((**theControl
).contrlTitle
) ;
1823 theFrame
.top
+= fi
.ascent
+ fi
.leading
>> 1 ;
1824 labelRect
.bottom
= theFrame
.top
+ 8 ;
1825 labelRect
.left
+= 10 ;
1826 labelRect
.right
=labelRect
.left
+ width
+ 6 ;
1833 RGBForeColor( &gAGAColorArray
[4] ) ;
1837 RGBForeColor( &gAGAColorArray
[7] ) ;
1839 FrameRect( &theFrame
) ;
1842 ::RGBForeColor(&gAGAColorArray
[1]);
1844 ::ForeColor(whiteColor
);
1845 ::MoveTo(theFrame
.left
+ 1, theFrame
.bottom
- 2);
1846 ::LineTo(theFrame
.left
+ 1, theFrame
.top
+ 1);
1847 ::LineTo(theFrame
.right
- 2, theFrame
.top
+ 1);
1848 ::MoveTo(theFrame
.left
, theFrame
.bottom
);
1849 ::LineTo(theFrame
.right
, theFrame
.bottom
);
1850 ::LineTo(theFrame
.right
, theFrame
.top
);
1852 AGASetFontStyle( &info
->fontStyle
) ;
1853 ::EraseRect( &labelRect
) ;
1854 ::MoveTo(labelRect
.left
+ 3, labelRect
.top
+ fi
.ascent
+ (fi
.leading
>> 1));
1855 ::DrawString((**theControl
).contrlTitle
);
1859 case kControlMsgCalcBestRect
:
1861 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1862 rec
->width
= (**theControl
).contrlRect
.right
- (**theControl
).contrlRect
.left
;
1863 rec
->height
= (**theControl
).contrlRect
.bottom
- (**theControl
).contrlRect
.top
;
1867 case kControlMsgSetData
:
1870 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1879 pascal SInt32
AGAStaticTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1881 Handle macText
= (**theControl
).contrlData
;
1882 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1888 macText
= NewHandle(0) ;
1889 (**theControl
).contrlData
= (Handle
) macText
;
1893 DisposeHandle( macText
) ;
1897 if (!(**theControl
).contrlVis
)
1901 AGAPortHelper
help((**theControl
).contrlOwner
) ;
1902 AGASetFontStyle( &info
->fontStyle
) ;
1903 int x
= (**theControl
).contrlRect
.left
;
1904 int y
= (**theControl
).contrlRect
.top
;
1907 ::GetFontInfo( &fi
) ;
1910 lineheight
= fi
.ascent
+ fi
.descent
+ fi
.leading
;
1911 int length
= GetHandleSize( macText
) ;
1917 RGBColor gray
= { 0xDDDD , 0xDDDD, 0xDDDD } ;
1918 ::RGBBackColor( &gray
) ;
1921 if ( (*macText
)[i
] == 0x0d )
1924 ::DrawText( *macText
, laststop
, i
-laststop
);
1931 ::DrawText( *macText
, laststop
, i
-laststop
);
1933 HUnlock( macText
) ;
1938 case kControlMsgCalcBestRect
:
1940 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1941 rec
->width
= (**theControl
).contrlRect
.right
- (**theControl
).contrlRect
.left
;
1942 rec
->height
= (**theControl
).contrlRect
.bottom
- (**theControl
).contrlRect
.top
;
1946 case kControlMsgSetData
:
1948 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
1949 if ( rec
->tag
== kControlStaticTextTextTag
)
1951 SetHandleSize( macText
, rec
->size
) ;
1952 memcpy( *macText
, rec
->dataPtr
, rec
->size
) ;
1955 return errDataNotSupported
;
1964 void AGAMoveControl(ControlHandle inControl
, short x
, short y
)
1966 if ( AGATestForNewControl( inControl
) )
1968 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
1969 if ( info
->magic
== kExtCDEFMagic
)
1971 if ( info
->procID
== kControlEditTextProc
)
1976 dx
= x
- (**inControl
).contrlRect
.left
;
1977 dy
= y
- (**inControl
).contrlRect
.top
;
1979 MoveControl( inControl
, x
,y
) ;
1982 macTE
= (TEHandle
) (**inControl
).contrlData
;
1983 (**macTE
).destRect
.left
+= dx
;
1984 (**macTE
).destRect
.top
+= dy
;
1985 (**macTE
).destRect
.right
+= dx
;
1986 (**macTE
).destRect
.bottom
+= dy
;
1987 (**macTE
).viewRect
.left
+= dx
;
1988 (**macTE
).viewRect
.top
+= dy
;
1989 (**macTE
).viewRect
.right
+= dx
;
1990 (**macTE
).viewRect
.bottom
+= dy
;
1993 if ( info
->procID
== kControlListBoxProc
)
1998 dx
= x
- (**inControl
).contrlRect
.left
;
1999 dy
= y
- (**inControl
).contrlRect
.top
;
2001 MoveControl( inControl
, x
,y
) ;
2002 ListHandle macList
;
2004 macList
= (ListHandle
) (**inControl
).contrlData
;
2005 (**macList
).rView
.left
+= dx
;
2006 (**macList
).rView
.top
+= dy
;
2007 (**macList
).rView
.right
+= dx
;
2008 (**macList
).rView
.bottom
+= dy
;
2013 MoveControl( inControl
, x
,y
) ;
2016 void AGASizeControl(ControlHandle inControl
, short x
, short y
)
2018 if ( AGATestForNewControl( inControl
) )
2020 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
2021 if ( info
->magic
== kExtCDEFMagic
)
2023 if ( info
->procID
== kControlEditTextProc
)
2028 dx
= x
- ( (**inControl
).contrlRect
.right
- (**inControl
).contrlRect
.left
) ;
2029 dy
= y
- ( (**inControl
).contrlRect
.bottom
- (**inControl
).contrlRect
.top
) ;
2031 SizeControl( inControl
, x
,y
) ;
2034 macTE
= (TEHandle
) (**inControl
).contrlData
;
2035 (**macTE
).destRect
.right
+= dx
;
2036 (**macTE
).destRect
.bottom
+= dy
;
2037 (**macTE
).viewRect
.right
+= dx
;
2038 (**macTE
).viewRect
.bottom
+= dy
;
2041 if ( info
->procID
== kControlListBoxProc
)
2046 dx
= x
- ( (**inControl
).contrlRect
.right
- (**inControl
).contrlRect
.left
) ;
2047 dy
= y
- ( (**inControl
).contrlRect
.bottom
- (**inControl
).contrlRect
.top
) ;
2049 SizeControl( inControl
, x
,y
) ;
2050 ListHandle macList
;
2052 macList
= (ListHandle
) (**inControl
).contrlData
;
2053 (**macList
).rView
.right
+= dx
;
2054 (**macList
).rView
.bottom
+= dy
;
2059 SizeControl( inControl
, x
,y
) ;
2062 pascal SInt32
AGARootControlDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
2064 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
2074 case kControlMsgCalcBestRect
:
2076 case kControlMsgSetData
:
2084 pascal SInt32
AGAEditTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
2086 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
2090 macTE
= (TEHandle
) (**theControl
).contrlData
;
2096 AGAPortHelper
help((**theControl
).contrlOwner
) ;
2097 SetPort( (**theControl
).contrlOwner
) ;
2098 ::TextFont( kFontIDGeneva
) ;
2101 RGBBackColor( &gAGARamp
[ kAGAWhite
] ) ;
2102 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
2103 Rect bounds
= (**theControl
).contrlRect
;
2104 InsetRect( &bounds
, 4 , 1 ) ;
2106 ::GetFontInfo( &fi
) ;
2108 bounds
.top
= bounds
.bottom
- abs( fi
.descent
) - fi
.ascent
- 3;
2109 macTE
= TENew( &bounds
, &bounds
) ;
2110 (**theControl
).contrlData
= (Handle
) macTE
;
2114 TEDispose( macTE
) ;
2118 AGAPortHelper
help((**theControl
).contrlOwner
) ;
2119 AGASetFontStyle( &info
->fontStyle
) ;
2120 SetPort( (**theControl
).contrlOwner
) ;
2121 RGBBackColor( &gAGARamp
[ kAGAWhite
] ) ;
2122 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
2123 EraseRect( &(**theControl
).contrlRect
) ;
2124 FrameRect( &(**theControl
).contrlRect
) ;
2125 TEUpdate( &(**theControl
).contrlRect
, macTE
) ;
2131 pt
.h
= LoWord( param
) ;
2132 pt
.v
= HiWord( param
) ;
2133 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
2134 return kControlButtonPart
;
2142 pt
.h
= LoWord( param
) ;
2143 pt
.v
= HiWord( param
) ;
2144 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
2146 TEClick( pt
, false , macTE
) ;
2150 case kControlMsgGetData
:
2152 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
2153 if ( rec
->tag
== kControlEditTextTEHandleTag
)
2155 return AGAGetDataHelper( rec
, sizeof( TEHandle
) , (char*) &macTE
) ;
2157 else if ( rec
->tag
== kControlEditTextTextTag
)
2159 return AGAGetDataHelper( rec
, (**macTE
).teLength
, (char*) *(**macTE
).hText
) ;
2161 else if ( rec
->tag
== kControlEditTextSelectionTag
)
2164 return errDataNotSupported
;
2167 case kControlMsgSetData
:
2169 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
2170 if ( rec
->tag
== kControlEditTextTextTag
)
2172 TESetText( rec
->dataPtr
, rec
->size
, macTE
) ;
2175 return errDataNotSupported
;
2177 case kControlMsgCalcBestRect
:
2179 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
2180 rec
->width
= (**theControl
).contrlRect
.right
- (**theControl
).contrlRect
.left
;
2181 rec
->height
= (**theControl
).contrlRect
.bottom
- (**theControl
).contrlRect
.top
;
2184 case kControlMsgFocus
:
2186 if ( param
== kControlFocusNoPart
)
2188 info
->hasFocus
= false ;
2189 TEDeactivate( macTE
) ;
2190 return kControlFocusNoPart
;
2192 else if ( param
== kControlFocusNextPart
|| param
== kControlFocusPrevPart
)
2194 if ( info
->hasFocus
)
2196 info
->hasFocus
= false ;
2197 TEDeactivate( macTE
) ;
2198 return kControlFocusNoPart
;
2202 info
->hasFocus
= true ;
2203 TEActivate( macTE
) ;
2204 return kControlEditTextPart
;
2207 else if ( param
== kControlEditTextPart
)
2209 if ( !info
->hasFocus
)
2211 info
->hasFocus
= true ;
2212 TEActivate( macTE
) ;
2213 return kControlEditTextPart
;
2218 case kControlMsgIdle
:
2223 case kControlMsgKeyDown
:
2225 AGAPortHelper
help( (**theControl
).contrlOwner
) ;
2226 AGASetFontStyle( &info
->fontStyle
) ;
2227 RGBBackColor( &gAGARamp
[ kAGAWhite
] ) ;
2228 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
2229 ControlKeyDownRec
* rec
= (ControlKeyDownRec
*) param
;
2230 TEKey( rec
->charCode
, macTE
) ;
2233 case kControlMsgActivate
:
2237 TEActivate( macTE ) ;
2239 TEDeactivate( macTE ) ;
2244 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
2246 case kControlMsgTestNewMsgSupport
:
2247 return kControlSupportsNewMessages
;
2248 case kControlMsgGetFeatures
:
2250 // kControlSupportsGhosting |
2251 // kControlSupportsEmbedding |
2252 kControlSupportsFocus
|
2254 kControlWantsActivate
|
2255 // kControlHandlesTracking |
2256 kControlSupportsDataAccess
|
2257 // kControlHasSpecialBackground |
2258 // kControlGetsFocusOnClick |
2259 kControlSupportsCalcBestRect
|
2260 // kControlSupportsLiveFeedback |
2261 // kControlHasRadioBehavior |
2270 pascal SInt32
AGAListControlDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
2273 ListHandle macList
;
2274 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
2276 macList
= (ListHandle
) (**theControl
).contrlData
;
2278 static inLoop
= false ;
2279 static lastClick
= NULL
;
2285 Rect databounds
= { 0,0,0,0} ;
2286 Point cellsize
= { 0,0} ;
2287 Rect listBounds
= (**theControl
).contrlRect
;
2289 InsetRect( &listBounds
, 1 , 1 ) ;
2291 macList
= LNew( &listBounds
, &databounds
, cellsize
, 128 ,
2292 (**theControl
).contrlOwner
, false /*drawit*/ , false /*hasGrow*/,
2293 false /* horzScroll */, true /*vertScroll*/ ) ;
2294 (**theControl
).contrlData
= (Handle
) macList
;
2295 info
->privateData
= NULL
;
2299 (**macList
).vScroll
= NULL
; // will be disposed by the window itself
2300 (**macList
).hScroll
= NULL
; // will be disposed by the window itself
2301 LDispose( macList
) ;
2304 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
2309 pt
.h
= LoWord( param
) ;
2310 pt
.v
= HiWord( param
) ;
2312 Rect allRect
= (**theControl
).contrlRect
;
2313 listRect
= allRect
;
2315 allRect
.right
+= 16 ;
2316 if ( PtInRect( pt
, &allRect
) )
2318 if ( !inLoop
&& StillDown() )
2321 LActivate( true , macList
) ;
2322 Boolean doubleClick
= LClick( pt
, 0 /* todo modifiers*/ , macList
) ;
2323 info
->privateData
= doubleClick
;
2326 return kControlListBoxPart
;
2334 AGAPortHelper
help((**theControl
).contrlOwner
) ;
2335 AGASetFontStyle( &info
->fontStyle
) ;
2336 RGBBackColor( &gAGARamp
[ kAGAWhite
] ) ;
2337 EraseRect( &(**theControl
).contrlRect
) ;
2338 FrameRect( &(**theControl
).contrlRect
) ;
2339 RgnHandle controlRgn
= NewRgn() ;
2340 SetRectRgn( controlRgn
, (**theControl
).contrlRect
.left
,
2341 (**theControl
).contrlRect
.top
,
2342 (**theControl
).contrlRect
.right
,
2343 (**theControl
).contrlRect
.bottom
) ;
2344 LUpdate( controlRgn
, macList
) ;
2350 pt
.h
= LoWord( param
) ;
2351 pt
.v
= HiWord( param
) ;
2353 Rect allRect
= (**theControl
).contrlRect
;
2354 listRect
= allRect
;
2355 allRect
.right
+= 16 ;
2356 if ( PtInRect( pt
, &listRect
) )
2358 if ( !inLoop
&& StillDown() )
2361 LActivate( true , macList
) ;
2362 Boolean doubleClick
= LClick( pt
, 0 /* todo modifiers*/ , macList
) ;
2363 info
->privateData
= doubleClick
;
2366 return kControlListBoxPart
;
2368 else if ( PtInRect( pt
, &allRect
) )
2370 if ( !inLoop
&& StillDown() )
2373 // LActivate( true , macList ) ;
2374 Boolean doubleClick
= LClick( pt
, 0 /* todo modifiers*/ , macList
) ;
2375 info
->privateData
= doubleClick
;
2378 return kControlPageDownPart
;
2384 case kControlMsgGetData
:
2386 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
2387 if ( rec
->tag
== kControlListBoxListHandleTag
)
2389 return AGAGetDataHelper( rec
, sizeof( ListHandle
) , (char*) &macList
) ;
2391 else if ( rec
->tag
== kControlListBoxDoubleClickTag
)
2393 Boolean doubleClick
= info
->privateData
;
2394 return AGAGetDataHelper( rec
, sizeof( Boolean
) , (char*) &doubleClick
) ;
2396 return errDataNotSupported
;
2406 OSErr
AGACreateRootControl (WindowPtr inWindow
,
2407 ControlHandle
* outControl
)
2409 ControlHandle theControl
= NULL
;
2411 SInt16 extCDEFID
= kExtCDEFID
<< 4 + 0 ;
2413 theControl
= NewControl( inWindow
, &inWindow
->portRect
, "\p" , true ,
2414 0 , 0 , 1 , extCDEFID
, 0 ) ;
2415 NewExtCDEFInfo( theControl
, AGARootControlDefProc
, kAGARootControlProcID
, 0 ) ;
2417 *outControl
= theControl
;
2421 OSErr
AGAEmbedControl (ControlHandle inControl
,
2422 ControlHandle inContainer
)
2424 if ( AGATestForNewControl( inControl
) )
2426 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
2427 info
->containerControl
= inContainer
;
2432 void AGADrawControl( ControlHandle control
)
2434 DrawOneControl( control
) ;
2435 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)(**control
).contrlOwner
)->controlList
;
2438 if ( AGATestForNewControl( iter
) )
2440 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**iter
).contrlRfCon
;
2441 if ( info
->containerControl
== control
)
2443 AGADrawControl( iter
) ;
2447 iter
= (**iter
).nextControl
;
2452 ControlHandle
AGANewControl(WindowPtr owningWindow
,
2453 const Rect
* bounds
,
2454 ConstStr255Param controlTitle
,
2455 Boolean initiallyVisible
,
2456 SInt16 initialValue
,
2457 SInt16 minimumValue
,
2458 SInt16 maximumValue
,
2460 SInt32 controlReference
)
2462 ControlHandle theControl
= NULL
;
2463 Rect boundsRect
= *bounds
;
2464 SInt16 extCDEFID
= kExtCDEFID
<< 4 + 0 ;
2465 SInt16 oldProcID
= extCDEFID
;
2468 case kControlScrollBarProc
:
2469 case kControlScrollBarLiveProc
:
2470 oldProcID
= scrollBarProc
;
2472 case kControlListBoxProc
:
2477 if ( oldProcID
== extCDEFID
&& procID
== kControlListBoxProc
)
2479 boundsRect
.right
-= 16 ;
2481 theControl
= NewControl( owningWindow
, &boundsRect
, controlTitle
, initiallyVisible
,
2482 initialValue
, minimumValue
, maximumValue
, oldProcID
, controlReference
) ;
2483 if ( oldProcID
== extCDEFID
)
2485 ControlDefProcPtr theProcPtr
= NULL
;
2486 SInt16 theVarCode
= 0 ;
2489 case kControlPushButtonProc
:
2490 theProcPtr
= AGAButtonDefProc
;
2492 case kControlCheckBoxProc
:
2493 theProcPtr
= AGACheckBoxDefProc
;
2495 case kControlRadioButtonProc
:
2496 theProcPtr
= AGARadioButtonDefProc
;
2498 case kControlProgressBarProc
:
2499 theProcPtr
= AGAProgressBarDefProc
;
2501 case kControlPlacardProc
:
2502 theProcPtr
= AGAPlacardDefProc
;
2504 case kControlStaticTextProc
:
2505 theProcPtr
= AGAStaticTextDefProc
;
2507 case kControlListBoxProc
:
2508 theProcPtr
= AGAListControlDefProc
;
2510 case kControlEditTextProc
:
2511 theProcPtr
= AGAEditTextDefProc
;
2513 case kControlGroupBoxTextTitleProc
:
2514 theProcPtr
= AGAStaticGroupBoxTextDefProc
;
2516 case kControlBevelButtonNormalBevelProc
:
2517 theProcPtr
= AGABevelButtonDefProc
;
2523 NewExtCDEFInfo( theControl
, theProcPtr
, procID
, controlReference
) ;
2529 void AGASetThemeWindowBackground (WindowRef inWindow
,
2535 SetPort( inWindow
) ;
2536 if ( inBrush
== kThemeBrushDialogBackgroundActive
)
2538 gAGABackgroundColor
= 2 ;
2542 gAGABackgroundColor
= 0 ;
2544 RGBBackColor( &gAGAColorArray
[gAGABackgroundColor
] ) ;
2548 void AGAApplyThemeBackground(ThemeBackgroundKind inKind
,
2549 const Rect
* bounds
,
2550 ThemeDrawState inState
,
2556 #endif // !TARGET_CARBON
2558 AGAPortHelper::AGAPortHelper( GrafPtr newport
)
2561 SetPort( newport
) ;
2562 // wxASSERT( newport->portRect.left == 0 && newport->portRect.top == 0 ) ;
2563 GetPenState( &oldPenState
) ;
2564 GetBackColor( &oldBackColor
) ;
2565 GetForeColor( &oldForeColor
) ;
2569 font
= GetPortTextFont( newport
);
2570 size
= GetPortTextSize( newport
);
2571 style
= GetPortTextFace( newport
);
2572 mode
= GetPortTextMode( newport
);
2576 AGAPortHelper::AGAPortHelper()
2580 void AGAPortHelper::Setup( GrafPtr newport
)
2583 SetPort( newport
) ;
2584 // wxASSERT( newport->portRect.left == 0 && newport->portRect.top == 0 ) ;
2585 GetPenState( &oldPenState
) ;
2586 GetBackColor( &oldBackColor
) ;
2587 GetForeColor( &oldForeColor
) ;
2591 font
= GetPortTextFont( newport
);
2592 size
= GetPortTextSize( newport
);
2593 style
= GetPortTextFace( newport
);
2594 mode
= GetPortTextMode( newport
);
2597 void AGAPortHelper::Clear()
2601 DisposeRgn( clip
) ;
2605 AGAPortHelper::~AGAPortHelper()
2611 DisposeRgn( clip
) ;
2612 RGBForeColor(&oldForeColor
);
2613 RGBBackColor(&oldBackColor
);
2614 SetPenState(&oldPenState
);
2620 SetOrigin( 0 , 0 ) ;
2622 wxDC::MacInvalidateSetup() ;