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,
88 ELEFLAG_VERTICAL|ELEFLAG_ALIGN_CENTER|ELEFLAG_NOSTRETCH,
91 txt = AxWin3_Widget_AddWidget(ele, ELETYPE_TEXT, ELEFLAG_NOSTRETCH, "Version String");
92 AxWin3_Widget_SetSize(txt, 20);
93 AxWin3_Widget_SetText(txt, "3.0");
95 // Turn off decorations
96 AxWin3_DecorateWindow(gSidebar, 0);
99 AxWin3_ShowWindow(gSidebar, 1);
103 void mainmenu_app_textedit(void *unused)
105 _SysDebug("TODO: Launch text editor");
108 void mainmenu_app_terminal(void *unused)
110 _SysDebug("TODO: Launch terminal emulator");
113 void mainmenu_run_dialog(void *unused)
115 AxWin3_ShowWindow(gRunDialog, 1);
118 void create_mainmenu(void)
120 gSystemMenu = AxWin3_Menu_Create(NULL);
122 AxWin3_Menu_AddItem(gSystemMenu, "Text &Editor\tWin+E", mainmenu_app_textedit, NULL, 0, NULL);
123 AxWin3_Menu_AddItem(gSystemMenu, "&Terminal Emulator\tWin+T", mainmenu_app_terminal, NULL, 0, NULL);
124 AxWin3_Menu_AddItem(gSystemMenu, NULL, NULL, NULL, 0, NULL);
125 AxWin3_Menu_AddItem(gSystemMenu, "&Run\tWin+R", mainmenu_run_dialog, NULL, 0, NULL);
128 // --------------------------------------------------------------------
130 // --------------------------------------------------------------------
131 int run_dorun(tAxWin3_Widget *unused)
133 char *cmd = AxWin3_Widget_GetText(gRunInput);
134 _SysDebug("Command string '%s'", cmd);
135 AxWin3_ShowWindow(gRunDialog, 0);
139 int run_close(tAxWin3_Widget *unused)
141 _SysDebug("Run diaglog closed");
142 AxWin3_ShowWindow(gRunDialog, 0);
146 tAxWin3_Widget *make_textbutton(tAxWin3_Widget *Parent, const char *Label, tAxWin3_Widget_FireCb handler)
148 tAxWin3_Widget *ret, *txt;
149 ret = AxWin3_Widget_AddWidget(Parent, ELETYPE_BUTTON, ELEFLAG_ALIGN_CENTER, "_btn");
150 AxWin3_Widget_SetFireHandler(ret, handler);
151 AxWin3_Widget_AddWidget(ret, ELETYPE_NONE, 0, "_spacer1");
152 txt = AxWin3_Widget_AddWidget(ret, ELETYPE_TEXT, ELEFLAG_NOSTRETCH|ELEFLAG_NOEXPAND, "_txt");
153 AxWin3_Widget_SetText(txt, Label);
154 AxWin3_Widget_AddWidget(ret, ELETYPE_NONE, 0, "_spacer2");
158 void create_run_dialog(void)
160 tAxWin3_Widget *root, *box;
162 gRunDialog = AxWin3_Widget_CreateWindow(NULL, RUN_WIDTH, RUN_HEIGHT, ELEFLAG_VERTICAL);
163 AxWin3_SetWindowTitle(gRunDialog, "Run Program...");
164 AxWin3_MoveWindow(gRunDialog, giScreenWidth/2-RUN_WIDTH/2, giScreenHeight/2-RUN_HEIGHT/2);
166 root = AxWin3_Widget_GetRoot(gRunDialog);
168 gRunInput = AxWin3_Widget_AddWidget(root, ELETYPE_TEXTINPUT, ELEFLAG_NOSTRETCH, "Input");
169 AxWin3_Widget_SetFireHandler(gRunInput, run_dorun);
171 box = AxWin3_Widget_AddWidget(root, ELETYPE_BOX, ELEFLAG_ALIGN_CENTER, "Button Area");
172 make_textbutton(box, "Ok", run_dorun);
173 make_textbutton(box, "Cancel", run_close);