Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drag problem (solved)



>You mean ShowDragHilite? The way it is implemented it works ok only
when the port's background color matches the area that you are hiliting.<

Thanks Mike, now I understand what is going on.

Here is the code I use as a supplement to Show/HideDragHilite when hiliting
a control rectangle, in case anyone else stumbles on this problem too:

if ( PtInRect( mousePt,
&itemRect ) )
{
if (
!receiveData->inContent ) // This is first time in.
{

receiveData->inContent = true;

hiliteRegion = NewRgn();
RectRgn(
hiliteRegion, &itemRect );


MyDragHiliteRemover( window, &itemRect, nil );

error =
ShowDragHilite( theDrag, hiliteRegion, true );
DisposeRgn(
hiliteRegion );
}
}
else
// Not in content area of window.
{
if (
receiveData->inContent )
{

receiveData->inContent = false;



HideDragHilite( theDrag ); // Need to call anyway or else
ShowDragHilite doesn't work next time.

hiliteFrameRgn = NewRgn();


MyDragHiliteRemover( window, controlRect, hiliteFrameRgn );

MyDrawControlFrame( control, hiliteFrameRgn );

DisposeRgn(
hiliteFrameRgn );
}
}


/*
---------------------------------------------------------------------------
----------------------------------------------- */
// Redraw the border
of a control.
static void MyDrawControlFrame( ControlRef control, RgnHandle
hiliteFrameRgn )
{
RgnHandle clipRegion = NewRgn();

GetClip( clipRegion );
SetClip( hiliteFrameRgn );
DrawOneControl( control );
SetClip( clipRegion );
DisposeRgn( clipRegion );
}


/*
---------------------------------------------------------------------------
----------------------------------------------- */

// After Bryan Pietrzak's snippet.
static void MyDragHiliteRemover( WindowRef window, const Rect
*dragBounds, RgnHandle hiliteFrameRgn )
{
RgnHandle outerRgn = NewRgn();
RgnHandle innerRgn = NewRgn();
Rect innerBounds = *dragBounds;

InsetRect( &innerBounds, 2, 2 );
RectRgn( outerRgn, dragBounds );
RectRgn( innerRgn, &innerBounds );

DiffRgn( outerRgn, innerRgn, outerRgn );

EraseRgn( outerRgn );
InvalWindowRgn( window, outerRgn );

if ( hiliteFrameRgn ) CopyRgn( outerRgn, hiliteFrameRgn );

DisposeRgn( innerRgn );
DisposeRgn( outerRgn );
}
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.