-include ../../Makefile.cfg
-CPPFLAGS += -I../include
+CPPFLAGS +=
LDFLAGS += -laxwin2
DIR = Apps/AxWin/1.0
* - By John Hodge (thePowersGang)
*/
#include <axwin2/axwin.h>
+#include <stdlib.h>
+#include <stdio.h>
// === CONSTANTS ===
enum eTerminal_Events
int main(int argc, char *argv[])
{
tAxWin_Element *menu, *tab;
+
+ if(argc != 1)
+ {
+ fprintf(stderr, "Usage: %s\n", argv[0]);
+ fprintf(stderr, "\tThis application takes no arguments\n");
+ return 0;
+ }
+
AxWin_Register("Terminal", Global_HandleMessage);
menu = AxWin_AddMenuItem(NULL, "File", 0);
*/
int Global_HandleMessage(tAxWin_Message *Message)
{
- return 0;
+ switch(Message->ID)
+ {
+ default:
+ return 0;
+ }
}
int Shell_HandleMessage(tAxWin_Message *Message)
{
- return 0;
+ switch(Message->ID)
+ {
+ default:
+ return 0;
+ }
}
-include ../../Makefile.cfg
-CPPFLAGS += -I../include
+CPPFLAGS +=
DIR := Apps/AxWin/1.0
BIN := AxWinWM
ShowHelp(argv[0]);
exit(EXIT_SUCCESS);
break;
+ default:
+ break;
}
}
}
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
+#include <acess/sys.h> // _SysDebug
+
+typedef void tMessages_Handle_Callback(void*, size_t, void*);
+typedef struct sFont tFont;
#include "wm.h"
#include "image.h"
//#include "font.h"
-typedef struct sFont tFont;
-
// === MACROS ===
static inline uint32_t Video_AlphaBlend(uint32_t _orig, uint32_t _new, uint8_t _alpha)
{
- int ao,ro,go,bo;
- int an,rn,gn,bn;
+ uint16_t ao,ro,go,bo;
+ uint16_t an,rn,gn,bn;
if( _alpha == 0 ) return _orig;
if( _alpha == 255 ) return _new;
}
// === GLOBALS ===
-extern char *gsTerminalDevice;
-extern char *gsMouseDevice;
+extern const char *gsTerminalDevice;
+extern const char *gsMouseDevice;
extern int giScreenWidth;
extern int giScreenHeight;
// === Functions ===
extern void memset32(void *ptr, uint32_t val, size_t count);
+// --- Initialisation ---
+extern void ParseCommandline(int argc, char *argv[]);
+extern void IPC_Init(void);
+extern void IPC_FillSelect(int *nfds, fd_set *set);
+extern void IPC_HandleSelect(fd_set *set);
+extern void Input_FillSelect(int *nfds, fd_set *set);
+extern void Input_HandleSelect(fd_set *set);
// --- Video ---
+extern void Video_Setup(void);
extern void Video_Update(void);
extern void Video_FillRect(short X, short Y, short W, short H, uint32_t Color);
extern void Video_DrawRect(short X, short Y, short W, short H, uint32_t Color);
extern int Video_DrawText(short X, short Y, short W, short H, tFont *Font, uint32_t Color, char *Text);
-extern void Video_DrawImage(short X, short Y, short W, short H, tImage *Image);
-// --- Debug Hack ---
-extern void _SysDebug(const char *Format, ...);
+extern void Video_DrawImage(short X, short Y, short W, short H, tImage *Image);
+// --- Interface ---
+extern void Interface_Init(void);
+extern void Interface_Update(void);
+extern void Interface_Render(void);
+// --- Decorator ---
+extern void Decorator_RenderWidget(tElement *Element);
+
#endif
case ELETYPE_BOX: break; // Box is a meta-element
case ELETYPE_TABBAR: // Tab Bar
+ Video_DrawRect(
+ Element->CachedX, Element->CachedY,
+ Element->CachedW, Element->CachedH,
+ BOX_BORDER
+ );
+ Video_FillRect(
+ Element->CachedX+1, Element->CachedY+1,
+ Element->CachedW-2, Element->CachedH-2,
+ BOX_BGCOLOUR
+ );
+ // Enumerate Items.
+ break;
case ELETYPE_TOOLBAR: // Tool Bar
Video_DrawRect(
Element->CachedX, Element->CachedY,
tElement *gpInterface_TabBar;
tElement *gpInterface_TabContent;
const char csLogoSmall[] = "base64:///"RESOURCE_LogoSmall_sif;
+tApplication *gpInterface_CurrentApp;
+
+typedef struct sApplicationLink tApplicationLink;
+
+struct sApplicationLink {
+ tApplication *App;
+ tElement *Button;
+ char Name[];
+};
// === CODE ===
/**
void Interface_Update(void)
{
+// tApplication *app;
+// tApplicationLink *lnk;
giInterface_Width = giScreenWidth/16;
AxWin_SetSize( gpInterface_Sidebar, giInterface_Width );
+
+ // Scan application list for changes
+ // - HACK for now, just directly access it
+// for( app = gWM_Applications; app; app = app->Next )
+// {
+// AxWin_CreateElement();
+// }
+
+ // Update current tab list
}
void Interface_Render(void)
{
-
Video_FillRect(
0, 0,
giInterface_Width, giScreenHeight,
#include <acess/sys.h>
// === IMPORTS ===
-extern void ParseCommandline(int argc, char *argv[]);
-extern void Video_Setup(void);
extern void WM_Update(void);
-extern void Interface_Init(void);
-extern void IPC_Init(void);
-extern void IPC_FillSelect(int *nfds, fd_set *set);
-extern void IPC_HandleSelect(fd_set *set);
-extern void Input_FillSelect(int *nfds, fd_set *set);
-extern void Input_HandleSelect(fd_set *set);
// === GLOBALS ===
-char *gsTerminalDevice = NULL;
-char *gsMouseDevice = NULL;
+const char *gsTerminalDevice = NULL;
+const char *gsMouseDevice = NULL;
int giScreenWidth = 640;
int giScreenHeight = 480;
#define STATICBUF_SIZE 64
// === TYPES ===
-typedef void tMessages_Handle_Callback(void*, size_t, void*);
// === PROTOTYPES ===
void IPC_Init(void);
void IPC_HandleSelect(fd_set *set);
void Messages_RespondDatagram(void *Ident, size_t Length, void *Data);
void Messages_RespondIPC(void *Ident, size_t Length, void *Data);
-void Messages_Handle(void *Ident, int MsgLen, tAxWin_Message *Msg, tMessages_Handle_Callback *Respond);
+void Messages_Handle(void *Ident, size_t MsgLen, tAxWin_Message *Msg, tMessages_Handle_Callback *Respond);
// === GLOBALS ===
int giNetworkFileHandle = -1;
SysSendMessage( *(tid_t*)Ident, Length, Data );
}
-void Messages_Handle(void *Ident, int MsgLen, tAxWin_Message *Msg, tMessages_Handle_Callback *Respond)
+void Messages_Handle(void *Ident, size_t MsgLen, tAxWin_Message *Msg, tMessages_Handle_Callback *Respond)
{
+ if( MsgLen < sizeof(tAxWin_Message) )
+ return ;
+ if( MsgLen < sizeof(tAxWin_Message) + Msg->Size )
+ return ;
+
switch(Msg->ID)
{
- #if 0
case MSG_SREQ_PING:
+ if( MsgLen < sizeof(tAxWin_Message) + 4 ) return;
Msg->ID = MSG_SRSP_VERSION;
- Msg->Size = 2;
+ Msg->Size = 4;
Msg->Data[0] = 0;
Msg->Data[1] = 1;
*(uint16_t*)&Msg->Data[2] = -1;
Respond(Ident, sizeof(Msg->ID), Msg);
break;
- #endif
+
+ case MSG_SREQ_REGISTER:
+ if( Msg->Len == strnlen(Msg->Len, Msg->Data) ) {
+ // Special handling?
+ return ;
+ }
+
+ break;
+
default:
fprintf(stderr, "WARNING: Unknown message %i (%p)\n", Msg->ID, Respond);
_SysDebug("WARNING: Unknown message %i (%p)\n", Msg->ID, Respond);
{
int r, g, b, a; // New
int or, og, ob; // Original
- for( x = 0; x < W; x ++ ) {
+ for( x = 0; x < W; x ++ )
+ {
b = data[x*4+0]; g = data[x*4+1]; r = data[x*4+2]; a = data[x*4+3];
if( a == 0 ) continue; // 100% transparent
ob = buf[x*4+0]; og = buf[x*4+1]; or = buf[x*4+2];
case IMGFMT_RGB:
for( y = 0; y < H; y ++ )
{
- for( x = 0; x < W; x ++ ) {
+ for( x = 0; x < W; x ++ )
+ {
buf[x*4+0] = data[x*3+2]; // Blue
buf[x*4+1] = data[x*3+1]; // Green
buf[x*4+2] = data[x*3+0]; // Red
buf += giScreenWidth * 4;
}
break;
+ default:
+ _SysDebug("ERROR: Unknown image format %i\n", Image->Format);
+ break;
}
}
* Acess GUI (AxWin) Version 2
* By John Hodge (thePowersGang)
*/
+#include <acess/sys.h>
#include "common.h"
typedef struct sGlyph {
// === PROTOTYPES ===
int Video_DrawText(short X, short Y, short W, short H, tFont *Font, uint32_t Color, char *Text);
+void Video_GetTextDims(tFont *Font, const char *Text, int *W, int *H);
tGlyph *_GetGlyph(tFont *Font, uint32_t Codepoint);
void _RenderGlyph(short X, short Y, tGlyph *Glyph, uint32_t Color);
tGlyph *_SystemFont_CacheGlyph(tFont *Font, uint32_t Codepoint);
#include <stdlib.h>
#include <string.h>
#include "wm.h"
+#include <acess/sys.h> // _SysDebug
// === IMPORTS ===
extern void Decorator_RenderWidget(tElement *Element);
void WM_Update(void);
// === GLOBALS ===
+// - TODO: Handle windows by having multiple root elements
tElement gWM_RootElement = {
.DebugName = "ROOT"
};
+
+tApplication *gWM_Applications;
+
+// --- Element type flags
struct {
void (*Init)(tElement *This);
void (*UpdateFlags)(tElement *This);
void AxWin_DeleteElement(tElement *Element)
{
// TODO: Implement AxWin_DeleteElement
+ free(Element);
}
/**
}
}
break;
+ default: // Any other, no special case
+ break ;
}
return ;
*/
/**
* \brief Updates the dimensions of an element
+ * \todo What is the \a Pass parameter for
*
* The dimensions of an element are calculated from the parent's
* cross dimension (the side at right angles to the alignment) sans some
else
child->CachedW = with;
- WM_UpdateDimensions(child, 0);
+ WM_UpdateDimensions(child, Pass);
}
_SysDebug("%p'%s' Done", Element, Element->DebugName);
#define _WM_H_
#include <axwin2/axwin.h>
+#include "common.h"
typedef struct sAxWin_Element tElement;
+typedef struct sTab tTab;
+typedef struct sApplication tApplication;
struct sAxWin_Element
{
char DebugName[];
};
-typedef struct sTab
+struct sTab
{
int Type; // Should be zero, allows a tab to be the parent of an element
tElement *Parent;
tElement *FirstChild;
tElement *LastChild;
- struct sTab *NextTab;
+ tTab *NextTab;
char *Name;
tElement *RootElement;
-} tTab;
+};
-typedef struct sApplication
+struct sApplication
{
- pid_t PID;
+ tApplication *Next;
+
+ void *Ident;
+ tMessages_Handle_Callback *SendMessage;
int nTabs;
tTab *Tabs;
+ tTab *CurrentTab;
char Name[];
-} tApplication;
+};
#endif
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);
*/
enum eAxWin_Messages
{
- // Server Requests
+ // Client->Server Requests
MSG_SREQ_PING,
// - Windows
MSG_SREQ_REGISTER, // bool (char[] Name) - Registers this PID with the Window Manager
MSG_SREQ_ADDTAB, // TAB (char[] Name) - Adds a tab to the window
MSG_SREQ_DELTAB, // void (TAB Tab) - Closes a tab
+ MSG_SREQ_SETICON // void (TAB Tab, char[] IconURI) - Set the icon of a tab (or application)
+
MSG_SREQ_NEWDIALOG, // DIALOG (TAB Parent, char[] Name) - Creates a dialog
MSG_SREQ_DELDIALOG, // void (DIALOG Dialog) - Closes a dialog
MSG_SREQ_RIMG, MSG_SREQ_SIMG, // Register/Set Image
MSG_SREQ_SETFONT, MSG_SREQ_PUTTEXT,
- // Server Responses
+ // Server->Client Responses
MSG_SRSP_VERSION,
MSG_SRSP_RETURN, // {int RequestID, void[] Return Value} - Returns a value from a server request
*/
struct sAxWin_Message
{
+ uint32_t Source;
uint16_t ID;
- uint16_t Size; //!< Size in DWORDS
+ uint16_t Size; // Size of data
char Data[];
};