src/video/SDL_video.c
changeset 6602 533131e24aeb
parent 6554 5bcda034e678
child 6611 5c8b5b03ad8a
     1.1 --- a/src/video/SDL_video.c	Tue Oct 23 17:10:09 2012 -0700
     1.2 +++ b/src/video/SDL_video.c	Tue Oct 23 17:11:22 2012 -0700
     1.3 @@ -2839,4 +2839,55 @@
     1.4      return SDL_FALSE;
     1.5  }
     1.6  
     1.7 +#if SDL_VIDEO_DRIVER_X11
     1.8 +extern int X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
     1.9 +#endif
    1.10 +
    1.11 +int
    1.12 +SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
    1.13 +{
    1.14 +    int dummybutton;
    1.15 +
    1.16 +    if (!buttonid) {
    1.17 +        buttonid = &dummybutton;
    1.18 +    }
    1.19 +    if (_this && _this->ShowMessageBox) {
    1.20 +        if (_this->ShowMessageBox(_this, messageboxdata, buttonid) == 0) {
    1.21 +            return 0;
    1.22 +        }
    1.23 +    }
    1.24 +
    1.25 +    /* It's completely fine to call this function before video is initialized */
    1.26 +#if SDL_VIDEO_DRIVER_X11
    1.27 +    if (X11_ShowMessageBox(messageboxdata, buttonid) == 0) {
    1.28 +        return 0;
    1.29 +    }
    1.30 +#endif
    1.31 +
    1.32 +    SDL_SetError("No message system available");
    1.33 +    return -1;
    1.34 +}
    1.35 +
    1.36 +int
    1.37 +SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window)
    1.38 +{
    1.39 +    SDL_MessageBoxData data;
    1.40 +    SDL_MessageBoxButtonData button;
    1.41 +
    1.42 +    SDL_zero(data);
    1.43 +    data.flags = flags;
    1.44 +    data.title = title;
    1.45 +    data.message = message;
    1.46 +    data.numbuttons = 1;
    1.47 +    data.buttons = &button;
    1.48 +    data.window = window;
    1.49 +
    1.50 +    SDL_zero(button);
    1.51 +    button.flags |= SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT;
    1.52 +    button.flags |= SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
    1.53 +    button.text = "OK";
    1.54 +
    1.55 +    return SDL_ShowMessageBox(&data, NULL);
    1.56 +}
    1.57 +
    1.58  /* vi: set ts=4 sw=4 expandtab: */