sdl_messagebox.odin 2.6 KB

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