sdl_messagebox.odin 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package sdl2
  2. import "core:c"
  3. when ODIN_OS == .Windows {
  4. foreign import lib "SDL2.lib"
  5. } else {
  6. foreign import lib "system:SDL2"
  7. }
  8. MessageBoxFlag :: enum u32 {
  9. _ = 0,
  10. ERROR = 4, /**< error dialog */
  11. WARNING = 5, /**< warning dialog */
  12. INFORMATION = 6, /**< informational dialog */
  13. BUTTONS_LEFT_TO_RIGHT = 7, /**< buttons placed left to right */
  14. BUTTONS_RIGHT_TO_LEFT = 8, /**< buttons placed right to left */
  15. }
  16. MessageBoxFlags :: distinct bit_set[MessageBoxFlag; u32]
  17. MESSAGEBOX_ERROR :: MessageBoxFlags{.ERROR}
  18. MESSAGEBOX_WARNING :: MessageBoxFlags{.WARNING}
  19. MESSAGEBOX_INFORMATION :: MessageBoxFlags{.INFORMATION}
  20. MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT :: MessageBoxFlags{.BUTTONS_LEFT_TO_RIGHT}
  21. MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT :: MessageBoxFlags{.BUTTONS_RIGHT_TO_LEFT}
  22. MessageBoxButtonFlag :: enum u32 {
  23. RETURNKEY_DEFAULT = 0, /**< Marks the default button when return is hit */
  24. ESCAPEKEY_DEFAULT = 1, /**< Marks the default button when escape is hit */
  25. }
  26. MessageBoxButtonFlags :: distinct bit_set[MessageBoxButtonFlag; u32]
  27. MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT :: MessageBoxButtonFlags{.RETURNKEY_DEFAULT}
  28. MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT :: MessageBoxButtonFlags{.ESCAPEKEY_DEFAULT}
  29. MessageBoxButtonData :: struct {
  30. flags: MessageBoxButtonFlags, /**< ::SDL_MessageBoxButtonFlags */
  31. buttonid: c.int, /**< User defined button id (value returned via SDL_ShowMessageBox) */
  32. text: cstring, /**< The UTF-8 button text */
  33. }
  34. MessageBoxColor :: struct {
  35. r, g, b: u8,
  36. }
  37. MessageBoxColorType :: enum c.int {
  38. BACKGROUND,
  39. TEXT,
  40. BUTTON_BORDER,
  41. BUTTON_BACKGROUND,
  42. BUTTON_SELECTED,
  43. }
  44. MessageBoxColorScheme :: struct {
  45. colors: [MessageBoxColorType]MessageBoxColor,
  46. }
  47. MessageBoxData :: struct {
  48. flags: MessageBoxFlags, /**< ::SDL_MessageBoxFlags */
  49. window: ^Window, /**< Parent window, can be NULL */
  50. title: cstring, /**< UTF-8 title */
  51. message: cstring, /**< UTF-8 message text */
  52. numbuttons: c.int,
  53. buttons: ^MessageBoxButtonData,
  54. colorScheme: ^MessageBoxColorScheme, /**< ::SDL_MessageBoxColorScheme, can be NULL to use system settings */
  55. }
  56. @(default_calling_convention="c", link_prefix="SDL_")
  57. foreign lib {
  58. ShowMessageBox :: proc(messageboxdata: ^MessageBoxData, buttonid: ^c.int) -> c.int ---
  59. ShowSimpleMessageBox :: proc(flags: MessageBoxFlags, title: cstring, message: cstring, window: ^Window) -> c.int ---
  60. }