sdl2-win93 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.dir-locals.el +2 -0
 - data/.github/workflows/gempush.yml +29 -0
 - data/.gitignore +14 -0
 - data/COPYING.txt +165 -0
 - data/Gemfile +4 -0
 - data/Gemfile.lock +24 -0
 - data/Makefile +4 -0
 - data/README.md +36 -0
 - data/Rakefile +51 -0
 - data/doc/po/ja.po +10357 -0
 - data/ext/sdl2_ext/clipboard.c +61 -0
 - data/ext/sdl2_ext/color.c +103 -0
 - data/ext/sdl2_ext/color.h +4 -0
 - data/ext/sdl2_ext/event.c +1298 -0
 - data/ext/sdl2_ext/extconf.rb +22 -0
 - data/ext/sdl2_ext/filesystem.c +63 -0
 - data/ext/sdl2_ext/gamecontroller.c +408 -0
 - data/ext/sdl2_ext/gamecontroller.c.m4 +408 -0
 - data/ext/sdl2_ext/gl.c +351 -0
 - data/ext/sdl2_ext/gl.c.m4 +351 -0
 - data/ext/sdl2_ext/hint.c +99 -0
 - data/ext/sdl2_ext/joystick.c +339 -0
 - data/ext/sdl2_ext/joystick.c.m4 +339 -0
 - data/ext/sdl2_ext/key.c +1302 -0
 - data/ext/sdl2_ext/key.c.m4 +833 -0
 - data/ext/sdl2_ext/main.c +258 -0
 - data/ext/sdl2_ext/messagebox.c +233 -0
 - data/ext/sdl2_ext/mixer.c +1205 -0
 - data/ext/sdl2_ext/mixer.c.m4 +1205 -0
 - data/ext/sdl2_ext/mouse.c +286 -0
 - data/ext/sdl2_ext/rubysdl2_internal.h +127 -0
 - data/ext/sdl2_ext/timer.c +63 -0
 - data/ext/sdl2_ext/ttf.c +376 -0
 - data/ext/sdl2_ext/ttf.c.m4 +376 -0
 - data/ext/sdl2_ext/video.c +4093 -0
 - data/ext/sdl2_ext/video.c.m4 +3867 -0
 - data/lib/sdl2.rb +3 -0
 - data/lib/sdl2/event.rb +55 -0
 - data/lib/sdl2/version.rb +8 -0
 - data/sample/chunk_destroy.rb +16 -0
 - data/sample/gfxprimitives.rb +54 -0
 - data/sample/icon.bmp +0 -0
 - data/sample/memory_test/m1.rb +28 -0
 - data/sample/memory_test/m2.rb +18 -0
 - data/sample/memory_test/m3.rb +12 -0
 - data/sample/message_box.rb +33 -0
 - data/sample/music_player.rb +137 -0
 - data/sample/playwave.rb +19 -0
 - data/sample/primitives.rb +32 -0
 - data/sample/test_clipboard.rb +16 -0
 - data/sample/test_controller.rb +62 -0
 - data/sample/test_joystick.rb +53 -0
 - data/sample/test_keyboard.rb +52 -0
 - data/sample/test_mouse.rb +50 -0
 - data/sample/test_surface.rb +13 -0
 - data/sample/test_ttf.rb +82 -0
 - data/sample/test_video.rb +59 -0
 - data/sample/testgl.rb +175 -0
 - data/sample/testsprite.rb +296 -0
 - data/sample/testspriteminimal.rb +75 -0
 - data/sample/timer.rb +11 -0
 - data/sample/version.rb +12 -0
 - data/sample/video_info.rb +64 -0
 - data/sdl2-win93.gemspec +31 -0
 - metadata +158 -0
 
    
        data/ext/sdl2_ext/main.c
    ADDED
    
    | 
         @@ -0,0 +1,258 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #define SDL2_EXTERN
         
     | 
| 
      
 2 
     | 
    
         
            +
            #include "rubysdl2_internal.h"
         
     | 
| 
      
 3 
     | 
    
         
            +
            #include <SDL.h>
         
     | 
| 
      
 4 
     | 
    
         
            +
            #include <SDL_version.h>
         
     | 
| 
      
 5 
     | 
    
         
            +
            #include <stdio.h>
         
     | 
| 
      
 6 
     | 
    
         
            +
            #ifdef HAVE_SDL_IMAGE_H
         
     | 
| 
      
 7 
     | 
    
         
            +
            #include <SDL_image.h>
         
     | 
| 
      
 8 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 9 
     | 
    
         
            +
            #ifdef HAVE_SDL_MIXER_H
         
     | 
| 
      
 10 
     | 
    
         
            +
            #include <SDL_mixer.h>
         
     | 
| 
      
 11 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 12 
     | 
    
         
            +
            #ifdef HAVE_SDL_TTF_H
         
     | 
| 
      
 13 
     | 
    
         
            +
            #include <SDL_ttf.h>
         
     | 
| 
      
 14 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 15 
     | 
    
         
            +
            #ifdef HAVE_SDL2_GFXPRIMITIVES_H
         
     | 
| 
      
 16 
     | 
    
         
            +
            #include <SDL2_gfxPrimitives.h>
         
     | 
| 
      
 17 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 18 
     | 
    
         
            +
            #include <stdarg.h>
         
     | 
| 
      
 19 
     | 
    
         
            +
            #include <ruby/encoding.h>
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            int rubysdl2_handle_error(int code, const char* cfunc)
         
     | 
| 
      
 22 
     | 
    
         
            +
            {
         
     | 
| 
      
 23 
     | 
    
         
            +
                VALUE err;
         
     | 
| 
      
 24 
     | 
    
         
            +
                char err_msg[1024];
         
     | 
| 
      
 25 
     | 
    
         
            +
              
         
     | 
| 
      
 26 
     | 
    
         
            +
                if (code >= 0)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    return code;
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                snprintf(err_msg, sizeof(err_msg), "%s (cfunc=%s)", SDL_GetError(), cfunc);
         
     | 
| 
      
 30 
     | 
    
         
            +
                err = rb_exc_new2(eSDL2Error, err_msg);
         
     | 
| 
      
 31 
     | 
    
         
            +
                rb_iv_set(eSDL2Error, "@error_code", INT2NUM(code));
         
     | 
| 
      
 32 
     | 
    
         
            +
              
         
     | 
| 
      
 33 
     | 
    
         
            +
                rb_exc_raise(err);
         
     | 
| 
      
 34 
     | 
    
         
            +
            }
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            void rubysdl2_define_attr_readers(VALUE klass, ...)
         
     | 
| 
      
 37 
     | 
    
         
            +
            {
         
     | 
| 
      
 38 
     | 
    
         
            +
                va_list ap;
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                va_start(ap, klass);
         
     | 
| 
      
 41 
     | 
    
         
            +
                for (;;) {
         
     | 
| 
      
 42 
     | 
    
         
            +
                    const char* field_name = va_arg(ap, const char*);
         
     | 
| 
      
 43 
     | 
    
         
            +
                    if (field_name == NULL)
         
     | 
| 
      
 44 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 45 
     | 
    
         
            +
                    rb_define_attr(klass, field_name, 1, 0);
         
     | 
| 
      
 46 
     | 
    
         
            +
                }
         
     | 
| 
      
 47 
     | 
    
         
            +
                va_end(ap);
         
     | 
| 
      
 48 
     | 
    
         
            +
            }
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            VALUE utf8str_new_cstr(const char* str)
         
     | 
| 
      
 51 
     | 
    
         
            +
            {
         
     | 
| 
      
 52 
     | 
    
         
            +
                return rb_enc_str_new(str, strlen(str), rb_utf8_encoding());
         
     | 
| 
      
 53 
     | 
    
         
            +
            }
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            VALUE SDL_version_to_String(const SDL_version* ver)
         
     | 
| 
      
 56 
     | 
    
         
            +
            {
         
     | 
| 
      
 57 
     | 
    
         
            +
                return rb_sprintf("%d.%d.%d", ver->major, ver->minor, ver->patch);
         
     | 
| 
      
 58 
     | 
    
         
            +
            }
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            VALUE SDL_version_to_Array(const SDL_version* ver)
         
     | 
| 
      
 61 
     | 
    
         
            +
            {
         
     | 
| 
      
 62 
     | 
    
         
            +
                return rb_ary_new3(3, INT2FIX(ver->major), INT2FIX(ver->minor), INT2FIX(ver->patch));
         
     | 
| 
      
 63 
     | 
    
         
            +
            }
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            const char* INT2BOOLCSTR(int n)
         
     | 
| 
      
 66 
     | 
    
         
            +
            {
         
     | 
| 
      
 67 
     | 
    
         
            +
                return n ? "true" : "false";
         
     | 
| 
      
 68 
     | 
    
         
            +
            }
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            typedef enum {
         
     | 
| 
      
 71 
     | 
    
         
            +
                NOT_INITIALIZED, INITIALIZDED, FINALIZED
         
     | 
| 
      
 72 
     | 
    
         
            +
            } sdl2_state;
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            static sdl2_state state = NOT_INITIALIZED;
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
            static void quit(VALUE unused)
         
     | 
| 
      
 77 
     | 
    
         
            +
            {
         
     | 
| 
      
 78 
     | 
    
         
            +
                if (state != INITIALIZDED)
         
     | 
| 
      
 79 
     | 
    
         
            +
                    return;
         
     | 
| 
      
 80 
     | 
    
         
            +
                
         
     | 
| 
      
 81 
     | 
    
         
            +
            #ifdef HAVE_SDL_IMAGE_H
         
     | 
| 
      
 82 
     | 
    
         
            +
                IMG_Quit();
         
     | 
| 
      
 83 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 84 
     | 
    
         
            +
            #ifdef HAVE_SDL_MIXER_H
         
     | 
| 
      
 85 
     | 
    
         
            +
                Mix_Quit();
         
     | 
| 
      
 86 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 87 
     | 
    
         
            +
            #ifdef HAVE_SDL_TTF_H
         
     | 
| 
      
 88 
     | 
    
         
            +
                TTF_Quit();
         
     | 
| 
      
 89 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 90 
     | 
    
         
            +
                SDL_VideoQuit();
         
     | 
| 
      
 91 
     | 
    
         
            +
                SDL_Quit();
         
     | 
| 
      
 92 
     | 
    
         
            +
                state = FINALIZED;
         
     | 
| 
      
 93 
     | 
    
         
            +
            }
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
            /*
         
     | 
| 
      
 96 
     | 
    
         
            +
             * Initialize SDL.
         
     | 
| 
      
 97 
     | 
    
         
            +
             * You must call this function before using any other Ruby/SDL2 methods.
         
     | 
| 
      
 98 
     | 
    
         
            +
             * 
         
     | 
| 
      
 99 
     | 
    
         
            +
             * You can specify initialized subsystem by flags which is
         
     | 
| 
      
 100 
     | 
    
         
            +
             * bitwise OR of the following constants:
         
     | 
| 
      
 101 
     | 
    
         
            +
             * 
         
     | 
| 
      
 102 
     | 
    
         
            +
             * * SDL2::INIT_TIMER - timer subsystem
         
     | 
| 
      
 103 
     | 
    
         
            +
             * * SDL2::INIT_AUDIO - audio subsystem
         
     | 
| 
      
 104 
     | 
    
         
            +
             * * SDL2::INIT_VIDEO - video subsystem
         
     | 
| 
      
 105 
     | 
    
         
            +
             * * SDL2::INIT_JOYSTICK - joystick subsystem
         
     | 
| 
      
 106 
     | 
    
         
            +
             * * SDL2::INIT_HAPTIC - haptic (force feedback) subsystem
         
     | 
| 
      
 107 
     | 
    
         
            +
             *     (interface is not implemented yet)
         
     | 
| 
      
 108 
     | 
    
         
            +
             * * SDL2::INIT_GAMECONTROLLER - controller subsystem
         
     | 
| 
      
 109 
     | 
    
         
            +
             * * SDL2::INIT_EVENTS - events subsystem
         
     | 
| 
      
 110 
     | 
    
         
            +
             * * SDL2::INIT_EVERYTHING - all of the above flags
         
     | 
| 
      
 111 
     | 
    
         
            +
             * * SDL2::INIT_NOPARACHUTE - this flag is ignored; for compatibility
         
     | 
| 
      
 112 
     | 
    
         
            +
             *
         
     | 
| 
      
 113 
     | 
    
         
            +
             * @overload init(flags)
         
     | 
| 
      
 114 
     | 
    
         
            +
             * 
         
     | 
| 
      
 115 
     | 
    
         
            +
             *   @param [Integer] flags initializing subsystems
         
     | 
| 
      
 116 
     | 
    
         
            +
             *   
         
     | 
| 
      
 117 
     | 
    
         
            +
             * @return [nil]
         
     | 
| 
      
 118 
     | 
    
         
            +
             */
         
     | 
| 
      
 119 
     | 
    
         
            +
            static VALUE SDL2_s_init(VALUE self, VALUE flags)
         
     | 
| 
      
 120 
     | 
    
         
            +
            {
         
     | 
| 
      
 121 
     | 
    
         
            +
                SDL_SetMainReady();
         
     | 
| 
      
 122 
     | 
    
         
            +
                HANDLE_ERROR(SDL_Init(NUM2UINT(flags)));
         
     | 
| 
      
 123 
     | 
    
         
            +
                state = INITIALIZDED;
         
     | 
| 
      
 124 
     | 
    
         
            +
                return Qnil;
         
     | 
| 
      
 125 
     | 
    
         
            +
            }
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
            int rubysdl2_is_active(void)
         
     | 
| 
      
 128 
     | 
    
         
            +
            {
         
     | 
| 
      
 129 
     | 
    
         
            +
                return state == INITIALIZDED;
         
     | 
| 
      
 130 
     | 
    
         
            +
            }
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
            static VALUE libsdl_version(void)
         
     | 
| 
      
 133 
     | 
    
         
            +
            {
         
     | 
| 
      
 134 
     | 
    
         
            +
                SDL_version version;
         
     | 
| 
      
 135 
     | 
    
         
            +
                SDL_GetVersion(&version);
         
     | 
| 
      
 136 
     | 
    
         
            +
                return SDL_version_to_String(&version);
         
     | 
| 
      
 137 
     | 
    
         
            +
            }
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
            static VALUE libsdl_version_number(void)
         
     | 
| 
      
 140 
     | 
    
         
            +
            {
         
     | 
| 
      
 141 
     | 
    
         
            +
                SDL_version version;
         
     | 
| 
      
 142 
     | 
    
         
            +
                SDL_GetVersion(&version);
         
     | 
| 
      
 143 
     | 
    
         
            +
                return SDL_version_to_Array(&version);
         
     | 
| 
      
 144 
     | 
    
         
            +
            }
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
            static VALUE libsdl_revision(void)
         
     | 
| 
      
 147 
     | 
    
         
            +
            {
         
     | 
| 
      
 148 
     | 
    
         
            +
                return rb_usascii_str_new_cstr(SDL_GetRevision());
         
     | 
| 
      
 149 
     | 
    
         
            +
            }
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
            static VALUE libsdl_revision_number(void)
         
     | 
| 
      
 152 
     | 
    
         
            +
            {
         
     | 
| 
      
 153 
     | 
    
         
            +
                return INT2NUM(SDL_GetRevisionNumber());
         
     | 
| 
      
 154 
     | 
    
         
            +
            }
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
            /*
         
     | 
| 
      
 157 
     | 
    
         
            +
             * Document-module: SDL2
         
     | 
| 
      
 158 
     | 
    
         
            +
             *
         
     | 
| 
      
 159 
     | 
    
         
            +
             * Namespace module for Ruby/SDL2.
         
     | 
| 
      
 160 
     | 
    
         
            +
             *
         
     | 
| 
      
 161 
     | 
    
         
            +
             */
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
            /*
         
     | 
| 
      
 164 
     | 
    
         
            +
             * Document-class: SDL2::Error
         
     | 
| 
      
 165 
     | 
    
         
            +
             *
         
     | 
| 
      
 166 
     | 
    
         
            +
             * An exception class for all Ruby/SDL2 specific errors.
         
     | 
| 
      
 167 
     | 
    
         
            +
             *
         
     | 
| 
      
 168 
     | 
    
         
            +
             * @attribute [r] error_code
         
     | 
| 
      
 169 
     | 
    
         
            +
             *   @return [Integer] error code sent from SDL library
         
     | 
| 
      
 170 
     | 
    
         
            +
             */
         
     | 
| 
      
 171 
     | 
    
         
            +
            void Init_sdl2_ext(void)
         
     | 
| 
      
 172 
     | 
    
         
            +
            {
         
     | 
| 
      
 173 
     | 
    
         
            +
                mSDL2 = rb_define_module("SDL2");
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
                rb_define_module_function(mSDL2, "init", SDL2_s_init, 1);
         
     | 
| 
      
 176 
     | 
    
         
            +
            #define DEFINE_SDL_INIT_CONST(type)                                     \
         
     | 
| 
      
 177 
     | 
    
         
            +
                rb_define_const(mSDL2, "INIT_" #type, UINT2NUM(SDL_INIT_##type))
         
     | 
| 
      
 178 
     | 
    
         
            +
              
         
     | 
| 
      
 179 
     | 
    
         
            +
                DEFINE_SDL_INIT_CONST(TIMER);
         
     | 
| 
      
 180 
     | 
    
         
            +
                DEFINE_SDL_INIT_CONST(AUDIO);
         
     | 
| 
      
 181 
     | 
    
         
            +
                DEFINE_SDL_INIT_CONST(VIDEO);
         
     | 
| 
      
 182 
     | 
    
         
            +
                DEFINE_SDL_INIT_CONST(JOYSTICK);
         
     | 
| 
      
 183 
     | 
    
         
            +
                DEFINE_SDL_INIT_CONST(HAPTIC);
         
     | 
| 
      
 184 
     | 
    
         
            +
                DEFINE_SDL_INIT_CONST(GAMECONTROLLER);
         
     | 
| 
      
 185 
     | 
    
         
            +
                DEFINE_SDL_INIT_CONST(EVENTS);
         
     | 
| 
      
 186 
     | 
    
         
            +
                DEFINE_SDL_INIT_CONST(EVERYTHING);
         
     | 
| 
      
 187 
     | 
    
         
            +
                DEFINE_SDL_INIT_CONST(NOPARACHUTE);
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
                /* SDL's version string  */
         
     | 
| 
      
 190 
     | 
    
         
            +
                rb_define_const(mSDL2, "LIBSDL_VERSION", libsdl_version());
         
     | 
| 
      
 191 
     | 
    
         
            +
                /* SDL's version array of numbers  */
         
     | 
| 
      
 192 
     | 
    
         
            +
                rb_define_const(mSDL2, "LIBSDL_VERSION_NUMBER", libsdl_version_number());
         
     | 
| 
      
 193 
     | 
    
         
            +
                /* SDL's revision (from VCS) string  */
         
     | 
| 
      
 194 
     | 
    
         
            +
                rb_define_const(mSDL2, "LIBSDL_REVISION", libsdl_revision());
         
     | 
| 
      
 195 
     | 
    
         
            +
                /* SDL's revision (from VCS) array of numbers  */
         
     | 
| 
      
 196 
     | 
    
         
            +
                rb_define_const(mSDL2, "LIBSDL_REVISION_NUMBER", libsdl_revision_number());
         
     | 
| 
      
 197 
     | 
    
         
            +
             
     | 
| 
      
 198 
     | 
    
         
            +
            #ifdef HAVE_SDL_IMAGE_H
         
     | 
| 
      
 199 
     | 
    
         
            +
                {
         
     | 
| 
      
 200 
     | 
    
         
            +
                    const SDL_version* version = IMG_Linked_Version();
         
     | 
| 
      
 201 
     | 
    
         
            +
                    /* SDL_image's version string, only available if SDL_image is linked */
         
     | 
| 
      
 202 
     | 
    
         
            +
                    rb_define_const(mSDL2, "LIBSDL_IMAGE_VERSION", SDL_version_to_String(version));
         
     | 
| 
      
 203 
     | 
    
         
            +
                    /* SDL_image's version array of numbers */
         
     | 
| 
      
 204 
     | 
    
         
            +
                    rb_define_const(mSDL2, "LIBSDL_IMAGE_VERSION_NUMBER", SDL_version_to_Array(version));
         
     | 
| 
      
 205 
     | 
    
         
            +
                }
         
     | 
| 
      
 206 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 207 
     | 
    
         
            +
            #ifdef HAVE_SDL_TTF_H
         
     | 
| 
      
 208 
     | 
    
         
            +
                {
         
     | 
| 
      
 209 
     | 
    
         
            +
                    const SDL_version* version = TTF_Linked_Version();
         
     | 
| 
      
 210 
     | 
    
         
            +
                    /* SDL_ttf's version string, only available if SDL_ttf is linked */
         
     | 
| 
      
 211 
     | 
    
         
            +
                    rb_define_const(mSDL2, "LIBSDL_TTF_VERSION", SDL_version_to_String(version));
         
     | 
| 
      
 212 
     | 
    
         
            +
                    /* SDL_ttf's version array of numbers */
         
     | 
| 
      
 213 
     | 
    
         
            +
                    rb_define_const(mSDL2, "LIBSDL_TTF_VERSION_NUMBER", SDL_version_to_Array(version));
         
     | 
| 
      
 214 
     | 
    
         
            +
                }
         
     | 
| 
      
 215 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 216 
     | 
    
         
            +
            #ifdef HAVE_SDL_MIXER_H
         
     | 
| 
      
 217 
     | 
    
         
            +
                {
         
     | 
| 
      
 218 
     | 
    
         
            +
                    const SDL_version* version = Mix_Linked_Version();
         
     | 
| 
      
 219 
     | 
    
         
            +
                    /* SDL_mixer's version string , only available if SDL_mixer is linked */
         
     | 
| 
      
 220 
     | 
    
         
            +
                    rb_define_const(mSDL2, "LIBSDL_MIXER_VERSION", SDL_version_to_String(version));
         
     | 
| 
      
 221 
     | 
    
         
            +
                    /* SDL_mixer's version array of numbers */
         
     | 
| 
      
 222 
     | 
    
         
            +
                    rb_define_const(mSDL2, "LIBSDL_MIXER_VERSION_NUMBER", SDL_version_to_Array(version));
         
     | 
| 
      
 223 
     | 
    
         
            +
                }
         
     | 
| 
      
 224 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 225 
     | 
    
         
            +
            #ifdef HAVE_SDL2_GFXPRIMITIVES_H
         
     | 
| 
      
 226 
     | 
    
         
            +
                rb_define_const(mSDL2, "LIBSDL2_GFX_VERSION", rb_sprintf("%d.%d.%d",
         
     | 
| 
      
 227 
     | 
    
         
            +
                    SDL2_GFXPRIMITIVES_MAJOR,
         
     | 
| 
      
 228 
     | 
    
         
            +
                    SDL2_GFXPRIMITIVES_MINOR,
         
     | 
| 
      
 229 
     | 
    
         
            +
                    SDL2_GFXPRIMITIVES_MICRO));
         
     | 
| 
      
 230 
     | 
    
         
            +
                rb_define_const(mSDL2, "LIBSDL2_GFX_VERSION_NUMBER", rb_ary_new3(3,
         
     | 
| 
      
 231 
     | 
    
         
            +
                    INT2FIX(SDL2_GFXPRIMITIVES_MAJOR),
         
     | 
| 
      
 232 
     | 
    
         
            +
                    INT2FIX(SDL2_GFXPRIMITIVES_MINOR),
         
     | 
| 
      
 233 
     | 
    
         
            +
                    INT2FIX(SDL2_GFXPRIMITIVES_MICRO)));
         
     | 
| 
      
 234 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
      
 236 
     | 
    
         
            +
                eSDL2Error = rb_define_class_under(mSDL2, "Error", rb_eStandardError);
         
     | 
| 
      
 237 
     | 
    
         
            +
                rb_define_attr(eSDL2Error, "error_code", 1, 0);
         
     | 
| 
      
 238 
     | 
    
         
            +
             
     | 
| 
      
 239 
     | 
    
         
            +
                rubysdl2_init_hints();
         
     | 
| 
      
 240 
     | 
    
         
            +
                rubysdl2_init_video();
         
     | 
| 
      
 241 
     | 
    
         
            +
                rubysdl2_init_gl();
         
     | 
| 
      
 242 
     | 
    
         
            +
                rubysdl2_init_messagebox();
         
     | 
| 
      
 243 
     | 
    
         
            +
                rubysdl2_init_event();
         
     | 
| 
      
 244 
     | 
    
         
            +
                rubysdl2_init_key();
         
     | 
| 
      
 245 
     | 
    
         
            +
                rubysdl2_init_mouse();
         
     | 
| 
      
 246 
     | 
    
         
            +
                rubysdl2_init_joystick();
         
     | 
| 
      
 247 
     | 
    
         
            +
                rubysdl2_init_gamecontorller();
         
     | 
| 
      
 248 
     | 
    
         
            +
                rubysdl2_init_timer();
         
     | 
| 
      
 249 
     | 
    
         
            +
                rubysdl2_init_image();
         
     | 
| 
      
 250 
     | 
    
         
            +
                rubysdl2_init_mixer();
         
     | 
| 
      
 251 
     | 
    
         
            +
                rubysdl2_init_ttf();
         
     | 
| 
      
 252 
     | 
    
         
            +
                rubysdl2_init_filesystem();
         
     | 
| 
      
 253 
     | 
    
         
            +
                rubysdl2_init_clipboard();
         
     | 
| 
      
 254 
     | 
    
         
            +
                rubysdl2_init_color();
         
     | 
| 
      
 255 
     | 
    
         
            +
                
         
     | 
| 
      
 256 
     | 
    
         
            +
                rb_set_end_proc(quit, 0);
         
     | 
| 
      
 257 
     | 
    
         
            +
                return;
         
     | 
| 
      
 258 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,233 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #include "rubysdl2_internal.h"
         
     | 
| 
      
 2 
     | 
    
         
            +
            #include <SDL_messagebox.h>
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            static VALUE sym_flags, sym_window, sym_title, sym_message, sym_buttons, sym_color_scheme,
         
     | 
| 
      
 5 
     | 
    
         
            +
                sym_id, sym_text, sym_bg, sym_button_border, sym_button_bg, sym_button_selected;
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            static VALUE mMessageBox;
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            static inline SDL_Window* Get_SDL_Window_or_NULL(VALUE win)
         
     | 
| 
      
 10 
     | 
    
         
            +
            {
         
     | 
| 
      
 11 
     | 
    
         
            +
                if (win == Qnil)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    return NULL;
         
     | 
| 
      
 13 
     | 
    
         
            +
                else
         
     | 
| 
      
 14 
     | 
    
         
            +
                    return Get_SDL_Window(win);
         
     | 
| 
      
 15 
     | 
    
         
            +
            }
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            /*
         
     | 
| 
      
 18 
     | 
    
         
            +
             * Document-module: SDL2::MessageBox
         
     | 
| 
      
 19 
     | 
    
         
            +
             *
         
     | 
| 
      
 20 
     | 
    
         
            +
             * This module provides functions to show a modal message box.
         
     | 
| 
      
 21 
     | 
    
         
            +
             */
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            /*
         
     | 
| 
      
 24 
     | 
    
         
            +
             * @overload show_simple_box(flag, title, message, parent)
         
     | 
| 
      
 25 
     | 
    
         
            +
             *   Create a simple modal message box.
         
     | 
| 
      
 26 
     | 
    
         
            +
             *
         
     | 
| 
      
 27 
     | 
    
         
            +
             *   This function pauses all ruby's threads and
         
     | 
| 
      
 28 
     | 
    
         
            +
             *   the threads are resumed when modal dialog is closed.
         
     | 
| 
      
 29 
     | 
    
         
            +
             *   
         
     | 
| 
      
 30 
     | 
    
         
            +
             *   You can create a message box before calling {SDL2.init}.
         
     | 
| 
      
 31 
     | 
    
         
            +
             *   
         
     | 
| 
      
 32 
     | 
    
         
            +
             *   You specify one of the following constants as flag
         
     | 
| 
      
 33 
     | 
    
         
            +
             *
         
     | 
| 
      
 34 
     | 
    
         
            +
             *   * {SDL2::MessageBox::ERROR}
         
     | 
| 
      
 35 
     | 
    
         
            +
             *   * {SDL2::MessageBox::WARNING}
         
     | 
| 
      
 36 
     | 
    
         
            +
             *   * {SDL2::MessageBox::INFORMATION}
         
     | 
| 
      
 37 
     | 
    
         
            +
             *
         
     | 
| 
      
 38 
     | 
    
         
            +
             *   @example show warning dialog
         
     | 
| 
      
 39 
     | 
    
         
            +
             *   
         
     | 
| 
      
 40 
     | 
    
         
            +
             *       SDL2.show_simple_message_box(SDL2::MessageBox::WARNING, "warning!",
         
     | 
| 
      
 41 
     | 
    
         
            +
             *                                    "Somewhat special warning message!!", nil)
         
     | 
| 
      
 42 
     | 
    
         
            +
             *                                
         
     | 
| 
      
 43 
     | 
    
         
            +
             *   @param [Integer] flag one of the above flags
         
     | 
| 
      
 44 
     | 
    
         
            +
             *   @param [String] title title text
         
     | 
| 
      
 45 
     | 
    
         
            +
             *   @param [String] message message text
         
     | 
| 
      
 46 
     | 
    
         
            +
             *   @param [SDL2::Window,nil] parent the parent window, or nil for no parent
         
     | 
| 
      
 47 
     | 
    
         
            +
             *   @return [nil]
         
     | 
| 
      
 48 
     | 
    
         
            +
             *   
         
     | 
| 
      
 49 
     | 
    
         
            +
             *   @see .show
         
     | 
| 
      
 50 
     | 
    
         
            +
             */
         
     | 
| 
      
 51 
     | 
    
         
            +
            static VALUE MessageBox_s_show_simple_box(VALUE self, VALUE flag, VALUE title,
         
     | 
| 
      
 52 
     | 
    
         
            +
                                                      VALUE message, VALUE parent)
         
     | 
| 
      
 53 
     | 
    
         
            +
            {
         
     | 
| 
      
 54 
     | 
    
         
            +
                title = rb_str_export_to_utf8(title);
         
     | 
| 
      
 55 
     | 
    
         
            +
                message = rb_str_export_to_utf8(message);
         
     | 
| 
      
 56 
     | 
    
         
            +
                HANDLE_ERROR(SDL_ShowSimpleMessageBox(NUM2UINT(flag),
         
     | 
| 
      
 57 
     | 
    
         
            +
                                                      StringValueCStr(title),
         
     | 
| 
      
 58 
     | 
    
         
            +
                                                      StringValueCStr(message),
         
     | 
| 
      
 59 
     | 
    
         
            +
                                                      Get_SDL_Window_or_NULL(parent)));
         
     | 
| 
      
 60 
     | 
    
         
            +
                return Qnil;
         
     | 
| 
      
 61 
     | 
    
         
            +
            }
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
            static void set_color_scheme(VALUE colors, VALUE sym, SDL_MessageBoxColor* color)
         
     | 
| 
      
 64 
     | 
    
         
            +
            {
         
     | 
| 
      
 65 
     | 
    
         
            +
                VALUE c = rb_hash_aref(colors, sym);
         
     | 
| 
      
 66 
     | 
    
         
            +
                Check_Type(c, T_ARRAY);
         
     | 
| 
      
 67 
     | 
    
         
            +
                color->r = NUM2UCHAR(rb_ary_entry(c, 0));
         
     | 
| 
      
 68 
     | 
    
         
            +
                color->g = NUM2UCHAR(rb_ary_entry(c, 1));
         
     | 
| 
      
 69 
     | 
    
         
            +
                color->b = NUM2UCHAR(rb_ary_entry(c, 2));
         
     | 
| 
      
 70 
     | 
    
         
            +
            }
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
            /*
         
     | 
| 
      
 73 
     | 
    
         
            +
             * @overload show(flag:, window: nil, title:, message:, buttons:, color_scheme: nil)
         
     | 
| 
      
 74 
     | 
    
         
            +
             *   Create a model message box.
         
     | 
| 
      
 75 
     | 
    
         
            +
             *
         
     | 
| 
      
 76 
     | 
    
         
            +
             *   You specify one of the following constants as flag
         
     | 
| 
      
 77 
     | 
    
         
            +
             *
         
     | 
| 
      
 78 
     | 
    
         
            +
             *   * {SDL2::MessageBox::ERROR}
         
     | 
| 
      
 79 
     | 
    
         
            +
             *   * {SDL2::MessageBox::WARNING}
         
     | 
| 
      
 80 
     | 
    
         
            +
             *   * {SDL2::MessageBox::INFORMATION}
         
     | 
| 
      
 81 
     | 
    
         
            +
             *
         
     | 
| 
      
 82 
     | 
    
         
            +
             *   One button in the dialog represents a hash with folloing elements.
         
     | 
| 
      
 83 
     | 
    
         
            +
             *   
         
     | 
| 
      
 84 
     | 
    
         
            +
             *       { flags: 0, SDL2::MessageBox::BUTTON_ESCAPEKEY_DEFAULT, or
         
     | 
| 
      
 85 
     | 
    
         
            +
             *                SDL2::MessageBox::BUTTON_RETURNKEY_DEFAULT,
         
     | 
| 
      
 86 
     | 
    
         
            +
             *                you can ignore it for 0,
         
     | 
| 
      
 87 
     | 
    
         
            +
             *         text: text of a button,
         
     | 
| 
      
 88 
     | 
    
         
            +
             *         id: index of the button
         
     | 
| 
      
 89 
     | 
    
         
            +
             *       }
         
     | 
| 
      
 90 
     | 
    
         
            +
             *
         
     | 
| 
      
 91 
     | 
    
         
            +
             *   and buttons is an array of above button hashes.
         
     | 
| 
      
 92 
     | 
    
         
            +
             *
         
     | 
| 
      
 93 
     | 
    
         
            +
             *   You can specify the color of message box by color_scheme.
         
     | 
| 
      
 94 
     | 
    
         
            +
             *   color_scheme is an hash whose keys are :bg, :text, :button_border, :button_bg,
         
     | 
| 
      
 95 
     | 
    
         
            +
             *   and :button_selected and values are array of three integers representing
         
     | 
| 
      
 96 
     | 
    
         
            +
             *   color.
         
     | 
| 
      
 97 
     | 
    
         
            +
             *   You can also use default color scheme by giving nil.
         
     | 
| 
      
 98 
     | 
    
         
            +
             *   
         
     | 
| 
      
 99 
     | 
    
         
            +
             *   
         
     | 
| 
      
 100 
     | 
    
         
            +
             *   This function pauses all ruby's threads until
         
     | 
| 
      
 101 
     | 
    
         
            +
             *   the modal dialog is closed.
         
     | 
| 
      
 102 
     | 
    
         
            +
             *   
         
     | 
| 
      
 103 
     | 
    
         
            +
             *   You can create a message box before calling {SDL2.init}.
         
     | 
| 
      
 104 
     | 
    
         
            +
             *
         
     | 
| 
      
 105 
     | 
    
         
            +
             *   @example show a dialog with 3 buttons
         
     | 
| 
      
 106 
     | 
    
         
            +
             *       button = SDL2::MessageBox.show(flags: SDL2::MessageBox::WARNING,
         
     | 
| 
      
 107 
     | 
    
         
            +
             *                                      window: nil,
         
     | 
| 
      
 108 
     | 
    
         
            +
             *                                      title: "Warning window",
         
     | 
| 
      
 109 
     | 
    
         
            +
             *                                      message: "Here is the warning message",
         
     | 
| 
      
 110 
     | 
    
         
            +
             *                                      buttons: [ { # flags is ignored
         
     | 
| 
      
 111 
     | 
    
         
            +
             *                                                  id: 0, 
         
     | 
| 
      
 112 
     | 
    
         
            +
             *                                                  text: "No",
         
     | 
| 
      
 113 
     | 
    
         
            +
             *                                                 }, 
         
     | 
| 
      
 114 
     | 
    
         
            +
             *                                                 {flags: SDL2::MessageBox::BUTTON_RETURNKEY_DEFAULT,
         
     | 
| 
      
 115 
     | 
    
         
            +
             *                                                  id: 1,
         
     | 
| 
      
 116 
     | 
    
         
            +
             *                                                  text: "Yes",
         
     | 
| 
      
 117 
     | 
    
         
            +
             *                                                 },
         
     | 
| 
      
 118 
     | 
    
         
            +
             *                                                 {flags: SDL2::MessageBox::BUTTON_ESCAPEKEY_DEFAULT,
         
     | 
| 
      
 119 
     | 
    
         
            +
             *                                                  id: 2,
         
     | 
| 
      
 120 
     | 
    
         
            +
             *                                                  text: "Cancel",
         
     | 
| 
      
 121 
     | 
    
         
            +
             *                                                 },
         
     | 
| 
      
 122 
     | 
    
         
            +
             *                                               ],
         
     | 
| 
      
 123 
     | 
    
         
            +
             *                                      color_scheme: {
         
     | 
| 
      
 124 
     | 
    
         
            +
             *                                                     bg: [255, 0, 0],
         
     | 
| 
      
 125 
     | 
    
         
            +
             *                                                     text: [0, 255, 0],
         
     | 
| 
      
 126 
     | 
    
         
            +
             *                                                     button_border: [255, 0, 0],
         
     | 
| 
      
 127 
     | 
    
         
            +
             *                                                     button_bg: [0, 0, 255],
         
     | 
| 
      
 128 
     | 
    
         
            +
             *                                                     button_selected: [255, 0, 0]
         
     | 
| 
      
 129 
     | 
    
         
            +
             *                                                    }
         
     | 
| 
      
 130 
     | 
    
         
            +
             *                                     )
         
     | 
| 
      
 131 
     | 
    
         
            +
             *                                 
         
     | 
| 
      
 132 
     | 
    
         
            +
             *   @param [Integer] flags message box type flag
         
     | 
| 
      
 133 
     | 
    
         
            +
             *   @param [SDL2::Window,nil] window the parent window, or nil for no parent
         
     | 
| 
      
 134 
     | 
    
         
            +
             *   @param [String] title the title text
         
     | 
| 
      
 135 
     | 
    
         
            +
             *   @param [String] message the message text
         
     | 
| 
      
 136 
     | 
    
         
            +
             *   @param [Array<Hash<Symbol => Object>>] buttons array of buttons
         
     | 
| 
      
 137 
     | 
    
         
            +
             *   @param [Hash<Symbol=>[Integer,Integer,Integer]> nil] color_scheme
         
     | 
| 
      
 138 
     | 
    
         
            +
             *       color scheme, or nil for the default color scheme
         
     | 
| 
      
 139 
     | 
    
         
            +
             *   @return [Integer] pressed button id
         
     | 
| 
      
 140 
     | 
    
         
            +
             *   
         
     | 
| 
      
 141 
     | 
    
         
            +
             *   @see .show_simple_box
         
     | 
| 
      
 142 
     | 
    
         
            +
             */
         
     | 
| 
      
 143 
     | 
    
         
            +
            static VALUE MessageBox_s_show(VALUE self, VALUE params)
         
     | 
| 
      
 144 
     | 
    
         
            +
            {
         
     | 
| 
      
 145 
     | 
    
         
            +
                SDL_MessageBoxData mb_data;
         
     | 
| 
      
 146 
     | 
    
         
            +
                VALUE title, message, texts, buttons, color_scheme;
         
     | 
| 
      
 147 
     | 
    
         
            +
                long num_buttons;
         
     | 
| 
      
 148 
     | 
    
         
            +
                int i;
         
     | 
| 
      
 149 
     | 
    
         
            +
                SDL_MessageBoxButtonData* button_data;
         
     | 
| 
      
 150 
     | 
    
         
            +
                SDL_MessageBoxColorScheme scheme;
         
     | 
| 
      
 151 
     | 
    
         
            +
                int buttonid;
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
                Check_Type(params, T_HASH);
         
     | 
| 
      
 154 
     | 
    
         
            +
                mb_data.flags = NUM2INT(rb_hash_aref(params, sym_flags));
         
     | 
| 
      
 155 
     | 
    
         
            +
                mb_data.window = Get_SDL_Window_or_NULL(rb_hash_aref(params, sym_window));
         
     | 
| 
      
 156 
     | 
    
         
            +
                title = rb_str_export_to_utf8(rb_hash_aref(params, sym_title));
         
     | 
| 
      
 157 
     | 
    
         
            +
                mb_data.title = StringValueCStr(title);
         
     | 
| 
      
 158 
     | 
    
         
            +
                message = rb_str_export_to_utf8(rb_hash_aref(params, sym_message));
         
     | 
| 
      
 159 
     | 
    
         
            +
                mb_data.message = StringValueCStr(message);
         
     | 
| 
      
 160 
     | 
    
         
            +
                
         
     | 
| 
      
 161 
     | 
    
         
            +
                buttons = rb_hash_aref(params, sym_buttons);
         
     | 
| 
      
 162 
     | 
    
         
            +
                Check_Type(buttons, T_ARRAY);
         
     | 
| 
      
 163 
     | 
    
         
            +
                mb_data.numbuttons = num_buttons = RARRAY_LEN(buttons);
         
     | 
| 
      
 164 
     | 
    
         
            +
                button_data = ALLOCA_N(SDL_MessageBoxButtonData, num_buttons);
         
     | 
| 
      
 165 
     | 
    
         
            +
                mb_data.buttons = button_data;
         
     | 
| 
      
 166 
     | 
    
         
            +
                texts = rb_ary_new2(num_buttons);
         
     | 
| 
      
 167 
     | 
    
         
            +
                
         
     | 
| 
      
 168 
     | 
    
         
            +
                for (i=0; i<num_buttons; ++i) {
         
     | 
| 
      
 169 
     | 
    
         
            +
                    VALUE button = rb_ary_entry(buttons, i);
         
     | 
| 
      
 170 
     | 
    
         
            +
                    VALUE flags = rb_hash_aref(button, sym_flags);
         
     | 
| 
      
 171 
     | 
    
         
            +
                    VALUE text;
         
     | 
| 
      
 172 
     | 
    
         
            +
                    if (flags == Qnil)
         
     | 
| 
      
 173 
     | 
    
         
            +
                        button_data[i].flags = 0;
         
     | 
| 
      
 174 
     | 
    
         
            +
                    else
         
     | 
| 
      
 175 
     | 
    
         
            +
                        button_data[i].flags = NUM2INT(flags);
         
     | 
| 
      
 176 
     | 
    
         
            +
                    text = rb_str_export_to_utf8(rb_hash_aref(button, sym_text));
         
     | 
| 
      
 177 
     | 
    
         
            +
                    rb_ary_push(texts, text);
         
     | 
| 
      
 178 
     | 
    
         
            +
                    button_data[i].buttonid = NUM2INT(rb_hash_aref(button, sym_id));
         
     | 
| 
      
 179 
     | 
    
         
            +
                    button_data[i].text = StringValueCStr(text);
         
     | 
| 
      
 180 
     | 
    
         
            +
                }
         
     | 
| 
      
 181 
     | 
    
         
            +
             
     | 
| 
      
 182 
     | 
    
         
            +
                color_scheme = rb_hash_aref(params, sym_color_scheme);
         
     | 
| 
      
 183 
     | 
    
         
            +
                if (color_scheme == Qnil) {
         
     | 
| 
      
 184 
     | 
    
         
            +
                    mb_data.colorScheme = NULL;
         
     | 
| 
      
 185 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 186 
     | 
    
         
            +
                    Check_Type(color_scheme, T_HASH);
         
     | 
| 
      
 187 
     | 
    
         
            +
                    mb_data.colorScheme = &scheme;
         
     | 
| 
      
 188 
     | 
    
         
            +
                    set_color_scheme(color_scheme, sym_bg, &scheme.colors[0]);
         
     | 
| 
      
 189 
     | 
    
         
            +
                    set_color_scheme(color_scheme, sym_text, &scheme.colors[1]);
         
     | 
| 
      
 190 
     | 
    
         
            +
                    set_color_scheme(color_scheme, sym_button_border, &scheme.colors[2]);
         
     | 
| 
      
 191 
     | 
    
         
            +
                    set_color_scheme(color_scheme, sym_button_bg, &scheme.colors[3]);
         
     | 
| 
      
 192 
     | 
    
         
            +
                    set_color_scheme(color_scheme, sym_button_selected, &scheme.colors[4]);
         
     | 
| 
      
 193 
     | 
    
         
            +
                }
         
     | 
| 
      
 194 
     | 
    
         
            +
                
         
     | 
| 
      
 195 
     | 
    
         
            +
                HANDLE_ERROR(SDL_ShowMessageBox(&mb_data, &buttonid));
         
     | 
| 
      
 196 
     | 
    
         
            +
                
         
     | 
| 
      
 197 
     | 
    
         
            +
                RB_GC_GUARD(title); RB_GC_GUARD(message); RB_GC_GUARD(texts);
         
     | 
| 
      
 198 
     | 
    
         
            +
                return INT2NUM(buttonid);
         
     | 
| 
      
 199 
     | 
    
         
            +
            }
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
            void rubysdl2_init_messagebox(void)
         
     | 
| 
      
 202 
     | 
    
         
            +
            {
         
     | 
| 
      
 203 
     | 
    
         
            +
                mMessageBox = rb_define_module_under(mSDL2, "MessageBox");
         
     | 
| 
      
 204 
     | 
    
         
            +
                
         
     | 
| 
      
 205 
     | 
    
         
            +
                rb_define_singleton_method(mMessageBox, "show_simple_box",
         
     | 
| 
      
 206 
     | 
    
         
            +
                                           MessageBox_s_show_simple_box, 4);
         
     | 
| 
      
 207 
     | 
    
         
            +
                rb_define_singleton_method(mMessageBox, "show", MessageBox_s_show, 1);
         
     | 
| 
      
 208 
     | 
    
         
            +
                /* This flag means that the message box shows an error message */
         
     | 
| 
      
 209 
     | 
    
         
            +
                rb_define_const(mMessageBox, "ERROR", INT2NUM(SDL_MESSAGEBOX_ERROR));
         
     | 
| 
      
 210 
     | 
    
         
            +
                /* This flag means that the message box shows a warning message */
         
     | 
| 
      
 211 
     | 
    
         
            +
                rb_define_const(mMessageBox, "WARNING", INT2NUM(SDL_MESSAGEBOX_WARNING));
         
     | 
| 
      
 212 
     | 
    
         
            +
                /* This flag means that the message box shows an informational message */
         
     | 
| 
      
 213 
     | 
    
         
            +
                rb_define_const(mMessageBox, "INFORMATION", INT2NUM(SDL_MESSAGEBOX_INFORMATION));
         
     | 
| 
      
 214 
     | 
    
         
            +
                /* This flag represents the button is selected when return key is pressed */
         
     | 
| 
      
 215 
     | 
    
         
            +
                rb_define_const(mMessageBox, "BUTTON_RETURNKEY_DEFAULT",
         
     | 
| 
      
 216 
     | 
    
         
            +
                                INT2NUM(SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT));
         
     | 
| 
      
 217 
     | 
    
         
            +
                /* This flag represents the button is selected when escape key is pressed */
         
     | 
| 
      
 218 
     | 
    
         
            +
                rb_define_const(mMessageBox, "BUTTON_ESCAPEKEY_DEFAULT",
         
     | 
| 
      
 219 
     | 
    
         
            +
                                INT2NUM(SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT));
         
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
                sym_flags = ID2SYM(rb_intern("flags"));
         
     | 
| 
      
 222 
     | 
    
         
            +
                sym_window =  ID2SYM(rb_intern("window"));
         
     | 
| 
      
 223 
     | 
    
         
            +
                sym_message = ID2SYM(rb_intern("message"));
         
     | 
| 
      
 224 
     | 
    
         
            +
                sym_title = ID2SYM(rb_intern("title"));
         
     | 
| 
      
 225 
     | 
    
         
            +
                sym_buttons = ID2SYM(rb_intern("buttons"));
         
     | 
| 
      
 226 
     | 
    
         
            +
                sym_color_scheme = ID2SYM(rb_intern("color_scheme"));
         
     | 
| 
      
 227 
     | 
    
         
            +
                sym_id = ID2SYM(rb_intern("id"));
         
     | 
| 
      
 228 
     | 
    
         
            +
                sym_text = ID2SYM(rb_intern("text"));
         
     | 
| 
      
 229 
     | 
    
         
            +
                sym_bg = ID2SYM(rb_intern("bg"));
         
     | 
| 
      
 230 
     | 
    
         
            +
                sym_button_border = ID2SYM(rb_intern("button_border"));
         
     | 
| 
      
 231 
     | 
    
         
            +
                sym_button_bg = ID2SYM(rb_intern("button_bg"));
         
     | 
| 
      
 232 
     | 
    
         
            +
                sym_button_selected = ID2SYM(rb_intern("button_selected"));
         
     | 
| 
      
 233 
     | 
    
         
            +
            }
         
     |