2012-12-19 09:30:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
|
|
|
* Project 64 - A Nintendo 64 emulator. *
|
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2012 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
2010-06-07 02:23:58 +00:00
|
|
|
#include "stdafx.h"
|
2008-11-14 20:51:06 +00:00
|
|
|
|
2015-09-07 19:47:44 +00:00
|
|
|
#ifdef WINDOWS_UI
|
2015-03-06 07:27:31 +00:00
|
|
|
BOOL CPartialGroupBox::Attach(HWND hWnd)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2015-03-06 07:27:31 +00:00
|
|
|
ATLASSUME(m_hWnd == NULL);
|
|
|
|
ATLASSERT(::IsWindow(hWnd));
|
|
|
|
|
|
|
|
// Allocate the thunk structure here, where we can fail gracefully.
|
|
|
|
|
|
|
|
BOOL result = m_thunk.Init(GetWindowProc(), this);
|
|
|
|
if (result == FALSE)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
WNDPROC pProc = m_thunk.GetWNDPROC();
|
|
|
|
WNDPROC pfnWndProc = (WNDPROC)::SetWindowLongPtrW(hWnd, GWLP_WNDPROC, (LONG_PTR)pProc);
|
|
|
|
if (pfnWndProc == NULL)
|
|
|
|
return FALSE;
|
|
|
|
m_pfnSuperWindowProc = pfnWndProc;
|
|
|
|
m_hWnd = hWnd;
|
|
|
|
return TRUE;
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL CPartialGroupBox::AttachToDlgItem(HWND parent, UINT dlgID)
|
|
|
|
{
|
2015-03-06 07:27:31 +00:00
|
|
|
return Attach(::GetDlgItem(parent,dlgID));
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
2012-10-05 09:15:21 +00:00
|
|
|
void CPartialGroupBox::Draw3dLine(CPaintDC & dc, LPCRECT lpRect, COLORREF clrTopLeft, COLORREF /*clrBottomRight*/)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
int x = lpRect->left;
|
|
|
|
int y = lpRect->top;
|
|
|
|
int cx = lpRect->right - lpRect->left;
|
2012-10-05 09:15:21 +00:00
|
|
|
//int cy = lpRect->bottom - lpRect->top;
|
2008-11-14 20:51:06 +00:00
|
|
|
|
|
|
|
dc.FillSolidRect(x, y, cx - 1, 1, clrTopLeft);
|
|
|
|
//dc.FillSolidRect(x, y, 1, cy - 1, clrTopLeft);
|
|
|
|
//dc.FillSolidRect(x + cx, y, -1, cy, clrBottomRight);
|
|
|
|
//dc.FillSolidRect(x, y + cy, cx, -1, clrBottomRight);
|
|
|
|
}
|
|
|
|
|
2012-10-05 09:15:21 +00:00
|
|
|
void CPartialGroupBox::OnPaint(HDC /*hDC*/)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
CPaintDC dc(m_hWnd);
|
|
|
|
|
|
|
|
//paint groupbox manually
|
|
|
|
CRect controlrect;
|
|
|
|
GetClientRect(controlrect);
|
|
|
|
//::MapWindowPoints(HWND_DESKTOP, GetParent(), (LPPOINT)(LPRECT)controlrect, (sizeof(RECT)/sizeof(POINT)));
|
|
|
|
|
|
|
|
CFontHandle font = GetFont();
|
|
|
|
|
|
|
|
dc.SelectFont(font);
|
|
|
|
dc.SetMapMode(MM_TEXT);
|
|
|
|
dc.SelectBrush(GetSysColorBrush(COLOR_BTNFACE));
|
|
|
|
|
2015-03-06 07:27:31 +00:00
|
|
|
wchar_t grptext[500];
|
|
|
|
GetWindowTextW(m_hWnd, grptext, sizeof(grptext) / sizeof(grptext[0]));
|
2008-11-14 20:51:06 +00:00
|
|
|
|
|
|
|
CRect fontsizerect(0,0,0,0);
|
2015-03-06 07:27:31 +00:00
|
|
|
dc.DrawTextW(grptext, -1, fontsizerect, DT_SINGLELINE | DT_LEFT | DT_CALCRECT);
|
2008-11-14 20:51:06 +00:00
|
|
|
|
|
|
|
CRect framerect(controlrect);
|
|
|
|
framerect.top += (fontsizerect.Height())/2;
|
|
|
|
long Style = GetStyle();
|
|
|
|
|
|
|
|
if((Style & 0xF000) == BS_FLAT)
|
|
|
|
{
|
|
|
|
dc.Draw3dRect(framerect,RGB(0,0,0),RGB(0,0,0));
|
|
|
|
framerect.DeflateRect(1,1);
|
|
|
|
dc.Draw3dRect(framerect,RGB(255,255,255),RGB(255,255,255));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Draw3dLine(dc,framerect,GetSysColor(COLOR_3DSHADOW),GetSysColor(COLOR_3DHILIGHT));
|
|
|
|
framerect.DeflateRect(1,1);
|
|
|
|
Draw3dLine(dc,framerect,GetSysColor(COLOR_3DHILIGHT),GetSysColor(COLOR_3DSHADOW));
|
|
|
|
}
|
|
|
|
|
2015-03-06 07:27:31 +00:00
|
|
|
if (wcslen(grptext))
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
CRect fontrect(controlrect);
|
|
|
|
fontrect.bottom = controlrect.top+fontsizerect.Height();
|
|
|
|
|
|
|
|
if((Style & 0xF00) == BS_RIGHT)
|
|
|
|
{
|
|
|
|
fontrect.right -= 6;
|
|
|
|
fontrect.left = fontrect.right - fontsizerect.Width();
|
|
|
|
}
|
|
|
|
else if((Style & 0xF00) == BS_CENTER)
|
|
|
|
{
|
|
|
|
fontrect.left += (controlrect.Width()-fontsizerect.Width())/2;
|
|
|
|
fontrect.right = fontrect.left + fontsizerect.Width();
|
|
|
|
}
|
|
|
|
else //BS_LEFT or default
|
|
|
|
{
|
|
|
|
fontrect.left += 6;
|
|
|
|
fontrect.right = fontrect.left + fontsizerect.Width();
|
|
|
|
}
|
|
|
|
|
|
|
|
fontrect.InflateRect(2,0);
|
|
|
|
dc.FillRect(fontrect,GetSysColor(COLOR_BTNFACE));
|
|
|
|
fontrect.DeflateRect(2,0);
|
|
|
|
|
|
|
|
//Draw Caption
|
|
|
|
dc.SetBkMode(OPAQUE);
|
|
|
|
dc.SetBkColor(GetSysColor(COLOR_BTNFACE));
|
|
|
|
|
2015-03-06 07:27:31 +00:00
|
|
|
dc.DrawTextW(grptext,-1,fontrect,DT_SINGLELINE|DT_LEFT);
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-07 19:47:44 +00:00
|
|
|
#endif
|