Esempio n. 1
0
void AlignIcons( HWND hDlg, LPALIGNOBJECTS_PARMS lpAlignParms )
/************************************************************************/
{
RECT		bRect, cRect;
int		xOffset, yOffset, i, wind;
LFIXED	vSpace, hSpace, fx, fy;
HWND		hWnd;

GetClientRect( hWnd = GetDlgItem( hDlg, IDC_ALIGN_GRID ), &bRect );

vSpace = FGET( RectHeight( &bRect ) - ( ALIGN_NUM_OBJECTS * ICON_HEIGHT ),
	ALIGN_NUM_OBJECTS - 1 );
hSpace = FGET( RectWidth( &bRect ) - ( ALIGN_NUM_OBJECTS * ICON_WIDTH ),
	ALIGN_NUM_OBJECTS - 1 );

fx = fy = 0;

for( i = 0, wind = GW_CHILD; i < ALIGN_NUM_OBJECTS; i++, wind = GW_HWNDNEXT )
	{	
	hWnd = GetWindow( hWnd, wind );
	GetClientRect( hWnd, &cRect );
	cRect.right -= 1;
	cRect.bottom -= 1;
	MapWindowPoints( hWnd, GetDlgItem( hDlg, IDC_ALIGN_GRID ),
		( LPPOINT )&cRect, 2 );
	ShowWindow( hWnd, SW_HIDE );
	ObjAlign( &bRect, &cRect, lpAlignParms, vSpace, hSpace,
		&xOffset, &yOffset, &fx, &fy );
	OffsetRect( &cRect, xOffset, yOffset );
	MoveWindow( hWnd, cRect.left, cRect.top, RectWidth( &cRect ),
		RectHeight( &cRect ), TRUE );
	UpdateWindow( GetDlgItem( hDlg, IDC_ALIGN_GRID ) );
	ShowWindow( hWnd, SW_SHOWNA );
	}
}
Esempio n. 2
0
extern void ObjEmitData( void *buffer, int size, bool align ) {
//*************************************************************
// Aligns to proper address, emits all pending labels, then emits the data

    if( align ) {
        (void)ObjAlign( CurrAlignment );
    }
    ObjFlushLabels();
    doEmitData( buffer, size );
}
Esempio n. 3
0
void ObjEmitData( owl_section_handle section, void *buffer, int size, bool align ) {
//**********************************************************************************
// Aligns to proper address, emits all pending labels, then emits the data

    if( align ) {
        (void)ObjAlign( section, CurrAlignment );
    }
    ObjFlushLabels();
    OWLEmitData( section, buffer, size );
    // printf( "real data emitted.\n" );
}
Esempio n. 4
0
void ObjEmitReloc( owl_section_handle section, void *target, owl_reloc_type type, bool align, bool named_sym ) {
//**************************************************************************************************************
// Should be called before emitting the data that has the reloc.
// (named_sym == TRUE) iff the target is a named label

    owl_offset          offset;

    if( align ) { // If data is aligned, we should also align this reloc offset!
        offset = ObjAlign( section, CurrAlignment );
    } else {
        offset = OWLTellOffset( section );
    }
    ObjFlushLabels();
#ifdef AS_PPC
    doEmitReloc( section, offset, target, type, named_sym );
#else
    {
        sym_reloc       reloc;
        bool            match_high;
        owl_offset      offset_hi, offset_lo;
        sym_handle      (*lookup_func)( void * );

        if( type != OWL_RELOC_HALF_HI && type != OWL_RELOC_HALF_LO ) {
            doEmitReloc( section, offset, target, type, named_sym );
        } else {
            lookup_func = named_sym ?
                (sym_handle (*)(void *))SymLookup :
                (sym_handle (*)(void *))AsNumLabelSymLookup;
            match_high = ( type == OWL_RELOC_HALF_LO );    // hi match lo etc.
            reloc = SymMatchReloc( match_high, lookup_func( target ), section );
            if( reloc ) {       // got a match
                if( match_high ) {
                    offset_hi = reloc->location.offset;
                    offset_lo = offset;
                } else {
                    offset_hi = offset;
                    offset_lo = reloc->location.offset;
                }
                doEmitReloc( section, offset_hi, target, OWL_RELOC_HALF_HI, named_sym );
                doEmitReloc( section, offset_lo, target, OWL_RELOC_PAIR, named_sym );
                doEmitReloc( section, offset_lo, target, OWL_RELOC_HALF_LO, named_sym );
                SymDestroyReloc( lookup_func( target ), reloc );
            } else {    // no match; stack it up with the (aligned) offset!
                SymStackReloc( !match_high, lookup_func( target ), section, offset, named_sym );
            }
        }
    }
#endif
}
Esempio n. 5
0
BOOL AlignObjects( LPIMAGE lpImage, LPALIGNOBJECTS_PARMS lpAlignParms )
/************************************************************************/
{
RECT		bRect, gRect, uRect;
LPOBJECT	lpObject, lpGroupObject;
int		xOffset, yOffset, gXOffset, gYOffset, nWidth, nHeight, nCount;
LFIXED	hSpace, vSpace, fx, fy;
WORD		wGroupIDs[NUM_GROUPS];

if( !( lpImage ) )
	return( FALSE );

if( !( lpObject = ImgGetBase( lpImage ) )	)
   return( FALSE );

if( !( lpAlignParms->bPreview ) )
	{
	if( !( ImgEditInit( lpImage, ET_SELOBJECTS, UT_OBJECTRECT, lpObject ) ) )
		return( FALSE );
	}

if( lpAlignParms->RectAlign == RA_IMAGE )
	{	
	ImgGetImageRect( lpImage, &bRect );
	}
else
	{	
	if( lpAlignParms->RectAlign == RA_MASK )
  		ImgGetMaskRect( lpImage, &bRect );
	else
		ImgGetSelObjectRect( lpImage, &bRect, YES );
	}

ImgGetSelObjectRect( lpImage, &uRect, YES );


nWidth = RectWidth( &bRect );
nHeight = RectHeight( &bRect );

nCount = 0;

InitGroupList( wGroupIDs );

while ( lpObject = ImgGetSelObject(lpImage, lpObject) )
   {
	if( lpObject->wGroupID )
		{
		if( !( IsPrevGroup( lpObject->wGroupID, wGroupIDs ) ) &&
			!( IsGroupLocked( lpObject->wGroupID ) ) )
			{
			SetGroupList( lpObject->wGroupID, wGroupIDs );
			lpImage->GetGroupRect( lpObject, &gRect );
			nWidth -= RectWidth( &gRect );
			nHeight -= RectHeight( &gRect );
			++nCount;
			}
		}
	else if (!lpObject->bLocked)
		{
		nWidth -= RectWidth( &lpObject->rObject );
		nHeight -= RectHeight( &lpObject->rObject );
		++nCount;
		}
	}

if( nCount == 0 )
	return( FALSE );

hSpace = FGET( nWidth, nCount - 1 );
vSpace = FGET( nHeight, nCount - 1 );

fx = fy = 0;

InitGroupList( wGroupIDs );

lpObject = ImgGetBase( lpImage );

while ( lpObject = ImgGetSelObject(lpImage, lpObject) )
   {
	if( lpObject->wGroupID )
		{
		if( !( IsPrevGroup( lpObject->wGroupID, wGroupIDs ) ) &&
			!( IsGroupLocked( lpObject->wGroupID ) ) )
			{
			SetGroupList( lpObject->wGroupID, wGroupIDs );
			lpImage->GetGroupRect( lpObject, &gRect );
			ObjAlign( &bRect, &gRect, lpAlignParms, vSpace, hSpace,
				&gXOffset, &gYOffset, &fx, &fy );
			lpGroupObject = ImgGetBase( lpImage );
			while( lpGroupObject = ImgGetSelObject( lpImage, lpGroupObject ) )
				{
				if( lpObject->wGroupID == lpGroupObject->wGroupID )
					{
					if( !( lpAlignParms->bPreview ) )
						ImgEditedObject( lpImage, lpGroupObject, IDS_UNDOOBJALIGN,
							NULL );
					OffsetRect( &lpGroupObject->rObject, gXOffset, gYOffset );
					}
				}
			}
		}
	else if (!lpObject->bLocked)
		{
		ObjAlign( &bRect, &lpObject->rObject, lpAlignParms, vSpace, hSpace,
			&xOffset, &yOffset, &fx, &fy ); 
		if( !( lpAlignParms->bPreview ) )
			ImgEditedObject( lpImage, lpObject, IDS_UNDOOBJALIGN, NULL );
		OffsetRect( &lpObject->rObject, xOffset, yOffset );
		}
   }
ImgGetSelObjectRect( lpImage, &bRect, YES );
AstralUnionRect( &uRect, &uRect, &bRect );
UpdateImage( lpImage, &uRect, YES );
return( TRUE );
}