static char *rcsid = "$Id: UiInfo.c,v 1.1 1992/03/26 18:13:50 kny Exp kny $";


#include "UiIncludes.h"

#define logo_width 90
#define logo_height 90
static char logo_bits[] =
{
  0x00, 0x00, 0x00, 0x00, 0xd8, 0xcf, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xc0, 0xff, 0x01, 0xc0, 0x02, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xa0, 0x7f, 0x00, 0x2e, 0x0f, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xd8, 0x4f, 0x01, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xe7, 0xa0, 0x80, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x31, 0x00, 0xc4, 0xef, 0xff, 0x07, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xe0, 0x00, 0x00, 0x84, 0xef, 0xff, 0x0f, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x70, 0x00, 0x00, 0x0c, 0xce, 0xff, 0x3f, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x7c, 0x00, 0x00, 0x9f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x3e, 0x00, 0x00, 0xfd, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
  0x00, 0x80, 0x1f, 0x00, 0x00, 0xf4, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00,
  0x00, 0x80, 0x13, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00,
  0x00, 0xe0, 0x09, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00,
  0x00, 0xe0, 0x00, 0x00, 0x00, 0xfa, 0xed, 0xff, 0xff, 0x1f, 0x00, 0x00,
  0x00, 0x38, 0x00, 0x00, 0x80, 0x3f, 0x9c, 0xff, 0xff, 0x3f, 0x00, 0x00,
  0x00, 0x08, 0x00, 0x00, 0x80, 0x5f, 0x62, 0xff, 0xff, 0x7f, 0x00, 0x00,
  0x00, 0x0c, 0x00, 0x00, 0x80, 0x1f, 0x40, 0xf6, 0xff, 0xff, 0x00, 0x00,
  0x00, 0x02, 0x00, 0x00, 0x00, 0xaf, 0x36, 0xe8, 0xff, 0xff, 0x00, 0x00,
  0x00, 0x03, 0x00, 0x00, 0x00, 0xfa, 0x0f, 0x14, 0xfd, 0xff, 0x01, 0x00,
  0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x0f, 0x00, 0xfc, 0xff, 0x03, 0x00,
  0x80, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x3f, 0x0c, 0xfc, 0xff, 0x07, 0x00,
  0x40, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0xff, 0x07, 0x00,
  0x40, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
  0x20, 0x00, 0x00, 0x00, 0xf2, 0xff, 0xff, 0xff, 0xff, 0xf7, 0x0f, 0x00,
  0x10, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xf7, 0xef, 0x1f, 0x00,
  0x30, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xef, 0x9f, 0x1f, 0x00,
  0x18, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x38, 0x00,
  0x18, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xbf, 0xff, 0x38, 0x00,
  0x1c, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xff, 0x71, 0x00,
  0x14, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x7f, 0xff, 0x61, 0x00,
  0x5a, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0x61, 0x00,
  0x02, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xc0, 0x00,
  0x41, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7d, 0xc0, 0x00,
  0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x80, 0x01,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0xfe, 0x07, 0xff, 0x81, 0x80, 0x08, 0x08, 0x02, 0xff, 0xc1, 0xff, 0x00,
  0xff, 0x8f, 0xff, 0xc3, 0xc1, 0x1d, 0x1c, 0x87, 0xff, 0xe3, 0xff, 0x01,
  0xff, 0x87, 0xff, 0xc7, 0xc1, 0x1d, 0x1c, 0xc7, 0xff, 0xe1, 0xff, 0x00,
  0x07, 0x80, 0x03, 0x87, 0x83, 0x0f, 0x0e, 0xc7, 0x01, 0xe0, 0x00, 0x00,
  0x07, 0x80, 0x03, 0x87, 0x83, 0x0f, 0x0e, 0xc7, 0x01, 0xe0, 0x00, 0x00,
  0x07, 0x80, 0x03, 0x87, 0x83, 0x0f, 0x0e, 0xc7, 0x01, 0xe0, 0x00, 0x00,
  0x07, 0x80, 0x03, 0x07, 0x07, 0x07, 0x07, 0xc7, 0x01, 0xe0, 0x00, 0x00,
  0x7f, 0x80, 0xff, 0x07, 0x07, 0x07, 0x07, 0xc7, 0xff, 0xe0, 0x1f, 0x00,
  0xff, 0x80, 0xff, 0x03, 0x07, 0x07, 0x07, 0x87, 0xff, 0xe1, 0x1f, 0x00,
  0x7f, 0x80, 0xff, 0x01, 0x8e, 0x8f, 0x03, 0x07, 0xff, 0xe3, 0x1f, 0x00,
  0x07, 0x80, 0xc3, 0x01, 0x8e, 0x8f, 0x03, 0x07, 0x80, 0xe3, 0x00, 0x00,
  0x07, 0x80, 0xc3, 0x01, 0x8e, 0x8f, 0x03, 0x07, 0x80, 0xe3, 0x00, 0x00,
  0x07, 0x80, 0x83, 0x03, 0xdc, 0xdd, 0x01, 0x07, 0x80, 0xe3, 0x00, 0x00,
  0x07, 0x80, 0x83, 0x03, 0xdc, 0xdd, 0x01, 0x07, 0x80, 0xe3, 0x00, 0x00,
  0xff, 0x87, 0x03, 0x07, 0xf8, 0xf8, 0x00, 0x87, 0xff, 0xe3, 0xff, 0x00,
  0xff, 0x8f, 0x03, 0x07, 0xf8, 0xf8, 0x00, 0xc7, 0xff, 0xe1, 0xff, 0x01,
  0xfe, 0x07, 0x01, 0x02, 0x70, 0x70, 0x00, 0x82, 0xff, 0xc0, 0xff, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0xfd, 0xff, 0x07, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x03, 0x00, 0x01,
  0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x41, 0x00, 0x01,
  0xfa, 0xff, 0x01, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x23, 0x00, 0x01,
  0xfe, 0xff, 0x03, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x31, 0x80, 0x00,
  0xf2, 0xff, 0x03, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x39, 0x80, 0x00,
  0xf4, 0xff, 0x03, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x7f, 0x3c, 0x80, 0x00,
  0xe4, 0xff, 0x03, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x3f, 0x1c, 0x40, 0x00,
  0xe4, 0xff, 0x01, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x1f, 0x0c, 0x40, 0x00,
  0xe8, 0xff, 0x03, 0x00, 0x00, 0x00, 0x80, 0xff, 0x1f, 0x0e, 0x40, 0x00,
  0xc8, 0xff, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x1f, 0x06, 0x20, 0x00,
  0xc8, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x0f, 0x06, 0x20, 0x00,
  0xd0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x07, 0x00, 0x10, 0x00,
  0x90, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x07, 0x00, 0x10, 0x00,
  0xa0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, 0x00, 0x08, 0x00,
  0x20, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0x00, 0x08, 0x00,
  0x40, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x04, 0x00,
  0x80, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x04, 0x00,
  0x80, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x02, 0x00,
  0x00, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
  0x00, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
  0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
  0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
  0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
  0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
  0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
  0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
  0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x80, 0x09, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x88, 0x03, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0xa0, 0x7f, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0xc0, 0x03, 0xfe, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0xdc, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
 0x00, 0x00, 0x00, 0x00, 0xa0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00};


static Widget uicreateinfoform();
static Widget uicreateinfook(Widget parent);
void uicreateinfolabels(Widget parent, Widget bottomwdg);
static void uiinfookcb(char *address, HText_t * htext,
		        HTextObject_t * htextobject, void *parameter);


int UiDisplayInfo()
{
    uiInfoGfx_t *infogfx = &uiTopLevel.InfoGfx;

    if (infogfx->FormWdg) {
	XtMapWidget(XtParent(infogfx->FormWdg));

	return UI_OK;
    }
    infogfx->FormWdg = uicreateinfoform();
    infogfx->OkWdg = uicreateinfook(infogfx->FormWdg);
    uicreateinfolabels(infogfx->FormWdg, infogfx->OkWdg);

    XtManageChild(infogfx->FormWdg);
    XtRealizeWidget(XtParent(infogfx->FormWdg));

    return UI_OK;
}


static Widget
 uicreateinfoform()
{
    ArgList args;
    Cardinal nargs;
    Widget formwdg;
    Widget topwdg;

    topwdg = XtCreateApplicationShell("Info",
				      topLevelShellWidgetClass,
				      NULL, 0);

    args = uiVaSetArgs(&nargs,
		       XmNresizePolicy, XmRESIZE_NONE,
		       XmNautoUnmanage, FALSE, NULL);
    formwdg = XmCreateForm(topwdg, "InfoDialog",
			   args, nargs);

    return formwdg;
}


static Widget
 uicreateinfook(formwdg)
Widget formwdg;
{
    ArgList args;
    Cardinal nargs;
    Widget okwdg;
    static uiActionData_t actiondata;

    args = uiVaSetArgs(&nargs,
		       XmNrightAttachment, XmATTACH_FORM,
		       XmNrightOffset, UI_INFO_WDG_OFFSET,
		       XmNbottomAttachment, XmATTACH_FORM,
		       XmNbottomOffset, UI_INFO_WDG_OFFSET, NULL);
    okwdg = XmCreatePushButtonGadget(formwdg, "   Ok   ", args, nargs);
    actiondata.ActionName = "InfoOk";
    actiondata.Page = uiPageInfo.CurrentPage;
    XtAddCallback(okwdg, XmNactivateCallback, uiinfookcb, (caddr_t) NULL);
    XtManageChild(okwdg);

    return okwdg;
}


void uicreateinfolabels(formwdg, bottomwdg)
Widget formwdg;
Widget bottomwdg;
{
    ArgList args;
    Cardinal nargs;
    XmString labelstr;
    Pixmap logo_pixmap;
    Widget wdg;
    Display *dpy;
    Widget label1wdg;
    Widget label2wdg;
    Widget label3wdg;

    wdg = uiTopLevel.TopGfx.TopWdg;
    dpy = XtDisplay(wdg);

    logo_pixmap =
	XCreatePixmapFromBitmapData(dpy, XtWindow(wdg), logo_bits,
				    logo_height, logo_width,
				    BlackPixel(dpy, DefaultScreen(dpy)),
				    uiGetArg(wdg, XmNbackground),
				  DefaultDepth(dpy, DefaultScreen(dpy)));

    if (logo_pixmap == NULL) {
	printf("Pixmap creation failed\n");
	exit(1);
    }
    args = uiVaSetArgs(&nargs,
		       XmNlabelType, XmPIXMAP,
		       XmNlabelPixmap, logo_pixmap,
		       XmNtopAttachment, XmATTACH_FORM,
		       XmNtopOffset, UI_INFO_WDG_OFFSET,
		       XmNleftAttachment, XmATTACH_FORM,
		       XmNleftOffset, UI_INFO_WDG_OFFSET, NULL);
    label1wdg = XmCreateLabelGadget(formwdg, "InfoLabel1", args, nargs);
    XtManageChild(label1wdg);

    labelstr = XmStringCreateLtoR("WorldWideWeb \n browser \n for the X Window System \n \n Version 1.0 Alpha", XmSTRING_DEFAULT_CHARSET);
    args = uiVaSetArgs(&nargs,
		       XmNlabelString, labelstr,
		       XmNtopAttachment, XmATTACH_FORM,
		       XmNtopOffset, UI_INFO_WDG_OFFSET,
		       XmNrightAttachment, XmATTACH_FORM,
		       XmNleftAttachment, XmATTACH_WIDGET,
		       XmNleftWidget, label1wdg,
		       XmNrightOffset, UI_INFO_WDG_OFFSET, NULL);
    label2wdg = XmCreateLabelGadget(formwdg, "InfoLabel2", args, nargs);
    XtManageChild(label2wdg);
    XmStringFree(labelstr);

    labelstr = XmStringCreateLtoR("Authors: \n Kim Nyberg, Teemu Rantanen, \n Kati Suominen, Kari Syd{nmaanlakka\n\nE-mail: erwise@cs.hut.fi", XmSTRING_DEFAULT_CHARSET);
    args = uiVaSetArgs(&nargs,
		       XmNlabelString, labelstr,
		       XmNtopAttachment, XmATTACH_WIDGET,
		       XmNtopWidget, label1wdg,
		       XmNtopOffset, UI_INFO_WDG_OFFSET,
		       XmNbottomAttachment, XmATTACH_WIDGET,
		       XmNbottomWidget, bottomwdg,
		       XmNbottomOffset, UI_INFO_WDG_OFFSET,
		       XmNleftAttachment, XmATTACH_FORM,
		       XmNleftOffset, UI_INFO_WDG_OFFSET,
		       XmNrightAttachment, XmATTACH_FORM,
		       XmNrightOffset, UI_INFO_WDG_OFFSET, NULL);
    label3wdg = XmCreateLabelGadget(formwdg, "InfoLabel3", args, nargs);
    XtManageChild(label3wdg);
    XmStringFree(labelstr);
}


static void uiinfookcb(address, htext, htextobject, parameter)
char *address;
HText_t *htext;
HTextObject_t *htextobject;
void *parameter;
{
    XtUnmapWidget(XtParent(uiTopLevel.InfoGfx.FormWdg));
}
