#include "pch.h"
#include "GenericBkMFC.h"
#include "DlgListBoxColorPickerST.h"
#include "DlgShowSelected.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

CDlgListBoxColorPickerST::CDlgListBoxColorPickerST(CWnd* pParent, CResourceServerST*	m_pIcons)
	: CDialog(CDlgListBoxColorPickerST::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgListBoxColorPickerST)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT

	m_pIconsDLL = m_pIcons;
}

void CDlgListBoxColorPickerST::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgListBoxColorPickerST)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP

	DDX_Control(pDX, IDC_LBXCOLORS1, m_lbxColors1);
	DDX_Control(pDX, IDC_BTNUP, m_btnUp);
	DDX_Control(pDX, IDC_BTNDOWN, m_btnDown);
	DDX_Control(pDX, IDC_BTNTOP, m_btnTop);
	DDX_Control(pDX, IDC_BTNBOTTOM, m_btnBottom);
}

BEGIN_MESSAGE_MAP(CDlgListBoxColorPickerST, CDialog)
	//{{AFX_MSG_MAP(CDlgListBoxColorPickerST)
	ON_LBN_DBLCLK(IDC_LBXCOLORS1, OnDblclkLbxColors1)
	ON_BN_CLICKED(IDC_BTNUP, OnBtnUp)
	ON_BN_CLICKED(IDC_BTNDOWN, OnBtnDown)
	ON_BN_CLICKED(IDC_BTNTOP, OnBtnTop)
	ON_BN_CLICKED(IDC_BTNBOTTOM, OnBtnBottom)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BOOL CDlgListBoxColorPickerST::OnInitDialog() 
{
	CDialog::OnInitDialog();

	// Othen buttons
	m_btnUp.SetIcon(IDI_MOVEUP);
	m_btnUp.SetTooltipText(_T("Move up"));
	m_btnUp.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 30);
	m_btnDown.SetIcon(IDI_MOVEDOWN);
	m_btnDown.SetTooltipText(_T("Move down"));
	m_btnDown.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 30);
	m_btnTop.SetIcon(IDI_MOVETOP);
	m_btnTop.SetTooltipText(_T("Move to top"));
	m_btnTop.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 30);
	m_btnBottom.SetIcon(IDI_MOVEBOTTOM);
	m_btnBottom.SetTooltipText(_T("Move to bottom"));
	m_btnBottom.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 30);

	// Add colors to listbox
	Populate();

	// Disable second list box item
	m_lbxColors1.EnableItem(36, FALSE);

	m_lbxColors1.SetCurSel(0);

	return TRUE;
} // End of OnInitDialog

void CDlgListBoxColorPickerST::OnOK()
{
} // End of OnOK

void CDlgListBoxColorPickerST::OnCancel()
{
} // End of OnCancel

void CDlgListBoxColorPickerST::Populate()
{
	// Add colors to listbox
	m_lbxColors1.AddString(_T("COLOR_3DDKSHADOW"), ::GetSysColor(COLOR_3DDKSHADOW));
	m_lbxColors1.AddString(_T("COLOR_3DFACE"), ::GetSysColor(COLOR_3DFACE));
	m_lbxColors1.AddString(_T("COLOR_3DHIGHLIGHT"), ::GetSysColor(COLOR_3DHIGHLIGHT));
	m_lbxColors1.AddString(_T("COLOR_3DHILIGHT"), ::GetSysColor(COLOR_3DHILIGHT));
	m_lbxColors1.AddString(_T("COLOR_3DLIGHT"), ::GetSysColor(COLOR_3DLIGHT));
	m_lbxColors1.AddString(_T("COLOR_3DSHADOW"), ::GetSysColor(COLOR_3DSHADOW));
	m_lbxColors1.AddString(_T("COLOR_ACTIVEBORDER"), ::GetSysColor(COLOR_ACTIVEBORDER));
	m_lbxColors1.AddString(_T("COLOR_ACTIVECAPTION"), ::GetSysColor(COLOR_ACTIVECAPTION));
	m_lbxColors1.AddString(_T("COLOR_APPWORKSPACE"), ::GetSysColor(COLOR_APPWORKSPACE));
	m_lbxColors1.AddString(_T("COLOR_BACKGROUND"), ::GetSysColor(COLOR_BACKGROUND));
	m_lbxColors1.AddString(_T("COLOR_BTNFACE"), ::GetSysColor(COLOR_BTNFACE));
	m_lbxColors1.AddString(_T("COLOR_BTNHIGHLIGHT"), ::GetSysColor(COLOR_BTNHIGHLIGHT));
	m_lbxColors1.AddString(_T("COLOR_BTNHILIGHT"), ::GetSysColor(COLOR_BTNHILIGHT));
	m_lbxColors1.AddString(_T("COLOR_BTNSHADOW"), ::GetSysColor(COLOR_BTNSHADOW));
	m_lbxColors1.AddString(_T("COLOR_BTNTEXT"), ::GetSysColor(COLOR_BTNTEXT));
	m_lbxColors1.AddString(_T("COLOR_CAPTIONTEXT"), ::GetSysColor(COLOR_CAPTIONTEXT));
	m_lbxColors1.AddString(_T("COLOR_DESKTOP"), ::GetSysColor(COLOR_DESKTOP));
	m_lbxColors1.AddString(_T("COLOR_GRADIENTACTIVECAPTION"), ::GetSysColor(COLOR_GRADIENTACTIVECAPTION));
	m_lbxColors1.AddString(_T("COLOR_GRADIENTINACTIVECAPTION"), ::GetSysColor(COLOR_GRADIENTINACTIVECAPTION));
	m_lbxColors1.AddString(_T("COLOR_GRAYTEXT"), ::GetSysColor(COLOR_GRAYTEXT));
	m_lbxColors1.AddString(_T("COLOR_HIGHLIGHT"), ::GetSysColor(COLOR_HIGHLIGHT));
	m_lbxColors1.AddString(_T("COLOR_HIGHLIGHTTEXT"), ::GetSysColor(COLOR_HIGHLIGHTTEXT));
	m_lbxColors1.AddString(_T("COLOR_HOTLIGHT"), ::GetSysColor(COLOR_HOTLIGHT));
	m_lbxColors1.AddString(_T("COLOR_INACTIVEBORDER"), ::GetSysColor(COLOR_INACTIVEBORDER));
	m_lbxColors1.AddString(_T("COLOR_INACTIVECAPTION"), ::GetSysColor(COLOR_INACTIVECAPTION));
	m_lbxColors1.AddString(_T("COLOR_INACTIVECAPTIONTEXT"), ::GetSysColor(COLOR_INACTIVECAPTIONTEXT));
	m_lbxColors1.AddString(_T("COLOR_INFOBK"), ::GetSysColor(COLOR_INFOBK));
	m_lbxColors1.AddString(_T("COLOR_INFOTEXT"), ::GetSysColor(COLOR_INFOTEXT));
	m_lbxColors1.AddString(_T("COLOR_MENU"), ::GetSysColor(COLOR_MENU));
	m_lbxColors1.AddString(_T("COLOR_MENUHILIGHT"), ::GetSysColor(COLOR_MENUHILIGHT));
	m_lbxColors1.AddString(_T("COLOR_MENUBAR"), ::GetSysColor(COLOR_MENUBAR));
	m_lbxColors1.AddString(_T("COLOR_MENUTEXT"), ::GetSysColor(COLOR_MENUTEXT));
	m_lbxColors1.AddString(_T("COLOR_SCROLLBAR"), ::GetSysColor(COLOR_SCROLLBAR));
	m_lbxColors1.AddString(_T("COLOR_WINDOW"), ::GetSysColor(COLOR_WINDOW));
	m_lbxColors1.AddString(_T("COLOR_WINDOWFRAME"), ::GetSysColor(COLOR_WINDOWFRAME));
	m_lbxColors1.AddString(_T("COLOR_WINDOWTEXT"), ::GetSysColor(COLOR_WINDOWTEXT));
	m_lbxColors1.AddString(_T("COLOR_3DDKSHADOW\n(Disabled)"), ::GetSysColor(COLOR_3DDKSHADOW));
} // End of Populate

void CDlgListBoxColorPickerST::OnDblclkLbxColors1()
{
	CDlgShowSelected	dlg(this);
	int					nIndex;
	CString				sStr;
	COLORREF			crColor;

	nIndex = m_lbxColors1.GetCurSel();
	if (nIndex != LB_ERR)
	{
		m_lbxColors1.GetTextAndColor(nIndex, sStr, &crColor);
		dlg.SetProperties(nIndex, sStr, crColor, m_pIconsDLL);
		dlg.DoModal();
	} // if
} // End of OnDblclkLbxColors1

void CDlgListBoxColorPickerST::OnBtnUp()
{
	m_lbxColors1.MoveUp(m_lbxColors1.GetCurSel());
} // End of OnBtnUp

void CDlgListBoxColorPickerST::OnBtnDown()
{
	m_lbxColors1.MoveDown(m_lbxColors1.GetCurSel());
} // End of OnBtnDown

void CDlgListBoxColorPickerST::OnBtnTop()
{
	m_lbxColors1.MoveTop(m_lbxColors1.GetCurSel());
} // End of OnBtnTop

void CDlgListBoxColorPickerST::OnBtnBottom()
{
	m_lbxColors1.MoveBottom(m_lbxColors1.GetCurSel());
} // End of OnBtnBottom
