1 #include <wx/mac/uma.h>
2 #include <wx/mac/aga.h>
6 pascal SInt32
AGAProgressBarDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
);
7 pascal SInt32
AGAPlacardDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
);
8 pascal SInt32
AGAStaticTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) ;
9 pascal SInt32
AGAListControlDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) ;
10 pascal SInt32
AGAEditTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) ;
11 pascal SInt32
AGAStaticGroupBoxTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
) ;
16 SInt16 kAGARootControlProcID
;
17 int gAGABackgroundColor
= 0 ;
19 const RGBColor gAGAColorArray
[] = { {0xFFFF, 0xFFFF, 0xFFFF}, // W
20 {0xEEEE, 0xEEEE, 0xEEEE}, // 1
21 {0xDDDD, 0xDDDD, 0xDDDD}, // 2
22 {0xCCCC, 0xCCCC, 0xCCCC}, // 3
23 {0xBBBB, 0xBBBB, 0xBBBB}, // 4
24 {0xAAAA, 0xAAAA, 0xAAAA}, // 5
25 {0x9999, 0x9999, 0x9999}, // 6
26 {0x8888, 0x8888, 0x8888}, // 7
27 {0x7777, 0x7777, 0x7777}, // 8
28 {0x6666, 0x6666, 0x6666}, // 9
29 {0x5555, 0x5555, 0x5555}, // 10
30 {0x4444, 0x4444, 0x4444}, // 11
31 {0x2222, 0x2222, 0x2222}, // 12
32 {0x0000, 0x0000, 0x0000} // B
35 char LAGADefaultOutline_mCorners
[4][5][5] = {
38 { -1, -1, -1, 12, B
},
46 { B
, 12, -1, -1, -1 },
70 char LAGAPushButton_mCorners
[3][4][4][4] = {
166 RGBColor gAGARamp
[] =
171 { 65535 , 65535 , 65535 } ,
173 { 61166 , 61166 , 61166 } ,
175 { 56797 , 56797 , 56797 } ,
177 { 52428 , 52428 , 52428 } ,
179 { 48059 , 48059 , 48059 } ,
181 { 43690 , 43690 , 43690 } ,
183 { 39321 , 39321 , 39321 } ,
185 { 34952 , 34952 , 34952 } ,
187 { 30583 , 30583 , 30583 } ,
189 { 26214 , 26214 , 26214 } ,
191 { 21845 , 21845 , 21845 } ,
193 { 17476 , 17476 , 17476 } ,
195 { 13107 , 13107 , 13107 } ,
197 { 8738 , 8738 , 8738 } ,
199 { 4369 , 4369 , 4369 } ,
203 RGBColor gAGABlueRamp
[] =
208 { 65535 , 65535 , 65535 } ,
210 { 61166 , 61166 , 65535 } ,
212 { 56797 , 56797 , 65535 } ,
214 { 52428 , 52428 , 65535 } ,
216 { 48059 , 48059 , 65535 } ,
218 { 43690 , 43690 , 65535 } ,
220 { 39321 , 39321 , 65535 } ,
222 { 34952 , 34952 , 65535 } ,
224 { 30583 , 30583 , 65535 } ,
226 { 26214 , 26214 , 65535 } ,
228 { 21845 , 21845 , 65535 } ,
230 { 17476 , 17476 , 65535 } ,
232 { 13107 , 13107 , 65535 } ,
234 { 8738 , 8738 , 65535 } ,
236 { 4369 , 4369 , 65535 } ,
241 kAGATransparent
= -1 ,
262 kAGAStateEnabled
= 0 ,
263 kAGAStatePressed
= 1 ,
264 kAGAStateDisabled
= 2 ,
265 kAGAStateInactive
= 3
269 typedef struct sControlData
271 ControlPartCode m_part ;
276 OSErr AGAFindControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , long *outOffset) ;
277 OSErr AGAFindControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , long *outOffset)
279 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
281 long size = GetHandleSize( info->data ) ;
282 char* data = *(info->data) ;
283 sControlData* current ;
284 while( offset + sizeof( sControlData ) <= size )
286 current = (sControlData*) (data+offset ) ;
287 if ( ( inPart == kControlEntireControl || inPart == current->m_part ) && inTagName == current->m_tag )
289 *outOffset = offset ;
293 return errDataNotSupported ; // nothing found
296 OSErr AGARemoveControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName ) ;
297 OSErr AGARemoveControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName )
299 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
301 long size = GetHandleSize( info->data ) ;
302 char* data = *(info->data) ;
303 sControlData* current ;
304 while( offset + sizeof( sControlData ) <= size )
306 current = (sControlData*) (data+offset ) ;
307 if ( ( inPart == kControlEntireControl || inPart == current->m_part ) && inTagName == current->m_tag )
309 long chunkSize = current->m_size + sizeof ( sControlData ) ;
310 memcpy( data + offset , data + offset + chunkSize , size - offset - chunkSize ) ;
311 SetHandleSize( info->data , size - chunkSize ) ;
318 OSErr AGAAddControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , Size inSize, Ptr inData) ;
319 OSErr AGAAddControlData( ControlHandle inControl , ControlPartCode inPart , ResType inTagName , Size inSize, Ptr inData)
321 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
323 long size = GetHandleSize( info->data ) ;
324 SetHandleSize( info->data , size + sizeof( sControlData ) + inSize ) ;
325 if ( MemError() == noErr )
327 char* data = *(info->data) ;
328 sControlData* current = (sControlData*)( data + size ) ;
329 current->m_tag = inTagName ;
330 current->m_part = inPart ;
331 current->m_size = inSize ;
332 memcpy( data + size + sizeof( sControlData ) , inData , inSize ) ;
335 return errDataNotSupported ;
339 OSErr AGAGetControlDataSize (ControlHandle inControl,
340 ControlPartCode inPart,
345 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
346 char* data = *(info->data) ;
348 OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ;
351 sControlData* current = (sControlData*) (data+offset ) ;
352 *outMaxSize = current->m_size ;
357 OSErr AGAGetControlData (ControlHandle inControl,
358 ControlPartCode inPart,
362 Size * outActualSize)
365 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
366 char* data = *(info->data) ;
368 OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ;
371 sControlData* current = (sControlData*) (data+offset ) ;
372 *outActualSize = current->m_size ;
375 if ( inBufferSize <= current->m_size )
376 memcpy( outBuffer , data + offset + sizeof( sControlData ) , current->m_size ) ;
378 err = errDataNotSupported ;
384 OSErr AGASetControlData (ControlHandle inControl,
385 ControlPartCode inPart,
391 ExtCDEFInfo* info = (ExtCDEFInfo* ) (**inControl).contrlRfCon ;
392 char* data = *(info->data) ;
394 OSErr err = AGAFindControlData( inControl , inPart , inTagName , &offset ) ;
397 sControlData* current = (sControlData*) (data+offset ) ;
398 if ( current->m_size == inSize )
400 memcpy( data + offset + sizeof( sControlData ) , inData , inSize) ;
404 AGARemoveControlData( inControl , inPart , inTagName ) ;
405 AGAAddControlData( inControl , inPart , inTagName , inSize , inData ) ;
410 AGAAddControlData( inControl , inPart , inTagName , inSize , inData ) ;
416 OSErr
AGASetControlFontStyle (ControlHandle inControl
,
417 const ControlFontStyleRec
* inStyle
)
419 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
420 if ( inStyle
->flags
== 0 )
426 if ( inStyle
->flags
& kControlUseFontMask
)
428 info
->fontStyle
.font
= inStyle
->font
;
430 if ( inStyle
->flags
& kControlUseSizeMask
)
432 info
->fontStyle
.size
= inStyle
->size
;
434 if ( inStyle
->flags
& kControlUseFaceMask
)
436 info
->fontStyle
.style
= inStyle
->style
;
438 if ( inStyle
->flags
& kControlUseModeMask
)
440 info
->fontStyle
.mode
= inStyle
->mode
;
442 if ( inStyle
->flags
& kControlUseJustMask
)
444 info
->fontStyle
.just
= inStyle
->just
;
446 if ( inStyle
->flags
& kControlUseForeColorMask
)
448 info
->fontStyle
.foreColor
= inStyle
->foreColor
;
450 if ( inStyle
->flags
& kControlUseBackColorMask
)
452 info
->fontStyle
.backColor
= inStyle
->backColor
;
458 OSErr
AGASetControlData (ControlHandle inControl
,
459 ControlPartCode inPart
,
464 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
465 ControlDataAccessRec rec
;
467 rec
.tag
= inTagName
;
470 rec
.dataPtr
= inData
;
472 return info
->defProc( info
->procID
, inControl
, kControlMsgSetData
, (long) &rec
) ;
475 SInt16
AGAHandleControlKey (ControlHandle inControl
,
480 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
481 ControlKeyDownRec rec
;
483 rec
.modifiers
= inModifiers
;
484 rec
.keyCode
= inKeyCode
;
485 rec
.charCode
= inCharCode
;
487 return info
->defProc( info
->procID
, inControl
, kControlMsgKeyDown
, (long) &rec
) ;
490 ControlPartCode
AGAHandleControlClick (ControlHandle inControl
,
493 ControlActionUPP inAction
)
495 return TrackControl( inControl
, inWhere
, inAction
) ;
498 Boolean
AGATestForNewControl( ControlHandle inControl
)
500 if ( (**inControl
).contrlRfCon
> 0x100 && !( (**inControl
).contrlRfCon
% 2 ) )
502 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
503 return info
->magic
== kExtCDEFMagic
;
507 void AGAIdleControls (WindowPtr inWindow
)
509 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)inWindow
)->controlList
;
512 if ( AGATestForNewControl( iter
) )
514 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**iter
).contrlRfCon
;
515 if ( info
->defProc( info
->procID
, iter
, kControlMsgTestNewMsgSupport
, 0 ) == kControlSupportsNewMessages
)
517 if ( info
->defProc( info
->procID
, iter
, kControlMsgGetFeatures
, 0 ) & kControlWantsIdle
)
519 info
->defProc( info
->procID
, iter
, kControlMsgIdle
, 0 ) ;
524 iter
= (**iter
).nextControl
;
528 void AGAUpdateOneControl( ControlHandle control
, RgnHandle inRgn
)
530 DrawOneControl( control
) ;
531 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)(**control
).contrlOwner
)->controlList
;
534 if ( AGATestForNewControl( iter
) )
536 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**iter
).contrlRfCon
;
537 if ( info
->containerControl
== control
)
539 AGAUpdateOneControl( iter
, inRgn
) ;
543 iter
= (**iter
).nextControl
;
547 void AGAUpdateControls( WindowPtr inWindow
, RgnHandle inRgn
)
550 AGAGetRootControl( inWindow
, &root
) ;
551 AGAUpdateOneControl( root
, inRgn
) ;
553 // and then all others
555 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)inWindow
)->controlList
;
558 if ( AGATestForNewControl( iter
) )
563 DrawOneControl( iter
) ;
566 iter
= (**iter
).nextControl
;
570 OSErr
AGAGetRootControl( WindowPtr inWindow
, ControlHandle
*outControl
)
572 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)inWindow
)->controlList
;
575 if ( AGATestForNewControl( iter
) )
577 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**iter
).contrlRfCon
;
578 if ( info
->procID
== kAGARootControlProcID
)
585 iter
= (**iter
).nextControl
;
590 void AGADeactivateControl( ControlHandle inControl
)
592 if ( AGATestForNewControl( inControl
) )
594 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
595 if ( info
->defProc( info
->procID
, inControl
, kControlMsgTestNewMsgSupport
, 0 ) == kControlSupportsNewMessages
)
597 if ( info
->defProc( info
->procID
, inControl
, kControlMsgGetFeatures
, 0 ) & kControlWantsActivate
)
599 info
->defProc( info
->procID
, inControl
, kControlMsgActivate
, 0 ) ;
605 void AGAActivateControl( ControlHandle inControl
)
607 if ( AGATestForNewControl( inControl
) )
609 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
610 if ( info
->defProc( info
->procID
, inControl
, kControlMsgTestNewMsgSupport
, 0 ) == kControlSupportsNewMessages
)
612 if ( info
->defProc( info
->procID
, inControl
, kControlMsgGetFeatures
, 0 ) & kControlWantsActivate
)
614 info
->defProc( info
->procID
, inControl
, kControlMsgActivate
, 1 ) ;
620 OSErr
AGASetKeyboardFocus (WindowPtr inWindow
,
621 ControlHandle inControl
,
622 ControlFocusPart inPart
)
624 if ( AGATestForNewControl( inControl
) )
626 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
627 if ( info
->defProc( info
->procID
, inControl
, kControlMsgTestNewMsgSupport
, 0 ) == kControlSupportsNewMessages
)
629 if ( info
->defProc( info
->procID
, inControl
, kControlMsgGetFeatures
, 0 ) & kControlSupportsFocus
)
631 return info
->defProc( info
->procID
, inControl
, kControlMsgFocus
, inPart
) ;
635 return errControlDoesntSupportFocus
;
638 OSErr
AGAGetBestControlRect (ControlHandle inControl
,
640 SInt16
* outBaseLineOffset
)
642 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
643 ControlCalcSizeRec rec
;
644 rec
.width
= (**inControl
).contrlRect
.right
- (**inControl
).contrlRect
.left
;
645 rec
.height
= (**inControl
).contrlRect
.bottom
- (**inControl
).contrlRect
.top
;
648 OSErr err
= info
->defProc( info
->procID
, inControl
, kControlMsgCalcBestRect
, (long) &rec
) ;
651 outRect
->left
= outRect
->top
= 0 ;
652 outRect
->right
= rec
. width
;
653 outRect
->bottom
= rec
. height
;
654 *outBaseLineOffset
= rec
. baseLine
;
660 OSErr
AGAGetControlData (ControlHandle inControl
,
661 ControlPartCode inPart
,
665 Size
* outActualSize
)
667 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
668 ControlDataAccessRec rec
;
670 rec
.tag
= inTagName
;
672 rec
.size
= inBufferSize
;
673 rec
.dataPtr
= outBuffer
;
675 OSErr err
= info
->defProc( info
->procID
, inControl
, kControlMsgGetData
, (long) &rec
) ;
676 *outActualSize
= rec
.size
;
680 OSErr
AGAGetControlDataSize (ControlHandle inControl
,
681 ControlPartCode inPart
,
685 return AGAGetControlData( inControl
, inPart
, inTagName
, 0 , NULL
, outMaxSize
) ;
689 void NewExtCDEFInfo( ControlHandle theControl
, ControlDefProcPtr defproc
, SInt16 procID
, long refcon
)
691 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) malloc( sizeof( ExtCDEFInfo
) ) ;
692 info
->defProc
= defproc
;
693 info
->hasFocus
= false ;
694 info
->magic
= kExtCDEFMagic
;
695 info
->contrlRfCon
= refcon
;
696 info
->procID
= procID
;
697 info
->containerControl
= NULL
;
698 info
->children
= NewHandle(0) ;
699 info
->fontStyle
.flags
= 0 ;
700 info
->fontStyle
.font
= 0 ;
701 info
->fontStyle
.size
= 12 ;
702 info
->fontStyle
.style
= 0 ;
703 info
->fontStyle
.mode
= 0 ;
704 info
->fontStyle
.just
= 0 ;
705 info
->fontStyle
.foreColor
= gAGARamp
[ kAGABlack
] ;
706 info
->fontStyle
.backColor
= gAGARamp
[ kAGA2
] ;
707 (**theControl
).contrlRfCon
= (long) info
;
708 defproc( info
->procID
, theControl
, initCntl
, 0) ;
711 void DisposeExtCDEFInfo( ControlHandle theControl
)
713 if ( AGATestForNewControl( theControl
) )
715 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
718 DisposeHandle( info
->children
) ;
719 info
->children
= NULL
;
720 free( (void*) (**theControl
).contrlRfCon
) ;
725 const short kAGAProgressHeight
= 14 ;
727 void AGADrawRectPlacard( const Rect
*inRect
, eAGAState inState
, bool fill
= false ) ;
728 void AGADrawRectProgress( const Rect
*inRect
, eAGAState inState
, double percentage
) ;
730 void AGADrawRectPlacard( const Rect
*inRect
, eAGAState inState
, bool fill
)
732 Rect rect
= *inRect
;
733 RGBColor pixelColor
;
734 if ( inState
== kAGAStateInactive
)
736 RGBForeColor( &gAGARamp
[ kAGA10
] ) ;
740 InsetRect( &rect
, 1 , 1 ) ;
741 RGBForeColor( &gAGARamp
[ kAGA1
] ) ;
747 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
749 InsetRect( &rect
, 1 , 1 ) ;
751 if ( inState
== kAGAStateEnabled
|| inState
== kAGAStateDisabled
)
752 RGBForeColor( &gAGARamp
[ kAGAWhite
] ) ;
754 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
756 MoveTo( rect
.left
, rect
.bottom
- 1 -1 ) ;
757 LineTo( rect
.left
, rect
.top
) ;
758 LineTo( rect
.right
-1-1 , rect
.top
) ;
760 if ( inState
== kAGAStateEnabled
|| inState
== kAGAStateDisabled
)
761 pixelColor
= gAGARamp
[ kAGA2
] ;
763 pixelColor
= gAGARamp
[ kAGA8
] ;
765 SetCPixel( rect
.right
-1 , rect
.top
, &pixelColor
) ;
766 SetCPixel( rect
.left
, rect
.bottom
-1 , &pixelColor
) ;
768 if ( inState
== kAGAStateEnabled
)
769 RGBForeColor( &gAGARamp
[ kAGA5
] ) ;
770 else if ( inState
== kAGAStateDisabled
)
771 RGBForeColor( &gAGARamp
[ kAGA4
] ) ;
773 RGBForeColor( &gAGARamp
[ kAGA6
] ) ;
775 MoveTo( rect
.left
+ 1 , rect
.bottom
-1 ) ;
776 LineTo( rect
.right
-1 , rect
.bottom
-1 ) ;
777 LineTo( rect
.right
-1 , rect
.top
-1 ) ;
781 InsetRect( &rect
, 1 , 1 ) ;
782 if ( inState
== kAGAStateEnabled
|| inState
== kAGAStateDisabled
)
783 RGBForeColor( &gAGARamp
[ kAGA2
] ) ;
785 RGBForeColor( &gAGARamp
[ kAGA8
] ) ;
790 void AGADrawRectProgress( const Rect
*inRect
, eAGAState inState
, double percentage
)
792 Rect rect
= *inRect
;
793 rect
.bottom
= rect
.top
+ 14 ;
794 RGBColor pixelColor
;
796 RGBForeColor( &gAGARamp
[ kAGA5
]) ;
797 MoveTo( rect
.left
, rect
.bottom
- 1 -1 ) ;
798 LineTo( rect
.left
, rect
.top
) ;
799 LineTo( rect
.right
-1-1 , rect
.top
) ;
801 RGBForeColor( &gAGARamp
[ kAGAWhite
] ) ;
802 MoveTo( rect
.left
+ 1 , rect
.bottom
-1 ) ;
803 LineTo( rect
.right
-1 , rect
.bottom
-1 ) ;
804 LineTo( rect
.right
-1 , rect
.top
-1 ) ;
806 InsetRect( &rect
, 1 , 1 ) ;
807 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
809 Rect barLeft
= rect
, barRight
= rect
;
811 int position
= percentage
* ( rect
.right
- rect
.left
) ;
812 barLeft
.right
= barLeft
.left
+ position
;
813 barRight
.left
= barLeft
.left
+ position
;
814 FrameRect( &barLeft
) ;
815 FrameRect( &barRight
) ;
817 InsetRect( &barLeft
, 1 , 1 ) ;
819 InsetRect( &barRight
, 1 , 1 ) ;
821 if ( !EmptyRect( &barRight
) )
823 RGBForeColor( &gAGARamp
[ kAGA10
] ) ;
824 MoveTo( barRight
.left
, barRight
.bottom
-1 ) ;
825 LineTo( barRight
.left
, barRight
.top
) ;
827 if ( !EmptyRect( &barRight
) )
829 RGBForeColor( &gAGARamp
[ kAGA7
] ) ;
830 MoveTo( barRight
.left
, barRight
.bottom
-1 ) ;
831 LineTo( barRight
.left
, barRight
.top
) ;
832 LineTo( barRight
.right
-1-1 , barRight
.top
) ;
833 RGBForeColor( &gAGARamp
[ kAGA2
] ) ;
834 MoveTo( barRight
.left
+ 1 , barRight
.bottom
-1 ) ;
835 LineTo( barRight
.right
-1 , barRight
.bottom
-1 ) ;
836 LineTo( barRight
.right
-1 , barRight
.top
- 1) ;
837 pixelColor
= gAGARamp
[ kAGA4
] ;
838 SetCPixel( barRight
.right
-1 , barRight
.top
, &pixelColor
) ;
839 InsetRect( &barRight
, 1 , 1) ;
840 if ( !EmptyRect( &barRight
) )
842 RGBForeColor( &gAGARamp
[ kAGA4
] ) ;
843 PaintRect( &barRight
) ;
846 if ( !EmptyRect( &barLeft
) )
848 RGBForeColor( &gAGABlueRamp
[ kAGA8
] ) ;
849 MoveTo( barLeft
.left
, barLeft
.bottom
-1 ) ;
850 LineTo( barLeft
.left
, barLeft
.top
) ;
851 LineTo( barLeft
.left
+1 , barLeft
.top
) ;
852 RGBForeColor( &gAGABlueRamp
[ kAGA12
] ) ;
853 MoveTo( barLeft
.left
+ 2, barLeft
.bottom
-1 ) ;
854 LineTo( barLeft
.right
-1 , barLeft
.bottom
-1 ) ;
855 LineTo( barLeft
.right
-1 , barLeft
.top
-1 ) ;
856 RGBForeColor( &gAGABlueRamp
[ kAGA10
] ) ;
857 MoveTo( barLeft
.left
+ 2, barLeft
.top
) ;
858 LineTo( barLeft
.right
-1 , barLeft
.top
) ;
859 pixelColor
= gAGABlueRamp
[ kAGA10
] ;
860 SetCPixel( barLeft
.left
+ 1, barLeft
.bottom
-1 , &pixelColor
) ;
861 InsetRect( &barLeft
, 1 , 1 ) ;
862 if ( !EmptyRect( &barLeft
) )
865 RGBForeColor( &gAGABlueRamp
[ kAGA3
] ) ;
866 PaintRect( &barLeft
) ;
872 SInt32
AGAGetDataHelper( ControlDataAccessRec
*rec
, Size size
, Ptr data
) ;
873 SInt32
AGAGetDataHelper( ControlDataAccessRec
*rec
, Size size
, Ptr data
)
875 if ( rec
->dataPtr
== NULL
)
882 if ( rec
->size
< size
)
883 return errDataSizeMismatch
;
886 memcpy( rec
->dataPtr
, data
, size
) ;
891 void AGASetFontStyle( ControlFontStyleRec
*fontstyle
) ;
892 void AGASetFontStyle( ControlFontStyleRec
*fontstyle
)
894 if( fontstyle
->font
>= 0 )
896 ::TextFont( fontstyle
->font
) ;
897 ::TextSize( fontstyle
->size
) ;
898 ::TextFace( fontstyle
->style
) ;
902 switch( fontstyle
->font
)
904 case kControlFontBigSystemFont
:
905 ::TextFont( systemFont
) ;
909 case kControlFontSmallSystemFont
:
910 ::TextFont( kFontIDGeneva
) ;
914 case kControlFontSmallBoldSystemFont
:
915 ::TextFont( kFontIDGeneva
) ;
921 ::RGBForeColor( &fontstyle
->foreColor
) ;
922 ::RGBBackColor( &fontstyle
->backColor
) ;
930 GetPenState( &oldPenState
) ;
931 GetBackColor( &oldBackColor
) ;
932 GetForeColor( &oldForeColor
) ;
939 style
= port
->txFace
;
948 RGBForeColor(&oldForeColor
);
949 RGBBackColor(&oldBackColor
);
950 SetPenState(&oldPenState
);
960 PenState oldPenState
;
961 RGBColor oldForeColor
;
962 RGBColor oldBackColor
;
970 pascal SInt32
AGAProgressBarDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
976 if (!(**theControl
).contrlVis
)
978 PenState oldPenState
;
979 RGBColor oldForeColor
;
980 RGBColor oldBackColor
;
984 GetPenState( &oldPenState
) ;
985 GetBackColor( &oldBackColor
) ;
986 GetForeColor( &oldForeColor
) ;
989 int theValue
= GetControlValue(theControl
) ;
990 int theMinimum
= GetControlMinimum(theControl
) ;
991 int theMaximum
= GetControlMaximum(theControl
) ;
993 AGADrawRectProgress( &(**theControl
).contrlRect
, kAGAStateEnabled
, (( double )( theValue
- theMinimum
)) / ( theMaximum
-theMinimum
) ) ;
996 RGBForeColor(&oldForeColor
);
997 RGBBackColor(&oldBackColor
);
998 SetPenState(&oldPenState
);
1002 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1012 pascal SInt32
AGAPlacardDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1018 if (!(**theControl
).contrlVis
)
1020 PenState oldPenState
;
1021 RGBColor oldForeColor
;
1022 RGBColor oldBackColor
;
1023 RGBColor backColor
;
1024 RGBColor foreColor
;
1026 GetPenState( &oldPenState
) ;
1027 GetBackColor( &oldBackColor
) ;
1028 GetForeColor( &oldForeColor
) ;
1031 AGADrawRectPlacard( &(**theControl
).contrlRect
, kAGAStateEnabled
, true ) ;
1034 RGBForeColor(&oldForeColor
);
1035 RGBBackColor(&oldBackColor
);
1036 SetPenState(&oldPenState
);
1046 pascal SInt32
AGABevelButtonDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1048 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1052 info
->privateData
= (long) malloc( sizeof( ControlButtonContentInfo
) ) ;
1053 memset( (char*) info
->privateData
, 0 , sizeof( ControlButtonContentInfo
) ) ;
1056 free( (void*) info
->privateData
) ;
1058 case kControlMsgSetData
:
1060 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
1061 if ( rec
->tag
== kControlBevelButtonContentTag
)
1063 memcpy( (char*) info
->privateData
, rec
->dataPtr
, rec
->size
) ;
1066 return errDataNotSupported
;
1068 case kControlMsgCalcBestRect
:
1070 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1078 if (!(**theControl
).contrlVis
)
1082 AGAPortHelper
help() ;
1083 AGASetFontStyle( &info
->fontStyle
) ;
1084 Boolean mRadioBehavior
= false ;
1086 int mValue
= GetControlValue( theControl
) ;
1087 long theValue
= (mRadioBehavior
? mValue
: 0);
1088 Boolean inPushed
= (**theControl
).contrlHilite
;
1089 Boolean down
= inPushed
|| (theValue
!= 0);
1090 Boolean hasColor
= 1;
1092 int triState_Off
= 3 ;
1093 Boolean disabled
= (mEnabled
== triState_Off
);
1095 Rect frame
= (**theControl
).contrlRect
;
1097 // Draw the black frame;
1098 ::MoveTo(frame
.left
+ 1, frame
.top
);
1099 ::LineTo(frame
.right
- 2, frame
.top
);
1100 ::MoveTo(frame
.right
- 1, frame
.top
+ 1);
1101 ::LineTo(frame
.right
- 1, frame
.bottom
- 2);
1102 ::MoveTo(frame
.right
- 2, frame
.bottom
- 1);
1103 ::LineTo(frame
.left
+ 1, frame
.bottom
- 1);
1104 ::MoveTo(frame
.left
, frame
.bottom
- 2);
1105 ::LineTo(frame
.left
, frame
.top
+ 1);
1107 // Draw the inside (w/o the Icon)
1108 ::InsetRect(&frame
, 1, 1);
1111 AGASetFontStyle( &info
->fontStyle
) ;
1113 ::RGBBackColor(&gAGAColorArray
[4]);
1115 ::EraseRect(&frame
);
1120 ::RGBForeColor(&gAGAColorArray
[7]);
1123 ::MoveTo(frame
.left
, frame
.bottom
- 1);
1124 ::LineTo(frame
.left
, frame
.top
);
1125 ::LineTo(frame
.right
- 1, frame
.top
);
1129 ::MoveTo(frame
.right
- 1, frame
.top
);
1130 ::LineTo(frame
.right
- 1, frame
.bottom
- 1);
1131 ::LineTo(frame
.left
, frame
.bottom
- 1);
1132 ::MoveTo(frame
.right
- 2, frame
.top
+ 1);
1133 ::LineTo(frame
.right
- 2, frame
.bottom
- 2);
1134 ::LineTo(frame
.left
+ 1, frame
.bottom
- 2);
1135 ::ForeColor(whiteColor
);
1136 ::MoveTo(frame
.left
, frame
.bottom
- 2);
1137 ::LineTo(frame
.left
, frame
.top
);
1138 ::LineTo(frame
.right
- 2, frame
.top
);
1144 frame
= (**theControl
).contrlRect
;
1146 PicHandle thePict
= ((ControlButtonContentInfo
*) info
->privateData
)->u
.picture
;
1149 GetPictInfo( thePict
, &theInfo
, 0 , 0 , systemMethod
, 0 ) ;
1150 Rect bitmaprect
= { 0 , 0 , theInfo
.sourceRect
.bottom
- theInfo
.sourceRect
.top
,
1151 theInfo
.sourceRect
.right
- theInfo
.sourceRect
.left
} ;
1152 ::OffsetRect( &bitmaprect
, (frame
.right
+ frame
.left
)/2 - bitmaprect
.right
/ 2 , (frame
.bottom
+ frame
.top
) / 2 - bitmaprect
.bottom
/ 2 ) ;
1154 ::OffsetRect( &bitmaprect
, 1 , 1 ) ;
1155 ::DrawPicture( thePict
, &bitmaprect
) ;
1163 pt
.h
= LoWord( param
) ;
1164 pt
.v
= HiWord( param
) ;
1165 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1166 return kControlButtonPart
;
1172 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1177 pt
.h
= LoWord( param
) ;
1178 pt
.v
= HiWord( param
) ;
1179 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1180 return kControlButtonPart
;
1192 pascal SInt32
AGAButtonDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1194 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1198 (**theControl
).contrlData
= NULL
;
1200 case kControlMsgSetData
:
1202 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
1203 Boolean isDefault
= *((Boolean
*)rec
->dataPtr
) ;
1204 (**theControl
).contrlData
= (Handle
) isDefault
;
1208 case kControlMsgCalcBestRect
:
1210 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1218 if (!(**theControl
).contrlVis
)
1222 AGAPortHelper
help() ;
1223 AGASetFontStyle( &info
->fontStyle
) ;
1224 Boolean mRadioBehavior
= false ;
1226 Rect frame
, tempRect
;
1227 int mValue
= GetControlValue( theControl
) ;
1228 long theValue
= (mRadioBehavior
? mValue
: 0);
1229 Boolean inPushed
= (**theControl
).contrlHilite
;
1230 Boolean down
= inPushed
|| (theValue
!= 0);
1231 Boolean hasColor
= 1;
1233 int triState_Off
= 3 ;
1234 Boolean disabled
= (mEnabled
== triState_Off
);
1236 // theState.Normalize();
1237 // CalcLocalFrameRect(frame);
1238 frame
= (**theControl
).contrlRect
;
1240 if ( (**theControl
).contrlData
)
1242 InsetRect( &frame
, -3 , -3 ) ;
1244 ::MoveTo(frame
.left
+ 3, frame
.top
);
1245 ::LineTo(frame
.right
- 4, frame
.top
);
1246 ::LineTo(frame
.right
- 1, frame
.top
+ 3);
1247 ::LineTo(frame
.right
- 1, frame
.bottom
- 4);
1248 ::LineTo(frame
.right
- 4, frame
.bottom
- 1);
1249 ::LineTo(frame
.left
+ 3, frame
.bottom
- 1);
1250 ::LineTo(frame
.left
, frame
.bottom
- 4);
1251 ::LineTo(frame
.left
, frame
.top
+ 3);
1252 ::LineTo(frame
.left
+ 3, frame
.top
);
1256 const RGBColor
*col
= gAGAColorArray
;
1257 for (int i
= 0; i
< 5; i
++)
1258 for (int j
= 0; j
< 5; j
++)
1260 if (LAGADefaultOutline_mCorners
[0][i
][j
] != -1)
1261 ::SetCPixel(frame
.left
+ j
, frame
.top
+ i
, &col
[LAGADefaultOutline_mCorners
[0][i
][j
]]);
1262 if (LAGADefaultOutline_mCorners
[1][i
][j
] != -1)
1263 ::SetCPixel(frame
.right
- 5 + j
, frame
.top
+ i
, &col
[LAGADefaultOutline_mCorners
[1][i
][j
]]);
1264 if (LAGADefaultOutline_mCorners
[2][i
][j
] != -1)
1265 ::SetCPixel(frame
.left
+ j
, frame
.bottom
- 5 + i
, &col
[LAGADefaultOutline_mCorners
[2][i
][j
]]);
1266 if (LAGADefaultOutline_mCorners
[3][i
][j
] != -1)
1267 ::SetCPixel(frame
.right
- 5 + j
, frame
.bottom
- 5 + i
, &col
[LAGADefaultOutline_mCorners
[3][i
][j
]]);
1270 ::RGBForeColor(&gAGAColorArray
[2]);
1271 ::MoveTo(frame
.left
+ 1, frame
.top
+ 5);
1272 ::LineTo(frame
.left
+ 1, frame
.bottom
- 6);
1273 ::MoveTo(frame
.left
+ 5, frame
.top
+ 1);
1274 ::LineTo(frame
.right
- 6, frame
.top
+ 1);
1276 ::RGBForeColor(&gAGAColorArray
[5]);
1277 ::MoveTo(frame
.left
+ 4, frame
.top
+ 2);
1278 ::LineTo(frame
.right
- 5, frame
.top
+ 2);
1279 ::LineTo(frame
.right
- 3, frame
.top
+ 4);
1280 ::LineTo(frame
.right
- 3, frame
.bottom
- 5);
1281 ::LineTo(frame
.right
- 5, frame
.bottom
- 3);
1282 ::LineTo(frame
.left
+ 4, frame
.bottom
- 3);
1283 ::LineTo(frame
.left
+ 2, frame
.bottom
- 5);
1284 ::LineTo(frame
.left
+ 2, frame
.top
+ 4);
1285 ::LineTo(frame
.left
+ 4, frame
.top
+ 2);
1287 ::RGBForeColor(&gAGAColorArray
[8]);
1288 ::MoveTo(frame
.right
- 2, frame
.top
+ 5);
1289 ::LineTo(frame
.right
- 2, frame
.bottom
- 6);
1290 ::MoveTo(frame
.left
+ 5, frame
.bottom
- 2);
1291 ::LineTo(frame
.right
- 6, frame
.bottom
- 2);
1296 AGASetFontStyle( &info
->fontStyle
) ;
1297 frame
= (**theControl
).contrlRect
;
1300 ::InsetRect(&tempRect
, 1, 1);
1304 ::RGBBackColor(&gAGAColorArray
[4]);
1306 EraseRect(&tempRect
);
1312 ::RGBForeColor(&gAGAColorArray
[7]);
1316 ::MoveTo(frame
.left
+ 2, frame
.top
);
1317 ::LineTo(frame
.right
- 3, frame
.top
);
1318 ::LineTo(frame
.right
- 1, frame
.top
+ 2);
1319 ::LineTo(frame
.right
- 1, frame
.bottom
- 3);
1320 ::LineTo(frame
.right
- 3, frame
.bottom
- 1);
1321 ::LineTo(frame
.left
+ 2, frame
.bottom
- 1);
1322 ::LineTo(frame
.left
, frame
.bottom
- 3);
1323 ::LineTo(frame
.left
, frame
.top
+ 2);
1324 ::LineTo(frame
.left
+ 2, frame
.top
);
1325 if (disabled
&& !hasColor
)
1328 // Draw the four corners around
1331 short pattern
= (disabled
? 2 : (down
? 1 : 0));
1332 const RGBColor
*col
= gAGAColorArray
;
1333 for (int i
= 0; i
< 4; i
++)
1334 for (int j
= 0; j
< 4; j
++)
1336 if (LAGAPushButton_mCorners
[pattern
][0][i
][j
] != -1)
1337 ::SetCPixel(frame
.left
+ j
, frame
.top
+ i
, &col
[LAGAPushButton_mCorners
[pattern
][0][i
][j
]]);
1338 if (LAGAPushButton_mCorners
[pattern
][1][i
][j
] != -1)
1339 ::SetCPixel(frame
.right
- 4 + j
, frame
.top
+ i
, &col
[LAGAPushButton_mCorners
[pattern
][1][i
][j
]]);
1340 if (LAGAPushButton_mCorners
[pattern
][2][i
][j
] != -1)
1341 ::SetCPixel(frame
.left
+ j
, frame
.bottom
- 4 + i
, &col
[LAGAPushButton_mCorners
[pattern
][2][i
][j
]]);
1342 if (LAGAPushButton_mCorners
[pattern
][3][i
][j
] != -1)
1343 ::SetCPixel(frame
.right
- 4 + j
, frame
.bottom
- 4 + i
, &col
[LAGAPushButton_mCorners
[pattern
][3][i
][j
]]);
1347 ::RGBForeColor(&gAGAColorArray
[8]);
1349 ::RGBForeColor(&gAGAColorArray
[2]);
1350 ::MoveTo(frame
.left
+ 1, frame
.top
+ 4);
1351 ::LineTo(frame
.left
+ 1, frame
.bottom
- 5);
1352 ::MoveTo(frame
.left
+ 4, frame
.top
+ 1);
1353 ::LineTo(frame
.right
- 5, frame
.top
+ 1);
1358 ::RGBForeColor(&gAGAColorArray
[1]);
1360 ::ForeColor(whiteColor
);
1361 ::MoveTo(frame
.left
+ 2, frame
.bottom
- 5);
1362 ::LineTo(frame
.left
+ 2, frame
.top
+ 2);
1363 ::LineTo(frame
.right
- 5, frame
.top
+ 2);
1366 ::RGBForeColor(&gAGAColorArray
[5]);
1368 ::RGBForeColor(&gAGAColorArray
[8]);
1369 ::MoveTo(frame
.left
+ 4, frame
.bottom
- 2);
1370 ::LineTo(frame
.right
- 5, frame
.bottom
- 2);
1371 ::MoveTo(frame
.right
- 2, frame
.bottom
- 5);
1372 ::LineTo(frame
.right
- 2, frame
.top
+ 4);
1375 ::RGBForeColor(&gAGAColorArray
[4]);
1377 ::RGBForeColor(&gAGAColorArray
[5]);
1378 ::MoveTo(frame
.left
+ 4, frame
.bottom
- 3);
1379 ::LineTo(frame
.right
- 5, frame
.bottom
- 3);
1380 ::MoveTo(frame
.right
- 3, frame
.bottom
- 5);
1381 ::LineTo(frame
.right
- 3, frame
.top
+ 4);
1384 AGASetFontStyle( &info
->fontStyle
) ;
1385 int x
= ( (**theControl
).contrlRect
.left
+ (**theControl
).contrlRect
.right
) / 2 ;
1386 int y
= ( (**theControl
).contrlRect
.top
+ (**theControl
).contrlRect
.bottom
) / 2 ;
1388 ::GetFontInfo( &fi
) ;
1390 y
+= fi
.ascent
/ 2 ;
1391 int length
= (**theControl
).contrlTitle
[0] ;
1394 int width
= TextWidth( &(**theControl
).contrlTitle
[1] , 0, length
) ;
1397 ::DrawText( &(**theControl
).contrlTitle
[1] , 0, length
);
1406 pt
.h
= LoWord( param
) ;
1407 pt
.v
= HiWord( param
) ;
1408 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1409 return kControlButtonPart
;
1415 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1420 pt
.h
= LoWord( param
) ;
1421 pt
.v
= HiWord( param
) ;
1422 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1423 return kControlButtonPart
;
1435 const int kAGACheckBoxWidth
= 12 ;
1436 const int kAGACheckBoxHeigth
= 12 ;
1438 pascal SInt32
AGACheckBoxDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1440 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1445 if (!(**theControl
).contrlVis
)
1447 PenState oldPenState
;
1448 RGBColor oldForeColor
;
1449 RGBColor oldBackColor
;
1450 RGBColor backColor
;
1451 RGBColor foreColor
;
1455 if (!(**theControl
).contrlVis
)
1459 AGAPortHelper
help() ;
1460 Rect frame
= (**theControl
).contrlRect
;
1461 Boolean hasColor
= true;
1462 Boolean disabled
= (*theControl
)->contrlHilite
== 255 ;
1463 int mValue
= GetControlValue( theControl
) ;
1464 Boolean inPushed
= (**theControl
).contrlHilite
;
1466 int triState_Off
= 3 ;
1468 frame
.right
= frame
.left
+ kAGACheckBoxWidth
;
1469 frame
.bottom
= frame
.top
+ kAGACheckBoxHeigth
;
1471 // Draw the frame of the checkbox
1474 ::RGBForeColor(&gAGAColorArray
[7]);
1478 ::FrameRect(&frame
);
1483 ::InsetRect(&frame
, 1, 1);
1485 ::RGBBackColor(inPushed
? &gAGAColorArray
[8] : &gAGAColorArray
[2]);
1486 ::EraseRect(&frame
);
1491 ::RGBForeColor(&gAGAColorArray
[10]);
1493 ForeColor(whiteColor
);
1494 ::MoveTo(frame
.left
, frame
.bottom
- 2);
1495 ::LineTo(frame
.left
, frame
.top
);
1496 ::LineTo(frame
.right
- 2, frame
.top
);
1499 ::RGBForeColor(&gAGAColorArray
[6]);
1501 ::RGBForeColor(mEnabled
!= triState_Off
? &gAGAColorArray
[7] : &gAGAColorArray
[5]);
1502 ::MoveTo(frame
.left
+ 1, frame
.bottom
- 1);
1503 ::LineTo(frame
.right
- 1, frame
.bottom
- 1);
1504 ::LineTo(frame
.right
- 1, frame
.top
+ 1);
1514 ::RGBForeColor(inPushed
? &gAGAColorArray
[10] : &gAGAColorArray
[5]);
1515 ::MoveTo(frame
.left
+ 3, frame
.bottom
- 2);
1516 ::LineTo(frame
.right
- 2, frame
.top
+ 3);
1517 ::MoveTo(frame
.right
- 2, frame
.bottom
- 2);
1518 ::LineTo(frame
.right
- 2, frame
.bottom
- 2);
1520 if (mEnabled
!= triState_Off
)
1521 ::RGBForeColor(inPushed
? &gAGAColorArray
[11] : &gAGAColorArray
[8]);
1522 ::MoveTo(frame
.left
+ 3, frame
.bottom
- 3);
1523 ::LineTo(frame
.right
- 2, frame
.top
+ 2);
1524 ::MoveTo(frame
.right
- 2, frame
.bottom
- 3);
1525 ::LineTo(frame
.right
- 2, frame
.bottom
- 3);
1527 if (mEnabled
!= triState_Off
)
1528 ::ForeColor(blackColor
);
1530 ::RGBForeColor(&gAGAColorArray
[7]);
1532 ::MoveTo(frame
.left
+ 2, frame
.top
+ 1);
1533 ::LineTo(frame
.right
- 3, frame
.bottom
- 4);
1534 ::MoveTo(frame
.left
+ 2, frame
.top
+ 2);
1535 ::LineTo(frame
.right
- 3, frame
.bottom
- 3);
1536 ::MoveTo(frame
.left
+ 2, frame
.bottom
- 4);
1537 ::LineTo(frame
.right
- 3, frame
.top
+ 1);
1538 ::MoveTo(frame
.left
+ 2, frame
.bottom
- 3);
1539 ::LineTo(frame
.right
- 3, frame
.top
+ 2);
1546 ::RGBForeColor(inPushed
? &gAGAColorArray
[10] : &gAGAColorArray
[5]);
1547 ::MoveTo(frame
.left
+ 3, frame
.top
+ 6);
1548 ::LineTo(frame
.right
- 2, frame
.top
+ 6);
1549 ::LineTo(frame
.right
- 2, frame
.top
+ 4);
1551 if (mEnabled
!= triState_Off
)
1552 ::ForeColor(blackColor
);
1554 ::RGBForeColor(&gAGAColorArray
[7]);
1556 ::MoveTo(frame
.left
+ 2, frame
.top
+ 4);
1557 ::LineTo(frame
.right
- 3, frame
.top
+ 4);
1558 ::MoveTo(frame
.left
+ 2, frame
.top
+ 5);
1559 ::LineTo(frame
.right
- 3, frame
.top
+ 5);
1563 if (inPushed
&& !hasColor
)
1566 AGASetFontStyle( &info
->fontStyle
) ;
1567 int x
= (**theControl
).contrlRect
.left
+ kAGACheckBoxWidth
+ 5 ;
1568 int y
= ( (**theControl
).contrlRect
.top
+ (**theControl
).contrlRect
.bottom
) / 2 ;
1570 ::GetFontInfo( &fi
) ;
1572 y
+= fi
.ascent
/ 2 ;
1574 int length
= (**theControl
).contrlTitle
[0] ;
1577 ::DrawText( &(**theControl
).contrlTitle
[1] , 0, length
);
1587 pt
.h
= LoWord( param
) ;
1588 pt
.v
= HiWord( param
) ;
1589 if ( PtInRect( pt
, &(**theControl
).contrlRect
) && ((*theControl
)->contrlVis
!= 0) && ((*theControl
)->contrlHilite
!= 255) )
1590 return kControlCheckBoxPart
;
1598 pt
.h
= LoWord( param
) ;
1599 pt
.v
= HiWord( param
) ;
1600 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
1602 if ( (**theControl
).contrlValue
)
1603 (**theControl
).contrlValue
= 0 ;
1605 (**theControl
).contrlValue
= 1 ;
1615 if ( !EmptyRect(&(**theControl
).contrlRect
) )
1616 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1618 case kControlMsgCalcBestRect
:
1620 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1621 rec
->width
= (**theControl
).contrlRect
.right
- (**theControl
).contrlRect
.left
;
1622 rec
->height
= kAGACheckBoxHeigth
;
1633 pascal SInt32
AGARadioButtonDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1636 /* ExtCDEFInfo* info = (ExtCDEFInfo* ) (**theControl).contrlRfCon ;
1641 if (!(**theControl).contrlVis)
1643 PenState oldPenState;
1644 RGBColor oldForeColor ;
1645 RGBColor oldBackColor ;
1646 RGBColor backColor ;
1647 RGBColor foreColor ;
1651 if (!(**theControl).contrlVis)
1655 AGAPortHelper help() ;
1656 Rect frame = (**theControl).contrlRect ;
1657 Boolean hasColor = true;
1658 Boolean disabled = (*theControl)->contrlHilite == 255 ;
1659 int mValue = GetControlValue( theControl ) ;
1660 Boolean inPushed = (**theControl).contrlHilite ;
1662 int triState_Off = 3 ;
1664 frame.right = frame.left + kAGACheckBoxWidth;
1665 frame.bottom = frame.top + kAGACheckBoxHeigth;
1667 // Draw the frame of the checkbox
1670 ::RGBForeColor(&gAGAColorArray[7]);
1674 ::FrameRect(&frame);
1679 ::InsetRect(&frame, 1, 1);
1681 ::RGBBackColor(inPushed ? &gAGAColorArray[8] : &gAGAColorArray[2]);
1682 ::EraseRect(&frame);
1687 ::RGBForeColor(&gAGAColorArray[10]);
1689 ForeColor(whiteColor);
1690 ::MoveTo(frame.left, frame.bottom - 2);
1691 ::LineTo(frame.left, frame.top);
1692 ::LineTo(frame.right - 2, frame.top);
1695 ::RGBForeColor(&gAGAColorArray[6]);
1697 ::RGBForeColor(mEnabled != triState_Off ? &gAGAColorArray[7] : &gAGAColorArray[5]);
1698 ::MoveTo(frame.left + 1, frame.bottom - 1);
1699 ::LineTo(frame.right - 1, frame.bottom - 1);
1700 ::LineTo(frame.right - 1, frame.top + 1);
1710 ::RGBForeColor(inPushed ? &gAGAColorArray[10] : &gAGAColorArray[5]);
1711 ::MoveTo(frame.left + 3, frame.bottom - 2);
1712 ::LineTo(frame.right - 2, frame.top + 3);
1713 ::MoveTo(frame.right - 2, frame.bottom - 2);
1714 ::LineTo(frame.right - 2, frame.bottom - 2);
1716 if (mEnabled != triState_Off)
1717 ::RGBForeColor(inPushed ? &gAGAColorArray[11] : &gAGAColorArray[8]);
1718 ::MoveTo(frame.left + 3, frame.bottom - 3);
1719 ::LineTo(frame.right - 2, frame.top + 2);
1720 ::MoveTo(frame.right - 2, frame.bottom - 3);
1721 ::LineTo(frame.right - 2, frame.bottom - 3);
1723 if (mEnabled != triState_Off)
1724 ::ForeColor(blackColor);
1726 ::RGBForeColor(&gAGAColorArray[7]);
1728 ::MoveTo(frame.left + 2, frame.top + 1);
1729 ::LineTo(frame.right - 3, frame.bottom - 4);
1730 ::MoveTo(frame.left + 2, frame.top + 2);
1731 ::LineTo(frame.right - 3, frame.bottom - 3);
1732 ::MoveTo(frame.left + 2, frame.bottom - 4);
1733 ::LineTo(frame.right - 3, frame.top + 1);
1734 ::MoveTo(frame.left + 2, frame.bottom - 3);
1735 ::LineTo(frame.right - 3, frame.top + 2);
1742 ::RGBForeColor(inPushed ? &gAGAColorArray[10] : &gAGAColorArray[5]);
1743 ::MoveTo(frame.left + 3, frame.top + 6);
1744 ::LineTo(frame.right - 2, frame.top + 6);
1745 ::LineTo(frame.right - 2, frame.top + 4);
1747 if (mEnabled != triState_Off)
1748 ::ForeColor(blackColor);
1750 ::RGBForeColor(&gAGAColorArray[7]);
1752 ::MoveTo(frame.left + 2, frame.top + 4);
1753 ::LineTo(frame.right - 3, frame.top + 4);
1754 ::MoveTo(frame.left + 2, frame.top + 5);
1755 ::LineTo(frame.right - 3, frame.top + 5);
1759 if (inPushed && !hasColor)
1762 AGASetFontStyle( &info->fontStyle ) ;
1763 int x = (**theControl).contrlRect.left + kAGACheckBoxWidth + 5 ;
1764 int y = ( (**theControl).contrlRect.top + (**theControl).contrlRect.bottom ) / 2 ;
1766 ::GetFontInfo( &fi ) ;
1768 y += fi.ascent / 2 ;
1770 int length = (**theControl).contrlTitle[0] ;
1773 ::DrawText( &(**theControl).contrlTitle[1] , 0, length);
1783 pt.h = LoWord( param ) ;
1784 pt.v = HiWord( param ) ;
1785 if ( PtInRect( pt , &(**theControl).contrlRect ) && ((*theControl)->contrlVis != 0) && ((*theControl)->contrlHilite != 255) )
1786 return kControlCheckBoxPart ;
1794 pt.h = LoWord( param ) ;
1795 pt.v = HiWord( param ) ;
1796 if ( PtInRect( pt , &(**theControl).contrlRect ) )
1798 if ( (**theControl).contrlValue )
1799 (**theControl).contrlValue = 0 ;
1801 (**theControl).contrlValue = 1 ;
1811 if ( !EmptyRect(&(**theControl).contrlRect ) )
1812 RectRgn((RgnHandle) param , &(**theControl).contrlRect ) ;
1814 case kControlMsgCalcBestRect :
1816 ControlCalcSizeRec *rec = (ControlCalcSizeRec *) param ;
1817 rec->width = (**theControl).contrlRect.right - (**theControl).contrlRect.left ;
1818 rec->height = kAGACheckBoxHeigth ;
1829 pascal SInt32
AGAStaticGroupBoxTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1831 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1841 if (!(**theControl
).contrlVis
)
1845 bool disabled
= false ;
1846 bool hasColor
= true ;
1847 AGAPortHelper
help() ;
1848 AGASetFontStyle( &info
->fontStyle
) ;
1850 ::GetFontInfo( &fi
) ;
1852 Rect labelRect
= (**theControl
).contrlRect
;
1853 Rect theFrame
= (**theControl
).contrlRect
;
1854 int width
= StringWidth((**theControl
).contrlTitle
) ;
1855 theFrame
.top
+= fi
.ascent
+ fi
.leading
>> 1 ;
1856 labelRect
.bottom
= theFrame
.top
+ 8 ;
1857 labelRect
.left
+= 10 ;
1858 labelRect
.right
=labelRect
.left
+ width
+ 6 ;
1865 RGBForeColor( &gAGAColorArray
[4] ) ;
1869 RGBForeColor( &gAGAColorArray
[7] ) ;
1871 FrameRect( &theFrame
) ;
1874 ::RGBForeColor(&gAGAColorArray
[1]);
1876 ::ForeColor(whiteColor
);
1877 ::MoveTo(theFrame
.left
+ 1, theFrame
.bottom
- 2);
1878 ::LineTo(theFrame
.left
+ 1, theFrame
.top
+ 1);
1879 ::LineTo(theFrame
.right
- 2, theFrame
.top
+ 1);
1880 ::MoveTo(theFrame
.left
, theFrame
.bottom
);
1881 ::LineTo(theFrame
.right
, theFrame
.bottom
);
1882 ::LineTo(theFrame
.right
, theFrame
.top
);
1884 AGASetFontStyle( &info
->fontStyle
) ;
1885 ::EraseRect( &labelRect
) ;
1886 ::MoveTo(labelRect
.left
+ 3, labelRect
.top
+ fi
.ascent
+ (fi
.leading
>> 1));
1887 ::DrawString((**theControl
).contrlTitle
);
1891 case kControlMsgCalcBestRect
:
1893 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1894 rec
->width
= (**theControl
).contrlRect
.right
- (**theControl
).contrlRect
.left
;
1895 rec
->height
= (**theControl
).contrlRect
.bottom
- (**theControl
).contrlRect
.top
;
1899 case kControlMsgSetData
:
1902 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
1911 pascal SInt32
AGAStaticTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
1913 Handle macText
= (**theControl
).contrlData
;
1914 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
1920 macText
= NewHandle(0) ;
1921 (**theControl
).contrlData
= (Handle
) macText
;
1925 DisposeHandle( macText
) ;
1929 if (!(**theControl
).contrlVis
)
1933 AGAPortHelper
help() ;
1934 AGASetFontStyle( &info
->fontStyle
) ;
1935 int x
= (**theControl
).contrlRect
.left
;
1936 int y
= (**theControl
).contrlRect
.top
;
1939 ::GetFontInfo( &fi
) ;
1942 lineheight
= fi
.ascent
+ fi
.descent
+ fi
.leading
;
1943 int length
= GetHandleSize( macText
) ;
1949 RGBColor gray
= { 0xDDDD , 0xDDDD, 0xDDDD } ;
1950 ::RGBBackColor( &gray
) ;
1953 if ( (*macText
)[i
] == 0x0d )
1956 ::DrawText( *macText
, laststop
, i
-laststop
);
1963 ::DrawText( *macText
, laststop
, i
-laststop
);
1965 HUnlock( macText
) ;
1970 case kControlMsgCalcBestRect
:
1972 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
1973 rec
->width
= (**theControl
).contrlRect
.right
- (**theControl
).contrlRect
.left
;
1974 rec
->height
= (**theControl
).contrlRect
.bottom
- (**theControl
).contrlRect
.top
;
1978 case kControlMsgSetData
:
1980 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
1981 if ( rec
->tag
== kControlStaticTextTextTag
)
1983 SetHandleSize( macText
, rec
->size
) ;
1984 memcpy( *macText
, rec
->dataPtr
, rec
->size
) ;
1987 return errDataNotSupported
;
1996 void AGAMoveControl(ControlHandle inControl
, short x
, short y
)
1998 if ( AGATestForNewControl( inControl
) )
2000 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
2001 if ( info
->magic
== kExtCDEFMagic
)
2003 if ( info
->procID
== kControlEditTextProc
)
2008 dx
= x
- (**inControl
).contrlRect
.left
;
2009 dy
= y
- (**inControl
).contrlRect
.top
;
2011 MoveControl( inControl
, x
,y
) ;
2014 macTE
= (TEHandle
) (**inControl
).contrlData
;
2015 (**macTE
).destRect
.left
+= dx
;
2016 (**macTE
).destRect
.top
+= dy
;
2017 (**macTE
).destRect
.right
+= dx
;
2018 (**macTE
).destRect
.bottom
+= dy
;
2019 (**macTE
).viewRect
.left
+= dx
;
2020 (**macTE
).viewRect
.top
+= dy
;
2021 (**macTE
).viewRect
.right
+= dx
;
2022 (**macTE
).viewRect
.bottom
+= dy
;
2025 if ( info
->procID
== kControlListBoxProc
)
2030 dx
= x
- (**inControl
).contrlRect
.left
;
2031 dy
= y
- (**inControl
).contrlRect
.top
;
2033 MoveControl( inControl
, x
,y
) ;
2034 ListHandle macList
;
2036 macList
= (ListHandle
) (**inControl
).contrlData
;
2037 (**macList
).rView
.left
+= dx
;
2038 (**macList
).rView
.top
+= dy
;
2039 (**macList
).rView
.right
+= dx
;
2040 (**macList
).rView
.bottom
+= dy
;
2045 MoveControl( inControl
, x
,y
) ;
2048 void AGASizeControl(ControlHandle inControl
, short x
, short y
)
2050 if ( AGATestForNewControl( inControl
) )
2052 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
2053 if ( info
->magic
== kExtCDEFMagic
)
2055 if ( info
->procID
== kControlEditTextProc
)
2060 dx
= x
- ( (**inControl
).contrlRect
.right
- (**inControl
).contrlRect
.left
) ;
2061 dy
= y
- ( (**inControl
).contrlRect
.bottom
- (**inControl
).contrlRect
.top
) ;
2063 SizeControl( inControl
, x
,y
) ;
2066 macTE
= (TEHandle
) (**inControl
).contrlData
;
2067 (**macTE
).destRect
.right
+= dx
;
2068 (**macTE
).destRect
.bottom
+= dy
;
2069 (**macTE
).viewRect
.right
+= dx
;
2070 (**macTE
).viewRect
.bottom
+= dy
;
2073 if ( info
->procID
== kControlListBoxProc
)
2078 dx
= x
- ( (**inControl
).contrlRect
.right
- (**inControl
).contrlRect
.left
) ;
2079 dy
= y
- ( (**inControl
).contrlRect
.bottom
- (**inControl
).contrlRect
.top
) ;
2081 SizeControl( inControl
, x
,y
) ;
2082 ListHandle macList
;
2084 macList
= (ListHandle
) (**inControl
).contrlData
;
2085 (**macList
).rView
.right
+= dx
;
2086 (**macList
).rView
.bottom
+= dy
;
2091 SizeControl( inControl
, x
,y
) ;
2094 pascal SInt32
AGARootControlDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
2096 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
2106 case kControlMsgCalcBestRect
:
2108 case kControlMsgSetData
:
2116 pascal SInt32
AGAEditTextDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
2118 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
2122 macTE
= (TEHandle
) (**theControl
).contrlData
;
2128 AGAPortHelper
help() ;
2129 SetPort( (**theControl
).contrlOwner
) ;
2130 ::TextFont( kFontIDGeneva
) ;
2133 RGBBackColor( &gAGARamp
[ kAGAWhite
] ) ;
2134 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
2135 Rect bounds
= (**theControl
).contrlRect
;
2136 InsetRect( &bounds
, 4 , 1 ) ;
2138 ::GetFontInfo( &fi
) ;
2140 bounds
.top
= bounds
.bottom
- abs( fi
.descent
) - fi
.ascent
- 3;
2141 macTE
= TENew( &bounds
, &bounds
) ;
2142 (**theControl
).contrlData
= (Handle
) macTE
;
2146 TEDispose( macTE
) ;
2150 AGAPortHelper
help() ;
2151 AGASetFontStyle( &info
->fontStyle
) ;
2152 SetPort( (**theControl
).contrlOwner
) ;
2153 RGBBackColor( &gAGARamp
[ kAGAWhite
] ) ;
2154 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
2155 EraseRect( &(**theControl
).contrlRect
) ;
2156 FrameRect( &(**theControl
).contrlRect
) ;
2157 TEUpdate( &(**theControl
).contrlRect
, macTE
) ;
2163 pt
.h
= LoWord( param
) ;
2164 pt
.v
= HiWord( param
) ;
2165 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
2166 return kControlButtonPart
;
2174 pt
.h
= LoWord( param
) ;
2175 pt
.v
= HiWord( param
) ;
2176 if ( PtInRect( pt
, &(**theControl
).contrlRect
) )
2178 TEClick( pt
, false , macTE
) ;
2182 case kControlMsgGetData
:
2184 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
2185 if ( rec
->tag
== kControlEditTextTEHandleTag
)
2187 return AGAGetDataHelper( rec
, sizeof( TEHandle
) , (char*) &macTE
) ;
2189 else if ( rec
->tag
== kControlEditTextTextTag
)
2191 return AGAGetDataHelper( rec
, (**macTE
).teLength
, (char*) *(**macTE
).hText
) ;
2193 else if ( rec
->tag
== kControlEditTextSelectionTag
)
2196 return errDataNotSupported
;
2199 case kControlMsgSetData
:
2201 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
2202 if ( rec
->tag
== kControlEditTextTextTag
)
2204 TESetText( rec
->dataPtr
, rec
->size
, macTE
) ;
2207 return errDataNotSupported
;
2209 case kControlMsgCalcBestRect
:
2211 ControlCalcSizeRec
*rec
= (ControlCalcSizeRec
*) param
;
2212 rec
->width
= (**theControl
).contrlRect
.right
- (**theControl
).contrlRect
.left
;
2213 rec
->height
= (**theControl
).contrlRect
.bottom
- (**theControl
).contrlRect
.top
;
2216 case kControlMsgFocus
:
2218 if ( param
== kControlFocusNoPart
)
2220 info
->hasFocus
= false ;
2221 TEDeactivate( macTE
) ;
2222 return kControlFocusNoPart
;
2224 else if ( param
== kControlFocusNextPart
|| param
== kControlFocusPrevPart
)
2226 if ( info
->hasFocus
)
2228 info
->hasFocus
= false ;
2229 TEDeactivate( macTE
) ;
2230 return kControlFocusNoPart
;
2234 info
->hasFocus
= true ;
2235 TEActivate( macTE
) ;
2236 return kControlEditTextPart
;
2239 else if ( param
== kControlEditTextPart
)
2241 if ( !info
->hasFocus
)
2243 info
->hasFocus
= true ;
2244 TEActivate( macTE
) ;
2245 return kControlEditTextPart
;
2250 case kControlMsgIdle
:
2255 case kControlMsgKeyDown
:
2257 AGAPortHelper
help() ;
2258 AGASetFontStyle( &info
->fontStyle
) ;
2259 SetPort( (**theControl
).contrlOwner
) ;
2260 RGBBackColor( &gAGARamp
[ kAGAWhite
] ) ;
2261 RGBForeColor( &gAGARamp
[ kAGABlack
] ) ;
2262 ControlKeyDownRec
* rec
= (ControlKeyDownRec
*) param
;
2263 TEKey( rec
->charCode
, macTE
) ;
2266 case kControlMsgActivate
:
2270 TEActivate( macTE ) ;
2272 TEDeactivate( macTE ) ;
2277 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
2279 case kControlMsgTestNewMsgSupport
:
2280 return kControlSupportsNewMessages
;
2281 case kControlMsgGetFeatures
:
2283 // kControlSupportsGhosting |
2284 // kControlSupportsEmbedding |
2285 kControlSupportsFocus
|
2287 kControlWantsActivate
|
2288 // kControlHandlesTracking |
2289 kControlSupportsDataAccess
|
2290 // kControlHasSpecialBackground |
2291 // kControlGetsFocusOnClick |
2292 kControlSupportsCalcBestRect
|
2293 // kControlSupportsLiveFeedback |
2294 // kControlHasRadioBehavior |
2303 pascal SInt32
AGAListControlDefProc (SInt16 procID
, ControlHandle theControl
, ControlDefProcMessage message
, SInt32 param
)
2306 ListHandle macList
;
2307 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**theControl
).contrlRfCon
;
2309 macList
= (ListHandle
) (**theControl
).contrlData
;
2311 static inLoop
= false ;
2312 static lastClick
= NULL
;
2318 Rect databounds
= { 0,0,0,0} ;
2319 Point cellsize
= { 0,0} ;
2320 Rect listBounds
= (**theControl
).contrlRect
;
2322 InsetRect( &listBounds
, 1 , 1 ) ;
2324 macList
= LNew( &listBounds
, &databounds
, cellsize
, 128 ,
2325 (**theControl
).contrlOwner
, false /*drawit*/ , false /*hasGrow*/,
2326 false /* horzScroll */, true /*vertScroll*/ ) ;
2327 (**theControl
).contrlData
= (Handle
) macList
;
2328 info
->privateData
= NULL
;
2332 (**macList
).vScroll
= NULL
; // will be disposed by the window itself
2333 (**macList
).hScroll
= NULL
; // will be disposed by the window itself
2334 LDispose( macList
) ;
2337 RectRgn((RgnHandle
) param
, &(**theControl
).contrlRect
) ;
2342 pt
.h
= LoWord( param
) ;
2343 pt
.v
= HiWord( param
) ;
2345 Rect allRect
= (**theControl
).contrlRect
;
2346 listRect
= allRect
;
2348 allRect
.right
+= 16 ;
2349 if ( PtInRect( pt
, &allRect
) )
2351 if ( !inLoop
&& StillDown() )
2354 LActivate( true , macList
) ;
2355 Boolean doubleClick
= LClick( pt
, 0 /* todo modifiers*/ , macList
) ;
2356 info
->privateData
= doubleClick
;
2359 return kControlListBoxPart
;
2367 AGAPortHelper
help() ;
2368 AGASetFontStyle( &info
->fontStyle
) ;
2369 RGBBackColor( &gAGARamp
[ kAGAWhite
] ) ;
2370 EraseRect( &(**theControl
).contrlRect
) ;
2371 FrameRect( &(**theControl
).contrlRect
) ;
2372 RgnHandle controlRgn
= NewRgn() ;
2373 SetRectRgn( controlRgn
, (**theControl
).contrlRect
.left
,
2374 (**theControl
).contrlRect
.top
,
2375 (**theControl
).contrlRect
.right
,
2376 (**theControl
).contrlRect
.bottom
) ;
2377 LUpdate( controlRgn
, macList
) ;
2383 pt
.h
= LoWord( param
) ;
2384 pt
.v
= HiWord( param
) ;
2386 Rect allRect
= (**theControl
).contrlRect
;
2387 listRect
= allRect
;
2388 allRect
.right
+= 16 ;
2389 if ( PtInRect( pt
, &listRect
) )
2391 if ( !inLoop
&& StillDown() )
2394 LActivate( true , macList
) ;
2395 Boolean doubleClick
= LClick( pt
, 0 /* todo modifiers*/ , macList
) ;
2396 info
->privateData
= doubleClick
;
2399 return kControlListBoxPart
;
2401 else if ( PtInRect( pt
, &allRect
) )
2403 if ( !inLoop
&& StillDown() )
2406 // LActivate( true , macList ) ;
2407 Boolean doubleClick
= LClick( pt
, 0 /* todo modifiers*/ , macList
) ;
2408 info
->privateData
= doubleClick
;
2411 return kControlPageDownPart
;
2417 case kControlMsgGetData
:
2419 ControlDataAccessRec
*rec
= (ControlDataAccessRec
*) param
;
2420 if ( rec
->tag
== kControlListBoxListHandleTag
)
2422 return AGAGetDataHelper( rec
, sizeof( ListHandle
) , (char*) &macList
) ;
2424 else if ( rec
->tag
== kControlListBoxDoubleClickTag
)
2426 Boolean doubleClick
= info
->privateData
;
2427 return AGAGetDataHelper( rec
, sizeof( Boolean
) , (char*) &doubleClick
) ;
2429 return errDataNotSupported
;
2439 OSErr
AGACreateRootControl (WindowPtr inWindow
,
2440 ControlHandle
* outControl
)
2442 ControlHandle theControl
= NULL
;
2444 SInt16 extCDEFID
= kExtCDEFID
<< 4 + 0 ;
2446 theControl
= NewControl( inWindow
, &inWindow
->portRect
, "\p" , true ,
2447 0 , 0 , 1 , extCDEFID
, 0 ) ;
2448 NewExtCDEFInfo( theControl
, AGARootControlDefProc
, kAGARootControlProcID
, 0 ) ;
2450 *outControl
= theControl
;
2454 OSErr
AGAEmbedControl (ControlHandle inControl
,
2455 ControlHandle inContainer
)
2457 if ( AGATestForNewControl( inControl
) )
2459 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**inControl
).contrlRfCon
;
2460 info
->containerControl
= inContainer
;
2465 void AGADrawControl( ControlHandle control
)
2467 DrawOneControl( control
) ;
2468 ControlHandle iter
= (ControlHandle
) ((WindowPeek
)(**control
).contrlOwner
)->controlList
;
2471 if ( AGATestForNewControl( iter
) )
2473 ExtCDEFInfo
* info
= (ExtCDEFInfo
* ) (**iter
).contrlRfCon
;
2474 if ( info
->containerControl
== control
)
2476 AGADrawControl( iter
) ;
2480 iter
= (**iter
).nextControl
;
2485 ControlHandle
AGANewControl(WindowPtr owningWindow
,
2486 const Rect
* bounds
,
2487 ConstStr255Param controlTitle
,
2488 Boolean initiallyVisible
,
2489 SInt16 initialValue
,
2490 SInt16 minimumValue
,
2491 SInt16 maximumValue
,
2493 SInt32 controlReference
)
2495 ControlHandle theControl
= NULL
;
2496 Rect boundsRect
= *bounds
;
2497 SInt16 extCDEFID
= kExtCDEFID
<< 4 + 0 ;
2498 SInt16 oldProcID
= extCDEFID
;
2501 case kControlScrollBarProc
:
2502 case kControlScrollBarLiveProc
:
2503 oldProcID
= scrollBarProc
;
2505 case kControlListBoxProc
:
2510 if ( oldProcID
== extCDEFID
&& procID
== kControlListBoxProc
)
2512 boundsRect
.right
-= 16 ;
2514 theControl
= NewControl( owningWindow
, &boundsRect
, controlTitle
, initiallyVisible
,
2515 initialValue
, minimumValue
, maximumValue
, oldProcID
, controlReference
) ;
2516 if ( oldProcID
== extCDEFID
)
2518 ControlDefProcPtr theProcPtr
= NULL
;
2519 SInt16 theVarCode
= 0 ;
2522 case kControlPushButtonProc
:
2523 theProcPtr
= AGAButtonDefProc
;
2525 case kControlCheckBoxProc
:
2526 theProcPtr
= AGACheckBoxDefProc
;
2528 case kControlRadioButtonProc
:
2529 theProcPtr
= AGARadioButtonDefProc
;
2531 case kControlProgressBarProc
:
2532 theProcPtr
= AGAProgressBarDefProc
;
2534 case kControlPlacardProc
:
2535 theProcPtr
= AGAPlacardDefProc
;
2537 case kControlStaticTextProc
:
2538 theProcPtr
= AGAStaticTextDefProc
;
2540 case kControlListBoxProc
:
2541 theProcPtr
= AGAListControlDefProc
;
2543 case kControlEditTextProc
:
2544 theProcPtr
= AGAEditTextDefProc
;
2546 case kControlGroupBoxTextTitleProc
:
2547 theProcPtr
= AGAStaticGroupBoxTextDefProc
;
2549 case kControlBevelButtonNormalBevelProc
:
2550 theProcPtr
= AGABevelButtonDefProc
;
2556 NewExtCDEFInfo( theControl
, theProcPtr
, procID
, controlReference
) ;
2562 void AGASetThemeWindowBackground (WindowRef inWindow
,
2568 SetPort( inWindow
) ;
2569 if ( inBrush
== kThemeBrushDialogBackgroundActive
)
2571 gAGABackgroundColor
= 2 ;
2575 gAGABackgroundColor
= 0 ;
2577 RGBBackColor( &gAGAColorArray
[gAGABackgroundColor
] ) ;