// === FUNCTIONS ===
// --- Management
extern tWindow *WM_CreateWindow(tWindow *Parent, int Flags, const char *Renderer);
-extern int WM_Reposition(tWindow *Window, int X, int Y, int W, int H);
-extern int WM_SetFlags(tWindow *Window, int Flags);
+extern void WM_ShowWindow(tWindow *Window, int bShow);
+extern int WM_ResizeWindow(tWindow *Window, int W, int H);
+extern int WM_MoveWindow(tWindow *Window, int X, int Y);
extern int WM_SendMessage(tWindow *Window, int MessageID, int Length, void *Data);
// --- Rendering
extern void WM_Render_FilledRect(tWindow *Window, tColour Colour, int X, int Y, int W, int H);
return 0;
}
+int IPC_Msg_ShowWindow(tIPC_Client *Client, tAxWin_IPCMessage *Msg)
+{
+ tIPCMsg_ShowWindow *info = (void*)Msg->Data;
+ tWindow *win;
+
+ if( Msg->Size < sizeof(*info) ) return -1;
+
+ win = IPC_int_GetWindow(Client, Msg->Window);
+ if(!win) return 1;
+
+ WM_ShowWindow(win, !!info->bShow);
+
+ return 0;
+}
+
+int IPC_Msg_SetWinPos(tIPC_Client *Client, tAxWin_IPCMessage *Msg)
+{
+ tIPCMsg_SetWindowPos *info = (void*)Msg->Data;
+ tWindow *win;
+
+ if(Msg->Size < sizeof(*info)) return -1;
+
+ win = IPC_int_GetWindow(Client, Msg->Window);
+ if(!win) return 1;
+
+ if(info->bSetPos)
+ WM_MoveWindow(win, info->X, info->Y);
+ if(info->bSetDims)
+ WM_ResizeWindow(win, info->W, info->H);
+
+ return 0;
+}
+
void IPC_Handle(const tIPC_Type *IPCType, const void *Ident, size_t MsgLen, tAxWin_IPCMessage *Msg)
{
tIPC_Client *client;
}
break;
- // --- Create window
+ // --- Create window
case IPCMSG_CREATEWIN:
_SysDebug(" IPC_Handle: IPCMSG_CREATEWIN");
IPC_Msg_CreateWin(client, Msg);
break;
-
-// case IPCMSG_SHOWWINDOW:
+ // --- Show/Hide a window
+ case IPCMSG_SHOWWINDOW:
+ _SysDebug(" IPC_Handle: IPCMSG_SHOWWINDOW");
+ IPC_Msg_ShowWindow(client, Msg);
+ break;
+ // --- Move/Resize a window
+ case IPCMSG_SETWINPOS:
+ _SysDebug(" IPC_Handle: IPCMSG_SETWINPOS");
+ IPC_Msg_SetWinPos(client, Msg);
+ break;
// --- Unknown message
default:
gpWM_Renderers = Renderer;
}
+// --- Manipulation
tWindow *WM_CreateWindow(tWindow *Parent, int RendererArg, const char *RendererName)
{
tWMRenderer *renderer;
return ret;
}
+void WM_ShowWindow(tWindow *Window, int bShow)
+{
+ // TODO: Message window
+ if(bShow)
+ Window->Flags |= WINFLAG_SHOW;
+ else
+ Window->Flags &= ~WINFLAG_SHOW;
+}
+
+int WM_MoveWindow(tWindow *Window, int X, int Y)
+{
+ // Clip coordinates
+ if(X + Window->W < 0) X = -Window->W + 1;
+ if(Y + Window->H < 0) Y = -Window->H + 1;
+ if(X >= giScreenWidth) X = giScreenWidth - 1;
+ if(Y >= giScreenHeight) Y = giScreenHeight - 1;
+
+ Window->X = X; Window->Y = Y;
+
+ return 0;
+}
+
+int WM_ResizeWindow(tWindow *Window, int W, int H)
+{
+ if(W <= 0 || H <= 0 ) return 1;
+ if(Window->X + W < 0) Window->X = -W + 1;
+ if(Window->Y + H < 0) Window->Y = -H + 1;
+
+ Window->W = W; Window->H = H;
+
+ return 0;
+}
+
+// --- Rendering / Update
void WM_int_UpdateWindow(tWindow *Window)
{
tWindow *child;
struct sIPCMsg_SetWindowPos
{
- int16_t X;
- int16_t Y;
- uint16_t W;
- uint16_t H;
- uint8_t Fields;
+ int16_t X, Y;
+ uint16_t W, H;
+ uint8_t bSetPos;
+ uint8_t bSetDims;
};
enum eAxWin_IPCMessageTypes
msg = AxWin3_int_AllocateIPCMessage(Window, IPCMSG_SETWINPOS, 0, sizeof(*info));
info = (void*)msg->Data;
- info->Fields = 0xF;
+ info->bSetPos = 1;
+ info->bSetDims = 1;
info->X = X; info->Y = Y;
info->W = W; info->H = H;
msg = AxWin3_int_AllocateIPCMessage(Window, IPCMSG_SETWINPOS, 0, sizeof(*info));
info = (void*)msg->Data;
- info->Fields = 0x3;
+ info->bSetPos = 1;
+ info->bSetDims = 0;
info->X = X;
info->Y = Y;
msg = AxWin3_int_AllocateIPCMessage(Window, IPCMSG_SETWINPOS, 0, sizeof(*info));
info = (void*)msg->Data;
- info->Fields = 0xC;
+ info->bSetPos = 0;
+ info->bSetDims = 1;
info->W = W;
info->H = H;