📄 pplistview.h
字号:
#ifndef __GUIPP_LISTVIEW_H__
#define __GUIPP_LISTVIEW_H__
#include "compileSwitch.h"
#include "Wnd.h"
//#include "ppButton.h"
#include "../eeb_app/eeb.h"
#if _USE_GUI == 1
#define LSIT_STYLE_BLACKTITLE 0x00010000
#define LIST_STYLE_SYMBIAN 0x00020000
#define LIST_STYLE_THIN_FRAME 0x00000001
#define LIST_STYLE_THICK_FRAME 0x00000002
#define LIST_STYLE_ICON 0x00000004
#define LIST_STYLE_REPORT 0x00000008
#define LIST_STYLE_STRUCT 0x00000010
#define LIST_FRAME_WIDTH 2
#define LIST_TOP_MARGIN 1
#define LIST_LEFT_MARGIN 1 // only for LSIT_STYLE_BLACKTITLE
#define LIST_RIGHT_MARGIN 1
#define LIST_BOTTOM_MARGIN 1
#define LIST_SCROLL_WIDTH 25 // only for LSIT_STYLE_BLACKTITLE
#define LIST_COLUMN_MARGIN 1
#define LIST_CAPTION_LEFT_MARGIN 2
#define LIST_CAPTION_TOP_MARGIN 1
#define LIST_CAPTION_BOTTOM_MARGIN 1
#define LIST_CAPTION_RIGHT_MARGIN 1
#define LIST_CAPTION_TEXT_MARGIN 1
#define LIST_SELECT_TOP_WIDTH 1
#define LIST_SELECT_BOTTOM_WIDTH 2
#define LIST_SELECT_LEFT_WIDTH 1
#define LIST_SELECT_RIGHT_WIDTH 2
#define LIST_LEFT_TO_SELECT_MARGIN 1
#define LIST_RIGHT_TO_SELECT_MARGIN 1
#define LIST_TOP_TO_SELECT_MARGIN 1
#define LIST_BOTTOM_TO_SELECT_MARGIN 1 // only for LSIT_STYLE_BLACKTITLE
#define LIST_MIN_SCROBALL_LEN 4
#define LIST_RIGHT_LINE_WIDTH 1 // only for LSIT_STYLE_SYMBIAN
#define LIST_RIGHT_LINE_MARGIN 5 // only for LSIT_STYLE_SYMBIAN
#define LIST_SYMBIAN_SCROLL_WIDTH 5 // only for LSIT_STYLE_SYMBIAN
class CListView;
#define ICONITEM_TXT_STYLE_AUTO 0x00 // Only select a inilized one
#define ICONITEM_TXT_STYLE_ONLYSTR 0x01 // Only display text by string
#define ICONITEM_TXT_STYLE_ONLYID 0x02 // Only display text by ID
#define ICONITEM_TXT_STYLE_STR_ID 0x03 // First display string text ,then ID text
#define ICONITEM_TXT_STYLE_ID_STR 0x04 // First diaplay ID text ,then string text
class TextItem
{
public:
int w_nTextStyle;
char * w_strText;
int w_strID;
int w_nData;
NANA_FONT w_Font;
TextItem(void)
{
w_strText = NULL;
w_strID = -1;
}
~TextItem()
{
if(NULL != w_strText)
{
delete w_strText;
}
}
void GetItemText(char * pTxt ,int nBufferSize);
};
class IconItem: public TextItem
{
public:
int w_nIcon;
};
/*
this is base listitem,from the viewpoint of NANAListView
each item is a virtual object with specified size and
can draw it self. NANAListView will only manage each item's
position and call there Draw() function.
*/
#define ITEMSTATE_NORMAL 0x00
#define ITEMSTATE_SELECTED 0x01
#define ITEMSTATE_HIGHLIGHT 0x02
class NANAListBase;
class NANAListItemBase:public CLinkListNode
{
public:
NANAListBase * w_ParentList;
virtual ~NANAListItemBase();
NANAListItemBase();
void SetParentList(NANAListBase * pList);
//called by NANAListView to draw item at specified location
virtual void Draw(NANARect rc,int bState,int nStyle);
//called by NANAListView to calculate rectangle area of item
//differnt styles of item will have different size
//
// (*p_width)
// >0:means item will take width of (*p_width)
// <0:means item will take whole line
// (*p_height)
// must be >0
//
virtual void GetSize(int *p_width,int *p_height);
};
#define ItemFrameMargin 2
class NANAListIconItem:public NANAListItemBase
{
public:
NANAListIconItem()
{
}
~NANAListIconItem()
{
}
// w_strText and w_strID both used for string text when they are initialized
// but w_strID have higher priority
IconItem w_IconData;
void SetItemFont(NANA_FONT font);
void SetItemIcon(int nIconID);
void SetItemText(char * pTxt);
void SetItemTextID(int nStringID);
void SetItemData(int nData);
virtual void GetSize(int *p_width,int *p_height);
virtual void Draw(NANARect rc,int bState,int nStyle);
};
class NANAListTextItem:public NANAListItemBase
{
private:
TextItem * w_pSubItem;
int w_nSubItemNum;
int w_nTextStyle;
public:
int GetSubItemNum(void)
{
return w_nSubItemNum;
}
void SetTextStyle(int nStyle)
{
int i;
w_nTextStyle = nStyle;
for(i=0;i<w_nSubItemNum;i++)
{
w_pSubItem[i].w_nTextStyle = w_nTextStyle;
}
}
NANAListTextItem(void)
{
w_nTextStyle = ICONITEM_TXT_STYLE_AUTO;
w_pSubItem = NULL;
}
// Realloc the sub item
void SetSubItemNum(int nSubItemNum);
NANAListTextItem(int nSubItem)
{
int i;
w_nTextStyle = ICONITEM_TXT_STYLE_AUTO;
w_nSubItemNum = nSubItem;
w_pSubItem = new TextItem[nSubItem];
for(i=0;i<w_nSubItemNum;i++)
{
w_pSubItem[i].w_strText = NULL;
w_pSubItem[i].w_strID = -1;
w_pSubItem[i].w_Font = &NANA_FONT16x;
w_pSubItem[i].w_nTextStyle = w_nTextStyle;
}
}
~NANAListTextItem()
{
if( NULL != w_pSubItem )
{
delete []w_pSubItem;
}
}
void SetItemFont(NANA_FONT font);
void SetTextStyle(int nSubItem, int nTextStyle);
void SetItemText(int nSubItem, char * pTxt);
void SetItemTextID(int nSubItem, int nStringID);
// We think that the Item can only display one line text;
// And the text in the line have same font
virtual void GetSize(int *p_width,int *p_height);
virtual void Draw(NANARect rc,int bState,int nStyle);
};
//Big ICON and a line of caption below
#define MAX_COLUMN 10
class NANAListBase: public NANAWnd
{
friend class NANAListItemBase;
protected:
NANAListItemBase w_ListHeader; //该节点既是列表头,又是列表项的头
NANAListItemBase w_ListTail; //该节点是节点链表末尾
int w_nItemCount;
int w_nSelectedItem; //被选中ITEM,-1表示没有项目被选中
int w_nColumnWidth[MAX_COLUMN];//
char w_cTitle[MAX_COLUMN];
int w_nColumnCount;
NANA_FONT w_Font;
int w_nFirstDisplayItem; // 当前需要绘制的第一Item
int w_nItemPerLine; // 每行绘制多少Item
int w_nDisplayLines; // 绘制多少行
int w_nDisplayItems; // 一共需要绘制多少Item
private:
int w_nRealWidth; // 每个Grid真是占据的宽度和高度
int w_nRealHeight;
NANARect w_GridRc;
int w_bMouseDownOnScrollBar_Up;
int w_bMouseDownOnScrollBar_Down;
NANARect w_ScrollUpRc; //滚动条按钮位置
NANARect w_ScrollDownRc;
public:
int w_ItemStyle;
int w_style;
int NeedScrollBar(void);
void Draw_ScrollBar(NANARect rcBar,float fDisplayPercent,float fFirstItemPercent);
void DrawListBoxTitle(NANARect rc);
NANAListBase();
~NANAListBase();
void SetColumnCaption(int nColumn,int nStringID);
void SetColumnWidth(int nColumn,float fPercentage);
void SetColumnCount(int nColumn);
int GetColumnWidth(int nColumn);
virtual void AddItem(NANAListItemBase *pnewItem);
virtual int GetItemIndex(NANAListItemBase *pItem);
virtual NANAListItemBase * GetItem(int nItem);
virtual void DeleteItem(NANAListItemBase * pItem);
virtual void OnPaint(void);
virtual void OnMouseDown(int x,int y);
virtual void OnMouseUp(int x,int y);
virtual void OnCreate(){return;}
int ItemHit(int x,int y);
// virtual void OnNotify(NANAWnd *pSrcWnd,int nMessageCode,int nParam1,int nParam2);
};
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -