GUIslice  0.16.0
Embedded GUI in C
XTextbox.c File Reference
#include "GUIslice.h"
#include "GUIslice_drv.h"
#include "elem/XTextbox.h"
#include <stdio.h>
Include dependency graph for XTextbox.c:

Functions

gslc_tsElemRefgslc_ElemXTextboxCreate (gslc_tsGui *pGui, int16_t nElemId, int16_t nPage, gslc_tsXTextbox *pXData, gslc_tsRect rElem, int16_t nFontId, char *pBuf, uint16_t nBufRows, uint16_t nBufCols)
 Create a Textbox Element. More...
 
void gslc_ElemXTextboxReset (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef)
 Reset the contents of the textbox. More...
 
void gslc_ElemXTextboxLineWrAdv (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef)
 
void gslc_ElemXTextboxScrollSet (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, uint8_t nScrollPos, uint8_t nScrollMax)
 Set the textbox scroll position (nScrollPos) as a fraction of nScrollMax. More...
 
void gslc_ElemXTextboxBufAdd (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, unsigned char chNew, bool bAdvance)
 
void gslc_ElemXTextboxColSet (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, gslc_tsColor nCol)
 Insert a color set code into the current buffer position. More...
 
void gslc_ElemXTextboxColReset (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef)
 Insert a color reset code into the current buffer position. More...
 
void gslc_ElemXTextboxWrapSet (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, bool bWrapEn)
 Enable or disable line wrap within textbox. More...
 
void gslc_ElemXTextboxAdd (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, char *pTxt)
 Add a text string to the textbox. More...
 
bool gslc_ElemXTextboxDraw (void *pvGui, void *pvElemRef, gslc_teRedrawType eRedraw)
 Draw a Textbox element on the screen. More...
 

Variables

const char GSLC_PMEM ERRSTR_NULL []
 
const char GSLC_PMEM ERRSTR_PXD_NULL []
 

Function Documentation

void gslc_ElemXTextboxAdd ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
char *  pTxt 
)

Add a text string to the textbox.

  • If it includes a newline then the buffer will advance to the next row
  • If wrap has been enabled, then a newline will be forced
Parameters
[in]pGuiPointer to GUI
[in]pElemRefPointer to Element reference
[in]pTxtPointer to text string (null-terminated)
Returns
none
void gslc_ElemXTextboxBufAdd ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
unsigned char  chNew,
bool  bAdvance 
)
void gslc_ElemXTextboxColReset ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef 
)

Insert a color reset code into the current buffer position.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPointer to Element reference
Returns
none
void gslc_ElemXTextboxColSet ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
gslc_tsColor  nCol 
)

Insert a color set code into the current buffer position.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPointer to Element reference
[in]nColColor to assign for next text written to textbox
Returns
none
gslc_tsElemRef* gslc_ElemXTextboxCreate ( gslc_tsGui pGui,
int16_t  nElemId,
int16_t  nPage,
gslc_tsXTextbox pXData,
gslc_tsRect  rElem,
int16_t  nFontId,
char *  pBuf,
uint16_t  nBufRows,
uint16_t  nBufCols 
)

Create a Textbox Element.

  • The textbox is a scrolling window designed for displaying multi-line text using a monospaced font. A character buffer is defined by nBufRows*nBufCols to capture the added text. If the allocation buffer is larger than the display size (defined by rElem), then a scrollbar will be shown.
  • Support for changing color within a row can be enabled with GSLC_FEATURE_XTEXTBOX_EMBED 1
  • Note that each color change command will consume 4 of the available "column" bytes.
Parameters
[in]pGuiPointer to GUI
[in]nElemIdElement ID to assign (0..16383 or GSLC_ID_AUTO to autogen)
[in]nPagePage ID to attach element to
[in]pXDataPtr to extended element data structure
[in]rElemRectangle coordinates defining textbox size
[in]nFontIdFont ID to use for text area
[in]pBufPtr to text buffer (already allocated) with size (nBufRows*nBufCols) chars
[in]nBufRowsNumber of rows in buffer
[in]nBufColsNumber of columns in buffer (incl special codes)
Returns
Pointer to Element reference or NULL if failure
bool gslc_ElemXTextboxDraw ( void *  pvGui,
void *  pvElemRef,
gslc_teRedrawType  eRedraw 
)

Draw a Textbox element on the screen.

Parameters
[in]pvGuiVoid ptr to GUI (typecast to gslc_tsGui*)
[in]pvElemRefVoid ptr to Element reference (typecast to gslc_tsElemRef*)
[in]eRedrawRedraw mode
Returns
true if success, false otherwise
void gslc_ElemXTextboxLineWrAdv ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef 
)
void gslc_ElemXTextboxReset ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef 
)

Reset the contents of the textbox.

  • Clears the buffer and resets the position
Parameters
[in]pGuiPointer to GUI
[in]pElemRefPointer to Element reference
Returns
none
void gslc_ElemXTextboxScrollSet ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
uint8_t  nScrollPos,
uint8_t  nScrollMax 
)

Set the textbox scroll position (nScrollPos) as a fraction of nScrollMax.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPointer to Element reference
[in]nScrollPosNew scroll position
[in]nScrollMaxMaximum scroll position
Returns
none
void gslc_ElemXTextboxWrapSet ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
bool  bWrapEn 
)

Enable or disable line wrap within textbox.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPointer to Element reference
[in]bWrapEnEnable line wrap if true
Returns
none

Variable Documentation

const char GSLC_PMEM ERRSTR_NULL[]
const char GSLC_PMEM ERRSTR_PXD_NULL[]