コード例 #1
0
void
SplashRedrawWindow(Splash * splash) {
    XImage *ximage;

    // making this method redraw a part of the image does not make
    // much sense as SplashUpdateScreenData always re-generates
    // the image completely, so whole window is always redrawn

    SplashUpdateScreenData(splash);
    ximage = XCreateImage(splash->display, splash->visual,
            splash->screenFormat.depthBytes * 8, ZPixmap, 0, (char *) NULL,
            splash->width, splash->height, 8, 0);
    ximage->data = (char *) splash->screenData;
    ximage->bits_per_pixel = ximage->depth;
    ximage->bytes_per_line = ximage->depth * ximage->width / 8;
    ximage->byte_order = ByteOrderToX(splash->screenFormat.byteOrder);
    ximage->bitmap_unit = 8;
    XPutImage(splash->display, splash->window,
            XDefaultGCOfScreen(splash->screen), ximage, 0, 0, 0, 0,
            splash->width, splash->height);
    ximage->data = NULL;
    XDestroyImage(ximage);
    SplashRemoveDecoration(splash);
    XMapWindow(splash->display, splash->window);
}
コード例 #2
0
ファイル: Login.c プロジェクト: shanelle794/theqvd
/* ARGSUSED */
static void Initialize (
    Widget greq,
    Widget gnew,
    ArgList args,
    Cardinal *num_args)
{
    LoginWidget w = (LoginWidget)gnew;
    XtGCMask	valuemask, xvaluemask;
    XGCValues	myXGCV;
    Arg		position[2];
    Position	x, y;
#ifdef USE_XINERAMA
    XineramaScreenInfo *screens;
    int                 s_num;
#endif

#ifdef XPM
    myXGCV.foreground = w->login.hipixel;
    myXGCV.background = w->core.background_pixel;
    valuemask = GCForeground | GCBackground;
    w->login.hiGC = XtGetGC(gnew, valuemask, &myXGCV);

    myXGCV.foreground = w->login.shdpixel;
    myXGCV.background = w->core.background_pixel;
    valuemask = GCForeground | GCBackground;
    w->login.shdGC = XtGetGC(gnew, valuemask, &myXGCV);
#endif /* XPM */

    myXGCV.foreground = w->login.textpixel;
    myXGCV.background = w->core.background_pixel;
    valuemask = GCForeground | GCBackground;
    if (w->login.font) {
	myXGCV.font = w->login.font->fid;
	valuemask |= GCFont;
    }
    w->login.textGC = XtGetGC(gnew, valuemask, &myXGCV);
    myXGCV.foreground = w->core.background_pixel;
    w->login.bgGC = XtGetGC(gnew, valuemask, &myXGCV);

    myXGCV.foreground = w->login.textpixel ^ w->core.background_pixel;
    myXGCV.function = GXxor;
    xvaluemask = valuemask | GCFunction;
    w->login.xorGC = XtGetGC (gnew, xvaluemask, &myXGCV);

    /*
     * Note that the second argument is a GCid -- QueryFont accepts a GCid and
     * returns the curently contained font.
     */

    if (w->login.font == NULL)
	w->login.font = XQueryFont (XtDisplay (w),
		XGContextFromGC (XDefaultGCOfScreen (XtScreen (w))));

    xvaluemask = valuemask;
    if (w->login.promptFont == NULL)
        w->login.promptFont = w->login.font;
    else
	xvaluemask |= GCFont;

    myXGCV.foreground = w->login.promptpixel;
    myXGCV.font = w->login.promptFont->fid;
    w->login.promptGC = XtGetGC (gnew, xvaluemask, &myXGCV);

    xvaluemask = valuemask;
    if (w->login.greetFont == NULL)
    	w->login.greetFont = w->login.font;
    else
	xvaluemask |= GCFont;

    myXGCV.foreground = w->login.greetpixel;
    myXGCV.font = w->login.greetFont->fid;
    w->login.greetGC = XtGetGC (gnew, xvaluemask, &myXGCV);

    xvaluemask = valuemask;
    if (w->login.failFont == NULL)
	w->login.failFont = w->login.font;
    else
	xvaluemask |= GCFont;

    myXGCV.foreground = w->login.failpixel;
    myXGCV.font = w->login.failFont->fid;
    w->login.failGC = XtGetGC (gnew, xvaluemask, &myXGCV);

#ifdef XPM
    w->login.logoValid = False;

    if (NULL != w->login.logoFileName)
    {
        XpmAttributes myAttributes = { 0 };
        Window tmpWindow = { 0 };
        struct stat myBuffer = { 0 };
        unsigned int myPixmapDepth = 0;

        if (0 != stat(w->login.logoFileName, &myBuffer))
        {
            LogError("Unable to stat() pixmap file %s\n",
                w->login.logoFileName);
            w->login.logoValid = False;
            goto SkipXpmLoad;
        }
        else

        myAttributes.valuemask |= XpmReturnPixels;
        myAttributes.valuemask |= XpmReturnExtensions;

        XpmReadFileToPixmap(XtDisplay(w),            /* display */
            RootWindowOfScreen(XtScreen(w)),         /* window */
            w->login.logoFileName,                   /* XPM filename */
            &(w->login.logoPixmap),                  /* pixmap */
            &(w->login.logoMask),                    /* pixmap mask */
            &myAttributes);                          /* XPM attributes */
        w->login.logoValid = True;

        XGetGeometry(XtDisplay(w), w->login.logoPixmap,
            &tmpWindow,
            &(w->login.logoX),
            &(w->login.logoY),
            &(w->login.logoWidth),
            &(w->login.logoHeight),
            &(w->login.logoBorderWidth),
            &myPixmapDepth);
    } else {
	w->login.logoX = 0;
	w->login.logoY = 0;
	w->login.logoWidth = 0;
	w->login.logoHeight = 0;
	w->login.logoBorderWidth = 0;
    }


SkipXpmLoad:
#endif /* XPM */
    w->login.data.name[0] = '\0';
    w->login.data.passwd[0] = '\0';
    w->login.state = GET_NAME;
    w->login.cursor = 0;
    w->login.failUp = 0;
    if (w->core.width == 0)
	w->core.width = max (GREET_W(w), FAIL_W(w)) + PAD_X(w);
    if (w->core.height == 0) {
	int fy = FAIL_Y(w);
	int pady = PAD_Y(w);

#ifndef XPM
	w->core.height = fy + pady;	/* for stupid compilers */
#else
/*	w->core.height = fy + pady;	* for stupid compilers */

        w->core.height = max(fy + pady,
            (w->login.logoHeight + (2*w->login.logoPadding)) + pady);
        
#endif /* XPM */
    }
#ifdef USE_XINERAMA
    if (
	XineramaIsActive(XtDisplay(w)) &&
	(screens = XineramaQueryScreens(XtDisplay(w), &s_num)) != NULL
       )
    {
	if ((x = w->core.x) == -1)
	    x = screens[0].x_org + (int)(screens[0].width - w->core.width) / 2;
	if ((y = w->core.y) == -1)
	    y = screens[0].y_org + (int)(screens[0].height - w->core.height) / 3;
	
	XFree(screens);
    }
    else
#endif
    {
	if ((x = w->core.x) == -1)
	    x = (int)(XWidthOfScreen (XtScreen (w)) - w->core.width) / 2;
	if ((y = w->core.y) == -1)
	    y = (int)(XHeightOfScreen (XtScreen (w)) - w->core.height) / 3;
    }
    XtSetArg (position[0], XtNx, x);
    XtSetArg (position[1], XtNy, y);
    XtSetValues (XtParent (w), position, (Cardinal) 2);
}
int main (int argc, char* argv[])
{
	/* Determine number of iterations. */
	if (2 != argc)
	{
		printf("usage: %s <num-iterations>\n", argv[0]);
		exit(1);
	}
	int numIterations = atoi(argv[1]);

	int returnCode = 0;
	Display* xDisplay = NULL;
	Window xWindow = 0;
	Picture xPictureWindow = 0;
	Pixmap xPixmapMain = 0;
	Picture xPictureMain = 0;
	Pixmap xPixmapOverlay = 0;
	Picture xPictureOverlay = 0;
	Pixmap xPixmapMask = 0;
	Picture xPictureMask = 0;
	GC gcMask = 0;

	/* Access X display. */
	if (NULL == (xDisplay = XOpenDisplay(NULL)))
	{
		printf("XOpenDisplay(NULL) failed\n");
		returnCode = 1;
		goto error;
	}

	/* Access info about the screen. */
	Screen* xScreen = XDefaultScreenOfDisplay(xDisplay);
	GC gc = XDefaultGCOfScreen(xScreen);
	Colormap xColormap = XDefaultColormapOfScreen(xScreen);

	/* Create main X window */
	xWindow = XCreateSimpleWindow(
			xDisplay,
			RootWindow(xDisplay, 0),
			0, 0,
			IMAGE_WIDTH*2,
			IMAGE_HEIGHT*2,
			0,
			BlackPixel(xDisplay, 0),
			BlackPixel(xDisplay, 0));
	if (0 == xWindow)
	{
		printf("XCreateSimpleWindow failed\n");
		returnCode = 1;
		goto error;
	}
	XMapWindow(xDisplay, xWindow);
	XSync(xDisplay, False);

	/* Get the attributes associated with the main window. */
	XWindowAttributes xWindowAttr;
	if (!XGetWindowAttributes(xDisplay, xWindow, &xWindowAttr))
	{
		printf("XGetWindowAttributes failed\n");
		returnCode = 1;
		goto error;
	}

	/* Find the X render picture format associated with the visual */
	/* for the main window */
	XRenderPictFormat* xRenderPictFormatWindow =
		XRenderFindVisualFormat(xDisplay, xWindowAttr.visual);
	if (NULL == xRenderPictFormatWindow)
	{
		printf("XRenderFindVisualFormat failed\n");
		returnCode = 1;
		goto error;
	}

	/* Find the X render picture format associated with 8 bit alpha. */
	XRenderPictFormat xRenderPictFormatTemplate;
	xRenderPictFormatTemplate.depth = 8;
	xRenderPictFormatTemplate.type = PictTypeDirect;
	xRenderPictFormatTemplate.direct.alphaMask = 0x0FF;
	unsigned long xRenderPictFormatTemplateMask =
			PictFormatDepth | PictFormatType | PictFormatAlphaMask;
	XRenderPictFormat* xRenderPictFormatMask =
		XRenderFindFormat(
			xDisplay,
			xRenderPictFormatTemplateMask,
			&xRenderPictFormatTemplate,
			0);
	if (NULL == xRenderPictFormatMask)
	{
		printf("XRenderFindFormat failed\n");
		returnCode = 1;
		goto error;
	}

	/* Create X render picture associated with the screen. */
	/* Having the same visual format as the window. */
	xPictureWindow = XRenderCreatePicture(
				xDisplay,
				xWindow,
				xRenderPictFormatWindow,
				0,
				NULL);
	if (0 == xPictureWindow)
	{
		printf("XRenderCreatePicture (window) failed\n");
		returnCode = 1;
		goto error;
	}

	/* Create backing pixmap for the main window. */
	xPixmapMain = XCreatePixmap(
			xDisplay,
			xWindow,
			xWindowAttr.width,
			xWindowAttr.height,
			xWindowAttr.depth);
	if (0 == xPixmapMain)
	{
		printf("XCreatePixmap (main) failed\n");
		returnCode = 1;
		goto error;
	}

	/* Create X render picture associated with the backing pixmap. */
	/* Having the same visual format as the window. */
	xPictureMain = XRenderCreatePicture(
			xDisplay,
			xPixmapMain,
			xRenderPictFormatWindow,
			0,
			NULL);
	if (0 == xPictureMain)
	{
		printf("XRenderCreatePicture (main) failed\n");
		returnCode = 1;
		goto error;
	}

	/* Draw concentric rectangles of different gray. */
	unsigned i;
	for (i = 0; i < 256; ++i)
	{
		float fGray = i / 255.0;

		/* Find the color gray. */
		XcmsColor xColorGray;
		xColorGray.spec.RGBi.red = fGray;
		xColorGray.spec.RGBi.green = fGray;
		xColorGray.spec.RGBi.blue = fGray;
		xColorGray.format = XcmsRGBiFormat;
		if (0 == XcmsAllocColor(
				xDisplay,
				xColormap,
				&xColorGray,
				XcmsRGBFormat))
		{
			printf("XcmsAllocColor failed\n");
			returnCode = 1;
			goto error;
		}

		/* Change the drawing color for the main window. */
		XSetForeground(xDisplay, gc, xColorGray.pixel);

		XDrawRectangle(
			xDisplay,
			xPixmapMain,
			gc,
			i, i,
			(IMAGE_WIDTH - i) * 2 - 1,
			(IMAGE_HEIGHT - i) * 2 - 1);
	}
	XRenderComposite(
		xDisplay,
		PictOpSrc,
		xPictureMain,	/* src */
		0,		/* mask */
		xPictureWindow,	/* dst */
		0, 0,		/* src (x,y) */
		0, 0,		/* mask (x,y) */
		0, 0,		/* dst (x,y) */
		xWindowAttr.width,
		xWindowAttr.height);
	XSync(xDisplay, False);

	/* Create pixmap for the overlay content. */
	xPixmapOverlay = XCreatePixmap(
				xDisplay,
				xWindow,
				IMAGE_WIDTH,
				IMAGE_HEIGHT,
				xWindowAttr.depth);
	if (0 == xPixmapOverlay)
	{
		printf("XCreatePixmap (overlay) failed\n");
		returnCode = 1;
		goto error;
	}

	/* Create X render picture assocaited with the overlay pixmap. */
	/* Having the same visual format as the window. */
	xPictureOverlay = XRenderCreatePicture(
				xDisplay,
				xPixmapOverlay,
				xRenderPictFormatWindow,
				0,
				NULL);
	if (0 == xPictureOverlay)
	{
		printf("XRenderCreatePicture (overlay) failed\n");
		returnCode = 1;
		goto error;
	}

	/* Fill the overlay with black to be used for overlay color. */
	XSetForeground(xDisplay, gc, XBlackPixelOfScreen(xScreen));
	XFillRectangle(
		xDisplay,
		xPixmapOverlay,
		gc,
		0, 0,
		IMAGE_WIDTH,
		IMAGE_HEIGHT);

	/* Create pixmap for the mask content. */
	xPixmapMask = XCreatePixmap(
				xDisplay,
				xWindow,
				IMAGE_WIDTH,
				IMAGE_HEIGHT,
				8);
	if (0 == xPixmapMask)
	{
		printf("XCreatePixmap (mask) failed\n");
		returnCode = 1;
		goto error;
	}

	/* Create X render picture assocaited with the mask pixmap. */
	xPictureMask = XRenderCreatePicture(
				xDisplay,
				xPixmapMask,
				xRenderPictFormatMask,
				0,
				NULL);
	if (0 == xPictureMask)
	{
		printf("XRenderCreatePicture (mask) failed\n");
		returnCode = 1;
		goto error;
	}

	/* Create a GC to go with mask */
	gcMask = XCreateGC(xDisplay, xPixmapMask, 0, NULL);
	XSetForeground(xDisplay, gcMask, 0x00000000);
	XFillRectangle(
		xDisplay,
		xPixmapMask,
		gcMask,
		0, 0,
		IMAGE_WIDTH,
		IMAGE_HEIGHT);
	XSetForeground(xDisplay, gcMask, 0x40404040);
	XDrawRectangle(
		xDisplay,
		xPixmapMask,
		gcMask,
		0, 0,
		IMAGE_WIDTH-1,
		IMAGE_HEIGHT-1);
	XFillArc(
		xDisplay,
		xPixmapMask,
		gcMask,
		100, 100,
		100, 100,
		0,		/* start angle-degrees * 64 */
		360 * 64);	/* extent angle-degrees * 64 */

	Bool bIncX = True;
	Bool bIncY = True;
	Bool bNextRow = False;
	int x = 0;
	int y = 0;
	struct timeval timeStart;
	gettimeofday(&timeStart, NULL);
	int iter;
	for (iter = 0; iter < numIterations; ++iter)
	{
		XRenderComposite(
			xDisplay,
			PictOpSrc,
			xPictureMain,	/* src */
			0,		/* mask */
			xPictureWindow,	/* dst */
			x, y,		/* src (x,y) */
			0, 0,		/* mask (x,y) */
			x,		/* dst x */
			y,		/* dst y */
			IMAGE_WIDTH,
			IMAGE_HEIGHT);

		if (bNextRow)
		{
			if (bIncY)
			{
				if ((y += 10) >= IMAGE_HEIGHT)
				{
					y = IMAGE_HEIGHT - 1;
					bIncY = False;
				}
			}
			else
			{
				if ((y -= 10) < 0)
				{
					y = 0;
					bIncY = True;
				}
			}

			bNextRow = False;
		}
		else
		{
			if (bIncX)
			{
				if (++x >= IMAGE_WIDTH)
				{
					x = IMAGE_WIDTH - 1;
					bIncX = False;
					bNextRow = True;
				}
			}
			else
			{
				if (--x < 0)
				{
					x = 0;
					bIncX = True;
					bNextRow = True;
				}
			}
		}

		XRenderComposite(
			xDisplay,
			PictOpOver,
			xPictureOverlay,/* src */
			xPictureMask,	/* mask */
			xPictureWindow,	/* dst */
			0, 0,		/* src (x,y) */
			0, 0,		/* mask (x,y) */
			x,		/* dst x */
			y,		/* dst y */
			IMAGE_WIDTH,
			IMAGE_HEIGHT);
	}
	XSync(xDisplay, False);

	struct timeval timeEnd;
	gettimeofday(&timeEnd, NULL);
	double elapsedSec =
		getElapsedMicroseconds(&timeStart, &timeEnd) / 1000000L;
	double fps = numIterations / elapsedSec;
	printf("average update rate = %.1lf FPS\n", fps);

error:

	if (0 != gcMask)
	{
		XFreeGC(xDisplay, gcMask);
		gcMask = 0;
	}

	if (0 != xPictureMask)
	{
		XRenderFreePicture(xDisplay, xPictureMask);
		xPictureMask = 0;
	}

	if (0 != xPixmapMask)
	{
		XFreePixmap(xDisplay, xPixmapMask);
		xPixmapMask = 0;
	}

	if (0 != xPictureOverlay)
	{
		XRenderFreePicture(xDisplay, xPictureOverlay);
		xPictureOverlay = 0;
	}

	if (0 != xPixmapOverlay)
	{
		XFreePixmap(xDisplay, xPixmapOverlay);
		xPixmapOverlay = 0;
	}

	if (0 != xPictureMain)
	{
		XRenderFreePicture(xDisplay, xPictureMain);
		xPictureMain = 0;
	}

	if (0 != xPixmapMain)
	{
		XFreePixmap(xDisplay, xPixmapMain);
		xPixmapMain = 0;
	}

	if (0 != xPictureWindow)
	{
		XRenderFreePicture(xDisplay, xPictureWindow);
		xPictureWindow = 0;
	}

	if (0 != xWindow)
	{
		XDestroyWindow(xDisplay, xWindow);
		xWindow = 0;
	}

	if (NULL != xDisplay)
	{
		XCloseDisplay(xDisplay);
		xDisplay = NULL;
	}

	return returnCode;
}
コード例 #4
0
ファイル: test1.c プロジェクト: idunham/dtextra
int
main(int argc, char **argv)
{
  Widget toplevel, rc, one;
  XtAppContext app;

  XtSetLanguageProc(NULL, NULL, NULL);

  toplevel = XtVaAppInitialize(&app, "BubbleButtonTest", NULL, 0, &argc, argv, NULL, NULL);

  rc = XmCreateRowColumn(toplevel, "RC", NULL, 0);

  one = XltCreateBubbleButton(rc, "BubbleButton1", NULL, 0);
  XtAddCallback(one, XmNactivateCallback, (XtCallbackProc)Callback, NULL);
  {
  XmString string;

  string = XmStringCreateSimple("MouseOver");
  XtVaSetValues(one,
  	XmNalignment, XmALIGNMENT_CENTER,
  	XltNmouseOverString, string,
  	NULL);
  XmStringFree(string);
  }
  XtManageChild(one);
  one = XltCreateBubbleButton(rc, "BubbleButton2", NULL, 0);
  {
    Pixmap pixmap;
    Pixmap pixmap_insens;
    XpmAttributes attrib;
    GC gc;

    {
	XpmColorSymbol colors[1];

	XtVaGetValues(one,
		      XmNbackground, &colors[0].pixel,
		      NULL);
	colors[0].name = NULL;
	colors[0].value = "None";
	attrib.valuemask = XpmCloseness | XpmColorSymbols;
	attrib.closeness = 40000;
	attrib.colorsymbols = colors;
	attrib.numsymbols = 1;
	XpmCreatePixmapFromData(XtDisplay(one),
				XRootWindowOfScreen(XtScreen(one)),
				dates,
				&pixmap,
				NULL,
				&attrib);

	pixmap_insens = XCreatePixmap(XtDisplay(one),
				      pixmap,
				      attrib.width,
				      attrib.height,
				      DefaultDepthOfScreen(XtScreen(one)));
	gc = XDefaultGCOfScreen(XtScreen(one));
	XSetFunction(XtDisplay(one),gc,GXcopy);
	XCopyArea(XtDisplay(one),
		  pixmap,
		  pixmap_insens,
		  gc,
		  0, 0,
		  attrib.width, attrib.height,
		  0, 0);
	XSetFillStyle(XtDisplay(one), gc, FillStippled);
	XSetStipple(XtDisplay(one), gc,
		    XmGetPixmapByDepth(XtScreen(one),
				       "25_foreground",
				       1 /*WhitePixelOfScreen(XtScreen(ToolBar))*/,
				       0 /*BlackPixelOfScreen(XtScreen(ToolBar))*/,
				       1));
	XFillRectangle(XtDisplay(one),
		       pixmap_insens,
		       gc,
		       0, 0,
		       attrib.width + 1, attrib.height + 1);

	XpmFreeAttributes(&attrib);

	XtVaSetValues(one,
		      XmNalignment, XmALIGNMENT_CENTER,
		      XmNlabelType, XmPIXMAP,
		      XmNlabelPixmap, pixmap,
		      XltNmouseOverPixmap, pixmap_insens,
		      NULL);
    }
  }
  XtAddCallback(one, XmNactivateCallback, (XtCallbackProc)Callback, NULL);
  XtManageChild(one);

  XtManageChild(rc);

  XtRealizeWidget(toplevel);
  XtAppMainLoop(app);

  exit(0);
}
コード例 #5
0
void HelloWorld::draw() {
    // Getting window dimensions.
    Window rootWindow;
    int x, y;
    unsigned int width, height, borderWidth, bitDepth;
    XGetGeometry(_display, _window, &rootWindow, &x, &y, &width, &height,
            &borderWidth, &bitDepth);

    // Setting up the GC.
    GC gc = XDefaultGCOfScreen(_screen);
    XSetBackground(_display, gc, _whiteColor);
    XSetFont(_display, gc, _font);
    XSetForeground(_display, gc, _blackColor);

    // Clearing the window.
    XClearArea(_display, _window, 0, 0, width, height, false);

    // Is the window large enough for us?
    if((width < MIN_CELL_SIZE * 3) ||
            (height < (MIN_CELL_SIZE * 3 + STRING_HEIGHT * 3))) {
        _drawStringCentered(gc, "Window too small.", 0, 0, width, height);
        return;
    }

    // Calculating grid cell sizes.
    int xStepSize = width / 3;
    int yStepSize = (height - STRING_HEIGHT * 3) / 3;

    // Drawing glyphs.
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            switch(_game.getCellState(i, j)) {
            case CELL_O:
                _drawO(gc, xStepSize * i, STRING_HEIGHT * 2 + yStepSize * j,
                        xStepSize, yStepSize);
                break;
            case CELL_X:
                _drawX(gc, xStepSize * i, STRING_HEIGHT * 2 + yStepSize * j,
                        xStepSize, yStepSize);
                break;
            default:
                break;
            }
        }
    }
    XSetBackground(_display, gc, _whiteColor);
    XSetForeground(_display, gc, _blackColor);

    // Drawing the grid lines.
    for(int i = 0; i <= 3; i++) {
        int yValue = STRING_HEIGHT * 2 + yStepSize * i;
        XDrawLine(_display, _window, gc, 0, yValue, width, yValue);
    }
    for(int i = 1; i <= 2; i++) {
        int xValue = xStepSize * i;
        XDrawLine(_display, _window, gc, xValue, STRING_HEIGHT * 2, xValue,
                height - STRING_HEIGHT);
    }

    // Drawing the strings.
    _drawStringCentered(gc, "Hello, World!", 0, 0, width, STRING_HEIGHT);
    _drawStringCentered(gc, "[R]estart", 0, height - STRING_HEIGHT,
            width, STRING_HEIGHT);

    switch(_game.getGameState()) {
    case X_TURN:
        _drawStringCentered(gc, "It is your turn to play.", 0, STRING_HEIGHT,
                width, STRING_HEIGHT);
        break;
    case O_TURN:
        _drawStringCentered(gc, "Please wait, thinking...", 0, STRING_HEIGHT,
                width, STRING_HEIGHT);
        break;
    case X_WON:
        _drawStringCentered(gc, "You have won.", 0, STRING_HEIGHT, width,
                STRING_HEIGHT);
        break;
    case O_WON:
        _drawStringCentered(gc, "You have lost.", 0, STRING_HEIGHT, width,
                STRING_HEIGHT);
        break;
    case DRAW:
        _drawStringCentered(gc, "It is a draw.", 0, STRING_HEIGHT, width,
                STRING_HEIGHT);
        break;
    default:
        break;
    }
}