c831558dc40961a32753e8f6288a55f9735fe34a
[tpg/acess2.git] / Usermode / Applications / axwin4_src / UI / main.c
1 /*
2  * AxWin4 GUI - UI Core
3  * - By John Hodge (thePowersGang)
4  *
5  * main.c
6  * - Program core
7  */
8 #include <axwin4/axwin.h>
9 #include <assert.h>
10 #include "include/common.h"
11 #include "include/taskbar.h"
12
13 // === PROTOTYPES ===
14 tAxWin4_Window *CreateBGWin(int w, int h);
15
16 // === GLOABLS ===
17 unsigned int    giScreenWidth = 640;
18 unsigned int    giScreenHeight = 480;
19
20 // === CODE ===
21 int main(int argc, const char *argv[])
22 {
23         assert( AxWin4_Connect("ipcpipe:///Devices/ipcpipe/axwin4") );
24         
25         AxWin4_GetScreenDimensions(0, &giScreenWidth, &giScreenHeight);
26         
27         tAxWin4_Window *bgwin = CreateBGWin(giScreenWidth, giScreenHeight);
28         Taskbar_Create();
29         
30         _SysDebug("Beginning queue");
31         while( AxWin4_WaitEventQueue(0) )
32                 ;
33         _SysDebug("Clean exit");
34         
35         return 0;
36 }
37
38 tAxWin4_Window *CreateBGWin(int w, int h)
39 {
40         tAxWin4_Window  *bgwin = AxWin4_CreateWindow("background");
41         AxWin4_MoveWindow(bgwin, 0,0);
42         AxWin4_ResizeWindow(bgwin, w,h);
43         AxWin4_SetWindowFlags(bgwin, AXWIN4_WNDFLAG_NODECORATE|AXWIN4_WNDFLAG_KEEPBELOW);
44         
45         // Load background image
46         uint32_t *buf = AxWin4_GetWindowBuffer(bgwin);
47         if( buf )
48         {
49                 for( size_t y = 0; y < h; y ++ )
50                 {
51                         for(size_t x = 0; x < w; x ++ )
52                         {
53                                 uint8_t r = y * 256 / h;
54                                 uint8_t g = 0;
55                                 uint8_t b = x * 256 / w;
56                                 buf[y*w+x] = (r << 16) | (g << 8) | b;
57                         }
58                 }
59         }
60         else
61         {
62                 //AxWin4_FillRect(bgwin, 0, 0, w, h, 0x0000CC);
63         }
64         //AxWin4_DamageRect(bgwin, 0, 0, w, h);
65         AxWin4_ShowWindow(bgwin, true);
66         
67         return bgwin;
68 }
69

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