GUIslice  0.16.0
Embedded GUI in C
Internal: Element Functions
Collaboration diagram for Internal: Element Functions:

Functions

gslc_tsElem gslc_ElemCreate (gslc_tsGui *pGui, int16_t nElemId, int16_t nPageId, int16_t nType, gslc_tsRect rElem, char *pStrBuf, uint8_t nStrBufMax, int16_t nFontId)
 Create a new element with default styling. More...
 
gslc_tsElemRefgslc_ElemAdd (gslc_tsGui *pGui, int16_t nPageId, gslc_tsElem *pElem, gslc_teElemRefFlags eFlags)
 Add the Element to the list of generated elements in the GUI environment. More...
 
uint8_t gslc_GetElemRefFlag (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, uint8_t nFlagMask)
 Get the flags associated with an element reference. More...
 
void gslc_SetElemRefFlag (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, uint8_t nFlagMask, uint8_t nFlagVal)
 Set the flags associated with an element reference. More...
 
gslc_tsElemgslc_GetElemFromRef (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef)
 Returns a pointer to an element from an element reference, copying from FLASH to RAM if element is stored in PROGMEM. More...
 
gslc_tsElemgslc_GetElemFromRefD (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, int16_t nLineNum)
 Returns a pointer to an element from an element reference. More...
 
void * gslc_GetXDataFromRef (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, int16_t nType, int16_t nLineNum)
 Returns a pointer to the data structure associated with an extended element. More...
 
void gslc_ElemSetImage (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, gslc_tsImgRef sImgRef, gslc_tsImgRef sImgRefSel)
 Set an element to use a bitmap image. More...
 
bool gslc_ElemDrawByRef (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, gslc_teRedrawType eRedraw)
 Draw an element to the active display. More...
 
void gslc_ElemDraw (gslc_tsGui *pGui, int16_t nPageId, int16_t nElemId)
 Draw an element to the active display. More...
 
void gslc_DrawTxtBase (gslc_tsGui *pGui, char *pStrBuf, gslc_tsRect rTxt, gslc_tsFont *pTxtFont, gslc_teTxtFlags eTxtFlags, int8_t eTxtAlign, gslc_tsColor colTxt, gslc_tsColor colBg, int16_t nMarginW, int16_t nMarginH)
 Draw text with full text justification. More...
 
void gslc_SetRoundRadius (gslc_tsGui *pGui, uint8_t nRadius)
 Set the global rounded radius. More...
 

Detailed Description

Function Documentation

void gslc_DrawTxtBase ( gslc_tsGui pGui,
char *  pStrBuf,
gslc_tsRect  rTxt,
gslc_tsFont pTxtFont,
gslc_teTxtFlags  eTxtFlags,
int8_t  eTxtAlign,
gslc_tsColor  colTxt,
gslc_tsColor  colBg,
int16_t  nMarginW,
int16_t  nMarginH 
)

Draw text with full text justification.

  • This function is usually only required by internal GUIslice rendering operations but is made available for custom element usage as well
Parameters
[in]pGuiPointer to GUI
[in]pStrBufPointer to text string buffer
[in]rTxtRectangle region to contain the text
[in]pTxtFontPointer to the font
[in]eTxtFlagsText string attributes
[in]eTxtAlignText alignment / justification mode
[in]colTxtText foreground color
[in]colBgText background color
[in]nMarginWHorizontal margin within rect region to keep text away
[in]nMarginHVertical margin within rect region to keep text away
Returns
none
gslc_tsElemRef* gslc_ElemAdd ( gslc_tsGui pGui,
int16_t  nPageId,
gslc_tsElem pElem,
gslc_teElemRefFlags  eFlags 
)

Add the Element to the list of generated elements in the GUI environment.

  • NOTE: The content of pElem is copied so the pointer can be released after the call.
Parameters
[in]pGuiPointer to GUI
[in]nPageIdPage ID to add element to (GSLC_PAGE_NONE to skip in case of temporary creation for compound elements)
[in]pElemPointer to Element to add
[in]eFlagsFlags describing the element (eg. whether the element should be stored in internal RAM array or is located in Flash/PROGMEM).
Returns
Pointer to Element reference or NULL if fail
gslc_tsElem gslc_ElemCreate ( gslc_tsGui pGui,
int16_t  nElemId,
int16_t  nPageId,
int16_t  nType,
gslc_tsRect  rElem,
char *  pStrBuf,
uint8_t  nStrBufMax,
int16_t  nFontId 
)

Create a new element with default styling.

Parameters
[in]pGuiPointer to GUI
[in]nElemIdUser-supplied ID for referencing this element (or GSLC_ID_AUTO to auto-generate)
[in]nPageIdThe page ID on which this page should be associated
[in]nTypeEnumeration that indicates the type of element that is requested for creation. The type adjusts the visual representation and default styling.
[in]rElemRectangle region framing the element
[in]pStrBufString to copy into element
[in]nStrBufMaxMaximum length of string buffer (pStrBuf). Only applicable if GSLC_LOCAL_STR=0. Ignored if GSLC_LOCAL_STR=1.)
[in]nFontIdFont ID for textual elements
Returns
Initialized structure
void gslc_ElemDraw ( gslc_tsGui pGui,
int16_t  nPageId,
int16_t  nElemId 
)

Draw an element to the active display.

  • Element is referenced by a page ID and element ID
  • Provides similar functionality as ElemDrawByRef() but accepts page and element IDs
Parameters
[in]pGuiPointer to GUI
[in]nPageIdID of page containing element
[in]nElemIdID of element
Returns
none
bool gslc_ElemDrawByRef ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
gslc_teRedrawType  eRedraw 
)

Draw an element to the active display.

  • Element is referenced by an element pointer
Parameters
[in]pGuiPointer to GUI
[in]pElemRefPtr to Element reference to draw
[in]eRedrawRedraw mode
Returns
true if success, false otherwise
void gslc_ElemSetImage ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
gslc_tsImgRef  sImgRef,
gslc_tsImgRef  sImgRefSel 
)

Set an element to use a bitmap image.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPointer to Element reference to update
[in]sImgRefImage reference (normal state)
[in]sImgRefSelImage reference (glowing state)
Returns
none
gslc_tsElem* gslc_GetElemFromRef ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef 
)

Returns a pointer to an element from an element reference, copying from FLASH to RAM if element is stored in PROGMEM.

This function enables all APIs to work with Elements irrespective of whether they were created in RAM or Flash.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPointer to Element Reference
Returns
Pointer to Element after ensuring that it is accessible from RAM
gslc_tsElem* gslc_GetElemFromRefD ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
int16_t  nLineNum 
)

Returns a pointer to an element from an element reference.

This is a wrapper for GetElemFromRef() including debug checking for invalid pointers.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPointer to Element Reference
[in]nLineNumLine number from calling function (ie. LINE)
Returns
Pointer to Element after ensuring that it is accessible from RAM
uint8_t gslc_GetElemRefFlag ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
uint8_t  nFlagMask 
)

Get the flags associated with an element reference.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefElement reference pointer
[in]nFlagMaskFlags to read
Returns
Values associated with the element reference flags (subject to the flag mask)
void* gslc_GetXDataFromRef ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
int16_t  nType,
int16_t  nLineNum 
)

Returns a pointer to the data structure associated with an extended element.

  • Example usage: gslc_tsXListbox* pListbox = (gslc_tsXListbox*)gslc_GetXDataFromRef(pGui, pElemRef, GSLC_TYPEX_LISTBOX, LINE);
Parameters
[in]pGuiPointer to GUI
[in]pElemRefPointer to Element Reference
[in]nTypeExpected type indicator (ie. GSLC_TYPEX_*)
[in]nLineNumLine number from calling function (ie. LINE)
Returns
Void pointer to extended data (pXData), or NULL if error. Needs to be typecasted accordingly.
void gslc_SetElemRefFlag ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
uint8_t  nFlagMask,
uint8_t  nFlagVal 
)

Set the flags associated with an element reference.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefElement reference pointer
[in]nFlagMaskFlags to read
[in]nFlagValValues to assign to masked flags
Returns
none
void gslc_SetRoundRadius ( gslc_tsGui pGui,
uint8_t  nRadius 
)

Set the global rounded radius.

  • Used for rounded rectangles
Parameters
[in]pGuiPointer to GUI
[in]nRadiusRadius for rounded elements
Returns
none