Ejemplo n.º 1
0
void View1TO1()
   {
   int x, y, res, ratio;
   LFIXED fixed;
   HDC hDC;
   HWND hWnd;
   LPDISPLAY lpDisplay;
   LPIMAGE lpImage;

	if (hWnd = GetActiveDoc())
      {
	   lpImage = GetImagePtr(hWnd);
	   lpDisplay = GetDisplayPtr(hWnd);
	   hDC = GetDC( PictPubApp.Get_hWndAstral() );
	   x = GetDeviceCaps( hDC, HORZRES ); // in pixels
	   ReleaseDC( PictPubApp.Get_hWndAstral(), hDC );
	   fixed = FGET( FUNITY, Control.ScreenWidth );
	   if (res = FMUL( x, fixed)) // in pixels/inch
         {
	      ratio = ( 100L * res ) / FrameResolution(ImgGetBaseEditFrame(lpImage));
	      x = ( lpDisplay->FileRect.left 
		   + lpDisplay->FileRect.right ) / 2;
	      y = ( lpDisplay->FileRect.top 
		   + lpDisplay->FileRect.bottom ) / 2;
	      Zoom( hWnd, x, y, ratio, NO, View.ZoomWindow );
         }
      }
   }
Ejemplo n.º 2
0
void CMiscPrefPage::HandleOK()
{
	HWND hActiveWnd;
	LPIMAGE lpImage = NULL;
	if (hActiveWnd = GetActiveDoc())
		lpImage = GetImagePtr(hActiveWnd);
	if (lpImage && m_MaskTint != Control.MaskTint &&
		ImgGetViewMode(lpImage) == VM_SLIME)
	{
		RECT rRect;

		rRect = GetDisplayPtr(hActiveWnd)->DispRect;
		AstralToWindowsRect(&rRect);
		::InvalidateRect( hActiveWnd, &rRect, FALSE );
	}
	if (!Control.IndependentSettings &&
		Control.IndependentSettings != m_IndependentSettings)
		SetCommonSettings();
	if (Control.UseTablet)
    {
		Control.UseTablet = TabletStart();
        if (!Control.UseTablet)
        {
            LPSTR    lp;

            AstralStr(IDS_NOTABLET, &lp);
            ::MessageBox(PictPubApp.Get_hWndAstral(), lp, szAppName, 
               MB_ICONHAND | MB_OK | MB_TASKMODAL);
        }
    }
	CPPPropertyPage::HandleOK();
}
Ejemplo n.º 3
0
void TextureFillProc( HWND hWindow, UINT msg, int x, int y, UINT32 Option )
/************************************************************************/
{
FNAME szFileName;
LPIMAGE lpImage;
TEXTUREFILL_PARMS parms;

switch (msg)
    {
    case WM_CREATE:	// The first mouse down message
	// Load the texture
	if (!IsOnImage(hWindow, x, y))
		break;
	if (!LookupExtFile(Texture.TextureName, szFileName, IDN_TEXTURE))
		break;
	if (!FileExists(szFileName))
		{
		Message(IDS_EOPEN, (LPSTR)szFileName);
		break;
		}
    lpImage = (LPIMAGE)GetImagePtr ( hWindow );
	parms.TextureOpacity = Texture.TextureOpacity;
	parms.TextureMergeMode = Texture.TextureMergeMode;
	lstrcpy(parms.TextureName, Texture.TextureName);
	parms.fHorzFlip = Texture.fHorzFlip;
	parms.fVertFlip = Texture.fVertFlip;
	ProcessCommand(lpImage->lpCmdList, IDS_CMD_TEXTUREFILL, &parms);
	break;

	case WM_ACTIVATE:
	if (!Option) // a deactivate
		{
		FrameClose( lpTextureFrame );
		lpTextureFrame = NULL;
		}
	return;
		
    case WM_LBUTTONDOWN:
	break;

    case WM_LBUTTONUP:
	Tool.bActive = NO;
	break;

    case WM_MOUSEMOVE:	// sent when ToolActive is on
	break;

    case WM_LBUTTONDBLCLK:
	break;

    case WM_DESTROY:	// The cancel operation message
	Tool.bActive = NO;
	break;
    }
}
Ejemplo n.º 4
0
void ViewAll(HWND hWnd)
/************************************************************************/
{
int x, y, width, height, rs, left, top;
RECT rClient;
LPIMAGE lpImage;
LPDISPLAY lpDisplay;

HWND hMDIWindow = hWnd;
CWnd *pWnd = CWnd::FromHandle(hMDIWindow);
if (pWnd->IsKindOf(RUNTIME_CLASS(CServerView)))        
	hMDIWindow = pWnd->GetParentFrame()->GetSafeHwnd();

if (IsIconic(hMDIWindow))
    return;

lpImage = GetImagePtr(hWnd);
lpDisplay = GetDisplayPtr(hWnd);

GetClientRect(hWnd, &rClient);
width = rClient.right - rClient.left;
height = rClient.bottom - rClient.top;
if (lpDisplay->HasRulers)
    {
    rs = GetRulerSize();
    width -= rs;
    height -= rs;
    }
if ((width <= 0 || height <= 0) && !View.ZoomWindow)
    return;

SaveLastView(hWnd);
lpDisplay->FileRect.top = 0;
lpDisplay->FileRect.left = 0;
lpDisplay->FileRect.bottom = lpImage->nlin - 1;
lpDisplay->FileRect.right = lpImage->npix - 1;
lpDisplay->FileRate = TINYRATE;
lpDisplay->ViewPercentage = 0;
x = ( lpDisplay->FileRect.left 
    + lpDisplay->FileRect.right+1 ) / 2;
y = ( lpDisplay->FileRect.top 
    + lpDisplay->FileRect.bottom+1 ) / 2;
if (View.ZoomWindow)
    {
	GetWinXY(hMDIWindow, &left, &top);
    FullViewWindow(hWnd, left, top, x, y, YES);
    }
else
    {
    ComputeDispRect(hWnd);
    ComputeFileRect(hWnd, x, y, lpDisplay->FileRate);
    SetupRulers(hWnd);
    InvalidateRect(hWnd, NULL, TRUE);
    }
}
Ejemplo n.º 5
0
/***************************************************************************
	ZoomBoundRect
		Takes sugested position and size for the zoom window in owner coords.
		Will set the inputs to allowed values.
***************************************************************************/
void ZoomBoundRect(int *x, int *y, int *width, int *height)
{
	LPIMAGE lpMyImage;
	RECT 	rZoom;
	int borderW, borderH, oldwidth, oldheight;
	LFIXED fRatio, fPreposedRatio;

	if (!hZoomWindow)
		return;

    lpMyImage = (LPIMAGE)GetImagePtr (hZoomWindow );
	if (!lpMyImage)
		return;
	// compute size or border
	GetWindowRect(hZoomWindow, &rZoom);
	oldwidth = rZoom.right - rZoom.left;
	oldheight = rZoom.bottom - rZoom.top;
	GetClientRect(hZoomWindow, &rZoom);
	borderW = oldwidth -(rZoom.right - rZoom.left);
	borderH = oldheight -(rZoom.bottom - rZoom.top);

//	GetClientRect(hOwner, &rOwner);
	// be sure the zoom widow is not larger than window
//	*width = Min(*width, rOwner.right - rOwner.left);
//	*height = Min(*height, rOwner.bottom - rOwner.top);

	// be sure aspect ratios are the same
	fPreposedRatio = FGET(*width-borderW, *height-borderH);
	fRatio = FGET(lpMyImage->npix, lpMyImage->nlin);

	// is it good enough?
	oldwidth = WHOLE(fRatio*(*height-borderH));
	if (oldwidth == (*width - borderW))
		return;
	
	if (fPreposedRatio > fRatio)
		{											// width too big
		*width = FMUL(*height-borderH, fRatio);
		*width += borderW;
		}
	else if (fPreposedRatio < fRatio)
		{												// height top big
		*height = FMUL(*width-borderW,
					FGET(lpMyImage->nlin, lpMyImage->npix));
		*height += borderH;
		}

//	*x = Bound (*x, -*width/2, rOwner.right-*width/2);
//	*y = Bound (*y, -*height/2, rOwner.bottom-*height/2);
	return;
}
Ejemplo n.º 6
0
void FloodProc( HWND hWindow, UINT msg, int x, int y, UINT32 Option )
/************************************************************************/
{
FRMDATATYPE type;
int res;
FLOOD_PARMS parms;
LPIMAGE lpImage;
RECT rArea;

switch (msg)
    {
    case WM_CREATE:	// The first mouse down message
	if (!IsOnImage(hWindow, x, y))
		break;
	Display2File(hWindow,&x, &y);
	lpImage = (LPIMAGE)GetImagePtr(hWindow);
	type = FrameType(ImgGetBaseEditFrame(lpImage));
	res = FrameResolution(ImgGetBaseEditFrame(lpImage));
	parms.FloodOpacity = Fill.FloodOpacity;
	parms.FloodMergeMode = Fill.FloodMergeMode;
	GetActiveColorFromType(type, &parms.Color);
	parms.iBaseRes = res;
	parms.x = x;
	parms.y = y;
	rArea.left = rArea.right = x;
	rArea.top = rArea.bottom = y;
	Measure(lpImage, &rArea, &parms.InColor);
	parms.FloodRange = Fill.FloodRange;
	parms.FloodFade = Fill.FloodFade;
	parms.idFloodColorModel = Fill.idFillColorModel;
	ProcessCommand(lpImage->lpCmdList, IDS_CMD_FLOOD, &parms);
	break;

    case WM_LBUTTONDOWN:
	break;

    case WM_LBUTTONUP:
	break;

    case WM_MOUSEMOVE:	// sent when ToolActive is on
	break;

    case WM_LBUTTONDBLCLK:
	break;

    case WM_DESTROY:	// The cancel operation message
	Tool.bActive = NO;
	break;
    }
}
Ejemplo n.º 7
0
static BOOL FileRectChanged(HWND hWnd)
/************************************************************************/
{
LPDISPLAY lpMyDisplay;
int fileW, fileH;
LPIMAGE lpMyImage;

lpMyDisplay = (LPDISPLAY)GetDisplayPtr(hZoomWindow);
lpMyImage = (LPIMAGE)GetImagePtr (hZoomWindow );

fileW = lpMyDisplay->FileRect.right - lpMyDisplay->FileRect.left + 1;
fileH = lpMyDisplay->FileRect.bottom - lpMyDisplay->FileRect.top + 1;

if (fileW != lpMyImage->npix || fileH != lpMyImage->nlin)
	return(TRUE);
return(FALSE);
}
Ejemplo n.º 8
0
void CObjectsPrefPage::HandleOK()
{
	HWND hActiveWnd;
	if (Control.MultipleObjects != m_bObjects)
		PictPubApp.EnableObjectMenu(AfxGetMainWnd()->GetMenu());
	LPIMAGE lpImage = NULL;
	if (hActiveWnd = GetActiveDoc())
		lpImage = GetImagePtr(hActiveWnd);
	if (!Control.UseMaskAndObjects &&
		Control.UseMaskAndObjects != m_bObjectMasks)
	{
		Control.UseMaskAndObjects = YES;
		RemoveObjectMarquee(lpImage);
		Control.UseMaskAndObjects = NO;
	}
	CPPPropertyPage::HandleOK();
}
Ejemplo n.º 9
0
void FullViewWindow( HWND hWindow, int x, int y, int cx, int cy,
                     BOOL fClipToImage )
/************************************************************************/
{
RECT NewWindowRect;
LPIMAGE lpImage;
LPDISPLAY lpDisplay;

HWND hMDIWindow = hWindow;
CWnd *pWnd = CWnd::FromHandle(hMDIWindow);
if (pWnd->IsKindOf(RUNTIME_CLASS(CServerView)))        
	hMDIWindow = pWnd->GetParentFrame()->GetSafeHwnd();

// if window is iconic, do nothing here
if (IsIconic(hMDIWindow))
    return;

lpImage = GetImagePtr(hWindow);
lpDisplay = GetDisplayPtr(hWindow);

// if window is maximized, do not change the size of the window
if ( !IsZoomed(hMDIWindow) )
    {
    // get the difference between the client area and the window area
    // not including scrollbars (i.e. - pretend scrollbars aren't there)
    // this is so we know how much extra size is needed for caption,
    // borders, etc. when we size the window
    CalcFullViewWindowSize( &NewWindowRect, &lpDisplay->FileRect,
        lpDisplay->FileRate, lpImage->npix, lpImage->nlin,
        x, y, lpDisplay->HasRulers, fClipToImage );
    // now actually size the window, it's possible nothing will happen here
    ASSERT(pWnd->IsKindOf(RUNTIME_CLASS(CServerView)));        
    pWnd->GetParentFrame()->MoveWindow(NewWindowRect.left, NewWindowRect.top,
        RectWidth(&NewWindowRect), RectHeight(&NewWindowRect), TRUE);
    }

// recompute DispRect and FileRect for cx and cy
// and also it's possible there was no WM_SIZE
ComputeDispRect(hWindow);
ComputeFileRect(hWindow, cx, cy, lpDisplay->FileRate );
SetupRulers(hWindow);
InvalidateRect(hWindow, NULL, TRUE);
}
Ejemplo n.º 10
0
/***************************************************************************
	ResizeMoveZoom
			checks if the current zoom window size and position are
				 compatable with the	owner window and the image size.
			Returns true if size or position was CHANGED.
			May change size of window, but does not redraw.
***************************************************************************/
BOOL ResizeMoveZoom()
{
LPIMAGE lpMyImage;
HWND	hParent;
RECT 	rZoom;
POINT ptZoomLT;
int 	x,y,h,w,oldheight, oldwidth;
BOOL bRet;


if (!hZoomWindow)
	return(FALSE);

lpMyImage = (LPIMAGE)GetImagePtr (hZoomWindow );
hParent = PictPubApp.Get_hWndAstral();
if (!hParent || !lpMyImage)
	return(FALSE);

GetWindowRect(hZoomWindow, &rZoom);
w = oldwidth = rZoom.right - rZoom.left;
h = oldheight = rZoom.bottom - rZoom.top;
ptZoomLT.x = rZoom.left;
ptZoomLT.y = rZoom.top;
ScreenToClient(hParent, &ptZoomLT);	 //find upper left in owner coords
x = ptZoomLT.x;
y = ptZoomLT.y;

ZoomBoundRect(&x, &y, &w, &h);

if (zoomdepth > 6)
	return(FALSE);
zoomdepth++;
if ( w != oldwidth || h != oldheight ||
		x != ptZoomLT.x ||y != ptZoomLT.y)
	{
	bRet = MoveWindow(hZoomWindow,x,y,oldwidth,oldheight, TRUE);
	//SendMessage(hZoomWindow, WM_NCPAINT, 0, 0L);
	}
zoomdepth--;
return (FALSE);
}
Ejemplo n.º 11
0
/************************************************************************
  ComputeZoomDisp
		Computes and sets values for the lpDisplay.
************************************************************************/
void ComputeZoomDisp()
{
LPDISPLAY lpMyDisplay;
RECT area;
int fileH, fileW, dispH, dispW;
int x, y;
LPIMAGE lpMyImage;


if (!hZoomWindow)
	return;
lpMyDisplay = (LPDISPLAY)GetDisplayPtr(hZoomWindow);
lpMyImage = (LPIMAGE)GetImagePtr (hZoomWindow );
if (!lpMyDisplay)
	return;
GetClientRect(hZoomWindow, &area);

dispH = area.bottom - area.top;
dispW = area.right - area.left;

x = 0;
y = 0;

// set lpDisplay
lpMyDisplay->DispRect.left = x;
lpMyDisplay->DispRect.right = x+dispW-1;
lpMyDisplay->DispRect.top =y ;
lpMyDisplay->DispRect.bottom = y+dispH-1;

fileW = lpMyImage->npix;
fileH = lpMyImage->nlin;

lpMyDisplay->FileRect.left   = x;
lpMyDisplay->FileRect.top	 = y;
lpMyDisplay->FileRect.right  = x + fileW - 1;
lpMyDisplay->FileRect.bottom = y + fileH - 1;

lpMyDisplay->FileRate = FGET(fileW, dispW);

BoundRect( &lpMyDisplay->FileRect, 0, 0, lpMyImage->npix-1, lpMyImage->nlin-1 );
}
Ejemplo n.º 12
0
void TintFillProc( HWND hWindow, UINT msg, int x, int y, UINT32 Option )
/************************************************************************/
{
LPIMAGE lpImage;
FRMDATATYPE type;
TINTFILL_PARMS parms;

switch (msg)
    {
    case WM_CREATE:	// The first mouse down message
	if (!IsOnImage(hWindow, x, y))
		break;
    lpImage = (LPIMAGE)GetImagePtr ( hWindow );
	type = FrameType(ImgGetBaseEditFrame(lpImage));

	parms.FillOpacity = Fill.FillOpacity;
	parms.FillMergeMode = Fill.FillMergeMode;
	GetActiveColorFromType(type, &parms.Color);

	ProcessCommand(lpImage->lpCmdList, IDS_CMD_TINTFILL, &parms);
	break;

    case WM_LBUTTONDOWN:
	break;

    case WM_LBUTTONUP:
	break;

    case WM_MOUSEMOVE:	// sent when ToolActive is on
	break;

    case WM_LBUTTONDBLCLK:
	break;

    case WM_DESTROY:	// The cancel operation message
	Tool.bActive = NO;
	break;
    }
}
Ejemplo n.º 13
0
BOOL ZoomPaint( HWND hWnd )
/************************************************************************/
{
PAINTSTRUCT ps;
HDC hDC;
RECT rPaint;
LPDISPLAY lpDisplay;
LPIMAGE lpImage;

hDC = BeginPaint(hWnd, &ps);
lpDisplay = (LPDISPLAY)GetDisplayPtr(hWnd);
lpImage = (LPIMAGE)GetImagePtr (hWnd);
if (lpImage && lpDisplay)
	{
	rPaint = ps.rcPaint;
	AstralToWindowsRect(&rPaint);
	lpImage->Paint(hWnd,hDC,&rPaint,NULL); 		// will paint the invert box
	AstralSetRectEmpty(&lpDisplay->UpdateRect);
	}
EndPaint(hWnd, &ps);
return (TRUE);

}
Ejemplo n.º 14
0
void ZoomBoundSize( MINMAXINFO FAR *lpInfo )
/***************************************************************************/
{
LPIMAGE lpMyImage;
RECT rArea;
int borderW, borderH;

if (!hZoomWindow)
	return;
lpMyImage = (LPIMAGE)GetImagePtr (hZoomWindow );

if (!lpMyImage)
	return;
GetWindowRect(hZoomWindow, &rArea);
borderW = rArea.right - rArea.left;
borderH = rArea.bottom - rArea.top;
GetClientRect(hZoomWindow, &rArea);
borderW -= rArea.right - rArea.left;
borderH -= rArea.bottom - rArea.top;
lpInfo->ptMinTrackSize.x = Min(32+borderW, lpMyImage->npix+borderW);
lpInfo->ptMinTrackSize.y = Min(32+borderH, lpMyImage->nlin+borderH);
return;
}
Ejemplo n.º 15
0
BOOL CanZoom( HWND hWnd, LFIXED FileRate, LPRECT lpFileRect,
               LPRECT lpDispRect )
/************************************************************************/
{
LFIXED DispRate;
long lFileWidth, lFileHeight;
int iDispWidth, iDispHeight;
LPIMAGE lpImage;

lpImage = GetImagePtr(hWnd);
if (FileRate != 0)  // FileRate passed in
    DispRate = FGET(FUNITY, FileRate);
else        // Displaying a FileRect
    {
    // calculate DispRate using this FileRect and
    // DispRect.
    iDispWidth = RectWidth(lpDispRect);
    iDispHeight = RectHeight(lpDispRect);
    DispRate = ScaleToFit(&iDispWidth, &iDispHeight,
                RectWidth(lpFileRect),
                RectHeight(lpFileRect));
    }
// Calculate eventual size in File coordinates using
// this DispRate.  This calculation is done by most
// of the viewing routines and has the possibility
// of overflow.  Usually in these routines when the
// calculation is made it is too late to turn back
// so those routines call CanZoom() before doing
// anything that is unreversible.
lFileWidth = FMUL(lpImage->npix, DispRate);
lFileHeight = FMUL(lpImage->nlin, DispRate);
// Although MAXINT is 32767, I decided to use 30000 just
// for some slop and my own paranoia
return(lFileWidth > 0L && lFileWidth <= MAX_IMAGE_WIDTH &&
       lFileHeight > 0L && lFileHeight <= MAX_IMAGE_HEIGHT);
}
Ejemplo n.º 16
0
void RevertLastView(HWND hWnd)
/************************************************************************/
{
int iWidth, iHeight, i;
RECT FileRect, WindowRect,r;
LFIXED FileRate;
int ViewPercentage;
POINT UpperLeft;
LPIMAGE lpImage;
LPDISPLAY lpDisplay;
HWND hMDIWindow = hWnd;
HWND  hClient;

lpImage = GetImagePtr(hWnd);
lpDisplay = GetDisplayPtr(hWnd);

CWnd *pWnd = CWnd::FromHandle(hMDIWindow);
if (pWnd->IsKindOf(RUNTIME_CLASS(CServerView)))        
	hMDIWindow = pWnd->GetParentFrame()->GetSafeHwnd();

if (IsIconic(hMDIWindow))
    return;

FileRect = lpDisplay->FileRect;
lpDisplay->FileRect = lpDisplay->LastFileRect;
lpDisplay->LastFileRect = FileRect;
FileRate = lpDisplay->FileRate;
lpDisplay->FileRate = lpDisplay->LastFileRate;
lpDisplay->LastFileRate = FileRate;
ViewPercentage = lpDisplay->ViewPercentage;
lpDisplay->ViewPercentage = lpDisplay->LastViewPercentage;
lpDisplay->LastViewPercentage = ViewPercentage;
ComputeDispRect(hWnd);
ComputeFileRect(hWnd, -1, -1, lpDisplay->FileRate);
GetWindowRect(hWnd, &WindowRect);
hClient = GetParent(hMDIWindow);
ScreenToClient(hClient, (LPPOINT)&WindowRect);
ScreenToClient(hClient, (LPPOINT)&WindowRect.right);
if (!IsZoomed(hMDIWindow) && !EqualRect(&lpDisplay->LastWindowRect, &WindowRect))
    {
    GetWindowRect(hMDIWindow, &r);
    ScreenToClient(hClient, (LPPOINT)&r);
    ScreenToClient(hClient, (LPPOINT)&r.right);
    iWidth   = RectWidth(&lpDisplay->LastWindowRect)-1;
    iWidth  += r.right - WindowRect.right;
    iHeight  = RectHeight(&lpDisplay->LastWindowRect)-1;
    iHeight += r.bottom - WindowRect.bottom;
    UpperLeft.x  = lpDisplay->LastWindowRect.left;
    i            = (WindowRect.left - r.left);
    UpperLeft.x -= i;
    iWidth      += i;
    UpperLeft.y  = lpDisplay->LastWindowRect.top;
    i            = (WindowRect.top - r.top);
    UpperLeft.y -= i;
    iHeight     += i;
    MoveWindow(hMDIWindow,UpperLeft.x, UpperLeft.y, iWidth, iHeight, TRUE);

    lpDisplay->LastWindowRect = WindowRect;
    }
else
    {
    SetupRulers(hWnd);
    InvalidateRect(hWnd, NULL, TRUE);
    }
ZoomMainViewChanged(hWnd);
}
Ejemplo n.º 17
0
BOOL ScrollImage( HWND hWnd, BOOL fVScroll, UINT code, int pos )
/************************************************************************/
{
int fy, dy, fx, dx;
RECT rScroll;
BOOL bScrollWindow;
#define SCROLLPIXELS 10
LPIMAGE lpImage;
LPDISPLAY lpDisplay;

lpImage = GetImagePtr(hWnd);
lpDisplay = GetDisplayPtr(hWnd);

if (IsIconic(hWnd))
    return( NO );

bScrollWindow = NO;
rScroll = lpDisplay->DispRect;
rScroll.bottom++; rScroll.right++;
if (fVScroll &&
    ( lpImage->nlin - RectHeight( &lpDisplay->FileRect ) > 0 ) )
    {
    switch ( code )
        {
        case SB_ENDSCROLL:
        ScrollEnd( hWnd );
        break;

        case SB_TOP:
        case SB_BOTTOM:
        MessageBeep(0);
        break;

        case SB_PAGEUP:
        case SB_PAGEDOWN:
        case SB_LINEUP:
        case SB_LINEDOWN:
        fy = SCROLLPIXELS;
        if ( code == SB_PAGEUP || code == SB_PAGEDOWN )
            fy *= 10;
        if ( !(fy = FMUL( fy, lpDisplay->FileRate )) )
            fy = 1;
        if ( code == SB_LINEDOWN || code == SB_PAGEDOWN )
            {
            fy = -fy;
            dy = lpDisplay->FileRect.bottom - lpImage->nlin + 1;
            }
        else
        // ( code == SB_LINEUP || code == SB_PAGEUP )
            dy = lpDisplay->FileRect.top;
        if ( !dy )
            break;
        if ( abs(fy) > abs(dy) )
            fy = dy;
        if ( !(dy = FMUL( fy, lpDisplay->DispRate )) )
            break;
        ScrollStart( hWnd );
        lpDisplay->FileRect.top -= fy;
        lpDisplay->FileRect.bottom -= fy;
        lpDisplay->yDiva -= dy;
        ScrollWindow( hWnd, 0 /*x*/, dy, &rScroll, &rScroll );
        AstralUpdateWindow(hWnd);
        bScrollWindow = YES;
        break;

        case SB_THUMBPOSITION:
        case SB_THUMBTRACK:
        if ( !(fy = GetDisplayScrollDelta( hWnd, lpDisplay, SB_VERT, pos) ) )
            break;
        if ( !(dy = FMUL( fy, lpDisplay->DispRate )) )
            break;
        ScrollStart( hWnd );
        lpDisplay->FileRect.top -= fy;
        lpDisplay->FileRect.bottom -= fy;
        lpDisplay->yDiva -= dy;
        ScrollWindow( hWnd, 0 /*x*/, dy, &rScroll, &rScroll );
        AstralUpdateWindow(hWnd);
        bScrollWindow = YES;
        break;
        }
    }

if (!fVScroll &&
    ( lpImage->npix - RectWidth( &lpDisplay->FileRect ) > 0 ) )
    {
    switch ( code )
        {
        case SB_ENDSCROLL:
        ScrollEnd( hWnd );
        break;

        case SB_TOP:
        case SB_BOTTOM:
        MessageBeep(0);
        break;

        case SB_PAGEUP:
        case SB_PAGEDOWN:
        case SB_LINEUP:
        case SB_LINEDOWN:
        fx = SCROLLPIXELS;
        if ( code == SB_PAGEUP || code == SB_PAGEDOWN )
            fx *= 10;
        if ( !(fx = FMUL( fx, lpDisplay->FileRate )) )
            fx = 1;
        if ( code == SB_LINEDOWN || code == SB_PAGEDOWN )
            {
            fx = -fx;
            dx = lpDisplay->FileRect.right - lpImage->npix + 1;
            }
        else
        // ( code == SB_LINEUP || code == SB_PAGEUP )
            dx = lpDisplay->FileRect.left;
        if ( !dx )
            break;
        if ( abs(fx) > abs(dx) )
            fx = dx;
        if ( !(dx = FMUL( fx, lpDisplay->DispRate )) )
            break;
        ScrollStart( hWnd );
        lpDisplay->FileRect.left -= fx;
        lpDisplay->FileRect.right -= fx;
        lpDisplay->xDiva -= dx;
        ScrollWindow( hWnd, dx, 0 /*y*/, &rScroll, &rScroll );
        AstralUpdateWindow(hWnd);
        bScrollWindow = YES;
        break;

        case SB_THUMBPOSITION:
        case SB_THUMBTRACK:
        if ( !(fx = GetDisplayScrollDelta( hWnd, lpDisplay, SB_HORZ, pos )) )
            break;
        if ( !(dx = FMUL( fx, lpDisplay->DispRate )) )
            break;
        ScrollStart( hWnd );
        lpDisplay->FileRect.left -= fx;
        lpDisplay->FileRect.right -= fx;
        lpDisplay->xDiva -= dx;
        ScrollWindow( hWnd, dx, 0 /*y*/, &rScroll, &rScroll );
        AstralUpdateWindow(hWnd);
        bScrollWindow = YES;
        break;
        }
    }

return( bScrollWindow );
}
Ejemplo n.º 18
0
void ComputeFileRect( HWND hWnd, int x, int y, LFIXED FileRate )
/************************************************************************/
{
int fx, fy, DispWidth, DispHeight, dx, dy;
LFIXED DispRate;
LPIMAGE lpImage;
LPDISPLAY lpDisplay;

// A NULL FileRate is a signal that FileRect was just initialized
// and doesn't need recalculating
if ( !FileRate)
    return;

lpImage = GetImagePtr(hWnd);
lpDisplay = GetDisplayPtr(hWnd);

// FileRect will be recomputed from FileRate and a center point (x,y)
DispWidth = RectWidth( &lpDisplay->DispRect );
DispHeight = RectHeight( &lpDisplay->DispRect );

DispRate = FGET(FUNITY, lpDisplay->FileRate);
dx = FMUL(lpImage->npix, DispRate);
dy = FMUL(lpImage->nlin, DispRate);
// FileRate == 1 is a special case for handling iconic state
// otherwise handle normally
if ( FileRate == TINYRATE) // Display all of image - iconic state
    {
    fx = lpImage->npix;
    fy = lpImage->nlin;
    lpDisplay->ViewPercentage = 0;
    }
else 
    {
    // if image fits or is smaller than display surface
    // use maximum FileRect, otherwise use current FileRate
    if (dx <= DispWidth)
        fx = lpImage->npix;
    else
        fx = FMUL( DispWidth, FileRate );
    if (dy <= DispHeight)
        fy = lpImage->nlin;
    else
        fy = FMUL( DispHeight, FileRate );
    }

if (x == -1 && y == -1) // special signal to use old XY
    {
    x = lpDisplay->FileRect.left;
    y = lpDisplay->FileRect.top;
    }
else
    {
    x -= ( fx / 2 );
    y -= ( fy / 2 );
    }
if ( x < 0 ) x = 0;
if ( y < 0 ) y = 0;
if ( x + fx - 1 >= lpImage->npix )  x = lpImage->npix - fx;
if ( y + fy - 1 >= lpImage->nlin )  y = lpImage->nlin - fy;
lpDisplay->FileRect.left   = x;
lpDisplay->FileRect.top = y;
lpDisplay->FileRect.right  = x + fx - 1;
lpDisplay->FileRect.bottom = y + fy - 1;
BoundRect( &lpDisplay->FileRect, 0, 0, lpImage->npix-1, lpImage->nlin-1 );
}
Ejemplo n.º 19
0
void ComputeDispRect(HWND hWnd)
/************************************************************************/
{
int w, h, dx, dy;
int iWidth, iHeight, iImageWidth, iImageHeight;
LFIXED DispRate;
RECT DispRect;
BOOL bZoomed, bIconic;
LPIMAGE lpImage;
LPDISPLAY lpDisplay;

lpImage = GetImagePtr(hWnd);
lpDisplay = GetDisplayPtr(hWnd);

BOOL bInPlaceFrameType = FALSE;
HWND hMDIWindow = hWnd;
CWnd *pWnd = CWnd::FromHandle(hMDIWindow);
if (pWnd->IsKindOf(RUNTIME_CLASS(CServerView)))        
{
	hMDIWindow = pWnd->GetParentFrame()->GetSafeHwnd();
	bInPlaceFrameType = ((CServerView*)pWnd)->GetDocument()->IsInPlaceActive();
}

// get max size of client area with no scrollbars
GetDispRect(hWnd, &DispRect, 1, 1);
w = RectWidth(&DispRect);
h = RectHeight(&DispRect);

// If we have no FileRate to this point, it means somebody wants
// to display a specific FileRect.  Calculate a FileRate so that
// we can calculate a DispRect.  This is necessary because it is
// possible (when the window is maximized for example) that the
// FileRect requested will not fill up the window, so it would
// need to be recalculated.  It is assumed that scrollbars would
// not be needrf and should not be needed if the calculation is
// done correctly, which hopefully it is.
if (!lpDisplay->FileRate)
    {
    iWidth = w; iHeight = h;
    DispRate = ScaleToFit(&iWidth, &iHeight, RectWidth(&lpDisplay->FileRect), RectHeight(&lpDisplay->FileRect));
    lpDisplay->FileRate = FGET(FUNITY, DispRate);
    }
if (lpDisplay->FileRate == TINYRATE) // Iconic
    {
    iWidth = w;
    iHeight = h;

    iImageWidth = lpImage->npix;
    iImageHeight = lpImage->nlin;
    DispRate = ScaleToFit(&iWidth, &iHeight, iImageWidth, iImageHeight);
	//---------------------------------------------------------------------
	// NOTE!! added bInPlaceFrameType here because Insitu needs to be able 
	// to scale over 100%.
	//---------------------------------------------------------------------
	if (!bInPlaceFrameType && (DispRate > FGET(1, 1))) 
        {
        DispRate = FGET(1, 1);
        iWidth = FMUL(iImageWidth, DispRate);
        iHeight = FMUL(iImageHeight, DispRate);
        }
    }
else // if (lpDisplay->FileRate) // Specific FileRate
    {
    // Calulate how much space is needed at this FileRate
    DispRate = FGET(FUNITY, lpDisplay->FileRate);
    iImageWidth = FMUL(lpImage->npix, DispRate);
    iImageHeight = FMUL(lpImage->nlin, DispRate);

    // See if scrollbars will be necessary and get the
    // appropriate DispRect if so
    if (iImageWidth > w && iImageHeight > h)
        {
        GetDispRect(hWnd, &DispRect, 2, 2);
        }
    else
    if (iImageWidth > w)
        {
        GetDispRect(hWnd, &DispRect, 2, 1);
        h = RectHeight(&DispRect);
        if (iImageHeight > h)
            {
            GetDispRect(hWnd, &DispRect, 2, 2);
            }
        }
    else
    if (iImageHeight > h)
        {
        GetDispRect(hWnd, &DispRect, 1, 2);
        w = RectWidth(&DispRect);
        if (iImageWidth > w)
            {
            GetDispRect(hWnd, &DispRect, 2, 2);
            }
        }
    w = RectWidth(&DispRect);
    h = RectHeight(&DispRect);
    iWidth = w;
    iHeight = h;

    // Clip the DispRect size to the amount needed for image
    if (iImageWidth < iWidth)
        iWidth = iImageWidth;
    if (iImageHeight < iHeight)
        iHeight = iImageHeight;
    }

bIconic = IsIconic(hMDIWindow);
bZoomed = IsZoomed(hMDIWindow);
if (bZoomed || bIconic)
    {
    dy = RectHeight(&DispRect) - iHeight;
    dy /= 2;
    dx = RectWidth(&DispRect) - iWidth;
    dx /= 2;
    lpDisplay->DispRect.top = DispRect.top + dy;
    lpDisplay->DispRect.left = DispRect.left + dx;
    }
else
    {
    lpDisplay->DispRect.top = DispRect.top;
    lpDisplay->DispRect.left = DispRect.left;
    }
lpDisplay->DispRect.bottom = lpDisplay->DispRect.top + iHeight - 1;
lpDisplay->DispRect.right = lpDisplay->DispRect.left + iWidth - 1;
}
Ejemplo n.º 20
0
void VignetteProc( HWND hWindow, UINT msg, int x, int y, UINT32 Option )
/************************************************************************/
{
RECT Rect;
BOOL fShift;
POINT pt;
static int Type, Style;
static BOOL fConstrain;
static RECT SelectRect;
int res;
FRMDATATYPE type;
LPIMAGE lpImage;
STRING szString;
GRADIENT_PARMS parms;

switch (msg)
    {
    case WM_CREATE:	// The first mouse down message
	if (!IsOnImage(hWindow, x, y))
		break;
	ImgGetInfo(GetActiveImage(), NULL, NULL, NULL, &type);
	if (type == FDT_LINEART)
		{
		AstralStrEx( IDC_TOOLNAMESTART+IDC_VIGNETTE, szString, sizeof(szString) );
		Message(IDS_NOTWITHLINEART, (LPSTR)szString);
		break;
		}
	AstralUpdateWindow(hWindow);
	Tool.bActive = YES;
//	SetMaskingState( x, y );
	break;

    case WM_LBUTTONDOWN:
	Type = Vignette.Gradient;
	fConstrain = ( Type == IDC_VIGSQUARE || Type == IDC_VIGCIRCLE );
	AstralSetRectEmpty( &SelectRect );
	if ( Type == IDC_VIGCIRCLE || Type == IDC_VIGELLIPSE )
		Style = SL_ELLIPSE;
	else
	if ( Type == IDC_VIGRADIAL || Type == IDC_VIGLINEAR )
		Style = SL_LINE;
	else
		Style = SL_BOX;
	pt.x = x; pt.y = y;
	StartSelection( hWindow, NULL, &SelectRect, Style | SL_SPECIAL,
		pt, 0L );
	break;

    case WM_LBUTTONUP:
	Tool.bActive = NO;
	Rect = SelectRect; // make a copy before it gets ordered
	EndSelection( hWindow, NULL, &SelectRect, Style, YES );
    lpImage = (LPIMAGE)GetImagePtr ( hWindow );
	res = FrameResolution(ImgGetBaseEditFrame(lpImage));
	type = FrameType(ImgGetBaseEditFrame(lpImage));

	parms.VigOpacity = Vignette.VigOpacity;
	parms.VigMergeMode = Vignette.VigMergeMode;
	parms.iBaseRes = res;
	parms.x1 = Rect.left;
	parms.y1 = Rect.top;
	parms.x2 = Rect.right;
	parms.y2 = Rect.bottom;
	GetActiveColorFromType(type, &parms.StartColor);
	GetAlternateColorFromType(type, &parms.EndColor);
	parms.Gradient = Vignette.Gradient;
	parms.RepeatCount = Vignette.RepeatCount;
	parms.SoftTransition = Vignette.SoftTransition;
	parms.Midpoint = Vignette.Midpoint;
	parms.VigColorModel = Vignette.VigColorModel;
	ProcessCommand(lpImage->lpCmdList, IDS_CMD_GRADIENT, &parms);
	break;

    case WM_MOUSEMOVE:	// sent when ToolActive is on
	fShift = SHIFT;
	pt.x = x; pt.y = y;
	UpdateSelection( hWindow, NULL, &SelectRect, Style,
		pt, fConstrain^CONSTRAINASPECT, 1L, 1L,
		MOVEKEY||Window.fRButtonDown, FROMCENTER);
	break;

    case WM_LBUTTONDBLCLK:
	break;

    case WM_DESTROY:	// The cancel operation message
	if (!Tool.bActive)
		break;
	Tool.bActive = NO;
	EndSelection( hWindow, NULL, &SelectRect, Style, YES );
	break;
    }
}
Ejemplo n.º 21
0
LOCAL BOOL FullScreenView_OnInitDialog(HWND hDlg, HWND hWndFocus, LPARAM lParam)
{
	CPPMDIChildWnd *pMDIChild;
	HWND hMDIWnd;
	RECT ClientRect;
	int npix, nlin, cx, cy, dx, dy;
	HWND hControl, hMDIChild, hView;
	LPOBJECT lpBase;
	LPFRAME lpFrame;

	// Make the window as big as the screen
	dx = GetSystemMetrics( SM_CXSCREEN );
	dy = GetSystemMetrics( SM_CYSCREEN );
	MoveWindow( hDlg, 0, 0, dx, dy, NO );

	// Compute the center of the window
	GetClientRect( hDlg, &ClientRect );
	cx = ( ClientRect.right + ClientRect.left ) / 2;
	cy = ( ClientRect.bottom + ClientRect.top ) / 2;

	// Link all of the images to image controls
	hControl = GetDlgItem( hDlg, IDC_VIEWFULL );

	CServerView *pView = PictPubApp.GetActiveView();
	BOOL bInplaceActive = (pView && pView->GetDocument()->IsInPlaceActive());
	if (bInplaceActive)
	{
		hMDIChild = pView->GetParentFrame()->GetSafeHwnd();
		hView = pView->GetSafeHwnd();
	}
	else
	{
		pMDIChild = (CPPMDIChildWnd*)((CMDIFrame*)PictPubApp.m_pMainWnd)->MDIGetActive();
		hMDIWnd = pMDIChild->GetSafeHwnd();
		if (hMDIWnd)
			hView = pMDIChild->GetActiveView()->GetSafeHwnd();
		else
			hView = NULL;
	}

	while ( hView )
 	{
		lpBase = ImgGetBase((LPIMAGE)GetImagePtr(hView));
		if ( !lpBase || !hControl )
			break;
		lpFrame = ObjGetEditFrame(lpBase);

		// Link the frame to the image control
		SetWindowLong( hControl, GWL_IMAGE, (long)lpBase );
			
		// The destination size can be no bigger the the screen
		npix = FrameXSize(lpFrame);
		nlin = FrameYSize(lpFrame);
		if ( npix > dx || nlin > dy )
 		{
			npix = dx;
			nlin = dy;
			ScaleToFit( &npix, &nlin,
				FrameXSize(lpFrame), FrameYSize(lpFrame));
 		}

		// Position the control in the center of the window
		ClientRect.left = cx - npix/2;
		ClientRect.right = ClientRect.left + npix;
		ClientRect.top = cy - nlin/2;
		ClientRect.bottom = ClientRect.top + nlin;
		MoveWindow( hControl,
			ClientRect.left, ClientRect.top, // New position
			RectWidth( &ClientRect ),
			RectHeight( &ClientRect ), // New size
			NO /* No repaint*/ );

		if (bInplaceActive)
			break;

		// Check to see if these get destroyed when the window does
		do	
		{
			hView = NULL;
			if (hMDIWnd = GetWindow( hMDIWnd, GW_HWNDNEXT ))
			{
				if ((CWnd::FromHandle(hMDIWnd))->
					IsKindOf(RUNTIME_CLASS(CPPMDIChildWnd)))
					hView = ((CPPMDIChildWnd*)CWnd::FromHandle(hMDIWnd))->
						GetActiveView()->GetSafeHwnd();
			}

		} while (hMDIWnd && !hView);

		if (!hView)
			break;

		// Get another image control				 
		hControl = CopyWindow( hControl );
	}

	return TRUE;
}
void
IndexedFont_Kerned :: RenderString_Unclipped
(
	struct r2pos& R2Pos_Cursor,
	int FixP_Alpha,
	const SCString& SCStr
) const
#if 1
{
	ProjChar* pProjChar_I = SCStr . pProjCh();

	const LPDIRECTDRAWSURFACE image_ptr = GetImagePtr();

	DDSURFACEDESC ddsdimage;
	
	memset(&ddsdimage, 0, sizeof(ddsdimage));
	ddsdimage.dwSize = sizeof(ddsdimage);

	/* lock the image */
	while (image_ptr->Lock(NULL, &ddsdimage, DDLOCK_WAIT, NULL) == DDERR_WASSTILLDRAWING);

	while ( *pProjChar_I )
	{
		const ProjChar ProjCh = *pProjChar_I;

		if
		(
			bCanRender( ProjCh )
		)
		{
			#if 0
			textprint("printable \'%c\'\n",ProjCh);
			#endif

			#if 0
			RenderChar_Clipped
			(
				R2Pos_Cursor,
				R2Rect_Clip,
				FixP_Alpha,
				ProjCh
			);
			#else
			if (ProjCh != ' ')
			{
				unsigned int theOffset=ProjCh - 32;
				int width = GetWidth(ProjCh);

				/*
				if
				(
					GetOffset
					(
						theOffset,
						ProjCh
					)
				)
				*/
				{
					if
					(
						width>0
					)
					{
						{
							// This code adapted from DrawGraphicWithAlphaChannel();
							// it assumes you're in a 16-bit mode...

							// okay, now we have the surfaces, we can copy from one to the other,
							// darkening pixels as we go
							{
								long fontimagePitchInShorts = (ddsdimage.lPitch/2); 
								long backbufferPitchInShorts = (BackBufferPitch/2); 

								unsigned short* fontimageRowStartPtr =
								(
									((unsigned short *)ddsdimage.lpSurface)
									+
									(GetHeight()*theOffset*fontimagePitchInShorts)
								);

								unsigned short* backbufferRowStartPtr =
								(
									((unsigned short *)ScreenBuffer)
									+
									(R2Pos_Cursor.y*backbufferPitchInShorts)
									+
									(R2Pos_Cursor.x)
								);
								int screenY = R2Pos_Cursor.y;

								for (int yCount=GetHeight(); yCount>0; yCount--)
								{
									unsigned short* fontimagePtr = fontimageRowStartPtr;
									unsigned short* backbufferPtr = backbufferRowStartPtr;

									int xIndex = R2Pos_Cursor.x+CloakingPhase/64;
									int yIndex = (screenY+CloakingPhase/128)&127;

//									if (screenY >= R2Rect_Clip.y0 && screenY <= R2Rect_Clip.y1)
									for (int xCount=width; xCount>0;xCount--)
									{
										int r = CloudTable[(xCount+xIndex)&127][yIndex];
			//							b += CloudTable[((xCount+R2Pos_Cursor.x)/2-CloakingPhase/96)&127][((yCount+R2Pos_Cursor.y)/4+CloakingPhase/64)&127]/4;
			//							b += CloudTable[((xCount+R2Pos_Cursor.x+10)/4-CloakingPhase/64)&127][((yCount+R2Pos_Cursor.y-50)/8+CloakingPhase/32)&127]/8;
			//							if (b>ONE_FIXED) b = ONE_FIXED;
										r = MUL_FIXED(FixP_Alpha,r);
										//int r = FixP_Alpha;
										if (*fontimagePtr)
										{
											unsigned int backR = (int)(*backbufferPtr) & DisplayPixelFormat.dwRBitMask;
											unsigned int backG = (int)(*backbufferPtr) & DisplayPixelFormat.dwGBitMask;
											unsigned int backB = (int)(*backbufferPtr) & DisplayPixelFormat.dwBBitMask;

											unsigned int fontR = (int)(*fontimagePtr) & DisplayPixelFormat.dwRBitMask;
											unsigned int fontG = (int)(*fontimagePtr) & DisplayPixelFormat.dwGBitMask;
											unsigned int fontB = (int)(*fontimagePtr) & DisplayPixelFormat.dwBBitMask;

											backR += MUL_FIXED(r,fontR);
											if (backR>DisplayPixelFormat.dwRBitMask) backR = DisplayPixelFormat.dwRBitMask;
											else backR &= DisplayPixelFormat.dwRBitMask;

											backG += MUL_FIXED(r,fontG);
											if (backG>DisplayPixelFormat.dwGBitMask) backG = DisplayPixelFormat.dwGBitMask;
											else backG &= DisplayPixelFormat.dwGBitMask;

											backB += MUL_FIXED(r,fontB);
											if (backB>DisplayPixelFormat.dwBBitMask) backB = DisplayPixelFormat.dwBBitMask;
											else backB &= DisplayPixelFormat.dwBBitMask;

											*backbufferPtr = (short)(backR|backG|backB);
										}
										fontimagePtr++;
										backbufferPtr++;
									}
									screenY++;
									fontimageRowStartPtr += fontimagePitchInShorts;
									backbufferRowStartPtr += backbufferPitchInShorts;
								}
							}
						   	
						}
					}
				}
			}

			#endif
		}
		else
		{
			#if 0
			textprint("unprintable \'%c\'\n",ProjCh);
			#endif
		}

		R2Pos_Cursor . x += 1+GetXInc
		(
            ProjCh,
            *(pProjChar_I+1)
		);
            // this takes responsibility for updating cursor pos,
            // rather than the RenderChar function

		pProjChar_I++;
	}
	image_ptr->Unlock((LPVOID)ddsdimage.lpSurface);
}
Ejemplo n.º 23
0
/************************************************************************
	UnhookZoom
		Unhooks the zoom window from the specified window.
		if this was its owner then zoom window destroys itself..
************************************************************************/

void UnhookZoom(HWND hWnd)
{
HWND hOwner, hWndMe;

if (!hZoomWindow)
	return;
hOwner = GetZoomOwner(hZoomWindow);
if (hOwner != hWnd || !hOwner)
	return;
hWndMe = hZoomWindow;
DestroyWindow(hWndMe);		// will set hZoomWindow = NULL
hZoomWindow = NULL;
}

//************************************************************************
//  ZoomSizeToDef
//		  Computes and sets size and position on the screen
//				for the new zoom window	according to the defaults
//***********************************************************************/
void ZoomSizeToDef()
{
	LPIMAGE lpMyImage;
	RECT rOwner, rArea, rParent;
	HWND hWndOwner,hParent;
	int x,y,height, width;
	int borderW, borderH;
	STRING szString;

	if (!hZoomWindow)
		return;
    lpMyImage = (LPIMAGE)GetImagePtr (hZoomWindow );
	hWndOwner = GetZoomOwner(hZoomWindow);
	hParent = PictPubApp.Get_hWndAstral();
	if (!hWndOwner || !hParent)
		return;
	if (hZoomWindow && lpMyImage )
	{
		x = View.rZoomRect.left;
		y = View.rZoomRect.top;
		width  = View.rZoomRect.right - View.rZoomRect.left;
		height = View.rZoomRect.bottom - View.rZoomRect.top;
		if (height == 0 || width == 0)
		{ // no previous values
			// use saved values if possible
			GetDefaultString( _T("sizeZoom"), _T("0,0"), szString, sizeof(STRING) );
			AsciiToInt2( szString, &width, &height);
			if (width+height != 0)
			{
				MoveWindow (hZoomWindow,x,y,width, height, FALSE);
				if (RestorePopup( hZoomWindow, _T("xyZoom"), NULL ))
				{
					// Restore popup will change View.rZoomRect
					x = View.rZoomRect.left;
					y = View.rZoomRect.top;
					MoveWindow (hZoomWindow,x,y,width, height, FALSE);
					return;
				}
			}
			// saved values failed, now use defaults
			GetWindowRect(hZoomWindow, &rArea);
			borderW = rArea.right - rArea.left;
			borderH = rArea.bottom - rArea.top;
			GetClientRect(hZoomWindow, &rArea);
			borderW -= rArea.right - rArea.left;
			borderH -= rArea.bottom - rArea.top;
			GetClientRect(hWndOwner, &rOwner);
			GetClientRect(hParent, &rParent);
			height = FMUL(RectHeight(&rOwner),
				View.ZoomDefaultSize)+borderH;
			width = FMUL(RectWidth(&rOwner),
				View.ZoomDefaultSize)+borderW;
			x = rParent.right-width;
			y = rParent.top + borderH;
			if (IsIconic(hWndOwner))
			{
				height = (rOwner.bottom - rOwner.top)+borderH;
				width = (rOwner.right - rOwner.left)+borderW;
			}
		}
		MoveWindow (hZoomWindow,x,y,width, height, FALSE);
 	}
}
Ejemplo n.º 24
0
static int ComputeZoom( HWND hWnd, int x, int y, int value,
                        BOOL fIncremental, LFIXED *lfFileRate,
                        int *Percentage )
/************************************************************************/
{
LFIXED DispRate;
int OldPercentage, iImageWidth, iImageHeight;
LPIMAGE lpImage;
LPDISPLAY lpDisplay;

HWND hMDIWindow = hWnd;
CWnd *pWnd = CWnd::FromHandle(hMDIWindow);
if (pWnd->IsKindOf(RUNTIME_CLASS(CServerView)))        
	hMDIWindow = pWnd->GetParentFrame()->GetSafeHwnd();

if (IsIconic(hMDIWindow))
    return(FALSE);

lpImage = GetImagePtr(hWnd);
lpDisplay = GetDisplayPtr(hWnd);

// Compute the viewing percentage, if necessary
if ( !(*Percentage = lpDisplay->ViewPercentage) )
    *Percentage = FMUL( 100, lpDisplay->DispRate );

// Compute the NEW viewing percentage, and DispRate
if ( fIncremental )
    {
    if (value < 0)
        {
        if (*Percentage > 100)
            {
            if (*Percentage % 100 != 0)
                *Percentage -= *Percentage % 100;
            else
                *Percentage -= 100;
            }
        else
        if (*Percentage <= 1)
            *Percentage = 0;
        else
            {
            OldPercentage = *Percentage;
            *Percentage = 100;
            while (*Percentage >= OldPercentage)
                *Percentage = (*Percentage+1)/2;
            }
        }
    else
    if (value > 0)
        {
        if (*Percentage > 32600)
            *Percentage = 0;
        else
        if (*Percentage >= 50)
            *Percentage = ((*Percentage+100)/100) * 100;
        else
        if (*Percentage)
            {
            OldPercentage = (*Percentage * 2) + 1;
            *Percentage = 100;
            while (*Percentage > OldPercentage)
                *Percentage = (*Percentage+1)/2;
            }
        else
            *Percentage = 1;
        }
    }
else
if (value > 0 && value < 32700)
    *Percentage  = value;
else
    *Percentage = 0;

// do we have a valid zoom percentage?
if (!*Percentage)
    return(FALSE);

// can we mathematically support this percentage?
DispRate = FGET( *Percentage, 100 );  /* DispRate */
*lfFileRate = FGET( 100, *Percentage );  /* FileRate */
if (!CanZoom(hWnd, *lfFileRate, &lpDisplay->FileRect,
        &lpDisplay->DispRect))
    {
    return(FALSE);
    }

// is our display surface too small?
iImageWidth = FMUL(lpImage->npix, DispRate);
iImageHeight = FMUL(lpImage->nlin, DispRate);
if (iImageHeight < 1 || iImageWidth < 1)
    {
    return(FALSE);
    }
return(TRUE);
}