📄 listbox.h
字号:
//! - \b #LISTBOX_STYLE_WRAP to indicate that the listbox should discard the
//! oldest string it contains if asked to add a new string while the string
//! table is already full.
//!
//! \return Nothing; this is not a function.
//
//*****************************************************************************
#define ListBoxStruct(pParent, pNext, pChild, pDisplay, lX, lY, lWidth, \
lHeight, ulStyle, ulBgColor, ulSelBgColor, \
ulTextColor, ulSelTextColor, ulOutlineColor, pFont, \
ppcText, usMaxEntries, usPopulatedEntries, \
pfnOnChange) \
{ \
{ \
sizeof(tListBoxWidget), \
(tWidget *)(pParent), \
(tWidget *)(pNext), \
(tWidget *)(pChild), \
pDisplay, \
{ \
lX, \
lY, \
(lX) + (lWidth) - 1, \
(lY) + (lHeight) - 1 \
}, \
ListBoxMsgProc \
}, \
ulStyle, \
ulBgColor, \
ulSelBgColor, \
ulTextColor, \
ulSelTextColor, \
ulOutlineColor, \
pFont, \
ppcText, \
usMaxEntries, \
usPopulatedEntries, \
(short)0xFFFF, \
0, \
0, \
0, \
0, \
pfnOnChange \
}
//*****************************************************************************
//
//! Declares an initialized variable containing a listbox 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 listbox.
//! \param lX is the X coordinate of the upper left corner of the listbox.
//! \param lY is the Y coordinate of the upper left corner of the listbox.
//! \param lWidth is the width of the listbox.
//! \param lHeight is the height of the listbox.
//! \param ulStyle is the style to be applied to the listbox.
//! \param ulBgColor is the background color for the listbox.
//! \param ulSelBgColor is the background color for the selected element in the
//! listbox.
//! \param ulTextColor is the color used to draw text on the listbox.
//! \param ulSelTextColor is the color used to draw the selected element
//! text in the listbox.
//! \param ulOutlineColor is the color used to outline the listbox.
//! \param pFont is a pointer to the font to be used to draw text on the
//! listbox.
//! \param ppcText is a pointer to the string table for the listbox.
//! \param usMaxEntries provides the number of entries in the \e ppcText array
//! and represents the maximum number of strings the listbox can hold.
//! \param usPopulatedEntries indicates the number of entries in the \e ppcText
//! array that currently hold valid string for the listbox.
//! \param pfnOnChange is a pointer to the application callback for the listbox.
//!
//! This macro declares a variable containing an initialized listbox 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 #LISTBOX_STYLE_OUTLINE to indicate that the listbox should be outlined.
//! - \b #LISTBOX_STYLE_LOCKED to indicate that the listbox should ignore user
//! input and merely display its contents.
//! - \b #LISTBOX_STYLE_WRAP to indicate that the listbox should discard the
//! oldest string it contains if asked to add a new string while the string
//! table is already full.
//!
//! \return Nothing; this is not a function.
//
//*****************************************************************************
#define ListBox(sName, pParent, pNext, pChild, pDisplay, lX, lY, lWidth, \
lHeight, ulStyle, ulBgColor, ulSelBgColor, ulTextColor, \
ulSelTextColor, ulOutlineColor, pFont, ppcText, usMaxEntries,\
usPopulatedEntries, pfnOnChange) \
tListBoxWidget sName = \
ListBoxStruct(pParent, pNext, pChild, pDisplay, lX, lY, lWidth, lHeight, \
ulStyle, ulBgColor, ulSelBgColor, ulTextColor, \
ulSelTextColor, ulOutlineColor, pFont, ppcText, \
usMaxEntries, usPopulatedEntries, pfnOnChange)
//*****************************************************************************
//
//! Sets the function to call when the listbox selection changes.
//!
//! \param pWidget is a pointer to the listbox widget to modify.
//! \param pfnCallback is a pointer to the function to call.
//!
//! This function sets the function to be called when the selected element in
//! this listbox changes. If style \b #LISTBOX_STYLE_LOCKED is selected, or
//! the callback function pointer set is NULL, no callbacks will be made.
//!
//! \return None.
//
//*****************************************************************************
#define ListBoxCallbackSet(pWidget, pfnCallback) \
do \
{ \
tListBoxWidget *pW = pWidget; \
pW->pfnOnChange = pfnCallback; \
} \
while(0)
//*****************************************************************************
//
//! Sets the background color of a listbox widget.
//!
//! \param pWidget is a pointer to the listbox widget to be modified.
//! \param ulColor is the 24-bit RGB color to use for the listbox background.
//!
//! This function changes the color used for the listbox background on the
//! display. The display is not updated until the next paint request.
//!
//! \return None.
//
//*****************************************************************************
#define ListBoxBackgroundColorSet(pWidget, ulColor) \
do \
{ \
tListBoxWidget *pW = pWidget; \
pW->ulBackgroundColor = ulColor; \
} \
while(0)
//*****************************************************************************
//
//! Sets the background color of the selected element in a listbox widget.
//!
//! \param pWidget is a pointer to the listbox widget to be modified.
//! \param ulColor is the 24-bit RGB color to use for the background of the
//! selected element.
//!
//! This function changes the color used for the background of the selected
//! line of text on the display. The display is not updated until the next
//! paint request.
//!
//! \return None.
//
//*****************************************************************************
#define ListBoxSelectedBackgroundColorSet(pWidget, ulColor) \
do \
{ \
tListBoxWidget *pW = pWidget; \
pW->ulSelectedBackgroundColor = ulColor; \
} \
while(0)
//*****************************************************************************
//
//! Sets the font for a listbox widget.
//!
//! \param pWidget is a pointer to the listbox widget to modify.
//! \param pFnt is a pointer to the font to use to draw text on the listbox.
//!
//! This function changes the font used to draw text on the listbox. The
//! display is not updated until the next paint request.
//!
//! \return None.
//
//*****************************************************************************
#define ListBoxFontSet(pWidget, pFnt) \
do \
{ \
tListBoxWidget *pW = pWidget; \
const tFont *pF = pFnt; \
pW->pFont = pF; \
} \
while(0)
//*****************************************************************************
//
//! Sets the outline color of a listbox widget.
//!
//! \param pWidget is a pointer to the listbox widget to be modified.
//! \param ulColor is the 24-bit RGB color to use to outline the listbox.
//!
//! This function changes the color used to outline the listbox on the display.
//! The display is not updated until the next paint request.
//!
//! \return None.
//
//*****************************************************************************
#define ListBoxOutlineColorSet(pWidget, ulColor) \
do \
{ \
tListBoxWidget *pW = pWidget; \
pW->ulOutlineColor = ulColor; \
} \
while(0)
//*****************************************************************************
//
//! Disables outlining of a listbox widget.
//!
//! \param pWidget is a pointer to the listbox widget to modify.
//!
//! This function disables the outlining of a listbox widget. The display is
//! not updated until the next paint request.
//!
//! \return None.
//
//*****************************************************************************
#define ListBoxOutlineOff(pWidget) \
do \
{ \
tListBoxWidget *pW = pWidget; \
pW->ulStyle &= ~(LISTBOX_STYLE_OUTLINE); \
} \
while(0)
//*****************************************************************************
//
//! Enables outlining of a listbox widget.
//!
//! \param pWidget is a pointer to the listbox widget to modify.
//!
//! This function enables the outlining of a listbox widget. The display is not
//! updated until the next paint request.
//!
//! \return None.
//
//*****************************************************************************
#define ListBoxOutlineOn(pWidget) \
do \
{ \
tListBoxWidget *pW = pWidget; \
pW->ulStyle |= LISTBOX_STYLE_OUTLINE; \
} \
while(0)
//*****************************************************************************
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -