2
0

sdl_messagebox.odin 2.5 KB

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