ExtPopupMenuWnd.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:735k
- // This is part of the Professional User Interface Suite library.
- // Copyright (C) 2001-2009 FOSS Software, Inc.
- // All rights reserved.
- //
- // http://www.prof-uis.com
- // mailto:support@prof-uis.com
- //
- // This source code can be used, modified and redistributed
- // under the terms of the license agreement that is included
- // in the Professional User Interface Suite package.
- //
- // Warranties and Disclaimers:
- // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND
- // INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- // IN NO EVENT WILL FOSS SOFTWARE INC. BE LIABLE FOR ANY DIRECT,
- // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES,
- // INCLUDING DAMAGES FOR LOSS OF PROFITS, LOSS OR INACCURACY OF DATA,
- // INCURRED BY ANY PERSON FROM SUCH PERSON'S USAGE OF THIS SOFTWARE
- // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- #include "stdafx.h"
- #define _AFX_NO_OLE_SUPPORT
- #ifndef __AFXPRIV_H__
- #include <AfxPriv.h>
- #endif
- #if _MFC_VER < 0x700
- #include <../src/AfxImpl.h>
- #else
- #include <../src/mfc/AfxImpl.h>
- #endif
- #include <math.h>
- #if (!defined __EXT_POPUP_MENU_WND_H)
- #include <ExtPopupMenuWnd.h>
- #endif
- #if (!defined __EXT_MFC_NO_CUSTOMIZE) || (!defined __EXT_MFC_NO_DATE_PICKER_POPUP) || (!defined __EXT_MFC_NO_UNDO_REDO_POPUP) || (!defined __EXT_MFC_NO_GRIDBASEWND)
- #if (!defined __EXT_POPUP_CTRL_MENU_H)
- #include <ExtPopupCtrlMenu.h>
- #endif
- #endif
- #if (!defined __EXT_MENUCONTROLBAR_H)
- #include <ExtMenuControlBar.h>
- #endif
- #if (!defined __EXT_PAINT_MANAGER_H)
- #include <ExtPaintManager.h>
- #endif
- #if (!defined __ExtCmdManager_H)
- #include <ExtCmdManager.h>
- #endif
- #if (!defined __EXT_MEMORY_DC_H)
- #include <../Src/ExtMemoryDC.h>
- #endif
- #if (!defined __EXT_LOCALIZATION_H)
- #include <../Src/ExtLocalization.h>
- #endif
- #if (!defined __EXT_BUTTON_H)
- #include <ExtButton.h>
- #endif
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- #if (!defined __EXT_RIBBON_BAR_H)
- #include <ExtRibbonBar.h>
- #endif // (!defined __EXT_RIBBON_BAR_H)
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- #if (!defined __EXT_SCROLLWND_H)
- #include <ExtScrollWnd.h>
- #endif
- #include <Resources/Resource.h>
- //#define _DEBUG_TEAROFF_TRANSPARENCY
- #define __WM_START_RESIZING (WM_USER+98)
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #if (!defined __EXT_MFC_WINMMDLL_ALREADY_DYN_LIKNED)
- #define __EXT_MFC_WINMMDLL_ALREADY_DYN_LIKNED
- #pragma message(" Prof-UIS is automatically linking with winmm.lib")
- #pragma message(" (Windows Multimedia System)")
- #pragma comment( lib, "winmm.lib" )
- #endif
- #ifdef _DEBUG
- static int g_nPopupCount = 0;
- //#define __VPC_VERIFY_0 ASSERT( g_nPopupCount == 0 )
- #define __VPC_VERIFY_0 { }
- #define __VPC_INC g_nPopupCount++
- #define __VPC_DEC g_nPopupCount--
- #else // _DEBUG
- #define __VPC_VERIFY_0 { }
- #define __VPC_INC { }
- #define __VPC_DEC { }
- #endif // _DEBUG
- #define ID_TIMER_ITEM_HIDE_DELAY 664
- #define ID_TIMER_ANIMATION 666
- #define ID_PERIOD_ANIMATION 30 // 20
- #define ID_TIMER_ITEM_FOCUS_DELAY 667
- #define ID_TIMER_SCROLLING 668
- #define ID_PERIOD_SCROLLING 50 // 15
- #define ID_TIMER_DELAY_SHOW 669
- #define ID_PERIOD_DELAY_SHOW_QUICK 20
- #define ID_PERIOD_DELAY_SHOW_NORMAL 500
- #define ID_PERIOD_DELAY_SHOW_RIBBON 900
- #define ID_TIMER_DELAY_EXPAND 670
- #define ID_FREQ_DELAY_EXPAND 50
- #define ID_TOTAL_DELAY_EXPAND 1500
- #define ID_TIMER_DELAY_KILL 671
- #define ID_PERIOD_DELAY_KILL 200
- #define ID_TIMER_DELAY_PAINT 672
- #define ID_TIMER_LIFE_STEP 673
- #define ID_PERIOD_LIFE_STEP 200
- #define ID_TIMER_FADE_OUT_ANIMATION 674
- #define ID_TIMER_AUTO_EXPAND 675
- #define __SCROLLING_PIXEL_STEP 5
- static const int g_nAnimStepMetric = 20;
- static clock_t g_nLastAnimTime = 0;
- #define __ANIM_CY 15
- #define __EXCLUDE_AREA_GAP_DX 3
- #define __EXCLUDE_AREA_GAP_DY __EXCLUDE_AREA_GAP_DX
- #define __BOX_ANIM_METRIC 32 // for __AT_BOXES,__AT_CIRCLES animation
- CExtPopupMenuSite CExtPopupMenuSite::g_DefPopupMenuSite;
- bool CExtPopupMenuWnd::g_bFullScreenMode = false;
- bool CExtPopupMenuWnd::g_bMenuWithShadows = true; // allow shadows
- bool CExtPopupMenuWnd::g_bMenuExpanding = true; // allow hide rarely used
- bool CExtPopupMenuWnd::g_bMenuDelayExpanding = true; // show full menu after short delay
- bool CExtPopupMenuWnd::g_bMenuHighlightRarely = true; // display rarely used in different style
- bool CExtPopupMenuWnd::g_bMenuShowCoolTips = true; // allow display cool tooltips
- bool CExtPopupMenuWnd::g_bMenuExpandAnimation = true; // allow animation when show rarely used
- bool CExtPopupMenuWnd::g_bUseStretchOnExpandAnimation = false; // use StretchBlt() instead of BitBlt() for painting menu expand amimation
- bool CExtPopupMenuWnd::g_bMenuLargeIcons = false; // use large icons
- bool CExtPopupMenuWnd::g_bEatNcAreaClicks = true;
- bool CExtPopupMenuWnd::g_bMRU_UseFullPathsInMenu = false;
- bool CExtPopupMenuWnd::g_bMRU_UseFullPathsInTipTool = false;
- bool CExtPopupMenuWnd::g_bShowStatusTipsOverDisabledItems = false;
- bool CExtPopupMenuWnd::g_bShowCoolTipsOverDisabledItems = false;
- CExtPopupMenuTipWnd::e_tip_style_t CExtPopupMenuWnd::g_eTtsClassicMenu = CExtPopupMenuTipWnd::__ETS_NONE; //__ETS_BALLOON;
- CExtPopupMenuTipWnd::e_tip_style_t CExtPopupMenuWnd::g_eTtsPaletteMenu = CExtPopupMenuTipWnd::__ETS_RECTANGLE_NO_ICON;
- CExtPopupMenuTipWnd::e_tip_style_t CExtPopupMenuWnd::g_eTtsColorMenu = CExtPopupMenuTipWnd::__ETS_RECTANGLE_NO_ICON;
- CExtPopupMenuTipWnd::e_tip_style_t CExtPopupMenuWnd::g_eTtsTearOffCaption = CExtPopupMenuTipWnd::__ETS_INV_RECTANGLE_NO_ICON;
- bool CExtPopupBaseWnd::g_bUseDesktopWorkArea = true; // align to desktop work area (false - to screen area)
- bool CExtPopupBaseWnd::g_bEnableOnIdleCalls = false;
- CObject * CExtPopupBaseWnd::g_pCombinedHelper = NULL;
- CExtPopupBaseWnd::e_animation_type_t
- CExtPopupBaseWnd::g_DefAnimationType =
- CExtPopupBaseWnd::__AT_NONE; // __AT_FADE; // __AT_RANDOM
- const UINT CExtPopupBaseWnd::g_nMsgPrepareMenu =
- ::RegisterWindowMessage(
- _T("CExtPopupMenuWnd::g_nMsgPrepareMenu")
- );
- const UINT CExtPopupBaseWnd::g_nMsgPrepareOneMenuLevel =
- ::RegisterWindowMessage(
- _T("CExtPopupMenuWnd::g_nMsgPrepareOneMenuLevel")
- );
- const UINT CExtPopupBaseWnd::g_nMsgPrepareDesktopBk =
- ::RegisterWindowMessage(
- _T("CExtPopupMenuWnd::g_nMsgPrepareDesktopBk")
- );
- const UINT CExtPopupBaseWnd::g_nMsgPopupNext =
- ::RegisterWindowMessage(
- _T("CExtPopupMenuWnd::g_nMsgPopupNext")
- );
- const UINT CExtPopupBaseWnd::g_nMsgPopupPrev =
- ::RegisterWindowMessage(
- _T("CExtPopupMenuWnd::g_nMsgPopupPrev")
- );
- const UINT CExtPopupBaseWnd::g_nMsgNotifyMenuExpanded =
- ::RegisterWindowMessage(
- _T("CExtPopupMenuWnd::g_nMsgNotifyMenuExpanded")
- );
- const UINT CExtPopupBaseWnd::g_nMsgNotifyMenuClosed =
- ::RegisterWindowMessage(
- _T("CExtPopupMenuWnd::g_nMsgNotifyMenuClosed")
- );
- const UINT CExtPopupBaseWnd::g_nMsgPopupDrawItem =
- ::RegisterWindowMessage(
- _T("CExtPopupMenuWnd::g_nMsgPopupDrawItem")
- );
- const UINT CExtPopupBaseWnd::g_nMsgPopupDrawLeftArea =
- ::RegisterWindowMessage(
- _T("CExtPopupMenuWnd::g_nMsgPopupDrawLeftArea")
- );
- const UINT CExtPopupBaseWnd::g_nMsgPopupDrawBackground =
- ::RegisterWindowMessage(
- _T("CExtPopupMenuWnd::g_nMsgPopupDrawBackground")
- );
- const UINT CExtPopupBaseWnd::g_nMsgCreateInplaceEdit =
- ::RegisterWindowMessage(
- _T("CExtPopupMenuWnd::g_nMsgCreateInplaceEdit")
- );
- const UINT CExtPopupBaseWnd::g_nMsgTranslateKeyboardEvent =
- ::RegisterWindowMessage(
- _T("CExtPopupBaseWnd::g_nMsgTranslateKeyboardEvent")
- );
- const UINT CExtPopupBaseWnd::g_nMsgTranslateMouseClickEvent =
- ::RegisterWindowMessage(
- _T("CExtPopupBaseWnd::g_nMsgTranslateMouseClickEvent")
- );
- const UINT CExtPopupBaseWnd::g_nMsgTranslateMouseMoveEvent =
- ::RegisterWindowMessage(
- _T("CExtPopupBaseWnd::g_nMsgTranslateMouseMoveEvent")
- );
- const UINT CExtPopupBaseWnd::g_nMsgTranslateMouseWheelEvent =
- ::RegisterWindowMessage(
- _T("CExtPopupBaseWnd::g_nMsgTranslateMouseWheelEvent")
- );
- #define __POPUP_WNDCLASS_STYLES__
- ( /*CS_OWNDC|*/ CS_GLOBALCLASS|CS_HREDRAW|CS_VREDRAW|CS_SAVEBITS )
- #define __TIP_WNDCLASS_STYLES__
- ( CS_OWNDC|CS_GLOBALCLASS|CS_HREDRAW|CS_VREDRAW|CS_SAVEBITS )
- #define __SHADOW_WNDCLASS_STYLES__
- ( CS_OWNDC|CS_GLOBALCLASS|CS_HREDRAW|CS_VREDRAW|CS_SAVEBITS )
- CExtPopupBaseWnd::TranslateKeyboardEventData_t::TranslateKeyboardEventData_t(
- CExtPopupBaseWnd * pEventSourcePopup,
- UINT nChar,
- UINT nRepCnt,
- UINT nFlags,
- bool bNoEat
- )
- : m_pEventSourcePopup( pEventSourcePopup )
- , m_bMessageHandled( false )
- , m_bNoEat( bNoEat )
- , m_nChar( nChar )
- , m_nRepCnt( nRepCnt )
- , m_nFlags( nFlags )
- {
- ASSERT_VALID( m_pEventSourcePopup );
- ASSERT( m_pEventSourcePopup->GetSafeHwnd() != NULL );
- }
- CExtPopupBaseWnd::TranslateKeyboardEventData_t::operator WPARAM ()
- {
- ASSERT( this != NULL );
- WPARAM wParam =
- reinterpret_cast
- < WPARAM >
- ( this );
- return wParam;
- }
- CExtPopupBaseWnd::TranslateKeyboardEventData_t & CExtPopupBaseWnd::TranslateKeyboardEventData_t::FromWPARAM( WPARAM wParam )
- {
- CExtPopupBaseWnd::TranslateKeyboardEventData_t * pData =
- reinterpret_cast
- < CExtPopupBaseWnd::TranslateKeyboardEventData_t * >
- ( wParam );
- ASSERT( pData != NULL );
- return (*pData);
- }
- bool CExtPopupBaseWnd::TranslateKeyboardEventData_t::Notify( HWND hWnd )
- {
- ASSERT( this != NULL );
- if( hWnd == NULL || (! ::IsWindow(hWnd) ) )
- return false;
- m_bMessageHandled = false;
- WPARAM wParam = (*this);
- ::SendMessage( hWnd, CExtPopupBaseWnd::g_nMsgTranslateKeyboardEvent, wParam, 0L );
- return m_bMessageHandled;
- }
- bool CExtPopupBaseWnd::TranslateKeyboardEventData_t::Notify()
- {
- ASSERT( this != NULL );
- ASSERT_VALID( m_pEventSourcePopup );
- ASSERT( m_pEventSourcePopup->GetSafeHwnd() != NULL );
- CExtPopupMenuWnd * pPopup =
- DYNAMIC_DOWNCAST(
- CExtPopupMenuWnd,
- m_pEventSourcePopup
- );
- if( pPopup == NULL )
- return false;
- HWND hWnd = pPopup->GetCmdReceiverHWND();
- bool bRetVal = Notify( hWnd );
- return bRetVal;
- }
- CExtPopupBaseWnd::TranslateMouseClickEventData_t::TranslateMouseClickEventData_t(
- CExtPopupBaseWnd * pEventSourcePopup,
- UINT nFlags,
- CPoint point,
- bool bNoEat
- )
- : m_pEventSourcePopup( pEventSourcePopup )
- , m_bMessageHandled( false )
- , m_bNoEat( bNoEat )
- , m_nFlags( nFlags )
- , m_point( point )
- {
- ASSERT_VALID( m_pEventSourcePopup );
- ASSERT( m_pEventSourcePopup->GetSafeHwnd() != NULL );
- }
- CExtPopupBaseWnd::TranslateMouseClickEventData_t::operator WPARAM ()
- {
- ASSERT( this != NULL );
- WPARAM wParam =
- reinterpret_cast
- < WPARAM >
- ( this );
- return wParam;
- }
- CExtPopupBaseWnd::TranslateMouseClickEventData_t & CExtPopupBaseWnd::TranslateMouseClickEventData_t::FromWPARAM( WPARAM wParam )
- {
- CExtPopupBaseWnd::TranslateMouseClickEventData_t * pData =
- reinterpret_cast
- < CExtPopupBaseWnd::TranslateMouseClickEventData_t * >
- ( wParam );
- ASSERT( pData != NULL );
- return (*pData);
- }
- bool CExtPopupBaseWnd::TranslateMouseClickEventData_t::Notify( HWND hWnd )
- {
- ASSERT( this != NULL );
- if( hWnd == NULL || (! ::IsWindow(hWnd) ) )
- return false;
- m_bMessageHandled = false;
- WPARAM wParam = (*this);
- ::SendMessage( hWnd, CExtPopupBaseWnd::g_nMsgTranslateMouseClickEvent, wParam, 0L );
- return m_bMessageHandled;
- }
- bool CExtPopupBaseWnd::TranslateMouseClickEventData_t::Notify()
- {
- ASSERT( this != NULL );
- ASSERT_VALID( m_pEventSourcePopup );
- ASSERT( m_pEventSourcePopup->GetSafeHwnd() != NULL );
- CExtPopupMenuWnd * pPopup =
- DYNAMIC_DOWNCAST(
- CExtPopupMenuWnd,
- m_pEventSourcePopup
- );
- if( pPopup == NULL )
- return false;
- HWND hWnd = pPopup->GetCmdReceiverHWND();
- bool bRetVal = Notify( hWnd );
- return bRetVal;
- }
- CExtPopupBaseWnd::TranslateMouseMoveEventData_t::TranslateMouseMoveEventData_t(
- CExtPopupBaseWnd * pEventSourcePopup,
- UINT nFlags,
- CPoint point,
- bool bNoEat
- )
- : m_pEventSourcePopup( pEventSourcePopup )
- , m_bMessageHandled( false )
- , m_bNoEat( bNoEat )
- , m_nFlags( nFlags )
- , m_point( point )
- {
- ASSERT_VALID( m_pEventSourcePopup );
- ASSERT( m_pEventSourcePopup->GetSafeHwnd() != NULL );
- }
- CExtPopupBaseWnd::TranslateMouseMoveEventData_t::operator WPARAM ()
- {
- ASSERT( this != NULL );
- WPARAM wParam =
- reinterpret_cast
- < WPARAM >
- ( this );
- return wParam;
- }
- CExtPopupBaseWnd::TranslateMouseMoveEventData_t & CExtPopupBaseWnd::TranslateMouseMoveEventData_t::FromWPARAM( WPARAM wParam )
- {
- CExtPopupBaseWnd::TranslateMouseMoveEventData_t * pData =
- reinterpret_cast
- < CExtPopupBaseWnd::TranslateMouseMoveEventData_t * >
- ( wParam );
- ASSERT( pData != NULL );
- return (*pData);
- }
- bool CExtPopupBaseWnd::TranslateMouseMoveEventData_t::Notify( HWND hWnd )
- {
- ASSERT( this != NULL );
- if( hWnd == NULL || (! ::IsWindow(hWnd) ) )
- return false;
- m_bMessageHandled = false;
- WPARAM wParam = (*this);
- ::SendMessage( hWnd, CExtPopupBaseWnd::g_nMsgTranslateMouseMoveEvent, wParam, 0L );
- return m_bMessageHandled;
- }
- bool CExtPopupBaseWnd::TranslateMouseMoveEventData_t::Notify()
- {
- ASSERT( this != NULL );
- ASSERT_VALID( m_pEventSourcePopup );
- ASSERT( m_pEventSourcePopup->GetSafeHwnd() != NULL );
- CExtPopupMenuWnd * pPopup =
- DYNAMIC_DOWNCAST(
- CExtPopupMenuWnd,
- m_pEventSourcePopup
- );
- if( pPopup == NULL )
- return false;
- HWND hWnd = pPopup->GetCmdReceiverHWND();
- bool bRetVal = Notify( hWnd );
- return bRetVal;
- }
- CExtPopupBaseWnd::TranslateMouseWheelEventData_t::TranslateMouseWheelEventData_t(
- CExtPopupBaseWnd * pEventSourcePopup,
- WPARAM wParam,
- LPARAM lParam,
- bool bNoEat
- )
- : m_pEventSourcePopup( pEventSourcePopup )
- , m_bMessageHandled( false )
- , m_bNoEat( bNoEat )
- , m_wParam( wParam )
- , m_lParam( lParam )
- {
- ASSERT_VALID( m_pEventSourcePopup );
- ASSERT( m_pEventSourcePopup->GetSafeHwnd() != NULL );
- }
- CExtPopupBaseWnd::TranslateMouseWheelEventData_t::operator WPARAM ()
- {
- ASSERT( this != NULL );
- WPARAM wParam =
- reinterpret_cast
- < WPARAM >
- ( this );
- return wParam;
- }
- CExtPopupBaseWnd::TranslateMouseWheelEventData_t & CExtPopupBaseWnd::TranslateMouseWheelEventData_t::FromWPARAM( WPARAM wParam )
- {
- CExtPopupBaseWnd::TranslateMouseWheelEventData_t * pData =
- reinterpret_cast
- < CExtPopupBaseWnd::TranslateMouseWheelEventData_t * >
- ( wParam );
- ASSERT( pData != NULL );
- return (*pData);
- }
- bool CExtPopupBaseWnd::TranslateMouseWheelEventData_t::Notify( HWND hWnd )
- {
- ASSERT( this != NULL );
- if( hWnd == NULL || (! ::IsWindow(hWnd) ) )
- return false;
- m_bMessageHandled = false;
- WPARAM wParam = (*this);
- ::SendMessage( hWnd, CExtPopupBaseWnd::g_nMsgTranslateMouseWheelEvent, wParam, 0L );
- return m_bMessageHandled;
- }
- bool CExtPopupBaseWnd::TranslateMouseWheelEventData_t::Notify()
- {
- ASSERT( this != NULL );
- ASSERT_VALID( m_pEventSourcePopup );
- ASSERT( m_pEventSourcePopup->GetSafeHwnd() != NULL );
- CExtPopupMenuWnd * pPopup =
- DYNAMIC_DOWNCAST(
- CExtPopupMenuWnd,
- m_pEventSourcePopup
- );
- if( pPopup == NULL )
- return false;
- HWND hWnd = pPopup->GetCmdReceiverHWND();
- bool bRetVal = Notify( hWnd );
- return bRetVal;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtSoundPlayer
- CExtSoundPlayer::CExtSoundPlayerAutoPtr g_SoundPlayer;
- IMPLEMENT_DYNCREATE( CExtSoundPlayer, CObject );
- CExtSoundPlayer::InternalSoundEventInitDone_t::InternalSoundEventInitDone_t()
- : CEvent( FALSE, TRUE )
- {
- }
- void CExtSoundPlayer::InternalSoundEventInitDone_t::SetInitDone()
- {
- SetEvent();
- }
- void CExtSoundPlayer::InternalSoundEventInitDone_t::WaitInitDone()
- {
- HANDLE hEvent = *this;
- ASSERT( hEvent != NULL );
- ::WaitForSingleObject( hEvent, INFINITE );
- }
- CExtSoundPlayer::InternalSoundThredadParms_t::InternalSoundThredadParms_t(
- __EXT_MFC_SAFE_LPCTSTR sSoundSpecBuffer,
- HANDLE hModule,
- DWORD dwPlayerFlags
- )
- : m_hModule( hModule )
- , m_dwPlayerFlags( dwPlayerFlags )
- , m_hThread( NULL )
- , m_dwThreadID( 0 )
- , m_pEventInitDone( NULL )
- {
- ::memset( m_sSoundSpecBuffer, 0, sizeof(m_sSoundSpecBuffer) );
- ASSERT( sSoundSpecBuffer != NULL );
- ASSERT( _tclen(sSoundSpecBuffer) > 0 );
- __EXT_MFC_STRNCPY(
- m_sSoundSpecBuffer,
- sizeof(m_sSoundSpecBuffer) / sizeof(m_sSoundSpecBuffer[0]),
- sSoundSpecBuffer,
- sizeof(m_sSoundSpecBuffer) / sizeof(m_sSoundSpecBuffer[0])
- );
- }
- CEvent CExtSoundPlayer::InternalSoundThredadParms_t::g_EventPlaySnd(
- TRUE,
- FALSE
- );
- CCriticalSection CExtSoundPlayer::InternalSoundThredadParms_t::g_CsPlaySnd;
- DWORD WINAPI CExtSoundPlayer::InternalSoundThredadParms_t::stat_ParallelPlayerProc(
- CExtSoundPlayer::InternalSoundThredadParms_t * pParms
- )
- {
- ASSERT( pParms != NULL );
- pParms->PlaySound();
- g_EventPlaySnd.SetEvent();
- return 0;
- }
- //#define __TRACE_SOUND_PLAYER_THREAD
- void CExtSoundPlayer::InternalSoundThredadParms_t::PlaySound()
- {
- TCHAR sSoundSpecBuffer[ sizeof(m_sSoundSpecBuffer) / sizeof(m_sSoundSpecBuffer[0]) ];
- __EXT_MFC_STRCPY(
- sSoundSpecBuffer,
- sizeof(m_sSoundSpecBuffer) / sizeof(m_sSoundSpecBuffer[0]),
- m_sSoundSpecBuffer
- );
- HANDLE hModule = m_hModule;
- DWORD dwPlayerFlags = m_dwPlayerFlags;
- if( m_pEventInitDone != NULL )
- m_pEventInitDone->SetInitDone();
- #ifdef __TRACE_SOUND_PLAYER_THREAD
- TRACE1("CExtSoundPlayer::InternalSoundThredadParms_t::PlaySound("%s") - STARTn",sSoundSpecBuffer);
- #endif // __TRACE_SOUND_PLAYER_THREAD
- if( (m_dwPlayerFlags & SND_ASYNC) != 0 )
- ::PlaySound( NULL, NULL, SND_PURGE );
- ::PlaySound(
- sSoundSpecBuffer,
- (HMODULE)hModule,
- dwPlayerFlags
- );
- if( (m_dwPlayerFlags & SND_SYNC) != 0 )
- ::PlaySound( NULL, NULL, SND_PURGE );
- #ifdef __TRACE_SOUND_PLAYER_THREAD
- TRACE1("CExtSoundPlayer::InternalSoundThredadParms_t::PlaySound("%s") - STOPn",sSoundSpecBuffer);
- #endif // __TRACE_SOUND_PLAYER_THREAD
- }
- void CExtSoundPlayer::InternalSoundThredadParms_t::PlaySoundParallel()
- {
- ASSERT( m_hThread == NULL );
- CSingleLock slCs( &g_CsPlaySnd );
- slCs.Lock();
- HANDLE hEvent = (HANDLE)g_EventPlaySnd;
- ASSERT( hEvent != NULL );
- if( ::WaitForSingleObject(hEvent,0) == WAIT_OBJECT_0 )
- {
- ASSERT( m_pEventInitDone == NULL );
- InternalSoundEventInitDone_t EventInitDone;
- m_pEventInitDone = &EventInitDone;
- m_hThread =
- ::CreateThread(
- NULL,
- 0,
- *this,
- this,
- CREATE_SUSPENDED,
- &m_dwThreadID
- );
- ASSERT( m_hThread != NULL );
- if( m_hThread != NULL )
- {
- VERIFY(
- ::SetThreadPriority(
- m_hThread,
- THREAD_PRIORITY_BELOW_NORMAL
- )
- );
- ::ResumeThread( m_hThread );
- EventInitDone.WaitInitDone();
- } // if( m_hThread != NULL )
- else
- g_EventPlaySnd.SetEvent();
- } // if( ::WaitForSingleObject(hEvent,0) == WAIT_OBJECT_0 )
- if( m_hThread != NULL )
- ::CloseHandle( m_hThread );
- slCs.Unlock();
- }
- CExtSoundPlayer::CExtSoundPlayerAutoPtr::CExtSoundPlayerAutoPtr()
- {
- m_pPlayer = new CExtSoundPlayer;
- }
- CExtSoundPlayer::CExtSoundPlayerAutoPtr::~CExtSoundPlayerAutoPtr()
- {
- if( m_pPlayer != NULL )
- delete m_pPlayer;
- }
- void CExtSoundPlayer::CExtSoundPlayerAutoPtr::InstallSoundPlayer(
- CExtSoundPlayer * pPlayer
- )
- {
- ASSERT( pPlayer != NULL );
- ASSERT_VALID( pPlayer );
- ASSERT_KINDOF( CExtSoundPlayer, m_pPlayer );
- if( m_pPlayer != NULL )
- delete m_pPlayer;
- m_pPlayer = pPlayer;
- }
- CExtSoundPlayer::CExtSoundPlayer()
- {
- }
- CExtSoundPlayer::~CExtSoundPlayer()
- {
- }
- void CExtSoundPlayer::PlaySound(
- CExtSoundPlayer::e_ui_sounds_t eSoundID
- )
- {
- ASSERT_VALID( this );
- switch( eSoundID )
- {
- case __NO_SOUND:
- return;
- case __ON_MENU_EXPAND_CLICKED:
- case __ON_MENU_POPUP_DISPLAYED:
- {
- InternalSoundThredadParms_t _istp(
- _T("MenuPopup"),
- NULL,
- SND_ALIAS|SND_NODEFAULT|SND_NOWAIT|SND_ASYNC
- );
- _istp.PlaySoundParallel();
- return;
- }
- case __ON_MENU_CMD_CLICKED:
- {
- InternalSoundThredadParms_t _istp(
- _T("MenuCommand"),
- NULL,
- SND_ALIAS|SND_NODEFAULT|SND_NOWAIT|SND_SYNC
- );
- _istp.PlaySoundParallel();
- return;
- }
- } // switch( eSoundID )
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtPopupMenuSite
- CExtPopupMenuSite::CExtPopupMenuSite()
- : m_pTopMenu( NULL )
- , m_pWndCapture( NULL )
- , m_pWndAnimation( NULL )
- , m_bShutdownMode( false )
- , m_hMouseHook( NULL )
- , m_hKeyboardHook( NULL )
- , m_lpnResultCmdID( NULL )
- , m_pWndToolTip( NULL )
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- , m_pWndScreenTip( NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- {
- }
- CExtPopupMenuSite::~CExtPopupMenuSite()
- {
- __PROF_UIS_MANAGE_STATE;
- _Done();
- for( ; true; )
- {
- POSITION pos = m_mapFadeOutInsances.GetStartPosition();
- if( pos == NULL )
- break;
- CExtPopupMenuWnd * pPopup = NULL;
- bool bFlag = false;
- m_mapFadeOutInsances.GetNextAssoc( pos, pPopup, bFlag );
- ASSERT_VALID( pPopup );
- pPopup->m_nFadeOutAnimationStepIndex = pPopup->m_nFadeOutAnimationStepCount;
- if( pPopup->GetSafeHwnd() == NULL )
- {
- //pPopup->m_bTopLevel = true;
- pPopup->_BuildItems( NULL, true );
- delete pPopup;
- }
- else
- {
- pPopup->TrackFlagsSet( pPopup->TrackFlagsGet() | TPMX_NO_FADE_OUT_ANIMATION );
- pPopup->DestroyWindow();
- }
- } // for( ; true; )
- if( m_pWndToolTip != NULL )
- {
- if( m_pWndToolTip->GetSafeHwnd() != NULL )
- m_pWndToolTip->DestroyWindow();
- delete m_pWndToolTip;
- m_pWndToolTip = NULL;
- } // if( m_pWndToolTip != NULL )
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( m_pWndScreenTip != NULL )
- {
- if( m_pWndScreenTip->GetSafeHwnd() != NULL )
- m_pWndScreenTip->DestroyWindow();
- delete m_pWndScreenTip;
- m_pWndScreenTip = NULL;
- } // if( m_pWndScreenTip != NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- }
- void CExtPopupMenuSite::FadeOutInstanceAdd( CExtPopupMenuWnd * pPopup )
- {
- ASSERT( pPopup != NULL );
- m_mapFadeOutInsances.SetAt( pPopup, false );
- }
- void CExtPopupMenuSite::FadeOutInstanceRemove( CExtPopupMenuWnd * pPopup )
- {
- ASSERT( pPopup != NULL );
- m_mapFadeOutInsances.RemoveKey( pPopup );
- }
- bool CExtPopupMenuSite::IsEmpty() const
- {
- return (m_pTopMenu == NULL) ? true : false;
- }
- bool CExtPopupMenuSite::IsShutdownMode() const
- {
- return m_bShutdownMode;
- }
- CExtPopupMenuTipWnd & CExtPopupMenuSite::GetTip()
- {
- if( m_pWndToolTip == NULL )
- m_pWndToolTip = new CExtPopupMenuTipWnd;
- return (*m_pWndToolTip);
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtPopupScreenTipWnd & CExtPopupMenuSite::GetScreenTip()
- {
- if( m_pWndScreenTip == NULL )
- m_pWndScreenTip = new CExtPopupScreenTipWnd;
- return (*m_pWndScreenTip);
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtPopupMenuWnd * CExtPopupMenuSite::GetCapture()
- {
- if( IsEmpty() )
- return NULL;
- ASSERT( ! IsShutdownMode() );
- return m_pWndCapture;
- }
- void CExtPopupMenuSite::SetCapture(
- CExtPopupMenuWnd * pNewPopup // = NULL
- )
- {
- if( IsEmpty() )
- return;
- ASSERT( ! IsShutdownMode() );
- #ifdef _DEBUG
- if( pNewPopup != NULL )
- {
- ASSERT_VALID( pNewPopup );
- } // if( pNewPopup != NULL )
- #endif // _DEBUG
- m_pWndCapture = pNewPopup;
- }
- void CExtPopupMenuSite::SetInstance(
- CExtPopupMenuWnd * pTopMenu // = NULL
- )
- {
- ASSERT( ! IsShutdownMode() );
- if( ! IsEmpty() )
- {
- ASSERT( m_pTopMenu != NULL );
- ASSERT_VALID( m_pTopMenu );
- ASSERT( m_pTopMenu->m_bTopLevel );
- if( m_pTopMenu == pTopMenu )
- return;
- if( m_pTopMenu != pTopMenu )
- _Done();
- } // if( ! IsEmpty() )
- ASSERT( m_pTopMenu == NULL );
- if( pTopMenu != NULL )
- {
- ASSERT_VALID( pTopMenu );
- ASSERT( pTopMenu->m_bTopLevel );
- m_pTopMenu = pTopMenu;
- _Hook( true );
- } // if( pTopMenu != NULL )
- }
- CExtPopupMenuWnd * CExtPopupMenuSite::GetAnimated()
- {
- if( IsEmpty() )
- return NULL;
- ASSERT( ! IsShutdownMode() );
- return m_pWndAnimation;
- }
- void CExtPopupMenuSite::SetAnimated(
- CExtPopupMenuWnd * pNewPopup // = NULL
- )
- {
- if( IsEmpty() )
- return;
- ASSERT( ! IsShutdownMode() );
- m_pWndAnimation = pNewPopup;
- }
- CExtPopupMenuWnd * CExtPopupMenuSite::GetInstance()
- {
- return m_pTopMenu;
- }
- void CExtPopupMenuSite::SetTargetCmdIdPtr(
- UINT * lpnResultCmdID // = NULL
- )
- {
- m_lpnResultCmdID = lpnResultCmdID;
- }
- UINT * CExtPopupMenuSite::GetTargetCmdIdPtr()
- {
- return m_lpnResultCmdID;
- }
- void CExtPopupMenuSite::DoneInstance()
- {
- _Done();
- }
- void CExtPopupMenuSite :: operator = ( CExtPopupMenuWnd * pTopMenu )
- {
- SetInstance(pTopMenu);
- }
- CExtPopupMenuWnd * CExtPopupMenuSite :: operator -> ()
- {
- ASSERT( ! IsEmpty() );
- ASSERT( ! IsShutdownMode() );
- ASSERT( m_pTopMenu != NULL );
- return m_pTopMenu;
- }
- bool CExtPopupMenuSite::IsTopPopup(
- CExtPopupMenuWnd * pTopMenu
- ) const
- {
- if( pTopMenu->GetSafeHwnd() == NULL )
- return false;
- ASSERT_VALID( pTopMenu );
- if( IsEmpty() )
- {
- if( (pTopMenu->TrackFlagsGet()&TPMX_NO_SITE) != 0 )
- return true;
- }
- ASSERT( ! IsShutdownMode() );
- return (pTopMenu==m_pTopMenu) ? true : false;
- }
- void CExtPopupMenuSite::_Done()
- {
- if( CExtBarButton::g_pTrackingMenuTBB != NULL )
- {
- bool bResetCurrentToolbarButton = true;
- CExtPopupMenuWnd * pPopup = GetInstance();
- if( pPopup != NULL
- && pPopup->m_eCombineAlign == CExtPopupMenuWnd::__CMBA_NONE
- )
- {
- POINT pt;
- if( ::GetCursorPos( &pt ) )
- {
- HWND hWnd = ::WindowFromPoint( pt );
- if( hWnd != NULL )
- {
- CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
- if( pWnd != NULL )
- {
- CExtToolControlBar * pToolBar = DYNAMIC_DOWNCAST( CExtToolControlBar, pWnd );
- if( pToolBar != NULL )
- {
- pToolBar->ScreenToClient( &pt );
- int nIdx = pToolBar->HitTest( pt );
- if( nIdx >= 0 && pToolBar->GetButton( nIdx ) == CExtBarButton::g_pTrackingMenuTBB )
- bResetCurrentToolbarButton = false;
- }
- }
- }
- }
- }
- if( bResetCurrentToolbarButton )
- CExtBarButton::g_pTrackingMenuTBB = NULL;
- }
- if( m_pWndToolTip != NULL )
- {
- if( m_pWndToolTip->GetSafeHwnd() != NULL )
- m_pWndToolTip->DestroyWindow();
- delete m_pWndToolTip;
- m_pWndToolTip = NULL;
- } // if( m_pWndToolTip != NULL )
- if( m_bShutdownMode )
- return;
- // if( m_pWndToolTip != NULL )
- // m_pWndToolTip->Hide();
- m_bShutdownMode = true;
- m_pWndCapture = NULL;
- m_pWndAnimation = NULL;
- m_lpnResultCmdID = NULL;
- _Hook( false );
- if( m_pTopMenu != NULL )
- {
- ASSERT( m_pTopMenu->m_bTopLevel );
- bool bFadeOutMode = m_pTopMenu->_IsFadeOutAnimation();
- if( ! bFadeOutMode )
- {
- VERIFY( m_pTopMenu->_BuildItems( NULL, true ) );
- if( m_pTopMenu->GetSafeHwnd() != NULL
- && ::IsWindow( m_pTopMenu->GetSafeHwnd() )
- )
- {
- CExtControlBar::stat_SetMessageString( m_pTopMenu->GetOwner() );
- m_pTopMenu->DestroyWindow();
- }
- ASSERT( m_pTopMenu->GetSafeHwnd() == NULL );
- delete m_pTopMenu;
- } // if( ! bFadeOutMode )
- m_pTopMenu = NULL;
- } // if( m_pTopMenu != NULL )
- __VPC_VERIFY_0;
- m_bShutdownMode = false;
- }
- LRESULT CALLBACK CExtPopupMenuSite::_HookMouseProc(
- int nCode, // hook code
- WPARAM wParam, // message identifier
- LPARAM lParam // mouse coordinates
- )
- {
- __PROF_UIS_MANAGE_STATE;
- if( nCode != HC_ACTION )
- return
- ::CallNextHookEx(
- g_DefPopupMenuSite.m_hMouseHook,
- nCode,
- wParam,
- lParam
- );
- MOUSEHOOKSTRUCT* lpMS = (MOUSEHOOKSTRUCT*)lParam;
- ASSERT( lpMS != NULL );
- if( CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON != NULL )
- {
- switch( wParam )
- {
- case WM_MOUSEMOVE:
- {
- CPoint pt( lpMS->pt );
- if( CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->
- _OnMouseMove(
- (UINT)wParam,
- pt
- )
- )
- return 1; // eat!
- }
- break;
- case WM_MOUSEWHEEL:
- {
- if( CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->
- _OnMouseWheel(
- wParam,
- lParam
- )
- )
- return 1; // eat!
- }
- break;
- case WM_NCLBUTTONDOWN:
- case WM_NCRBUTTONDOWN:
- case WM_NCMBUTTONDOWN:
- case WM_LBUTTONDOWN:
- case WM_RBUTTONDOWN:
- case WM_MBUTTONDOWN:
- case WM_NCLBUTTONUP:
- case WM_NCRBUTTONUP:
- case WM_NCMBUTTONUP:
- case WM_LBUTTONUP:
- case WM_RBUTTONUP:
- case WM_MBUTTONUP:
- {
- CPoint ptSrc( lpMS->pt );
- if( CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->_OnMouseClick(
- (UINT)wParam,
- ptSrc
- )
- )
- return 1; // eat!
- }
- break;
- } // switch( wParam )
- }
- if( nCode == HC_ACTION // +2.55 - fix by Ulrich Berger-Kubik
- && (! g_DefPopupMenuSite.IsEmpty() )
- && (! g_DefPopupMenuSite.IsShutdownMode() )
- )
- {
- CExtPopupMenuWnd * pWndCapture =
- g_DefPopupMenuSite.GetCapture();
- if( pWndCapture != NULL
- && ::IsWindow( pWndCapture->GetSafeHwnd() )
- )
- {
- ASSERT_VALID( pWndCapture );
- CExtBarButton * pSavedTrackingMenuTBB = CExtBarButton::g_pTrackingMenuTBB;
- switch( wParam )
- {
- //case WM_MOUSEACTIVATE:
- // if( lpMS->hwnd != pWndCapture->GetSafeHwnd() )
- // return 1;
- //break;
- case WM_MOUSEMOVE:
- {
- CPoint pt( lpMS->pt );
- pWndCapture->ScreenToClient( &pt );
- bool bNoEat = false;
- if( pWndCapture->
- _OnMouseMove(
- (UINT)wParam,
- pt,
- bNoEat
- )
- )
- {
- HWND hWnd = ::WindowFromPoint( lpMS->pt );
- if( hWnd != NULL
- && ::GetWindowThreadProcessId( hWnd, NULL ) == ::GetCurrentThreadId()
- )
- {
- INT nHT = (INT)::SendMessage( hWnd, WM_NCHITTEST, 0L, MAKELPARAM(lpMS->pt.x,lpMS->pt.y) );
- INT nMM = WM_MOUSEMOVE;
- if( nHT != HTCLIENT
- && nHT != HTMINBUTTON
- && nHT != HTMAXBUTTON
- && nHT != HTHELP
- && nHT != HTCLOSE
- && nHT != HTNOWHERE
- )
- nMM = WM_NCMOUSEMOVE;
- else
- nHT = HTCLIENT;
- ::SendMessage( hWnd, WM_SETCURSOR, (WPARAM)hWnd, MAKELPARAM(nHT,nMM) );
- }
- return 1; // eat!
- }
- if( bNoEat )
- return
- ::CallNextHookEx(
- g_DefPopupMenuSite.m_hMouseHook,
- nCode,
- wParam,
- lParam
- );
- }
- break;
- case WM_MOUSEWHEEL:
- {
- bool bNoEat = false;
- if( pWndCapture->
- _OnMouseWheel(
- wParam,
- lParam,
- bNoEat
- )
- )
- return 1; // eat!
- if( bNoEat )
- return
- ::CallNextHookEx(
- g_DefPopupMenuSite.m_hMouseHook,
- nCode,
- wParam,
- lParam
- );
- return 1; // eat!
- }
- break;
- case WM_NCLBUTTONDBLCLK:
- case WM_NCRBUTTONDBLCLK:
- case WM_NCMBUTTONDBLCLK:
- case WM_LBUTTONDBLCLK:
- case WM_RBUTTONDBLCLK:
- case WM_MBUTTONDBLCLK:
- CExtBarButton::g_pTrackingMenuTBB = NULL;
- // continue ...
- case WM_NCLBUTTONDOWN:
- case WM_NCRBUTTONDOWN:
- case WM_NCMBUTTONDOWN:
- case WM_LBUTTONDOWN:
- case WM_RBUTTONDOWN:
- case WM_MBUTTONDOWN:
- case WM_NCLBUTTONUP:
- case WM_NCRBUTTONUP:
- case WM_NCMBUTTONUP:
- case WM_LBUTTONUP:
- case WM_RBUTTONUP:
- case WM_MBUTTONUP:
- {
- HWND hWndFromPoint = WindowFromPoint( lpMS->pt );
- LRESULT nHT =
- ::SendMessage(
- hWndFromPoint,
- WM_NCHITTEST,
- 0L,
- MAKELPARAM( lpMS->pt.x, lpMS->pt.y )
- );
- if( hWndFromPoint != NULL )
- {
- if( ( nHT == HTSYSMENU || nHT == HTCAPTION )
- && wParam != WM_NCLBUTTONUP
- && ( ! g_PaintManager.m_DWM.IsCompositionEnabled() )
- )
- {
- CWnd * pWndFromPointPermanent = CWnd::FromHandlePermanent( hWndFromPoint );
- if( pWndFromPointPermanent == NULL
- || (! pWndFromPointPermanent->IsKindOf( RUNTIME_CLASS(CMiniFrameWnd) ) )
- )
- {
- pWndCapture->TrackFlagsSet( pWndCapture->TrackFlagsGet() | TPMX_NO_FADE_OUT_ANIMATION );
- CExtToolControlBar::_CloseTrackingMenus();
- CExtPopupMenuWnd::CancelMenuTracking();
- return
- ::CallNextHookEx(
- g_DefPopupMenuSite.m_hMouseHook,
- nCode,
- wParam,
- lParam
- );
- }
- }
- } // if( hWndFromPoint != NULL )
- //CRect rcWndCapture;
- //_pWndCapture->GetWindowRect( &rcWndCapture );
- //if( !rcWndCapture.PtInRect(lpMS->pt) )
- // break;
- CPoint ptSrc( lpMS->pt );
- pWndCapture->ScreenToClient( &ptSrc );
- bool bSameToolBarButtonIsClicked = false;
- CExtPopupMenuWnd * pDefInstancePopup = CExtPopupMenuSite::g_DefPopupMenuSite.GetInstance();
- CPoint pt( lpMS->pt );
- HWND hWndPT = ::WindowFromPoint( pt );
- CWnd * pWndPermanentPT = NULL;
- if( hWndPT != NULL )
- pWndPermanentPT = CWnd::FromHandlePermanent( hWndPT );
- if( pDefInstancePopup != NULL
- && pWndPermanentPT != NULL
- && pSavedTrackingMenuTBB != NULL
- && ( wParam == WM_LBUTTONDOWN || wParam == WM_LBUTTONDBLCLK )
- )
- {
- ASSERT_VALID( pDefInstancePopup );
- ASSERT( ::IsWindow(pDefInstancePopup->GetSafeHwnd()) );
- if( ( ! pDefInstancePopup->m_rcExcludeArea.IsRectEmpty() )
- && pDefInstancePopup->m_rcExcludeArea.PtInRect( pt )
- && pWndPermanentPT != NULL
- && pWndPermanentPT->IsKindOf( RUNTIME_CLASS( CExtToolControlBar ) )
- )
- {
- CPoint ptBarClient = pt;
- pWndPermanentPT->ScreenToClient( &ptBarClient );
- INT nHtTbb = ((CExtToolControlBar*)pWndPermanentPT)->HitTest( ptBarClient );
- if( nHtTbb >= 0 && LPVOID(((CExtToolControlBar*)pWndPermanentPT)->GetButton(nHtTbb)) == LPVOID(pSavedTrackingMenuTBB) )
- bSameToolBarButtonIsClicked = true;
- }
- }
- DWORD dwCTF = pWndCapture->TrackFlagsGet();
- bool bNoEat = false;
- HWND hWndCapture = pWndCapture->GetSafeHwnd();
- ASSERT( hWndCapture != NULL && ::IsWindow(hWndCapture) );
- if( pWndCapture->_OnMouseClick(
- (UINT)wParam,
- ptSrc,
- bNoEat
- )
- )
- {
- if( ( ! bNoEat )
- && ( dwCTF & TPMX_SYSMENU ) != 0
- && ( wParam == WM_NCLBUTTONDOWN || wParam == WM_NCLBUTTONDBLCLK )
- && nHT == HTSYSMENU
- )
- return
- ::CallNextHookEx(
- g_DefPopupMenuSite.m_hMouseHook,
- nCode,
- wParam,
- lParam
- );
- if( ! bSameToolBarButtonIsClicked )
- return 1; // eat!
- }
- if( ( ! bNoEat )
- && ( dwCTF & TPMX_SYSMENU ) != 0
- && ( wParam == WM_NCLBUTTONDOWN || wParam == WM_NCLBUTTONDBLCLK )
- && nHT == HTSYSMENU
- )
- bNoEat = true;
- if( bNoEat )
- return
- ::CallNextHookEx(
- g_DefPopupMenuSite.m_hMouseHook,
- nCode,
- wParam,
- lParam
- );
- if( ! (::IsWindow(hWndCapture)) )
- return 1; // eat!
-
- // post processing
- if( hWndPT != NULL )
- {
- CExtPopupMenuWnd * pPopup = pWndCapture;
- for( ; pPopup != NULL; pPopup = pPopup->m_pWndParentMenu )
- {
- CPoint ptClient( pt );
- pPopup->ScreenToClient( &ptClient );
- if( pPopup->_PtInWndArea(ptClient) )
- return 1; // eat!
- CExtPopupMenuTipWnd & _tipWnd = pPopup->GetTip();
- HWND hWndTest = _tipWnd.GetSafeHwnd();
- if( hWndTest != NULL )
- {
- if( hWndTest == hWndPT
- || ::IsChild( hWndTest, hWndPT )
- )
- return 1; // eat!
- } // if( hWndTest != NULL )
- if( pWndPermanentPT != NULL
- && ::IsChild( pPopup->m_hWnd, hWndPT )
- && pWndPermanentPT->IsKindOf( RUNTIME_CLASS(CScrollBar) )
- )
- return 1; // eat!
- } // for( ; pPopup != NULL; pPopup = pPopup->m_pWndParentMenu )
- } // if( hWndPT != NULL )
- if( pDefInstancePopup != NULL )
- {
- bool bEatEvent = false;
- ASSERT_VALID( pDefInstancePopup );
- ASSERT( ::IsWindow(pDefInstancePopup->GetSafeHwnd()) );
- if( bSameToolBarButtonIsClicked )
- bEatEvent = true;
- pDefInstancePopup->_CancelingSet();
- pDefInstancePopup->_OnCancelMode();
- if( ! bEatEvent )
- {
- if( wParam != WM_LBUTTONDOWN
- && wParam != WM_RBUTTONDOWN
- && wParam != WM_MBUTTONDOWN
- )
- bEatEvent = true;
- }
- if( ! bEatEvent )
- {
- if( ! ::IsWindow( hWndPT ) )
- bEatEvent = true;
- }
- if( bEatEvent )
- {
- if( CExtPopupMenuWnd::g_bEatNcAreaClicks )
- return 1; // eat!
- }
- } // if( pDefInstancePopup != NULL )
- // else
- // CExtPopupMenuSite::g_DefPopupMenuSite._Done();
-
- }
- break;
- //default:
- // return 1; // eat!
- } // switch( wParam )
- } // if( pWndCapture != NULL ....
- else
- return 1; // eat
- } // if( (! g_DefPopupMenuSite.IsEmpty() ) ...
- return
- ::CallNextHookEx(
- g_DefPopupMenuSite.m_hMouseHook,
- nCode,
- wParam,
- lParam
- );
- }
- LRESULT CALLBACK CExtPopupMenuSite::_HookKeyboardProc(
- int nCode, // hook code
- WPARAM wParam, // virtual-key code
- LPARAM lParam // keystroke-message information
- )
- {
- __PROF_UIS_MANAGE_STATE;
- if( nCode != HC_ACTION )
- return
- ::CallNextHookEx(
- g_DefPopupMenuSite.m_hKeyboardHook,
- nCode,
- wParam,
- lParam
- );
- if( CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON != NULL )
- {
- if( CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->
- _OnKeyDown(
- (UINT)wParam,
- LOWORD(lParam),
- HIWORD(lParam)
- )
- )
- return 1; // eat!
- }
- if( (! g_DefPopupMenuSite.IsEmpty() )
- && (! g_DefPopupMenuSite.IsShutdownMode() )
- )
- {
- CExtPopupMenuWnd * pWndCapture =
- g_DefPopupMenuSite.GetCapture();
- if( pWndCapture->GetSafeHwnd() != NULL
- && ::IsWindow( pWndCapture->GetSafeHwnd() )
- )
- {
- ASSERT_VALID( pWndCapture );
- if( (lParam & (1<<31)) == 0 )
- {
- // clocks allows to fix problem with
- // duplicated fast key hook calls
- static clock_t _clock_step =
- CLOCKS_PER_SEC / 50; // 1/50 of second
- static clock_t _clock_last =
- 0; //clock();
- clock_t _clock_curr =
- clock();
- //ASSERT( _clock_curr >= _clock_last );
- clock_t _clock_diff =
- abs(_clock_curr - _clock_last);
- bool bForceChildProcessing = false;
- HWND hWndFocus = ::GetFocus();
- if( hWndFocus != NULL
- && ( ( ::__EXT_MFC_GetWindowLong( hWndFocus, GWL_STYLE ) & WS_CHILD ) != 0 )
- )
- {
- HWND hWndTest = ::GetParent( hWndFocus );
- if( hWndTest != NULL )
- {
- CWnd * pWndPermantent =
- CWnd::FromHandlePermanent( hWndTest );
- if( pWndPermantent != NULL
- && pWndPermantent->IsKindOf(
- RUNTIME_CLASS( CExtPopupMenuWnd )
- )
- )
- bForceChildProcessing = true;
- } // if( hWndTest != NULL )
- } // if( hWndFocus != NULL ...
- if( _clock_diff >= _clock_step
- || bForceChildProcessing
- )
- {
- _clock_last = _clock_curr;
- bool bNoEat = false;
- if( pWndCapture->
- _OnKeyDown(
- (UINT)wParam,
- LOWORD(lParam),
- HIWORD(lParam),
- bNoEat
- )
- )
- return 1; // eat!
- if( bNoEat )
- return
- ::CallNextHookEx(
- g_DefPopupMenuSite.m_hKeyboardHook,
- nCode,
- wParam,
- lParam
- );
- if( pWndCapture != NULL )
- return 1; // eat!
- } // if( _clock_diff >= _clock_step ...
- else
- return 1; // eat! 2.28 fix
- } // if( (lParam & (1<<31)) == 0 )
- else
- {
- // 2.21 fix for dialog system menu
- return 1; // eat!
- }
- } // if( pWndCapture->GetSafeHwnd() != NULL ...
- // if( ! CExtToolControlBar::g_bMenuTracking )
- // return 1; // eat!
- } // if( (! g_DefPopupMenuSite.IsEmpty() ) ...
- if( (!CExtToolControlBar::g_bMenuTracking)
- && CExtPopupMenuWnd::IsCmdKeyActivation( lParam )
- && ( lParam & (1<<31) ) != 0
- )
- {
- CExtPopupMenuWnd::CancelMenuTracking();
- return
- ::CallNextHookEx(
- g_DefPopupMenuSite.m_hKeyboardHook,
- nCode,
- wParam,
- lParam
- );
- }
- // return
- // ::CallNextHookEx(
- // g_DefPopupMenuSite.m_hKeyboardHook,
- // nCode,
- // wParam,
- // lParam
- // );
- return 1; // eat! 2.28 fix
- }
- void CExtPopupMenuSite::_Hook(
- bool bHook // = true
- )
- {
- if( bHook )
- {
- if( m_hMouseHook == NULL )
- {
- m_hMouseHook =
- ::SetWindowsHookEx(
- WH_MOUSE,
- _HookMouseProc,
- 0,
- ::GetCurrentThreadId()
- );
- ASSERT( m_hMouseHook != NULL );
- }
- if( m_hKeyboardHook == NULL )
- {
- m_hKeyboardHook =
- ::SetWindowsHookEx(
- WH_KEYBOARD,
- _HookKeyboardProc,
- 0,
- ::GetCurrentThreadId()
- );
- ASSERT( m_hKeyboardHook != NULL );
- }
- } // if( bHook )
- else
- {
- if( m_hMouseHook != NULL )
- {
- ::UnhookWindowsHookEx( m_hMouseHook );
- m_hMouseHook = NULL;
- }
- if( m_hKeyboardHook != NULL )
- {
- ::UnhookWindowsHookEx( m_hKeyboardHook );
- m_hKeyboardHook = NULL;
- }
- } // else from if( bHook )
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtWndShadow
- CExtWndShadow::CExtWndShadow()
- {
- Destroy();
- }
- CExtWndShadow::CExtWndShadow( const CExtWndShadow & other )
- {
- Destroy();
- _Assign( other );
- }
- CExtWndShadow::~CExtWndShadow()
- {
- Destroy();
- }
- CExtWndShadow & CExtWndShadow:: operator = ( const CExtWndShadow & other )
- {
- Destroy();
- _Assign( other );
- return (*this);
- }
- void CExtWndShadow::_Assign( const CExtWndShadow & other )
- {
- Destroy();
- if( other.m_bmp0org.GetSafeHandle() != NULL )
- {
- COLORREF * pClrSurface = NULL;
- HBITMAP hBitmap =
- CExtBitmap::stat_CloneBitmap(
- (HBITMAP)other.m_bmp0org.GetSafeHandle(),
- NULL,
- &pClrSurface
- );
- ASSERT( hBitmap != NULL );
- if( hBitmap != NULL )
- {
- ASSERT( pClrSurface != NULL );
- m_bmp0org.Attach( hBitmap );
- }
- }
- if( other.m_bmp1org.GetSafeHandle() != NULL )
- {
- COLORREF * pClrSurface = NULL;
- HBITMAP hBitmap =
- CExtBitmap::stat_CloneBitmap(
- (HBITMAP)other.m_bmp1org.GetSafeHandle(),
- NULL,
- &pClrSurface
- );
- ASSERT( hBitmap != NULL );
- if( hBitmap != NULL )
- {
- ASSERT( pClrSurface != NULL );
- m_bmp1org.Attach( hBitmap );
- }
- }
- if( other.m_bmp0mak.GetSafeHandle() != NULL )
- {
- COLORREF * pClrSurface = NULL;
- HBITMAP hBitmap =
- CExtBitmap::stat_CloneBitmap(
- (HBITMAP)other.m_bmp0mak.GetSafeHandle(),
- NULL,
- &pClrSurface
- );
- ASSERT( hBitmap != NULL );
- if( hBitmap != NULL )
- {
- ASSERT( pClrSurface != NULL );
- m_bmp0mak.Attach( hBitmap );
- }
- }
- if( other.m_bmp1mak.GetSafeHandle() != NULL )
- {
- COLORREF * pClrSurface = NULL;
- HBITMAP hBitmap =
- CExtBitmap::stat_CloneBitmap(
- (HBITMAP)other.m_bmp1mak.GetSafeHandle(),
- NULL,
- &pClrSurface
- );
- ASSERT( hBitmap != NULL );
- if( hBitmap != NULL )
- {
- ASSERT( pClrSurface != NULL );
- m_bmp1mak.Attach( hBitmap );
- }
- }
- m_rcWndArea = other.m_rcWndArea;
- m_rc1stArea = other.m_rc1stArea;
- m_rc2ndArea = other.m_rc2ndArea;
- m_nShadowSize = other.m_nShadowSize;
- m_nBr0 = other.m_nBr0;
- m_nBr1 = other.m_nBr1;
- m_bEnablePhotos = other.m_bEnablePhotos;
- m_bEnablePaintManagerColor = other.m_bEnablePaintManagerColor;
- if( other.m_rgnSafe.GetSafeHandle() != NULL )
- {
- if( m_rgnSafe.CreateRectRgn( 0, 0, 0, 0 ) )
- {
- int nCombineResult =
- m_rgnSafe.CombineRgn(
- &m_rgnSafe,
- (CRgn*)&other.m_rgnSafe,
- RGN_OR
- );
- ASSERT( nCombineResult != ERROR );
- nCombineResult;
- } // if( m_rgnSafe.CreateRectRgn( 0, 0, 0, 0 ) )
- #ifdef _DEBUG
- else
- {
- ASSERT( FALSE );
- } // else from if( m_rgnSafe.CreateRectRgn( 0, 0, 0, 0 ) )
- #endif // _DEBUG
- } // if( other.m_rgnSafe.GetSafeHandle() != NULL )
- }
- void CExtWndShadow::ApplyFloatingImage(
- HWND hWndStatic,
- HWND hWndFloat,
- LPCRECT pRectCustomFloatPos // = NULL
- )
- {
- if( m_bmp0mak.GetSafeHandle() == NULL
- && m_bmp1mak.GetSafeHandle() == NULL
- )
- return;
- if( hWndStatic == NULL
- || hWndFloat == NULL
- || (! ::IsWindow(hWndStatic) )
- || (! ::IsWindow(hWndFloat) )
- )
- {
- ASSERT( FALSE );
- return;
- }
- CRect rcWndStatic = m_rcWndArea, rcWndFloat;
- ::ClientToScreen( hWndStatic, ((LPPOINT)(&rcWndStatic)) );
- ::ClientToScreen( hWndStatic, ((LPPOINT)(&rcWndStatic))+1 );
- if( pRectCustomFloatPos != NULL )
- rcWndFloat = (*pRectCustomFloatPos);
- else
- ::GetWindowRect( hWndFloat, rcWndFloat );
- CRect rcIntersection;
- if( ! rcIntersection.IntersectRect(
- &rcWndStatic,
- &rcWndFloat
- )
- )
- return;
- HBITMAP hBmpFloat =
- CExtPaintManager::stat_PrintWnd( hWndFloat );
- if( hBmpFloat == NULL )
- {
- ASSERT( FALSE );
- return;
- }
- CPoint ptOffset =
- rcWndFloat.TopLeft()
- - rcWndStatic.TopLeft()
- ;
- CBitmap _bmpFloatDestructor;
- _bmpFloatDestructor.Attach( hBmpFloat );
- BITMAP _bmpInfo;
- ::memset( &_bmpInfo, 0, sizeof(BITMAP) );
- ::GetObject( hBmpFloat, sizeof(BITMAP), &_bmpInfo );
- if( ! ( _bmpInfo.bmWidth > 0 && _bmpInfo.bmHeight > 0 ) )
- {
- ASSERT( FALSE );
- return;
- }
- CDC dcSrc, dcDst;
- if( (! dcSrc.CreateCompatibleDC( NULL ) )
- || (! dcDst.CreateCompatibleDC( NULL ) )
- )
- {
- ASSERT( FALSE );
- return;
- }
- HGDIOBJ hBmpOldSrc = ::SelectObject( dcSrc.GetSafeHdc(), hBmpFloat );
- if( m_bmp0mak.GetSafeHandle() != NULL )
- {
- CBitmap * pOldBmpDst = dcDst.SelectObject( &m_bmp0mak );
- dcDst.BitBlt(
- ptOffset.x - m_rcWndArea.Width(),
- ptOffset.y,
- _bmpInfo.bmWidth,
- _bmpInfo.bmHeight,
- &dcSrc,
- 0,
- 0,
- SRCCOPY
- );
- dcDst.SelectObject( pOldBmpDst );
- }
- if( m_bmp1mak.GetSafeHandle() != NULL )
- {
- CBitmap * pOldBmpDst = dcDst.SelectObject( &m_bmp1mak );
- dcDst.BitBlt(
- ptOffset.x,
- ptOffset.y - m_rcWndArea.Height(),
- _bmpInfo.bmWidth,
- _bmpInfo.bmHeight,
- &dcSrc,
- 0,
- 0,
- SRCCOPY
- );
- dcDst.SelectObject( pOldBmpDst );
- }
- ::SelectObject( dcSrc.GetSafeHdc(), hBmpOldSrc );
- }
- void CExtWndShadow::_DoPixelOvershadow(
- int nMakeSpec,
- int nPosX,
- int nPosY,
- COLORREF clrShadowAdjust
- )
- {
- ASSERT( nMakeSpec >= 0 && nMakeSpec <= 100 );
- ASSERT( ! m_rcWndArea.IsRectEmpty() );
- // ASSERT( nPosX < m_rcWndArea.Width() + INT(m_nShadowSize) );
- // ASSERT( nPosY < m_rcWndArea.Height() + INT(m_nShadowSize) );
- if( nPosX >= m_rcWndArea.Width() + INT(m_nShadowSize) )
- return;
- if( nPosY >= m_rcWndArea.Height() + INT(m_nShadowSize) )
- return;
- ASSERT( m_pHelperDibSurface != NULL );
- int nTotalWidth = m_rcWndArea.Width()+m_nShadowSize;
- int nTotalHeight = m_rcWndArea.Height()+m_nShadowSize;
- COLORREF * ptr =
- m_pHelperDibSurface
- + nPosX
- + (nTotalHeight-nPosY)*nTotalWidth;
- COLORREF clrAdj = *ptr;
- if( clrShadowAdjust != ((COLORREF)(-1)) )
- {
- int nMakeSpecR = nMakeSpec + ::MulDiv( (100-nMakeSpec), GetBValue(clrShadowAdjust), 255 );
- int nMakeSpecG = nMakeSpec + ::MulDiv( (100-nMakeSpec), GetGValue(clrShadowAdjust), 255 );
- int nMakeSpecB = nMakeSpec + ::MulDiv( (100-nMakeSpec), GetRValue(clrShadowAdjust), 255 );
- if( nMakeSpecR > 100 )
- nMakeSpecR = 100;
- if( nMakeSpecG > 100 )
- nMakeSpecG = 100;
- if( nMakeSpecB > 100 )
- nMakeSpecB = 100;
- clrAdj =
- RGB(
- (( nMakeSpecR * int(GetRValue(clrAdj)) ) / 100),
- (( nMakeSpecG * int(GetGValue(clrAdj)) ) / 100),
- (( nMakeSpecB * int(GetBValue(clrAdj)) ) / 100)
- );
- } // if( clrShadowAdjust != ((COLORREF)(-1)) )
- else
- {
- clrAdj =
- RGB(
- (( nMakeSpec * int(GetRValue(clrAdj)) ) / 100),
- (( nMakeSpec * int(GetGValue(clrAdj)) ) / 100),
- (( nMakeSpec * int(GetBValue(clrAdj)) ) / 100)
- );
- } // else from if( clrShadowAdjust != ((COLORREF)(-1)) )
- *ptr = clrAdj;
- }
- bool CExtWndShadow::HavePhotos() const
- {
- ASSERT( m_nShadowSize >= 0 );
- if( m_nShadowSize == 0
- || m_rcWndArea.IsRectEmpty()
- )
- return false;
- if( m_bmp0mak.GetSafeHandle() == NULL
- || m_bmp1mak.GetSafeHandle() == NULL
- )
- return false;
- return true;
- }
- bool CExtWndShadow::_HaveOriginals() const
- {
- ASSERT( m_nShadowSize >= 0 );
- if( m_nShadowSize == 0
- || m_rcWndArea.IsRectEmpty()
- )
- return false;
- if( m_bmp0org.GetSafeHandle() == NULL
- || m_bmp1org.GetSafeHandle() == NULL
- )
- return false;
- return true;
- }
- bool CExtWndShadow::_RestoreOriginals( CDC & dc )
- {
- ASSERT( m_nShadowSize >= 0 );
- if( m_nShadowSize == 0
- || m_rcWndArea.IsRectEmpty ()
- )
- return true;
- if( ! _HaveOriginals() )
- return false;
- INT nWndAreaDX = m_rcWndArea.Width();
- INT nWndAreaDY = m_rcWndArea.Height();
- ASSERT( nWndAreaDX > 0 && nWndAreaDY > 0 );
- CDC dcmm;
- if( ! dcmm.CreateCompatibleDC(&dc) )
- {
- ASSERT( FALSE );
- return false;
- }
- CBitmap * pbmpold = dcmm.SelectObject( &m_bmp0org );
- ASSERT( pbmpold != NULL );
- dc.BitBlt(
- m_rcWndArea.Width(),
- 0,
- m_nShadowSize,
- nWndAreaDY + m_nShadowSize,
- &dcmm,
- 0,
- 0,
- SRCCOPY
- );
- dcmm.SelectObject( &m_bmp1org );
- dc.BitBlt(
- 0,
- m_rcWndArea.Height(),
- nWndAreaDX + m_nShadowSize,
- m_nShadowSize,
- &dcmm,
- 0,
- 0,
- SRCCOPY
- );
- dcmm.SelectObject( pbmpold );
- return true;
- }
- bool CExtWndShadow::Restore( CDC & dc )
- {
- ASSERT( m_nShadowSize >= 0 );
- if( m_nShadowSize == 0
- || m_rcWndArea.IsRectEmpty ()
- )
- return true;
- if( ! HavePhotos() )
- return false;
- INT nWndAreaDX = m_rcWndArea.Width();
- INT nWndAreaDY = m_rcWndArea.Height();
- ASSERT( nWndAreaDX > 0 && nWndAreaDY > 0 );
- CDC dcmm;
- if( ! dcmm.CreateCompatibleDC(&dc) )
- {
- ASSERT( FALSE );
- return false;
- }
- if( m_rgnSafe.GetSafeHandle() != NULL )
- dc.SelectClipRgn( &m_rgnSafe, RGN_AND );
- CBitmap * pbmpold = dcmm.SelectObject( &m_bmp0mak );
- ASSERT( pbmpold != NULL );
- dc.BitBlt(
- m_rcWndArea.right,
- m_rcWndArea.top,
- m_nShadowSize,
- nWndAreaDY + m_nShadowSize,
- &dcmm,
- 0,
- 0,
- SRCCOPY
- );
- dcmm.SelectObject( &m_bmp1mak );
- dc.BitBlt(
- m_rcWndArea.left,
- m_rcWndArea.bottom,
- nWndAreaDX + m_nShadowSize,
- m_nShadowSize,
- &dcmm,
- 0,
- 0,
- SRCCOPY
- );
- dcmm.SelectObject( pbmpold );
- if( m_rgnSafe.GetSafeHandle() != NULL )
- dc.SelectClipRgn( NULL );
-
- return true;
- }
- bool CExtWndShadow::Paint(
- CExtPaintManager * pPM,
- CDC & dc,
- const CRect & rcWndArea,
- const CRect & rc1stArea, // = CRect(0,0,0,0)
- const CRect & rc2ndArea, // = CRect(0,0,0,0)
- UINT nShadowSize, // = DEF_SHADOW_SIZE
- UINT nBr0, // = DEF_BRIGHTNESS_MIN
- UINT nBr1, // = DEF_BRIGHTNESS_MAX
- bool bEnablePhotos, // = true
- bool bEnablePaintManagerColor, // = true
- bool m_bMakePhotosOnly, // = false
- HWND hWndStatic, // = NULL
- HWND hWndFloat, // = NULL
- LPCRECT pRectCustomFloatPos // = NULL
- )
- {
- m_rcWndArea = rcWndArea;
- m_rc1stArea = rc1stArea;
- m_rc2ndArea = rc2ndArea;
- m_nShadowSize = nShadowSize;
- m_nBr0 = nBr0;
- m_nBr1 = nBr1;
- m_bEnablePhotos = bEnablePhotos;
- m_bEnablePaintManagerColor = bEnablePaintManagerColor;
- return
- Paint(
- pPM,
- dc,
- m_bMakePhotosOnly,
- hWndStatic,
- hWndFloat,
- pRectCustomFloatPos
- );
- }
- bool CExtWndShadow::Paint(
- CExtPaintManager * pPM,
- CDC & dc,
- bool m_bMakePhotosOnly, // = false
- HWND hWndStatic, // = NULL
- HWND hWndFloat, // = NULL
- LPCRECT pRectCustomFloatPos // = NULL
- )
- {
- ASSERT( m_nShadowSize >= 0 );
- ASSERT( ! m_rcWndArea.IsRectEmpty() );
- if( m_nShadowSize == 0
- || m_rcWndArea.IsRectEmpty()
- )
- return true;
- if( hWndFloat != NULL )
- {
- ASSERT( hWndStatic != NULL );
- ASSERT( ::IsWindow( hWndFloat ) );
- ASSERT( ::IsWindow( hWndStatic ) );
- __EXT_MFC_LONG_PTR dwStyle = ::__EXT_MFC_GetWindowLong(hWndFloat,GWL_STYLE);
- if( (dwStyle&WS_VISIBLE) == 0 )
- hWndFloat = hWndStatic = NULL;
- } // if( hWndFloat != NULL )
- else
- {
- hWndStatic = NULL;
- } // else from if( hWndFloat != NULL )
- if( ! _HaveOriginals() )
- _MakeOriginals( dc );
- INT nWndAreaDX = m_rcWndArea.Width();
- INT nWndAreaDY = m_rcWndArea.Height();
- if( m_rgnSafe.GetSafeHandle() == NULL
- && (! m_rc1stArea.IsRectEmpty() )
- && (! m_rc2ndArea.IsRectEmpty() )
- )
- {
- CRect rc1(
- m_rcWndArea.right,
- m_rcWndArea.top,
- m_rcWndArea.right + m_nShadowSize,
- m_rcWndArea.top + nWndAreaDY + m_nShadowSize
- );
- CRect rc2(
- m_rcWndArea.left,
- m_rcWndArea.bottom,
- m_rcWndArea.left + nWndAreaDX + m_nShadowSize,
- m_rcWndArea.bottom + m_nShadowSize
- );
- m_rgnSafe.CreateRectRgnIndirect( &rc1 );
- if( m_rgnSafe.GetSafeHandle() != NULL )
- {
- CRgn rgnSecond;
- rgnSecond.CreateRectRgnIndirect( &rc2 );
- if( rgnSecond.GetSafeHandle() != NULL
- && m_rgnSafe.CombineRgn( &m_rgnSafe, &rgnSecond, RGN_OR ) != ERROR
- )
- {
- }
- else
- m_rgnSafe.DeleteObject();
- } // if( m_rgnSafe.GetSafeHandle() != NULL )
- } // if( m_rgnSafe.GetSafeHandle() == NULL ...
- if( m_bMakePhotosOnly && m_bEnablePhotos )
- {
- CDC dcCache;
- CBitmap bmpCache;
- int nDX = nWndAreaDX + m_nShadowSize;
- int nDY = nWndAreaDY + m_nShadowSize;
- nDX += m_rc2ndArea.Width();
- nDY += m_rc2ndArea.Height();
- if( dcCache.CreateCompatibleDC( &dc )
- && bmpCache.CreateCompatibleBitmap( &dc, nDX, nDY )
- )
- {
- CBitmap * pOldBmp = dcCache.SelectObject( &bmpCache );
- bool bRetVal = false;
- if( dcCache.BitBlt(
- 0, 0, nDX, nDY,
- &dc, 0, 0, SRCCOPY
- )
- )
- {
- bRetVal = Paint( pPM, dcCache, false );
- ASSERT( bRetVal );
- }
- #ifdef _DEBUG
- else
- {
- ASSERT( FALSE );
- }
- #endif // _DEBUG
- dcCache.SelectObject( pOldBmp );
- return bRetVal;
- }
- #ifdef _DEBUG
- else
- {
- ASSERT( FALSE );
- }
- #endif // _DEBUG
- } // if( m_bMakePhotosOnly && m_bEnablePhotos )
- if( m_rgnSafe.GetSafeHandle() != NULL )
- dc.SelectClipRgn( &m_rgnSafe, RGN_AND );
- bool bRetVal = true, bDoPaint = false;
- if( _HaveOriginals() && hWndStatic != NULL && hWndFloat != NULL )
- bDoPaint = true;
- if( ! bDoPaint )
- {
- if( ! Restore( dc ) )
- bDoPaint = true;
- }
- if( bDoPaint )
- {
- if( CExtPaintManager::stat_GetBPP() > 8 )
- bRetVal =
- _PaintHi(
- pPM,
- dc,
- hWndStatic,
- hWndFloat,
- pRectCustomFloatPos
- );
- else
- bRetVal =
- _PaintLo(
- pPM,
- dc,
- hWndStatic,
- hWndFloat,
- pRectCustomFloatPos
- );
- }
- if( m_rgnSafe.GetSafeHandle() != NULL )
- dc.SelectClipRgn( NULL );
- return bRetVal;
- }
- bool CExtWndShadow::_PaintLo(
- CExtPaintManager * pPM,
- CDC & dc,
- HWND hWndStatic, // = NUL
- HWND hWndFloat, // = NULL
- LPCRECT pRectCustomFloatPos // = NULL
- )
- {
- if( pPM == NULL )
- pPM = g_PaintManager.GetPM();
- ASSERT_VALID( pPM );
- INT nWndAreaDX = m_rcWndArea.Width();
- INT nWndAreaDY = m_rcWndArea.Height();
- if( m_bmp0mak.GetSafeHandle() != NULL )
- m_bmp0mak.DeleteObject();
- if( m_bmp1mak.GetSafeHandle() != NULL )
- m_bmp1mak.DeleteObject();
- static int _Pattern[] =
- {
- ~0xAA,
- ~0x55,
- ~0xAA,
- ~0x55,
- ~0xAA,
- ~0x55,
- ~0xAA,
- ~0x55
- };
- CBitmap _bitmapPattern;
- CBrush _brushPattern;
- if( (! _bitmapPattern.CreateBitmap( 8, 8, 1, 1, _Pattern ) )
- || (! _brushPattern.CreatePatternBrush( &_bitmapPattern ) )
- )
- return false;
- CRect rcMM(
- m_rcWndArea.left,
- m_rcWndArea.top,
- m_rcWndArea.right + nWndAreaDX,
- m_rcWndArea.bottom + nWndAreaDY
- );
- CExtMemoryDC dcmm(
- &dc,
- &rcMM,
- /// CExtMemoryDC::MDCOPT_RTL_COMPATIBILITY |
- CExtMemoryDC::MDCOPT_TO_MEMORY
- );
- ASSERT( dcmm.GetSafeHdc() != NULL );
- if( dcmm.GetSafeHdc() == NULL )
- return false;
- dcmm.SetViewportOrg( 0, 0 );
- dcmm.SetWindowOrg( 0, 0 );
- CPalette * pOldPalette = NULL;
- if( (::GetDeviceCaps(dcmm.m_hDC,RASTERCAPS) & RC_PALETTE) != 0 )
- {
- pOldPalette =
- dcmm.SelectPalette( & pPM->m_PaletteWide, FALSE );
- dcmm.RealizePalette();
- }
- dcmm.BitBlt(
- 0,
- 0,
- nWndAreaDX + m_nShadowSize,
- nWndAreaDY + m_nShadowSize,
- &dc,
- m_rcWndArea.left,
- m_rcWndArea.top,
- SRCCOPY
- );
- if( _HaveOriginals() )
- _RestoreOriginals( dcmm );
- if( hWndStatic != NULL && hWndFloat != NULL )
- {
- ASSERT( ::IsWindow(hWndStatic) );
- ASSERT( ::IsWindow(hWndFloat) );
- CRect rcWndStatic = m_rcWndArea, rcWndFloat;
- ::ClientToScreen( hWndStatic, ((LPPOINT)(&rcWndStatic)) );
- ::ClientToScreen( hWndStatic, ((LPPOINT)(&rcWndStatic))+1 );
- if( pRectCustomFloatPos != NULL )
- rcWndFloat = (*pRectCustomFloatPos);
- else
- ::GetWindowRect( hWndFloat, rcWndFloat );
- HBITMAP hBmpFloat =
- CExtPaintManager::stat_PrintWnd( hWndFloat );
- if( hBmpFloat == NULL )
- {
- ASSERT( FALSE );
- return false;
- }
- CPoint ptOffset =
- rcWndFloat.TopLeft()
- - rcWndStatic.TopLeft()
- ;
- CBitmap _bmpFloatDestructor;
- _bmpFloatDestructor.Attach( hBmpFloat );
- BITMAP _bmpInfo;
- ::memset( &_bmpInfo, 0, sizeof(BITMAP) );
- ::GetObject( hBmpFloat, sizeof(BITMAP), &_bmpInfo );
- if( ! ( _bmpInfo.bmWidth > 0 && _bmpInfo.bmHeight > 0 ) )
- {
- ASSERT( FALSE );
- return false;
- }
- CDC dcSrc;
- if(! dcSrc.CreateCompatibleDC( NULL ) )
- {
- ASSERT( FALSE );
- return false;
- }
- HGDIOBJ hBmpOldSrc = ::SelectObject( dcSrc.GetSafeHdc(), hBmpFloat );
- dcmm.BitBlt(
- ptOffset.x,
- ptOffset.y,
- _bmpInfo.bmWidth,
- _bmpInfo.bmHeight,
- &dcSrc,
- 0,
- 0,
- SRCCOPY
- );
- ::SelectObject( dcSrc.GetSafeHdc(), hBmpOldSrc );
- _bmpFloatDestructor.DeleteObject();
- } // if( hWndStatic != NULL && hWndFloat != NULL )
- UINT nPaintShadowSize =
- ( m_nShadowSize > 4 )
- ? 4
- : m_nShadowSize
- ;
- CRect rV( nWndAreaDX,
- nPaintShadowSize,
- nWndAreaDX + nPaintShadowSize,
- nWndAreaDY
- );
- CRect rH( nPaintShadowSize,
- nWndAreaDY,
- nWndAreaDX + nPaintShadowSize,
- nWndAreaDY + nPaintShadowSize
- );
- CBrush * pOldBrush = dcmm.SelectObject( &_brushPattern );
- dcmm.PatBlt( rH.left, rH.top, rH.Width(), rH.Height(), 0xA000C9 );
- dcmm.PatBlt( rV.left, rV.top, rV.Width(), rV.Height(), 0xA000C9 );
- dcmm.SelectObject( pOldBrush );
- dc.ExcludeClipRect( &m_rcWndArea );
- if( m_rgnSafe.GetSafeHandle() != NULL )
- dc.SelectClipRgn( &m_rgnSafe, RGN_AND );
- dc.BitBlt(
- m_rcWndArea.left,
- m_rcWndArea.top,
- nWndAreaDX + m_nShadowSize,
- nWndAreaDY + m_nShadowSize,
- &dcmm,
- 0,
- 0,
- SRCCOPY
- );
- dc.SelectClipRgn( NULL );
- if( m_bEnablePhotos )
- {
- if( ! _MakePhotos(dc,dcmm) )
- {
- ASSERT( FALSE );
- return false;
- }
- }
- if( pOldPalette != NULL )
- dcmm.SelectPalette( pOldPalette, FALSE );
- dcmm.__Flush( FALSE );
- return true;
- }
- bool CExtWndShadow::_PaintHi(
- CExtPaintManager * pPM,
- CDC & dc,
- HWND hWndStatic, // = NULL
- HWND hWndFloat, // = NULL
- LPCRECT pRectCustomFloatPos // = NULL
- )
- {
- if( pPM == NULL )
- pPM = g_PaintManager.GetPM();
- ASSERT_VALID( pPM );
- INT nWndAreaDX = m_rcWndArea.Width();
- INT nWndAreaDY = m_rcWndArea.Height();
- CDC dcmm;
- if( ! dcmm.CreateCompatibleDC( &dc ) )
- {
- ASSERT( FALSE );
- return false;
- }
- COLORREF clrShadowAdjust = ((COLORREF)(-1));
- if( m_bEnablePaintManagerColor )
- clrShadowAdjust = pPM->GetShadowAdjustColor();
- BITMAPINFOHEADER bih;
- bih.biSize = sizeof(BITMAPINFOHEADER);
- bih.biWidth = nWndAreaDX+m_nShadowSize;
- bih.biHeight = nWndAreaDY+m_nShadowSize;
- bih.biPlanes = 1;
- bih.biBitCount = 32;
- bih.biCompression = BI_RGB;
- bih.biSizeImage = (nWndAreaDX+m_nShadowSize) * (nWndAreaDY+m_nShadowSize);
- bih.biXPelsPerMeter = 0;
- bih.biYPelsPerMeter = 0;
- bih.biClrUsed = 0;
- bih.biClrImportant = 0;
- ASSERT( m_pHelperDibSurface == NULL );
- HBITMAP hDIB =
- ::CreateDIBSection(
- dcmm.GetSafeHdc(),
- (LPBITMAPINFO)&bih,
- DIB_RGB_COLORS,
- (void **)&m_pHelperDibSurface,
- NULL,
- NULL
- );
- if( hDIB == NULL || m_pHelperDibSurface == NULL )
- {
- ASSERT( FALSE );
- return false;
- }
- HGDIOBJ hOldSurface = dcmm.SelectObject( hDIB );
- dcmm.BitBlt(
- 0,
- 0,
- nWndAreaDX + m_nShadowSize,
- nWndAreaDY + m_nShadowSize,
- &dc,
- m_rcWndArea.left,
- m_rcWndArea.top,
- SRCCOPY
- );
- if( _HaveOriginals() )
- _RestoreOriginals( dcmm );
- if( hWndStatic != NULL && hWndFloat != NULL )
- {
- ASSERT( ::IsWindow(hWndStatic) );
- ASSERT( ::IsWindow(hWndFloat) );
- CRect rcWndStatic = m_rcWndArea, rcWndFloat;
- ::ClientToScreen( hWndStatic, ((LPPOINT)(&rcWndStatic)) );
- ::ClientToScreen( hWndStatic, ((LPPOINT)(&rcWndStatic))+1 );
- if( pRectCustomFloatPos != NULL )
- rcWndFloat = (*pRectCustomFloatPos);
- else
- ::GetWindowRect( hWndFloat, rcWndFloat );
- HBITMAP hBmpFloat =
- CExtPaintManager::stat_PrintWnd( hWndFloat );
- if( hBmpFloat == NULL )
- {
- ASSERT( FALSE );
- return false;
- }
- CPoint ptOffset =
- rcWndFloat.TopLeft()
- - rcWndStatic.TopLeft()
- ;
- CBitmap _bmpFloatDestructor;
- _bmpFloatDestructor.Attach( hBmpFloat );
- BITMAP _bmpInfo;
- ::memset( &_bmpInfo, 0, sizeof(BITMAP) );
- ::GetObject( hBmpFloat, sizeof(BITMAP), &_bmpInfo );
- if( ! ( _bmpInfo.bmWidth > 0 && _bmpInfo.bmHeight > 0 ) )
- {
- ASSERT( FALSE );
- return false;
- }
- CDC dcSrc;
- if( ! dcSrc.CreateCompatibleDC( NULL ) )
- {
- ASSERT( FALSE );
- return false;
- }
- HGDIOBJ hBmpOldSrc = ::SelectObject( dcSrc.GetSafeHdc(), hBmpFloat );
- dcmm.BitBlt(
- ptOffset.x,
- ptOffset.y,
- _bmpInfo.bmWidth,
- _bmpInfo.bmHeight,
- &dcSrc,
- 0,
- 0,
- SRCCOPY
- );
- ::SelectObject( dcSrc.GetSafeHdc(), hBmpOldSrc );
- _bmpFloatDestructor.DeleteObject();
- } // if( hWndStatic != NULL && hWndFloat != NULL )
- UINT nBrDiff = m_nBr1 - m_nBr0;
- LONG n2nd, nStep, nDist, nDist1;
- LONG nDist2 = m_nShadowSize * m_nShadowSize;
- INT nMakeSpec;
- bool bCmbaV = false, bCmbaH = false,
- bCmbaVrt = false, bCmbaVrb = false,
- bCmbaHrb = false, bCmbaHlb = false,
- bCmbaLA = false;
- INT nX0 = 0, nX1 = nWndAreaDX,
- nY0 = 0, nY1 = nWndAreaDY,
- nLa0 = 0, nLa1 = 0;
- if( !( m_rc1stArea.IsRectEmpty() || m_rc2ndArea.IsRectEmpty() ) )
- {
- bool bCmbaDetected = false;
- if( m_rc1stArea.right == m_rc2ndArea.right )
- { // vertical-right combining
- bCmbaDetected = true;
- if( m_rc1stArea.top < m_rc2ndArea.top )
- bCmbaVrb = true;
- else
- bCmbaVrt = true;
- } // vertical-right combining
- if( (! bCmbaDetected )
- && m_rc1stArea.left == m_rc2ndArea.left
- )
- { // vertical-left combining
- if( m_rc2ndArea.bottom >= m_rc1stArea.top-1
- && m_rc2ndArea.top < m_rc1stArea.top
- )
- {
- if( m_rc2ndArea.right >= m_rc1stArea.right )
- {
- bCmbaDetected = true;
- bCmbaV = true;
- }
- }
- if( (! bCmbaDetected )
- && m_rc1stArea.bottom >= m_rc2ndArea.top-1
- && m_rc1stArea.top < m_rc2ndArea.top
- )
- {
- if( m_rc1stArea.right >= m_rc2ndArea.right )
- {
- bCmbaDetected = true;
- bCmbaH = true;
- nX0 =
- m_rcWndArea.right -
- (m_rc1stArea.right - m_rc2ndArea.right);
- }
- }
- } // vertical-left combining
- if( (! bCmbaDetected )
- && m_rc1stArea.bottom == m_rc2ndArea.bottom
- )
- { // horizontal-bottom combining
- bCmbaDetected = true;
- if( m_rc1stArea.left < m_rc2ndArea.left )
- bCmbaHrb = true;
- else
- bCmbaHlb = true;
- } // horizontal-bottom combining
- if( (!bCmbaDetected)
- && m_rc1stArea.right == m_rc2ndArea.left+1
- )
- {
- bCmbaDetected = true;
- bCmbaLA = true;
- nLa0 = m_rcWndArea.top
- + m_rc2ndArea.bottom - m_rc1stArea.top;
- nLa1 = nLa0 + m_nShadowSize;
- }
- if( (! bCmbaDetected )
- && m_rc1stArea.left == m_rc2ndArea.right - 1
- )
- {
- bCmbaDetected = true;
- bCmbaH = true;
- }
- bCmbaDetected;
- } // if( !( m_rc1stArea.IsRectEmpty() || m_rc2ndArea.IsRectEmpty() ) )
- for( nStep = 0; ULONG(nStep) < m_nShadowSize; nStep++ )
- {
- nMakeSpec = m_nBr0 + ( nStep * nBrDiff ) / m_nShadowSize;
- for( n2nd = nX0
- + m_nShadowSize * 2 + 1
- - ( bCmbaH ? ( m_nShadowSize * 2 - nStep ) : 0 )
- - ( bCmbaHlb ? m_nShadowSize : 0 )
- ;
- n2nd < LONG(nX1) + ( bCmbaHrb ? LONG(m_nShadowSize) : 0 );
- n2nd++
- )
- _DoPixelOvershadow(
- nMakeSpec,
- n2nd,
- nY1 + nStep,
- clrShadowAdjust
- );
- for( n2nd = nY0
- + m_nShadowSize*2+1
- - ( bCmbaV ? ( m_nShadowSize * 2 - nStep ) : 0 )
- - ( bCmbaVrt ? m_nShadowSize : 0 )
- ;
- n2nd < LONG(nY1) + ( bCmbaVrb ? LONG(m_nShadowSize) : 0 );
- n2nd++
- )
- {
- if( bCmbaLA
- && n2nd >= nLa0
- && n2nd < LONG(nLa1) - ( LONG(m_nShadowSize) - nStep )
- )
- {
- continue;
- }
- _DoPixelOvershadow(
- nMakeSpec,
- nX1 + nStep,
- n2nd,
- clrShadowAdjust
- );
- }
- nDist1 = nStep*nStep;
- for( n2nd = 0; ULONG(n2nd) < m_nShadowSize; n2nd++ )
- {
- nDist = nDist1 + n2nd * n2nd;
- if( nDist > nDist2 )
- continue;
- nDist = (LONG)::sqrt( double(nDist) );
- nMakeSpec = m_nBr0 + ( nDist * nBrDiff ) / m_nShadowSize;
- if( ! ( bCmbaVrb || bCmbaHrb ) )
- _DoPixelOvershadow(
- nMakeSpec,
- nX1 + nStep,
- nY1 + n2nd,
- clrShadowAdjust
- );
- if( ! ( bCmbaH || bCmbaHlb ) )
- _DoPixelOvershadow(
- nMakeSpec,
- m_nShadowSize + ( m_nShadowSize - nStep ),
- nY1 + n2nd,
- clrShadowAdjust
- );
- if( ! ( bCmbaV || bCmbaVrt ) )
- _DoPixelOvershadow(
- nMakeSpec,
- nX1 + nStep,
- m_nShadowSize + ( m_nShadowSize - n2nd ),
- clrShadowAdjust
- );
- } // for( n2nd = 0; ULONG(n2nd) < m_nShadowSize; n2nd++ )
- } // for( nStep = 0; ULONG(nStep) < m_nShadowSize; nStep++ )
- dc.ExcludeClipRect( &m_rcWndArea );
- if( m_rgnSafe.GetSafeHandle() != NULL )
- dc.SelectClipRgn( &m_rgnSafe, RGN_AND );
- dc.BitBlt(
- m_rcWndArea.left,
- m_rcWndArea.top,
- nWndAreaDX + m_nShadowSize,
- nWndAreaDY + m_nShadowSize,
- &dcmm,
- 0,
- 0,
- SRCCOPY
- );
- dc.SelectClipRgn( NULL );
- bool bRetVal = true;
- if( m_bEnablePhotos )
- {
- if( ! _MakePhotos( dc, dcmm ) )
- {
- ASSERT( FALSE );
- bRetVal = false;
- } // if( ! _MakePhotos( dc, dcmm ) )
- } // if( m_bEnablePhotos )
- if( hOldSurface != NULL )
- dcmm.SelectObject( hOldSurface );
- ::DeleteObject( hDIB );
- m_pHelperDibSurface = NULL;
- return bRetVal;
- }
- bool CExtWndShadow::_MakePhotos( CDC & dc, CDC & dcmm )
- {
- ASSERT( m_nShadowSize >= 0 );
- ASSERT( ! m_rcWndArea.IsRectEmpty() );
- INT nWndAreaDX = m_rcWndArea.Width();
- INT nWndAreaDY = m_rcWndArea.Height();
- if( m_bmp0mak.GetSafeHandle() != NULL )
- m_bmp0mak.DeleteObject();
- if( m_bmp1mak.GetSafeHandle() != NULL )
- m_bmp1mak.DeleteObject();
- if( ! m_bmp0mak.CreateCompatibleBitmap(
- &dc,
- m_nShadowSize,
- nWndAreaDY + m_nShadowSize
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- dcmm.SelectObject( &m_bmp0mak );
- if( ! dcmm.BitBlt(
- 0,
- 0,
- m_nShadowSize,
- nWndAreaDY + m_nShadowSize,
- &dc,
- m_rcWndArea.right,
- m_rcWndArea.top,
- SRCCOPY
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- if( ! m_bmp1mak.CreateCompatibleBitmap(
- &dc,
- nWndAreaDX + m_nShadowSize,
- m_nShadowSize
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- dcmm.SelectObject( &m_bmp1mak );
- if( ! dcmm.BitBlt(
- 0,
- 0,
- nWndAreaDX + m_nShadowSize,
- m_nShadowSize,
- &dc,
- m_rcWndArea.left,
- m_rcWndArea.bottom,
- SRCCOPY
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- return true;
- }
- bool CExtWndShadow::_MakeOriginals( CDC & dc )
- {
- ASSERT( m_nShadowSize >= 0 );
- ASSERT( ! m_rcWndArea.IsRectEmpty() );
- INT nWndAreaDX = m_rcWndArea.Width();
- INT nWndAreaDY = m_rcWndArea.Height();
- ASSERT(
- m_bmp0org.GetSafeHandle() == NULL
- && m_bmp1org.GetSafeHandle() == NULL
- );
- CDC dcmm;
- if( ! dcmm.CreateCompatibleDC( NULL ) )
- {
- ASSERT( FALSE );
- return false;
- }
- if( ! m_bmp0org.CreateCompatibleBitmap(
- &dc,
- m_nShadowSize,
- nWndAreaDY + m_nShadowSize
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- CBitmap * pOldBmp = dcmm.SelectObject( &m_bmp0org );
- if( ! dcmm.BitBlt(
- 0,
- 0,
- m_nShadowSize,
- nWndAreaDY + m_nShadowSize,
- &dc,
- m_rcWndArea.right,
- m_rcWndArea.top,
- SRCCOPY
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- if( ! m_bmp1org.CreateCompatibleBitmap(
- &dc,
- nWndAreaDX + m_nShadowSize,
- m_nShadowSize
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- dcmm.SelectObject( &m_bmp1org );
- if( ! dcmm.BitBlt(
- 0,
- 0,
- nWndAreaDX + m_nShadowSize,
- m_nShadowSize,
- &dc,
- m_rcWndArea.left,
- m_rcWndArea.bottom,
- SRCCOPY
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- dcmm.SelectObject( pOldBmp );
- return true;
- }
- void CExtWndShadow::_FreeWinObjects()
- {
- if( m_bmp0org.GetSafeHandle() != NULL )
- m_bmp0org.DeleteObject();
- if( m_bmp1org.GetSafeHandle() != NULL )
- m_bmp1org.DeleteObject();
- if( m_bmp0mak.GetSafeHandle() != NULL )
- m_bmp0mak.DeleteObject();
- if( m_bmp1mak.GetSafeHandle() != NULL )
- m_bmp1mak.DeleteObject();
- m_pHelperDibSurface = NULL;
- }
- void CExtWndShadow::Destroy()
- {
- _FreeWinObjects();
- m_rcWndArea.SetRectEmpty();
- m_rgnSafe.DeleteObject();
- m_bEnablePhotos = false;
- m_bEnablePaintManagerColor = false;
- }
- void CExtWndShadow::PostReShadow()
- {
- if( m_bmp0org.GetSafeHandle() != NULL
- && m_bmp1org.GetSafeHandle() != NULL
- && m_bmp0mak.GetSafeHandle() != NULL
- && m_bmp1mak.GetSafeHandle() != NULL
- )
- {
- m_bmp0mak.DeleteObject();
- m_bmp1mak.DeleteObject();
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtPopupMenuWnd::MENUITEMDATA
- CExtPopupMenuWnd::MENUITEMDATA::MENUITEMDATA(
- CExtPopupMenuWnd * pOwner // = NULL
- )
- : m_cAccelChar( _T(' ') )
- , m_pOwner( pOwner )
- {
- // self constant type assertion
- ASSERT( TYPE_SEPARATOR==ID_SEPARATOR );
- m_pWndChild = NULL;
- m_nItemIndex = -100;
- m_nCmdID = TYPE_SEPARATOR;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_pCmdNode = NULL;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_sItemText = m_sAccelText = m_sExtendedText = _T("");
- m_sizeItem.cx = m_sizeItem.cy = 0;
- m_nIconAreaWidth = 0;
- m_bSelected
- = m_bDisplayed
- = m_bForceDisplayed
- = m_bChildCombine
- = m_bToolButton
- = m_bToolWrap
- = m_bBold
- = m_bDefault
- = m_bEnabledAppearance
- = m_bBigAccent
- = m_bForcePopupDisabled
- = m_bForceEnabled
- = m_bForceNoLeftGradient
- = m_bCheck
- = m_bRadio
- = m_bIndeterminate
- = m_bXtraChecked
- = m_bNoCmdUI
- = m_bIconMode
- = false;
- m_pCbCmdDeliver = NULL;
- m_pCbXtraMarkState = NULL;
- m_bEnabled = true;
- m_hWndSpecCmdReceiver = NULL;
- m_pHelperInplaceEditWnd = NULL;
- m_pInplaceEditStr = NULL;
- m_pCbVerifyTextInput = NULL;
- m_pCbPutTextInputResult = NULL;
- m_pInplaceEditCbWndProc = NULL;
- m_pInplaceEditCbCookie = NULL;
- m_nInplaceEditWidth = 0;
- m_bAllowInplaceEditActivation = true;
- m_nLParam = 0L;
- m_bTempSelTextValid = false;
- m_sTempSelText.Empty();
- m_nMarginLeft
- = m_nMarginTop
- = m_nMarginRight
- = m_nMarginBottom
- = -1;
- m_rcCacheBasic.SetRect( 0, 0, 0, 0 );
- m_rcCacheIndents.SetRect( 0, 0, 0, 0 );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_pWndKeyTipBasic = m_pWndKeyTipDD = NULL;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- }
- CExtPopupMenuWnd::MENUITEMDATA::MENUITEMDATA(
- const CExtPopupMenuWnd::MENUITEMDATA & other
- )
- : m_cAccelChar( _T(' ') )
- {
- m_pOwner = other.m_pOwner;
- // self constant type assertion
- ASSERT( TYPE_SEPARATOR==ID_SEPARATOR );
- m_pWndChild = NULL;
- m_nItemIndex = -100;
- m_nCmdID = TYPE_SEPARATOR;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_pCmdNode = NULL;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_sItemText = m_sAccelText = m_sExtendedText = _T("");
- m_sizeItem.cx = m_sizeItem.cy = 0;
- m_nIconAreaWidth = 0;
- m_bSelected
- = m_bDisplayed
- = m_bForceDisplayed
- = m_bChildCombine
- = m_bToolButton
- = m_bToolWrap
- = m_bBold
- = m_bDefault
- = m_bEnabledAppearance
- = m_bBigAccent
- = m_bForcePopupDisabled
- = m_bForceEnabled
- = m_bForceNoLeftGradient
- = m_bCheck
- = m_bRadio
- = m_bIndeterminate
- = m_bXtraChecked
- = m_bNoCmdUI
- = m_bIconMode
- = false;
- m_pCbCmdDeliver = NULL;
- m_pCbXtraMarkState = NULL;
- m_bEnabled = true;
- m_hWndSpecCmdReceiver = NULL;
- m_pHelperInplaceEditWnd = NULL;
- m_pInplaceEditStr = NULL;
- m_pCbVerifyTextInput = NULL;
- m_pCbPutTextInputResult = NULL;
- m_pInplaceEditCbWndProc = NULL;
- m_pInplaceEditCbCookie = NULL;
- m_nInplaceEditWidth = 0;
- m_bAllowInplaceEditActivation = true;
- m_nLParam = 0L;
- m_bTempSelTextValid = false;
- m_sTempSelText.Empty();
- m_rcCacheBasic.SetRect( 0, 0, 0, 0 );
- m_rcCacheIndents.SetRect( 0, 0, 0, 0 );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_pWndKeyTipBasic = m_pWndKeyTipDD = NULL;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- AssignFromOther( other );
- }
- CExtPopupMenuWnd::MENUITEMDATA::~MENUITEMDATA()
- {
- // DestroyPopup();
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- HDWP hPassiveModeDWP = NULL;
- KeyTipTrackingQuery( false, NULL, hPassiveModeDWP );
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdKeyTip * CExtPopupMenuWnd::MENUITEMDATA::KeyTipGetInfo(
- bool bBasic
- )
- {
- CExtCustomizeCmdTreeNode * pNode = GetCmdNode();
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- CExtCustomizeCmdKeyTip * pCmdKeyTip = pNode->CmdKeyTipGet( bBasic );
- return pCmdKeyTip;
- }
- return NULL;
- }
- CExtSafeString CExtPopupMenuWnd::MENUITEMDATA::KeyTipGetText(
- INT nIndent,
- bool bBasic
- )
- {
- CExtSafeString strKeyTipText( _T("") );
- CExtCustomizeCmdKeyTip * pCmdKeyTip = KeyTipGetInfo( bBasic );
- if( pCmdKeyTip != NULL )
- strKeyTipText = pCmdKeyTip->GetTipText( nIndent );
- return strKeyTipText;
- }
- CWnd * CExtPopupMenuWnd::MENUITEMDATA::KeyTipGetParentWnd()
- {
- CExtPopupMenuWnd * pOwnerPopupMenuWnd = GetOwner();
- if( pOwnerPopupMenuWnd->GetSafeHwnd() == NULL )
- return NULL;
- ASSERT_VALID( pOwnerPopupMenuWnd );
- return pOwnerPopupMenuWnd;
- }
- CPoint CExtPopupMenuWnd::MENUITEMDATA::KeyTipGetGuideLines(
- bool bBasic
- )
- {
- CExtPopupMenuWnd * pOwnerPopupMenuWnd = GetOwner();
- ASSERT( pOwnerPopupMenuWnd->GetSafeHwnd() != NULL );
- ASSERT_VALID( pOwnerPopupMenuWnd );
- CRect rc = GetCachedRect( false );
- pOwnerPopupMenuWnd->ClientToScreen( &rc );
- if( bBasic )
- {
- int nIconAreaWidth = GetIconAreaWidth();
- CPoint ptGuideLines(
- rc.left + nIconAreaWidth,
- rc.bottom
- );
- return ptGuideLines;
- }
- else
- {
- CPoint ptGuideLines(
- rc.right,
- rc.bottom
- );
- return ptGuideLines;
- }
- }
- CExtPopupKeyTipWnd * CExtPopupMenuWnd::MENUITEMDATA::KeyTipGetWnd(
- bool bBasic
- )
- {
- #ifdef _DEBUG
- if( m_pWndKeyTipBasic != NULL )
- {
- ASSERT_VALID( m_pWndKeyTipBasic );
- }
- if( m_pWndKeyTipDD != NULL )
- {
- ASSERT_VALID( m_pWndKeyTipDD );
- }
- #endif // _DEBUG
- return bBasic ? m_pWndKeyTipBasic : m_pWndKeyTipDD;
- }
- void CExtPopupMenuWnd::MENUITEMDATA::KeyTipTrackingQuery(
- bool bShow,
- CExtCustomizeCmdKeyTip * pKeyTipChain,
- HDWP & hPassiveModeDWP
- )
- {
- if( bShow )
- {
- CExtPopupMenuWnd * pOwnerPopupMenuWnd = GetOwner();
- ASSERT( pOwnerPopupMenuWnd->GetSafeHwnd() != NULL );
- ASSERT_VALID( pOwnerPopupMenuWnd );
- INT nKTI, nIndent = pKeyTipChain->KeyCodeGetCount();
- for( nKTI = 0; nKTI < 2; nKTI++ )
- {
- bool bBasic = ( nKTI == 0 ) ? true : false;
- CExtPopupKeyTipWnd *& pWndKeyTip = bBasic ? m_pWndKeyTipBasic : m_pWndKeyTipDD;
- ASSERT_VALID( pKeyTipChain );
- CExtSafeString strKeyTipText = KeyTipGetText( nIndent, bBasic );
- if( strKeyTipText.IsEmpty() )
- continue;
- if( pWndKeyTip == NULL )
- {
- try
- {
- pWndKeyTip = new CExtPopupKeyTipWnd;
- }
- catch( CException * pException )
- {
- pException->Delete();
- continue;
- }
- } // if( pWndKeyTip == NULL )
- #ifdef _DEBUG
- else
- {
- ASSERT_VALID( pWndKeyTip );
- } // else from if( pWndKeyTip == NULL )
- #endif // _DEBUG
- CWnd * pWndKeyTipParent = KeyTipGetParentWnd();
- ASSERT_VALID( pWndKeyTipParent );
- ASSERT( pWndKeyTipParent->GetSafeHwnd() != NULL );
- CPoint ptGuideLines = KeyTipGetGuideLines( bBasic );
- if( ! pWndKeyTip->Create(
- pWndKeyTipParent,
- ptGuideLines,
- strKeyTipText,
- IsEnabled(),
- hPassiveModeDWP
- )
- )
- {
- delete pWndKeyTip;
- pWndKeyTip = NULL;
- continue;
- }
- pWndKeyTip->ShowWindow( SW_SHOWNOACTIVATE );
- } // for( nKTI = 0; nKTI < 2; nKTI++ )
- } // if( bShow )
- else
- {
- if( m_pWndKeyTipBasic != NULL )
- {
- m_pWndKeyTipBasic->Hide();
- delete m_pWndKeyTipBasic;
- m_pWndKeyTipBasic = NULL;
- }
- if( m_pWndKeyTipDD != NULL )
- {
- m_pWndKeyTipDD->Hide();
- delete m_pWndKeyTipDD;
- m_pWndKeyTipDD = NULL;
- }
- } // else from if( bShow )
- }
- bool CExtPopupMenuWnd::MENUITEMDATA::KeyTipTranslate(
- DWORD dwKeyCode,
- CExtCustomizeCmdKeyTip * pKeyTipChain
- )
- {
- ASSERT_VALID( pKeyTipChain );
- CExtPopupMenuWnd * pOwnerPopupMenuWnd = GetOwner();
- if( pOwnerPopupMenuWnd->GetSafeHwnd() == NULL )
- return false;
- ASSERT_VALID( pOwnerPopupMenuWnd );
- if( ! IsEnabled() )
- return false;
- INT nKTI;
- for( nKTI = 0; nKTI < 2; nKTI++ )
- {
- bool bBasic = ( nKTI == 0 ) ? true : false;
- CExtCustomizeCmdKeyTip * pCmdKeyTip = KeyTipGetInfo( bBasic );
- if( pCmdKeyTip == NULL )
- continue;
- CExtPopupKeyTipWnd * pWndKeyTip = KeyTipGetWnd( bBasic );
- if( pWndKeyTip->GetSafeHwnd() == NULL
- || ( pWndKeyTip->GetStyle() & WS_VISIBLE ) == 0
- )
- continue;
- if( ! pCmdKeyTip->CompareWidthChain( *pKeyTipChain ) )
- continue;
- INT nKeyCodeCountOwn = pCmdKeyTip->KeyCodeGetCount();
- INT nKeyCodeCountChain = pKeyTipChain->KeyCodeGetCount();
- ASSERT( nKeyCodeCountOwn > nKeyCodeCountChain );
- DWORD dwKeyCodeOwn = pCmdKeyTip->KeyCodeGetAt( nKeyCodeCountChain );
- if( dwKeyCodeOwn != dwKeyCode )
- continue;
- pKeyTipChain->KeyCodeAdd( dwKeyCode );
- nKeyCodeCountChain++;
- if( nKeyCodeCountOwn > nKeyCodeCountChain )
- return true;
- KeyTipInvokeAction( bBasic );
- return true;
- } // for( nKTI = 0; nKTI < 2; nKTI++ )
- return false;
- }
- void CExtPopupMenuWnd::MENUITEMDATA::KeyTipDisplay(
- CExtCustomizeCmdKeyTip & keyTipChain
- )
- {
- ASSERT_VALID( (&keyTipChain) );
- CExtPopupMenuWnd * pOwnerPopupMenuWnd = GetOwner();
- if( pOwnerPopupMenuWnd->GetSafeHwnd() == NULL )
- return;
- ASSERT_VALID( pOwnerPopupMenuWnd );
- // if( ! IsEnabled() )
- // return;
- INT nKTI;
- for( nKTI = 0; nKTI < 2; nKTI++ )
- {
- bool bBasic = ( nKTI == 0 ) ? true : false;
- CExtCustomizeCmdKeyTip * pCmdKeyTip = KeyTipGetInfo( bBasic );
- if( pCmdKeyTip == NULL )
- continue;
- CExtPopupKeyTipWnd * pWndKeyTip = KeyTipGetWnd( bBasic );
- if( pWndKeyTip->GetSafeHwnd() == NULL
- || ( pWndKeyTip->GetStyle() & WS_VISIBLE ) == 0
- )
- continue;
- if( pCmdKeyTip->CompareWidthChain( keyTipChain ) )
- continue;
- pWndKeyTip->ShowWindow( SW_HIDE );
- } // for( nKTI = 0; nKTI < 2; nKTI++ )
- }
- bool CExtPopupMenuWnd::MENUITEMDATA::KeyTipInvokeAction(
- bool bBasic
- )
- {
- CExtPopupMenuWnd * pOwnerPopupMenuWnd = GetOwner();
- if( pOwnerPopupMenuWnd->GetSafeHwnd() == NULL )
- return false;
- ASSERT_VALID( pOwnerPopupMenuWnd );
- bool bSeparatedDropDown = false;
- const CExtCustomizeCmdTreeNode * pNode = GetCmdNode();
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- bSeparatedDropDown =
- (pNode->GetFlags() & __ECTN_TBB_SEPARATED_DROPDOWN)
- ? true : false;
- } // if( pNode != NULL )
- if( ( ( ! bBasic ) || (! bSeparatedDropDown ) )
- && IsPopup()
- && ( ! IsInplaceEdit() )
- )
- {
- INT nCurIndex = pOwnerPopupMenuWnd->ItemGetIndexOf( this );
- pOwnerPopupMenuWnd->_ItemFocusSet( nCurIndex, TRUE, TRUE );
- return true;
- } // if( ( ! bBasic ) ...
- if( ! bBasic )
- return false;
- INT nCurIndex = pOwnerPopupMenuWnd->ItemGetIndexOf( this );
- pOwnerPopupMenuWnd->_ItemFocusSet( nCurIndex, FALSE, TRUE );
- if( IsInplaceEdit() )
- {
- CWnd * pWndInplace = GetInplaceEditPtr();
- if( pWndInplace != NULL )
- {
- ASSERT_VALID( pWndInplace );
- ASSERT( pWndInplace->GetSafeHwnd() != NULL && (::IsWindow(pWndInplace->GetSafeHwnd())) );
- if( IsAllowInplaceEditActivation() )
- {
- if( (pWndInplace->GetStyle() & WS_VISIBLE) == 0 )
- {
- CRect rcInplaceEdit;
- pOwnerPopupMenuWnd->_GetItemRect( nCurIndex, rcInplaceEdit );
- rcInplaceEdit =
- AdjustInplaceEditRect(
- rcInplaceEdit,
- pOwnerPopupMenuWnd->OnQueryLayoutRTL()
- );
- pWndInplace->SetWindowPos(
- NULL,
- rcInplaceEdit.left, rcInplaceEdit.top,
- rcInplaceEdit.Width(), rcInplaceEdit.Height(),
- SWP_NOZORDER|SWP_NOOWNERZORDER
- |SWP_NOACTIVATE|SWP_SHOWWINDOW
- );
- } // if( (pWndInplace->GetStyle() & WS_VISIBLE) == 0 )
- pWndInplace->SetFocus();
- return true;
- } // if( IsAllowInplaceEditActivation() )
- } // if( pWndInplace != NULL )
- }
- pOwnerPopupMenuWnd->_EndSequence( GetCmdID(), pOwnerPopupMenuWnd->GetCmdReceiverHWND() );
- return true;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtPopupMenuWnd * CExtPopupMenuWnd::MENUITEMDATA::GetOwner()
- {
- return m_pOwner;
- }
- const CExtPopupMenuWnd * CExtPopupMenuWnd::MENUITEMDATA::GetOwner() const
- {
- return m_pOwner;
- }
- void CExtPopupMenuWnd::MENUITEMDATA::SetOwner( CExtPopupMenuWnd * pOwner )
- {
- m_pOwner = pOwner;
- }
- CExtPopupMenuWnd::MENUITEMDATA &
- CExtPopupMenuWnd::MENUITEMDATA::operator = (
- const CExtPopupMenuWnd::MENUITEMDATA & other
- )
- {
- AssignFromOther( other );
- return (*this);
- }
- void CExtPopupMenuWnd::MENUITEMDATA::AssignFromOther(
- const CExtPopupMenuWnd::MENUITEMDATA & other
- )
- {
- // self constant type assertion
- ASSERT( TYPE_SEPARATOR==ID_SEPARATOR );
- LPVOID lpvThis = (LPVOID)this;
- LPVOID lpvOther = (LPVOID)(&other);
- if( lpvThis == lpvOther )
- return;
-
- m_pOwner = other.m_pOwner;
- m_pWndChild = other.m_pWndChild;
- m_nItemIndex = other.m_nItemIndex;
- m_nCmdID = other.m_nCmdID;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_pCmdNode = other.m_pCmdNode;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_sItemText = other.m_sItemText;
- m_sExtendedText = other.m_sExtendedText;
- m_sAccelText = other.m_sAccelText;
- m_iconPopup = other.m_iconPopup;
- m_sizeItem = other.m_sizeItem;
- m_nIconAreaWidth = other.m_nIconAreaWidth;
- m_bSelected = other.m_bSelected;
- m_bDisplayed = other.m_bDisplayed;
- m_bForceDisplayed = other.m_bForceDisplayed;
- m_bChildCombine = other.m_bChildCombine;
- m_bToolButton = other.m_bToolButton;
- m_bToolWrap = other.m_bToolWrap;
- m_bBold = other.m_bBold;
- m_bDefault = other.m_bDefault;
- m_bEnabledAppearance = other.m_bEnabledAppearance;
- m_bBigAccent = other.m_bBigAccent;
- m_bForcePopupDisabled = other.m_bForcePopupDisabled;
- m_bForceEnabled = other.m_bForceEnabled;
- m_bForceNoLeftGradient = other.m_bForceNoLeftGradient;
- m_cAccelChar = other.m_cAccelChar;
- m_hWndSpecCmdReceiver = other.m_hWndSpecCmdReceiver;
- m_bCheck = other.m_bCheck;
- m_bRadio = other.m_bRadio;
- m_pCbCmdDeliver = other.m_pCbCmdDeliver;
- m_pCbXtraMarkState = other.m_pCbXtraMarkState;
- m_bXtraChecked = other.m_bXtraChecked;
- m_bNoCmdUI = other.m_bNoCmdUI;
- m_bIconMode = other.m_bIconMode;
- m_bEnabled = other.m_bEnabled;
- m_bIndeterminate = other.m_bIndeterminate;
- m_pHelperInplaceEditWnd = other.m_pHelperInplaceEditWnd;
- m_pInplaceEditStr = other.m_pInplaceEditStr;
- m_pCbVerifyTextInput = other.m_pCbVerifyTextInput;
- m_pCbPutTextInputResult = other.m_pCbPutTextInputResult;
- m_pInplaceEditCbWndProc = other.m_pInplaceEditCbWndProc;
- m_pInplaceEditCbCookie = other.m_pInplaceEditCbCookie;
- m_nInplaceEditWidth = other.m_nInplaceEditWidth;
- m_bAllowInplaceEditActivation = other.m_bAllowInplaceEditActivation;
- m_nLParam = other.m_nLParam;
- m_bTempSelTextValid = other.m_bTempSelTextValid;
- m_sTempSelText = other.m_sTempSelText;
- m_nMarginLeft = m_nMarginLeft;
- m_nMarginTop = m_nMarginTop;
- m_nMarginRight = m_nMarginRight;
- m_nMarginBottom = m_nMarginBottom;
- m_rcCacheBasic = other.m_rcCacheBasic;
- m_rcCacheIndents = other.m_rcCacheIndents;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- HDWP hPassiveModeDWP = NULL;
- KeyTipTrackingQuery( false, NULL, hPassiveModeDWP );
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- }
- void CExtPopupMenuWnd::MENUITEMDATA::SetOuterMargins(
- INT nMarginLeft, // = -1
- INT nMarginTop, // = -1
- INT nMarginRight, // = -1
- INT nMarginBottom // = -1
- )
- {
- if( nMarginLeft >= 0 )
- m_nMarginLeft = nMarginLeft;
- if( nMarginTop >= 0 )
- m_nMarginTop = nMarginTop;
- if( nMarginRight >= 0 )
- m_nMarginRight = nMarginRight;
- if( nMarginBottom >= 0 )
- m_nMarginBottom = nMarginBottom;
- }
- void CExtPopupMenuWnd::MENUITEMDATA::SetOuterMargins(
- const RECT & rcMargins
- )
- {
- SetOuterMargins(
- rcMargins.left,
- rcMargins.top,
- rcMargins.right,
- rcMargins.bottom
- );
- }
- void CExtPopupMenuWnd::MENUITEMDATA::GetOuterMargins(
- INT * p_nMarginLeft, // = NULL,
- INT * p_nMarginTop, // = NULL,
- INT * p_nMarginRight, // = NULL,
- INT * p_nMarginBottom // = NULL
- ) const
- {
- // returns default indent values, if indents are is not initialized yet
- if( p_nMarginLeft != NULL )
- (*p_nMarginLeft) =
- (m_nMarginLeft == -1) ? 1 : m_nMarginLeft;
- if( p_nMarginTop != NULL )
- (*p_nMarginTop) =
- (m_nMarginTop == -1) ? 0 : m_nMarginTop;
- if( p_nMarginRight != NULL )
- (*p_nMarginRight) =
- (m_nMarginRight == -1) ? 1 : m_nMarginRight;
- if( p_nMarginBottom != NULL )
- (*p_nMarginBottom) =
- (m_nMarginBottom == -1) ? 1 : m_nMarginBottom;
-
- }
- void CExtPopupMenuWnd::MENUITEMDATA::GetOuterMargins(
- RECT & rcMargins
- ) const
- {
- INT nMarginLeft, nMarginTop, nMarginRight, nMarginBottom;
- GetOuterMargins(
- &nMarginLeft,
- &nMarginTop,
- &nMarginRight,
- &nMarginBottom
- );
- ::SetRect( &rcMargins, nMarginLeft, nMarginTop, nMarginRight, nMarginBottom );
- }
- CRect CExtPopupMenuWnd::MENUITEMDATA::GetOuterMargins() const
- {
- INT nMarginLeft, nMarginTop, nMarginRight, nMarginBottom;
- GetOuterMargins(
- &nMarginLeft,
- &nMarginTop,
- &nMarginRight,
- &nMarginBottom
- );
- CRect rcMargins;
- ::SetRect( &rcMargins, nMarginLeft, nMarginTop, nMarginRight, nMarginBottom );
- return rcMargins;
- }
- int CExtPopupMenuWnd::MENUITEMDATA::GetMeasuredHeight()
- {
- INT nHeight = m_sizeItem.cy;
- INT nMarginTop = 0, nMarginBottom = 0;
- GetOuterMargins(
- NULL,
- &nMarginTop,
- NULL,
- &nMarginBottom
- );
- nHeight += nMarginTop;
- nHeight += nMarginBottom;
- return nHeight;
- }
- int CExtPopupMenuWnd::MENUITEMDATA::GetMeasuredWidth()
- {
- INT nWidth = m_sizeItem.cx;
- INT nMarginLeft = 0, nMarginRight = 0;
- GetOuterMargins(
- &nMarginLeft,
- NULL,
- &nMarginRight,
- NULL
- );
- nWidth += nMarginLeft;
- nWidth += nMarginRight;
- return nWidth;
- }
- CRect CExtPopupMenuWnd::MENUITEMDATA::AdjustInplaceEditRect(
- const RECT & rcItem,
- bool bRTL
- ) const
- {
- CRect rcInplaceEdit( rcItem );
- int nInplaceEditWidth = GetInplaceEditWidth();
- ASSERT( nInplaceEditWidth > 0 );
- INT nDD = m_pOwner->PmBridge_GetPM()->GetDropDownButtonWidth( (CObject*)GetOwner() );
- if( bRTL )
- {
- rcInplaceEdit.DeflateRect( 1, 2, 1, 2 );
- rcInplaceEdit.right = rcInplaceEdit.left + nInplaceEditWidth;
- if( IsPopup() )
- rcInplaceEdit.right -= nDD;
- } // if( bRTL )
- else
- {
- rcInplaceEdit.DeflateRect( 1, 2, 1, 2 );
- rcInplaceEdit.left = rcInplaceEdit.right - nInplaceEditWidth;
- if( IsPopup() )
- rcInplaceEdit.right -= nDD;
- } // else from if( bRTL )
- return rcInplaceEdit;
- }
- UINT CExtPopupMenuWnd::MENUITEMDATA::GetCmdID() const
- {
- // if( IsSeparator()
- // || IsInplaceEdit()
- // )
- // return ( (UINT) (IDC_STATIC) );
- if( IsPopup() )
- {
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode =
- ( const_cast < MENUITEMDATA * > ( this ) )
- -> GetCmdNode();
- if( pNode == NULL )
- return 0;
- ASSERT_VALID( pNode );
- if( ( pNode->GetFlags() & __ECTN_TBB_COLOR ) != 0 )
- return 0;
- // if( ( pNode->GetFlags() & __ECTN_TBB_UNDO_REDO ) != 0 )
- // return pNode->GetCmdID();
- // if( ( pNode->GetFlags() & __ECTN_TBB_SEPARATED_DROPDOWN ) == 0 )
- // return 0;
- // CExtCmdItem * pCmdItem =
- // g_CmdManager->CmdGetPtr(
- // g_CmdManager->ProfileNameFromWnd( GetCmdReceiver() ),
- // pNode->GetCmdID()
- // );
- // if( pCmdItem != NULL )
- // return pCmdItem->m_nCmdID;
- if( ( pNode->GetFlags() & (__ECTN_TBB_UNDO_REDO|__ECTN_TBB_SEPARATED_DROPDOWN) ) != 0 )
- return pNode->GetCmdID();
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return ( (UINT) (IDC_STATIC) );
- } // if( IsPopup() )
- return m_nCmdID;
- }
- UINT CExtPopupMenuWnd::MENUITEMDATA::SetCmdID( UINT nCmdID )
- {
- // should be used only without references to command manager
- ASSERT( ! IsPopup() ); // should not be applied for popups
- UINT nOldCmdID = m_nCmdID;
- m_nCmdID = nCmdID;
- return nOldCmdID;
- }
- bool CExtPopupMenuWnd::MENUITEMDATA::IsExecutableCmdID() const
- {
- if( IsSeparator()
- || IsInplaceEdit()
- )
- return false;
- if( IsPopup() )
- {
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode =
- ( const_cast < MENUITEMDATA * > ( this ) )
- -> GetCmdNode();
- if( pNode == NULL )
- return false;
- ASSERT_VALID( pNode );
- if( ( pNode->GetFlags() & __ECTN_TBB_COLOR ) != 0 )
- return false;
- // if( ( pNode->GetFlags() & __ECTN_TBB_UNDO_REDO ) != 0 )
- // return false;
- // if( ( pNode->GetFlags() & __ECTN_TBB_SEPARATED_DROPDOWN ) == 0 )
- // return false;
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( GetCmdReceiver() ),
- pNode->GetCmdID()
- );
- if( pCmdItem != NULL
- && pCmdItem->StateIsSeparatedDD()
- )
- return true;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return false;
- } // if( IsPopup() )
- return true;
- }
- bool CExtPopupMenuWnd::MENUITEMDATA::SetPopupText( __EXT_MFC_SAFE_LPCTSTR strText )
- {
- SetText( strText );
- int nPos = m_sItemText.Find(_T('t'));
- if( nPos >= 0 )
- {
- CExtSafeString sLeft = m_sItemText.Left(nPos);
- CExtSafeString sRight = m_sItemText.Right(m_sItemText.GetLength()-nPos-1);
- m_sItemText = sLeft;
- m_sAccelText = sRight;
- }
- return true;
- }
- bool CExtPopupMenuWnd::MENUITEMDATA::SetPopupAccelText( __EXT_MFC_SAFE_LPCTSTR strText ) // NULL if empty
- {
- m_sAccelText = (strText == NULL) ? _T("") : strText;
- return true;
- }
- __EXT_MFC_SAFE_LPCTSTR CExtPopupMenuWnd::MENUITEMDATA::GetText() const
- {
- if( IsSeparator() )
- return _T("");
- return m_sItemText;
- }
- void CExtPopupMenuWnd::MENUITEMDATA::SetText( __EXT_MFC_SAFE_LPCTSTR strText )
- {
- if( IsSeparator() )
- return;
- m_sItemText = (strText != NULL) ? strText : _T("");
- }
- __EXT_MFC_SAFE_LPCTSTR CExtPopupMenuWnd::MENUITEMDATA::GetAccelText() const
- {
- if( IsSeparator() )
- return _T("");
- return m_sAccelText;
- }
- void CExtPopupMenuWnd::MENUITEMDATA::SetAccelText( __EXT_MFC_SAFE_LPCTSTR strText )
- {
- if( IsSeparator() )
- return;
- m_sAccelText = (strText != NULL) ? strText : _T("");
- }
- void CExtPopupMenuWnd::MENUITEMDATA::AccelCharInit()
- {
- m_cAccelChar = _T(' ');
- CExtSafeString sDisplayText( GetText() );
- if( sDisplayText.IsEmpty() )
- return;
- int nIndex = sDisplayText.Find( _T('&') );
- if( nIndex + 1 == sDisplayText.GetLength() )
- {
- TRACE(_T("warning : & is bad position, access key is invalid.n"));
- return;
- }
- if( nIndex < 0 )
- {
- if( ! CExtPopupMenuWnd::g_bAllowNonAccelPositioning )
- return;
- m_cAccelChar = sDisplayText[0];
- }
- else
- m_cAccelChar = sDisplayText[nIndex + 1]; // -1 + 1 = 0; it's ok
- TCHAR szChar[2] = { TCHAR(m_cAccelChar), _T(' ') };
- ::CharUpper( szChar );
- m_cAccelChar = szChar[0];
- }
- __EXT_MFC_SAFE_TCHAR CExtPopupMenuWnd::MENUITEMDATA::AccelCharGet() const
- {
- return __EXT_MFC_SAFE_TCHAR( TCHAR(m_cAccelChar) );
- }
- bool CExtPopupMenuWnd::MENUITEMDATA::AccelCharIsSet() const
- {
- return (m_cAccelChar == _T(' ') ) ? false : true;
- }
- CExtCmdIcon * CExtPopupMenuWnd::MENUITEMDATA::GetIconPtr()
- {
- if( IsSeparator() )
- return NULL;
- // if( (! m_iconPopup.IsEmpty() ) || IsNoCmdUI() )
- // return (m_iconPopup.IsEmpty()) ? NULL : (&m_iconPopup);
- if( ! m_iconPopup.IsEmpty() )
- return (&m_iconPopup);
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode = GetCmdNode();
- if( pNode != NULL )
- return
- pNode->GetIconPtrInMenu(
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( GetCmdReceiver() ),
- pNode->GetCmdID() //m_nCmdID
- )
- );
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( IsPopup() )
- return NULL;
- return
- g_CmdManager->CmdGetIconPtr(
- g_CmdManager->ProfileNameFromWnd( GetCmdReceiver() ),
- m_nCmdID
- );
- }
- const CExtCmdIcon * CExtPopupMenuWnd::MENUITEMDATA::GetIconPtr() const
- {
- return
- ( const_cast < CExtPopupMenuWnd::MENUITEMDATA * > ( this ) )
- -> GetIconPtr();
- }
- CExtCmdIcon & CExtPopupMenuWnd::MENUITEMDATA::GetIcon()
- {
- CExtCmdIcon * pIcon = GetIconPtr();
- if( pIcon != NULL )
- return (*pIcon);
- static CExtCmdIcon g_EmptyIcon;
- return g_EmptyIcon;
- }
- const CExtCmdIcon & CExtPopupMenuWnd::MENUITEMDATA::GetIcon() const
- {
- return
- ( const_cast < CExtPopupMenuWnd::MENUITEMDATA * > ( this ) )
- -> GetIcon();
- }
- bool CExtPopupMenuWnd::MENUITEMDATA::UpdateCmdManagerCommand(
- CExtCmdItem * pCmdItem,
- int nItemIndex
- )
- {
- ASSERT( pCmdItem != NULL );
- ASSERT( !IsPopup() );
- ASSERT( m_pWndChild == NULL );
- m_sItemText.Empty();
- m_sAccelText.Empty();
- m_nCmdID = pCmdItem->m_nCmdID;
- if( ! CExtCmdManager::IsCommand(m_nCmdID) )
- {
- m_nCmdID = TYPE_SEPARATOR;
- m_nItemIndex = -100;
- ASSERT( FALSE );
- return false;
- }
- if( nItemIndex >= 0 )
- m_nItemIndex = nItemIndex;
- SetText( pCmdItem->m_sMenuText );
- SetAccelText( pCmdItem->m_sAccelText );
- AccelCharInit();
- MeasureItem( NULL );
- return true;
- }
- CExtCmdItem * CExtPopupMenuWnd::MENUITEMDATA::GetCmd() const
- {
- if( IsSeparator() || IsNoCmdUI() )
- return NULL;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode =
- ( const_cast < MENUITEMDATA * > ( this ) )
- -> GetCmdNode();
- if( pNode != NULL
- && ( ( pNode->GetFlags() & (__ECTN_TBB_COLOR|__ECTN_TBB_SEPARATED_DROPDOWN) ) != 0
- || ( pNode->GetFlags() & (__ECTN_TBB_UNDO_REDO|__ECTN_TBB_SEPARATED_DROPDOWN) ) != 0
- || IsInplaceEdit()
- )
- )
- {
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( GetCmdReceiver() ),
- pNode->GetCmdID(
- ( ( pNode->GetFlags() & __ECTN_TBB_SEPARATED_DROPDOWN ) != 0 )
- ? true : false
- )
- );
- // ASSERT( pCmdItem != NULL );
- return pCmdItem;
- } // if( pNode != NULL ...
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( IsPopup() )
- return NULL;
- if( m_pOwner != NULL
- && m_pOwner->_IsRibbonMode()
- && m_pOwner->m_hWndNotifyMenuClosed != NULL
- && ::IsWindow( m_pOwner->m_hWndNotifyMenuClosed )
- )
- {
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( m_pOwner->m_hWndNotifyMenuClosed ),
- m_nCmdID
- );
- //ASSERT( pCmdItem != NULL );
- return pCmdItem;
- }
- else
- {
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( GetCmdReceiver() ),
- m_nCmdID
- );
- //ASSERT( pCmdItem != NULL );
- return pCmdItem;
- }
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * CExtPopupMenuWnd::MENUITEMDATA::GetCmdNode()
- {
- #ifdef _DEBUG
- if( m_pCmdNode != NULL )
- {
- ASSERT_VALID( m_pCmdNode );
- }
- #endif // _DEBUG
- return m_pCmdNode;
- }
- void CExtPopupMenuWnd::MENUITEMDATA::SetCmdNode( CExtCustomizeCmdTreeNode * pNode )
- {
- m_pCmdNode = pNode;
- #ifdef _DEBUG
- if( m_pCmdNode != NULL )
- {
- ASSERT_VALID( m_pCmdNode );
- }
- #endif // _DEBUG
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- void CExtPopupMenuWnd::MENUITEMDATA::MeasureItem(
- CExtPaintManager * pPM
- )
- {
- if( pPM == NULL )
- pPM = g_PaintManager.GetPM();
- ASSERT_VALID( pPM );
- if( IsToolButton() )
- m_nIconAreaWidth = 0;
- else
- {
- m_nIconAreaWidth = __EXT_MENU_ICON_CX;
- m_nIconAreaWidth = pPM->UiScalingDo( m_nIconAreaWidth, CExtPaintManager::__EUIST_Y );
- }
- if( pPM == NULL )
- pPM = g_PaintManager.GetPM();
- if( IsSeparator() )
- {
- m_sizeItem.cx = 0;
- m_sizeItem.cy = pPM->GetSeparatorHeight();
- return;
- }
- bool bBold = IsBold();
- bool bForceNoText = false;
- CExtCmdIcon * pIcon = GetIconPtr();
- if( pIcon != NULL && pIcon->IsEmpty() )
- pIcon = NULL;
- if( pIcon == NULL || ( pIcon != NULL && (! IsIconMode() ) ) )
- { // if non displaying text in icon mode
- AccelCharInit();
- CExtSafeString sMeasureText( GetText() );
- if( ! ( IsInplaceEdit() || IsToolButton() ) )
- {
- if( m_pOwner == NULL
- || ( m_pOwner->TrackFlagsGet() & TPMX_HIDE_KEYBOARD_ACCELERATORS ) == 0
- )
- sMeasureText += (LPCTSTR)GetAccelText();
- }
- sMeasureText.Replace( _T("&"), _T("") );
- CWindowDC dc( NULL );
- CFont * pOldFont =
- dc.SelectObject(
- bBold
- ? (&(pPM->m_FontBold))
- : (&(pPM->m_FontNormal))
- );
- //ASSERT( pOldFont != NULL );
- CRect rect( 0, 0, 0, 0 );
- ::DrawText(
- dc.GetSafeHdc(),
- sMeasureText,
- sMeasureText.GetLength(),
- &rect,
- DT_CALCRECT|DT_SINGLELINE|DT_LEFT
- );
- m_sizeItem.cx = rect.Width();
- m_sizeItem.cy = rect.Height();
- if( m_sExtendedText.GetLength() > 0 )
- {
- CRect rcExtended( 0, 0, 0, 0 );
- ::DrawText(
- dc.GetSafeHdc(),
- m_sExtendedText,
- m_sExtendedText.GetLength(),
- &rcExtended,
- DT_CALCRECT|DT_TOP|DT_LEFT
- );
- CSize _sizeExtended = rcExtended.Size();
- m_sizeItem.cx = max( m_sizeItem.cx, _sizeExtended.cx );
- m_sizeItem.cy += _sizeExtended.cy + __EXT_MENU_IMG_RECT_OUT_GAP;
- }
- else if( IsBigAccent() )
- m_sizeItem.cy += rect.Height();
- m_sizeItem.cx += __EXT_MENU_IMG_RECT_OUT_GAP*2;
- m_sizeItem.cy += __EXT_MENU_IMG_RECT_OUT_GAP*2;
- dc.SelectObject( pOldFont );
- } // if non displaying text in icon mode
- else
- {
- bForceNoText = true;
- m_sizeItem.cx = m_sizeItem.cy = 0;
- }
- if( bBold )
- m_sizeItem.cx += 5;
- CSize sizeIcon( 0, 0 );
- int nIconHeightMetric = 0;
- if( ! ( IsToolButton() && IsInplaceEdit() ) )
- {
- if( pIcon != NULL )
- {
- sizeIcon = pIcon->GetSize();
- sizeIcon.cx = pPM->UiScalingDo( sizeIcon.cx, CExtPaintManager::__EUIST_X );
- sizeIcon.cy = pPM->UiScalingDo( sizeIcon.cy, CExtPaintManager::__EUIST_Y );
- if( g_bMenuLargeIcons )
- {
- sizeIcon.cx *= 2;
- sizeIcon.cy *= 2;
- } // if( g_bMenuLargeIcons )
- CSize _sizeMinIconArea(
- pPM->UiScalingDo( __EXT_MENU_ICON_CX, CExtPaintManager::__EUIST_X ),
- pPM->UiScalingDo( __EXT_MENU_ICON_CY, CExtPaintManager::__EUIST_Y )
- );
- if( sizeIcon.cx < _sizeMinIconArea.cx )
- sizeIcon.cx = _sizeMinIconArea.cx;
- if( sizeIcon.cy < _sizeMinIconArea.cy )
- sizeIcon.cy = _sizeMinIconArea.cy;
- INT nAdjust = pPM->UiScalingDo( 18, CExtPaintManager::__EUIST_X );
- if( sizeIcon.cx <= nAdjust && sizeIcon.cy < sizeIcon.cx )
- sizeIcon.cy = sizeIcon.cx;
- if( ! IsToolButton() )
- {
- INT _cx = pPM->UiScalingDo( sizeIcon.cx, CExtPaintManager::__EUIST_X );
- m_nIconAreaWidth = max( m_nIconAreaWidth, _cx );
- }
- else
- m_sizeItem.cx +=
- sizeIcon.cx +
- pPM->UiScalingDo( __EXT_MENU_IMG_RECT_OUT_GAP*2, CExtPaintManager::__EUIST_X )
- ;
- nIconHeightMetric =
- sizeIcon.cy +
- pPM->UiScalingDo( __EXT_MENU_IMG_RECT_OUT_GAP*2, CExtPaintManager::__EUIST_Y )
- ;
- m_sizeItem.cy = max( m_sizeItem.cy, nIconHeightMetric );
- } // if( pIcon != NULL )
- }
- m_sizeItem.cy = max( m_sizeItem.cy, nIconHeightMetric );
- INT nMenuMinHeight = pPM->UiScalingDo( __EXT_MENU_MIN_HEIGHT, CExtPaintManager::__EUIST_Y );
- if( m_sizeItem.cy < nMenuMinHeight )
- m_sizeItem.cy = nMenuMinHeight;
- if( IsToolButton() )
- {
- if( sizeIcon.cy == 0 )
- m_sizeItem.cy -= 2;
- }
- else
- {
- INT _cx = pPM->UiScalingDo( sizeIcon.cx, CExtPaintManager::__EUIST_X );
- m_nIconAreaWidth = max( _cx, m_sizeItem.cy );
- if( IsExtraMark() )
- {
- m_nIconAreaWidth *= 2;
- m_nIconAreaWidth += pPM->UiScalingDo( 4, CExtPaintManager::__EUIST_Y );;
- } // if( IsExtraMark() )
- m_nIconAreaWidth += pPM->UiScalingDo( 2, CExtPaintManager::__EUIST_Y );; // + 2.28
- m_sizeItem.cx += __EXT_MENU_GAP * 7;
- m_sizeItem.cx += 5; // + 2.28
- }
- if( IsInplaceEdit() )
- {
- m_sizeItem.cx += m_nInplaceEditWidth;
- if( ! IsToolButton() )
- {
- m_sizeItem.cx += + 2 + 10;
- if( g_bMenuLargeIcons )
- m_sizeItem.cx += m_nIconAreaWidth;
- } // if( ! IsToolButton() )
- if( ! g_bMenuLargeIcons )
- m_sizeItem.cy -= 2; // + 2.28
- } // if( IsInplaceEdit() )
- else if( IsToolButton() )
- {
- if( IsPopup() )
- {
- //m_sizeItem.cx += __DROPDOWN_ARROW_GAP * 2 + __EXT_MENU_GAP * 2 + 5;