sdl3bind/castholm/v0.1.3-SDL-3.2.0/api/messagebox.zig

65 lines
2.3 KiB
Zig

const std = @import("std");
pub const c = @import("c.zig").c;
pub const Window = opaque {};
pub const MessageBoxFlags = packed struct(u32) {
messageboxError: bool = false, // error dialog
messageboxWarning: bool = false, // warning dialog
messageboxInformation: bool = false, // informational dialog
messageboxButtonsLeftToRight: bool = false, // buttons placed left to right
messageboxButtonsRightToLeft: bool = false, // buttons placed right to left
pad0: u26 = 0,
rsvd: bool = false,
};
pub const MessageBoxButtonFlags = packed struct(u32) {
messageboxButtonReturnkeyDefault: bool = false, // Marks the default button when return is hit
messageboxButtonEscapekeyDefault: bool = false, // Marks the default button when escape is hit
pad0: u29 = 0,
rsvd: bool = false,
};
pub const MessageBoxButtonData = extern struct {
flags: MessageBoxButtonFlags,
buttonID: c_int, // User defined button id (value returned via SDL_ShowMessageBox)
text: [*c]const u8, // The UTF-8 button text
};
pub const MessageBoxColor = extern struct {
r: u8,
g: u8,
b: u8,
};
pub const MessageBoxColorType = enum(c_int) {
messageboxColorBackground,
messageboxColorText,
messageboxColorButtonBorder,
messageboxColorButtonBackground,
messageboxColorButtonSelected,
messageboxColorCount, //Size of the colors array of SDL_MessageBoxColorScheme.
};
pub const MessageBoxColorScheme = extern struct {
colors: [c.SDL_MESSAGEBOX_COLOR_COUNT]MessageBoxColor,
};
pub const MessageBoxData = extern struct {
flags: MessageBoxFlags,
window: ?*Window, // Parent window, can be NULL
title: [*c]const u8, // UTF-8 title
message: [*c]const u8, // UTF-8 message text
numbuttons: c_int,
buttons: *const MessageBoxButtonData,
colorScheme: *const MessageBoxColorScheme, // SDL_MessageBoxColorScheme, can be NULL to use system settings
};
pub inline fn showMessageBox(messageboxdata: *const MessageBoxData, buttonid: *c_int) bool {
return @bitCast(c.SDL_ShowMessageBox(@ptrCast(messageboxdata), @ptrCast(buttonid)));
}
pub inline fn showSimpleMessageBox(flags: MessageBoxFlags, title: [*c]const u8, message: [*c]const u8, window: ?*Window) bool {
return @bitCast(c.SDL_ShowSimpleMessageBox(@bitCast(flags), title, message, window));
}