?? chameleonctl.cpp
字號(hào):
}
else if( m_lButtonType == 2 )
{
//Windows32
DrawCaption( pdcDraw->m_hDC, 2 );
if( bDefault && m_bShowFocusRect )
{
DrawRectangle( pdcDraw->m_hDC, 0, 0, m_nWidth, m_nHeight,
m_ulDarkShadow, true );
DrawRectangle( pdcDraw->m_hDC, 1, 1, m_nWidth - 2, m_nHeight - 2,
m_ulShadow, true );
DrawFocusR( pdcDraw->m_hDC, m_recFocusRect, m_ulText );
}
else
{
DrawFrame( pdcDraw->m_hDC, m_ulDarkShadow, m_ulHighLight,
m_ulShadow, m_ulLight, 0 );
}
}
else if( m_lButtonType == 3 )
{
//WindowsXP
float fStep;
DWORD ulXPFaxe2;
fStep = 25 / (float)m_nHeight;
ulXPFaxe2 = ShiftColor( m_ulXPFace, -0x20, true );
for( int nCount = 1; nCount <= m_nHeight; nCount++ )
{
DrawLine( pdcDraw->m_hDC, 0, m_nHeight - nCount,
m_nWidth, m_nHeight - nCount,
ShiftColor( ulXPFaxe2, (int)(-fStep * nCount), true ) );
}
DrawCaption( pdcDraw->m_hDC, 2 );
DrawRectangle( pdcDraw->m_hDC, 0, 0, m_nWidth, m_nHeight, 0x733C00, true );
SetPixel( pdcDraw->m_hDC, 1, 1, 0x7B4D10 );
SetPixel( pdcDraw->m_hDC, 1, m_nHeight - 2, 0x7B4D10 );
SetPixel( pdcDraw->m_hDC, m_nWidth - 2, 1, 0x7B4D10 );
SetPixel( pdcDraw->m_hDC, m_nWidth - 2, m_nHeight - 2, 0x7B4D10 );
DrawLine( pdcDraw->m_hDC, 2, m_nHeight - 2,
m_nWidth - 2, m_nHeight - 2, ShiftColor( ulXPFaxe2, 0x10, true ) );
DrawLine( pdcDraw->m_hDC, 1, m_nHeight - 3,
m_nWidth - 2, m_nHeight - 3, ShiftColor( ulXPFaxe2, 0x0A, true ) );
DrawLine( pdcDraw->m_hDC, m_nWidth - 2, 2,
m_nWidth - 2, m_nHeight - 2, ShiftColor( ulXPFaxe2, 0x05, true ) );
DrawLine( pdcDraw->m_hDC, m_nWidth - 3, 3,
m_nWidth - 3, m_nHeight - 3, m_ulXPFace );
DrawLine( pdcDraw->m_hDC, 2, 1,
m_nWidth - 2, 1, ShiftColor( ulXPFaxe2, -0x20, true ) );
DrawLine( pdcDraw->m_hDC, 1, 2,
m_nWidth - 2, 2, ShiftColor( ulXPFaxe2, -0x18, true ) );
DrawLine( pdcDraw->m_hDC, 1, 2,
1, m_nHeight - 2, ShiftColor( ulXPFaxe2, -0x20, true ) );
DrawLine( pdcDraw->m_hDC, 2, 2,
2, m_nHeight - 2, ShiftColor( ulXPFaxe2, -0x16, true ) );
}
else if( m_lButtonType == 4 )
{
//Mac
DrawRectangle( pdcDraw->m_hDC, 1, 1, m_nWidth - 2, m_nHeight - 2,
ShiftColor( m_ulShadow, -0x10 ) );
m_ulXPFace = ShiftColor( m_ulShadow, -0x10 );
DrawCaption( pdcDraw->m_hDC, 2 );
m_ulXPFace = ShiftColor( m_ulFace, 0x30 );
DrawRectangle( pdcDraw->m_hDC, 0, 0, m_nWidth, m_nHeight,
m_ulDarkShadow, true );
DrawRectangle( pdcDraw->m_hDC, 1, 1, m_nWidth - 2, m_nHeight - 2,
ShiftColor( m_ulShadow, -0x40 ), true );
DrawRectangle( pdcDraw->m_hDC, 2, 2, m_nWidth - 4, m_nHeight - 4,
ShiftColor( m_ulShadow, -0x20 ), true );
SetPixel( pdcDraw->m_hDC, 2, 2, ShiftColor( m_ulShadow, -0x40 ) );
SetPixel( pdcDraw->m_hDC, 3, 3, ShiftColor( m_ulShadow, -0x20 ) );
SetPixel( pdcDraw->m_hDC, 1, 1, m_ulDarkShadow );
SetPixel( pdcDraw->m_hDC, 1, m_nHeight - 2, m_ulDarkShadow );
SetPixel( pdcDraw->m_hDC, m_nWidth - 2, 1, m_ulDarkShadow );
SetPixel( pdcDraw->m_hDC, m_nWidth - 2, m_nHeight - 2, m_ulDarkShadow );
DrawLine( pdcDraw->m_hDC, m_nWidth - 3, 1, m_nWidth - 3, m_nHeight - 3,
m_ulShadow );
DrawLine( pdcDraw->m_hDC, 1, m_nHeight - 3, m_nWidth - 2, m_nHeight - 3,
m_ulShadow );
SetPixel( pdcDraw->m_hDC, m_nWidth - 4, m_nHeight - 4, m_ulShadow );
DrawLine( pdcDraw->m_hDC, m_nWidth - 2, 3, m_nWidth - 2, m_nHeight - 2,
ShiftColor( m_ulShadow, -0x10 ) );
DrawLine( pdcDraw->m_hDC, 3, m_nHeight - 2, m_nWidth - 2, m_nHeight - 2,
ShiftColor( m_ulShadow, -0x10 ) );
DrawLine( pdcDraw->m_hDC, m_nWidth - 2, m_nHeight - 3,
m_nWidth - 4, m_nHeight - 1, ShiftColor( m_ulShadow, -0x20 ) );
SetPixel( pdcDraw->m_hDC, 2, m_nHeight - 2, ShiftColor( m_ulShadow, -0x20 ) );
SetPixel( pdcDraw->m_hDC, m_nWidth - 2, 2, ShiftColor( m_ulShadow, -0x20 ) );
}
else if( m_lButtonType == 5 )
{
//Java
DrawRectangle( pdcDraw->m_hDC, 1, 1, m_nWidth - 2, m_nHeight - 2,
ShiftColor( m_ulShadow, 0x10 ), false );
DrawRectangle( pdcDraw->m_hDC, 0, 0, m_nWidth - 1, m_nHeight - 1,
ShiftColor( m_ulShadow, -0x1A ), true );
DrawLine( pdcDraw->m_hDC, m_nWidth - 1, 1, m_nWidth - 1, m_nHeight,
m_ulHighLight );
DrawLine( pdcDraw->m_hDC, 1, m_nHeight - 1, m_nWidth - 1, m_nHeight - 1,
m_ulHighLight );
DrawCaption( pdcDraw->m_hDC, 1 );
if( m_bFocus && m_bShowFocusRect )
{
DrawRectangle( pdcDraw->m_hDC, m_recText.left - 2, m_recText.top - 1,
m_recText.Width() + 4, m_recText.Height() + 2, 0xCC9999, true );
}
}
else if( m_lButtonType == 6 )
{
//Netscape6
DrawCaption( pdcDraw->m_hDC, 2 );
DrawFrame( pdcDraw->m_hDC, m_ulShadow, ShiftColor( m_ulLight, 0x08 ),
m_ulShadow, ShiftColor( m_ulLight, 0x08 ), 0 );
DrawFocusR( pdcDraw->m_hDC, m_recFocusRect, m_ulText );
}
else if( m_lButtonType == 7 )
{
//SimpleFlat
DrawCaption( pdcDraw->m_hDC, 2 );
DrawFrame( pdcDraw->m_hDC, m_ulShadow, m_ulHighLight, 0, 0, 0, true );
DrawFocusR( pdcDraw->m_hDC, m_recFocusRect, m_ulText );
}
else if( m_lButtonType == 8 )
{
//FlatHight
DrawCaption( pdcDraw->m_hDC, 2 );
DrawFrame( pdcDraw->m_hDC, m_ulShadow, m_ulHighLight, 0, 0, 0, true );
DrawFocusR( pdcDraw->m_hDC, m_recFocusRect, m_ulText );
}
else if( m_lButtonType == 9 )
{
//OfficeXP
if( m_bMouseOver )
{
if( m_lColorScheme == 2 )
{
DrawRectangle( pdcDraw->m_hDC, 0, 0, m_nWidth, m_nHeight,
ShiftColor( m_ulOfficeXPF, -0x20 ) );
}
else
{
DrawRectangle( pdcDraw->m_hDC, 0, 0, m_nWidth, m_nHeight,
ShiftColor( m_ulOfficeXPB, 0x80 ) );
}
}
DrawCaption( pdcDraw->m_hDC, 2 );
DrawRectangle( pdcDraw->m_hDC, 0, 0, m_nWidth, m_nHeight,
m_ulOfficeXPB, true );
DrawFocusR( pdcDraw->m_hDC, m_recFocusRect, m_ulText );
}
else if( m_lButtonType == 10 )
{
//Transparent
}
else if( m_lButtonType == 11 )
{
//Hover
DrawCaption( pdcDraw->m_hDC, 2 );
DrawFrame( pdcDraw->m_hDC, m_ulDarkShadow, m_ulHighLight, m_ulShadow,
m_ulLight, 0, false );
DrawFocusR( pdcDraw->m_hDC, m_recFocusRect, m_ulText );
}
else if( m_lButtonType == 12 )
{
//KDE2
DrawRectangle( pdcDraw->m_hDC, 1, 1, m_nWidth, m_nHeight,
ShiftColor( m_ulFace, -0x09 ) );
DrawRectangle( pdcDraw->m_hDC, 0, 0, m_nWidth, m_nHeight,
ShiftColor( m_ulShadow, -0x30 ), true );
DrawLine( pdcDraw->m_hDC, 2, m_nHeight - 2, m_nWidth - 2, m_nHeight - 2,
m_ulHighLight );
DrawLine( pdcDraw->m_hDC, m_nWidth - 2, 2, m_nWidth - 2, m_nHeight - 1,
m_ulHighLight );
DrawCaption( pdcDraw->m_hDC, 7 );
DrawFocusR( pdcDraw->m_hDC, m_recFocusRect, m_ulText );
}
else if( m_lButtonType == 13 )
{
//Graphic
int nPicWidth;
int nPicHeight;
CRect recRender;
CRect recWBounds;
GetPictureSize( 2, nPicWidth, nPicHeight );
if( nPicWidth != 0 && nPicHeight != 0 )
{
recRender.left = 0;
recRender.top = 0;
if( m_bStretch )
{
recRender.right = m_nWidth;
recRender.bottom = m_nHeight;
}
else
{
recRender.right = nPicWidth;
recRender.bottom = nPicHeight;
}
recWBounds.left = 0;
recWBounds.top = 0;
recWBounds.right = nPicWidth;
recWBounds.bottom = nPicHeight;
m_phdDownPicture.Render( pdcDraw, recRender, recWBounds );
}
DrawCaption( pdcDraw->m_hDC, 2 );
}
}
}
else
{
//Disable狀態(tài)
if( m_lButtonType == 1 )
{
//Windows16
DrawCaption( pdcDraw->m_hDC, 3 );
DrawFrame( pdcDraw->m_hDC, m_ulHighLight, m_ulShadow, m_ulHighLight,
m_ulShadow, -1 );
DrawRectangle( pdcDraw->m_hDC, 0, 0, m_nWidth, m_nHeight,
m_ulDarkShadow, true );
}
else if( m_lButtonType == 2 )
{
//Windows32
DrawCaption( pdcDraw->m_hDC, 3 );
DrawFrame( pdcDraw->m_hDC, m_ulHighLight, m_ulDarkShadow,
m_ulLight, m_ulShadow, 0 );
}
else if( m_lButtonType == 3 )
{
//WindowsXP
DrawRectangle( pdcDraw->m_hDC, 0, 0, m_nWidth, m_nHeight,
ShiftColor( m_ulXPFace, -0x18, true ) );
DrawCaption( pdcDraw->m_hDC, 5 );
DrawRectangle( pdcDraw->m_hDC, 0, 0, m_nWidth, m_nHeight,
ShiftColor( m_ulXPFace, -0x54, true ), true );
SetPixel( pdcDraw->m_hDC, 1, 1, ShiftColor( m_ulXPFace, -0x48, true ) );
SetPixel( pdcDraw->m_hDC, 1, m_nHeight - 2,
ShiftColor( m_ulXPFace, -0x48, true ) );
SetPixel( pdcDraw->m_hDC, m_nWidth - 2, 1,
ShiftColor( m_ulXPFace, -0x48, true ) );
SetPixel( pdcDraw->m_hDC, m_nWidth - 2, m_nHeight - 2,
ShiftColor( m_ulXPFace, -0x48, true ) );
}
else if( m_lButtonType == 4 )
{
//Mac
DrawRectangle( pdcDraw->m_hDC, 1, 1, m_nWidth - 2, m_nHeight - 2, m_ulLight );
DrawCaption( pdcDraw->m_hDC, 3 );
DrawRectangle( pdcDraw->m_hDC, 0, 0, m_nWidth, m_nHeight, m_ulDarkShadow, true );
SetPixel( pdcDraw->m_hDC, 1, 1, m_ulDarkShadow );
SetPixel( pdcDraw->m_hDC, 1, m_nHeight - 2, m_ulDarkShadow );
SetPixel( pdcDraw->m_hDC, m_nWidth - 2, 1, m_ulDarkShadow );
SetPixel( pdcDraw->m_hDC, m_nWidth - 2, m_nHeight - 2, m_ulDarkShadow );
DrawLine( pdcDraw->m_hDC, 1, 2, 2, 0, m_ulFace );
DrawLine( pdcDraw->m_hDC, 3, 2, m_nWidth - 3, 2, m_ulHighLight );
DrawLine( pdcDraw->m_hDC, 2, 2, 2, m_nHeight - 3, m_ulHighLight );
SetPixel( pdcDraw->m_hDC, 3, 3, m_ulHighLight );
DrawLine( pdcDraw->m_hDC, m_nWidth - 3, 1, m_nWidth - 3, m_nHeight - 3,
m_ulFace );
DrawLine( pdcDraw->m_hDC, 1, m_nHeight - 3, m_nWidth - 3, m_nHeight - 3,
m_ulFace );
SetPixel( pdcDraw->m_hDC, m_nHeight - 4, m_nHeight - 4, m_ulFace );
DrawLine( pdcDraw->m_hDC, m_nWidth - 2, 2, m_nWidth - 2, m_nHeight - 2,
m_ulShadow );
DrawLine( pdcDraw->m_hDC, 2, m_nHeight - 2, m_nWidth - 2, m_nHeight - 2,
m_ulShadow );
SetPixel( pdcDraw->m_hDC, m_nHeight - 3, m_nHeight - 3, m_ulShadow );
}
else if( m_lButtonType == 5 )
{
//Java
DrawCaption( pdcDraw->m_hDC, 4 );
DrawRectangle( pdcDraw->m_hDC, 0, 0, m_nWidth, m_nHeight, m_ulShadow, true );
}
else if( m_lButtonType == 6 )
{
//Netscape6
DrawCaption( pdcDraw->m_hDC, 4 );
DrawFrame( pdcDraw->m_hDC, ShiftColor( m_ulLight, 0x08 ), m_ulShadow,
ShiftColor( m_ulLight, 0x08 ), m_ulShadow, 0 );
}
else if( m_lButtonType == 7 )
{
//SimpleFlat
DrawCaption( pdcDraw->m_hDC, 3 );
DrawFrame( pdcDraw->m_hDC, m_ulHighLight, m_ulShadow, 0, 0, 0, true );
}
else if( m_lButtonType == 8 )
{
//FlatHight
DrawCaption( pdcDraw->m_hDC, 3 );
}
else if( m_lButtonType == 9 )
{
//OfficeXP
DrawCaption( pdcDraw->m_hDC, 4 );
}
else if( m_lButtonType == 10 )
{
//Transparent
}
else if( m_lButtonType == 11 )
{
//Hover
DrawCaption( pdcDraw->m_hDC, 3 );
}
else if( m_lButtonType == 12 )
{
//KDE2
float fStep;
fStep = 58 / (float)m_nHeight;
for( int nCount = 1; nCount <= m_nHeight; nCount++ )
{
DrawLine( pdcDraw->m_hDC, 0, nCount, m_nWidth, nCount,
ShiftColor( m_ulHighLight, (int)(-fStep * nCount) ) );
}
DrawRectangle( pdcDraw->m_hDC, 0, 0, m_nWidth, m_nHeight,
ShiftColor( m_ulShadow, -0x32 ), true );
DrawRectangle( pdcDraw->m_hDC, 1, 1, m_nWidth - 2, m_nHeight - 2,
ShiftColor( m_ulFace, -0x09 ), true );
DrawRectangle( pdcDraw->m_hDC, 2, 2, m_nWidth - 4, 2, m_ulHighLight );
DrawRectangle( pdcDraw->m_hDC, 2, 4, 2, m_nHeight - 6, m_ulHighLight );
DrawCaption( pdcDraw->m_hDC, 6 );
}
else if( m_lButtonType == 13 )
{
//Graphic
int nPicWidth;
int nPicHeight;
CRect recRender;
CRect recWBounds;
GetPictureSize( 4, nPicWidth, nPicHeight );
if( nPicWidth != 0 && nPicHeight != 0 )
{
recRender.left = 0;
recRender.top = 0;
if( m_bStretch )
{
recRender.right = m_nWidth;
recRender.bottom = m_nHeight;
}
else
{
recRender.right = nPicWidth;
recRender.bottom = nPicHeight;
}
recWBounds.left = 0;
recWBounds.top = 0;
recWBounds.right = nPicWidth;
recWBounds.bottom = nPicHeight;
m_phdDisablePicture.Render( pdcDraw, recRender, recWBounds );
}
DrawCaption( pdcDraw->m_hDC, 3 );
}
}
pdcDraw->SelectObject( pfntOld );
if( bReleaseDC )
{
ReleaseDC( pdcDraw );
}
return 0;
}
/////////////////////////////////////////////////////////////////////////////
//
// 檢查鼠標(biāo)是否在控件上
// 參數(shù): none
// 返回值: 0 正確
//
/////////////////////////////////////////////////////////////////////////////
bool CChameleonCtrl::CheckMouseOver()
{
CPoint pntCursor;
if( GetCursorPos( &pntCursor ) )
{
if( WindowFromPoint(pntCursor) == this )
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
/////////////////////////////////////////////////////////////////////////////
//
// 創(chuàng)建控件區(qū)域
// 參數(shù): rgnCreate 需要?jiǎng)?chuàng)建的區(qū)域
// 返回值: 0 正確
//
/////////////////////////////////////////////////////////////////////////////
int CChameleonCtrl::MakeRegion( CRgn & rgnCreate )
{
CRgn rgnTemp1;
CRgn rgnTemp2;
rgnCreate.DeleteObject();
rgnCreate.CreateRectRgn( 0, 0, m_nWidth, m_nHeight );
rgnTemp2.CreateRectRgn( 0, 0, 0, 0 );
if( m_lButtonType == 1 || m_lButtonType == 5 ||
m_lButtonType == 12 )
{
//Windows16
//Java
//KDE2
rgnTemp1.CreateRectRgn( 0, m_nHeight, 1, m_nHeight - 1 );
rgnTemp2.CombineRgn( &rgnCreate, &rgnTemp1, RGN_DIFF );
rgnTemp1.DeleteObject();
rgnTemp1.CreateRectRgn( m_nWidth, 0, m_nWidth - 1, 1 );
rgnCreate.CombineRgn( &rgnTemp2, &rgnTemp1, RGN_DIFF );
rgnTemp1.DeleteObject();
if( m_lButtonType != 5 )
{
//Java
rgnTemp1.CreateRectRgn( 0, 0, 1, 1 );
rgnTemp2.CombineRgn( &rgnCreate, &rgnTemp1, RGN_DIFF );
rgnTemp1.DeleteObject();
rgnTemp1.CreateRectRgn( m_nWidth, m_nHeight, m_nWidth - 1, m_nHeight - 1 );
rgnCreate.CombineRgn( &rgnTemp2, &rgnTemp1, RGN_DIFF );
rgnTemp1.DeleteObject();
}
}
else if( m_lButtonType == 3 || m_lButtonType == 4 )
{
//WindowsXP
//Mac
rgnTemp1.CreateRectRgn( 0, 0, 2, 1 );
rgnTemp2.CombineRgn( &rgnCreate, &rgnTemp1, RGN_DIFF );
rgnTemp1.DeleteObject();
rgnTemp1.CreateRectRgn( 0, m_nHeight, 2, m_nHeight - 1 );
rgnCreate.CombineRgn( &rgnTemp2, &rgnTemp1, RGN_DIFF );
rgnTemp1.DeleteObject();
rgnTemp1.CreateRectRgn( m_nWidth, 0, m_nWidth - 2, 1 );
rgnTemp2.CombineRgn( &rgnCreate, &rgnTemp1, RGN_DIFF );
rgnTemp1.DeleteObject();
rgnTemp1.CreateRectRgn( m_nWidth, m_nHeight, m_nWidth - 2, m_nHeight - 1 );
rgnCreate.CombineRgn( &rgnTemp2, &rgnTemp1, RGN_DIFF );
rgnTemp1.DeleteObject();
rgnTemp1.CreateRectRgn( 0, 1, 1, 2 );
rgnTemp2.CombineRgn( &rgnCreate, &rgnTemp1, RGN_DIFF );
rgnTemp1.DeleteObject();
rgnTemp1.CreateRectRgn( 0, m_nHeight - 1, 1, m_nHeight - 2 );
rgnCreate.CombineRgn( &rgnTemp2, &rgnTemp1, RGN_DIFF );
rgnTemp1.DeleteObject();
rgnTemp1.CreateRectRgn( m_nWidth, 1, m_nWidth - 1, 2 );
rgnTemp2.CombineRgn( &rgnCreate, &rgnTemp1, RGN_DIFF );
rgnTemp1.DeleteObject();
rgnTemp1.CreateRectRgn( m_nWidth, m_nHeight - 1, m_nWidth - 1, m_nHeight - 2 );
rgnCreate.CombineRgn( &rgnTemp2, &rgnTemp1, RGN_DIFF );
rgnTemp1.DeleteObject();
}
rgnTemp2.DeleteObject();
return 0;
}
/////////////////////////////////////////////////////////////////////////////
//
// 設(shè)置窗口顏色變量
// 參數(shù): none
// 返回值: 0 正確
//
/////////////////////////////////////////////////////////////////////////////
int CChameleonCtrl::SetColor()
{
if( m_lColorScheme == 2 )
{
//Custom
if( m_bMouseOver && m_lColorScheme == 2 )
{
m_ulFace = m_lBackOverColor;
}
else
{
m_ulFace = TranslateColor( GetBackColor() );
}
m_ulFaceO = m_lBackOverColor;
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -