📄 canvas.h
字号:
//! - \b #CANVAS_STYLE_TEXT_OPAQUE to indicate that the canvas text should be
//! drawn opaque (in other words, drawing the background pixels).
//! - \b #CANVAS_STYLE_TEXT_LEFT to indicate that the canvas text should be
//! left aligned within the widget bounding rectangle.
//! - \b #CANVAS_STYLE_TEXT_HCENTER to indicate that the canvas text should be
//! horizontally centered within the widget bounding rectangle.
//! - \b #CANVAS_STYLE_TEXT_RIGHT to indicate that the canvas text should be
//! right aligned within the widget bounding rectangle.
//! - \b #CANVAS_STYLE_TEXT_TOP to indicate that the canvas text should be
//! top aligned within the widget bounding rectangle.
//! - \b #CANVAS_STYLE_TEXT_VCENTER to indicate that the canvas text should be
//! vertically centered within the widget bounding rectangle.
//! - \b #CANVAS_STYLE_TEXT_BOTTOM to indicate that the canvas text should be
//! bottom aligned within the widget bounding rectangle.
//!
//! \return Nothing; this is not a function.
//
//*****************************************************************************
#define CanvasStruct(pParent, pNext, pChild, pDisplay, lX, lY, lWidth, \
lHeight, ulStyle, ulFillColor, ulOutlineColor, \
ulTextColor, pFont, pcText, pucImage, pfnOnPaint) \
{ \
{ \
sizeof(tCanvasWidget), \
(tWidget *)(pParent), \
(tWidget *)(pNext), \
(tWidget *)(pChild), \
pDisplay, \
{ \
lX, \
lY, \
(lX) + (lWidth) - 1, \
(lY) + (lHeight) - 1 \
}, \
CanvasMsgProc \
}, \
ulStyle, \
ulFillColor, \
ulOutlineColor, \
ulTextColor, \
pFont, \
pcText, \
pucImage, \
pfnOnPaint \
}
//*****************************************************************************
//
//! Declares an initialized variable containing a canvas widget data structure.
//!
//! \param sName is the name of the variable to be declared.
//! \param pParent is a pointer to the parent widget.
//! \param pNext is a pointer to the sibling widget.
//! \param pChild is a pointer to the first child widget.
//! \param pDisplay is a pointer to the display on which to draw the canvas.
//! \param lX is the X coordinate of the upper left corner of the canvas.
//! \param lY is the Y coordinate of the upper left corner of the canvas.
//! \param lWidth is the width of the canvas.
//! \param lHeight is the height of the canvas.
//! \param ulStyle is the style to be applied to the canvas.
//! \param ulFillColor is the color used to fill in the canvas.
//! \param ulOutlineColor is the color used to outline the canvas.
//! \param ulTextColor is the color used to draw text on the canvas.
//! \param pFont is a pointer to the font to be used to draw text on the
//! canvas.
//! \param pcText is a pointer to the text to draw on this canvas.
//! \param pucImage is a pointer to the image to draw on this canvas.
//! \param pfnOnPaint is a pointer to the application function to draw onto
//! this canvas.
//!
//! This macro declares a variable containing an initialized canvas widget data
//! structure, which can be used to construct the widget tree at compile time
//! in global variables (as opposed to run-time via function calls).
//!
//! \e ulStyle is the logical OR of the following:
//!
//! - \b #CANVAS_STYLE_OUTLINE to indicate that the canvas should be outlined.
//! - \b #CANVAS_STYLE_FILL to indicate that the canvas should be filled.
//! - \b #CANVAS_STYLE_TEXT to indicate that the canvas should have text drawn
//! on it (using \e pFont and \e pcText).
//! - \b #CANVAS_STYLE_IMG to indicate that the canvas should have an image
//! drawn on it (using \e pucImage).
//! - \b #CANVAS_STYLE_APP_DRAWN to indicate that the canvas should be drawn
//! with the application-supplied drawing function (using \e pfnOnPaint).
//! - \b #CANVAS_STYLE_TEXT_OPAQUE to indicate that the canvas text should be
//! drawn opaque (in other words, drawing the background pixels).
//! - \b #CANVAS_STYLE_TEXT_LEFT to indicate that the canvas text should be
//! left aligned within the widget bounding rectangle.
//! - \b #CANVAS_STYLE_TEXT_HCENTER to indicate that the canvas text should be
//! horizontally centered within the widget bounding rectangle.
//! - \b #CANVAS_STYLE_TEXT_RIGHT to indicate that the canvas text should be
//! right aligned within the widget bounding rectangle.
//! - \b #CANVAS_STYLE_TEXT_TOP to indicate that the canvas text should be
//! top aligned within the widget bounding rectangle.
//! - \b #CANVAS_STYLE_TEXT_VCENTER to indicate that the canvas text should be
//! vertically centered within the widget bounding rectangle.
//! - \b #CANVAS_STYLE_TEXT_BOTTOM to indicate that the canvas text should be
//! bottom aligned within the widget bounding rectangle.
//!
//! \return Nothing; this is not a function.
//
//*****************************************************************************
#define Canvas(sName, pParent, pNext, pChild, pDisplay, lX, lY, lWidth, \
lHeight, ulStyle, ulFillColor, ulOutlineColor, ulTextColor, \
pFont, pcText, pucImage, pfnOnPaint) \
tCanvasWidget sName = \
CanvasStruct(pParent, pNext, pChild, pDisplay, lX, lY, lWidth, \
lHeight, ulStyle, ulFillColor, ulOutlineColor, \
ulTextColor, pFont, pcText, pucImage, pfnOnPaint)
//*****************************************************************************
//
//! Disables application drawing of a canvas widget.
//!
//! \param pWidget is a pointer to the canvas widget to modify.
//!
//! This function disables the use of the application callback to draw on a
//! canvas widget. The display is not updated until the next paint request.
//!
//! \return None.
//
//*****************************************************************************
#define CanvasAppDrawnOff(pWidget) \
do \
{ \
tCanvasWidget *pW = pWidget; \
pW->ulStyle &= ~(CANVAS_STYLE_APP_DRAWN); \
} \
while(0)
//*****************************************************************************
//
//! Enables application drawing of a canvas widget.
//!
//! \param pWidget is a pointer to the canvas widget to modify.
//!
//! This function enables the use of the application callback to draw on a
//! canvas widget. The display is not updated until the next paint request.
//!
//! \return None.
//
//*****************************************************************************
#define CanvasAppDrawnOn(pWidget) \
do \
{ \
tCanvasWidget *pW = pWidget; \
pW->ulStyle |= CANVAS_STYLE_APP_DRAWN; \
} \
while(0)
//*****************************************************************************
//
//! Sets the function to call when this canvas widget is drawn.
//!
//! \param pWidget is a pointer to the canvas widget to modify.
//! \param pfnOnPnt is a pointer to the function to call.
//!
//! This function sets the function to be called when this canvas is drawn and
//! \b CANVAS_STYLE_APP_DRAWN is selected.
//!
//! \return None.
//
//*****************************************************************************
#define CanvasCallbackSet(pWidget, pfnOnPnt) \
do \
{ \
tCanvasWidget *pW = pWidget; \
pW->pfnOnPaint = pfnOnPnt; \
} \
while(0)
//*****************************************************************************
//
//! Sets the fill color of a canvas widget.
//!
//! \param pWidget is a pointer to the canvas widget to be modified.
//! \param ulColor is the 24-bit RGB color to use to fill the canvas.
//!
//! This function changes the color used to fill the canvas on the display.
//! The display is not updated until the next paint request.
//!
//! \return None.
//
//*****************************************************************************
#define CanvasFillColorSet(pWidget, ulColor) \
do \
{ \
tCanvasWidget *pW = pWidget; \
pW->ulFillColor = ulColor; \
} \
while(0)
//*****************************************************************************
//
//! Disables filling of a canvas widget.
//!
//! \param pWidget is a pointer to the canvas widget to modify.
//!
//! This function disables the filling of a canvas widget. The display is not
//! updated until the next paint request.
//!
//! \return None.
//
//*****************************************************************************
#define CanvasFillOff(pWidget) \
do \
{ \
tCanvasWidget *pW = pWidget; \
pW->ulStyle &= ~(CANVAS_STYLE_FILL); \
} \
while(0)
//*****************************************************************************
//
//! Enables filling of a canvas widget.
//!
//! \param pWidget is a pointer to the canvas widget to modify.
//!
//! This function enables the filling of a canvas widget. The display is not
//! updated until the next paint request.
//!
//! \return None.
//
//*****************************************************************************
#define CanvasFillOn(pWidget) \
do \
{ \
tCanvasWidget *pW = pWidget; \
pW->ulStyle |= CANVAS_STYLE_FILL; \
} \
while(0)
//*****************************************************************************
//
//! Sets the font for a canvas widget.
//!
//! \param pWidget is a pointer to the canvas widget to modify.
//! \param pFnt is a pointer to the font to use to draw text on the canvas.
//!
//! This function changes the font used to draw text on the canvas. The
//! display is not updated until the next paint request.
//!
//! \return None.
//
//*****************************************************************************
#define CanvasFontSet(pWidget, pFnt) \
do \
{ \
tCanvasWidget *pW = pWidget; \
const tFont *pF = pFnt; \
pW->pFont = pF; \
} \
while(0)
//*****************************************************************************
//
//! Changes the image drawn on a canvas widget.
//!
//! \param pWidget is a pointer to the canvas widget to be modified.
//! \param pImg is a pointer to the image to draw onto the canvas.
//!
//! This function changes the image that is drawn onto the canvas. The display
//! is not updated until the next paint request.
//!
//! \return None.
//
//*****************************************************************************
#define CanvasImageSet(pWidget, pImg) \
do \
{ \
tCanvasWidget *pW = pWidget; \
const unsigned char *pI = pImg; \
pW->pucImage = pI; \
} \
while(0)
//*****************************************************************************
//
//! Disables the image on a canvas widget.
//!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -