2 * Acess2 GUI v3 User Interface
3 * - By John Hodge (thePowersGang)
10 #include <axwin3/axwin.h>
11 #include <axwin3/widget.h>
12 #include <axwin3/menu.h>
14 #define SIDEBAR_WIDTH 40
19 void create_sidebar(void);
20 void create_mainmenu(void);
21 void create_run_dialog(void);
25 tAxWin3_Widget *gSidebarRoot;
28 tAxWin3_Widget *gRunInput;
33 int systembutton_fire(tAxWin3_Widget *Widget)
35 _SysDebug("SystemButton pressed");
36 AxWin3_Menu_ShowAt(gSystemMenu, SIDEBAR_WIDTH, 0);
40 int main(int argc, char *argv[])
42 // Connect to AxWin3 Server
45 // TODO: Register to be told when the display layout changes
46 AxWin3_GetDisplayDims(0, NULL, NULL, &giScreenWidth, &giScreenHeight);
58 void create_sidebar(void)
60 tAxWin3_Widget *btn, *txt, *ele;
63 gSidebar = AxWin3_Widget_CreateWindow(NULL, SIDEBAR_WIDTH, giScreenHeight, ELEFLAG_VERTICAL);
64 AxWin3_MoveWindow(gSidebar, 0, 0);
65 gSidebarRoot = AxWin3_Widget_GetRoot(gSidebar);
68 btn = AxWin3_Widget_AddWidget(gSidebarRoot, ELETYPE_BUTTON, ELEFLAG_NOSTRETCH, "SystemButton");
69 AxWin3_Widget_SetSize(btn, SIDEBAR_WIDTH);
70 AxWin3_Widget_SetFireHandler(btn, systembutton_fire);
71 txt = AxWin3_Widget_AddWidget(btn, ELETYPE_IMAGE, 0, "SystemLogo");
72 AxWin3_Widget_SetText(txt, "file:///Acess/Apps/AxWin/3.0/AcessLogoSmall.sif");
74 // - Plain <hr/> style spacer
75 ele = AxWin3_Widget_AddWidget(gSidebarRoot, ELETYPE_SPACER, ELEFLAG_NOSTRETCH, "SideBar Spacer Top");
76 AxWin3_Widget_SetSize(ele, 4);
79 ele = AxWin3_Widget_AddWidget(gSidebarRoot, ELETYPE_BOX, ELEFLAG_VERTICAL, "ProgramList");
81 // - Plain <hr/> style spacer
82 ele = AxWin3_Widget_AddWidget(gSidebarRoot, ELETYPE_SPACER, ELEFLAG_NOSTRETCH, "SideBar Spacer Top");
83 AxWin3_Widget_SetSize(ele, 4);
86 ele = AxWin3_Widget_AddWidget(gSidebarRoot, ELETYPE_BOX, ELEFLAG_VERTICAL|ELEFLAG_ALIGN_CENTER|ELEFLAG_NOSTRETCH, "Version/Time");
87 txt = AxWin3_Widget_AddWidget(ele, ELETYPE_TEXT, ELEFLAG_NOSTRETCH, "Version String");
88 AxWin3_Widget_SetSize(txt, 20);
89 AxWin3_Widget_SetText(txt, "3.0");
91 // Turn off decorations
92 AxWin3_DecorateWindow(gSidebar, 0);
95 AxWin3_ShowWindow(gSidebar, 1);
99 void mainmenu_app_textedit(void *unused)
101 _SysDebug("TODO: Launch text editor");
104 void mainmenu_app_terminal(void *unused)
106 _SysDebug("TODO: Launch terminal emulator");
109 void mainmenu_run_dialog(void *unused)
111 AxWin3_ShowWindow(gRunDialog, 1);
114 void create_mainmenu(void)
116 gSystemMenu = AxWin3_Menu_Create(NULL);
118 AxWin3_Menu_AddItem(gSystemMenu, "Text &Editor\tWin+E", mainmenu_app_textedit, NULL, 0, NULL);
119 AxWin3_Menu_AddItem(gSystemMenu, "Terminal Emulator\tWin+T", mainmenu_app_terminal, NULL, 0, NULL);
120 AxWin3_Menu_AddItem(gSystemMenu, NULL, NULL, NULL, 0, NULL);
121 AxWin3_Menu_AddItem(gSystemMenu, "Run\tWin+R", mainmenu_run_dialog, NULL, 0, NULL);
124 int run_dorun(tAxWin3_Widget *unused)
126 // char *cmd = AxWin3_Widget_GetText(gRunInput);
127 AxWin3_ShowWindow(gRunDialog, 0);
131 int run_close(tAxWin3_Widget *unused)
133 AxWin3_ShowWindow(gRunDialog, 0);
137 tAxWin3_Widget *make_textbutton(tAxWin3_Widget *Parent, const char *Label, tAxWin3_Widget_FireCb handler)
139 tAxWin3_Widget *ret, *txt;
140 ret = AxWin3_Widget_AddWidget(Parent, ELETYPE_BUTTON, ELEFLAG_ALIGN_CENTER, "_btn");
141 AxWin3_Widget_SetFireHandler(ret, handler);
142 AxWin3_Widget_AddWidget(ret, ELETYPE_NONE, 0, "_spacer1");
143 txt = AxWin3_Widget_AddWidget(ret, ELETYPE_TEXT, ELEFLAG_NOSTRETCH|ELEFLAG_NOEXPAND, "_txt");
144 AxWin3_Widget_SetText(txt, Label);
145 AxWin3_Widget_AddWidget(ret, ELETYPE_NONE, 0, "_spacer2");
149 void create_run_dialog(void)
151 tAxWin3_Widget *root, *box;
153 gRunDialog = AxWin3_Widget_CreateWindow(NULL, RUN_WIDTH, RUN_HEIGHT, ELEFLAG_VERTICAL);
154 AxWin3_SetWindowTitle(gRunDialog, "Run Program...");
155 AxWin3_MoveWindow(gRunDialog, giScreenWidth/2-RUN_WIDTH/2, giScreenHeight/2-RUN_HEIGHT/2);
157 root = AxWin3_Widget_GetRoot(gRunDialog);
159 gRunInput = AxWin3_Widget_AddWidget(root, ELETYPE_TEXTINPUT, ELEFLAG_NOSTRETCH, "Input");
160 AxWin3_Widget_SetFireHandler(gRunInput, run_dorun);
162 box = AxWin3_Widget_AddWidget(root, ELETYPE_BOX, ELEFLAG_ALIGN_CENTER, "Button Area");
163 make_textbutton(box, "Ok", run_dorun);
164 make_textbutton(box, "Cancel", run_close);