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

📄 sxbutton.h

📁 PW芯片方案Flash ROM烧写程序
💻 H
字号:
//---------------------------------------------------------------------------
// Pixelworks Inc. Company Confidential Strictly Private
//
// $Archive: /Pixware/SwTools/GUIBuilder/SXBUTTON.H $
// $Revision: 1.1.1.1 $
// $Author: KevinM $
// $Date: 2003/09/29 18:19:04 $
//
// --------------------------------------------------------------------------
// >>>>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// --------------------------------------------------------------------------
// Copyright 1999-2001(c) Pixelworks Inc.
//
// Pixelworks owns the sole copyright to this software. Under international 
// copyright laws you (1) may not make a copy of this software except for 
// the purposes of maintaining a single archive copy, (2) may not derive
// works herefrom, (3) may not distribute this work to others. These rights 
// are provided for information clarification, other restrictions of rights 
// may apply as well.
//
// This is an unpublished work.
// --------------------------------------------------------------------------
// >>>>>>>>>>>>>>>>>>>>>>>>>>>> WARRANTEE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// --------------------------------------------------------------------------
// Pixelworks Inc. MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THE USE OF
// THIS SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
// PURPOSE.
// --------------------------------------------------------------------------
//

#include "MemDC.h"

// CSXButton window

#ifndef _SXBUTTON_H
#define _SXBUTTON_H

#define	SXBUTTON_CENTER	-1
#define	MAX_LINES		20

// these are the three categories of hilighting we start with.
#define	_BORDER			1
#define	_NORMAL			2
#define	_SELECT			3

// these are used for the main lines
#define	_BORDER_CLR		RGB(0,0,255)
#define	_NORMAL_CLR		RGB(255,255,0)
#define	_SELECT_CLR		RGB(255,0,0)
#define	_THUMB_CLR		RGB(0,255,0)

// these are used for the arrows showing dimensions
#define	_BORDER_A_CLR	RGB(0,0,128)
#define	_NORMAL_A_CLR	RGB(128,128,0)
#define	_SELECT_A_CLR	RGB(128,0,0)
#define	_THUMB_A_CLR	RGB(0,128,0)

#define LNONE           -2
#define LEDGE           -1

// this defines the lines that can be rendered on the screen.
typedef struct {
	int			nType;
	int			nPenStyle;
	int			nWidth;
	COLORREF	crColor;
	BOOL		bVertical;
	int			nOffset;	    
    int 		nLeftIndex, nRightIndex, nTopIndex, nBottomIndex;
} LineInfo;

class CSXButton : public CButton
{
// Construction
public:
	CSXButton();

// Attributes
private:
	//	Positioning
	BOOL		m_bUseOffset;				
	CPoint		m_pointImage;
	CPoint		m_pointText;
	int			m_nImageOffsetFromBorder;
	int			m_nTextOffsetFromImage;

	//	Image
	HICON		m_hIcon;					
	HBITMAP		m_hBitmap;
	HBITMAP		m_hBitmapDisabled;
	int			m_nImageWidth, m_nImageHeight;
	BOOL		m_bOwnBitmap;

	//	Color Tab
	char		m_bColorTab;				
	COLORREF	m_crColorTab;

	//	State
	BOOL		m_bDefault;
	BOOL		m_bPlain;
	BOOL		m_bGraphic;
	BOOL		m_bFontHRender;
	BOOL		m_bEdit;
	BOOL	    m_bAllowScale;
	BOOL	    m_bFitScale;

	int			m_nScale;
	
	UINT		m_nOldAction;
	UINT		m_nOldState;

    // when used for our specific font rendering, use this
	CString		m_strFont;
	CString		m_strText;
	COLORREF	m_clrFore, m_clrBack;
    BOOL		m_bFontRender;
	BOOL		m_bFontExists;
    CPoint		m_ptLast;
    CPoint		m_ptDown;
    int			m_nOffset;

	// hotspot rendering
	BOOL		m_bHotSpot;
    int			m_nHotX, m_nHotY;

	// these are for the graphic rendering mode.
	int			m_nOffsetX, m_nOffsetY;

    // these are used so we can set the pen up for duration of multiple commands
	CPen		*m_pCurPen;
	CPen		*m_pOldPen;
    CDC			*m_pDC;
	CRect		m_rcItem;

    LineInfo	m_sLines[MAX_LINES];
	LineInfo	m_sCurLineInfo;
	BOOL		m_bCurLineInfoOk;

    CRect		m_rectHandles[MAX_LINES];

/* not static - always false unless asked
static	BOOL	m_bShowBoxes;
static	BOOL	m_bShowNumbers;
static	BOOL	m_bShowDimensions;
*/

	BOOL		m_bShowBoxes;
	BOOL		m_bShowNumbers;
	BOOL		m_bShowDimensions;
    BOOL		m_bShowMagnets;
	BOOL		m_bShowLines;
    int			m_nLines;

    int			m_nVHeight;
    int			m_nVWidth;
    int			m_nHeight;
    int			m_nWidth;
    int			m_nSHeight;
    int			m_nSWidth;

    int			m_bIsCaptured;		// mouse is captured
	int			m_bIsCaptureLine;	// it's a line (v. magnet)
    int			m_nCaptureLine;		// which line index
    int			m_nCaptureMagnet;	// which magnet index
	int			m_nCapX, m_nCapY;	// captured X and Y locations

    CString     m_strLocalFileName;
//    PWBlitData	m_sBlitMap;
//	CMagnetArray m_arrMagnetPoints;
    BOOL		m_bIsBlitMap;
    BOOL		m_bIsChanged;

    int         m_nBorderVertTop;
    int         m_nBorderVertBottom;
    int         m_nSelectVertTop;
    int         m_nSelectVertBottom;
    int         m_nNormalVertTop;
    int         m_nNormalVertBottom;
    int         m_nBorderHorzLeft;
    int         m_nBorderHorzRight;
    int         m_nSelectHorzLeft;
    int         m_nSelectHorzRight;
    int         m_nNormalHorzLeft;
    int         m_nNormalHorzRight;

	// stuff for dynamic titling on popup window..
	CString		m_strTitle;
	CWnd		*m_pWnd;

	// if we want to read the background
	BOOL		m_bWantBackground;
	COLORREF	m_clrBackground;

// Operations
public:
	//	Positioning
	int		SetImageOffset( int nPixels ); 
	int		SetTextOffset( int nPixels );
	CPoint	SetImagePos( CPoint p );
	CPoint	SetTextPos( CPoint p );

	//	Image
	BOOL	SetIcon( UINT nID, int nWidth, int nHeight );
	BOOL	SetBitmap( UINT nID, int nWidth, int nHeight );
	BOOL	SetMaskedBitmap( UINT nID, int nWidth, int nHeight, COLORREF crTransparentMask );
	BOOL	HasImage() { return (BOOL)( m_hIcon != 0  || m_hBitmap != 0 ); }
	BOOL	SetBitmapFile( const CString& strBitmap, BOOL bClearNew = TRUE, BOOL bReadBMI = TRUE );
	void	SetHBITMAP( const HBITMAP hBitmap, const BOOL bOwner );
	void	SetFontRender( const CString& strFont, const CString& strText, 
							const COLORREF fore, const COLORREF back );	
	void	SetOffsetAmount( const int nOffset ) { m_nOffset = nOffset; };

	//	Color Tab
	void	SetColorTab(COLORREF crTab);

	//	State of the button
	BOOL	SetDefaultButton( BOOL bState = TRUE );
	void	SetPlainRender( BOOL bPlain = TRUE )				{ m_bPlain   	= bPlain; 	};
	void	SetGraphicRender( BOOL bGraphic = TRUE )			{ m_bGraphic 	= bGraphic; };
	void	SetFontHRender( BOOL bFontHRender = TRUE )			{ m_bFontHRender= bFontHRender; };
	void	SetGraphicEdit( BOOL bEdit = TRUE )					{ m_bEdit	 	= bEdit; 	};
	void	SetGraphicAllowScale( BOOL bAllowScale )			{ m_bAllowScale	= bAllowScale;};
	void	SetGraphicFitScale( BOOL bFitScale )				{ m_bFitScale	= bFitScale;};
	void	SetGraphicScale( const int nScale );
//	void	SetGraphicBlitType( const PWBlitType eBlitType );

	BOOL	IsBlitMap(void) 									{ return m_bIsBlitMap; };
//	PWBlitType GetBlitType(void) 								{ return m_sBlitMap.eBlitType; };
//	int		GetBlitMapScale(void) 								{ return m_sBlitMap.nBlitScale; };
	CPoint	GetLastPoint(void)									{ return m_ptLast; };

	// hotspot highlight
	void	SetHotSpot( const BOOL bEnable, int nX, int nY );

	int		AddLine( const int nType, const int nPenStyle, const int nWidth, 
					  const COLORREF crColor, BOOL bVertical, int nOffset );
//	void	AddVLine( const int nType, const int nPercent );
//	void	AddHLine( const int nType, const int nPercent );
	int		AddOffsetLine( int nType, const int nOffset, const BOOL bVertical );
	void	LimitLineRange( int nIndex, int nLeftIndex, int nRightIndex, int nTopIndex, int nBottomIndex );
    void	ClearLines(void);

	int		GetHOffset( const int nPercent );
	int		GetVOffset( const int nPercent );

	void	SetLines(void);
	void	GetLines(void);
	void	LowHighTest( int& nLow, int& nHigh );

	BOOL	LoadBlitMap(void);
	void	StoreBlitMap( BOOL bForce = FALSE );
	BOOL	IsChanged(void)					{ return m_bIsChanged; };

	BOOL	GetShowBoxes(void)				{ return m_bShowBoxes; };
	void	SetShowBoxes( BOOL bShow)		{ m_bShowBoxes = bShow; Invalidate(); };
	BOOL	GetShowLines(void)				{ return m_bShowLines; };
	void	SetShowLines( BOOL bShow)		{ m_bShowLines = bShow; Invalidate(); };
	BOOL	GetShowNumbers(void)			{ return m_bShowNumbers; };
	void	SetShowNumbers( BOOL bShow)		{ m_bShowNumbers = bShow; Invalidate(); };
	BOOL	GetShowDimensions(void)			{ return m_bShowDimensions; };
	void	SetShowDimensions( BOOL bShow)	{ m_bShowDimensions = bShow; Invalidate(); };
	BOOL	GetShowMagnets(void)			{ return m_bShowMagnets; };
	void	SetShowMagnets( BOOL bShow)		{ m_bShowMagnets = bShow; Invalidate(); };

    void	AddMagnet( BOOL bNE, BOOL bNW, BOOL bSE, BOOL bSW, BOOL bCE );

	void	SetTitle( CWnd *pWnd, CString& strTitle )	{ m_pWnd = pWnd; m_strTitle = strTitle; };

	CString	GetInfo(void);
	void	WantBackground(void)			{ m_bWantBackground = TRUE; };			
											// if we want the background pixel
 	COLORREF GetBackground(void)			{ return m_clrBackground; };
											// what background pixel is..
	int		GetWidth(void)					{ return m_nImageWidth; };
	int		GetHeight(void)					{ return m_nImageHeight; };

private:
	BOOL	SetBitmapCommon( UINT nID, int nWidth, int nHeight, COLORREF crTransparentMask, BOOL bUseMask );
	void	CheckPointForCentering( CPoint &p, int nWidth, int nHeight );
	void	Redraw(void);
	void	DrawPlainBitmap(void);
	void	DrawGraphicBitmap(void);
	void	DrawFontText(void);
	void	DrawFontHelper(void);

    BOOL	SetPen( const int nPenStyle, const int nWidth, COLORREF crColor );
	void	ResetPen(void);
    void	DrawLine( const int nX, const int nY, const int nX2, const int nY2 );
	void	DrawOffset( const int nX, const int nY, const int nX2, const int nY2,
                        BOOL bVertical, int nIndex, int nLineIndex, int nOffset );

	void 	SetupForLine( LineInfo *plineInfo );
	void	DrawLines(void);
	void	ResetLine(void);
	void	DrawBoxes(void);
	void	DrawFrameBoxes(void);
	void	DrawBox( const CRect& rect, CBrush& br, COLORREF cr );
	void	Cook( long& nValue, int nOffset );
	void	DrawDimensions(void);
	void	DrawFrameDimensions(void);
	void	DrawDim( const CRect& rect, COLORREF cr, BOOL bVertical );
	void 	DrawLocation(void);

	BOOL	FindLine( CPoint& point );
	BOOL	MoveLine( CPoint& point );
	BOOL	FindMagnet( CPoint& point );
	BOOL	MoveMagnet( CPoint& point );
    void    MoveMagnetDone(void);
	void	InvalidateLineRect( LineInfo *plineInfo );
	CRect	GetLineRect( LineInfo *plineInfo );
	void	PaintBkgnd(void);
	BOOL 	AdjustForClipping( int& nNewCell, int nOldCell );
	void	DrawMagnets(void);
//	void	DrawMagnet( CMagnetPoint& pt );
//	void	SetMagnetFlag( PWBlitType eBlitType );;
	void	ValidateAllMagnets(void);
	void	ValidateMagnet( int nIndex );

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CSXButton)
	public:
	virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CSXButton();

	// Generated message map functions
protected:
	//{{AFX_MSG(CSXButton)
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

#endif
/////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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