⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ppmenu.h

📁 基于ARM平台的控制系统,自己带有MINIGUI,可以直接在VC下运行界面演示程序
💻 H
字号:
#ifndef __GUIPP_MENU_H__
#define __GUIPP_MENU_H__

#include "GUIpp.h"

#if _USE_GUI == 1




#define MENU_NOTIFY_MESSAGE			1

////////////////////////////////

#define MENU_KEY_OK					1
#define MENU_KEY_CANCEL				2
#define MENU_KEY_UP					3
#define MENU_KEY_DOWN				4

////////////////////////////////
#define MENU_ITEM_MAX_TITLE_CHARS 	40
////////////////////////////////
// 菜单风格
#define MENU_STYLE_BLACKICON			0x00010000
#define MENU_STYLE_NORMAL				0x00020000

/////////////////////////////
// 菜单弹出位置布局
#define MENU_ALIGN_HOR_MIDDLE			0x00000001
#define MENU_ALIGN_HOR_LEFT				0x00000002
#define MENU_ALIGN_HOR_RIGHT 			0x00000004
#define MENU_ALIGN_HOR_INNER			0x00000008
#define MENU_ALIGN_HOR_OUTER 			0x00000010
#define MENU_ALIGN_VER_MIDDLE 			0x00000020
#define MENU_ALIGN_VER_TOP				0x00000040
#define MENU_ALIGN_VER_BOTTOM 			0x00000080
#define MENU_ALIGN_VER_INNER			0x00000100
#define MENU_ALIGN_VER_OUTER 			0x00000200


#define MENU_ITEM_STYLE_NORMAL				1				


#define MENU_ITEM_ICON_LEFT_MARGEN  		4
#define MENU_ITEM_ICON_RIGHT_MARGEN 		4
#define MENU_ITEM_TEXT_RIGHT_MARGEN 		4
#define MENU_ITEM_TEXT_LEFT_MARGEN 			4
#define MENU_ITEM_TOP_MARGEN 				4
#define MENU_ITEM_BOTTOM_MARGEN 			4
#define MENU_TOP_MARGEN 					1
#define MENU_BOTTOM_MARGEN 					1

#define MENU_SHADOW_SIZE					3	

class NANAMenu;
class NANAMenuItem;



class NANAMenuItem : public CLinkListNode
{
friend class NANAMenu;
private:
	int 					w_style;			// 风格
	int						w_icon;			// 图标指针
	char					w_strCaption[ MENU_ITEM_MAX_TITLE_CHARS ];

	NANAMenu		*		w_pSubMenu;

	NANAMenuItem(const char *pStrCaption,int nIcon,int nStyle,NANAMenu * pSubMenu)
	{
		if(pStrCaption)
		{
			DEBUG_Assert( strlen(pStrCaption) < MENU_ITEM_MAX_TITLE_CHARS );
			strcpy(w_strCaption,pStrCaption);
		}
		else
		{
			w_strCaption[0] = 0;
		}
		w_icon = nIcon;
		w_style = nStyle;
		w_pSubMenu = pSubMenu;
	}
};

class NANAMenu:public NANAFrameWnd
{
friend class NANAMenuItem;

private:
	
	NANAMenuItem	w_MenuItemHead;
	NANAMenuItem	w_MenuItemTail;
	
	int 			w_style;				// 风格,目前只有MENU_STYLE_BLACKICON一种

	NANAFrameWnd *	w_pNotifyWnd;		// 其"父"窗体
	
	
	int 			w_nTotalItem;		// 总菜单项条数
	
	int 			w_nSelectedItem;	// 当前选中序号

	int 			w_nPressed;			// 是否按下状态
	
	NANA_FONT		w_font;				//使用的字体

	int				w_nAlign;

	NANARect GetPopupRect(NANAWnd * pDockWnd, int nWidth,int nHeight, int nAlign);

	void DrawBlackIconItem(int nStartX,int nStartY,int nWidth , NANAMenuItem * pMenuItem,int nSelected,int nPressed);

	void DrawItem(int nStartX,int nStartY,int nWidth , NANAMenuItem * pMenuItem,int nSelected,int nPressed);

	
public:
	
	NANAMenu();
	
	void SetStyle(int nStyle,NANA_FONT font = &NANA_FONT12);
	
	void Show(NANAFrameWnd *pNotifyWnd,NANAWnd *pDockWnd,int nAlign);

	
	void AddItem(const char *pStrCaption,int nIcon=0,int nStyle=MENU_ITEM_STYLE_NORMAL,NANAMenu * pSubMenu = NULL );
	
	virtual void OnPaint();
	
	virtual void OnKey(int nKeyCode,int bKeyDown);

	virtual void OnMouseDown(int x,int y);

	virtual void OnMouseUp(int x,int y);

	virtual void OnMouseMove(int x,int y);
	
};


#endif	//end of _USE_GUI == 1
#endif	//end of #ifndef

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -