working on metrics editor
This commit is contained in:
@@ -1,275 +0,0 @@
|
||||
// ColorListBox.cpp : implementation file
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
// CColorListBox class -
|
||||
// A CListBox-derived class with optional colored items.
|
||||
//
|
||||
// Version: 1.0 01/10/1998 Copyright © Patrice Godard
|
||||
//
|
||||
// Version: 2.0 09/17/1999 Copyright © Paul M. Meidinger
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "ColorListBox.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CColorListBox
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
CColorListBox::CColorListBox()
|
||||
//
|
||||
// Return Value: None.
|
||||
//
|
||||
// Parameters : None.
|
||||
//
|
||||
// Remarks : Standard constructor.
|
||||
//
|
||||
{
|
||||
} // CColorListBox
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
CColorListBox::~CColorListBox()
|
||||
//
|
||||
// Return Value: None.
|
||||
//
|
||||
// Parameters : None.
|
||||
//
|
||||
// Remarks : Destructor.
|
||||
//
|
||||
{
|
||||
} // ~CColorListBox()
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CColorListBox, CListBox)
|
||||
//{{AFX_MSG_MAP(CColorListBox)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CColorListBox message handlers
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
void CColorListBox::DrawItem(LPDRAWITEMSTRUCT lpDIS)
|
||||
//
|
||||
// Return Value: None.
|
||||
//
|
||||
// Parameters : lpDIS - A long pointer to a DRAWITEMSTRUCT structure
|
||||
// that contains information about the type of drawing required.
|
||||
//
|
||||
// Remarks : Called by the framework when a visual aspect of
|
||||
// an owner-draw list box changes.
|
||||
//
|
||||
{
|
||||
if ((int)lpDIS->itemID < 0)
|
||||
return;
|
||||
|
||||
CDC* pDC = CDC::FromHandle(lpDIS->hDC);
|
||||
|
||||
COLORREF crText;
|
||||
CString sText;
|
||||
COLORREF crNorm = (COLORREF)lpDIS->itemData; // Color information is in item data.
|
||||
COLORREF crHilite = RGB(255-GetRValue(crNorm), 255-GetGValue(crNorm), 255-GetBValue(crNorm));
|
||||
|
||||
// If item has been selected, draw the highlight rectangle using the item's color.
|
||||
if ((lpDIS->itemState & ODS_SELECTED) &&
|
||||
(lpDIS->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))
|
||||
{
|
||||
CBrush brush(crNorm);
|
||||
pDC->FillRect(&lpDIS->rcItem, &brush);
|
||||
}
|
||||
|
||||
// If item has been deselected, draw the rectangle using the window color.
|
||||
if (!(lpDIS->itemState & ODS_SELECTED) && (lpDIS->itemAction & ODA_SELECT))
|
||||
{
|
||||
CBrush brush(::GetSysColor(COLOR_WINDOW));
|
||||
pDC->FillRect(&lpDIS->rcItem, &brush);
|
||||
}
|
||||
|
||||
// If item has focus, draw the focus rect.
|
||||
if ((lpDIS->itemAction & ODA_FOCUS) && (lpDIS->itemState & ODS_FOCUS))
|
||||
pDC->DrawFocusRect(&lpDIS->rcItem);
|
||||
|
||||
// If item does not have focus, redraw (erase) the focus rect.
|
||||
if ((lpDIS->itemAction & ODA_FOCUS) && !(lpDIS->itemState & ODS_FOCUS))
|
||||
pDC->DrawFocusRect(&lpDIS->rcItem);
|
||||
|
||||
|
||||
// Set the background mode to TRANSPARENT to draw the text.
|
||||
int nBkMode = pDC->SetBkMode(TRANSPARENT);
|
||||
|
||||
// If the item's color information is set, use the highlight color
|
||||
// gray text color, or normal color for the text.
|
||||
if (lpDIS->itemData)
|
||||
{
|
||||
if (lpDIS->itemState & ODS_SELECTED)
|
||||
crText = pDC->SetTextColor(crHilite);
|
||||
else if (lpDIS->itemState & ODS_DISABLED)
|
||||
crText = pDC->SetTextColor(::GetSysColor(COLOR_GRAYTEXT));
|
||||
else
|
||||
crText = pDC->SetTextColor(crNorm);
|
||||
}
|
||||
// Else the item's color information is not set, so use the
|
||||
// system colors for the text.
|
||||
else
|
||||
{
|
||||
if (lpDIS->itemState & ODS_SELECTED)
|
||||
crText = pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
|
||||
else if (lpDIS->itemState & ODS_DISABLED)
|
||||
crText = pDC->SetTextColor(::GetSysColor(COLOR_GRAYTEXT));
|
||||
else
|
||||
crText = pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));
|
||||
}
|
||||
|
||||
|
||||
// Get and display item text.
|
||||
GetText(lpDIS->itemID, sText);
|
||||
CRect rect = lpDIS->rcItem;
|
||||
|
||||
// Setup the text format.
|
||||
UINT nFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER;
|
||||
if (GetStyle() & LBS_USETABSTOPS)
|
||||
nFormat |= DT_EXPANDTABS;
|
||||
|
||||
// Calculate the rectangle size before drawing the text.
|
||||
pDC->DrawText(sText, -1, &rect, nFormat | DT_CALCRECT);
|
||||
pDC->DrawText(sText, -1, &rect, nFormat);
|
||||
|
||||
pDC->SetTextColor(crText);
|
||||
pDC->SetBkMode(nBkMode);
|
||||
} // DrawItem
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
void CColorListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMIS)
|
||||
//
|
||||
// Return Value: None.
|
||||
//
|
||||
// Parameters : lpMIS - A long pointer to a
|
||||
// MEASUREITEMSTRUCT structure.
|
||||
//
|
||||
// Remarks : Called by the framework when a list box with
|
||||
// an owner-draw style is created.
|
||||
//
|
||||
{
|
||||
// ### Is the default list box item height the same as
|
||||
// the menu check height???
|
||||
lpMIS->itemHeight = ::GetSystemMetrics(SM_CYMENUCHECK);
|
||||
} // MeasureItem
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
int CColorListBox::AddString(LPCTSTR lpszItem)
|
||||
//
|
||||
// Return Value: The zero-based index to the string in the list box.
|
||||
// The return value is LB_ERR if an error occurs; the
|
||||
// return value is LB_ERRSPACE if insufficient space
|
||||
// is available to store the new string.
|
||||
//
|
||||
// Parameters : lpszItem - Points to the null-terminated
|
||||
// string that is to be added.
|
||||
//
|
||||
// Remarks : Call this member function to add a string to a list
|
||||
// box. Provided because CListBox::AddString is NOT
|
||||
// a virtual function.
|
||||
//
|
||||
{
|
||||
return ((CListBox*)this)->AddString(lpszItem);
|
||||
} // AddString
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
int CColorListBox::AddString(LPCTSTR lpszItem, COLORREF rgb)
|
||||
//
|
||||
// Return Value: The zero-based index to the string in the list box.
|
||||
// The return value is LB_ERR if an error occurs; the
|
||||
// return value is LB_ERRSPACE if insufficient space
|
||||
// is available to store the new string.
|
||||
//
|
||||
// Parameters : lpszItem - Points to the null-terminated
|
||||
// string that is to be added.
|
||||
// rgb - Specifies the color to be associated with the item.
|
||||
//
|
||||
// Remarks : Call this member function to add a string to a list
|
||||
// box with a custom color.
|
||||
//
|
||||
{
|
||||
int nItem = AddString(lpszItem);
|
||||
if (nItem >= 0)
|
||||
SetItemData(nItem, rgb);
|
||||
return nItem;
|
||||
} // AddString
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
int CColorListBox::InsertString(int nIndex, LPCTSTR lpszItem)
|
||||
//
|
||||
// Return Value: The zero-based index of the position at which the
|
||||
// string was inserted. The return value is LB_ERR if
|
||||
// an error occurs; the return value is LB_ERRSPACE if
|
||||
// insufficient space is available to store the new string.
|
||||
//
|
||||
// Parameters : nIndex - Specifies the zero-based index of the position
|
||||
// to insert the string. If this parameter is –1, the string
|
||||
// is added to the end of the list.
|
||||
// lpszItem - Points to the null-terminated string that
|
||||
// is to be inserted.
|
||||
//
|
||||
// Remarks : Inserts a string into the list box. Provided because
|
||||
// CListBox::InsertString is NOT a virtual function.
|
||||
//
|
||||
{
|
||||
return ((CListBox*)this)->InsertString(nIndex, lpszItem);
|
||||
} // InsertString
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
int CColorListBox::InsertString(int nIndex, LPCTSTR lpszItem, COLORREF rgb)
|
||||
//
|
||||
// Return Value: The zero-based index of the position at which the
|
||||
// string was inserted. The return value is LB_ERR if
|
||||
// an error occurs; the return value is LB_ERRSPACE if
|
||||
// insufficient space is available to store the new string.
|
||||
//
|
||||
// Parameters : nIndex - Specifies the zero-based index of the position
|
||||
// to insert the string. If this parameter is –1, the string
|
||||
// is added to the end of the list.
|
||||
// lpszItem - Points to the null-terminated string that
|
||||
// is to be inserted.
|
||||
// rgb - Specifies the color to be associated with the item.
|
||||
//
|
||||
// Remarks : Inserts a colored string into the list box.
|
||||
//
|
||||
{
|
||||
int nItem = ((CListBox*)this)->InsertString(nIndex,lpszItem);
|
||||
if (nItem >= 0)
|
||||
SetItemData(nItem, rgb);
|
||||
return nItem;
|
||||
} // InsertString
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
void CColorListBox::SetItemColor(int nIndex, COLORREF rgb)
|
||||
//
|
||||
// Return Value: None.
|
||||
//
|
||||
// Parameters : nIndex - Specifies the zero-based index of the item.
|
||||
// rgb - Specifies the color to be associated with the item.
|
||||
//
|
||||
// Remarks : Sets the 32-bit value associated with the specified
|
||||
// item in the list box.
|
||||
//
|
||||
{
|
||||
SetItemData(nIndex, rgb);
|
||||
RedrawWindow();
|
||||
} // SetItemColor
|
||||
@@ -1,65 +0,0 @@
|
||||
#if !defined(AFX_COLORLISTBOX_H__5529A6B1_584A_11D2_A41A_006097BD277B__INCLUDED_)
|
||||
#define AFX_COLORLISTBOX_H__5529A6B1_584A_11D2_A41A_006097BD277B__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
// ColorListBox.h : header file
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
// CColorListBox class -
|
||||
// A CListBox-derived class with optional colored items.
|
||||
//
|
||||
// Version: 1.0 01/10/1998 Copyright © Patrice Godard
|
||||
//
|
||||
// Version: 2.0 09/17/1999 Copyright © Paul M. Meidinger
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CColorListBox window
|
||||
|
||||
class CColorListBox : public CListBox
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CColorListBox();
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
int AddString(LPCTSTR lpszItem); // Adds a string to the list box
|
||||
int AddString(LPCTSTR lpszItem, COLORREF rgb); // Adds a colored string to the list box
|
||||
int InsertString(int nIndex, LPCTSTR lpszItem); // Inserts a string to the list box
|
||||
int InsertString(int nIndex, LPCTSTR lpszItem, COLORREF rgb); // Inserts a colored string to the list box
|
||||
void SetItemColor(int nIndex, COLORREF rgb); // Sets the color of an item in the list box
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CColorListBox)
|
||||
public:
|
||||
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
|
||||
virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CColorListBox();
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CColorListBox)
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_COLORLISTBOX_H__5529A6B1_584A_11D2_A41A_006097BD277B__INCLUDED_)
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "smpackage.h"
|
||||
#include "EditMetricsDlg.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
@@ -19,7 +20,6 @@ EditMetricsDlg::EditMetricsDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(EditMetricsDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(EditMetricsDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
@@ -28,19 +28,89 @@ void EditMetricsDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(EditMetricsDlg)
|
||||
DDX_Control(pDX, IDC_LIST_NAME, m_listName);
|
||||
DDX_Control(pDX, IDC_LIST_CLASS, m_listClass);
|
||||
DDX_Control(pDX, IDC_EDIT_VALUE, m_editValue);
|
||||
DDX_Control(pDX, IDC_EDIT_DEFAULT, m_editDefault);
|
||||
DDX_Control(pDX, IDC_BUTTON_REMOVE, m_buttonRemove);
|
||||
DDX_Control(pDX, IDC_BUTTON_OVERRIDE, m_buttonOverride);
|
||||
DDX_Control(pDX, IDC_BUTTON_NEW, m_buttonNew);
|
||||
DDX_Control(pDX, IDC_TREE, m_tree);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(EditMetricsDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(EditMetricsDlg)
|
||||
// NOTE: the ClassWizard will add message map macros here
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// EditMetricsDlg message handlers
|
||||
|
||||
BOOL EditMetricsDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: Add extra initialization here
|
||||
|
||||
RefreshTree();
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
IniFile iniBase;
|
||||
IniFile iniTheme;
|
||||
|
||||
unsigned long GetColor( bool bInBase, bool bInTheme )
|
||||
{
|
||||
if( bInBase && bInTheme )
|
||||
return RGB(0,0,0);
|
||||
else if( bInBase && !bInTheme )
|
||||
return RGB(127,127,127);
|
||||
else if( !bInBase && bInTheme )
|
||||
return RGB(255,0,0);
|
||||
else
|
||||
ASSERT(0);
|
||||
return RGB(0,0,0);
|
||||
}
|
||||
|
||||
void EditMetricsDlg::RefreshTree()
|
||||
{
|
||||
m_tree.DeleteAllItems();
|
||||
|
||||
iniBase.Reset();
|
||||
iniBase.SetPath( "Themes\\default\\metrics.ini" );
|
||||
iniBase.ReadFile();
|
||||
|
||||
iniTheme.Reset();
|
||||
iniTheme.SetPath( "Themes\\"+m_sTheme+"\\metrics.ini" );
|
||||
iniTheme.ReadFile();
|
||||
|
||||
IniFile iniCombined;
|
||||
iniCombined.SetPath( "Themes\\default\\metrics.ini" );
|
||||
iniCombined.ReadFile();
|
||||
iniCombined.SetPath( "Themes\\"+m_sTheme+"\\metrics.ini" );
|
||||
iniCombined.ReadFile();
|
||||
|
||||
for( int i=0; i<iniCombined.names.GetSize(); i++ )
|
||||
{
|
||||
CString sKey = iniCombined.names[i];
|
||||
bool bInBase = iniBase.FindKey(sKey) != -1;
|
||||
bool bInTheme = iniTheme.FindKey(sKey) != -1;
|
||||
|
||||
HTREEITEM item1 = m_tree.InsertItem( sKey );
|
||||
m_tree.SetItemColor( item1, GetColor(bInBase,bInTheme) );
|
||||
|
||||
IniFile::key &key = iniCombined.keys[i];
|
||||
for( POSITION pos=key.GetStartPosition(); pos != NULL; )
|
||||
{
|
||||
CString sName, sValue;
|
||||
key.GetNextAssoc( pos, sName, sValue );
|
||||
|
||||
CString sThrowAway;
|
||||
bool bInBase = !!iniBase.GetValue( sKey, sName, sThrowAway );
|
||||
bool bInTheme = !!iniTheme.GetValue( sKey, sName, sThrowAway );
|
||||
|
||||
HTREEITEM item2 = m_tree.InsertItem( sName, item1 );
|
||||
m_tree.SetItemColor( item2, GetColor(bInBase,bInTheme) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// EditMetricsDlg.h : header file
|
||||
//
|
||||
|
||||
#include "ColorListBox.h"
|
||||
#include "TreeCtrlEx.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// EditMetricsDlg dialog
|
||||
@@ -21,10 +21,10 @@ public:
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(EditMetricsDlg)
|
||||
enum { IDD = IDD_EDIT_METRICS };
|
||||
CColorListBox m_listName;
|
||||
CColorListBox m_listClass;
|
||||
CEdit m_editValue;
|
||||
CEdit m_editDefault;
|
||||
CButton m_buttonRemove;
|
||||
CButton m_buttonOverride;
|
||||
CButton m_buttonNew;
|
||||
CTreeCtrlEx m_tree;
|
||||
//}}AFX_DATA
|
||||
|
||||
CString m_sTheme;
|
||||
@@ -41,9 +41,11 @@ protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(EditMetricsDlg)
|
||||
// NOTE: the ClassWizard will add member functions here
|
||||
virtual BOOL OnInitDialog();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
void RefreshTree();
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
|
||||
@@ -150,6 +150,26 @@ int IniFile::GetNumValues(CString keyname)
|
||||
return keys[keynum].GetCount();
|
||||
}
|
||||
|
||||
//gets value of [keyname] valuename =
|
||||
//overloaded to return CString, int, and double
|
||||
BOOL IniFile::GetValue(CString keyname, CString valuename, CString value_out)
|
||||
{
|
||||
int keynum = FindKey(keyname);//, valuenum = FindValue(keynum,valuename);
|
||||
if( keynum == -1 )
|
||||
{
|
||||
error = "Unable to locate specified key.";
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CMapStringToString &map = keys[keynum];
|
||||
if( !map.Lookup(valuename, value_out) )
|
||||
{
|
||||
error = "Unable to locate specified value.";
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//gets value of [keyname] valuename =
|
||||
//overloaded to return CString, int, and double
|
||||
CString IniFile::GetValue(CString keyname, CString valuename)
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
|
||||
|
||||
//all private functions
|
||||
private:
|
||||
//private:
|
||||
|
||||
//returns index of specified key, or -1 if not found
|
||||
int FindKey(CString keyname);
|
||||
@@ -86,6 +86,7 @@ public:
|
||||
//gets value of [keyname] valuename =
|
||||
//overloaded to return CString, int, and double,
|
||||
//returns "", or 0 if key/value not found. Sets error member to show problem
|
||||
BOOL GetValue(CString keyname, CString valuename, CString value_out);
|
||||
CString GetValue(CString keyname, CString valuename);
|
||||
int GetValueI(CString keyname, CString valuename);
|
||||
double GetValueF(CString keyname, CString valuename);
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Author: Sami (M.ALSAMSAM), ittiger@ittiger.net
|
||||
//
|
||||
// Filename: TreeCtrlEx.cpp
|
||||
//
|
||||
// http : www.ittiger.net
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
#include "stdafx.h"
|
||||
#include "TreeCtrlEx.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
//////////////////////////////////
|
||||
CTreeCtrlEx::CTreeCtrlEx()
|
||||
{
|
||||
}
|
||||
|
||||
CTreeCtrlEx::~CTreeCtrlEx()
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
IMPLEMENT_DYNAMIC(CTreeCtrlEx, CTreeCtrl)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CTreeCtrlEx, CTreeCtrl)
|
||||
//{{AFX_MSG_MAP(CTreeCtrlEx)
|
||||
ON_WM_PAINT()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
void CTreeCtrlEx::SetItemFont(HTREEITEM hItem, LOGFONT& logfont)
|
||||
{
|
||||
Color_Font cf;
|
||||
if( !m_mapColorFont.Lookup( hItem, cf ) )
|
||||
cf.color = (COLORREF)-1;
|
||||
cf.logfont = logfont;
|
||||
m_mapColorFont[hItem] = cf;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
void CTreeCtrlEx::SetItemBold(HTREEITEM hItem, BOOL bBold)
|
||||
{
|
||||
SetItemState(hItem, bBold ? TVIS_BOLD: 0, TVIS_BOLD);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
void CTreeCtrlEx::SetItemColor(HTREEITEM hItem, COLORREF color)
|
||||
{
|
||||
Color_Font cf;
|
||||
if(!m_mapColorFont.Lookup(hItem, cf))
|
||||
cf.logfont.lfFaceName[0] = '\0';
|
||||
cf.color = color;
|
||||
m_mapColorFont[hItem] = cf;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
BOOL CTreeCtrlEx::GetItemFont(HTREEITEM hItem, LOGFONT * plogfont)
|
||||
{
|
||||
Color_Font cf;
|
||||
if(!m_mapColorFont.Lookup(hItem, cf))
|
||||
return FALSE;
|
||||
if(cf.logfont.lfFaceName[0] == '\0')
|
||||
return FALSE;
|
||||
*plogfont = cf.logfont;
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
BOOL CTreeCtrlEx::GetItemBold(HTREEITEM hItem)
|
||||
{
|
||||
return GetItemState(hItem, TVIS_BOLD) & TVIS_BOLD;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
COLORREF CTreeCtrlEx::GetItemColor(HTREEITEM hItem)
|
||||
{
|
||||
// Returns (COLORREF)-1 if color was not set
|
||||
Color_Font cf;
|
||||
if(!m_mapColorFont.Lookup(hItem, cf))
|
||||
return (COLORREF) - 1;
|
||||
return cf.color;
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
void CTreeCtrlEx::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this);
|
||||
|
||||
// Create a memory DC compatible with the paint DC
|
||||
CDC memDC;
|
||||
memDC.CreateCompatibleDC(&dc);
|
||||
|
||||
CRect rcClip, rcClient;
|
||||
dc.GetClipBox( &rcClip );
|
||||
GetClientRect(&rcClient);
|
||||
|
||||
// Select a compatible bitmap into the memory DC
|
||||
CBitmap bitmap;
|
||||
bitmap.CreateCompatibleBitmap( &dc, rcClient.Width(), rcClient.Height() );
|
||||
memDC.SelectObject( &bitmap );
|
||||
|
||||
// Set clip region to be same as that in paint DC
|
||||
CRgn rgn;
|
||||
rgn.CreateRectRgnIndirect( &rcClip );
|
||||
memDC.SelectClipRgn(&rgn);
|
||||
rgn.DeleteObject();
|
||||
|
||||
// First let the control do its default drawing.
|
||||
CWnd::DefWindowProc(WM_PAINT, (WPARAM)memDC.m_hDC, 0);
|
||||
|
||||
HTREEITEM hItem = GetFirstVisibleItem();
|
||||
|
||||
int iItemCount = GetVisibleCount() + 1;
|
||||
while(hItem && iItemCount--)
|
||||
{
|
||||
CRect rect;
|
||||
|
||||
// Do not meddle with selected items or drop highlighted items
|
||||
UINT selflag = TVIS_DROPHILITED | TVIS_SELECTED;
|
||||
Color_Font cf;
|
||||
|
||||
//if ( !(GetTreeCtrl().GetItemState( hItem, selflag ) & selflag )
|
||||
// && m_mapColorFont.Lookup( hItem, cf ))
|
||||
|
||||
if ((GetItemState(hItem, selflag) & selflag)
|
||||
&& ::GetFocus() == m_hWnd)
|
||||
;
|
||||
else if (m_mapColorFont.Lookup(hItem, cf))
|
||||
{
|
||||
CFont *pFontDC;
|
||||
CFont fontDC;
|
||||
LOGFONT logfont;
|
||||
|
||||
if(cf.logfont.lfFaceName[0] != '\0')
|
||||
logfont = cf.logfont;
|
||||
else {
|
||||
// No font specified, so use window font
|
||||
CFont *pFont = GetFont();
|
||||
pFont->GetLogFont( &logfont );
|
||||
}
|
||||
|
||||
if(GetItemBold(hItem))
|
||||
logfont.lfWeight = 700;
|
||||
|
||||
fontDC.CreateFontIndirect(&logfont);
|
||||
pFontDC = memDC.SelectObject(&fontDC );
|
||||
|
||||
if(cf.color != (COLORREF) - 1)
|
||||
memDC.SetTextColor(cf.color);
|
||||
else
|
||||
memDC.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
|
||||
|
||||
|
||||
CString sItem = GetItemText(hItem);
|
||||
|
||||
GetItemRect(hItem, &rect, TRUE);
|
||||
memDC.SetBkColor( GetSysColor(COLOR_WINDOW));
|
||||
memDC.TextOut(rect.left + 2, rect.top + 1, sItem);
|
||||
|
||||
memDC.SelectObject(pFontDC);
|
||||
}
|
||||
hItem = GetNextVisibleItem(hItem);
|
||||
}
|
||||
|
||||
|
||||
dc.BitBlt(rcClip.left, rcClip.top, rcClip.Width(), rcClip.Height(), &memDC,
|
||||
rcClip.left, rcClip.top, SRCCOPY);
|
||||
|
||||
memDC.DeleteDC();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Author: Sami (M.ALSAMSAM), ittiger@ittiger.net
|
||||
//
|
||||
// Filename: TreeCtrlEx.h
|
||||
//
|
||||
// http : www.ittiger.net
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
#if !defined(AFX_TREECTRLEX_H__5D969ED4_7DEA_4FB5_8C1D_E12D1CCF0989__INCLUDED_)
|
||||
#define AFX_TREECTRLEX_H__5D969ED4_7DEA_4FB5_8C1D_E12D1CCF0989__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <afxtempl.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
class CTreeCtrlEx : public CTreeCtrl
|
||||
{
|
||||
DECLARE_DYNAMIC(CTreeCtrlEx)
|
||||
|
||||
public:
|
||||
CTreeCtrlEx();
|
||||
virtual ~CTreeCtrlEx();
|
||||
|
||||
void SetItemFont(HTREEITEM, LOGFONT&);
|
||||
void SetItemBold(HTREEITEM, BOOL);
|
||||
void SetItemColor(HTREEITEM, COLORREF);
|
||||
BOOL GetItemFont(HTREEITEM, LOGFONT *);
|
||||
BOOL GetItemBold(HTREEITEM);
|
||||
COLORREF GetItemColor(HTREEITEM);
|
||||
|
||||
protected:
|
||||
|
||||
struct Color_Font {
|
||||
COLORREF color;
|
||||
LOGFONT logfont;
|
||||
};
|
||||
|
||||
CMap <void*, void*, Color_Font, Color_Font&> m_mapColorFont;
|
||||
|
||||
protected:
|
||||
//{{AFX_MSG(CTreeCtrlEx)
|
||||
afx_msg void OnPaint();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_TREECTRLEX_H__5D969ED4_7DEA_4FB5_8C1D_E12D1CCF0989__INCLUDED_)
|
||||
@@ -42,11 +42,11 @@
|
||||
#define IDC_BUTTON_CONVERT 1024
|
||||
#define IDC_BUTTON_ANALYZE 1025
|
||||
#define IDC_BUTTON_EDIT_METRICS 1026
|
||||
#define IDC_LIST_CLASS 1026
|
||||
#define IDC_LIST_NAME 1027
|
||||
#define IDC_BUTTON_ANALYZE_METRICS 1027
|
||||
#define IDC_EDIT_VALUE 1028
|
||||
#define IDC_EDIT_DEFAULT 1029
|
||||
#define IDC_BUTTON_OVERRIDE 1037
|
||||
#define IDC_BUTTON_NEW 1039
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
@@ -54,7 +54,7 @@
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 147
|
||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||
#define _APS_NEXT_CONTROL_VALUE 1029
|
||||
#define _APS_NEXT_CONTROL_VALUE 1035
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[General Info]
|
||||
Version=1
|
||||
LastClass=ConvertThemeDlg
|
||||
LastClass=EditMetricsDlg
|
||||
LastTemplate=CDialog
|
||||
NewFileInclude1=#include "stdafx.h"
|
||||
NewFileInclude2=#include "smpackage.h"
|
||||
@@ -13,16 +13,16 @@ Class2=CSmpackageDlg
|
||||
|
||||
ResourceCount=8
|
||||
Resource1=IDR_MAINFRAME
|
||||
Resource2=IDD_EDIT_INSTALLATIONS
|
||||
Resource2=IDD_INSTALL
|
||||
Class3=CSMPackageInstallDlg
|
||||
Class4=CSmpackageExportDlg
|
||||
Resource3=IDD_INSTALL
|
||||
Resource3=IDD_EDIT_INSTALLATIONS
|
||||
Class5=EnterName
|
||||
Resource4=IDD_CONVERT_THEME
|
||||
Resource4=IDD_MENU
|
||||
Class6=EditInsallations
|
||||
Resource5=IDD_DIALOG_NAME
|
||||
Resource5=IDD_CONVERT_THEME
|
||||
Class7=MainMenuDlg
|
||||
Resource6=IDD_MENU
|
||||
Resource6=IDD_DIALOG_NAME
|
||||
Class8=ConvertThemeDlg
|
||||
Resource7=IDD_EXPORTER
|
||||
Class9=EditMetricsDlg
|
||||
@@ -166,21 +166,20 @@ LastObject=IDC_CONVERT_THEME
|
||||
[DLG:IDD_CONVERT_THEME]
|
||||
Type=1
|
||||
Class=ConvertThemeDlg
|
||||
ControlCount=14
|
||||
ControlCount=13
|
||||
Control1=IDOK,button,1342242817
|
||||
Control2=IDC_STATIC,static,1342177294
|
||||
Control3=IDC_LIST_THEMES,listbox,1352728835
|
||||
Control4=IDC_BUTTON_CONVERT,button,1476460544
|
||||
Control5=IDC_STATIC,static,1342308352
|
||||
Control6=IDC_STATIC,static,1342308352
|
||||
Control7=IDC_STATIC,button,1342177287
|
||||
Control8=IDC_STATIC,static,1342308352
|
||||
Control9=IDC_BUTTON_ANALYZE,button,1476460544
|
||||
Control10=IDC_STATIC,button,1342177287
|
||||
Control11=IDC_STATIC,static,1342308352
|
||||
Control12=IDC_BUTTON_EDIT_METRICS,button,1476460544
|
||||
Control13=IDC_STATIC,static,1342308352
|
||||
Control14=IDC_BUTTON_ANALYZE_METRICS,button,1476460544
|
||||
Control6=IDC_STATIC,button,1342177287
|
||||
Control7=IDC_STATIC,static,1342308352
|
||||
Control8=IDC_BUTTON_ANALYZE,button,1476460544
|
||||
Control9=IDC_STATIC,button,1342177287
|
||||
Control10=IDC_STATIC,static,1342308352
|
||||
Control11=IDC_BUTTON_EDIT_METRICS,button,1476460544
|
||||
Control12=IDC_STATIC,static,1342308352
|
||||
Control13=IDC_BUTTON_ANALYZE_METRICS,button,1476460544
|
||||
|
||||
[CLS:ConvertThemeDlg]
|
||||
Type=0
|
||||
@@ -194,17 +193,19 @@ VirtualFilter=dWC
|
||||
[DLG:IDD_EDIT_METRICS]
|
||||
Type=1
|
||||
Class=EditMetricsDlg
|
||||
ControlCount=10
|
||||
ControlCount=12
|
||||
Control1=IDOK,button,1342242817
|
||||
Control2=IDC_STATIC,static,1342177294
|
||||
Control3=IDC_LIST_CLASS,listbox,1352728835
|
||||
Control3=IDC_EDIT_VALUE,edit,1350631552
|
||||
Control4=IDC_STATIC,static,1342308352
|
||||
Control5=IDC_LIST_NAME,listbox,1352728835
|
||||
Control5=IDC_EDIT_DEFAULT,edit,1350633600
|
||||
Control6=IDC_STATIC,static,1342308352
|
||||
Control7=IDC_EDIT_VALUE,edit,1350631552
|
||||
Control8=IDC_STATIC,static,1342308352
|
||||
Control9=IDC_EDIT_DEFAULT,edit,1350633600
|
||||
Control10=IDC_STATIC,static,1342308352
|
||||
Control7=IDC_BUTTON_OVERRIDE,button,1342242816
|
||||
Control8=IDC_BUTTON_REMOVE,button,1342242816
|
||||
Control9=IDC_BUTTON_NEW,button,1342242816
|
||||
Control10=IDC_TREE,SysTreeView32,1350631461
|
||||
Control11=IDC_STATIC,static,1342308352
|
||||
Control12=IDC_STATIC,static,1342308352
|
||||
|
||||
[CLS:EditMetricsDlg]
|
||||
Type=0
|
||||
@@ -213,4 +214,5 @@ ImplementationFile=EditMetricsDlg.cpp
|
||||
BaseClass=CDialog
|
||||
Filter=D
|
||||
VirtualFilter=dWC
|
||||
LastObject=EditMetricsDlg
|
||||
|
||||
|
||||
@@ -88,14 +88,6 @@ LINK32=link.exe
|
||||
# Name "smpackage - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ColorListBox.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ColorListBox.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\converttheme.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -243,5 +235,13 @@ SOURCE=.\StdAfx.h
|
||||
|
||||
SOURCE=.\res\StepMania.ICO
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\TreeCtrlEx.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\TreeCtrlEx.h
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
|
||||
@@ -174,34 +174,32 @@ BEGIN
|
||||
IDC_STATIC,103,168,215,35
|
||||
END
|
||||
|
||||
IDD_CONVERT_THEME DIALOG DISCARDABLE 0, 0, 332, 282
|
||||
IDD_CONVERT_THEME DIALOG DISCARDABLE 0, 0, 332, 262
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Theme Elements"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Close",IDOK,275,261,50,14
|
||||
DEFPUSHBUTTON "Close",IDOK,275,241,50,14
|
||||
CONTROL 144,IDC_STATIC,"Static",SS_BITMAP,0,0,332,38
|
||||
LISTBOX IDC_LIST_THEMES,7,48,88,207,LBS_SORT |
|
||||
LISTBOX IDC_LIST_THEMES,7,44,88,192,LBS_SORT |
|
||||
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "Convert from 3.0 to 4.0",IDC_BUTTON_CONVERT,170,55,95,
|
||||
PUSHBUTTON "Convert from 3.0 to 4.0",IDC_BUTTON_CONVERT,170,51,95,
|
||||
15,WS_DISABLED
|
||||
LTEXT "This will convert the element names in a SM 3.0 theme to the SM 4.0 theme naming scheme. After converting a theme, it will no longer be compatible with StepMania 3.0. Be sure to make a backup if this is important to you.",
|
||||
IDC_STATIC,110,75,210,33
|
||||
LTEXT "This tool will not convert any theme metrics. You'll need to convert these by hand.",
|
||||
IDC_STATIC,110,113,210,18
|
||||
GROUPBOX "Elements",IDC_STATIC,105,45,220,122
|
||||
LTEXT "This will convert the element names in a SM 3.0 theme to the SM 4.0 theme naming scheme. After converting a theme, it will no longer be compatible with StepMania 3.0. Be sure to make a backup if this is important to you. (This tool will not convert theme metrics)",
|
||||
IDC_STATIC,110,71,210,40
|
||||
GROUPBOX "Elements",IDC_STATIC,105,41,220,106
|
||||
LTEXT "Check for redundant or possibly midnamed theme elements.",
|
||||
IDC_STATIC,110,155,210,10
|
||||
PUSHBUTTON "Analyze Elements",IDC_BUTTON_ANALYZE,165,135,95,15,
|
||||
IDC_STATIC,110,135,210,10
|
||||
PUSHBUTTON "Analyze Elements",IDC_BUTTON_ANALYZE,165,115,95,15,
|
||||
WS_DISABLED
|
||||
GROUPBOX "Metrics",IDC_STATIC,105,172,220,83
|
||||
GROUPBOX "Metrics",IDC_STATIC,105,153,220,83
|
||||
LTEXT "Edit theme metrics with a user-friendly interface.",
|
||||
IDC_STATIC,110,202,210,10
|
||||
PUSHBUTTON "Edit Metrics",IDC_BUTTON_EDIT_METRICS,165,182,95,15,
|
||||
IDC_STATIC,110,183,210,10
|
||||
PUSHBUTTON "Edit Metrics",IDC_BUTTON_EDIT_METRICS,165,163,95,15,
|
||||
WS_DISABLED
|
||||
LTEXT "Check for redundant or possibly midnamed theme metrics.",
|
||||
IDC_STATIC,109,242,210,10
|
||||
PUSHBUTTON "Analyze Metrics",IDC_BUTTON_ANALYZE_METRICS,165,222,95,
|
||||
IDC_STATIC,109,223,210,10
|
||||
PUSHBUTTON "Analyze Metrics",IDC_BUTTON_ANALYZE_METRICS,165,203,95,
|
||||
15,WS_DISABLED
|
||||
END
|
||||
|
||||
@@ -212,17 +210,21 @@ FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Close",IDOK,275,213,50,14
|
||||
CONTROL 146,IDC_STATIC,"Static",SS_BITMAP,0,0,332,38
|
||||
LISTBOX IDC_LIST_CLASS,7,57,94,170,LBS_SORT |
|
||||
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Class",IDC_STATIC,7,47,88,9
|
||||
LISTBOX IDC_LIST_NAME,106,57,107,170,LBS_SORT |
|
||||
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Name",IDC_STATIC,106,47,88,9
|
||||
EDITTEXT IDC_EDIT_VALUE,217,58,108,46,ES_AUTOHSCROLL
|
||||
LTEXT "Value",IDC_STATIC,218,47,88,9
|
||||
EDITTEXT IDC_EDIT_DEFAULT,217,119,108,48,ES_AUTOHSCROLL |
|
||||
EDITTEXT IDC_EDIT_VALUE,217,116,108,38,ES_AUTOHSCROLL
|
||||
LTEXT "Value",IDC_STATIC,218,105,88,9
|
||||
EDITTEXT IDC_EDIT_DEFAULT,217,170,108,40,ES_AUTOHSCROLL |
|
||||
ES_READONLY
|
||||
LTEXT "Default Value",IDC_STATIC,218,108,88,9
|
||||
LTEXT "Default Value",IDC_STATIC,218,159,88,9
|
||||
PUSHBUTTON "Override",IDC_BUTTON_OVERRIDE,217,45,60,14
|
||||
PUSHBUTTON "Remove Override",IDC_BUTTON_REMOVE,217,63,60,14
|
||||
PUSHBUTTON "New Metric",IDC_BUTTON_NEW,217,81,60,14
|
||||
CONTROL "Tree1",IDC_TREE,"SysTreeView32",TVS_HASBUTTONS |
|
||||
TVS_LINESATROOT | TVS_SHOWSELALWAYS | WS_BORDER |
|
||||
WS_TABSTOP,91,44,119,165
|
||||
LTEXT "Help:\n\nGray = A metric that is not overridden by the current theme (exists in the base theme but not in the current theme)",
|
||||
IDC_STATIC,7,43,79,62
|
||||
LTEXT "Black = A metric that is overridden by the current theme (exists in both the base theme, and the current theme)\n\nRed = A metric that exists in the current theme but not in the base theme (check to see if the metric name is misspelled)",
|
||||
IDC_STATIC,7,106,78,103
|
||||
END
|
||||
|
||||
|
||||
@@ -322,7 +324,7 @@ BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 325
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 275
|
||||
BOTTOMMARGIN, 255
|
||||
END
|
||||
|
||||
IDD_EDIT_METRICS, DIALOG
|
||||
|
||||
Reference in New Issue
Block a user