#ifndef _WM_RENDERER_H_
#define _WM_RENDERER_H_
-typedef struct
+typedef struct sWMRenderer
{
+ /**
+ * \brief Internal pointer to next loaded renderer
+ */
+ struct sWMRenderer *Next;
+
+ /**
+ * \brief Renderer name / identifier
+ */
+ const char *Name;
+
+ /**
+ * \brief Initialise a window structure for the renderer
+ * \param W Width of the new window
+ * \param H Height of the new window
+ * \param Flags Flags for the window
+ * \return malloc()'d window structure, or NULL on error
+ * \note Only the fields \a W and \a H need be filled in the window
+ * structure, the rest will be filled by the caller.
+ */
tWindow (*InitWindow)(int W, int H, int Flags);
+
+ /**
+ * \brief Redraw a window on the screen
+ * \param Window Window to render
+ *
+ * Called when a window needs to be re-rendered, e.g. when it is uncovered or
+ * repositioned.
+ *
+ * \todo List all conditions for Redraw
+ */
void (*Redraw)(tWindow *Window);
+
+ /**
+ * \brief Handle a message sent to the window using WM_SendMessage
+ * \param Window Target window
+ * \param MessageID Implementation defined message ID (usually the command)
+ * \param Length Length of the buffer \a Data
+ * \param Data Implementation defined data buffer
+ */
int (*SendMessage)(tWindow *Window, int MessageID, int Length, void *Data);
} tWMRenderer;
#include <common.h>
#include <wm_renderer.h>
+// === PROTOTYPES ===
+tWindow *Renderer_Class_Create(int Width, int Height, int Flags);
+void Renderer_Class_Redraw(tWindow *Window);
+int Renderer_Class_HandleMessage(tWindow *Target, int Msg, int Len, void *Data);
+
// === GLOBALS ===
tWMRenderer gRenderer_Class = {
+ .Name = "Classful",
.CreateWindow = Renderer_Class_Create,
.Redraw = Renderer_Class_Redraw,
- .SendMessage = Renderer_Class_SendMessage
+ .HandleMessage = Renderer_Class_HandleMessage
};
// === CODE ===
int Renderer_Class_Init(void)
{
+ WM_RegisterRenderer(&gRenderer_Class);
+
return 0;
}
+tWindow *Renderer_Class_Create(int Width, int Height, int Flags)
+{
+ // TODO: Add info
+ return WM_CreateWindowStruct(0);
+}
+
+void Renderer_Class_Redraw(tWindow *Window)
+{
+
+}
+
+int Renderer_Class_HandleMessage(tWindow *Target, int Msg, int Len, void *Data)
+{
+ tClassfulInfo *info = Target->RendererInfo;
+ switch(Msg)
+ {
+ case MSG_CLASSFUL_SETBGCOLOUR:
+ if( Len != sizeof(uint32_t) ) return -1;
+ info->BGColour = *(uint32_t*)Data;
+ break;
+
+ case MSG_CLASSFUL_SETTEXT:
+
+ break;
+ }
+}
// === GLOBALS ===
tWMRenderer gRenderer_Passthru = {
+ .Name = "Passthru",
.CreateWindow = Renderer_Passthru_Create,
.Redraw = Renderer_Passthru_Redraw,
.SendMessage = Renderer_Passthru_SendMessage