// XTOutBarCtrl.cpp : implementation of the CXTOutBarCtrl class.
//
// This file is a part of the XTREME TOOLKIT PRO MFC class library.
// �1998-2005 Codejock Software, All Rights Reserved.
//
// THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
// RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
// CONSENT OF CODEJOCK SOFTWARE.
//
// THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
// IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
// YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
// SINGLE COMPUTER.
//
// CONTACT INFORMATION:
// support@codejock.com
// http://www.codejock.com
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "XTPResourceManager.h"
#include "XTPColorManager.h"
#include "XTPDrawHelpers.h"
#include "XTResource.h"
#include "XTDefines.h"
#include "XTUtil.h"
#include "XTGlobal.h"
#include "XTVC50Helpers.h"
#include "XTWndHook.h"
#include "XTFlatComboBox.h"
#include "XTOutBarCtrl.h"
#include "XTMemDC.h"
#include "XTOutBarTheme.h"
#include "XTFunctions.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CXTOutBarEditItem
CXTOutBarEditItem::CXTOutBarEditItem()
{
m_iIndex = -1;
m_pParentWnd = NULL;
m_bSmallIcons = false;
m_bEscapeKey = false;
m_bIsFolder = false;
}
CXTOutBarEditItem::~CXTOutBarEditItem()
{
}
IMPLEMENT_DYNAMIC(CXTOutBarEditItem, CXTEdit)
BEGIN_MESSAGE_MAP(CXTOutBarEditItem, CXTEdit)
//{{AFX_MSG_MAP(CXTOutBarEditItem)
ON_WM_KILLFOCUS()
ON_WM_CHAR()
ON_WM_SETCURSOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CXTOutBarEditItem::OnKillFocus(CWnd* /*pNewWnd*/)
{
PostMessage( WM_CLOSE );
if ( !m_bEscapeKey )
{
GetWindowText( m_strText );
if ( !m_strText.IsEmpty( ) )
{
m_pParentWnd->EndLabelEdit( this, m_bIsFolder );
}
}
}
BOOL CXTOutBarEditItem::PreTranslateMessage(MSG* pMsg)
{
switch ( pMsg->wParam )
{
case VK_ESCAPE:
{
m_bEscapeKey = TRUE; // fall thru
}
case VK_RETURN:
{
PostMessage( WM_CLOSE );
return TRUE;
}
}
return CXTEdit::PreTranslateMessage(pMsg);
}
void CXTOutBarEditItem::PostNcDestroy()
{
delete this;
}
BOOL CXTOutBarEditItem::Create(LPCTSTR lpszText, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, UINT nIndex, bool bIsFolder, bool bSmallIcons)
{
ASSERT_VALID( pParentWnd ); // must be valid.
m_pParentWnd = ( CXTOutBarCtrl* )pParentWnd;
ASSERT_KINDOF( CXTOutBarCtrl, m_pParentWnd ); // must be an outlook bar control.
// get the inside size of the outlook bar.
CRect rcInside;
m_pParentWnd->GetInsideRect( rcInside );
rcInside.DeflateRect(5,5);
// adjust the size if necessary.
m_rcOriginal = rect;
m_bSmallIcons = bSmallIcons;
m_bIsFolder = bIsFolder;
m_iIndex = nIndex;
m_strText = lpszText;
if ( m_rcOriginal.Width( ) > rcInside.Width( ) )
{
if ( m_bSmallIcons != TRUE )
{
m_rcOriginal.left = rcInside.left;
}
m_rcOriginal.right = rcInside.right;
}
if (!CXTEdit::Create(dwStyle, m_rcOriginal, pParentWnd, nID))
return FALSE;
if (!CXTEdit::Initialize(m_pParentWnd))
return FALSE;
SetFont( m_pParentWnd->GetFontX( ) );
SetWindowText( m_strText );
return TRUE;
}
void CXTOutBarEditItem::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// if this is a folder, do default processing.
if ( m_bIsFolder )
{
CXTEdit::OnChar(nChar, nRepCnt, nFlags);
return;
}
// if the escape or return key has been pressed, abort edit.
else if ( nChar == VK_ESCAPE || nChar == VK_RETURN )
{
if ( nChar == VK_ESCAPE )
{
m_bEscapeKey = TRUE;
}
m_pParentWnd->SetFocus( );
return;
}
CXTEdit::OnChar(nChar, nRepCnt, nFlags);
// get the inside size of the outlook bar.
CRect rcInside;
m_pParentWnd->GetInsideRect( rcInside );
rcInside.DeflateRect(5,5);
// get the edit box text
CString strText;
GetWindowText( strText );
// get the font used by the outlook bar.
CFont* pFont = m_pParentWnd->GetFontX( );
ASSERT( pFont && pFont->GetSafeHandle( ) );
// select the font used by the outlook bar.
CWindowDC dc( NULL );
// get the size of the text string.
CFont* f = dc.SelectObject( pFont );
CSize sz = dc.GetTextExtent( strText );
dc.SelectObject( f );
// construct the edit box size.
CRect rcItem = m_rcOriginal;
// calculate the width of the edit box.
if ( m_bSmallIcons == TRUE )
{
rcItem.right = rcItem.left + sz.cx + 9;
if ( rcItem.right < m_rcOriginal.right )
{
rcItem.right = m_rcOriginal.right;
}
else if ( rcItem.right > rcInside.right )
{
rcItem.right = rcInside.right;
}
}
else
{
int x = ( rcInside.Width( )-sz.cx )/2;
rcItem.left = rcInside.left + x;
rcItem.right = rcItem.left + sz.cx;
rcItem.InflateRect( 6,0 );
if ( rcItem.Width( ) < m_rcOriginal.Width( ) )
{
rcItem = m_rcOriginal;
}
else if ( rcItem.Width( ) > rcInside.Width( ) )
{
rcItem.left = rcInside.left;
rcItem.right = rcInside.right;
}
}
// resize the edit box.
MoveWindow( &rcItem );
}
BOOL CXTOutBarEditItem::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
HCURSOR hCursor = ::LoadCursor( NULL, IDC_IBEAM );
if ( hCursor != NULL )
{
::SetCursor( hCursor );
return TRUE;
}
return CXTEdit::OnSetCursor(pWnd, nHitTest, message);
}
/////////////////////////////////////////////////////////////////////////////
// CXTOutBarCtrl
IMPLEMENT_THEME_HOST(CXTOutBarCtrl, CXTOutBarTheme)
CXTOutBarCtrl::CXTOutBarCtrl()
: CXTThemeManagerStyleHost(GetThemeFactoryClass())
, m_penBlack(PS_SOLID, 1, RGB(0,0,0))
{
m_rcUpArrow.SetRectEmpty();
m_rcDownArrow.SetRectEmpty();
m_dwFlags = OBS_XT_DEFAULT;
m_pLargeImageList = NULL;
m_pSmallImageList = NULL;
m_sizeOffset.cx = 4;
m_sizeOffset.cy = 3;
m_sizeMargin.cx = 5;
m_sizeMargin.cy = 5;
m_nFolderHeight = 22;
m_nSelFolder = 0;
m_nLastFolderSelected = -1;
m_nFolderHilighted = -1;
m_nLastItemSelected = -1;
m_nItemHilighted = -1;
m_nLastDragItemDraw = -1;
m_nLastDragItemDrawType = -1;
m_nFirstItem = 0;
m_nIconSpacingSmall = 10;
m_nIconSpacingLarge = 8;
m_nAnimationTickCount = 10;
m_nSelAnimCount = 0;
m_nSelAnimTiming = 0;
m_nHitInternal1 = 0;
m_nHitInternal2 = 0;
m_bUpArrow = FALSE;
m_bDownArrow = FALSE;
m_bUpPressed = FALSE;
m_bDownPressed = FALSE;
m_bLooping = FALSE;
m_bPressedHighlight = FALSE;
m_bIconPressed = FALSE;
SetFontX(CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT)));
}
CXTOutBarCtrl::~CXTOutBarCtrl()
{
int iFolder;
for (iFolder = 0; iFolder < m_arFolder.GetSize(); iFolder++)
{
m_nSelFolder = iFolder;
CXTOutBarFolder* pBarFolder = (CXTOutBarFolder*)m_arFolder.GetAt(iFolder);
SAFE_DELETE( pBarFolder );
}
m_arFolder.RemoveAll();
m_penBlack.DeleteObject();
m_font.DeleteObject();
}
IMPLEMENT_DYNCREATE(CXTOutBarCtrl, CWnd)
BEGIN_MESSAGE_MAP(CXTOutBarCtrl, CWnd)
//{{AFX_MSG_MAP(CXTOutBarCtrl)
ON_WM_TIMER()
ON_WM_PAINT()
ON_WM_ERASEBKGND()
ON_WM_MOUSEMOVE()
ON_MESSAGE_VOID(WM_MOUSELEAVE, OnMouseLeave)
ON_WM_LBUTTONDOWN()
ON_WM_SETCURSOR()
ON_WM_SIZE()
ON_COMMAND(XT_IDC_LARGEICON, OnLargeIcon)
ON_UPDATE_COMMAND_UI(XT_IDC_LARGEICON, OnUpdateLargeIcon)
ON_COMMAND(XT_IDC_SMALLICON, OnSmallIcon)
ON_UPDATE_COMMAND_UI(XT_IDC_SMALLICON, OnUpdateSmallIcon)
ON_COMMAND(XT_IDC_REMOVEITEM, OnRemoveItem)
ON_UPDATE_COMMAND_UI(
丸子桑麻
- 粉丝: 2
- 资源: 5
最新资源
- Kivy-1.11.1-cp38-cp38-win32.whl.zip
- Kivy-1.11.1-cp38-cp38-win_amd64.whl.zip
- Kivy-1.11.1-cp37-cp37m-win32.whl.zip
- Kivy-1.11.1-cp36-cp36m-win_amd64.whl.zip
- Kivy-1.11.1-cp37-cp37m-win_amd64.whl.zip
- Kivy-1.11.1-cp39-cp39-win32.whl.zip
- Kivy-1.11.1-cp39-cp39-win_amd64.whl.zip
- Kivy-2.0.0-cp36-cp36m-win_amd64.whl.zip
- Kivy-2.0.0-cp37-cp37m-win_amd64.whl.zip
- Kivy-2.0.0-cp36-cp36m-win32.whl.zip
- Kivy-2.0.0-cp37-cp37m-win32.whl.zip
- Kivy-2.0.0-cp39-cp39-win_amd64.whl.zip
- Kivy-2.0.0-cp38-cp38-win_amd64.whl.zip
- Kivy-2.0.0-cp38-cp38-win32.whl.zip
- Kivy-2.0.0-cp310-cp310-win_amd64.whl.zip
- Kivy-2.0.0-cp39-cp39-win32.whl.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页