AxWin3 - Fixed overflow caused by using width in height calculations
[tpg/acess2.git] / Usermode / Applications / axwin3_src / WM / include / wm.h
1 /*
2  * Acess2 Window Manager v3 (axwin3)
3  * - By John Hodge (thePowersGang)
4  *
5  * include/wm.h
6  * - Window management functions
7  */
8 #ifndef _WM_H_
9 #define _WM_H_
10
11 #include <stdint.h>
12 #include <stdlib.h>
13
14 #include "image.h"
15
16 // === CONSTANTS ===
17 /**
18  * \brief Window Flags
19  * \{
20  */
21 //! Render the window
22 #define WINFLAG_SHOW            0x00000001
23 //! Don't decoratate even if root
24 #define WINFLAG_NODECORATE      0x00000002
25 //! Window takes up all of screen
26 #define WINFLAG_MAXIMIZED       0x00000004
27 //! Window contents are valid
28 #define WINFLAG_CLEAN           0x00000040
29 //! All child windows are un-changed
30 #define WINFLAG_CHILDCLEAN      0x00000080
31
32 #define WINFLAG_RENDER_MASK     0x00FFFF00
33 #define WINFLAG_USR_MASK        0xFF000000
34 /**
35  * \}
36  */
37
38 // === TYPES ===
39 typedef struct sWindow  tWindow;
40 typedef struct sWMRenderer      tWMRenderer;
41 typedef uint32_t        tColour;
42 typedef struct sFont    tFont;
43 typedef struct sIPC_Client      tIPC_Client;
44
45 // === FUNCTIONS ===
46 // --- Management
47 extern tWindow  *WM_CreateWindow(tWindow *Parent, tIPC_Client *Client, uint32_t ID, int Flags, const char *Renderer);
48 extern tWindow  *WM_GetWindowByID(tWindow *Requester, uint32_t ID);
49 extern void     WM_Invalidate(tWindow *Window);
50 extern void     WM_SetWindowTitle(tWindow *Window, const char *Title);
51 extern void     WM_FocusWindow(tWindow *Destination);
52 extern void     WM_RaiseWindow(tWindow *Window);
53 extern void     WM_ShowWindow(tWindow *Window, int bShow);
54 extern void     WM_DecorateWindow(tWindow *Window, int bDecorate);
55 extern int      WM_ResizeWindow(tWindow *Window, int W, int H);
56 extern int      WM_MoveWindow(tWindow *Window, int X, int Y);
57 extern int      WM_SendMessage(tWindow *Source, tWindow *Dest, int MessageID, int Length, const void *Data);
58 // --- Rendering
59 extern void     WM_Render_FillRect(tWindow *Window, int X, int Y, int W, int H, tColour Colour);
60 extern void     WM_Render_DrawRect(tWindow *Window, int X, int Y, int W, int H, tColour Colour);
61 /**
62  * \brief Draw text to a window
63  * \param Window        Destination Window
64  * \param X     X coordinate (Left)
65  * \param Y     Y coordinate (Top)
66  * \param W     Width of destination region
67  * \param H     Height of destination region
68  * \param Font  Font to use
69  * \param Colour        Text foreground colour
70  * \param Text  UTF-8 string to render
71  * \param MaxLen        Number of bytes in \a Text to read (Note: A final multi-byte sequence can exceed this count)
72  *
73  * \note As as noted in the \a MaxLen parameter, up to 3 more bytes may be read
74  *       if the final character is a multi-byte UTF-8 sequence. This allows 1
75  *       to be passed to only render a single character.
76  */
77 extern int      WM_Render_DrawText(tWindow *Window, int X, int Y, int W, int H, tFont *Font, tColour Colour, const char *Text, int MaxLen);
78 /**
79  * \brief Get the dimensions of a string if it was rendered
80  * \param Font  Font to use
81  * \param Text  UTF-8 string to be processed
82  * \param MaxLen        Number of bytes in \a Text to read (same caveat as WM_Render_DrawText applies)
83  * \param W     Pointer to an integer to store the width of the rendered text
84  * \param H     Pointer to an integer to store the height of the rendered text
85  */
86 extern void     WM_Render_GetTextDims(tFont *Font, const char *Text, int MaxLen, int *W, int *H);
87 extern void     WM_Render_DrawImage(tWindow *Window, int X, int Y, int W, int H, tImage *Image);
88 extern void     WM_Render_SetTextCursor(tWindow *Window, int X, int Y, int W, int H, tColour Colour);
89 // NOTE: Should really be elsewhere
90 extern tColour  Video_AlphaBlend(tColour _orig, tColour _new, uint8_t _alpha);
91 #endif
92

UCC git Repository :: git.ucc.asn.au