OldSchool Library
Message Boxes

Functions and definitions related to message boxes in OSLib. More...

Macros

#define oslDebug(format...)
 Displays a debug message, with the same format as printf.
 
#define oslMake3Buttons(b1, a1, b2, a2, b3, a3)
 Creates a 32-bit integer to be used for the 'flags' parameter when calling oslMessageBox.
 
#define oslWarning(format...)
 Displays a warning message with the same format as oslDebug.
 
#define oslFatalError(format...)
 Displays a fatal error message. This function will terminate execution after displaying the message.
 
#define oslAssert(cond)
 Displays a fatal error message if the condition is not satisfied.
 

Enumerations

enum  OSL_MB_ACTIONS {
  OSL_MB_OK = 1 , OSL_MB_CANCEL , OSL_MB_YES , OSL_MB_NO ,
  OSL_MB_QUIT
}
 Message box button actions. More...
 

Functions

unsigned int oslMessageBox (const char *text, const char *title, unsigned int flags)
 Displays a message box.
 

Detailed Description

Functions and definitions related to message boxes in OSLib.

Macro Definition Documentation

◆ oslDebug

#define oslDebug ( format...)
Value:
({ char __str2[1000], __str[1000]; sprintf(__str2, "Debug (%s:%i,%s)",__FUNCTION__,__LINE__,__FILE__); sprintf(__str , ##format); oslMessageBox(__str, __str2, oslMake3Buttons(OSL_KEY_CROSS,OSL_MB_OK,OSL_KEY_TRIANGLE,OSL_MB_QUIT,0,0)); })
@ OSL_KEY_CROSS
Cross key.
Definition keys.h:86
@ OSL_KEY_TRIANGLE
Triangle key.
Definition keys.h:84
unsigned int oslMessageBox(const char *text, const char *title, unsigned int flags)
Displays a message box.
#define oslMake3Buttons(b1, a1, b2, a2, b3, a3)
Creates a 32-bit integer to be used for the 'flags' parameter when calling oslMessageBox.
Definition messagebox.h:63
@ OSL_MB_QUIT
Definition messagebox.h:35
@ OSL_MB_OK
Definition messagebox.h:31

Displays a debug message, with the same format as printf.

The title displays the file, the line number, and the function from where it has been called.

Example usage:

int var = 2;
oslDebug("var = %i", var);
#define oslDebug(format...)
Displays a debug message, with the same format as printf.
Definition messagebox.h:50

◆ oslMake3Buttons

#define oslMake3Buttons ( b1,
a1,
b2,
a2,
b3,
a3 )
Value:
((b1)|((a1)<<5)|((b2)<<9)|((a2)<<14)|((b3)<<18)|((a3)<<23))

Creates a 32-bit integer to be used for the 'flags' parameter when calling oslMessageBox.

There are 6 arguments, 2 per button. The first of each pair represents the button assigned (one of the OSL_KEY_BITS values) and the second one represents the action (one of OSL_MB_ACTIONS values).

Example usage:

@ OSL_KEY_CIRCLE
Circle key.
Definition keys.h:85
@ OSL_MB_CANCEL
Definition messagebox.h:32

◆ oslFatalError

#define oslFatalError ( format...)
Value:
({ char __str[1000]; sprintf(__str , ##format); oslMessageBox(__str, "Fatal error", oslMake3Buttons(OSL_KEY_CROSS,OSL_MB_QUIT,0,0,0,0)); })

Displays a fatal error message. This function will terminate execution after displaying the message.

The only available choice is 'Quit', ensuring that this function is a dead end and no one will ever return from it.

◆ oslAssert

#define oslAssert ( cond)
Value:
({ if (!(cond)) { char __str[1000]; sprintf(__str , "This program encountered a fatal error and must be terminated.\n\nFile : %s:%i\nError: %s",__FILE__,__LINE__,""#cond); oslMessageBox(__str, "Fatal error", oslMake3Buttons(OSL_KEY_CROSS,OSL_MB_QUIT,0,0,0,0)); } })

Displays a fatal error message if the condition is not satisfied.

This macro allows you to assert that a condition is true. If it is not, a fatal error message is displayed, and the program is terminated.

Example usage:

oslAssert(img != NULL);
OSL_IMAGE * oslLoadImageFilePNG(char *filename, int location, int pixelFormat)
Loads an image from a PNG file.
@ OSL_IN_RAM
In RAM.
Definition drawing.h:976
@ OSL_SWIZZLED
Directly swizzle image (only works for oslLoadImage[...] functions!)
Definition drawing.h:978
@ OSL_PF_5551
15 bits, 5 bits per component, 1 alpha bit
Definition drawing.h:1010
#define oslAssert(cond)
Displays a fatal error message if the condition is not satisfied.
Definition messagebox.h:94
Structure representing an image loaded in memory.
Definition drawing.h:927

Enumeration Type Documentation

◆ OSL_MB_ACTIONS

Message box button actions.

These enumerations represent the different actions that can be associated with buttons in a message box.

Enumerator
OSL_MB_OK 

Ok button

OSL_MB_CANCEL 

Cancel button

OSL_MB_YES 

Yes button

OSL_MB_NO 

No button

OSL_MB_QUIT 

Quit button (exits immediately with an oslQuit call!)

Function Documentation

◆ oslMessageBox()

unsigned int oslMessageBox ( const char * text,
const char * title,
unsigned int flags )
extern

Displays a message box.

Parameters
textThe text displayed inside of the message box.
titleThe title of the message box.
flagsFlags representing the buttons and their actions, created using oslMake3Buttons.
Returns
Returns a 32-bit unsigned integer representing the message box result.

Example usage:

oslMessageBox("This is a message", "Message Title", oslMake3Buttons(OSL_KEY_CROSS, OSL_MB_OK, OSL_KEY_CIRCLE, OSL_MB_CANCEL, 0, 0));