| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- /********************************************
- ** 工作室:S&P工作室
- ** 作者 :张东斌
- ** 日期 :2007年6月
- *********************************************/
- #include "stdafx.h"
- #include "SPVC80Helpers.h"
- #include "SPDrawHelpers.h"
- #include "SPPropertyGridInplaceEdit.h"
- #include "SPPropertyGridInplaceButton.h"
- #include "SPPropertyGridInplaceList.h"
- #include "SPPropertyGridItem.h"
- #include "SPPropertyGridInplaceButton.h"
- #include "SPPropertyGridInplaceEdit.h"
- #include "SPPropertyGrid.h"
- #include "SPPropertyGridPaintManager.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CXTColorPicker
- CSPPropertyGridInplaceButton::CSPPropertyGridInplaceButton() : m_bPressed( FALSE ) , m_bOver( FALSE ) , m_pGrid( 0 ) , m_pItem( 0 )
- {
- }
- CSPPropertyGridInplaceButton::~CSPPropertyGridInplaceButton()
- {
- }
- IMPLEMENT_DYNAMIC( CSPPropertyGridInplaceButton , CStatic )
- BEGIN_MESSAGE_MAP(CSPPropertyGridInplaceButton, CStatic)
- //{{AFX_MSG_MAP(CSPPropertyGridInplaceButton)
- ON_WM_PAINT()
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONUP()
- ON_WM_MOUSEMOVE()
- ON_WM_CAPTURECHANGED()
- ON_WM_SETFOCUS()
- ON_WM_KILLFOCUS()
- ON_WM_KEYDOWN()
- ON_WM_GETDLGCODE()
- ON_MESSAGE_VOID(WM_MOUSELEAVE, OnMouseLeave)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- UINT CSPPropertyGridInplaceButton::OnGetDlgCode()
- {
- return DLGC_WANTALLKEYS;
- }
- void CSPPropertyGridInplaceButton::HideWindow()
- {
- if ( m_hWnd )
- {
- ShowWindow( SW_HIDE );
- }
- }
- void CSPPropertyGridInplaceButton::Create( CSPPropertyGridItem * pItem , CRect rect )
- {
- ASSERT( pItem && pItem->GetGrid() );
- int nWidth = GetSystemMetrics( SM_CXHTHUMB );
- m_pGrid = pItem->GetGrid();
- rect.left = rect.right - nWidth;
- rect.top -= 1;
- if ( !m_hWnd )
- {
- CStatic::Create( _T( "" ),SS_NOTIFY | WS_CHILD,rect,m_pGrid );
- }
- SetWindowPos( 0,rect.left,rect.top,rect.Width(),rect.Height(),SWP_NOZORDER | SWP_SHOWWINDOW );
- m_pItem = pItem;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CSPPropertyGridInplaceButton message handlers
- void CSPPropertyGridInplaceButton::OnPaint()
- {
- CPaintDC dc ( this );
- CSPPropertyGridView * pView = ( CSPPropertyGridView * ) m_pGrid;
- if ( pView )
- {
- pView->m_pGrid->GetPaintManager()->FillInplaceButton( &dc,this );
- }
- }
- void CSPPropertyGridInplaceButton::OnLButtonDown( UINT , CPoint )
- {
- m_bOver = m_bPressed = TRUE;
- Invalidate( FALSE );
- SetCapture();
- }
- void CSPPropertyGridInplaceButton::OnLButtonUp( UINT nFlags , CPoint point )
- {
- if ( m_bPressed )
- {
- m_bPressed = FALSE;
- Invalidate( FALSE );
- ReleaseCapture();
- if ( m_bOver )
- m_pItem->OnInplaceButtonDown();
- }
- CStatic::OnLButtonUp( nFlags,point );
- }
- void CSPPropertyGridInplaceButton::OnMouseMove( UINT nFlags , CPoint point )
- {
- CSPClientRect rect ( this );
- if ( ( rect.PtInRect( point ) && !m_bOver ) || ( !rect.PtInRect( point ) && m_bOver ) )
- {
- m_bOver = rect.PtInRect( point );
- Invalidate( FALSE );
- if ( m_bOver )
- {
- TRACKMOUSEEVENT tme ={sizeof( TRACKMOUSEEVENT ), TME_LEAVE, m_hWnd};
- _TrackMouseEvent( &tme );
- }
- }
- CStatic::OnMouseMove( nFlags,point );
- }
- void CSPPropertyGridInplaceButton::OnMouseLeave()
- {
- //reset mouse vars
- OnMouseMove( 0,CPoint( -1,-1 ) );
- }
- void CSPPropertyGridInplaceButton::OnCaptureChanged( CWnd * pWnd )
- {
- m_bPressed = FALSE;
- Invalidate( FALSE );
- CStatic::OnCaptureChanged( pWnd );
- }
- void CSPPropertyGridInplaceButton::DestroyItem()
- {
- // reset variables to defaults.
- m_bPressed = FALSE;
- m_bOver = FALSE;
- m_pGrid = NULL;
- m_pItem = NULL;
- // destroy the window.
- //DestroyWindow( );
- if ( ::IsWindow( m_hWnd ) )
- {
- ShowWindow( SW_HIDE );
- }
- }
- void CSPPropertyGridInplaceButton::OnSetFocus( CWnd * pOldWnd )
- {
- CStatic::OnSetFocus( pOldWnd );
- Invalidate( FALSE );
- #ifdef SP_SITENOTIFY_ONFOCUS
- SP_SITENOTIFY_ONFOCUS( this,m_pGrid,TRUE )
- #endif
- }
- void CSPPropertyGridInplaceButton::OnKillFocus( CWnd * pNewWnd )
- {
- CStatic::OnKillFocus( pNewWnd );
- if ( m_pGrid )
- {
- m_pGrid->Invalidate( FALSE );
- }
- Invalidate( FALSE );
- #ifdef SP_SITENOTIFY_ONFOCUS
- SP_SITENOTIFY_ONFOCUS( this,m_pGrid,FALSE )
- #endif
- }
- void CSPPropertyGridInplaceButton::OnKeyDown( UINT nChar , UINT nRepCnt , UINT nFlags )
- {
- if ( m_pItem && ( nChar == VK_SPACE || nChar == VK_DOWN || nChar == VK_RETURN ) )
- {
- m_pItem->OnInplaceButtonDown();
- return;
- }
- if ( nChar == VK_TAB && m_pGrid )
- {
- ( ( CSPPropertyGrid * ) m_pGrid->GetParent() )->OnNavigate( SPGridUIInplaceButton,GetKeyState( VK_SHIFT ) >= 0,m_pItem );
- return;
- }
- CStatic::OnKeyDown( nChar,nRepCnt,nFlags );
- }
|