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

📄 cdxcdynamiccontrolsmanager.h

📁 这是国外的resip协议栈
💻 H
📖 第 1 页 / 共 2 页
字号:
// cdxCDynamicControlsManager.h: interface for the cdxCDynamicControlsManager class.////////////////////////////////////////////////////////////////////////#if !defined(AFX_CDXCDYNAMICCONTROLSMANAGER_H__6517AE13_5D12_11D2_BE4C_000000000000__INCLUDED_)#define AFX_CDXCDYNAMICCONTROLSMANAGER_H__6517AE13_5D12_11D2_BE4C_000000000000__INCLUDED_#if _MSC_VER >= 1000#pragma once#endif // _MSC_VER >= 1000#include	"cdxCSizeIconCtrl.h"#include	<afxpriv.h>typedef cdxCSizeIconCtrl	cdxCSizeCtrl;//// cdxCDynamicControlsManager.h : header file// -----------------------------------------------------------------------// Author:  Hans B黨ler (hans.buehler@student.hu-berlin.de)//          codex design (http://www-pool.mathematik.hu-berlin.de/~codex// Version: 1.5// Release: 5 (Mar 1999 to www.codeguru.com)// -----------------------------------------------------------------------// Changes for V1.1:// - cdxCSizeCtrl is now only a typedef on cdxCSizeIconCtrl which is been//   but in two extra files (header and impl.) to make it available to//   the programmer even if you don't use cdxCDynamicControls.//   The include/impl file for cdxCSizeIconCtrl must be available.// - GetSizeIconBitmap() is been deleted.// - ICON_CONTROL_ID has been changed to AFX_IDW_SIZE_BOX// Changes for V1.2:// - cdxCDynamicControlsManager::DoOnGetMinMaxInfo() has been modified//   (thanks to a bug report by Michel Wassink <mww@mitutoyo.nl>)://   Now, if you don't call SetMaxSize(), the maximum position of a window//   will not be changed.//	  BUG: Under W95 and W98, resizing didn't work properly REMOVED.// Changes for V1.3:// - FindSzControl() and RemSzControl() have been added.// Changes for V1.4:// - RestoreWindowPosition() is been speed up.// - FixWindowSize() has been debugged// - RemSzControl() is been made more comfortable.//   You can now remove controls properly from the dynamic controls manager.//   Moreover, the embedded ControlPosition class has now some more virtual//   functions for your own use.//   For example, you can modify the way a control reacts later now.// - Enable() / Disable() have been added.//   Using them you can temporarily disable the automatic repositioning.// Changes to V1.5// - Flickering of controls during resize fixed thanks to great hint//   by Rodger Bernstein.// -----------------------------------------------------------------------// Comments welcome.///* * cdxCDynamicControlsManager * ========================== * Makes any CWnd derived class capable of dynamic control resizing * and repositioning. * Moreover, it can set a window's max/min tracking size (the size * the user can change) and add a nice sizing icon to the windows * lower right corner (if the window does not have one - as dialogs). * * To make any CWnd derived capable of automatically displaying * its controls, you embed a member of this class in your window * (or you derive your class from both this class and your window * base class - that depends on how you want to use the member * functions of this class). * * Then, the following functions must be called * *		DoInitWindow()			-	Must be called after the window became *										valid (i.e. CWnd::m_hWnd is non-zero) *										and has its initial (minimum) size. *		DoOnSize()				-	by the OnSize() message handler *		DoOnGetMinMaxInfo()	-	by the OnGetMinMaxInfo() message handler *		DoDestroyWindow()		-	by DestroyWindow(). * * See cdxCSizingDialog.h for an example. *  * NOTE: * Unfortunately, we cannot derive this class from CObject, because * those macros DECLARE_xxx are too lame to handle multipile derived * classes if both classes have been derived from the same base-class * CObject. */class cdxCDynamicControlsManager{	//	// various constants	//public:	enum Mode		// flags for AddSzControl()	{		mdNone		=	0,					// does nothing		mdResize		=	1,					// resize in that dimension		mdRepos		=	2,					// reposition		mdRelative	=	3,					// center (size by delta/2 and repos by delta/2)		md__Last		=	mdRelative	};	enum Freedom	{		fdNone		=	0,					// might be used but I don't imagine what you want from this ??		fdHoriz		=	0x01,				// horizantally sizable only		fdVert		=	0x02,				// vertically sizable only		fdAll			=	fdHoriz|fdVert	// sizable in all directions	};	enum RestoreFlags	{		rflg_none			=	0,			// only load window position		rflg_state			=	0x01,		// make window iconic/zoomed if been before		rflg_visibility	=	0x02,		// hide/show window as been before		rflg_all				=	rflg_state|rflg_visibility	};	enum	{		ICON_CONTROL_ID	=	AFX_IDW_SIZE_BOX	};	//	// a positioning parameter	//public:	class PositionSetup	{	public:		BYTE	m_dX1pcnt,m_dX2pcnt,			// how positioning should work (see docs)				m_dY1pcnt,m_dY2pcnt;	public:		PositionSetup(BYTE dX1pcnt = 0, BYTE dX2pcnt = 0, BYTE dY1pcnt = 0, BYTE dY2pcnt = 0) : m_dX1pcnt(dX1pcnt), m_dX2pcnt(dX2pcnt), m_dY1pcnt(dY1pcnt), m_dY2pcnt(dY2pcnt) {}		~PositionSetup() {}		// validity check		bool IsValid() const { return (m_dX1pcnt <= m_dX2pcnt) && (m_dY1pcnt <= m_dY2pcnt); }		// transform		CRect Transform(const CRect & rectOriginal, const CSize & szDelta) const;		// quick-use		CRect operator()(const CRect & rectOriginal, const CSize & szDelta) const { return Transform(rectOriginal,szDelta); }	};	//	// an astract handle to a sizeable control that you can	// use to add further controls to	// see discussion of AddSzControl()	//public:	class ControlPosition	{	protected:		ControlPosition() {}	public:		virtual ~ControlPosition() {}	public:		virtual bool IsMember(CWnd & ctrl) const = NULL;		virtual bool IsUsed() const = NULL;		virtual void Add(CWnd & ctrl) = NULL;		virtual bool Rem(CWnd & ctrl) = NULL;		virtual bool Modify(const CRect & rectOriginal, const PositionSetup & rSetup) = NULL;		virtual CRect GetCurrentPosition() const = NULL;		virtual CRect GetOriginalPosition() const = NULL;		virtual PositionSetup GetPositionSetup() const = NULL; 	};	//	// internal storage class for controls and their	// original positions and their behaviour settings	//private:	class ControlData : public ControlPosition	{		//		// all controls with the same positioning arguments		// (used by Add())		// Note that the window is not need to be already created		//	private:		struct ControlEntry		{		private:			ControlData		& m_rMaster;			// container			ControlEntry	*m_pNext,*m_pPrev;	// next, prev			CWnd				& m_rCtrl;				// the control		public:			ControlEntry(CWnd & ctrl, ControlData & rMaster);			virtual ~ControlEntry();			void Position(AFX_SIZEPARENTPARAMS *lpSz, int x, int y, int wid, int hi, bool bAll);			void Add(CWnd & ctrl, int x, int y, int wid, int hi);			ControlEntry *GetNext() { return m_pNext; }			CWnd & GetCWnd() { return m_rCtrl; }			const ControlEntry *GetNext() const { return m_pNext; }			const CWnd & GetCWnd() const { return m_rCtrl; }			bool operator==(const CWnd & ctrl) const { return &m_rCtrl == &ctrl; }		};		friend struct ControlEntry;	private:		cdxCDynamicControlsManager	& m_rMaster;			// the master class		ControlData						*m_pNext,*m_pPrev;	// a linked list (root in m_rMaster.m_pFirst)		ControlEntry					*m_pCtrl;				// control link list		PositionSetup					m_posSetup;		CRect								m_rectOriginal;		// original position of control(s)	public:		ControlData(cdxCDynamicControlsManager & rMaster, CWnd & ctrl, const PositionSetup & rPosSetup);		virtual ~ControlData();		virtual bool IsUsed() const { return m_pCtrl != NULL; }		//		// access to CWnds		//		virtual bool IsMember(CWnd & ctrl) const;		virtual void Add(CWnd & ctrl) { new ControlEntry(ctrl,*this); }		virtual bool Rem(CWnd & ctrl);		//		// positioning		//		virtual bool Modify(const CRect & rectOriginal, const PositionSetup & rSetup);		virtual CRect GetCurrentPosition() const;		virtual CRect GetOriginalPosition() const { return CRect(m_rectOriginal); }		virtual PositionSetup GetPositionSetup() const { return PositionSetup(m_posSetup); }		//		// helpers		//		ControlData *GetNext() { return m_pNext; }		const ControlData *GetNext() const { return m_pNext; }		//		// events		//		void OnSize(const CSize & szDelta, AFX_SIZEPARENTPARAMS *lpSz, const CPoint *pOffset = NULL);	};	//	// my members	//	friend class ControlData;	friend struct ControlData::ControlEntry;private:	ControlData		*m_pFirst;	CWnd				*m_pWnd;						// Use Init() !!!!!!!!!	CSize				m_szClientRelative,		// original's window size (client !!) - used in OnSize() to calculate delta size						m_szMin,						// minimum size (whole window)						m_szMax;						// maximum (whole window)	Freedom			m_Freedom;					// what is allowed	cdxCSizeCtrl	*m_pWndSizeIcon;			// the icon control	int				m_iDisabledCnt;			// counts Disable() and Enable()	UINT				m_iTotalCnt;				// total counter of all ControlData::ControlEntry objectspublic:	UINT				m_idSizeIcon;				// ID of the icon control (you can set this to change the default, ICON_CONTROL_ID)	bool				m_bApplyScrollPosition;	// fix scroll position for controls (set this in your constructor)public:	cdxCDynamicControlsManager() : m_pFirst(NULL), m_pWnd(NULL), m_Freedom(fdAll), m_pWndSizeIcon(NULL), m_idSizeIcon(ICON_CONTROL_ID), m_iDisabledCnt(0), m_iTotalCnt(0), m_bApplyScrollPosition(false) {}	virtual ~cdxCDynamicControlsManager() { DoDestroyWindow(); }	//	// check status	//	bool IsReady() const { return (m_pWnd != NULL) && ::IsWindow(m_pWnd->m_hWnd); }	UINT GetTotalChildCnt() const { return m_iTotalCnt; }	//	// get some basics	//	const CSize & GetMinSize() const { return m_szMin; }	const CSize & GetMaxSize() const { return m_szMax; }	Freedom GetFreedom() const { return m_Freedom; }	//	// wanna change some basics ?	//	bool SetMinMaxSize(const CSize & szMin, const CSize & szMax, bool bResizeIfNecessary = true);	bool FixWindowSize();	void SetFreedom(Freedom fd) { m_Freedom = fd; }	void HideSizeIcon();	void ShowSizeIcon();	//	// add controls to handle

⌨️ 快捷键说明

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