/* Draw our message box. */ static void X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx ) { int i; Window window = data->window; Display *display = data->display; X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] ); X11_XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height ); X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] ); for ( i = 0; i < data->numlines; i++ ) { TextLineData *plinedata = &data->linedata[ i ]; if (SDL_X11_HAVE_UTF8) { X11_Xutf8DrawString( display, window, data->font_set, ctx, data->xtext, data->ytext + i * data->text_height, plinedata->text, plinedata->length ); } else { X11_XDrawString( display, window, ctx, data->xtext, data->ytext + i * data->text_height, plinedata->text, plinedata->length ); } } for ( i = 0; i < data->numbuttons; i++ ) { SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[ i ]; const SDL_MessageBoxButtonData *buttondata = buttondatax11->buttondata; int border = ( buttondata->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT ) ? 2 : 0; int offset = ( ( data->mouse_over_index == i ) && ( data->button_press_index == data->mouse_over_index ) ) ? 1 : 0; X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND ] ); X11_XFillRectangle( display, window, ctx, buttondatax11->rect.x - border, buttondatax11->rect.y - border, buttondatax11->rect.w + 2 * border, buttondatax11->rect.h + 2 * border ); X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BORDER ] ); X11_XDrawRectangle( display, window, ctx, buttondatax11->rect.x, buttondatax11->rect.y, buttondatax11->rect.w, buttondatax11->rect.h ); X11_XSetForeground( display, ctx, ( data->mouse_over_index == i ) ? data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED ] : data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] ); if (SDL_X11_HAVE_UTF8) { X11_Xutf8DrawString( display, window, data->font_set, ctx, buttondatax11->x + offset, buttondatax11->y + offset, buttondata->text, buttondatax11->length ); } else { X11_XDrawString( display, window, ctx, buttondatax11->x + offset, buttondatax11->y + offset, buttondata->text, buttondatax11->length ); } } }
/* Draw our message box. */ static void X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx ) { int i; Drawable window = data->window; Display *display = data->display; #if SDL_VIDEO_DRIVER_X11_XDBE if (SDL_X11_HAVE_XDBE && data->xdbe) { window = data->buf; X11_XdbeBeginIdiom(data->display); } #endif X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] ); X11_XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height ); X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] ); for ( i = 0; i < data->numlines; i++ ) { TextLineData *plinedata = &data->linedata[ i ]; if (SDL_X11_HAVE_UTF8) { X11_Xutf8DrawString( display, window, data->font_set, ctx, data->xtext, data->ytext + i * data->text_height, plinedata->text, plinedata->length ); } else { X11_XDrawString( display, window, ctx, data->xtext, data->ytext + i * data->text_height, plinedata->text, plinedata->length ); } } for ( i = 0; i < data->numbuttons; i++ ) { SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[ i ]; const SDL_MessageBoxButtonData *buttondata = buttondatax11->buttondata; int border = ( buttondata->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT ) ? 2 : 0; int offset = ( ( data->mouse_over_index == i ) && ( data->button_press_index == data->mouse_over_index ) ) ? 1 : 0; X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND ] ); X11_XFillRectangle( display, window, ctx, buttondatax11->rect.x - border, buttondatax11->rect.y - border, buttondatax11->rect.w + 2 * border, buttondatax11->rect.h + 2 * border ); X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BORDER ] ); X11_XDrawRectangle( display, window, ctx, buttondatax11->rect.x, buttondatax11->rect.y, buttondatax11->rect.w, buttondatax11->rect.h ); X11_XSetForeground( display, ctx, ( data->mouse_over_index == i ) ? data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED ] : data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] ); if (SDL_X11_HAVE_UTF8) { X11_Xutf8DrawString( display, window, data->font_set, ctx, buttondatax11->x + offset, buttondatax11->y + offset, buttondata->text, buttondatax11->length ); } else { X11_XDrawString( display, window, ctx, buttondatax11->x + offset, buttondatax11->y + offset, buttondata->text, buttondatax11->length ); } } #if SDL_VIDEO_DRIVER_X11_XDBE if (SDL_X11_HAVE_XDBE && data->xdbe) { XdbeSwapInfo swap_info; swap_info.swap_window = data->window; swap_info.swap_action = XdbeUndefined; X11_XdbeSwapBuffers(data->display, &swap_info, 1); X11_XdbeEndIdiom(data->display); } #endif }