Exemplo n.º 1
0
static void DrawBox( HWND hWnd, HDC hDC )  // Assumes zoom box is current view!
/************************************************************************/
{
RECT rFile, rDraw;
HWND hOwner;
LPDISPLAY lpOwnerDisp, lpMyDisp;

hOwner = GetZoomOwner(hWnd);
if (!hOwner)
	return;
lpOwnerDisp = (LPDISPLAY)GetDisplayPtr(hOwner);
lpMyDisp = (LPDISPLAY)GetDisplayPtr(hWnd);
if (!lpOwnerDisp || !lpMyDisp)
	return;

//rDisp = lpMyDisp->DispRect;
rFile = lpMyDisp->FileRect;

// get owners file rect and convert to our file rect

rDraw.left = lpOwnerDisp->FileRect.left-rFile.left;
rDraw.top= lpOwnerDisp->FileRect.top-rFile.top;
rDraw.right= lpOwnerDisp->FileRect.right-rFile.left;
rDraw.bottom= lpOwnerDisp->FileRect.bottom-rFile.top;


// convert into our display rect
File2DispRect(hWnd, &rDraw, &rDraw);

// limit to display rect
IntersectRect(&rDraw, &rDraw, &(lpMyDisp->DispRect));

//rDraw.left++;
//rDraw.top++;

//old way:fRate = FGET(rDisp.right-rDisp.left, rFile.right-rFile.left);
//rDraw.left = FMUL(rDraw.left,fRate);
//rDraw.right = FMUL(rDraw.right,fRate);
//fRate = FGET(rDisp.bottom-rDisp.top, rFile.bottom-rFile.top);
//rDraw.top = FMUL(rDraw.top,fRate);
//rDraw.bottom = FMUL(rDraw.bottom,fRate);

// Invert the box
InvertBox(hDC, &rDraw);

// remeber box
SetWindowWord( hWnd, GWW_ZOOMBOXLEFT, (WORD)rDraw.left);
SetWindowWord( hWnd, GWW_ZOOMBOXTOP, (WORD)rDraw.top);
SetWindowWord( hWnd, GWW_ZOOMBOXRIGHT, (WORD)rDraw.right);
SetWindowWord( hWnd, GWW_ZOOMBOXBOTTOM, (WORD)rDraw.bottom);
}
Exemplo n.º 2
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 );
         }
      }
   }
Exemplo n.º 3
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();
}
Exemplo n.º 4
0
static void GetDispRect( HWND hWnd, LPRECT lpRect, int iHorzMode, int iVertMode )
/************************************************************************/
// int iHorzMode; /* 0 = GetClientRect 1 = No Scrollbars 2 = With Scrollbars */
// int iVertMode; /* 0 = GetClientRect 1 = No Scrollbars 2 = With Scrollbars */
{
RECT rHorz, rVert;
int cy, cx;
LPDISPLAY lpDisplay;

GetScrollBarSize(&cx, &cy);
if (iHorzMode == 2)         // with horizontal scrollbar
    {
    GetRealClientRect(hWnd, &rHorz);
    rHorz.bottom -= cy;
    }
else
if (iHorzMode == 1)     // without horizontal scrollbar
    {
    GetRealClientRect(hWnd, &rHorz);
    }
else
    {           // actual client size
    GetClientRect(hWnd, &rHorz);
    }
if (iVertMode == 2)     // with vertical scrollbar
    {
    GetRealClientRect(hWnd, &rVert);
    rVert.right -= cx;
    }
else
if (iVertMode == 1) // without horizontal scrollbar
    {
    GetRealClientRect(hWnd, &rVert);
    }
else                // actual client size
    {
    GetClientRect(hWnd, &rVert);
    }

lpRect->top = rHorz.top;
lpRect->bottom = rHorz.bottom;
lpRect->left = rVert.left;
lpRect->right = rVert.right;


lpDisplay = GetDisplayPtr(hWnd);
if (lpDisplay->HasRulers && !IsIconic(hWnd)) 
    {
    lpRect->top += GetRulerSize();
    lpRect->left += GetRulerSize();
    }

// adjust because our rects include right and bottom
lpRect->bottom -= 1;
lpRect->right -= 1;
}
Exemplo n.º 5
0
void ViewXY( HWND hWnd, int x, int y )
/************************************************************************/
{
LPDISPLAY lpDisplay;

lpDisplay = GetDisplayPtr(hWnd);
ComputeFileRect(hWnd, x, y, lpDisplay->FileRate);
SetupRulers( hWnd );
InvalidateRect( hWnd, NULL, TRUE );
}
Exemplo n.º 6
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);
    }
}
Exemplo n.º 7
0
LOCAL void ZoomBox_OnDestroy(HWND hWnd)
/***********************************************************************/
{
LPDISPLAY lpMyDisplay;

if (lpMyDisplay = (LPDISPLAY)GetDisplayPtr(hWnd) )
	FreeUp((LPTR)lpMyDisplay);
hZoomWindow = NULL;
if (Tool.hRibbon)
	SendMessage( Tool.hRibbon, WM_DOCACTIVATED, 0, 1L );
}
Exemplo n.º 8
0
void SaveLastView(HWND hWnd)
/************************************************************************/
{
LPDISPLAY lpDisplay;

lpDisplay = GetDisplayPtr(hWnd);
lpDisplay->LastWindowRect = lpDisplay->WindowRect;
lpDisplay->LastFileRect = lpDisplay->FileRect;
lpDisplay->LastFileRate = lpDisplay->FileRate;
lpDisplay->LastViewPercentage = lpDisplay->ViewPercentage;
}
Exemplo n.º 9
0
LOCAL void ZoomBox_OnLButtonUp(HWND hWnd, int x, int y, UINT keyFlags)
/***********************************************************************/
{
BOOL fGotaRect;
LPDISPLAY lpMyDisplay;
RECT ClientRect;
HWND hOwner;

if ( !fCapture )
	return;
ReleaseCapture(); fCapture = FALSE;
if (fSelection)
	{
	EndSelection( hWnd, NULL, &SelectRect, SL_BOX|SL_NOLIMIT, YES );
	if (abs(SelectRect.right-SelectRect.left) <= SMALL_MOVEMENT &&
			abs(SelectRect.bottom-SelectRect.top) <= SMALL_MOVEMENT)
		fGotaRect = NO;
	else
		fGotaRect = YES;
	}
else
	{
	fGotaRect = NO;
	SelectRect.left = SelectRect.right = StartPoint.x;
	SelectRect.top = SelectRect.bottom = StartPoint.y;
	Display2File( hWnd, (LPINT)&SelectRect.left, (LPINT)&SelectRect.top );
	Display2File( hWnd, (LPINT)&SelectRect.right, (LPINT)&SelectRect.bottom );
	}

// clip to file rect
lpMyDisplay = GetDisplayPtr(hWnd);
ClientRect = lpMyDisplay->FileRect;
AstralIntersectRect( &SelectRect, &SelectRect, &ClientRect );
SetFocus(hOldFocus);
EnableMarquee(fMarquee);
hOwner = GetZoomOwner(hWnd);
if (!hOwner)
	return;
if (IsIconic(hOwner))
	return;
SaveLastView(hOwner);
if ( fGotaRect )
	ViewRect(hOwner, &SelectRect, NO);
else
	{
	Zoom( hOwner, SelectRect.left, SelectRect.top,
		( SHIFT ? -100 : ( CONTROL ? +100 : 0 ) ), YES,NO);
	}
}
Exemplo n.º 10
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);
}
Exemplo n.º 11
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);
}
Exemplo n.º 12
0
void ViewRect(HWND hWnd, LPRECT lpRect,  BOOL fResizeWindow)
/************************************************************************/
{
int x, y, left, top;
RECT rMax;
LPDISPLAY lpDisplay;

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

lpDisplay = GetDisplayPtr(hWnd);

if (fResizeWindow) // if allowed to change size use a max size
    GetClientRect(PictPubApp.Get_hClientAstral(), &rMax);
else // if window size will not change use current DispRect
    rMax = lpDisplay->DispRect;
if (!CanZoom(hWnd, 0L, lpRect, &rMax))
    return;
SaveLastView(hWnd);
lpDisplay->FileRect = *lpRect;
lpDisplay->FileRate = 0;
lpDisplay->ViewPercentage = 0;
x = (lpDisplay->FileRect.left 
    + lpDisplay->FileRect.right+1) / 2;
y = ( lpDisplay->FileRect.top 
    + lpDisplay->FileRect.bottom+1) / 2;
if (fResizeWindow)
    {
    GetWinXY(hMDIWindow, &left, &top);
    FullViewWindow(hWnd, left, top, x, y, NO);
    }
else
    {
    ComputeDispRect(hWnd);
    ComputeFileRect(hWnd, x, y, lpDisplay->FileRate);
    SetupRulers(hWnd);
    InvalidateRect(hWnd, NULL, TRUE);
    }
ZoomMainViewChanged(hWnd);
}
Exemplo n.º 13
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 );
}
Exemplo n.º 14
0
void Zoom( HWND hWnd, int x, int y, int value, BOOL fIncremental,
            BOOL fAllowSizeChange )
/************************************************************************/
{
LFIXED FileRate;
int Percentage, left, top;
LPDISPLAY lpDisplay;

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

if (IsIconic(hMDIWindow))
    return;

if (!ComputeZoom(hWnd,x,y,value,fIncremental, &FileRate, &Percentage))
    {
    Message( IDS_BADZOOM );
    return;
    }

SaveLastView(hWnd);
lpDisplay = GetDisplayPtr(hWnd);
lpDisplay->ViewPercentage = Percentage;
lpDisplay->FileRate = FileRate;
if (fAllowSizeChange)
    {
	 GetWinXY(hMDIWindow, &left, &top);
    FullViewWindow(hWnd, left, top, x, y, YES);
    }
else
    {
    ComputeDispRect(hWnd);
    // Change the FileRect to accomodate
    ComputeFileRect( hWnd, x, y, FileRate);
    SetupRulers(hWnd);
    InvalidateRect( hWnd, NULL, TRUE );
    }
ZoomMainViewChanged(hWnd);      // update the 'zoom window'
}
Exemplo n.º 15
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);

}
Exemplo 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);
}
Exemplo 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 );
}
Exemplo 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 );
}
Exemplo 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;
}
Exemplo n.º 20
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);
}