home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Learn 3D Graphics Programming on the PC
/
Learn_3D_Graphics_Programming_on_the_PC_Ferraro.iso
/
rwwin
/
status.c_
/
status.bin
Wrap
Text File
|
1995-11-14
|
7KB
|
231 lines
/**********************************************************************
*
* File : status.c
*
* Abstract : Add a status bar to the bottom of a RenderWare window
*
**********************************************************************
*
* This file is a product of Criterion Software Ltd.
*
* This file is provided as is with no warranties of any kind and is
* provided without any obligation on Criterion Software Ltd. or
* Canon Inc. to assist in its use or modification.
*
* Criterion Software Ltd. will not, under any
* circumstances, be liable for any lost revenue or other damages arising
* from the use of this file.
*
* Copyright (c) 1995 Criterion Software Ltd.
* All Rights Reserved.
*
* RenderWare is a trademark of Canon Inc.
*
************************************************************************/
#define INCLUDE_SHELLAPI_H
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <rwlib.h>
/* Structure and Enum definitions */
typedef enum {
B_IN,
B_OUT
} EnBox;
/* Constant definitions */
#define STATUS_HEIGHT 20 /* height of the status bar */
/************************************************************************
*
* Function: Box3D()
*
* Description: Draws a 3D box on the output DC.
*
* Parameters: hdc - output DC
* type - a sunken or raised box
* left - x co-ordinate for left of box
* top - y co-ordinate for top of box
* right - x co-ordinate for left of box
* bottom - y co-ordinate for left of box
*
************************************************************************/
static void Box3d(HDC hdc, EnBox type, int left, int top, int right, int bottom)
{
LOGPEN lp;
HPEN pen, oldpen;
/* Create a grey pen */
lp.lopnStyle = PS_SOLID;
lp.lopnWidth.x = 0;
lp.lopnWidth.y = 0;
lp.lopnColor = RGB(128, 128, 128);
pen = CreatePenIndirect(&lp);
if (type == B_IN)
{
/* Use the grey pen for the left and top of the box */
oldpen = SelectObject(hdc, pen);
}
else
{
/* Use the white pen for the left and top of the box */
oldpen = SelectObject(hdc, GetStockObject(WHITE_PEN));
}
/* draw the left and top of the box */
MoveToEx(hdc, left, bottom, NULL);
LineTo(hdc, left, top);
LineTo(hdc, right, top);
if (type == B_IN)
{
/* Use the white pen for the right and bottom of the box */
SelectObject(hdc, GetStockObject(WHITE_PEN));
}
else
{
/* Use the grey pen for the right and bottom of the box */
SelectObject(hdc, pen);
}
/* draw the right and bottom of the box */
LineTo(hdc, right, bottom);
LineTo(hdc, left, bottom);
SelectObject(hdc, oldpen);
DeleteObject(pen);
}
/************************************************************************
*
* Function: ShowAppLeftStatus()
*
* Description: Display the left status bar below the RenderWare
* camera.
*
* Parameters: window - window containing status bar
* Camera - RenderWare camera
* string - string to display in status bar
*
************************************************************************/
void ShowAppLeftStatus(HWND Window, RwCamera *Camera, char *string)
{
RwInt32 height, width;
HDC dc;
RECT r;
/* Don't include the status bar in minimised windows */
if (IsIconic(Window))
return;
/* Find out where the bottom of the camera is */
RwGetCameraViewport(Camera, NULL, NULL, &width, &height);
dc = GetDC(Window);
/* Define the dimensions of the area of the status bar that will
contain text */
SetRect(&r, 2, (int)height + 2, (int)width/2 - 3, (int)height + STATUS_HEIGHT - 2);
/* clear the status bar to grey */
SelectObject(dc, GetStockObject(LTGRAY_BRUSH));
Rectangle(dc, r.left - 2, r.top - 2, r.right + 3, r.bottom + 3);
/* draw the 3D effect lines */
Box3d(dc, B_OUT, r.left - 2, r.top - 2, r.right + 2, r.bottom + 2);
Box3d(dc, B_IN, r.left, r.top, r.right, r.bottom);
SetBkMode(dc, TRANSPARENT);
SetTextColor(dc, RGB(0,0,0));
SelectObject(dc, GetStockObject(ANSI_VAR_FONT));
/* Draw the text */
ExtTextOut(dc, r.left + 4, r.top + 3, ETO_CLIPPED, &r, string, strlen(string), NULL);
ReleaseDC(Window, dc);
}
/************************************************************************
*
* Function: ShowAppRightStatus()
*
* Description: Display the right status bar below the RenderWare
* camera.
*
* Parameters: window - window containing status bar
* Camera - RenderWare camera
* string - string to display in status bar
*
************************************************************************/
void ShowAppRightStatus(HWND Window, RwCamera *Camera, char *string)
{
RwInt32 height, width;
HDC dc;
RECT r;
/* Don't include the status bar in minimised windows */
if (IsIconic(Window))
return;
/* Find out where the bottom of the camera is */
RwGetCameraViewport(Camera, NULL, NULL, &width, &height);
dc = GetDC(Window);
/* Define the dimensions of the area of the status bar that will
contain text */
SetRect(&r, (int)width/2 + 2, (int)height + 2, (int)width - 2, (int)height + STATUS_HEIGHT - 2);
/* clear the status bar to grey */
SelectObject(dc, GetStockObject(LTGRAY_BRUSH));
Rectangle(dc, r.left - 2, r.top - 2, r.right + 3, r.bottom + 3);
/* draw the 3D effect lines */
Box3d(dc, B_OUT, r.left - 2, r.top - 2, r.right + 2, r.bottom + 2);
Box3d(dc, B_IN, r.left, r.top, r.right, r.bottom);
SetBkMode(dc, TRANSPARENT);
SetTextColor(dc, RGB(0,0,0));
SelectObject(dc, GetStockObject(ANSI_VAR_FONT));
/* Draw the text */
ExtTextOut(dc, r.left + 2, r.top + 1, ETO_CLIPPED, &r, string, strlen(string), NULL);
ReleaseDC(Window, dc);
}
/************************************************************************
*
* Function: StatusAdjustHeight()
*
* Description: If the status bar is currently displayed, then
* adjust the supplied height to account for this
*
* Parameters: window - window containing status bar
* height - Current height
*
* Return Value: new height.
*
************************************************************************/
int StatusAdjustHeight(HWND Window, int height)
{
if (IsIconic(Window))
return (height);
else
return (height - STATUS_HEIGHT);
}