Usermode/AxWin4 - Shared buffers working, added DrawCtrl code
[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
11 tAxWin4_Window *CreateBGWin(int w, int h);
12 tAxWin4_Window *CreateTaskbar(int w, int h);
13
14 // === CODE ===
15 int main(int argc, const char *argv[])
16 {
17         assert( AxWin4_Connect("ipcpipe:///Devices/ipcpipe/axwin4") );
18         
19         unsigned int w, h;
20         AxWin4_GetScreenDimensions(0, &w, &h);
21         
22         tAxWin4_Window *bgwin = CreateBGWin(w, h);
23         tAxWin4_Window *menu = CreateTaskbar(w, h);
24         
25         _SysDebug("Beginning queue");
26         while( AxWin4_WaitEventQueue(0) )
27                 ;
28         _SysDebug("Clean exit");
29         
30         return 0;
31 }
32
33 tAxWin4_Window *CreateBGWin(int w, int h)
34 {
35         tAxWin4_Window  *bgwin = AxWin4_CreateWindow("background");
36         AxWin4_MoveWindow(bgwin, 0,0);
37         AxWin4_ResizeWindow(bgwin, w,h);
38         AxWin4_SetWindowFlags(bgwin, AXWIN4_WNDFLAG_NODECORATE|AXWIN4_WNDFLAG_KEEPBELOW);
39         
40         // Load background image
41         uint32_t *buf = AxWin4_GetWindowBuffer(bgwin);
42         for( size_t y = 0; y < h; y ++ )
43         {
44                 for(size_t x = 0; x < w; x ++ )
45                 {
46                         uint8_t r = y * 256 / h;
47                         uint8_t g = 0;
48                         uint8_t b = x * 256 / w;
49                         buf[y*w+x] = (r << 16) | (g << 8) | b;
50                 }
51         }
52         //AxWin4_DamageRect(bgwin, 0, 0, w, h);
53         AxWin4_ShowWindow(bgwin, true);
54         
55         return bgwin;
56 }
57
58 tAxWin4_Window *CreateTaskbar(int w, int h)
59 {
60          int    winheight = 30;
61         tAxWin4_Window *win = AxWin4_CreateWindow("taskbar");
62         AxWin4_MoveWindow(win, 0, 0);
63         AxWin4_ResizeWindow(win, w, winheight);
64         
65         AxWin4_SetWindowFlags(win, AXWIN4_WNDFLAG_NODECORATE);
66         Taskbar_Redraw(win);
67         AxWin4_ShowWindow(win, true);
68         
69         return win;
70 }
71
72 void Taskbar_Redraw(tAxWin4_Window *win)
73 {
74          int    w = 640;
75          int    h = 30;
76         AxWin4_DrawControl(win, 0, 0, w, h, 0x01);      // Standard button, suitable for a toolbar
77         AxWin4_DrawControl(win, 5, 5, h-10, h-10, 0x00);        // Standard button
78         
79         AxWin4_DamageRect(bgwin, 0, 0, w, h);
80 }
81

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