/* Copyright (c) 2022 Alex Diener This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Alex Diener alex@ludobloom.com */ #ifndef __UIModalConfirmationDialog_H__ #define __UIModalConfirmationDialog_H__ #ifdef __cplusplus extern "C" { #endif typedef struct UIModalConfirmationDialog UIModalConfirmationDialog; #define UIModalConfirmationDialog_superclass UIModalDialog #include "uitoolkit/UIButton.h" #include "uitoolkit/UIKeyShortcut.h" #include "uitoolkit/UIModalDialog.h" #include typedef void (* UIModalConfirmationDialog_callback)(UIModalConfirmationDialog * dialog, unsigned int buttonIndex, void * context1, void * context2); struct UIModalConfirmationDialog_button { UIButton * button; UIKeyShortcut * keyShortcut; }; #define UIModalConfirmationDialog_ivars \ UIModalDialog_ivars \ \ UIModalConfirmationDialog_callback callback; \ void * callbackContext1; \ void * callbackContext2; \ unsigned int buttonCount; \ struct UIModalConfirmationDialog_button * buttons; \ UIAppearance messageLabelAppearance; \ UIAppearance defaultButtonAppearance; #define UIModalConfirmationDialog_vtable(self_type) \ UIModalDialog_vtable(self_type) stemobject_declare(UIModalConfirmationDialog) // Additional arguments: Additional button labels and key shortcuts, from right to left after button 1 UIModalConfirmationDialog * UIModalConfirmationDialog_create(String title, String displayedMessage, UIModalConfirmationDialog_callback callback, void * callbackContext1, void * callbackContext2, UIWindowRoot * windowRoot, UIAppearance appearance, String button1Label, UIKeyShortcut * button1KeyShortcut, ...) __attribute__((sentinel)); UIModalConfirmationDialog * UIModalConfirmationDialog_vcreate(String title, String displayedMessage, UIModalConfirmationDialog_callback callback, void * callbackContext1, void * callbackContext2, UIWindowRoot * windowRoot, UIAppearance appearance, String button1Label, UIKeyShortcut * button1KeyShortcut, va_list args); bool UIModalConfirmationDialog_init(UIModalConfirmationDialog * self, String title, String displayedMessage, UIModalConfirmationDialog_callback callback, void * callbackContext1, void * callbackContext2, UIWindowRoot * windowRoot, UIAppearance appearance, String button1Label, UIKeyShortcut * button1KeyShortcut, ...) __attribute__((sentinel)); bool UIModalConfirmationDialog_vinit(UIModalConfirmationDialog * self, String title, String displayedMessage, UIModalConfirmationDialog_callback callback, void * callbackContext1, void * callbackContext2, UIWindowRoot * windowRoot, UIAppearance appearance, String button1Label, UIKeyShortcut * button1KeyShortcut, va_list args); void UIModalConfirmationDialog_dispose(UIModalConfirmationDialog * self); bool UIModalConfirmationDialog_dialogKeyDown(UIModalConfirmationDialog * self, unsigned int charCode, unsigned int keyCode, unsigned int modifiers, bool isRepeat, double referenceTime); #ifdef __cplusplus } #endif #endif