AxWin2 - More fiddling, almost ready now :)
[tpg/acess2.git] / Usermode / Applications / axwin2_src / WM / common.h
1 /*
2  * Acess GUI (AxWin) Version 2
3  * By John Hodge (thePowersGang)
4  */
5 #ifndef _COMMON_H_
6 #define _COMMON_H_
7
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <stdint.h>
11 #include <acess/sys.h>  // _SysDebug
12
13 // === TYPES ===
14 typedef struct sIPC_Type        tIPC_Type;
15 typedef struct sFont    tFont;
16
17 struct sIPC_Type
18 {
19          int    (*GetIdentSize)(void *Ident);
20          int    (*CompareIdent)(void *Ident1, void *Ident2);
21         void    (*SendMessage)(void *Ident, size_t, void *Data);
22 };
23
24 #include "wm.h"
25 #include "image.h"
26 //#include "font.h"
27
28 // === MACROS ===
29 static inline uint32_t Video_AlphaBlend(uint32_t _orig, uint32_t _new, uint8_t _alpha)
30 {
31         uint16_t        ao,ro,go,bo;
32         uint16_t        an,rn,gn,bn;
33         if( _alpha == 0 )       return _orig;
34         if( _alpha == 255 )     return _new;
35         
36         ao = (_orig >> 24) & 0xFF;
37         ro = (_orig >> 16) & 0xFF;
38         go = (_orig >>  8) & 0xFF;
39         bo = (_orig >>  0) & 0xFF;
40         
41         an = (_new >> 24) & 0xFF;
42         rn = (_new >> 16) & 0xFF;
43         gn = (_new >>  8) & 0xFF;
44         bn = (_new >>  0) & 0xFF;
45
46         if( _alpha == 0x80 ) {
47                 ao = (ao + an) / 2;
48                 ro = (ro + rn) / 2;
49                 go = (go + gn) / 2;
50                 bo = (bo + bn) / 2;
51         }
52         else {
53                 ao = ao*(255-_alpha) + an*_alpha;
54                 ro = ro*(255-_alpha) + rn*_alpha;
55                 go = go*(255-_alpha) + gn*_alpha;
56                 bo = bo*(255-_alpha) + bn*_alpha;
57                 ao /= 255*2;
58                 ro /= 255*2;
59                 go /= 255*2;
60                 bo /= 255*2;
61         }
62
63         return (ao << 24) | (ro << 16) | (go << 8) | bo;
64 }
65
66 // === GLOBALS ===
67 extern const char       *gsTerminalDevice;
68 extern const char       *gsMouseDevice;
69
70 extern int      giScreenWidth;
71 extern int      giScreenHeight;
72 extern uint32_t *gpScreenBuffer;
73
74 extern int      giTerminalFD;
75 extern int      giMouseFD;
76
77 // === Functions ===
78 extern void     memset32(void *ptr, uint32_t val, size_t count);
79 // --- Initialisation ---
80 extern void     ParseCommandline(int argc, char *argv[]);
81 // --- Messages / IPC ---
82 extern void     IPC_Init(void);
83 extern void     IPC_FillSelect(int *nfds, fd_set *set);
84 extern void     IPC_HandleSelect(fd_set *set);
85 // --- Input ---
86 extern void     Input_FillSelect(int *nfds, fd_set *set);
87 extern void     Input_HandleSelect(fd_set *set);
88 // --- Local WM ---
89 extern tApplication     *AxWin_RegisterClient(tIPC_Type *Method, void *Ident, const char *Name);
90 extern void     AxWin_DeregisterClient(tApplication *App);
91 extern tApplication     *AxWin_GetClient(tIPC_Type *Method, void *Ident);
92 extern tElement *AxWin_CreateAppWindow(tApplication *App, const char *Name);
93 // --- Video ---
94 extern void     Video_Setup(void);
95 extern void     Video_Update(void);
96 extern void     Video_FillRect(short X, short Y, short W, short H, uint32_t Color);
97 extern void     Video_DrawRect(short X, short Y, short W, short H, uint32_t Color);
98 extern int      Video_DrawText(short X, short Y, short W, short H, tFont *Font, uint32_t Color, char *Text);
99 extern void     Video_DrawImage(short X, short Y, short W, short H, tImage *Image);
100 // --- Interface ---
101 extern void     Interface_Init(void);
102 extern void     Interface_Update(void);
103 extern void     Interface_Render(void);
104 // --- Decorator ---
105 extern void     Decorator_RenderWidget(tElement *Element);
106
107 #endif

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