📄 listview.h
字号:
/**
* \file listview.h
* \author Wei Yongming <ymwei@minigui.org>
* \date 2002/01/06
*
* The header file of MiniGUI extension library.
*
\verbatim
Copyright (C) 2002-2007 Feynman Software
Copyright (C) 1998-2002 Wei Yongming
All rights reserved by Feynman Software.
This file is part of MiniGUI, a compact cross-platform Graphics
User Interface (GUI) support system for real-time embedded systems.
\endverbatim
*/
/*
* $Id: listview.h 7370 2007-08-16 05:29:44Z xgwang $
*
* MiniGUI for Linux/uClinux, eCos, uC/OS-II, VxWorks,
* pSOS, ThreadX, NuCleus, OSE, and Win32.
*
* Copyright (C) 2002-2007 Feynman Software.
* Copyright (C) 1998-2002 Wei Yongming.
*/
#ifndef EXT_LISTVIEW_H
#define EXT_LISTVIEW_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* \addtogroup mgext_fns
* @{
*/
/**
* \addtogroup mgext_controls
* @{
*/
/**
* \defgroup mgext_ctrl_listview ListView control
* @{
*/
/**
* \def CTRL_LISTVIEW
* \brief The class name of listview control.
*/
#define CTRL_LISTVIEW ("ListView")
/** Listview return value */
#define LV_OKAY 0
/** Listview return value */
#define LV_ERR (-1)
/** Listview return value */
#define LV_ERRSPACE (-2)
/**
* \var typedef GHANDLE HLVITEM
* \brief List view item handle
*/
typedef GHANDLE HLVITEM;
/** list view item flags */
#define LVIF_FOLD 0x0001L
/**
* Structure of the listview item info, contains information about an item.
* This structure is used for creating or retrieving an item.
*/
typedef struct _LVITEM
{
/**
* The rows of the item
*/
int nItem;
/** Height of the item */
int nItemHeight;
/** Attached additional data of this item */
DWORD itemData;
/**
* State flags of the item, can be OR'ed by the following values:
*
* - LVIF_FOLD\n
* The item is folded.
*
* When adding an item to the listview control, only LVIF_FOLD
* flag is valid.
*/
DWORD dwFlags;
} LVITEM;
/** Data type of the pointer to a LVITEM */
typedef LVITEM *PLVITEM;
/** Listview bitmap flags */
#define LVFLAG_BITMAP 0x0001
/** Listview icon flags */
#define LVFLAG_ICON 0x0002
/**
* Struct of the listview subitem info, contains information about a subitem.
* This structure is used for creating or retrieving a subitem.
*/
typedef struct _LVSUBITEM
{
/** Flags of the subitem, can be OR'ed by the following values:
*
* - LVFLAG_BITMAP
* The sub item has a bitmap icon.
* - LVFLAG_ICON
* The sub item has an icon.
*/
DWORD flags;
/** The Subitem vertical position(rows) */
int nItem;
/** The Subitem horizontal position(columns) */
int subItem;
/** Text content of this subitem */
char *pszText;
/** Max text len */
int nTextMax;
/** Text color of the subitem */
int nTextColor;
/** Image of the subitem, can be bitmap or icon, determined by flags */
DWORD image;
} LVSUBITEM;
/** Data type of the pointer to a LVSUBITEM */
typedef LVSUBITEM *PLVSUBITEM;
/** Contains information for sorting listview */
typedef struct _LVSORTDATA
{
/** Sorting column index */
int ncol;
/** Low sorted or high sorted */
int losorted;
/** Listview handle */
HWND hLV;
} LVSORTDATA;
/** Data type of pointer to a LVSORTDATA */
typedef LVSORTDATA *PLVSORTDATA;
/** Type of listview comparision fuction */
typedef int (*PFNLVCOMPARE) (HLVITEM nItem1, HLVITEM nItem2, PLVSORTDATA sortData);
typedef GHANDLE HLVHDR;
typedef GHANDLE HLVHDRITEM;
/** Type of listview header background drawing function */
/* hlvhdr is reserved for extension */
typedef void (*PFN_LVHDR_BKDRAWFUNC) (HWND hWnd, HLVHDR hlvhdr, HDC hdc, RECT *rcDraw);
/** Type of listview header item drawing function */
typedef void (*PFN_LVHDR_ITEMDRAWFUNC) (HWND hWnd, int idx, HDC hdc, RECT *rcDraw);
/** Contains function pointers for customized drawing */
typedef struct _LVCUSTOMDRAWFUNCS
{
/** Colunm header background drawing function */
PFN_LVHDR_BKDRAWFUNC pfnDrawHdrBk;
/** Colunm header item drawing function */
PFN_LVHDR_ITEMDRAWFUNC pfnDrawHdrItem;
} LVCUSTOMDRAWFUNCS;
/** Column flags */
/** Column text left align, default */
#define LVCF_LEFTALIGN 0x0000
/** Column text right align */
#define LVCF_RIGHTALIGN 0x0001
/** Column text center align */
#define LVCF_CENTERALIGN 0x0002
/** Column treeview style */
#define LVCF_TREEVIEW 0x0004
/** Header flags */
/** Header text left align, default */
#define LVHF_LEFTALIGN 0x0000
/** Header text right align */
#define LVHF_RIGHTALIGN 0x0004
/** Header text center align */
#define LVHF_CENTERALIGN 0x0008
/**
* Struct of the listview column info, contains information about a column.
* This structure is used for creating or retrieving a column.
*/
typedef struct _LVCOLUMN
{
/** The horizontal position */
int nCols;
/** Column's width */
int width;
/** The title of this column */
char *pszHeadText;
/** Max text len */
int nTextMax;
/** Image of the column header, can be bitmap or icon */
DWORD image;
/** Comparision function associated with the column */
PFNLVCOMPARE pfnCompare;
/** Column and header flags */
DWORD colFlags;
} LVCOLUMN;
/** Data type of pointer to a LVCOLUMN */
typedef LVCOLUMN *PLVCOLUMN;
/** Listview search flags */
/** Search by text */
#define LVFF_TEXT 0x0001
/** Search by addtional data */
#define LVFF_ADDDATA 0x0002
/** Contains information for finding a certain item info */
typedef struct _LVFINDINFO
{
/**
* Type of search to perform.
* This member can be set to one or more of the following values:
* - LVFF_TEXT
* Searches based on the item(subitems) text.
* - LVFF_ADDDATA
* Searches based on the attached additional item data.
*/
DWORD flags;
/** Search index to begin with, 0 from the beginning */
int iStart;
/** PszInfo containing nCols columns' text */
int nCols;
/** All the subitem's content of this item */
char **pszInfo;
/** The additional item data */
DWORD addData;
/** The found item's row, reserved */
int nItem;
/** The found subitem's column, reserved */
int nSubitem;
} LVFINDINFO;
/** Data type of pointer to a LVFINDINFO */
typedef LVFINDINFO *PLVFINDINFO;
/** Contains listview general notification information */
typedef struct _LVNM_NORMAL
{
/** wParam parameter of the message */
WPARAM wParam;
/** lParam parameter of the message */
LPARAM lParam;
} LVNM_NORMAL;
/** Data type of pointer to a LVNM_NORMAL */
typedef LVNM_NORMAL *PLVNM_NORMAL;
/** Keydown notification information */
typedef LVNM_NORMAL LVNM_KEYDOWN;
/** Data type of pointer to a LVNM_KEYDOWN */
typedef LVNM_KEYDOWN *PLVNM_KEYDOWN;
/** Contains listview notification information when mouse down on the header */
typedef LVNM_NORMAL LVNM_HEADRDOWN;
/** Data type of pointer to a LVNM_HEADRDOWN */
typedef LVNM_HEADRDOWN *PLVNM_HEADRDOWN;
/** Contains listview notification information when mouse up on the header */
typedef LVNM_NORMAL LVNM_HEADRUP;
/** Data type of pointer to a LVNM_HEADRUP */
typedef LVNM_HEADRUP *PLVNM_HEADUP;
/** Contains listview notification information when mouse down on the item area */
typedef LVNM_NORMAL LVNM_ITEMRDOWN;
/** Data type of pointer to a LVNM_ITEMRDOWN */
typedef LVNM_ITEMRDOWN *PLVNM_ITEMRDOWN;
/** Contains listview notification information when mouse up on the item area */
typedef LVNM_NORMAL LVNM_ITEMRUP;
/** Data type of pointer to a LVNM_ITEMRUP */
typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
/**
* \defgroup mgext_ctrl_listview_styles Styles of listview control
* @{
*/
/**
* \def LVS_UPNOTIFY
* \brief Notifies the parent window when mouse is up (default is down).
*
* Causes the listview to notify the listview parent window
* with a notification message when the user make actions, such as clicks, doubleclicks, ...,etc.
*/
#define LVS_UPNOTIFY 0x0001L /* must be the same with SVS_UPNOTIFY */
#define LVS_NOTIFY LVS_UPNOTIFY
/**
* \def LVS_SORT
* \brief Sorts strings automatically.
*
* Causes the listview to sort strings automatically.
*/
#define LVS_SORT 0x0002L
/**
* \def LVS_MULTIPLESEL
* \brief Causes the listview to allow the user to select multiple items.
*/
#define LVS_MULTIPLESEL 0x0008L /* reserved */
/**
* \def LVS_CHECKBOX
* \brief Displays a check box in an item.
*/
#define LVS_CHECKBOX 0x1000L /* reserved */
/**
* \def LVS_AUTOCHECK
* \brief If the list view has LVS_CHECKBOX style, this
* style tell the list view to auto-switch the check box between
* checked or un-checked when the user click the check mark box of an item.
*/
#define LVS_AUTOCHECK 0x2000L /* reserved */
/**
* \def LVS_AUTOCHECKBOX
* \brief If the list view has LVS_AUTOCHECKBOX style, this style tell the list view
* use LVS_CHECKBOX and LVS_AUTOCHECK style.
* */
#define LVS_AUTOCHECKBOX (LVS_CHECKBOX | LVS_AUTOCHECK) /* reserved */
/**
* \def LVS_TREEVIEW
* \brief Uses listview in a treeview style.
*/
#define LVS_TREEVIEW 0x4000L
/** @} end of mgext_ctrl_listview_styles */
/**
* \defgroup mgext_ctrl_listview_msgs Messages of ListView control
* @{
*/
/**
* \def LVM_ADDITEM
* \brief Adds a item to listview, this item is also called a row.
*
* \code
* LVM_ADDITEM
* PLVITEM p
* HLVITEM parent;
*
* wParam = (WPARAM)parent;
* p =(LPARAM)lParam;
* \endcode
*
* \param p Pointes to a LVITEM structure that contains the information of
* the new item to be added. nItem member of the LVITEM struct speficied
* the item position in its parent item, beginning with zero.
* \param parent Handle of the parent item into which the new item is about to insert.
* If parent equals zero, the parent item will be the root of listview.
*
* \return Returns the handle of the new item if successful, or 0 otherwise.
*/
#define LVM_ADDITEM 0xF110
/**
* \def LVM_FILLSUBITEM
* \brief Sets the content of a subitem, indentified by rows and columns.
*
* \code
* LVM_FILLSUBITEM
* PLVSUBITEM p;
* HLVITEM pi;
*
* lParam = (LPARAM)p;
* wParam = (WPARAM)pi;
* \endcode
*
* \param p Pointes to a PLVSUBITEM structure that contains the information of
* the subitem to set. If pi is not zero, nItem member of this struct
* has no meaning.
* \param pi Handle of the target item.
* If pi equals zero, the row position of the target item is
* specified by nItem member of p structure.
*
* \return Returns LV_OKAY if successful, or LV_ERR otherwise.
*/
#define LVM_FILLSUBITEM 0xF111
/**
* \def LVM_ADDCOLUMN
* \brief Adds a new column to listview, indentified by column.
*
* \code
* LVM_ADDCOLUMN
* PLVCOLUMN p;
*
* wParam = 0;
* lParam =(LPARAM)p;
* \endcode
*
* \param p Pointes to a LVCOLUMN structure that contains the information about the new
* column to be added.
*/
#define LVM_ADDCOLUMN 0xF112
/**
* \def LVM_DELITEM
* \brief Deletes an item form listview.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -