static bool LogoCallBack(t_x11 *x11, XEvent *event, Window /*w*/, void *data) { /* Assume window is 100x110 */ static bool bFirst = true; #define CSIZE 9 #define NSIZE 8 #define OSIZE 9 #define HSIZE 7 #define YOFFS 30 static t_circle c[] = { { 10, YOFFS+12, CSIZE, &LIGHTGREEN }, { 20, YOFFS+22, CSIZE, &LIGHTGREEN }, { 20, YOFFS+34, OSIZE, &LIGHTRED }, { 30, YOFFS+12, NSIZE, &LIGHTCYAN }, { 30, YOFFS+ 2, HSIZE, &WHITE }, { 40, YOFFS+22, CSIZE, &LIGHTGREEN }, { 40, YOFFS+34, CSIZE, &LIGHTGREEN }, { 50, YOFFS+12, CSIZE, &LIGHTGREEN }, { 50, YOFFS, OSIZE, &LIGHTRED }, { 60, YOFFS+22, NSIZE, &LIGHTCYAN }, { 60, YOFFS+32, HSIZE, &WHITE }, { 70, YOFFS+12, CSIZE, &LIGHTGREEN }, { 80, YOFFS+22, CSIZE, &LIGHTGREEN }, { 80, YOFFS+34, OSIZE, &LIGHTRED }, { 90, YOFFS+12, NSIZE, &LIGHTCYAN }, { 90, YOFFS+ 2, HSIZE, &WHITE }, {100, YOFFS+22, CSIZE, &LIGHTGREEN } }; static int lines[] = { 0, 1, 1, 2, 1, 3, 3, 4, 3, 5, 5, 6, 5, 7, 7, 8, 7, 9, 9, 10, 9, 11, 11, 12, 12, 13, 12, 14, 14, 15, 14, 16 }; #define COFFS 70 static t_mess Mess[] = { { "GROMACS", 0, 20, NULL }, { NULL, 16, 9, NULL }, { "Copyright (c) 1991-2013", COFFS+ 2, 9, NULL }, { "D.v.d.Spoel, E.Lindahl, B.Hess", COFFS+11, 9, NULL }, { "& Groningen University ", COFFS+20, 9, NULL }, { "click to dismiss", COFFS+31, 8, NULL } }; #define NMESS asize(Mess) int i; real wfac, hfac; t_logo *logo; t_windata *wd; logo = (t_logo *)data; wd = &(logo->wd); if (bFirst) { wfac = wd->width/110.0; hfac = wd->height/110.0; for (i = 0; (i < asize(c)); i++) { c[i].x *= wfac; c[i].y *= hfac; } Mess[1].text = GromacsVersion(); for (i = 0; (i < NMESS); i++) { Mess[i].y *= hfac; Mess[i].h *= hfac; Mess[i].fnt = (i == 0) ? logo->bigfont : (i == NMESS-1) ? x11->font : logo->smallfont; } bFirst = false; } switch (event->type) { case Expose: XSetForeground(x11->disp, x11->gc, WHITE); XSetLineAttributes(x11->disp, x11->gc, 3, LineSolid, CapNotLast, JoinRound); for (i = 0; (i < asize(lines)); i += 2) { XDrawLine(x11->disp, wd->self, x11->gc, c[lines[i]].x, c[lines[i]].y, c[lines[i+1]].x, c[lines[i+1]].y); } XSetLineAttributes(x11->disp, x11->gc, 1, LineSolid, CapNotLast, JoinRound); for (i = 0; (i < asize(c)); i++) { XSetForeground(x11->disp, x11->gc, *(c[i].col)); XFillCircle(x11->disp, wd->self, x11->gc, c[i].x, c[i].y, c[i].rad); } XSetForeground(x11->disp, x11->gc, BLACK); XDrawRectangle(x11->disp, wd->self, x11->gc, 2, 2, wd->width-5, wd->height-5); for (i = 0; (i < NMESS); i++) { SpecialTextInRect(x11, Mess[i].fnt, wd->self, Mess[i].text, 0, Mess[i].y, wd->width, Mess[i].h, eXCenter, eYCenter); } XSetForeground(x11->disp, x11->gc, x11->fg); break; case ButtonPress: hide_logo(x11, logo); return logo->bQuitOnClick; break; default: break; } return false; }
void TextInRect(t_x11 *x11, Drawable win, const char *s, int x, int y, int width, int height, eXPos eX, eYPos eY) { SpecialTextInRect(x11, NULL, win, s, x, y, width, height, eX, eY); }