Exemplo n.º 1
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.º 2
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.º 3
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.º 4
0
afx_msg void CServerView::OnRulerShow()
{
    if (STOP) return;
    CServerDoc* pDoc = GetDocument();
    LPIMAGE lpImage = pDoc->GetImage();

    if (lpImage)
    {
        HWND hActiveWnd = GetSafeHwnd();
        if (m_lpDisplay->HasRulers)
            DestroyRulers(hActiveWnd);
        else
            CreateRulers(hActiveWnd);

        ComputeDispRect(hActiveWnd);
        ComputeFileRect(hActiveWnd, 0, 0, m_lpDisplay->FileRate );
        SetupRulers(hActiveWnd);
        InvalidateRect(NULL, TRUE);
    }
}
Exemplo n.º 5
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.º 6
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);
}