AxWin_AddMenuItem(menu, "&Close Tab\tCtrl-Shift-W", EVENT_CLOSE_TAB);
AxWin_AddMenuItem(menu, "E&xit\tAlt-F4", EVENT_EXIT);
- tab = AxWin_CreateTab("root@acess: ~");
+ tab = AxWin_CreateWindow("root@acess: ~");
//geConsole = AxWin_CreateElement();
AxWin_MessageLoop();
extern tApplication *AxWin_RegisterClient(tIPC_Type *Method, void *Ident, const char *Name);
extern void AxWin_DeregisterClient(tApplication *App);
extern tApplication *AxWin_GetClient(tIPC_Type *Method, void *Ident);
+extern tElement *AxWin_CreateAppWindow(tApplication *App, const char *Name);
// --- Video ---
extern void Video_Setup(void);
extern void Video_Update(void);
void IPC_FillSelect(int *nfds, fd_set *set);
void IPC_HandleSelect(fd_set *set);
void IPC_Handle(tIPC_Type *IPCType, void *Ident, size_t MsgLen, tAxWin_Message *Msg);
+void IPC_ReturnValue(tIPC_Type *IPCType, void *Ident, int MessageID, uint32_t Value);
int IPC_Type_Datagram_GetSize(void *Ident);
int IPC_Type_Datagram_Compare(void *Ident1, void *Ident2);
void IPC_Type_Datagram_Send(void *Ident, size_t Length, void *Data);
void IPC_Handle(tIPC_Type *IPCType, void *Ident, size_t MsgLen, tAxWin_Message *Msg)
{
tApplication *app;
+ tElement *ele;
if( MsgLen < sizeof(tAxWin_Message) )
return ;
return ;
}
+ ele = AxWin_CreateAppWindow(app, Msg->Data);
+ IPC_ReturnValue(IPCType, Ident, MSG_SREQ_ADDWIN, ele->ApplicationID);
break;
+ // --- Set a window's icon
+ case MSG_SREQ_SETICON:
+ // TODO: Find a good way of implementing this
+ break;
+
+ // --- Create an element
+ case MSG_SREQ_INSERT: {
+ struct sAxWin_SReq_NewElement *info = (void *)Msg->Data;
+
+ if( Msg->Size != sizeof(*info) ) return;
+
+ if( !app || info->Parent > app->MaxElementIndex ) return ;
+
+ ele = AxWin_CreateElement( app->EleIndex[info->Parent], info->Type, info->Flags, NULL );
+ IPC_ReturnValue(IPCType, Ident, MSG_SREQ_ADDWIN, ele->ApplicationID);
+ break; }
+
// --- Unknown message
default:
fprintf(stderr, "WARNING: Unknown message %i (%p)\n", Msg->ID, IPCType);
}
}
+void IPC_ReturnValue(tIPC_Type *IPCType, void *Ident, int MessageID, uint32_t Value)
+{
+ char data[sizeof(tAxWin_Message) + sizeof(tAxWin_RetMsg)];
+ tAxWin_Message *msg = (void *)data;
+ tAxWin_RetMsg *ret_msg = (void *)msg->Data;
+
+ msg->Source = 0; // 0 = Server
+ msg->ID = MSG_SRSP_RETURN;
+ msg->Size = sizeof(tAxWin_RetMsg);
+ ret_msg->ReqID = MessageID;
+ ret_msg->Rsvd = 0;
+ ret_msg->Value = Value;
+
+ IPCType->SendMessage(Ident, sizeof(data), data);
+}
+
int IPC_Type_Datagram_GetSize(void *Ident)
{
return 4 + Net_GetAddressSize( ((uint16_t*)Ident)[1] );
return NULL;
}
-tElement *AxWin_CreateWindow(tApplication *App, const char *Name)
+tElement *AxWin_CreateAppWindow(tApplication *App, const char *Name)
{
tElement *ret;
-
- // TODO: Implement _CreateTab
ret = AxWin_CreateElement(&App->MetaElement, ELETYPE_WINDOW, 0, NULL);
ret->Text = strdup(Name);
strcpy(req.Data, Name);
msg = AxWin_int_SendAndWait(MSG_SRSP_RETURN, &req);
- ret = ((tAxWin_RetMsg*)msg->Data)->Bool;
+ ret = ((tAxWin_RetMsg*)msg->Data)->Value;
free(msg);
gAxWin_DefaultCallback = DefaultCallback;
return !!ret;
}
-tAxWin_Element *AxWin_CreateTab(const char *Title)
+tAxWin_Element *AxWin_CreateWindow(const char *Title)
{
tAxWin_Message req;
tAxWin_Message *msg;
strcpy(req.Data, Title);
msg = AxWin_int_SendAndWait(MSG_SRSP_RETURN, &req);
- ret = (tAxWin_Element*) ((tAxWin_RetMsg*)msg->Data)->Handle;
+ ret = (tAxWin_Element*) ((tAxWin_RetMsg*)msg->Data)->Value;
free(msg);
return ret;
// === Core Types ===
typedef struct sAxWin_Element tAxWin_Element;
-//typedef struct sAxWin_Message tAxWin_Message;
typedef int tAxWin_MessageCallback(tAxWin_Message *);
-//typedef int tAxWin_MessageCallback(void *Source, int Message, int Length, void *Data);
// === Functions ===
extern int AxWin_Register(const char *ApplicationName, tAxWin_MessageCallback *DefaultHandler);
-extern tAxWin_Element *AxWin_CreateTab(const char *TabTitle);
+extern tAxWin_Element *AxWin_CreateWindow(const char *TabTitle);
extern tAxWin_Element *AxWin_AddMenuItem(tAxWin_Element *Parent, const char *Label, int Message);
extern int AxWin_MessageLoop(void);
MSG_SREQ_REGISTER, // bool (char[] Name) - Registers this PID with the Window Manager
MSG_SREQ_ADDWIN, // ELEMENT (char[] Name) - Adds a tab to the window
- MSG_SREQ_DELWIN, // void (ELEMENT Tab) - Closes a tab
MSG_SREQ_SETICON, // void (TAB Tab, char[] IconURI) - Set the icon of a tab (or application)
MSG_SREQ_GETNAME, // char[] (ELEMENT Element)
// - Builtin Elements
- MSG_SREQ_INSERT, // void (ELEMENT Parent, eAxWin_Controls Type, u32 Flags)
+ MSG_SREQ_INSERT, // ELEMENT (ELEMENT Parent, eAxWin_Controls Type, u32 Flags)
+ MSG_SREQ_DELETE, // void (ELEMENT Element)
// - Drawing
// All drawing functions take an ELEMENT as their first parameter.
- // This must be either a Tab, Dialog or Canvas control
+ // This must be either a Window or Canvas control
MSG_SREQ_SETCOL,
MSG_SREQ_PSET,
MSG_SREQ_LINE, MSG_SREQ_CURVE,
uint32_t Flags;
};
+struct sAxWin_SReq_NewElement
+{
+ uint16_t Parent;
+ uint16_t Type;
+ uint32_t Flags;
+};
+
// --- Server Responses
/**
uint16_t Build;
};
-/**
- * \brief Server Response - New Window
- * \see eAxWin_Messages.MSG_SRSP_NEWWINDOW
- */
-struct sAxWin_SRsp_NewWindow
-{
- uint32_t Handle;
-};
-
// === Core Message Structure
/**
{
uint16_t ReqID;
uint16_t Rsvd;
- union
- {
- uint8_t Bool;
- uint32_t Handle;
- int Integer;
- };
+ uint32_t Value;
};
#endif