int AxWin3_int_DefaultMessageHandler(tWindow *Win, int ID, size_t Len, const void *Data) { switch(ID) { case WNDMSG_HOTKEY: { const struct sWndMsg_Hotkey *mi = Data; if( Len < sizeof(*mi) ) return -1; if( mi->ID >= MAX_HOTKEYS ) _SysDebug("--- Out of range hotkey %i fired", mi->ID); else if( gAxWin3_Hotkeys[mi->ID] == 0 ) _SysDebug("--- Unmapped hotkey ID %i fired", mi->ID); else gAxWin3_Hotkeys[mi->ID](); } return 1; // Honour a close message by default case WNDMSG_CLOSE: AxWin3_DestroyWindow(Win); return 1; // Zero f***s given? case WNDMSG_DESTROY: _SysDebug("TODO: Check that WNDMSG_DESTROY was from us calling _DestroyWindow"); // TODO: Finalise cleanup of window, this will be the last message sent to this window AxWin3_int_DelWindowByID(Win->ServerID); return 1; default: return 0; } }
// === CODE === int main(int argc, char *argv[]) { AxWin3_Connect(NULL); // --- Build up window gMainWindow = AxWin3_Widget_CreateWindow(NULL, 500, 400, ELEFLAG_VERTICAL); AxWin3_SetWindowTitle(gMainWindow, "Acess Text Editor"); // TODO: Update title with other info gMainWindow_Root = AxWin3_Widget_GetRoot(gMainWindow); //gMainWindow_MenuBar = AxWin3_Menu_Create(gMainWindow); //AxWin3_Widget_AddWidget_SubWindow(gMainWindow_Root, gMainWindow_MenuBar); // TODO: Populate menu // Create toolbar gMainWindow_Toolbar = AxWin3_Widget_AddWidget(gMainWindow_Root, ELETYPE_TOOLBAR, ELEFLAG_NOSTRETCH, "Toolbar"); add_toolbar_button(gMainWindow_Toolbar, "BtnNew", Toolbar_New); add_toolbar_button(gMainWindow_Toolbar, "BtnOpen", Toolbar_Open); add_toolbar_button(gMainWindow_Toolbar, "BtnSave", Toolbar_Save); add_toolbar_button(gMainWindow_Toolbar, "BtnClose", Toolbar_Close); AxWin3_Widget_AddWidget(gMainWindow_Toolbar, ELETYPE_SPACER, ELEFLAG_NOSTRETCH, ""); add_toolbar_button(gMainWindow_Toolbar, "BtnUndo", NULL); add_toolbar_button(gMainWindow_Toolbar, "BtnRedo", NULL); AxWin3_Widget_AddWidget(gMainWindow_Toolbar, ELETYPE_SPACER, ELEFLAG_NOSTRETCH, ""); add_toolbar_button(gMainWindow_Toolbar, "BtnCut", NULL); add_toolbar_button(gMainWindow_Toolbar, "BtnCopy", NULL); add_toolbar_button(gMainWindow_Toolbar, "BtnPaste", NULL); AxWin3_Widget_AddWidget(gMainWindow_Toolbar, ELETYPE_SPACER, ELEFLAG_NOSTRETCH, ""); add_toolbar_button(gMainWindow_Toolbar, "BtnSearch", NULL); add_toolbar_button(gMainWindow_Toolbar, "BtnReplace", NULL); // TODO: Tab control? gMainWindow_TextArea = AxWin3_RichText_CreateWindow(gMainWindow, 0); AxWin3_Widget_AddWidget_SubWindow(gMainWindow_Root, gMainWindow_TextArea, 0, "TextArea"); AxWin3_RichText_SetKeyHandler (gMainWindow_TextArea, TextArea_KeyHandler); AxWin3_RichText_SetMouseHandler (gMainWindow_TextArea, TextArea_MouseHandler); AxWin3_RichText_SetBackground (gMainWindow_TextArea, 0xFFFFFF); AxWin3_RichText_SetDefaultColour(gMainWindow_TextArea, 0x000000); AxWin3_RichText_SetFont (gMainWindow_TextArea, "#monospace", 10); AxWin3_RichText_SetCursorPos (gMainWindow_TextArea, 0, 0); AxWin3_RichText_SetCursorType (gMainWindow_TextArea, AXWIN3_RICHTEXT_CURSOR_VLINE); AxWin3_RichText_SetCursorBlink (gMainWindow_TextArea, 1); // <testing> AxWin3_RichText_SetLineCount(gMainWindow_TextArea, 3); AxWin3_RichText_SendLine(gMainWindow_TextArea, 0, "First line!"); AxWin3_RichText_SendLine(gMainWindow_TextArea, 2, "Third line! \x01""ff0000red\x01""00ff00green"); // </testing> AxWin3_ShowWindow(gMainWindow_TextArea, 1); // TODO: Status Bar? AxWin3_MoveWindow(gMainWindow, 50, 50); AxWin3_ShowWindow(gMainWindow, 1); AxWin3_FocusWindow(gMainWindow); // Main loop AxWin3_MainLoop(); AxWin3_DestroyWindow(gMainWindow); return 0; }