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

📄 panel.h

📁 C语言大赛的平台。分为环境模块和策略模块。
💻 H
字号:
/**
 * Panel作为基本的绘图模块单元,组织一些元素并负责它们的重绘
 */

#pragma once

enum
{
	DIRTY_STATE_INIT, // I'm need the first draw
	DIRTY_STATE_CLEAN, // I'm clean.
	DIRTY_STATE_UPPER, // I'm dirty and the upper panels need to redraw.
	DIRTY_STATE_ALL	// I'm dirty and all the panels need to redraw!
};

enum
{
	DRAW_NONE,
	DRAW_NORMAL,
	DRAW_USETHREAD
};

class Panel: public virtual Trigger
{
	public:
		Panel(Window *pWnd, int x = 0, int y = 0, int width = 0, int height = 0, int dirtyMark = DIRTY_STATE_UPPER);
		virtual ~Panel(void);

		int addControl(Control *pControl);
		int removeControl(Control *pControl);
		int clearControlList(void);

		HDC gethMemDC(void);
		void getPosition(int &x, int &y);
		void getPosition(POINT &point);
		void getSize(int &width, int &height);
		void WindowToPanel(int &x, int &y);
		void WindowToPanel(POINT &point);

	protected:
		void draw(bool needThread);

		virtual int onTrigger(void *pParam);
		void detect(void *pParam); // determine whether to be redraw
		void refresh(void *pParam);

		virtual void drawBkg(void) = 0; // redraw the area's background
		void drawControls(void); // redraw the items contained by this panel
		void markDirty(void); // call after the draw is finished
		virtual void BitBlt(void); // draw the Panel to the Window client

		static DWORD WINAPI drawProc(LPVOID pParam);

	protected:
		const int DIRTY_MARK;

		Window *mpWnd;
		HDC mhMemDC;
		HBITMAP mhMemBMP, mhMemBMPOld;
		HANDLE mhDrawProc;
		int mX, mY, mWidth, mHeight;
		int mDirtyState; // whether the panel considers the window is dirty

		list<Control*> mControlList;
};

⌨️ 快捷键说明

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