DEFSYM(sleep),
DEFSYM(waittid),
+ DEFSYM(gettid),
DEFSYM(setuid),
DEFSYM(setgid),
- DEFSYM(gettid),
+ DEFSYM(getuid),
+ DEFSYM(getgid),
DEFSYM(SysSendMessage),
DEFSYM(SysGetMessage),
--- /dev/null
+/*
+ * Acess2 Window Manager v3
+ * - By John Hodge (thePowersGang)
+ *
+ * richtext_messages.h
+ * - Formatted Text Field
+ */
+#ifndef _RICHTEXT_MESSAGES_H_
+#define _RICHTEXT_MESSAGES_H_
+
+enum eRichText_Attrs {
+ _ATTR_DEFBG,
+ _ATTR_DEFFG,
+ _ATTR_SCROLL,
+ _ATTR_LINECOUNT,
+ _ATTR_COLCOUNT,
+ _ATTR_CURSOR,
+ _ATTR_CURSORBLINK,
+ _ATTR_CURSORPOS,
+};
+
+enum
+{
+ // Calls
+ MSG_RICHTEXT_SETATTR,
+ MSG_RICHTEXT_SETFONT,
+ MSG_RICHTEXT_DELLINE,
+ MSG_RICHTEXT_ADDLINE,
+
+ // Events
+
+ MSG_RICHTEXT_SENDLINE, // Bi-directional
+ MSG_RICHTEXT_REQLINE // Bi-directional
+};
+
+struct sRichTextMsg_SetAttr
+{
+ uint32_t Attr;
+ uint32_t Value;
+};
+
+struct sRichTextMsg_SetFont
+{
+ uint16_t Size;
+ char Name[];
+};
+
+struct sRichTextMsg_AddDelLine
+{
+ uint32_t Line;
+};
+
+struct sRichTextMsg_ReqLine
+{
+ uint32_t Line;
+};
+
+struct sRichTextMsg_SendLine
+{
+ uint32_t Line;
+ char LineData[];
+};
+
+#endif
+
{
// Control (Client->Server) messages
MSG_WIDGET_CREATE = 0x1000,
+ MSG_WIDGET_CREATESUBWIN,
MSG_WIDGET_DELETE,
MSG_WIDGET_SETFOCUS,
MSG_WIDGET_SETFLAGS,
char DebugName[];
} tWidgetMsg_Create;
+typedef struct
+{
+ uint32_t Parent;
+ uint32_t NewID;
+ uint32_t Type;
+ uint32_t Flags;
+ uint32_t WindowHandle;
+ char DebugName[];
+} tWidgetMsg_CreateSubWin;
+
typedef struct
{
uint32_t WidgetID;
LDFLAGS += -lc -soname libaxwin3.so
OBJ = main.o msg.o wm.o r_widget.o r_menu.o
+OBJ += r_richtext.o
BIN = libaxwin3.so
include ../../../Libraries/Makefile.tpl
--- /dev/null
+/*
+ * AxWin3 Interface Library
+ * - By John Hodge (thePowersGang)
+ *
+ * r_richtext.c
+ * - Formatted Text window type
+ */
+#include <axwin3/axwin.h>
+#include <axwin3/richtext.h>
+#include "include/internal.h"
+#include <richtext_messages.h>
+
+// === TYPES ===
+typedef struct sRichText_Window
+{
+ tAxWin3_RichText_KeyHandler KeyCallback;
+ tAxWin3_RichText_MouseHandler MouseCallback;
+// tAxWin3_RichText_LineHandler LineHandler;
+} tRichText_Window;
+
+// === CODE ===
+int AxWin3_RichText_MessageHandler(tHWND Window, int MessageID, int Size, void *Data)
+{
+ return 0;
+}
+
+static void _SendAttrib(tHWND Window, int Attr, uint32_t Value)
+{
+ struct sRichTextMsg_SetAttr msg;
+ msg.Attr = Attr;
+ msg.Value = Value;
+ AxWin3_SendMessage(Window, Window, MSG_RICHTEXT_SETATTR, sizeof(msg), &msg);
+}
+
+tHWND AxWin3_RichText_CreateWindow(tHWND Parent, int Flags)
+{
+ tHWND ret = AxWin3_CreateWindow(Parent, "RichText", Flags, sizeof(tRichText_Window), AxWin3_RichText_MessageHandler);
+// tRichText_Window *info = AxWin3_int_GetDataPtr(ret);
+ return ret;
+}
+
+void AxWin3_RichText_SetKeyHandler(tHWND Window, tAxWin3_RichText_KeyHandler Handler)
+{
+ tRichText_Window *info = AxWin3_int_GetDataPtr(Window);
+ info->KeyCallback = Handler;
+}
+
+void AxWin3_RichText_SetMouseHandler(tHWND Window, tAxWin3_RichText_MouseHandler Handler)
+{
+ tRichText_Window *info = AxWin3_int_GetDataPtr(Window);
+ info->MouseCallback = Handler;
+}
+
+void AxWin3_RichText_EnableScroll(tHWND Window, int bEnable)
+{
+ _SendAttrib(Window, _ATTR_SCROLL, bEnable);
+}
+void AxWin3_RichText_SetLineCount(tHWND Window, int Lines)
+{
+ _SendAttrib(Window, _ATTR_LINECOUNT, Lines);
+}
+void AxWin3_RichText_SetColCount(tHWND Window, int Cols)
+{
+ _SendAttrib(Window, _ATTR_COLCOUNT, Cols);
+}
+void AxWin3_RichText_SetBackground(tHWND Window, uint32_t ARGB_Colour)
+{
+ _SendAttrib(Window, _ATTR_DEFBG, ARGB_Colour);
+}
+void AxWin3_RichText_SetDefaultColour(tHWND Window, uint32_t ARGB_Colour)
+{
+ _SendAttrib(Window, _ATTR_DEFFG, ARGB_Colour);
+}
+void AxWin3_RichText_SetFont(tHWND Window, const char *FontName, int PointSize)
+{
+ // TODO: Send message
+}
+void AxWin3_RichText_SetCursorType(tHWND Window, int Type)
+{
+ _SendAttrib(Window, _ATTR_CURSOR, Type);
+}
+void AxWin3_RichText_SetCursorBlink(tHWND Window, int bBlink)
+{
+ _SendAttrib(Window, _ATTR_CURSORBLINK, bBlink);
+}
+void AxWin3_RichText_SetCursorPos(tHWND Window, int Row, int Column)
+{
+ if(Row < 0 || Row > 0xFFFFF || Column > 0xFFF || Column < 0)
+ return ;
+ _SendAttrib(Window, _ATTR_CURSORPOS, ((Row & 0xFFFFF) << 12) | (Column & 0xFFF));
+}
return info->Elements[ID];
}
+uint32_t AxWin3_Widget_int_AllocateID(tWidgetWindowInfo *Info)
+{
+ uint32_t newID;
+ // BUG BUG BUG - Double Allocations! (citation needed)
+ // TODO: Atomicity
+ for( newID = Info->FirstFreeID; newID < Info->nElements; newID ++ )
+ {
+ if( Info->Elements[newID] == NULL )
+ break;
+ }
+ if( newID == Info->nElements )
+ {
+ const int size_step = 4;
+ Info->nElements += 4;
+ Info->Elements = realloc(Info->Elements, sizeof(*Info->Elements)*Info->nElements);
+ newID = Info->nElements - 4;
+ memset( &Info->Elements[newID+1], 0, (size_step-1)*sizeof(Info->Elements));
+ _SysDebug("Expanded to %i and allocated %i", Info->nElements, newID);
+ }
+ else
+ _SysDebug("Allocated %i", newID);
+ Info->Elements[newID] = (void*)-1;
+
+ return newID;
+
+}
+
int AxWin3_Widget_MessageHandler(tHWND Window, int MessageID, int Size, void *Data)
{
tAxWin3_Widget *widget;
info = AxWin3_int_GetDataPtr(Parent->Window);
- // Assign ID
- // BUG BUG BUG - Double Allocations!
- // TODO: Atomicity
- for( newID = info->FirstFreeID; newID < info->nElements; newID ++ )
- {
- if( info->Elements[newID] == NULL )
- break;
- }
- if( newID == info->nElements )
- {
- const int size_step = 4;
- info->nElements += 4;
- info->Elements = realloc(info->Elements, sizeof(*info->Elements)*info->nElements);
- newID = info->nElements - 4;
- memset( &info->Elements[newID+1], 0, (size_step-1)*sizeof(info->Elements));
- _SysDebug("Expanded to %i and allocated %i", info->nElements, newID);
- }
- else
- _SysDebug("Allocated %i", newID);
- info->Elements[newID] = (void*)-1;
+ newID = AxWin3_Widget_int_AllocateID(info);
// Create new widget structure
ret = calloc(sizeof(tAxWin3_Widget), 1);
return ret;
}
+tAxWin3_Widget *AxWin3_Widget_AddWidget_SubWindow(tAxWin3_Widget *Parent, tHWND Window, const char *DebugName)
+{
+ tWidgetWindowInfo *info = AxWin3_int_GetDataPtr(Parent->Window);
+ int newID = AxWin3_Widget_int_AllocateID(info);
+
+ tAxWin3_Widget *ret = calloc(sizeof(tAxWin3_Widget), 1);
+ ret->Window = Parent->Window;
+ ret->ID = newID;
+ info->Elements[newID] = ret;
+
+ // Send message
+ {
+ char tmp[sizeof(tWidgetMsg_CreateSubWin)+1];
+ tWidgetMsg_CreateSubWin *msg = (void*)tmp;
+ msg->Parent = Parent->ID;
+ msg->NewID = newID;
+ msg->Type = ELETYPE_SUBWIN;
+ msg->Flags = 0; // TODO: Flags
+ msg->WindowHandle = AxWin3_int_GetWindowID(Window);
+ msg->DebugName[0] = '\0';
+ AxWin3_SendMessage(ret->Window, ret->Window, MSG_WIDGET_CREATESUBWIN, sizeof(tmp), tmp);
+ }
+
+ return ret;
+}
+
+
void AxWin3_Widget_DelWidget(tAxWin3_Widget *Widget)
{
tWidgetMsg_Delete msg;
add_toolbar_button(gMainWindow_Toolbar, "BtnOpen", Toolbar_Open);
add_toolbar_button(gMainWindow_Toolbar, "BtnOpen", Toolbar_Save);
AxWin3_Widget_AddWidget(gMainWindow_Toolbar, ELETYPE_SPACER, 0, "");
- AxWin3_Widget_AddWidget(gMainWindow_Toolbar, ELETYPE_BUTTON, 0, "BtnUndo");
- AxWin3_Widget_AddWidget(gMainWindow_Toolbar, ELETYPE_BUTTON, 0, "BtnRedo");
+ add_toolbar_button(gMainWindow_Toolbar, "BtnUndo", NULL);
+ add_toolbar_button(gMainWindow_Toolbar, "BtnRedo", NULL);
AxWin3_Widget_AddWidget(gMainWindow_Toolbar, ELETYPE_SPACER, 0, "");
- AxWin3_Widget_AddWidget(gMainWindow_Toolbar, ELETYPE_BUTTON, 0, "BtnCut");
- AxWin3_Widget_AddWidget(gMainWindow_Toolbar, ELETYPE_BUTTON, 0, "BtnCopy");
- AxWin3_Widget_AddWidget(gMainWindow_Toolbar, ELETYPE_BUTTON, 0, "BtnPaste");
+ 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, 0, "");
- AxWin3_Widget_AddWidget(gMainWindow_Toolbar, ELETYPE_BUTTON, 0, "BtnSearch");
- AxWin3_Widget_AddWidget(gMainWindow_Toolbar, ELETYPE_BUTTON, 0, "BtnReplace");
+ add_toolbar_button(gMainWindow_Toolbar, "BtnSearch", NULL);
+ add_toolbar_button(gMainWindow_Toolbar, "BtnReplace", NULL);
// TODO: Tab control?
AxWin3_RichText_SetCursorType (gMainWindow_TextArea, AXWIN3_RICHTEXT_CURSOR_VLINE);
AxWin3_RichText_SetCursorBlink (gMainWindow_TextArea, 1);
// TODO: Status Bar?
-
- // Load a file
- FILE *fp = fopen("", "r");
- if( !fp ) {
- perror("fopen");
- return -1;
- }
- fclose(fp);
+ AxWin3_ShowWindow(gMainWindow, 1);
+
// Main loop
AxWin3_MainLoop();
void add_toolbar_button(tAxWin3_Widget *Toolbar, const char *Ident, tAxWin3_Widget_FireCb Callback)
{
tAxWin3_Widget *btn = AxWin3_Widget_AddWidget(Toolbar, ELETYPE_BUTTON, 0, Ident);
+ // TODO: Get image / text using `Ident` as a lookup key
AxWin3_Widget_SetText(btn, Ident);
+ AxWin3_Widget_SetFireHandler(btn, Callback);
}
+
+int Toolbar_New(tAxWin3_Widget *Widget)
+{
+ return 0;
+}
+int Toolbar_Open(tAxWin3_Widget *Widget)
+{
+ return 0;
+}
+int Toolbar_Save(tAxWin3_Widget *Widget)
+{
+ return 0;
+}
+
AXWIN3_RICHTEXT_CURSOR_INV, // Inverted
};
-tHWND AxWin3_RichText_CreateWindow(tHWND Parent, int Flags);
-void AxWin3_RichText_EnableScroll(tHWND Parent, int bEnable);
-void AxWin3_RichText_SetKeyHandler(tHWND Window, tAxWin3_RichText_KeyHandler Handler);
-void AxWin3_RichText_SetMouseHandler(tHWND Window, tAxWin3_RichText_MouseHandler Handler);
-void AxWin3_RichText_SetBackground(tHWND Window, uint32_t ARGB_Colour);
-void AxWin3_RichText_SetDefaultColour(tHWND Window, uint32_t ARGB_Colour);
-void AxWin3_RichText_SetFont(tHWND Window, const char *FontName, int PointSize);
-void AxWin3_RichText_SetCursorType(tHWND Parent, int Type);
-void AxWin3_RichText_SetCursorBlink(tHWND Parent, int bBlink);
-void AxWin3_RichText_SetCursorPos(tHWND Window, int Row, int Column);
+extern tHWND AxWin3_RichText_CreateWindow(tHWND Parent, int Flags);
+extern void AxWin3_RichText_SetKeyHandler(tHWND Window, tAxWin3_RichText_KeyHandler Handler);
+extern void AxWin3_RichText_SetMouseHandler(tHWND Window, tAxWin3_RichText_MouseHandler Handler);
+extern void AxWin3_RichText_EnableScroll(tHWND Window, int bEnable);
+extern void AxWin3_RichText_SetLineCount(tHWND Window, int Lines);
+extern void AxWin3_RichText_SetColCount(tHWND Window, int Cols);
+extern void AxWin3_RichText_SetBackground(tHWND Window, uint32_t ARGB_Colour);
+extern void AxWin3_RichText_SetDefaultColour(tHWND Window, uint32_t ARGB_Colour);
+extern void AxWin3_RichText_SetFont(tHWND Window, const char *FontName, int PointSize);
+extern void AxWin3_RichText_SetCursorType(tHWND Window, int Type);
+extern void AxWin3_RichText_SetCursorBlink(tHWND Window, int bBlink);
+extern void AxWin3_RichText_SetCursorPos(tHWND Window, int Row, int Column);
#endif