X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Faxwin4_src%2FUI%2Fmain.c;h=b00ce261222eab7c2e964d08de563ae7eba64479;hb=cb37616a62753de8a1b8d28e3c4ec3ad9891de1b;hp=e599cb913c1f5ce18c2f3cf5258c6e27d0c83fbb;hpb=91d300c3c18adcc6581f268b787db0b34a7a6150;p=tpg%2Facess2.git diff --git a/Usermode/Applications/axwin4_src/UI/main.c b/Usermode/Applications/axwin4_src/UI/main.c index e599cb91..b00ce261 100644 --- a/Usermode/Applications/axwin4_src/UI/main.c +++ b/Usermode/Applications/axwin4_src/UI/main.c @@ -8,26 +8,74 @@ #include #include +tAxWin4_Window *CreateBGWin(int w, int h); +tAxWin4_Window *CreateTaskbar(int w, int h); + // === CODE === int main(int argc, const char *argv[]) { assert( AxWin4_Connect("ipcpipe:///Devices/ipcpipe/axwin4") ); - tAxWin4_Window *bgwin = AxWin4_CreateWindow("background"); + unsigned int w, h; + AxWin4_GetScreenDimensions(0, &w, &h); - AxWin4_MoveWindow(bgwin, 0,0); - AxWin4_ResizeWindow(bgwin, 640,480); - //AxWin4_SetWindowFlags(bgwin, AXWIN4_WNDFLAG_NODECORATE|AXWIN4_WNDFLAG_KEEPBELOW); + tAxWin4_Window *bgwin = CreateBGWin(w, h); + tAxWin4_Window *menu = CreateTaskbar(w, h); - // Load image - char *image = malloc(640*480*4); - AxWin4_DrawBitmap(bgwin, 0, 0, 640, 480, image); - _SysDebug("Beginning queue"); - while( AxWin4_WaitEventQueue(0) ) ; _SysDebug("Clean exit"); return 0; } + +tAxWin4_Window *CreateBGWin(int w, int h) +{ + tAxWin4_Window *bgwin = AxWin4_CreateWindow("background"); + AxWin4_MoveWindow(bgwin, 0,0); + AxWin4_ResizeWindow(bgwin, w,h); + AxWin4_SetWindowFlags(bgwin, AXWIN4_WNDFLAG_NODECORATE|AXWIN4_WNDFLAG_KEEPBELOW); + + // Load background image + uint32_t *buf = AxWin4_GetWindowBuffer(bgwin); + for( size_t y = 0; y < h; y ++ ) + { + for(size_t x = 0; x < w; x ++ ) + { + uint8_t r = y * 256 / h; + uint8_t g = 0; + uint8_t b = x * 256 / w; + buf[y*w+x] = (r << 16) | (g << 8) | b; + } + } + //AxWin4_DamageRect(bgwin, 0, 0, w, h); + AxWin4_ShowWindow(bgwin, true); + + return bgwin; +} + +tAxWin4_Window *CreateTaskbar(int w, int h) +{ + int winheight = 30; + tAxWin4_Window *win = AxWin4_CreateWindow("taskbar"); + AxWin4_MoveWindow(win, 0, 0); + AxWin4_ResizeWindow(win, w, winheight); + + AxWin4_SetWindowFlags(win, AXWIN4_WNDFLAG_NODECORATE); + Taskbar_Redraw(win); + AxWin4_ShowWindow(win, true); + + return win; +} + +void Taskbar_Redraw(tAxWin4_Window *win) +{ + int w = 640; + int h = 30; + AxWin4_DrawControl(win, 0, 0, w, h, 0x01); // Standard button, suitable for a toolbar + AxWin4_DrawControl(win, 5, 5, h-10, h-10, 0x00); // Standard button + + AxWin4_DamageRect(bgwin, 0, 0, w, h); +} +