home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
cyber.net 2
/
cybernet2.ISO
/
qtw111
/
pviewer
/
pictkids.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-11
|
49KB
|
1,314 lines
// ---------------------------------------------------------------------
//
// PictKids.c - Picture Viewer - QuickTime for Windows
//
// Version 1.0
//
// (c) 1988-1992 Apple Computer, Inc. All Rights Reserved.
//
// ---------------------------------------------------------------------
// Includes
// --------
#define NOMINMAX
#include <Windows.H> // Required by Windows
#include <stdlib.h> // Required for abs function
#include <qtole.h> // Interface to qtole dll
#include <qtw.h> // Interface to QuickTime
#include "common.h" // Interface to common.c
#include "viewer.h" // Interface to *.c files
#include "viewer.hr" // Defines used in *.rc files
#include "picture.h" // Interface to picture window
// child window processing
// Constants
// -----------------------
#define BANNER_TEXT_HEIGHT 9 // Banner text height in points
#define TEXT_EXTRA_SPACING 1 // Extra spacing in number text
// Message-Persistent Data
// -----------------------
static struct // Hungarian notation: g
{WORD wScrollBarWidth; // Vertical scroll bar width
WORD wScrollBarHeight; // Horizontal scroll bar height
WORD wBannerBarHeight; // Banner bar height
WORD wZoomWndWidth; // Width of zoom scroll bar window
WORD wMinWndHeight; // Minimum height of window
HBITMAP hbmpGrowBox; // Grow box bitmap
BOOL bLimitGrowBoxResize; // Flag to turn on max resize limits
// using grow box
POINT ptMaxGrowBoxResize; // Max size for grow box resizing
RECT rcResizeRect; // Maximized wnd grow box resize rect
POINT ptCursorOffset; // Offset of cursor from edge of window
// used during maximized wnd grow box resize
} g;
// Exported callback function
// ----------------------------
LONG __export CALLBACK PictureBannerWndProc (HWND, UINT, WPARAM, LPARAM);
// Internal Function Declarations
// ------------------------------
static VOID NEAR UpdateScrollingParms (HWND, NPPICTUREDATA, LPRECT);
static HBITMAP NEAR GetGrowBoxBitmap (HDC, NPPICTUREDATA);
static VOID NEAR DrawTheFrameRect (LPRECT);
// Function: ResizeKids - Resizes the child windows whenever the picture
// window is resized
// --------------------------------------------------------------------
// Parameters: HWND hwndPicture Handle of picture window
// WORD wClientWidth Width of client rect
// WORD wClientHeight Height of client rect
//
// Returns: 0L
// --------------------------------------------------------------------
VOID FAR ResizeKids
( HWND hwndPicture, WORD wClientWidth, WORD wClientHeight )
{
NPPICTUREDATA pPictureData; // -> picture data struct
RECT rcPicture; // Picture rect in picture coordinates
HDWP hdwp; // Handle to defer wnd pos struct
int xBrdr; // Width of non resizable border
int yBrdr; // Height of non resizable border
// Note: All the extra terms involving xBrdr and yBrdr are used to make
// the control boundaries match up correctly without heavy lines
// appearing between the controls
xBrdr = GetSystemMetrics( SM_CXBORDER );
yBrdr = GetSystemMetrics( SM_CYBORDER );
if( !(pPictureData =
(NPPICTUREDATA) GetWindowWord( hwndPicture, 0 ))) {
CommonTellUser( ViewerQueryResources(),
VIEWER_STRING_NOPICDATA, VIEWER_STRING_CAPTION, MB_OK );
return;
}
if( ( hdwp = BeginDeferWindowPos( 5 )) &&
// Zoom window. This control has a constant size
( hdwp = DeferWindowPos( hdwp, pPictureData->zsZoomScroll.hwnd,
NULL,
-xBrdr,
wClientHeight - g.wScrollBarHeight + yBrdr,
g.wZoomWndWidth,
g.wScrollBarHeight,
SWP_NOZORDER )) &&
// Banner bar. This control has a constant height
( hdwp = DeferWindowPos( hdwp, pPictureData->hwndBanner,
NULL,
0,
0,
wClientWidth,
g.wBannerBarHeight,
SWP_NOZORDER )) &&
// Vertical scroll bar. This control has a constant width
( hdwp = DeferWindowPos( hdwp, pPictureData->spmsVScroll.hwnd,
NULL,
wClientWidth - g.wScrollBarWidth + xBrdr,
g.wBannerBarHeight - yBrdr,
g.wScrollBarWidth,
wClientHeight - g.wScrollBarHeight
- g.wBannerBarHeight + 3 * yBrdr,
SWP_NOZORDER )) &&
// Horizontal scroll bar. This control has a constant height
( hdwp = DeferWindowPos( hdwp, pPictureData->spmsHScroll.hwnd,
NULL,
g.wZoomWndWidth - 2 * xBrdr,
wClientHeight - g.wScrollBarHeight + yBrdr,
wClientWidth - g.wZoomWndWidth -
g.wScrollBarWidth + 4 * xBrdr,
g.wScrollBarHeight,
SWP_NOZORDER ))) {
EndDeferWindowPos( hdwp );
}
else { // Zoom window. This control has a constant size
MoveWindow( pPictureData->zsZoomScroll.hwnd,
-xBrdr, wClientHeight - g.wScrollBarHeight + yBrdr,
g.wZoomWndWidth, g.wScrollBarHeight, TRUE );
// Banner bar. This control has a constant height
MoveWindow( pPictureData->hwndBanner, 0, 0,
wClientWidth, g.wBannerBarHeight, TRUE );
// Vertical scroll bar. This control has a constant width
MoveWindow( pPictureData->spmsVScroll.hwnd,
wClientWidth - g.wScrollBarWidth + xBrdr,
g.wBannerBarHeight - yBrdr, g.wScrollBarWidth,
wClientHeight - g.wScrollBarHeight -
g.wBannerBarHeight + 3 * yBrdr, TRUE );
// Horizontal scroll bar. This control has a constant height
MoveWindow( pPictureData->spmsHScroll.hwnd,
g.wZoomWndWidth - 2 * xBrdr,
wClientHeight - g.wScrollBarHeight + yBrdr,
wClientWidth - g.wZoomWndWidth -
g.wScrollBarWidth + 4 * xBrdr,
g.wScrollBarHeight, TRUE );
}
pPictureData->rcGrowBox.left = wClientWidth -
g.wScrollBarWidth + 2 * xBrdr;
pPictureData->rcGrowBox.top = wClientHeight -
g.wScrollBarHeight + 2 * yBrdr;
pPictureData->rcGrowBox.right = wClientWidth;
pPictureData->rcGrowBox.bottom = wClientHeight;
rcPicture.left = rcPicture.top = 0;
rcPicture.right = wClientWidth;
rcPicture.bottom = wClientHeight;
PictureRectFromClient( &rcPicture );
UpdateScrollingParms( hwndPicture, pPictureData, &rcPicture );
// Force these to get painted now to avoid long delay while
// waiting for the picture to be painted. This improves the
// appearance of the window during resizing
UpdateWindow( pPictureData->zsZoomScroll.hwnd );
UpdateWindow( pPictureData->hwndBanner );
UpdateWindow( pPictureData->spmsHScroll.hwnd );
UpdateWindow( pPictureData->spmsVScroll.hwnd );
return;
}
// Function: CreateViewerKids - Creates the child windows for the picture
// window
// --------------------------------------------------------------------
// Parameters: HWND hwndPicture Handle of picture window
// NPPICTUREDATA pPictureData -> to picture data struct
//
// Returns: LONG 0l if OK
// --------------------------------------------------------------------
LONG FAR CreateViewerKids( HWND hwndPicture, NPPICTUREDATA pPictureData )
{
WORD wIDError; // Resource error string id
g.wScrollBarWidth = (WORD) GetSystemMetrics( SM_CXVSCROLL );
g.wScrollBarHeight = (WORD) GetSystemMetrics( SM_CYHSCROLL );
g.wBannerBarHeight = (WORD) GetSystemMetrics( SM_CYMENU );
g.wMinWndHeight = (WORD) ( GetSystemMetrics( SM_CYCAPTION ) +
g.wBannerBarHeight + g.wScrollBarHeight +
3 * GetSystemMetrics( SM_CYVSCROLL ));
wIDError = VIEWER