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 *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
#pragma once
|
2008-11-14 20:51:06 +00:00
|
|
|
|
|
|
|
template <class TParam>
|
|
|
|
class CModifiedComboBoxT :
|
|
|
|
public CComboBox
|
|
|
|
{
|
2008-12-04 10:41:51 +00:00
|
|
|
typedef std::list<TParam *> TParamList;
|
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
public:
|
|
|
|
// Constructors
|
2012-11-13 05:07:23 +00:00
|
|
|
CModifiedComboBoxT(TParam defaultValue, HWND hWnd = NULL, bool AllwaysSelected = true) :
|
2008-11-14 20:51:06 +00:00
|
|
|
CComboBox(hWnd),
|
2012-11-13 05:07:23 +00:00
|
|
|
m_defaultValue(defaultValue),
|
|
|
|
m_AllwaysSelected(AllwaysSelected),
|
2008-11-14 20:51:06 +00:00
|
|
|
m_Changed(false),
|
|
|
|
m_Reset(false),
|
|
|
|
m_BoldFont(NULL),
|
|
|
|
m_OriginalFont(NULL),
|
|
|
|
m_TextField(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~CModifiedComboBoxT()
|
|
|
|
{
|
|
|
|
if (m_BoldFont)
|
|
|
|
{
|
|
|
|
DeleteObject(m_BoldFont);
|
|
|
|
}
|
2008-12-04 10:41:51 +00:00
|
|
|
for (TParamList::iterator iter = m_ParamList.begin(); iter != m_ParamList.end(); iter ++)
|
|
|
|
{
|
|
|
|
TParam * Item = (TParam *)*iter;
|
|
|
|
if (Item)
|
|
|
|
{
|
|
|
|
delete Item;
|
|
|
|
}
|
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 10:41:51 +00:00
|
|
|
int AddItem (LPCSTR strItem, const TParam & lParam)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
int indx = AddString(strItem);
|
2008-12-04 10:41:51 +00:00
|
|
|
TParam * Value = new TParam(lParam);
|
|
|
|
SetItemData(indx,(DWORD_PTR)(Value));
|
|
|
|
m_ParamList.push_back(Value);
|
2012-11-13 05:07:23 +00:00
|
|
|
if ((m_AllwaysSelected && GetCount() == 1) || m_defaultValue == lParam)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
SetCurSel(indx);
|
|
|
|
}
|
|
|
|
return indx;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetReset ( bool Reset )
|
|
|
|
{
|
|
|
|
m_Reset = Reset;
|
|
|
|
if (m_Reset)
|
|
|
|
{
|
|
|
|
SetChanged(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetChanged (bool Changed)
|
|
|
|
{
|
|
|
|
m_Changed = Changed;
|
|
|
|
if (m_Changed)
|
|
|
|
{
|
|
|
|
SetReset(false);
|
|
|
|
if (m_BoldFont == NULL)
|
|
|
|
{
|
|
|
|
m_OriginalFont = (HFONT)SendMessage(WM_GETFONT);
|
|
|
|
|
|
|
|
LOGFONT lfSystemVariableFont;
|
|
|
|
GetObject ( m_OriginalFont, sizeof(LOGFONT), &lfSystemVariableFont );
|
|
|
|
lfSystemVariableFont.lfWeight = FW_BOLD;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetTextField (HWND hWnd)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-04 10:41:51 +00:00
|
|
|
inline void SetDefault (const TParam & defaultValue)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
m_defaultValue = defaultValue;
|
|
|
|
for (int i = 0, n = GetCount(); i < n; i++)
|
|
|
|
{
|
2008-12-04 10:41:51 +00:00
|
|
|
if (*((TParam *)GetItemData(i)) == m_defaultValue)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
SetCurSel(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsChanged ( void ) const
|
|
|
|
{
|
|
|
|
return m_Changed;
|
|
|
|
}
|
|
|
|
inline bool IsReset ( void ) const
|
|
|
|
{
|
|
|
|
return m_Reset;
|
|
|
|
}
|
|
|
|
|
2012-11-13 05:07:23 +00:00
|
|
|
private:
|
|
|
|
CModifiedComboBoxT(void); // Disable default constructor
|
|
|
|
CModifiedComboBoxT(const CModifiedComboBoxT&); // Disable copy constructor
|
|
|
|
CModifiedComboBoxT& operator=(const CModifiedComboBoxT&); // Disable assignment
|
|
|
|
|
|
|
|
bool m_Changed;
|
|
|
|
bool m_Reset;
|
|
|
|
TParam m_defaultValue;
|
|
|
|
HFONT m_BoldFont;
|
|
|
|
HFONT m_OriginalFont;
|
|
|
|
HWND m_TextField;
|
|
|
|
bool m_AllwaysSelected;
|
|
|
|
|
|
|
|
TParamList m_ParamList;
|
|
|
|
|
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef CModifiedComboBoxT<WPARAM> CModifiedComboBox;
|
2008-12-04 10:41:51 +00:00
|
|
|
typedef CModifiedComboBoxT<stdstr> CModifiedComboBoxTxt;
|