Bounds resizing
Bounds resizing
- Subject: Bounds resizing
- From: "Dan Rodricks" <email@hidden>
- Date: Sun, 21 May 2006 20:43:13 +0530
Hai All,
I want to make a collection of drawings as a group and resize all the
elements in the group together,for that i have created union of bounds and
made a resultant Bound which contain the entair (selected) drawings.
Problem that i am facing now is ,i am not able to resize the newly created
bound ,but i could resize it if i remove the object from the
bounds(Group).My bound knobs that i have given at the four corners are
getting rubbed during resizing.
For the time being i am making all these codes on sketch. changes i have
given are given bellow can someone identify the
basic problem.
Chages i have made are given bellow.
- (IBAction)Group:(id)sender //Grouping Action
{
NSArray *orderedSelection = [self orderedSelectedGraphics];
unsigned int nElementCount = [orderedSelection count];
if (nElementCount > 0) {
++m_nGroupID;
int i = 0;
for( i = 0; i < nElementCount; ++i)
{
m_nGroupElements[m_nGroupID][i] = [[orderedSelection
objectAtIndex:i] GetObjectID];
[[orderedSelection objectAtIndex:i] setgrouped:YES];
}
}
- (NSRect)findGroupDrawingBounds:(NSArray *)graphics
{
NSRect rect = NSZeroRect;
unsigned i, c = [graphics count];
for (i=0; i<c; i++) {
if (i==0) {
rect = [[graphics objectAtIndex:i] drawingBounds];
} else {
rect = NSUnionRect(rect, [[graphics objectAtIndex:i]
drawingBounds]);
}
}
return rect;
}
-(int) GetGroupID:(SKTGraphic *)graphics
{
unsigned int nIndexGroupCount = 0;
unsigned int nElementIndex = 0;
BOOL bIsGrouped = NO;
unsigned int temp;
NSRect rect = NSZeroRect;
// get the group ID
for( nIndexGroupCount = 0; nIndexGroupCount <= m_nGroupID;
++nIndexGroupCount)
{
temp = m_nGroupElements[nIndexGroupCount][nElementIndex];
for( nElementIndex = 0;
m_nGroupElements[nIndexGroupCount][nElementIndex] != -1; ++nElementIndex)
{
if( [graphics GetObjectID] ==
m_nGroupElements[nIndexGroupCount][nElementIndex])
{
return nIndexGroupCount;
}
}
}
return -1;
}
-(NSRect) GetGroupBounds:(int)nIndexGroupCount
{
NSRect rect = NSZeroRect;
unsigned int nElementIndex = 0;
SKTDrawWindowController *drawWindowController = [self
drawWindowController];
NSArray *graphics;
unsigned nTotalElementCount = 0;
graphics = [[drawWindowController document] graphics];
unsigned nIndex = 0;
nTotalElementCount = [graphics count];
BOOL firstElement = YES;
for( nElementIndex = 0;
m_nGroupElements[nIndexGroupCount][nElementIndex] != -1; ++nElementIndex)
{
for( nIndex = 0; nIndex < nTotalElementCount; ++nIndex)
{
int temp = [[graphics objectAtIndex:nIndex]
GetObjectID];
int temp2 =
m_nGroupElements[nIndexGroupCount][nElementIndex];
if (temp ==temp2)
{
if (firstElement)
{
rect = [[graphics objectAtIndex:nIndex]
drawingBounds];
firstElement =NO;
}
else
{
rect = NSUnionRect(rect, [[graphics
objectAtIndex:nIndex] drawingBounds]); /*Making The Union // of Bounds.
*/
}
}
}
}
Thanks In Advance.
Regards.
Dan Rodrics.
return rect;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden