#ifndef _GUISLICE_EX_XTEMPLATE_H_ #define _GUISLICE_EX_XTEMPLATE_H_ #include "GUIslice.h" // ======================================================================= // GUIslice library extension: Example template // - Calvin Hass // - https://www.impulseadventure.com/elec/guislice-gui.html // - https://github.com/ImpulseAdventure/GUIslice // ======================================================================= // // The MIT License // // Copyright 2016-2020 Calvin Hass // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // // ======================================================================= /// \file XTemplate.h #ifdef __cplusplus extern "C" { #endif // __cplusplus // ============================================================================ // Extended Element: Example template // ============================================================================ // Define unique identifier for extended element type // - Select any number above GSLC_TYPE_BASE_EXTEND #define GSLC_TYPEX_TEMPLATE GSLC_TYPE_BASE_EXTEND + 12 /// Callback function for slider feedback //typedef bool (*GSLC_CB_XTEMPLATE_POS)(void* pvGui,void* pvElem,int16_t nPos); // Extended element data structures // - These data structures are maintained in the gslc_tsElem // structure via the pXData pointer /// Extended data for Slider element typedef struct { // Config // Style config // State //int16_t nPos; ///< Example position value // Callbacks //GSLC_CB_XTEXTEX_POS pfuncXPos; ///< Callback func ptr for position update } gslc_tsXTemplate; /// /// Create an Extended Text Field Element /// /// \param[in] pGui: Pointer to GUI /// \param[in] nElemId: Element ID to assign (0..16383 or GSLC_ID_AUTO to autogen) /// \param[in] nPage: Page ID to attach element to /// \param[in] pXData: Ptr to extended element data structure /// \param[in] rElem: Rectangle coordinates defining element size /// \param[in] pStrBuf: Ptr to string buffer /// \param[in] nStrBufMax: Maximum buffer alength allocated to pStrBuf /// \param[in] nFontId: ID of font to use for text output /// /// \return Pointer to Element reference or NULL if failure /// gslc_tsElemRef* gslc_ElemXTemplateCreate(gslc_tsGui* pGui, int16_t nElemId, int16_t nPage, gslc_tsXTemplate* pXData, gslc_tsRect rElem, char* pStrBuf, uint8_t nStrBufMax, int16_t nFontId); /// /// Draw the template element on the screen /// - Called from gslc_ElemDraw() /// /// \param[in] pvGui: Void ptr to GUI (typecast to gslc_tsGui*) /// \param[in] pvElemRef: Void ptr to Element (typecast to gslc_tsElemRef*) /// \param[in] eRedraw: Redraw mode /// /// \return true if success, false otherwise /// bool gslc_ElemXTemplateDraw(void* pvGui,void* pvElemRef,gslc_teRedrawType eRedraw); /// /// Handle touch events to template element /// - Called from gslc_ElemSendEventTouch() /// /// \param[in] pvGui: Void ptr to GUI (typecast to gslc_tsGui*) /// \param[in] pvElemRef: Void ptr to Element ref (typecast to gslc_tsElemRef*) /// \param[in] eTouch: Touch event type /// \param[in] nRelX: Touch X coord relative to element /// \param[in] nRelY: Touch Y coord relative to element /// /// \return true if success, false otherwise /// bool gslc_ElemXTemplateTouch(void* pvGui,void* pvElemRef,gslc_teTouch eTouch,int16_t nRelX,int16_t nRelY); // ============================================================================ // ------------------------------------------------------------------------ // Read-only element macros // ------------------------------------------------------------------------ // Macro initializers for Read-Only Elements in Flash/PROGMEM // #ifdef __cplusplus } #endif // __cplusplus #endif // _GUISLICE_EX_XTEMPLATE_H_