Wuhoo  0.1
Windows using header only
Classes | Macros | Typedefs | Enumerations | Functions
wuhoo.h File Reference

Go to the source code of this file.

Classes

struct  WuhooEventKey
 Struct representing a keyboard press. More...
 
struct  WuhooRGBA
 Helper struct to work with RGBA system backed buffers. The alpha channel is currently not respected in any backend. More...
 
struct  WuhooEventMouseMove
 
struct  WuhooEventMousePress
 
struct  WuhooEventMouseWheel
 
struct  WuhooEventWindow
 
struct  WuhooEventDrop
 
union  WuhooEventData
 
struct  WuhooEvent
 The event union that holds event-specific data. More...
 
struct  WuhooWindow
 

Macros

#define WuhooNull   ((void*)0)
 
#define WuhooSuccess   WuhooNull
 
#define WuhooDefaultPosition   (-2147483647 - 1) /* INT_MIN */
 
#define WuhooTrue   (1)
 
#define WuhooInternal   static
 
#define WuhooYes   WuhooTrue
 
#define WuhooFalse   (0)
 
#define WuhooNo   WuhooFalse
 
#define WuhooUnused(x)   (void)(x)
 
#define WuhooOnlySet(value, flag)   (((flag) & (value)) == (flag))
 
#define WuhooFlag(shift_count)   (1 << shift_count)
 
#define WUHOO_STRING   "Wuhoo"
 
#define WUHOO_MAX_FILE_NAME_LENGTH   256
 
#define WUHOO_MAX_TITLE_LENGTH   256
 
#define WUHOO_MAX_CHARACTER_SIZE   6
 

Typedefs

typedef void * WuhooHandle
 
typedef void * WuhooResult
 
typedef unsigned char WuhooBoolean
 
typedef unsigned char WuhooByte
 
typedef unsigned short WuhooR5G6B5
 
typedef unsigned short WuhooR5G5B5
 
typedef unsigned int WuhooSize
 
typedef unsigned int WuhooFlags
 
typedef unsigned int WuhooGLAttr
 
typedef enum WuhooKeyModifiersEnum WuhooMouseModifiersEnum
 
typedef int WuhooMouseModifiers
 
typedef int WuhooKeyModifiers
 
typedef int WuhooWindowFlags
 
typedef unsigned int WuhooUTF32
 
typedef unsigned short WuhooUTF16
 
typedef unsigned char WuhooUTF8
 
typedef WuhooResult(* WuhooConvertRGBA) (void *dst, WuhooRGBA const *const src, WuhooSize x, WuhooSize y, WuhooSize width, WuhooSize height, WuhooSize src_width, WuhooSize src_height)
 

Enumerations

enum  WuhooFlagsEnum {
  WUHOO_FLAG_TITLED = WuhooFlag(0), WUHOO_FLAG_CANVAS = WuhooFlag(2), WUHOO_FLAG_RESIZEABLE = WuhooFlag(4), WUHOO_FLAG_BORDERLESS = WuhooFlag(5),
  WUHOO_FLAG_MOUSE_CAPTURE = WuhooFlag(6), WUHOO_FLAG_FILE_DROP = WuhooFlag(7), WUHOO_FLAG_CLOSEABLE = WuhooFlag(8), WUHOO_FLAG_CLIENT_REGION = WuhooFlag(9),
  WUHOO_FLAG_WINDOW_REGION = WuhooFlag(10)
}
 
enum  WuhooKeyModifiersEnum {
  WUHOO_KMOD_NONE = 0, WUHOO_KMOD_LSHIFT = WuhooFlag(0), WUHOO_KMOD_RSHIFT = WuhooFlag(1), WUHOO_KMOD_LCTRL = WuhooFlag(2),
  WUHOO_KMOD_RCTRL = WuhooFlag(3), WUHOO_KMOD_LALT = WuhooFlag(4), WUHOO_KMOD_RALT = WuhooFlag(5), WUHOO_KMOD_LGUI = WuhooFlag(6),
  WUHOO_KMOD_RGUI = WuhooFlag(7), WUHOO_KMOD_NUM = WuhooFlag(8), WUHOO_KMOD_CAPS = WuhooFlag(9), WUHOO_KMOD_MODE = WuhooFlag(10),
  WUHOO_KMOD_DEADCHAR = WuhooFlag(11), WUHOO_KMOD_CTRL = (WUHOO_KMOD_LCTRL | WUHOO_KMOD_RCTRL), WUHOO_KMOD_SHIFT = (WUHOO_KMOD_LSHIFT | WUHOO_KMOD_RSHIFT), WUHOO_KMOD_ALT = (WUHOO_KMOD_LALT | WUHOO_KMOD_RALT),
  WUHOO_KMOD_GUI = (WUHOO_KMOD_LGUI | WUHOO_KMOD_RGUI), WUHOO_KMOD_MAX
}
 
enum  WuhooKeyCode {
  WUHOO_VKEY_UNKNOWN, WUHOO_VKEY_BACKSPACE = 8, WUHOO_VKEY_FORWARD_DELETE = WUHOO_VKEY_BACKSPACE, WUHOO_VKEY_TAB = 9,
  WUHOO_VKEY_ENTER = 13, WUHOO_VKEY_KPAD_ENTER, WUHOO_VKEY_ESCAPE = 27, WUHOO_VKEY_SPACE = ' ',
  WUHOO_VKEY_QUOTE = '\'', WUHOO_VKEY_COMMA = ',', WUHOO_VKEY_MINUS = '-', WUHOO_VKEY_PERIOD = '.',
  WUHOO_VKEY_FORWARD_SLASH = '/', WUHOO_VKEY_0 = '0', WUHOO_VKEY_1, WUHOO_VKEY_2,
  WUHOO_VKEY_3, WUHOO_VKEY_4, WUHOO_VKEY_5, WUHOO_VKEY_6,
  WUHOO_VKEY_7, WUHOO_VKEY_8, WUHOO_VKEY_9 = '9', WUHOO_VKEY_SEMICOLON = ';',
  WUHOO_VKEY_EQUALS = '=', WUHOO_VKEY_A = 'A', WUHOO_VKEY_B, WUHOO_VKEY_C,
  WUHOO_VKEY_D, WUHOO_VKEY_E, WUHOO_VKEY_F, WUHOO_VKEY_G,
  WUHOO_VKEY_H, WUHOO_VKEY_I, WUHOO_VKEY_J, WUHOO_VKEY_K,
  WUHOO_VKEY_L, WUHOO_VKEY_M, WUHOO_VKEY_N, WUHOO_VKEY_O,
  WUHOO_VKEY_P, WUHOO_VKEY_Q, WUHOO_VKEY_R, WUHOO_VKEY_S,
  WUHOO_VKEY_T, WUHOO_VKEY_U, WUHOO_VKEY_V, WUHOO_VKEY_W,
  WUHOO_VKEY_X, WUHOO_VKEY_Y, WUHOO_VKEY_Z = 'Z', WUHOO_VKEY_LEFT_BRACKET = '[',
  WUHOO_VKEY_BACK_SLASH = '\\', WUHOO_VKEY_RIGHT_BRACKET = ']', WUHOO_VKEY_GRAVE = '`', WUHOO_VKEY_TILDA = WUHOO_VKEY_GRAVE,
  WUHOO_VKEY_DELETE = 127, WUHOO_VKEY_F1, WUHOO_VKEY_F2, WUHOO_VKEY_F3,
  WUHOO_VKEY_F4, WUHOO_VKEY_F5, WUHOO_VKEY_F6, WUHOO_VKEY_F7,
  WUHOO_VKEY_F8, WUHOO_VKEY_F9, WUHOO_VKEY_F10, WUHOO_VKEY_F11,
  WUHOO_VKEY_F12, WUHOO_VKEY_F13, WUHOO_VKEY_PRINTSCREEN = WUHOO_VKEY_F13, WUHOO_VKEY_F14,
  WUHOO_VKEY_F15, WUHOO_VKEY_INSERT, WUHOO_VKEY_HELP = WUHOO_VKEY_INSERT, WUHOO_VKEY_HOME,
  WUHOO_VKEY_PAGE_UP, WUHOO_VKEY_END, WUHOO_VKEY_PAGE_DOWN, WUHOO_VKEY_MENU,
  WUHOO_VKEY_KPAD_0, WUHOO_VKEY_KPAD_1, WUHOO_VKEY_KPAD_2, WUHOO_VKEY_KPAD_3,
  WUHOO_VKEY_KPAD_4, WUHOO_VKEY_KPAD_5, WUHOO_VKEY_KPAD_6, WUHOO_VKEY_KPAD_7,
  WUHOO_VKEY_KPAD_8, WUHOO_VKEY_KPAD_9, WUHOO_VKEY_KPAD_DIVIDE, WUHOO_VKEY_KPAD_SLASH = WUHOO_VKEY_KPAD_DIVIDE,
  WUHOO_VKEY_KPAD_PLUS, WUHOO_VKEY_KPAD_MINUS, WUHOO_VKEY_KPAD_EQUALS, WUHOO_VKEY_KPAD_MULITPLY,
  WUHOO_VKEY_KPAD_DECIMAL, WUHOO_VKEY_KPAD_NUM_LOCK, WUHOO_VKEY_KPAD_COMMA = WUHOO_VKEY_KPAD_DECIMAL, WUHOO_VKEY_SHIFT,
  WUHOO_VKEY_CONTROL, WUHOO_VKEY_ALT, WUHOO_VKEY_CAPS_LOCK, WUHOO_VKEY_UP,
  WUHOO_VKEY_DOWN, WUHOO_VKEY_RIGHT, WUHOO_VKEY_LEFT, WUHOO_VKEY_MAX
}
 
enum  WuhooWindowFlagsEnum {
  WUHOO_WINDOW_FLAG_RESIZED = WuhooFlag(0), WUHOO_WINDOW_FLAG_FULL_SCREEN = WuhooFlag(1), WUHOO_WINDOW_FLAG_FOCUS_GAINED = WuhooFlag(2), WUHOO_WINDOW_FLAG_FOCUS_LOST = WuhooFlag(3),
  WUHOO_WINDOW_FLAG_MINIMIZED = WuhooFlag(4), WUHOO_WINDOW_FLAG_MAXIMIZED = WuhooFlag(5), WUHOO_WINDOW_FLAG_MOVED = WuhooFlag(6), WUHOO_WINDOW_FLAG_CLOSED = WuhooFlag(7),
  WUHOO_WINDOW_FLAG_REGION_UPDATED = WuhooFlag(8), WUHOO_WINDOW_FLAG_DROP_STARTED = WuhooFlag(9)
}
 
enum  WuhooWindowState {
  WUHOO_WSTATE_UNKNOWN, WUHOO_WSTATE_RESIZED, WUHOO_WSTATE_FULL_SCREENED, WUHOO_WSTATE_MOVED,
  WUHOO_WSTATE_MINIMIZED, WUHOO_WSTATE_MAXIMIZED, WUHOO_WSTATE_CREATED, WUHOO_WSTATE_CLOSED,
  WUHOO_WSTATE_UNFOCUSED, WUHOO_WSTATE_FOCUSED, WUHOO_WSTATE_HIDDEN, WUHOO_WSTATE_INVALIDATED,
  WUHOO_WSTATE_MAX
}
 
enum  WuhooEventType {
  WUHOO_EVT_NONE, WUHOO_EVT_WINDOW, WUHOO_EVT_KEY, WUHOO_EVT_MOUSE_PRESS,
  WUHOO_EVT_MOUSE_MOVE, WUHOO_EVT_MOUSE_WHEEL, WUHOO_EVT_DROP, WUHOO_EVT_MAX
}
 
enum  WuhooKeyState { WUHOO_KSTATE_UNKNOWN, WUHOO_KSTATE_UP, WUHOO_KSTATE_DOWN, WUHOO_KSTATE_MAX }
 
enum  WuhooMouseState {
  WUHOO_MSTATE_UNKNOWN, WUHOO_MSTATE_LPRESSED, WUHOO_MSTATE_LRELEASED, WUHOO_MSTATE_RPRESSED,
  WUHOO_MSTATE_RRELEASED, WUHOO_MSTATE_MPRESSED, WUHOO_MSTATE_MRELEASED, WUHOO_MSTATE_MAX
}
 

Functions

WuhooResult WuhooWindowInit (WuhooWindow *window)
 
WuhooResult WuhooWindowDestroy (WuhooWindow *window)
 
WuhooResult WuhooWindowCreate (WuhooWindow *window, int posx, int posy, WuhooSize width, WuhooSize height, const char *title, WuhooFlags flags, const void *data)
 
WuhooResult WuhooWindowEventNext (WuhooWindow *window, WuhooEvent *event)
 
WuhooResult WuhooWindowDropContentsGet (WuhooWindow *window, WuhooEvent *event, char *buffer, WuhooSize buffer_size)
 
WuhooResult WuhooWindowRegionSet (WuhooWindow *window, int posx, int posy, WuhooSize width, WuhooSize height)
 
WuhooResult WuhooWindowRegionGet (WuhooWindow *window, int *posx, int *posy, WuhooSize *width, WuhooSize *height)
 
WuhooResult WuhooWindowClientRegionGet (WuhooWindow *window, int *posx, int *posy, WuhooSize *width, WuhooSize *height)
 
WuhooResult WuhooWindowClientRegionSet (WuhooWindow *window, int posx, int posy, WuhooSize width, WuhooSize height)
 
WuhooResult WuhooWindowBlit (WuhooWindow *window, WuhooRGBA *pixels, WuhooSize src_x, WuhooSize src_y, WuhooSize src_width, WuhooSize src_height, WuhooSize dst_x, WuhooSize dst_y, WuhooSize dst_width, WuhooSize dst_height)
 
WuhooResult WuhooWindowShow (WuhooWindow *window)
 
WuhooResult WuhooWindowSetTitle (WuhooWindow *window, const char *title)
 
const char * WuhooResultString (WuhooResult result)
 

Detailed Description

wuhoo single header library.

Macro Definition Documentation

◆ WUHOO_STRING

#define WUHOO_STRING   "Wuhoo"

Wuhoo String Representation

◆ WuhooSuccess

#define WuhooSuccess   WuhooNull

Returned if everything has gone well

Enumeration Type Documentation

◆ WuhooEventType

Wuhoo Event types.

Enumerator
WUHOO_EVT_WINDOW 

WuhooEventWindow.

WUHOO_EVT_KEY 

WuhooEventKey.

WUHOO_EVT_MOUSE_PRESS 

WuhooEventMousePress.

WUHOO_EVT_MOUSE_MOVE 

WuhooEventMouseMove.

WUHOO_EVT_MOUSE_WHEEL 

WuhooEventMouseWheel.

WUHOO_EVT_DROP 

WuhooEventDrop.

◆ WuhooMouseState

Mouse button state of the triggered WuhooEventMouseMove, WuhooEventMousePress or WuhooEventMouseWheel.

◆ WuhooWindowState

State of the window that triggered the WuhooEventWindow.

Function Documentation

◆ WuhooResultString()

const char* WuhooResultString ( WuhooResult  result)

A descriptive string of the WuhooResult.

Parameters
resultA WuhooResult returned from any of Wuhoo's APIs.
Returns
const char *

◆ WuhooWindowBlit()

WuhooResult WuhooWindowBlit ( WuhooWindow window,
WuhooRGBA pixels,
WuhooSize  src_x,
WuhooSize  src_y,
WuhooSize  src_width,
WuhooSize  src_height,
WuhooSize  dst_x,
WuhooSize  dst_y,
WuhooSize  dst_width,
WuhooSize  dst_height 
)

Blit pixels to the framebuffer using the window system's native calls. In case of a graphics-enabled window (e.g. OpenGL) this call simply blits the contents of the API buffer to the screen by calling the appropriate API calss (e.g. SwapBuffer, flush e.t.c.).

The current implementation does not properly handle regional drawing.

Parameters
windowThe WuhooWindow struct handle.
pixelsRGBA unsigned char pixel buffer.
src_xRead from source starting at x (Not Implemented Yet).
src_yRead from source starting at y (Not Implemented Yet).
src_widthwidth of the source region.
src_heightheight of the source region.
dst_xWrite to destination starting at x.
dst_yWrite to destination starting at y.
dst_widthwidth of the destination region.
dst_heightheight of the destination region.
Returns
WuhooResult
See also
WuhooWindow, WuhooResult

◆ WuhooWindowClientRegionGet()

WuhooResult WuhooWindowClientRegionGet ( WuhooWindow window,
int *  posx,
int *  posy,
WuhooSize *  width,
WuhooSize *  height 
)

Get a window's position and client region size.

Parameters
windowThe WuhooWindow struct handle.
posxThe horizontal postion of the window.
posyThe vertical postion of the window.
widthThe width of the client region of the window.
heightThe height of the client region of the window.
Returns
WuhooResult
See also
WuhooWindow

◆ WuhooWindowClientRegionSet()

WuhooResult WuhooWindowClientRegionSet ( WuhooWindow window,
int  posx,
int  posy,
WuhooSize  width,
WuhooSize  height 
)

Set a window's position and client region size.

Parameters
windowThe WuhooWindow struct handle.
posxThe new horizontal postion of the window.
posyThe new vertical postion of the window.
widthThe new width of the client region of the window.
heightThe new height of the client region of the window.
Returns
WuhooResult
See also
WuhooWindow

◆ WuhooWindowCreate()

WuhooResult WuhooWindowCreate ( WuhooWindow window,
int  posx,
int  posy,
WuhooSize  width,
WuhooSize  height,
const char *  title,
WuhooFlags  flags,
const void *  data 
)

Allocate all the resources required for a WuhooWindow struct and prepare for a native Window to show.

Parameters
windowThe WuhooWindow struct handle.
posxHorizontal window offset of the upper left corner.
posyVertical window offset of the upper left corner.
widthwidth of the window.
heightheight of the window.
titleTitle of the created window.
flagsFlags to customize the created window.
dataAdditional data (Currently unused).
Returns
WuhooResult
See also
WuhooWindow, WuhooResult

◆ WuhooWindowDestroy()

WuhooResult WuhooWindowDestroy ( WuhooWindow window)

Properly release resources aquired for a WuhooWindow struct during use of the Wuhoo API.

Parameters
WuhooWindowthe window struct to destroy.
Returns
WuhooResult
See also
WuhooWindow, WuhooResult

◆ WuhooWindowDropContentsGet()

WuhooResult WuhooWindowDropContentsGet ( WuhooWindow window,
WuhooEvent event,
char *  buffer,
WuhooSize  buffer_size 
)

Allocate all the resources required for a WuhooWindow struct and prepare for a native Window to show.

Parameters
windowThe WuhooWindow struct handle.
eventThe WuhooEvent struct that triggered this event in the first place.
bufferThe buffer that receives the UTF-8 encoded list of the dropeed files.
buffer_sizeThe size of the provided buffer (If you can't much the requested size of the event, you will get a truncated list).
Returns
WuhooResult
See also
WuhooWindow, WuhooEvent

◆ WuhooWindowEventNext()

WuhooResult WuhooWindowEventNext ( WuhooWindow window,
WuhooEvent event 
)

Allocate all the resources required for a WuhooWindow struct and prepare for a native Window to show.

Parameters
windowThe WuhooWindow struct handle.
eventThe WuhooEvent struct to receive the new event information.
Returns
WuhooResult
See also
WuhooWindow, WuhooEvent

◆ WuhooWindowInit()

WuhooResult WuhooWindowInit ( WuhooWindow window)

Properly initialize a WuhooWindow struct for use by the Wuhoo API.

Parameters
WuhooWindowthe window struct to initialize.
Returns
WuhooResult
See also
WuhooWindow, WuhooResult

◆ WuhooWindowRegionGet()

WuhooResult WuhooWindowRegionGet ( WuhooWindow window,
int *  posx,
int *  posy,
WuhooSize *  width,
WuhooSize *  height 
)

Get a window's position and client region size.

Parameters
windowThe WuhooWindow struct handle.
posxThe horizontal postion of the window.
posyThe vertical postion of the window.
widthThe width of the of the window.
heightThe height of the of the window (including title bar).
Returns
WuhooResult
See also
WuhooWindow

◆ WuhooWindowRegionSet()

WuhooResult WuhooWindowRegionSet ( WuhooWindow window,
int  posx,
int  posy,
WuhooSize  width,
WuhooSize  height 
)

Set a window's position and size.

Parameters
windowThe WuhooWindow struct handle.
posxThe new horizontal postion of the window.
posyThe new vertical postion of the window.
widthThe new width of the window.
heightThe new height of the window.
Returns
WuhooResult
See also
WuhooWindow

◆ WuhooWindowSetTitle()

WuhooResult WuhooWindowSetTitle ( WuhooWindow window,
const char *  title 
)

Set the title of the window. The title parameter beeds to be encoded in UTF-8.

Parameters
windowThe WuhooWindow struct handle.
titleThe new title in UTF-8 encoding.
Returns
WuhooResult
See also
WuhooWindow

◆ WuhooWindowShow()

WuhooResult WuhooWindowShow ( WuhooWindow window)

Present the previously inited and created WuhooWindow The window should be visible on the screen after this call