scbarg.cpp
来自「用bcg库编写的java IDE 源码」· C++ 代码 · 共 475 行
CPP
475 行
/////////////////////////////////////////////////////////////////////////
//
// CSizingControlBarG Version 2.43
//
// Created: Jan 24, 1998 Last Modified: August 03, 2000
//
// See the official site at www.datamekanix.com for documentation and
// the latest news.
//
/////////////////////////////////////////////////////////////////////////
// Copyright (C) 1998-2000 by Cristi Posea. All rights reserved.
//
// This code is free for personal and commercial use, providing this
// notice remains intact in the source files and all eventual changes are
// clearly marked with comments.
//
// You must obtain the author's consent before you can include this code
// in a software library.
//
// No warrantee of any kind, express or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc. to
// cristi@datamekanix.com or post them at the message board at the site.
/////////////////////////////////////////////////////////////////////////
// sizecbar.cpp : implementation file
//
#include "stdafx.h"
#include "scbarg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////
// CSizingControlBarG
IMPLEMENT_DYNAMIC(CSizingControlBarG, baseCSizingControlBarG);
CSizingControlBarG::CSizingControlBarG()
{
m_cyGripper = 16;
}
CSizingControlBarG::~CSizingControlBarG()
{
}
BEGIN_MESSAGE_MAP(CSizingControlBarG, baseCSizingControlBarG)
//{{AFX_MSG_MAP(CSizingControlBarG)
ON_WM_NCLBUTTONUP()
ON_WM_NCHITTEST()
//}}AFX_MSG_MAP
// ON_MESSAGE(WM_SETTEXT, OnSetText)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////
// CSizingControlBarG message handlers
/////////////////////////////////////////////////////////////////////////
// Mouse Handling
//
LRESULT CSizingControlBarG::OnSetText(WPARAM wParam, LPARAM lParam)
{
return 0;//baseCSizingControlBarG::OnSetText(wParam,lParam)
}
void CSizingControlBarG::OnNcLButtonUp(UINT nHitTest, CPoint point)
{
if (nHitTest == HTCLOSE)
m_pDockSite->ShowControlBar(this, FALSE, FALSE); // hide
baseCSizingControlBarG::OnNcLButtonUp(nHitTest, point);
}
void CSizingControlBarG::NcCalcClient(LPRECT pRc, UINT nDockBarID)
{
/*
CRect rcBar(pRc); // save the bar rect
// subtract edges
baseCSizingControlBarG::NcCalcClient(pRc, nDockBarID);
if (!HasGripper())
return;
CRect rc(pRc); // the client rect as calculated by the base class
BOOL bHorz = (nDockBarID == AFX_IDW_DOCKBAR_TOP) ||
(nDockBarID == AFX_IDW_DOCKBAR_BOTTOM);
if (bHorz)
rc.DeflateRect(m_cyGripper, 0, 0, 0);
else
rc.DeflateRect(0, m_cyGripper, 0, 0);
// set position for the "x" (hide bar) button
CPoint ptOrgBtn;
if (bHorz)
ptOrgBtn = CPoint(rc.left -11, rc.top+5);
else
ptOrgBtn = CPoint(rc.right - 18, rc.top - 11);
m_biHide.Move(ptOrgBtn - rcBar.TopLeft(),bHorz);
*pRc = rc;
*/
}
void CSizingControlBarG::NcPaintGripper(CDC* pDC, CRect rcClient)
{
/*
if (!HasGripper())
return;
// paints a simple "two raised lines" gripper
// override this if you want a more sophisticated gripper
CRect gripper = rcClient;
CRect rcbtn = m_biHide.GetRect();
BOOL bHorz = IsHorzDocked();
gripper.DeflateRect(1, 1);
if (bHorz)
{ // gripper at left
gripper.left -= m_cyGripper-1;
gripper.right = gripper.left + 3;
gripper.top = rcbtn.bottom+20;
//gripper.bottom
}
else
{ // gripper at top
gripper.top -= m_cyGripper-2;
gripper.bottom = gripper.top + 3;
gripper.right = rcbtn.left - 5;
gripper.left += 5;
}
pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT),
::GetSysColor(COLOR_BTNSHADOW));
gripper.OffsetRect(bHorz ? 3 : 0, bHorz ? 0 : 3);
pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT),
::GetSysColor(COLOR_BTNSHADOW));
//m_biHide.Paint(pDC);
*/
}
UINT CSizingControlBarG::OnNcHitTest(CPoint point)
{
/*
CRect rcBar;
GetWindowRect(rcBar);
UINT nRet = baseCSizingControlBarG::OnNcHitTest(point);
if (nRet != HTCLIENT)
return nRet;
CRect rc = m_biHide.GetRect();
rc.OffsetRect(rcBar.TopLeft());
if (rc.PtInRect(point))
return HTCLOSE;
*/
return HTCLIENT;
}
/////////////////////////////////////////////////////////////////////////
// CSizingControlBarG implementation helpers
void CSizingControlBarG::OnUpdateCmdUI(CFrameWnd* pTarget,
BOOL bDisableIfNoHndler)
{
/*
UNUSED_ALWAYS(bDisableIfNoHndler);
UNUSED_ALWAYS(pTarget);
if (!HasGripper())
return;
BOOL bNeedPaint = FALSE;
CPoint pt;
::GetCursorPos(&pt);
BOOL bHit = (OnNcHitTest(pt) == HTCLOSE);
BOOL bLButtonDown = (::GetKeyState(VK_LBUTTON) < 0);
BOOL bWasPushed = m_biHide.bPushed;
m_biHide.bPushed = bHit && bLButtonDown;
BOOL bWasRaised = m_biHide.bRaised;
m_biHide.bRaised = bHit && !bLButtonDown;
bNeedPaint |= (m_biHide.bPushed ^ bWasPushed) ||
(m_biHide.bRaised ^ bWasRaised);
if (bNeedPaint)
SendMessage(WM_NCPAINT);
*/
}
/*
/////////////////////////////////////////////////////////////////////////
// CSCBButton
CSCBButton::CSCBButton()
{
bRaised = FALSE;
bPushed = FALSE;
bRPushed = FALSE;
bHoriz = FALSE;
}
void CSCBButton::Paint(CDC* pDC)
{
CRect rc = GetRect();
COLORREF clrOldTextColor = pDC->GetTextColor();
pDC->SetTextColor(::GetSysColor(COLOR_BTNTEXT));
int nPrevBkMode = pDC->SetBkMode(TRANSPARENT);
CFont font;
int ppi = pDC->GetDeviceCaps(LOGPIXELSX);
int pointsize = MulDiv(60, 96, ppi); // 6 points at 96 ppi
font.CreatePointFont(pointsize, _T("Marlett"));
CFont* oldfont = pDC->SelectObject(&font);
if (bPushed)
{
DrawBtnDown(pDC);
}
else
{
DrawBtnUp(pDC);
}
pDC->TextOut(ptOrg.x + 2, ptOrg.y + 1, CString(_T("r")));//t // x-like
font.Detach();
font.CreatePointFont(90, _T("Marlett"));
oldfont = pDC->SelectObject(&font);
//draw roll-up-down button
DrawRBtn(pDC);
pDC->SelectObject(oldfont);
pDC->SetBkMode(nPrevBkMode);
pDC->SetTextColor(clrOldTextColor);
}
void CSCBButton::DrawBtnUp(CDC* pDC)
{
CPen penBlack;
//draw hide button
if( penBlack.CreatePen( PS_SOLID, 2, RGB(241,241,235) ) )//draw top and left
{
// Select it into the device context
// Save the old pen at the same time
CPen* pOldPen = pDC->SelectObject( &penBlack );
// Draw top
pDC->MoveTo(CPoint(ptOrg.x,ptOrg.y));
pDC->LineTo(CPoint(ptOrg.x+10,ptOrg.y));
// Draw left
pDC->MoveTo(CPoint(ptOrg.x,ptOrg.y));
pDC->LineTo(CPoint(ptOrg.x,ptOrg.y+10));
// Restore the old pen to the device context
pDC->SelectObject( pOldPen );
}
penBlack.Detach();
if( penBlack.CreatePen( PS_SOLID, 2, RGB(131,131,131) ) )
{
// Select it into the device context
// Save the old pen at the same time
CPen* pOldPen = pDC->SelectObject( &penBlack );
// Draw bottom
pDC->MoveTo(CPoint(ptOrg.x,ptOrg.y+10));
pDC->LineTo(CPoint(ptOrg.x+10,ptOrg.y+10));
//draw right
pDC->MoveTo(CPoint(ptOrg.x+10,ptOrg.y+1));
pDC->LineTo(CPoint(ptOrg.x+10,ptOrg.y+10));
// Restore the old pen to the device context
pDC->SelectObject( pOldPen );
}
penBlack.Detach();
}
void CSCBButton::DrawBtnDown(CDC* pDC)
{
CPen penBlack; // Construct it, then initialize
if(penBlack.CreatePen(PS_SOLID,2,RGB(131,131,131)))//draw top and left
{
// Select it into the device context
// Save the old pen at the same time
CPen* pOldPen = pDC->SelectObject( &penBlack );
// Draw top
pDC->MoveTo(CPoint(ptOrg.x,ptOrg.y));
pDC->LineTo(CPoint(ptOrg.x+10,ptOrg.y));
// Draw left
pDC->MoveTo(CPoint(ptOrg.x,ptOrg.y));
pDC->LineTo(CPoint(ptOrg.x,ptOrg.y+10));
// Restore the old pen to the device context
pDC->SelectObject( pOldPen );
}
penBlack.Detach();
if(penBlack.CreatePen(PS_SOLID,2,RGB(241,241,235)))
{
// Select it into the device context
// Save the old pen at the same time
CPen* pOldPen = pDC->SelectObject( &penBlack );
// Draw bottom
pDC->MoveTo(CPoint(ptOrg.x,ptOrg.y+10));
pDC->LineTo(CPoint(ptOrg.x+10,ptOrg.y+10));
//draw right
pDC->MoveTo(CPoint(ptOrg.x+10,ptOrg.y+1));
pDC->LineTo(CPoint(ptOrg.x+10,ptOrg.y+10));
// Restore the old pen to the device context
pDC->SelectObject( pOldPen );
}
penBlack.Detach();
}
void CSCBButton::DrawRBtn(CDC* pDC)
{
CPen penBlack;
//draw roll-up-down button
if(penBlack.CreatePen(PS_SOLID,2,RGB(241,241,235)))//draw top and left
{
// Select it into the device context
// Save the old pen at the same time
CPen* pOldPen = pDC->SelectObject( &penBlack );
if(bHoriz)
{
// Draw top
pDC->MoveTo(CPoint(ptOrg.x,ptOrg.y+15));//-5 for space
pDC->LineTo(CPoint((ptOrg.x)+10,ptOrg.y+15));
// Draw left
pDC->MoveTo(CPoint(ptOrg.x,ptOrg.y+15));
pDC->LineTo(CPoint(ptOrg.x,(ptOrg.y+15)+10));
}
else
{
// Draw top
pDC->MoveTo(CPoint(ptOrg.x-15,ptOrg.y));//-5 for space
pDC->LineTo(CPoint((ptOrg.x-15)+10,ptOrg.y));
// Draw left
pDC->MoveTo(CPoint(ptOrg.x-15,ptOrg.y));
pDC->LineTo(CPoint(ptOrg.x-15,ptOrg.y+10));
}
// Restore the old pen to the device context
pDC->SelectObject( pOldPen );
}
penBlack.Detach();
if(penBlack.CreatePen(PS_SOLID,2,RGB(131,131,131)))
{
// Select it into the device context
// Save the old pen at the same time
CPen* pOldPen = pDC->SelectObject( &penBlack );
if(bHoriz)
{
// Draw bottom
pDC->MoveTo(CPoint(ptOrg.x,ptOrg.y+25));//-5 for space
pDC->LineTo(CPoint(ptOrg.x+10,ptOrg.y+25));
// Draw right
pDC->MoveTo(CPoint(ptOrg.x+10,ptOrg.y+16));
pDC->LineTo(CPoint(ptOrg.x+10,(ptOrg.y+25)));
pDC->TextOut(ptOrg.x , ptOrg.y+14, CString(_T("w")));//t // x-like
}
else
{
// Draw bottom
pDC->MoveTo(CPoint(ptOrg.x-15,ptOrg.y+10));//-5 for space
pDC->LineTo(CPoint((ptOrg.x-15)+10,ptOrg.y+10));
// Draw right
pDC->MoveTo(CPoint(ptOrg.x-5,ptOrg.y+1));
pDC->LineTo(CPoint(ptOrg.x-5,ptOrg.y+10));
pDC->TextOut(ptOrg.x - 16, ptOrg.y, CString(_T("t")));//t // x-like
}
// Restore the old pen to the device context
pDC->SelectObject( pOldPen );
}
penBlack.Detach();
/*
{
//draw roll-up-down button
if(penBlack.CreatePen(PS_SOLID,2,RGB(131,131,131)))//draw top and left
{
// Select it into the device context
// Save the old pen at the same time
CPen* pOldPen = pDC->SelectObject( &penBlack );
// Draw top
pDC->MoveTo(CPoint(ptOrg.x-15,ptOrg.y));//-5 for space
pDC->LineTo(CPoint((ptOrg.x-15)+10,ptOrg.y));
// Draw left
pDC->MoveTo(CPoint(ptOrg.x-15,ptOrg.y));
pDC->LineTo(CPoint(ptOrg.x-15,ptOrg.y+10));
// Restore the old pen to the device context
pDC->SelectObject( pOldPen );
}
penBlack.Detach();
if(penBlack.CreatePen(PS_SOLID,2,RGB(241,241,235)))
{
// Select it into the device context
// Save the old pen at the same time
CPen* pOldPen = pDC->SelectObject( &penBlack );
// Draw bottom
pDC->MoveTo(CPoint(ptOrg.x-15,ptOrg.y+10));//-5 for space
pDC->LineTo(CPoint((ptOrg.x-15)+10,ptOrg.y+10));
// Draw right
pDC->MoveTo(CPoint(ptOrg.x-5,ptOrg.y+1));
pDC->LineTo(CPoint(ptOrg.x-5,ptOrg.y+10));
// Restore the old pen to the device context
pDC->SelectObject( pOldPen );
}
penBlack.Detach();
}
*
}
*/
BOOL CSizingControlBarG::HasGripper() const
{
#if defined(_SCB_MINIFRAME_CAPTION) || !defined(_SCB_REPLACE_MINIFRAME)
// if the miniframe has a caption, don't display the gripper
if (IsFloating())
return FALSE;
#endif //_SCB_MINIFRAME_CAPTION
return TRUE;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?