# Milsko GUI Toolkit Documentation

## Table of Contents

Mw/Constants.h
  MwDIRECTION
  MwORIENTATION
Mw/Core.h
  MwDispatch
  MwDispatch2
  MwCreateWidget
  MwVaCreateWidget
  MwVaListCreateWidget
  MwDestroyWidget
  MwLoop
  MwStep
  MwPending
  MwSetInteger
  MwSetText
  MwSetVoid
  MwGetInteger
  MwGetText
  MwGetVoid
  MwSetDefault
  MwVaApply
  MwVaListApply
  MwAddUserHandler
  MwDispatchUserHandler
  MwSetErrorHandler
  MwDispatchError
  MwGetBeforeStep
  MwForceRender
Mw/Cursor.h
  MwCursorDefault
  MwCursorDefaultMask
  MwCursorCross
  MwCursorCrossMask
Mw/Default.h
  MwDefaultBackground
  MwDefaultForeground
  MwDefaultBorderWidth
Mw/Draw.h
  MwParseColor
  MwLightenColor
  MwDrawRect
  MwDrawFrame
  MwDrawTriangle
  MwDrawFrameEx
  MwDrawText
  MwLoadImage
  MwTextWidth
  MwTextHeight
Mw/Error.h
  MwErrorEnum_T
  MwEsuccess
  MwEerror
  MwGetLastError
Mw/Font.h
  MwFontData[]
  MwBoldFontData[]
Mw/LowLevel.h
Mw/MachDep.h
Mw/Milsko.h
Mw/StringDefs.h
Mw/TypeDefs.h
Mw/Widget/Button.h
  MwButtonClass
Mw/Widget/Frame.h
  MwFrameClass
Mw/Widget/Image.h
  MwImageClass
Mw/Widget/Menu.h
  MwMenuClass
  MwMenuAdd
Mw/Widget/OpenGL.h
  MwOpenGLClass
  MwOpenGLMakeCurrent
  MwOpenGLGetProcAddress
  MwOpenGLSwapBuffer
Mw/Widget/ScrollBar.h
  MwScrollBarClass
  MwScrollBarGetVisibleLength
Mw/Widget/SubMenu.h
  MwSubMenuClass
Mw/Widget/Vulkan.h
  MwVulkanClass
  MwVulkanEnableExtension
  MwVulkanEnableLayer
  MwVulkanConfig_T
  api_version
  vk_version
  validation_layers
  MwVulkanConfigure
  MwVulkanField_T
  MwVulkanField_GetInstanceProcAddr
  MwVulkanField_Instance
  MwVulkanField_Surface
  MwVulkanField_PhysicalDevice
  MwVulkanField_LogicalDevice
  MwVulkanField_GraphicsQueueIndex
  MwVulkanField_PresentQueueIndex
  MwVulkanField_PresentQueue
  MwVulkanGetField
  MwVulkanSupported
Mw/Widget/Window.h
  MwWindowClass

## Mw/Constants.h

Constants.

    enum MwDIRECTION;

  Direction enumeration.

    enum MwORIENTATION;

  Orientation.

## Mw/Core.h

Core.

    #define MwDispatch(x, y)

  Dispatches the handler of widget class.

| Used internally.

Parameter `x`
  Widget.
Parameter `y`
  Handler name.

    #define MwDispatch2(x, y)

  Dispatches the handler of widget class.

| Used internally.

Parameter `x`
  Widget.
Parameter `y`
  Handler name.
Returns
  `0` for success, otherwise failed.

    MWDECL MwWidget MwCreateWidget (
    	MwClass widget_class,
    	const char* name,
    	MwWidget parent,
    	int x,
    	int y,
    	unsigned int width,
    	unsigned int height
    );

  Creates a widget.
Parameter `widget_class`
  Widget class.
Parameter `name`
  Widget name.
Parameter `parent`
  Parent widget or `NULL`.
Parameter `x`
  X.
Parameter `y`
  Y.
Parameter `width`
  Width.
Parameter `height`
  Height.
Returns
  Widget.

    MWDECL MwWidget MwVaCreateWidget (
    	MwClass widget_class,
    	const char* name,
    	MwWidget parent,
    	int x,
    	int y,
    	unsigned int width,
    	unsigned int height,
    	...
    );

  Creates a widget.
Parameter `widget_class`
  Widget class.
Parameter `name`
  Widget name.
Parameter `parent`
  Parent widget or `NULL`.
Parameter `x`
  X.
Parameter `y`
  Y.
Parameter `width`
  Width.
Parameter `height`
  Height.
Parameter `...`
  Same with MwVaApply.
Returns
  Widget.

    MWDECL MwWidget MwVaListCreateWidget (
    	MwClass widget_class,
    	const char* name,
    	MwWidget parent,
    	int x,
    	int y,
    	unsigned int width,
    	unsigned int height,
    	va_list va
    );

  Creates a widget.
Parameter `widget_class`
  Widget class.
Parameter `name`
  Widget name.
Parameter `parent`
  Parent widget or `NULL`.
Parameter `x`
  X.
Parameter `y`
  Y.
Parameter `width`
  Width.
Parameter `height`
  Height.
Parameter `va`
  Same with MwVaListApply.
Returns
  Widget.

    MWDECL void MwDestroyWidget (
    	MwWidget handle
    );

  Destroys the widget and its child widgets.
Parameter `handle`
  Widget.

    MWDECL void MwLoop (
    	MwWidget handle
    );

  Runs the main loop.
Parameter `handle`
  Widget.

    MWDECL void MwStep (
    	MwWidget handle
    );

  Runs the single step.
Parameter `handle`
  Widget.

    MWDECL int MwPending (
    	MwWidget handle
    );

  Check if any event is pending.
Parameter `handle`
  Widget.
Returns
  `1` if any event is pending.

    MWDECL void MwSetInteger (
    	MwWidget handle,
    	const char* key,
    	int n
    );

  Sets an integer property.
Parameter `handle`
  Widget.
Parameter `key`
  Key.
Parameter `n`
  Value.

    MWDECL void MwSetText (
    	MwWidget handle,
    	const char* key,
    	const char* value
    );

  Sets a text property.
Parameter `handle`
  Widget.
Parameter `key`
  Key.
Parameter `value`
  Value.

    MWDECL void MwSetVoid (
    	MwWidget handle,
    	const char* key,
    	void* value
    );

  Sets a void pointer property.
Parameter `handle`
  Widget.
Parameter `key`
  Key.
Parameter `value`
  Value.

    MWDECL int MwGetInteger (
    	MwWidget handle,
    	const char* key
    );

  Gets the integer property.
Parameter `handle`
  Widget.
Parameter `key`
  Key.
Returns
  Value.

    MWDECL const char* MwGetText (
    	MwWidget handle,
    	const char* key
    );

  Gets the text property.
Parameter `handle`
  Widget.
Parameter `key`
  Key.
Returns
  Value.

    MWDECL void* MwGetVoid (
    	MwWidget handle,
    	const char* key
    );

  Gets the void pointer property.
Parameter `handle`
  Widget.
Parameter `key`
  Key.
Returns
  Value.

    MWDECL void MwSetDefault (
    	MwWidget handle
    );

  Sets the default property.

| This is called when widget is created.

Parameter `handle`
  Widget.

    MWDECL void MwVaApply (
    	MwWidget handle,
    	...
    );

  Sets the properties.
Parameter `handle`
  Widget.
Parameter `...`
  Properties.

    MWDECL void MwVaListApply (
    	MwWidget handle,
    	va_list va
    );

  Sets properties.
Parameter `handle`
  Widget.
Parameter `va`
  Properties.

    MWDECL void MwAddUserHandler (
    	MwWidget handle,
    	const char* key,
    	MwUserHandler handler,
    	void* user_data
    );

  Sets a user handler.
Parameter `handle`
  Widget.
Parameter `key`
  Key.
Parameter `handler`
  Handler.
Parameter `user_data`
  User data passed to handler.

    MWDECL void MwDispatchUserHandler (
    	MwWidget handle,
    	const char* key,
    	void* handler_data
    );

  Dispatches the user handler.
Parameter `handle`
  Widget.
Parameter `key`
  Key.
Parameter `handler_data`
  Handler data passed to handler.

    MWDECL void MwSetErrorHandler (
    	MwErrorHandler handler,
    	void* user_data
    );

  Sets an error handler.
Parameter `handle`
  Widget.
Parameter `handler`
  Handler.
Parameter `user_data`
  User data passed to handler.

    MWDECL void MwDispatchError (
    	int code,
    	const char* message
    );

  Dispatches the error handler.
Parameter `code`
  Error code.
Parameter `message`
  Error message.

    MWDECL void MwGetBeforeStep (
    	MwWidget handle,
    	jmp_buf* jmpbuf
    );

  Gets the before_step of widget.
Parameter `handle`
  Widget.
Parameter `jmpbuf`
  jmp_buf.

    MWDECL void MwForceRender (
    	MwWidget handle
    );

  Forcefully makes widget render.
Parameter `handle`
  Widget.

## Mw/Cursor.h

Cursor externs.

    MWDECL MwCursor MwCursorDefault;

  Default cursor.

    MWDECL MwCursor MwCursorDefaultMask;

  Default cursor mask.

    MWDECL MwCursor MwCursorCross;

  Cross cursor.

    MWDECL MwCursor MwCursorCrossMask;

  Cross cursor mask.

## Mw/Default.h

Default properties.

    MWDECL const char* MwDefaultBackground;

  Default background color.

    MWDECL const char* MwDefaultForeground;

  Default foreground color.

    MWDECL const int MwDefaultBorderWidth;

  Default border width.

## Mw/Draw.h

Common drawing API.

    MWDECL MwLLColor MwParseColor (
    	MwWidget handle,
    	const char* text
    );

  Parses a color text.
Parameter `handle`
  Widget.
Parameter `text`
  Color text.
Returns
  Color.

    MWDECL MwLLColor MwLightenColor (
    	MwWidget handle,
    	MwLLColor color,
    	int r,
    	int g,
    	int b
    );

  Lighten a color.
Parameter `handle`
  Widget.
Parameter `color`
  Color.
Parameter `r`
  Red.
Parameter `g`
  Green.
Parameter `b`
  Blue.
Returns
  Color.

    MWDECL void MwDrawRect (
    	MwWidget handle,
    	MwRect* rect,
    	MwLLColor color
    );

  Draws a filled rectangle.
Parameter `handle`
  Widget.
Parameter `rect`
  Rectangle area.
Parameter `color`
  Color.

    MWDECL void MwDrawFrame (
    	MwWidget handle,
    	MwRect* rect,
    	MwLLColor color,
    	int invert
    );

  Draws a frame.

| `rect` gets changed to the area of rectangle inside.

Parameter `handle`
  Widget.
Parameter `rect`
  Rectangle area.
Parameter `color`
  Color.
Parameter `invert`
  Invert the 3D border color or not.

    MWDECL void MwDrawTriangle (
    	MwWidget handle,
    	MwRect* rect,
    	MwLLColor color,
    	int invert,
    	int direction
    );

  Draws a triangle.
Parameter `handle`
  Widget.
Parameter `rect`
  Rectangle area.
Parameter `color`
  Color.
Parameter `invert`
  Invert the 3D border color or not.

    MWDECL void MwDrawFrameEx (
    	MwWidget handle,
    	MwRect* rect,
    	MwLLColor color,
    	int invert,
    	int border
    );

  Draws a frame with specified border width.

| `rect` gets changed to the area of rectangle inside.

Parameter `handle`
  Widget.
Parameter `rect`
  Rectangle area.
Parameter `color`
  Color.
Parameter `invert`
  Invert the 3D border color or not.
Parameter `border`
  Border width.

    MWDECL void MwDrawText (
    	MwWidget handle,
    	MwPoint* point,
    	const char* text,
    	int bold,
    	MwLLColor color
    );

  Draws a text.
Parameter `handle`
  Widget.
Parameter `point`
  Center point of the text.
Parameter `text`
  Text.
Parameter `bold`
  Bold.
Parameter `color`
  Color.

    MWDECL MwLLPixmap MwLoadImage (
    	MwWidget handle,
    	const char* path
    );

  Creates a pixmap from image.
Parameter `handle`
  Widget.
Parameter `path`
  Path.
Returns
  Pixmap.

    MWDECL int MwTextWidth (
    	MwWidget handle,
    	const char* text
    );

  Calculates a text width.
Parameter `handle`
  Widget.
Parameter `text`
  Text.
Returns
  Text width.

    MWDECL int MwTextHeight (
    	MwWidget handle,
    	const char* text
    );

  Calculates a text height.
Parameter `handle`
  Widget.
Parameter `text`
  Text.
Returns
  Text height.

## Mw/Error.h

Error codes.

    typedef enum MwErrorEnum_T;

  Error code enumeration.

     MwEsuccess = 0

  No error.

     MwEerror

  There was an error.

    MWDECL const char* MwGetLastError (
    	void
    );

  Get the last error.

## Mw/Font.h

Default font.

    MWDECL MwFont MwFontData[];

  Default font data.

    MWDECL MwFont MwBoldFontData[];

  Default bold font data.

## Mw/LowLevel.h

Low-level drawing API.

| This is used internally.

## Mw/MachDep.h

Machine dependent headers and macros.

## Mw/Milsko.h

Includes all headers.

## Mw/StringDefs.h

String definitions for property.

## Mw/TypeDefs.h

Type definitions.

## Mw/Widget/Button.h

Button widget.

    MWDECL MwClass MwButtonClass;

  Button widget class.

## Mw/Widget/Frame.h

Frame widget.

    MWDECL MwClass MwFrameClass;

  Frame widget class.

## Mw/Widget/Image.h

Image widget.

    MWDECL MwClass MwImageClass;

  Image widget class.

## Mw/Widget/Menu.h

Menu widget.

    MWDECL MwClass MwMenuClass;

  Menu widget class.

    MWDECL MwMenu MwMenuAdd (
    	MwWidget handle,
    	MwMenu menu,
    	const char* name
    );

  Adds a menu.
Parameter `handle`
  Widget.
Parameter `menu`
  Menu.
Parameter `name`
  Menu name.
Returns
  Menu.

## Mw/Widget/OpenGL.h

OpenGL widget.

    MWDECL MwClass MwOpenGLClass;

  OpenGL widget class.

    MWDECL void MwOpenGLMakeCurrent (
    	MwWidget handle
    );

  Make a widget current OpenGL context.
Parameter `handle`
  Widget.

    MWDECL void* MwOpenGLGetProcAddress (
    	MwWidget handle,
    	const char* name
    );

  Get a procedure from OpenGL.
Parameter `handle`
  Widget.
Parameter `name`
  Name.
Returns
  Procedure.

    MWDECL void MwOpenGLSwapBuffer (
    	MwWidget handle
    );

  Swaps the buffer of OpenGL context.
Parameter `handle`
  Widget.

## Mw/Widget/ScrollBar.h

ScrollBar widget.

    MWDECL MwClass MwScrollBarClass;

  ScrollBar widget class.

    MWDECL int MwScrollBarGetVisibleLength (
    	MwWidget handle
    );

  Calculates a visible length of scrollbar.
Parameter `handle`
  Widget.
Returns
  Visible length.

## Mw/Widget/SubMenu.h

SubMenu widget.

    MWDECL MwClass MwSubMenuClass;

  SubMenu widget class.

## Mw/Widget/Vulkan.h

Vulkan widget.

| This header is not documented yet.

    MWDECL MwClass MwVulkanClass;

  Vulkan widget class.

    MWDECL void MwVulkanEnableExtension (
    	const char* ext_name
    );

  Add an extension to the list of extensions to enable prior to initialization.

| This must be called before MwCreateWidget.

    MWDECL void MwVulkanEnableLayer (
    	const char* ext_name
    );

  Add an layer to the list of layers to enable prior to initialization.

| This must be called before MwCreateWidget.

    typedef struct MwVulkanConfig_T;

  Configuration options that can be passed to setup Vulkan before a widget is created.

     uint32_t api_version;

  Vulkan API version (default: VK_API_VERSION_1_0).

     uint32_t vk_version;

  Vulkan version (default: VK_VERSION_1_0).

     VkBool32 validation_layers;

  Whether or not to enable validation layers (default: false).

    MWDECL void MwVulkanConfigure (
    	MwVulkanConfig cfg
    );

  Configure Vulkan prior to initializing the widget.

| The configuration provided will be used for future initializations of the Vulkan widget (unless it's changed).

    typedef enum MwVulkanField_T;

  Field that can be gotten from Vulkan.

     MwVulkanField_GetInstanceProcAddr = 0

  The address of the vulkan widget's vkGetInstanceProcAddr function (PFN_vkGetInstanceProcAddr).

     MwVulkanField_Instance

  The address of the vulkan widget's instance (VkInstance).

     MwVulkanField_Surface

  The address of the vulkan widget's surface (VkSurfaceKHR).

     MwVulkanField_PhysicalDevice

  The address of the vulkan widget's physical device (VkPhysicalDevice).

     MwVulkanField_LogicalDevice

  The address of the vulkan widget's logical device (VkDevice).

     MwVulkanField_GraphicsQueueIndex

  The address of the index that the vulkan widget uses for the graphics queue (uint32_t *).

     MwVulkanField_PresentQueueIndex

  The address of the index that the vulkan widget uses for the present queue (uint32_t *).

     MwVulkanField_PresentQueue

  The address of the vulkan widget's graphics queue (VkQueue).

    MWDECL void* MwVulkanGetField (
    	MwWidget handle,
    	MwVulkanField field,
    	MwErrorEnum* out
    );

  Function for getting a field from within Vulkan.

| Consult the documentation for MwVulkanField to know what type is expected for out.

    MWDECL VkBool32 MwVulkanSupported (
    	void
    );

  Return whether Vulkan is installed on the target platform.

## Mw/Widget/Window.h

Window widget.

    MWDECL MwClass MwWindowClass;

  Window widget class.