📄 welcome.cc
字号:
//**************************************************************//* filename: welcome.cc *//* *//**************************************************************//* programmed by: Thomas Wagner *//* last change: 10-05-95 (XXX: not updated) *//**************************************************************#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include "welcome.h"#include "version.h"#include "include_bmps/tubs.bmp"extern unsigned long buttonpix, blackpix, whitepix, shadowpix, lightpix, redpix;extern Cursor maincursor;#if 1extern#endifXContext Windowcontext;Welcome::Welcome (Display * initdisplay, GC initgc, BigWindow * parent, XFontStruct * fontstruct, int Actionnumber):BigWindow (initdisplay, initgc, DefaultRootWindow (initdisplay), fontstruct, 200, 200, 300, 300, "Welcome", DEFAULT_BDWIDTH){ Parent = parent; char *ollitext1 = "Fuzzy-programming by: "; char *ollitext2 = "Oliver Wagner"; char *thomastext1 = "User-interface by: "; char *thomastext2 = "Thomas Wagner"; char *copyright = "Copyright 1995"; short textwidthleft, textwidthright, textwidth, textheight; textwidthleft = MAX (XTextWidth (fontstruct, ollitext1, strlen (ollitext1)), XTextWidth (fontstruct, thomastext1, strlen (thomastext1))); textwidthright = MAX (XTextWidth (fontstruct, ollitext2, strlen (ollitext2)), XTextWidth (fontstruct, thomastext2, strlen (thomastext2))); textwidth = textwidthleft + textwidthright; textheight = fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent; Pixmap bmp; if ((bmp = XCreateBitmapFromData (display, window, tubs_bits, tubs_width, tubs_height)) == None) { printf ("Failed to create bitmap!\n"); exit (0); } short depth, textx, texty; Ok = new ActionIcon (display, gc, this, fontstruct, 35, 40, WELCOME_BUTTONWIDTH, WELCOME_BUTTONHEIGHT, "Ok", NULL, 0, 0, Actionnumber, ICON_SELECTABLE); SizeMe (3 * WELCOME_BORDER + tubs_width + textwidth, 3 * WELCOME_BORDER + tubs_height + WELCOME_BUTTONHEIGHT); Ok->PlaceMe ((width - Ok->Getwidth ()) / 2, height - WELCOME_BORDER - Ok->Getheight ()); depth = DefaultDepth (display, DefaultScreen (display)); pixmap = XCreatePixmap (display, window, width, height, depth); XSetForeground (display, gc, buttonpix); XFillRectangle (display, pixmap, gc, 0, 0, width, height); DrawBorder (pixmap, HIGH);// now draw a lot of text from top to bottom textx = (int) (2 * WELCOME_BORDER + tubs_width); texty = WELCOME_BORDER; { XGCValues tempgcv; GC tempgc; tempgcv.font = (fontstruct)->fid; tempgcv.foreground = blackpix; tempgcv.background = whitepix; tempgc = XCreateGC (display, window, (GCFont | GCForeground | GCBackground), &tempgcv); XFontStruct *tempfs; char fontname4[] = "-adobe-times-bold-i-normal--12-120-75-75-p-68-iso8859-1"; char fontname3[] = "-adobe-times-bold-i-normal--14-140-75-75-p-77-iso8859-1"; char fontname2[] = "-adobe-times-bold-i-normal--18-180-75-75-p-98-iso8859-1"; char fontname1[] = "-adobe-times-bold-i-normal--24-240-75-75-p-128-iso8859-1"; if ((tempfs = XLoadQueryFont (display, fontname1)) == NULL) printf ("font %s not found!\n", fontname1); else { XTextItem xti; xti.chars = "FDA-Tool"; xti.nchars = strlen (xti.chars); xti.delta = 0; xti.font = tempfs->fid; texty += tempfs->max_bounds.ascent + tempfs->max_bounds.descent; XDrawText (display, pixmap, tempgc, textx, texty, &xti, 1); XUnloadFont (display, xti.font); } if ((tempfs = XLoadQueryFont (display, fontname2)) == NULL) printf ("font %s not found!\n", fontname2); else { XTextItem xti; xti.chars = WELCOME_BANNER; xti.nchars = strlen (xti.chars); xti.delta = 0; xti.font = tempfs->fid; texty += tempfs->max_bounds.ascent + tempfs->max_bounds.descent; XDrawText (display, pixmap, tempgc, textx, texty, &xti, 1); XUnloadFont (display, xti.font); } if ((tempfs = XLoadQueryFont (display, fontname3)) == NULL) printf ("font %s not found!\n", fontname3); else { XTextItem xti; xti.chars = "University of Braunschweig"; xti.nchars = strlen (xti.chars); xti.delta = 0; xti.font = tempfs->fid; texty += tempfs->max_bounds.ascent + tempfs->max_bounds.descent; XDrawText (display, pixmap, tempgc, textx, texty, &xti, 1); xti.chars = "Department of Computer-Science"; xti.nchars = strlen (xti.chars); texty += tempfs->max_bounds.ascent + tempfs->max_bounds.descent + WELCOME_BORDER; XDrawText (display, pixmap, tempgc, textx, texty, &xti, 1); XUnloadFont (display, xti.font); } if ((tempfs = XLoadQueryFont (display, fontname4)) == NULL) printf ("font %s not found!\n", fontname4); else { XTextItem xti; xti.chars = "Supervisor: Frank Klawonn"; xti.nchars = strlen (xti.chars); xti.delta = 0; xti.font = tempfs->fid; texty += tempfs->max_bounds.ascent + tempfs->max_bounds.descent; XDrawText (display, pixmap, tempgc, textx, texty, &xti, 1); XUnloadFont (display, xti.font); } XFreeGC (display, tempgc); } texty += textheight + WELCOME_BORDER; XSetForeground (display, gc, blackpix); XDrawString (display, pixmap, gc, textx, texty, ollitext1, strlen (ollitext1)); XDrawString (display, pixmap, gc, textx + textwidthleft, texty, ollitext2, strlen (ollitext2)); texty += textheight; XDrawString (display, pixmap, gc, textx, texty, thomastext1, strlen (thomastext1)); XDrawString (display, pixmap, gc, textx + textwidthleft, texty, thomastext2, strlen (thomastext2)); texty += 2 * textheight; XDrawString (display, pixmap, gc, textx, texty, copyright, strlen (copyright));// final insert graphic int allplanes = (int) pow (2, depth) - 1; XSetForeground (display, gc, blackpix); XSetPlaneMask (display, gc, AllPlanes); XSetBackground (display, gc, buttonpix); XSetFunction (display, gc, GXclear); XCopyPlane (display, bmp, pixmap, gc, 0, 0, tubs_width, tubs_height, WELCOME_BORDER + 2, WELCOME_BORDER + 2, 1); XSetFunction (display, gc, GXor); XCopyPlane (display, bmp, pixmap, gc, 0, 0, tubs_width, tubs_height, WELCOME_BORDER + 2, WELCOME_BORDER + 2, 1); XSetBackground (display, gc, allplanes); XSetForeground (display, gc, 0); XSetFunction (display, gc, GXand); XCopyPlane (display, bmp, pixmap, gc, 0, 0, tubs_width, tubs_height, WELCOME_BORDER, WELCOME_BORDER, 1); XSetFunction (display, gc, GXor); XSetForeground (display, gc, whitepix); XSetBackground (display, gc, 0); XCopyPlane (display, bmp, pixmap, gc, 0, 0, tubs_width, tubs_height, WELCOME_BORDER, WELCOME_BORDER, 1); XSetFunction (display, gc, GXcopy); XFreePixmap (display, bmp); SetSelectedInput (ExposureMask | StructureNotifyMask); FixMySize (); MapMe ();}void Welcome::Action (int Actionnumber, int value){ XUnmapWindow (display, window);#if 0 /* XXX: would you believe this ??? */ delete this;#endif Parent->Action (Actionnumber, 0);}void Welcome::HandleEvent (XEvent * Event){ switch (Event->type) { case Expose: if (Event->xexpose.count == 0) XCopyArea (display, pixmap, window, gc, 0, 0, width, height, 0, 0); break; }}Welcome::~Welcome (){ XFreePixmap (display, pixmap); delete Ok;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -