[Add] Allert windows as a way to warn the user of something.
This commit is contained in:
parent
d1d08da22c
commit
94623aa081
@ -112,6 +112,8 @@ static void toolkit_drawOutline(double x, double y, double w,
|
|||||||
double h, double b, glColour* c, glColour* lc);
|
double h, double b, glColour* c, glColour* lc);
|
||||||
static void toolkit_drawRect(double x, double y, double w, double h,
|
static void toolkit_drawRect(double x, double y, double w, double h,
|
||||||
glColour* c, glColour* lc);
|
glColour* c, glColour* lc);
|
||||||
|
// Misc.
|
||||||
|
static void toolkit_alertClose(char* str);
|
||||||
|
|
||||||
// Add a button that when pressed will trigger call, passing it's name as the
|
// Add a button that when pressed will trigger call, passing it's name as the
|
||||||
// only parameter.
|
// only parameter.
|
||||||
@ -1060,6 +1062,36 @@ static Widget* toolkit_getFocus(void) {
|
|||||||
return &wdw->widgets[wdw->focus];
|
return &wdw->widgets[wdw->focus];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void toolkit_alert(const char* fmt, ...) {
|
||||||
|
char msg[256];
|
||||||
|
va_list ap;
|
||||||
|
unsigned int wdw;
|
||||||
|
|
||||||
|
if(window_exists("Warning")) return;
|
||||||
|
|
||||||
|
if(fmt == NULL) return;
|
||||||
|
else {
|
||||||
|
// Get the message.
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vsprintf(msg, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
wdw = window_create("Warning", -1, -1, 300, 140);
|
||||||
|
|
||||||
|
window_addText(wdw, 20, -30, 260, 70, 0, "txtAlert",
|
||||||
|
&gl_smallFont, &cBlack, msg);
|
||||||
|
|
||||||
|
window_addButton(wdw, 135, 20, 50, 30, "btnOK", "OK",
|
||||||
|
toolkit_alertClose);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void toolkit_alertClose(char* str) {
|
||||||
|
(void)str;
|
||||||
|
if(window_exists("Warning"))
|
||||||
|
window_destroy(window_get("Warning"));
|
||||||
|
}
|
||||||
|
|
||||||
// Init.
|
// Init.
|
||||||
int toolkit_init(void) {
|
int toolkit_init(void) {
|
||||||
windows = malloc(sizeof(Window)*MIN_WINDOWS);
|
windows = malloc(sizeof(Window)*MIN_WINDOWS);
|
||||||
|
@ -30,6 +30,9 @@ void window_addRect(const unsigned int wid,
|
|||||||
const int w, const int h, // size.
|
const int w, const int h, // size.
|
||||||
char* name, glColour* colour, int border); // Properties.
|
char* name, glColour* colour, int border); // Properties.
|
||||||
|
|
||||||
|
// Popups and alerts.
|
||||||
|
void toolkit_alert(const char* fmt, ...);
|
||||||
|
|
||||||
// Modification
|
// Modification
|
||||||
void window_modifyText(const unsigned int wid, char* name, char* newstring);
|
void window_modifyText(const unsigned int wid, char* name, char* newstring);
|
||||||
void window_modifyImage(const unsigned int wid, char* name, glTexture* image);
|
void window_modifyImage(const unsigned int wid, char* name, glTexture* image);
|
||||||
|
Loading…
Reference in New Issue
Block a user