From: John Hodge Date: Mon, 30 May 2011 12:51:52 +0000 (+0800) Subject: AxWin - Re-structured to share headers between clients and server X-Git-Tag: rel0.10~91 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=43992cf707ec82f8ffd3a1500ad5952640335a6d;p=tpg%2Facess2.git AxWin - Re-structured to share headers between clients and server --- diff --git a/Usermode/Applications/axwin2_src/WM/interface.c b/Usermode/Applications/axwin2_src/WM/interface.c index 8d62c67d..65632bb1 100644 --- a/Usermode/Applications/axwin2_src/WM/interface.c +++ b/Usermode/Applications/axwin2_src/WM/interface.c @@ -33,57 +33,57 @@ void Interface_Init(void) giInterface_Width = giScreenWidth/16; // Set root window to no-border - WM_SetFlags(NULL, 0); + AxWin_SetFlags(NULL, 0); // -- Create Sidebar (Menu and Window List) -- - gpInterface_Sidebar = WM_CreateElement(NULL, ELETYPE_TOOLBAR, ELEFLAG_VERTICAL, "Sidebar"); - WM_SetSize( gpInterface_Sidebar, giInterface_Width ); + gpInterface_Sidebar = AxWin_CreateElement(NULL, ELETYPE_TOOLBAR, ELEFLAG_VERTICAL, "Sidebar"); + AxWin_SetSize( gpInterface_Sidebar, giInterface_Width ); // > System Menu Button - btn = WM_CreateElement(gpInterface_Sidebar, ELETYPE_BUTTON, ELEFLAG_NOSTRETCH, "SystemMenu"); - WM_SetSize(btn, giInterface_Width-4); - //text = WM_CreateElement(btn, ELETYPE_IMAGE, ELEFLAG_SCALE, "MenuLogo"); - text = WM_CreateElement(btn, ELETYPE_IMAGE, 0, "MenuLogo"); - //WM_SetText(text, "file:///LogoSmall.sif"); - WM_SetText(text, csLogoSmall); + btn = AxWin_CreateElement(gpInterface_Sidebar, ELETYPE_BUTTON, ELEFLAG_NOSTRETCH, "SystemMenu"); + AxWin_SetSize(btn, giInterface_Width-4); + //text = AxWin_CreateElement(btn, ELETYPE_IMAGE, ELEFLAG_SCALE, "MenuLogo"); + text = AxWin_CreateElement(btn, ELETYPE_IMAGE, 0, "MenuLogo"); + //AxWin_SetText(text, "file:///LogoSmall.sif"); + AxWin_SetText(text, csLogoSmall); // > Plain
style spacer - ele = WM_CreateElement(gpInterface_Sidebar, ELETYPE_SPACER, ELEFLAG_NOSTRETCH, "SideBar Spacer Top"); - WM_SetSize(ele, 4); + ele = AxWin_CreateElement(gpInterface_Sidebar, ELETYPE_SPACER, ELEFLAG_NOSTRETCH, "SideBar Spacer Top"); + AxWin_SetSize(ele, 4); // > Application List (Window list on most OSs) - gpInterface_ProgramList = WM_CreateElement(gpInterface_Sidebar, ELETYPE_BOX, ELEFLAG_VERTICAL, "ProgramList"); + gpInterface_ProgramList = AxWin_CreateElement(gpInterface_Sidebar, ELETYPE_BOX, ELEFLAG_VERTICAL, "ProgramList"); // > Plain
style spacer - ele = WM_CreateElement(gpInterface_Sidebar, ELETYPE_SPACER, ELEFLAG_NOSTRETCH, "SideBar Spacer Bottom"); - WM_SetSize(ele, 4); + ele = AxWin_CreateElement(gpInterface_Sidebar, ELETYPE_SPACER, ELEFLAG_NOSTRETCH, "SideBar Spacer Bottom"); + AxWin_SetSize(ele, 4); // > Version/Time - text = WM_CreateElement(gpInterface_Sidebar, ELETYPE_TEXT, ELEFLAG_NOSTRETCH, "Version String"); - WM_SetSize(text, 20); - WM_SetText(text, "2.0"); + text = AxWin_CreateElement(gpInterface_Sidebar, ELETYPE_TEXT, ELEFLAG_NOSTRETCH, "Version String"); + AxWin_SetSize(text, 20); + AxWin_SetText(text, "2.0"); // -- // -- Create Main Area and regions within -- // -- // > Righthand Area - gpInterface_MainArea = WM_CreateElement(NULL, ELETYPE_BOX, ELEFLAG_VERTICAL, "MainArea"); + gpInterface_MainArea = AxWin_CreateElement(NULL, ELETYPE_BOX, ELEFLAG_VERTICAL, "MainArea"); // > Header Bar (Title) - gpInterface_HeaderBar = WM_CreateElement(gpInterface_MainArea, ELETYPE_BOX, 0, "HeaderBar"); - WM_SetSize(gpInterface_HeaderBar, giInterface_HeaderBarSize); - text = WM_CreateElement(gpInterface_HeaderBar, ELETYPE_TEXT, 0, NULL); - WM_SetText(text, "Acess2 GUI - By thePowersGang (John Hodge)"); + gpInterface_HeaderBar = AxWin_CreateElement(gpInterface_MainArea, ELETYPE_BOX, 0, "HeaderBar"); + AxWin_SetSize(gpInterface_HeaderBar, giInterface_HeaderBarSize); + text = AxWin_CreateElement(gpInterface_HeaderBar, ELETYPE_TEXT, 0, NULL); + AxWin_SetText(text, "Acess2 GUI - By thePowersGang (John Hodge)"); // > Tab Bar (Current windows) - gpInterface_TabBar = WM_CreateElement(gpInterface_MainArea, ELETYPE_TABBAR, 0, "TabBar"); - WM_SetSize(gpInterface_TabBar, giInterface_TabBarSize); + gpInterface_TabBar = AxWin_CreateElement(gpInterface_MainArea, ELETYPE_TABBAR, 0, "TabBar"); + AxWin_SetSize(gpInterface_TabBar, giInterface_TabBarSize); // > Application Space - gpInterface_TabContent = WM_CreateElement(gpInterface_MainArea, ELETYPE_BOX, 0, "TabContent"); + gpInterface_TabContent = AxWin_CreateElement(gpInterface_MainArea, ELETYPE_BOX, 0, "TabContent"); } void Interface_Update(void) { giInterface_Width = giScreenWidth/16; - WM_SetSize( gpInterface_Sidebar, giInterface_Width ); + AxWin_SetSize( gpInterface_Sidebar, giInterface_Width ); } void Interface_Render(void) diff --git a/Usermode/Applications/axwin2_src/WM/wm.c b/Usermode/Applications/axwin2_src/WM/wm.c index e2b0d231..e4d45b5c 100644 --- a/Usermode/Applications/axwin2_src/WM/wm.c +++ b/Usermode/Applications/axwin2_src/WM/wm.c @@ -14,11 +14,12 @@ extern void Decorator_RenderWidget(tElement *Element); extern void Video_GetTextDims(tFont *Font, const char *Text, int *W, int *H); // === PROTOTYPES === -tElement *WM_CreateElement(tElement *Parent, int Type, int Flags, const char *DebugName); +tElement *AxWin_CreateElement(tElement *Parent, int Type, int Flags, const char *DebugName); +void AxWin_DeleteElement(tElement *Element); +void AxWin_SetFlags(tElement *Element, int Flags); +void AxWin_SetSize(tElement *Element, int Size); +void AxWin_SetText(tElement *Element, const char *Text); void WM_UpdateMinDims(tElement *Element); -void WM_SetFlags(tElement *Element, int Flags); -void WM_SetSize(tElement *Element, int Size); -void WM_SetText(tElement *Element, const char *Text); void WM_UpdateDimensions(tElement *Element, int Pass); void WM_UpdatePosition(tElement *Element); void WM_RenderWidget(tElement *Element); @@ -40,7 +41,7 @@ struct { // === CODE === // --- Widget Creation and Control --- -tElement *WM_CreateElement(tElement *Parent, int Type, int Flags, const char *DebugName) +tAxWin_Element *AxWin_CreateElement(tElement *Parent, int Type, int Flags, const char *DebugName) { tElement *ret; const char *dbgName = DebugName ? DebugName : ""; @@ -74,10 +75,18 @@ tElement *WM_CreateElement(tElement *Parent, int Type, int Flags, const char *De return ret; } +/** + * \brief + */ +void AxWin_DeleteElement(tElement *Element) +{ + // TODO: Implement AxWin_DeleteElement +} + /** * \brief Alter an element's flags */ -void WM_SetFlags(tElement *Element, int Flags) +void AxWin_SetFlags(tElement *Element, int Flags) { // Permissions are handled in the message handler if(!Element) { @@ -89,7 +98,7 @@ void WM_SetFlags(tElement *Element, int Flags) return ; } -void WM_SetSize(tElement *Element, int Size) +void AxWin_SetSize(tElement *Element, int Size) { if(!Element) return ; Element->FixedWith = Size; @@ -100,7 +109,7 @@ void WM_SetSize(tElement *Element, int Size) * \brief Set the text field of an element * \note Used for the image path on ELETYPE_IMAGE */ -void WM_SetText(tElement *Element, const char *Text) +void AxWin_SetText(tElement *Element, const char *Text) { if(!Element) return ; if(Element->Text) free(Element->Text); diff --git a/Usermode/Applications/axwin2_src/WM/wm.h b/Usermode/Applications/axwin2_src/WM/wm.h index 565697d7..9ce35443 100644 --- a/Usermode/Applications/axwin2_src/WM/wm.h +++ b/Usermode/Applications/axwin2_src/WM/wm.h @@ -2,14 +2,18 @@ #ifndef _WM_H_ #define _WM_H_ -typedef struct sElement +#include + +typedef struct sAxWin_Element tElement; + +struct sAxWin_Element { int Type; - struct sElement *Parent; - struct sElement *FirstChild; - struct sElement *LastChild; - struct sElement *NextSibling; + tElement *Parent; + tElement *FirstChild; + tElement *LastChild; + tElement *NextSibling; short PaddingL, PaddingR; short PaddingT, PaddingB; @@ -33,15 +37,16 @@ typedef struct sElement short CachedW, CachedH; char DebugName[]; -} tElement; +}; typedef struct sTab { int Type; // Should be zero, allows a tab to be the parent of an element - struct sElement *Parent; - struct sElement *FirstChild; - struct sElement *LastChild; + tElement *Parent; + tElement *FirstChild; + tElement *LastChild; + struct sTab *NextTab; char *Name; @@ -58,100 +63,4 @@ typedef struct sApplication char Name[]; } tApplication; -// === CONSTANTS === -enum eElementFlags -{ - /** - * \brief Rendered - * - * If set, the element will be ignored in calculating sizes and - * rendering. - */ - ELEFLAG_NORENDER = 0x001, - /** - * \brief Element visibility - * - * If set, the element is not drawn (but still is used for size calculations) - */ - ELEFLAG_INVISIBLE = 0x002, - - /** - * \brief Position an element absulutely (ignored in size calcs) - */ - ELEFLAG_ABSOLUTEPOS = 0x004, - - /** - * \brief Fixed size element - */ - ELEFLAG_FIXEDSIZE = 0x008, - - /** - * \brief Element "orientation" - * - * Vertical means that the children of this element are stacked, - * otherwise they list horizontally - */ - ELEFLAG_VERTICAL = 0x010,// ELEFLAG_HORIZONTAL = 0x000, - /** - * \brief Action for text that overflows - */ - ELEFLAG_WRAP = 0x020,// ELEFLAG_NOWRAP = 0x000, - /** - * \brief Cross size action - * - * If this flag is set, the element will only be as large (across - * its parent) as is needed to encase the contents of the element. - * Otherwise, the element will expand to fill all avaliable space. - */ - ELEFLAG_NOEXPAND = 0x040, - - /** - * \brief With (length) size action - * If this flag is set, the element will only be as large as - * is required along it's parent - */ - ELEFLAG_NOSTRETCH = 0x080, - - /** - * \brief Center alignment - */ - ELEFLAG_ALIGN_CENTER= 0x100, - /** - * \brief Right/Bottom alignment - * - * If set, the element aligns to the end of avaliable space (instead - * of the beginning) - */ - ELEFLAG_ALIGN_END = 0x200 -}; - -/** - */ -enum eElementTypes -{ - ELETYPE_NONE, - - ELETYPE_BOX, //!< Content box (invisible in itself) - ELETYPE_TABBAR, //!< Tab Bar - ELETYPE_TOOLBAR, //!< Tool Bar - - ELETYPE_BUTTON, //!< Push Button - - ELETYPE_TEXT, //!< Text - ELETYPE_IMAGE, //!< Image - - ELETYPE_SPACER, //!< Visual Spacer (horizontal / vertical rule) - - MAX_ELETYPES = 0x100 -}; - -// === FUNCTIONS === -/** - * \brief Create a new element as a child of \a Parent - */ -extern tElement *WM_CreateElement(tElement *Parent, int Type, int Flags, const char *DebugName); -extern void WM_SetFlags(tElement *Element, int Flags); -extern void WM_SetSize(tElement *Element, int Size); -extern void WM_SetText(tElement *Element, const char *Text); - #endif diff --git a/Usermode/include/axwin2/axwin.h b/Usermode/include/axwin2/axwin.h index 9b147968..ad5b76d9 100644 --- a/Usermode/include/axwin2/axwin.h +++ b/Usermode/include/axwin2/axwin.h @@ -28,6 +28,97 @@ extern int AxWin_HandleMessage(tAxWin_Message *Message); // === Window Control === -extern tAxWin_Element *AxWin_CreateElement(int ElementType); +extern tAxWin_Element *AxWin_CreateElement(tAxWin_Element *Parent, int ElementType, int Flags, const char *DebugName); +extern void AxWin_SetFlags(tAxWin_Element *Element, int Flags); +extern void AxWin_SetText(tAxWin_Element *Element, const char *Text); +extern void AxWin_SetSize(tAxWin_Element *Element, int Size); +extern void AxWin_DeleteElement(tAxWin_Element *Element); + +// === CONSTANTS === +enum eElementFlags +{ + /** + * \brief Rendered + * + * If set, the element will be ignored in calculating sizes and + * rendering. + */ + ELEFLAG_NORENDER = 0x001, + /** + * \brief Element visibility + * + * If set, the element is not drawn (but still is used for size calculations) + */ + ELEFLAG_INVISIBLE = 0x002, + + /** + * \brief Position an element absulutely (ignored in size calcs) + */ + ELEFLAG_ABSOLUTEPOS = 0x004, + + /** + * \brief Fixed size element + */ + ELEFLAG_FIXEDSIZE = 0x008, + + /** + * \brief Element "orientation" + * + * Vertical means that the children of this element are stacked, + * otherwise they list horizontally + */ + ELEFLAG_VERTICAL = 0x010,// ELEFLAG_HORIZONTAL = 0x000, + /** + * \brief Action for text that overflows + */ + ELEFLAG_WRAP = 0x020,// ELEFLAG_NOWRAP = 0x000, + /** + * \brief Cross size action + * + * If this flag is set, the element will only be as large (across + * its parent) as is needed to encase the contents of the element. + * Otherwise, the element will expand to fill all avaliable space. + */ + ELEFLAG_NOEXPAND = 0x040, + + /** + * \brief With (length) size action + * If this flag is set, the element will only be as large as + * is required along it's parent + */ + ELEFLAG_NOSTRETCH = 0x080, + + /** + * \brief Center alignment + */ + ELEFLAG_ALIGN_CENTER= 0x100, + /** + * \brief Right/Bottom alignment + * + * If set, the element aligns to the end of avaliable space (instead + * of the beginning) + */ + ELEFLAG_ALIGN_END = 0x200 +}; + +/** + */ +enum eElementTypes +{ + ELETYPE_NONE, + + ELETYPE_BOX, //!< Content box (invisible in itself) + ELETYPE_TABBAR, //!< Tab Bar + ELETYPE_TOOLBAR, //!< Tool Bar + + ELETYPE_BUTTON, //!< Push Button + + ELETYPE_TEXT, //!< Text + ELETYPE_IMAGE, //!< Image + + ELETYPE_SPACER, //!< Visual Spacer (horizontal / vertical rule) + + MAX_ELETYPES = 0x100 +}; #endif