home *** CD-ROM | disk | FTP | other *** search
- /*
- puparms.c
-
- % pop_SetParms
-
- C-scape 3.2
- Copyright (c) 1986, 1987, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 9/15/88 jmd changed vid_ to disp_
- 9/16/88 jmd updated for 3.0
-
- 11/13/89 jmd added a shadow
- 3/28/90 jmd ansi-fied
- 8/27/90 jmd added popparms_struct
- 12/05/90 jdc fixed default auto-sizing
- 12/06/90 jmd changed default to no shadow
- 12/12/90 jmd fixed syntax error
- 12/14/90 jdc polished auto-sizing
- 12/18/90 jmd fixed auto-sizing clip to display trouble
- 12/21/90 ted/jdc fixed popup-positioning calculation.
- */
-
- #include <stdio.h>
-
- #include "cscape.h"
- #include "scancode.h"
- #include "popdecl.h"
-
- popparms_struct popparms = {
-
- 0, /* shadow for popups */
- 0x08, /* shadow attr for popups */
-
- DEFAULT_HEIGHT, /* popup default height */
- DEFAULT_WIDTH /* popup default width */
- };
-
- void pop_SetParms(sed_type sed, int row, int col, int height, int width, char *title)
- /*
- Adjusts the parameters for pop up boxes.
- If any of these arguments (row, col, height, width) are
- negative default values are used (centered).
- */
- {
- int bordwid, bordhgt, w_actual, h_actual;
-
- bordwid = bord_GetWidth(sed) - win_GetWidth(sed);
- if (width < 0) {
- width = popparms.width;
- }
- if (width < 0) {
- /* use menu width */
- w_actual = sed_GetMenuWidth(sed);
- }
- else {
- /* use passed in width value */
- w_actual = width;
- }
-
- bordhgt = bord_GetHeight(sed) - win_GetHeight(sed);
- if (height < 0) {
- height = popparms.height;
- }
- if (height < 0) {
- /* use menu height */
- h_actual = sed_GetMenuHeight(sed);
- }
- else {
- /* use passed in height value */
- h_actual = height;
- }
-
- /* set up the title before centering */
- if (title != NULL) {
- sed_SetBorderTitle(sed, title);
- }
-
- /* set up the position */
- if (row < 0) {
- row = (disp_GetHeight() - bordhgt - h_actual)/2;
- row = (row < 0) ? 0 : row;
- }
- if (height < 0 && (row + h_actual + bordhgt > disp_GetHeight())) {
- /* if auto height, clip to the display */
- h_actual = disp_GetHeight() - bordhgt - row;
- h_actual = (h_actual < 1) ? 1 : h_actual;
- }
-
- if (col < 0) {
- col = (disp_GetWidth() - bordwid - w_actual)/2;
- col = (col < 0) ? 0 : col;
- }
- if (width < 0 && (col + w_actual + bordwid > disp_GetWidth())) {
- /* if auto width, clip to the display */
- w_actual = disp_GetWidth() - bordwid - col;
- w_actual = (w_actual < 1) ? 1 : w_actual;
- }
-
- sed_SetPosition(sed, row, col);
- win_SetSize(sed, h_actual, w_actual);
-
- sed_SetShadow(sed, popparms.shadow);
- sed_SetShadowAttr(sed, popparms.shadowattr);
- }
-