home *** CD-ROM | disk | FTP | other *** search
- /*
- winload.c
-
- % winreq_load
-
- OWL 1.2
- Copyright (c) 1988, 1989 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 9/01/89 jdc added win_IsCharSize
- 10/24/89 jmd added static to function
-
- 12/11/89 jmd removed os-list headers
- 12/17/89 jdc fixed attrs
- 1/23/89 jdc added default defines
- 3/28/90 jmd ansi-fied
- 4/16/90 jdc renamed _bfile_gets to bf_gets
- 5/10/90 jdc added win_GoFunc
- 5/18/90 jmd converted nul_funcptr from OSTATIC to static
- 6/27/90 jdc preened the GoFunc code
- 8/08/90 jdc moved aux function down to window level
- 9/24/90 jdc removed gofunc code
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
-
- #include "bordobj.h"
- #include "winod.h"
- #include "winsfile.h"
- #include "winspriv.h"
-
- OSTATIC objreq_func (winreq_load);
- static VOID_FPTR null_funcptr = FNULL;
-
- #define DEFAULT_BORD bd_prompt
- #define DEFAULT_MOUSE (mouhandler_fptr)null_funcptr
- #define DEFAULT_EXP (exp_fptr)null_funcptr
- #define DEFAULT_AUX (aux_fptr)null_funcptr;
-
- void win_LoadInit(void)
- {
- winreq_loadfptr = winreq_load;
- }
-
- static int winreq_load(VOID *objdata, int msg, VOID *indata, VOID *outdata)
- {
- ocbox box;
- opbox pbox;
- int shadow_x, shadow_y, shadow_attr, clip;
- int bd_attr, handle;
- unsigned bd_feature;
- bd_fptr border;
- mouhandler_fptr mouse;
- exp_fptr explode;
- aux_fptr auxfunc;
- char *sbuf;
- bfile_type bfile;
- sfile_type sfile;
- win_type win;
- int attr = -1;
-
- oak_notused(msg);
- oak_notused(outdata);
-
- win = winod_GetSelf((win_od *)objdata);
- sfile = (sfile_type)indata;
-
- bfile = sfile->bfile;
- sbuf = sfile->buf;
-
- /* win info:
- new for 3.2! go func,
- ymin, xmin, ymax, xmax, parent clip,
- shadow x, shadow y, shadow attr, border attr, border features,
- attr,
- font, border, border title, mouse, explode
- */
- if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
- return(FALSE);
- }
- while (sscanf(sbuf, "%d %d %d %d %d %d %d %d %d %d %d",
- &box.toprow, &box.leftcol, &box.botrow, &box.rightcol, &clip,
- &shadow_x, &shadow_y, &shadow_attr,
- &bd_attr, &bd_feature, &attr) < 10) {
-
- /* ver 3.2 file: used to have gofunc here, now empty */
-
- if (*sbuf == '1') {
- /* ver 3.2.1 file (aux function) */
-
- if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
- return(FALSE);
- }
- if ((auxfunc = sfile_FindAuxFunc(sfile, sbuf + V32LEN, &handle)) == FNULL) {
- auxfunc = DEFAULT_AUX;
- }
- obj_SetAux(win, auxfunc);
- if (handle == -1) {
- handle = sfile_PutAuxFunc(sfile, sbuf + V32LEN, auxfunc);
- }
- win_SetAuxHandle(win, handle);
- }
-
- /* let's try that fscanf again */
- if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
- return(FALSE);
- }
- }
-
- /* ignore font for now */
- if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
- return(FALSE);
- }
- win_SetFont(win, disp_GetDefFont());
-
- win_SetParentClip(win, clip);
- win_SetShadowAttr(win, (byte)shadow_attr);
-
- if (attr != -1) { /* old file format */
- win_SetAttr(win, (byte)attr);
- }
-
- /* border */
- if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
- return(FALSE);
- }
- if (*sbuf == '\0') {
- border = FNULL;
- handle = -1;
- }
- else if ((border = sfile_FindBorderFunc(sfile, sbuf, &handle)) == FNULL) {
- border = DEFAULT_BORD;
- }
- win_SetBorder(win, border);
- if (handle == -1) {
- handle = sfile_PutBorderFunc(sfile, sbuf, border);
- }
- win_SetBorderHandle(win, handle);
-
- /* win init */
- if (win_IsCharSize(win)) {
- ocbox_pixcoords(&box, win_GetFont(win), &pbox);
- shadow_x *= win_GetFontWidth(win);
- shadow_y *= win_GetFontHeight(win);
- }
- else {
- pbox.ymin = box.toprow;
- pbox.xmin = box.leftcol;
- pbox.ymax = box.botrow;
- pbox.xmax = box.rightcol;
- }
- win_ReallySetPixPosition(win, pbox.xmin, pbox.ymin);
- win_ReallySetPixSize(win, opbox_GetWidth(&pbox), opbox_GetHeight(&pbox));
-
- win_SetPixShadow(win, shadow_x, shadow_y);
-
- bord_SetAttr(win, (byte)bd_attr);
- bord_SetFeature(win, bd_feature);
-
- /* border title */
- if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
- return(FALSE);
- }
- if (strcmp(sbuf, FSYM_NULLSTR) != 0) {
- bord_SetTitle(win, sbuf);
- }
-
- /* mouse */
- if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
- return(FALSE);
- }
- if ((mouse = sfile_FindMouseFunc(sfile, sbuf, &handle)) == FNULL) {
- mouse = DEFAULT_MOUSE;
- }
- win_SetMouse(win, mouse);
- if (handle == -1) {
- handle = sfile_PutMouseFunc(sfile, sbuf, mouse);
- }
- win_SetMouseHandle(win, handle);
-
- /* explode */
- if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
- return(FALSE);
- }
- if ((explode = sfile_FindExplodeFunc(sfile, sbuf, &handle)) == FNULL) {
- explode = DEFAULT_EXP;
- }
- win_SetExplode(win, explode);
- if (handle == -1) {
- handle = sfile_PutExplodeFunc(sfile, sbuf, explode);
- }
- win_SetExplodeHandle(win, handle);
-
- /* Put window into unemployed list (at the top) */
- win_ListAdd(wmgr_unemployedhead(), win);
-
- return(TRUE);
- }
-