2 * Acess Text Editor (ATE)
3 * - By John Hodge (thePowersGang)
8 #include <axwin3/axwin.h>
9 #include <axwin3/widget.h>
10 #include <axwin3/menu.h>
11 #include <axwin3/richtext.h>
15 int main(int argc, char *argv[]);
16 int TextArea_KeyHandler(tHWND Window, int bPress, uint32_t KeySym, uint32_t Translated);
17 int TextArea_MouseHandler(tHWND Window, int bPress, int Button, int Row, int Col);
18 void add_toolbar_button(tAxWin3_Widget *Toolbar, const char *Ident, tAxWin3_Widget_FireCb Callback);
19 int Toolbar_New(tAxWin3_Widget *Widget);
20 int Toolbar_Open(tAxWin3_Widget *Widget);
21 int Toolbar_Save(tAxWin3_Widget *Widget);
25 tAxWin3_Widget *gMainWindow_Root;
26 tHWND gMainWindow_MenuBar;
27 tAxWin3_Widget *gMainWindow_Toolbar;
28 tHWND gMainWindow_TextArea;
31 int main(int argc, char *argv[])
35 // --- Build up window
36 gMainWindow = AxWin3_Widget_CreateWindow(NULL, 320, 200, ELEFLAG_VERTICAL);
37 gMainWindow_Root = AxWin3_Widget_GetRoot(gMainWindow);
39 //gMainWindow_MenuBar = AxWin3_Menu_Create(gMainWindow);
40 //AxWin3_Widget_AddWidget_SubWindow(gMainWindow_Root, gMainWindow_MenuBar);
41 // TODO: Populate menu
44 gMainWindow_Toolbar = AxWin3_Widget_AddWidget(gMainWindow_Root, ELETYPE_TOOLBAR, 0, "Toolbar");
45 add_toolbar_button(gMainWindow_Toolbar, "BtnNew", Toolbar_New);
46 add_toolbar_button(gMainWindow_Toolbar, "BtnOpen", Toolbar_Open);
47 add_toolbar_button(gMainWindow_Toolbar, "BtnOpen", Toolbar_Save);
48 AxWin3_Widget_AddWidget(gMainWindow_Toolbar, ELETYPE_SPACER, 0, "");
49 add_toolbar_button(gMainWindow_Toolbar, "BtnUndo", NULL);
50 add_toolbar_button(gMainWindow_Toolbar, "BtnRedo", NULL);
51 AxWin3_Widget_AddWidget(gMainWindow_Toolbar, ELETYPE_SPACER, 0, "");
52 add_toolbar_button(gMainWindow_Toolbar, "BtnCut", NULL);
53 add_toolbar_button(gMainWindow_Toolbar, "BtnCopy", NULL);
54 add_toolbar_button(gMainWindow_Toolbar, "BtnPaste", NULL);
55 AxWin3_Widget_AddWidget(gMainWindow_Toolbar, ELETYPE_SPACER, 0, "");
56 add_toolbar_button(gMainWindow_Toolbar, "BtnSearch", NULL);
57 add_toolbar_button(gMainWindow_Toolbar, "BtnReplace", NULL);
61 gMainWindow_TextArea = AxWin3_RichText_CreateWindow(gMainWindow, 0);
62 AxWin3_Widget_AddWidget_SubWindow(gMainWindow_Root, gMainWindow_TextArea, "TextArea");
63 AxWin3_RichText_SetKeyHandler (gMainWindow_TextArea, TextArea_KeyHandler);
64 AxWin3_RichText_SetMouseHandler (gMainWindow_TextArea, TextArea_MouseHandler);
65 AxWin3_RichText_SetBackground (gMainWindow_TextArea, 0xFFFFFF);
66 AxWin3_RichText_SetDefaultColour(gMainWindow_TextArea, 0x000000);
67 AxWin3_RichText_SetFont (gMainWindow_TextArea, "#monospace", 10);
68 AxWin3_RichText_SetCursorPos (gMainWindow_TextArea, 0, 0);
69 AxWin3_RichText_SetCursorType (gMainWindow_TextArea, AXWIN3_RICHTEXT_CURSOR_VLINE);
70 AxWin3_RichText_SetCursorBlink (gMainWindow_TextArea, 1);
73 AxWin3_ShowWindow(gMainWindow, 1);
81 int TextArea_KeyHandler(tHWND Window, int bPress, uint32_t KeySym, uint32_t Translated)
86 int TextArea_MouseHandler(tHWND Window, int bPress, int Button, int Row, int Col)
91 void add_toolbar_button(tAxWin3_Widget *Toolbar, const char *Ident, tAxWin3_Widget_FireCb Callback)
93 tAxWin3_Widget *btn = AxWin3_Widget_AddWidget(Toolbar, ELETYPE_BUTTON, 0, Ident);
94 // TODO: Get image / text using `Ident` as a lookup key
95 AxWin3_Widget_SetText(btn, Ident);
96 AxWin3_Widget_SetFireHandler(btn, Callback);
99 int Toolbar_New(tAxWin3_Widget *Widget)
103 int Toolbar_Open(tAxWin3_Widget *Widget)
107 int Toolbar_Save(tAxWin3_Widget *Widget)