3 * - By John Hodge (thePowersGang)
6 * - Main toolbar (aka Taskbar)
8 #include <axwin4/axwin.h>
9 #include "include/common.h"
10 #include "include/taskbar.h"
14 #define TASKBAR_HEIGHT 30
15 #define TASKBAR_BORDER 3 // Border between window edge and controls
16 #define TASKBAR_SYSBTN_SIZE (TASKBAR_HEIGHT-TASKBAR_BORDER*2)
17 #define TASKBAR_WIN_MAXSIZE 100
18 #define TASKBAR_WIN_MINSIZE 24
19 #define TASKBAR_CLOCKSIZE 60
22 typedef struct sTaskbar_Win tTaskbar_Win;
32 tAxWin4_Window *gpTaskbar_Window;
33 unsigned int giTaskbar_NumWins = 0;
34 tTaskbar_Win *gpTaskbar_FirstWin;
37 void Taskbar_Create(void)
39 gpTaskbar_Window = AxWin4_CreateWindow("taskbar");
40 tAxWin4_Window * const win = gpTaskbar_Window;
42 AxWin4_MoveWindow(win, 0, 0);
43 AxWin4_ResizeWindow(win, giScreenWidth, TASKBAR_HEIGHT);
45 AxWin4_SetWindowFlags(win, AXWIN4_WNDFLAG_NODECORATE);
47 AxWin4_ShowWindow(win, true);
50 void Taskbar_Redraw(void)
52 const int w = giScreenWidth;
53 const int h = TASKBAR_HEIGHT;
55 const int active_height = h - TASKBAR_BORDER*2;
56 const int winlist_start_x = TASKBAR_BORDER+TASKBAR_SYSBTN_SIZE+TASKBAR_BORDER;
57 const int clock_start_x = w - (TASKBAR_BORDER+TASKBAR_CLOCKSIZE);
59 // Window background: Toolbar skin
60 AxWin4_DrawControl(gpTaskbar_Window, 0, 0, w, h, AXWIN4_CTL_TOOLBAR, 0);
63 // TODO: Use an image instead
64 AxWin4_DrawControl(gpTaskbar_Window, TASKBAR_BORDER, TASKBAR_BORDER, TASKBAR_SYSBTN_SIZE, active_height, AXWIN4_CTL_BUTTON, 0);
67 // TODO: Maintain/request a list of windows
68 if( giTaskbar_NumWins )
70 int winbutton_size = (clock_start_x - winlist_start_x) / giTaskbar_NumWins;
71 if(winbutton_size > TASKBAR_WIN_MAXSIZE) winbutton_size = TASKBAR_WIN_MAXSIZE;
72 int x = winlist_start_x;
73 for(tTaskbar_Win *win = gpTaskbar_FirstWin; win; win = win->Next )
75 AxWin4_DrawControl(gpTaskbar_Window, x, TASKBAR_BORDER, winbutton_size, active_height, AXWIN4_CTL_BUTTON, 0);
84 strftime(timestr, 5, "%H%M", localtime(&rawtime));
85 //AxWin4_DrawControl(gpTaskbar_Window, clock_start_x, TASKBAR_BORDER, TASKBAR_CLOCKSIZE, active_height, AXWIN4_CTL_BOX);
86 AxWin4_DrawText(gpTaskbar_Window, clock_start_x, TASKBAR_BORDER, TASKBAR_CLOCKSIZE, active_height, 0, timestr);
87 //AxWin4_DrawText(gpTaskbar_Window, clock_start_x, TASKBAR_BORDER, TASKBAR_CLOCKSIZE, 16, 0, timestr);
90 AxWin4_DamageRect(gpTaskbar_Window, 0, 0, w, h);