2012-12-19 09:30:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
2015-11-10 05:21:49 +00:00
|
|
|
* Project64 - A Nintendo 64 emulator. *
|
2012-12-19 09:30:18 +00:00
|
|
|
* 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
|
|
|
|
2008-12-04 10:41:51 +00:00
|
|
|
CModifiedEditBox::CModifiedEditBox(bool bString /* = true */, HWND hWnd /* = NULL */) :
|
2015-11-07 01:11:25 +00:00
|
|
|
CEdit(hWnd),
|
|
|
|
m_Changed(false),
|
|
|
|
m_Reset(false),
|
|
|
|
m_BoldFont(NULL),
|
|
|
|
m_OriginalFont(NULL),
|
|
|
|
m_TextField(NULL),
|
|
|
|
m_bString(bString)
|
|
|
|
{
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CModifiedEditBox::~CModifiedEditBox()
|
|
|
|
{
|
2015-11-12 21:27:28 +00:00
|
|
|
if (m_BoldFont)
|
|
|
|
{
|
|
|
|
DeleteObject(m_BoldFont);
|
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void CModifiedEditBox::SetReset(bool Reset)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2015-11-12 21:27:28 +00:00
|
|
|
m_Reset = Reset;
|
|
|
|
if (m_Reset)
|
|
|
|
{
|
|
|
|
SetChanged(false);
|
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void CModifiedEditBox::SetChanged(bool Changed)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2015-11-12 21:27:28 +00:00
|
|
|
m_Changed = Changed;
|
|
|
|
if (m_Changed)
|
|
|
|
{
|
|
|
|
SetReset(false);
|
|
|
|
if (m_BoldFont == NULL)
|
|
|
|
{
|
|
|
|
m_OriginalFont = (HFONT)SendMessage(WM_GETFONT);
|
2008-11-14 20:51:06 +00:00
|
|
|
|
2015-11-12 21:27:28 +00:00
|
|
|
LOGFONT lfSystemVariableFont;
|
|
|
|
GetObject(m_OriginalFont, sizeof(LOGFONT), &lfSystemVariableFont);
|
|
|
|
lfSystemVariableFont.lfWeight = FW_BOLD;
|
2008-11-14 20:51:06 +00:00
|
|
|
|
2015-11-12 21:27:28 +00:00
|
|
|
m_BoldFont = CreateFontIndirect(&lfSystemVariableFont);
|
|
|
|
}
|
|
|
|
SendMessage(WM_SETFONT, (WPARAM)m_BoldFont);
|
|
|
|
InvalidateRect(NULL);
|
|
|
|
if (m_TextField)
|
|
|
|
{
|
|
|
|
::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_BoldFont, 0);
|
|
|
|
::InvalidateRect(m_TextField, NULL, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_OriginalFont)
|
|
|
|
{
|
|
|
|
SendMessage(WM_SETFONT, (WPARAM)m_OriginalFont);
|
|
|
|
InvalidateRect(NULL);
|
|
|
|
if (m_TextField)
|
|
|
|
{
|
|
|
|
::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_OriginalFont, 0);
|
|
|
|
::InvalidateRect(m_TextField, NULL, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
stdstr CModifiedEditBox::GetWindowText(void)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2015-11-12 21:27:28 +00:00
|
|
|
stdstr Result;
|
|
|
|
ATLASSERT(::IsWindow(m_hWnd));
|
2008-11-14 20:51:06 +00:00
|
|
|
|
2015-11-12 21:27:28 +00:00
|
|
|
int nLen = ::GetWindowTextLength(m_hWnd);
|
|
|
|
if (nLen == 0)
|
|
|
|
{
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
Result.resize(nLen + 1);
|
|
|
|
::GetWindowText(m_hWnd, (char *)Result.c_str(), nLen + 1);
|
|
|
|
return Result;
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
2008-12-04 10:41:51 +00:00
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void CModifiedEditBox::SetTextField(HWND hWnd)
|
2008-12-04 10:41:51 +00:00
|
|
|
{
|
2015-11-12 21:27:28 +00:00
|
|
|
if (m_TextField && m_OriginalFont)
|
|
|
|
{
|
|
|
|
::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_OriginalFont, 0);
|
|
|
|
}
|
|
|
|
m_TextField = hWnd;
|
|
|
|
if (m_Changed && m_BoldFont)
|
|
|
|
{
|
|
|
|
::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_BoldFont, 0);
|
|
|
|
}
|
|
|
|
}
|