mirror of https://github.com/stella-emu/stella.git
Added the ability to sort (in alphabetical order) by Name, Manufacturer
or Rarity columns in the game listview. The currently selected sort column is also saved, and then used when StellaX starts again. The current width of columns is also saved, and reused when StellaX starts again. Still TODO is get the titlebar close button to 'hook' into the MainDlg::Quit() method, so that it works the same way as pressing the 'Exit' button or pressing 'Alt-F4'. Right now, pressing the close button in the titlebar bypasses the Quit() method, and AFAICT also the freeing of any memory. This bug seems to have been present in StellaX since the beginning. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@304 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
eda901519b
commit
1a82add67b
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: SettingsWin32.cxx,v 1.8 2004-07-05 00:53:48 stephena Exp $
|
// $Id: SettingsWin32.cxx,v 1.9 2004-07-11 22:04:21 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -62,6 +62,13 @@ SettingsWin32::SettingsWin32()
|
||||||
#ifdef SNAPSHOT_SUPPORT
|
#ifdef SNAPSHOT_SUPPORT
|
||||||
set("ssdir", ".\\");
|
set("ssdir", ".\\");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// These settings are for the StellaX frontend
|
||||||
|
// If you don't use StellaX, the following settings are ignored
|
||||||
|
set("sortcol", "0");
|
||||||
|
set("namecolwidth", "0");
|
||||||
|
set("manufacturercolwidth", "0");
|
||||||
|
set("raritycolwidth", "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -2,24 +2,17 @@
|
||||||
// StellaX
|
// StellaX
|
||||||
// Jeff Miller 05/01/2000
|
// Jeff Miller 05/01/2000
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "pch.hxx"
|
#include "pch.hxx"
|
||||||
#include "HeaderCtrl.hxx"
|
#include "HeaderCtrl.hxx"
|
||||||
|
|
||||||
CHeaderCtrl::CHeaderCtrl(
|
CHeaderCtrl::CHeaderCtrl()
|
||||||
) : \
|
: m_nSortCol(0),
|
||||||
m_nSortCol(0),
|
|
||||||
m_fSortAsc(TRUE)
|
m_fSortAsc(TRUE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LRESULT CHeaderCtrl::WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL& rfHandled )
|
||||||
LRESULT CHeaderCtrl::WndProc(
|
|
||||||
HWND hWnd,
|
|
||||||
UINT msg,
|
|
||||||
WPARAM wParam,
|
|
||||||
LPARAM lParam,
|
|
||||||
BOOL& rfHandled
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
switch ( msg )
|
switch ( msg )
|
||||||
{
|
{
|
||||||
|
@ -32,18 +25,13 @@ LRESULT CHeaderCtrl::WndProc(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHeaderCtrl::SetSortCol(
|
void CHeaderCtrl::SetSortCol( int nCol, BOOL bAsc )
|
||||||
int nCol,
|
|
||||||
BOOL bAsc
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
m_nSortCol = nCol;
|
m_nSortCol = nCol;
|
||||||
m_fSortAsc = bAsc;
|
m_fSortAsc = bAsc;
|
||||||
|
|
||||||
// change this item to owner draw
|
// change this item to owner draw
|
||||||
|
|
||||||
HWND hwndHeader = ::GetDlgItem( *this, 0 );
|
HWND hwndHeader = ::GetDlgItem( *this, 0 );
|
||||||
|
|
||||||
HDITEM hdi;
|
HDITEM hdi;
|
||||||
hdi.mask = HDI_FORMAT;
|
hdi.mask = HDI_FORMAT;
|
||||||
Header_GetItem(hwndHeader, nCol, &hdi);
|
Header_GetItem(hwndHeader, nCol, &hdi);
|
||||||
|
@ -51,45 +39,34 @@ void CHeaderCtrl::SetSortCol(
|
||||||
Header_SetItem(hwndHeader, nCol, &hdi);
|
Header_SetItem(hwndHeader, nCol, &hdi);
|
||||||
|
|
||||||
// repaint the header
|
// repaint the header
|
||||||
|
InvalidateRect(hwndHeader, NULL, TRUE);
|
||||||
::InvalidateRect(hwndHeader, NULL, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHeaderCtrl::OnDrawItem(
|
void CHeaderCtrl::OnDrawItem( HWND hwnd, UINT idCtl, LPDRAWITEMSTRUCT lpdis )
|
||||||
HWND hwnd,
|
|
||||||
UINT idCtl,
|
|
||||||
LPDRAWITEMSTRUCT lpdis
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNUSED_ALWAYS( idCtl );
|
UNUSED_ALWAYS( idCtl );
|
||||||
|
|
||||||
HDC hdc = lpdis->hDC;
|
HDC hdc = lpdis->hDC;
|
||||||
|
|
||||||
RECT rcLabel;
|
RECT rcLabel;
|
||||||
::CopyRect( &rcLabel, &(lpdis->rcItem) );
|
|
||||||
|
CopyRect( &rcLabel, &(lpdis->rcItem) );
|
||||||
|
|
||||||
/* save the DC */
|
/* save the DC */
|
||||||
|
|
||||||
int nSavedDC = ::SaveDC( hdc );
|
int nSavedDC = ::SaveDC( hdc );
|
||||||
|
|
||||||
/* set clip region to column */
|
/* set clip region to column */
|
||||||
|
|
||||||
HRGN hrgn = ::CreateRectRgnIndirect( &rcLabel );
|
HRGN hrgn = ::CreateRectRgnIndirect( &rcLabel );
|
||||||
SelectObject( hdc, hrgn );
|
SelectObject( hdc, hrgn );
|
||||||
DeleteObject( hrgn );
|
DeleteObject( hrgn );
|
||||||
|
|
||||||
/* draw the background */
|
/* draw the background */
|
||||||
|
FillRect( hdc, &rcLabel, ::GetSysColorBrush(COLOR_3DFACE) );
|
||||||
::FillRect( hdc, &rcLabel, ::GetSysColorBrush(COLOR_3DFACE) );
|
|
||||||
|
|
||||||
/* offset the label */
|
/* offset the label */
|
||||||
|
|
||||||
SIZE size;
|
SIZE size;
|
||||||
::GetTextExtentPoint32( hdc, _T(" "), 1, &size );
|
GetTextExtentPoint32( hdc, _T(" "), 1, &size );
|
||||||
int nOffset = size.cx * 2;
|
int nOffset = size.cx * 2;
|
||||||
|
|
||||||
/* get the column text and format */
|
/* get the column text and format */
|
||||||
|
|
||||||
TCHAR tszText[255 + 1];
|
TCHAR tszText[255 + 1];
|
||||||
HDITEM hdi;
|
HDITEM hdi;
|
||||||
hdi.mask = HDI_TEXT | HDI_FORMAT;
|
hdi.mask = HDI_TEXT | HDI_FORMAT;
|
||||||
|
@ -98,27 +75,17 @@ void CHeaderCtrl::OnDrawItem(
|
||||||
Header_GetItem( GetDlgItem(hwnd, 0), lpdis->itemID, &hdi );
|
Header_GetItem( GetDlgItem(hwnd, 0), lpdis->itemID, &hdi );
|
||||||
|
|
||||||
/* determine format for drawing label */
|
/* determine format for drawing label */
|
||||||
|
UINT uFormat = DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER | DT_END_ELLIPSIS;
|
||||||
UINT uFormat = DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP |
|
|
||||||
DT_VCENTER | DT_END_ELLIPSIS;
|
|
||||||
|
|
||||||
/* determine justification */
|
/* determine justification */
|
||||||
|
|
||||||
if (hdi.fmt & HDF_CENTER)
|
if (hdi.fmt & HDF_CENTER)
|
||||||
{
|
|
||||||
uFormat |= DT_CENTER;
|
uFormat |= DT_CENTER;
|
||||||
}
|
|
||||||
else if (hdi.fmt & HDF_RIGHT)
|
else if (hdi.fmt & HDF_RIGHT)
|
||||||
{
|
|
||||||
uFormat |= DT_RIGHT;
|
uFormat |= DT_RIGHT;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
uFormat |= DT_LEFT;
|
uFormat |= DT_LEFT;
|
||||||
}
|
|
||||||
|
|
||||||
/* adjust the rect if selected */
|
/* adjust the rect if selected */
|
||||||
|
|
||||||
if (lpdis->itemState & ODS_SELECTED)
|
if (lpdis->itemState & ODS_SELECTED)
|
||||||
{
|
{
|
||||||
rcLabel.left++;
|
rcLabel.left++;
|
||||||
|
@ -127,30 +94,23 @@ void CHeaderCtrl::OnDrawItem(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* adjust rect for sort arrow */
|
/* adjust rect for sort arrow */
|
||||||
|
|
||||||
if ( lpdis->itemID == m_nSortCol )
|
if ( lpdis->itemID == m_nSortCol )
|
||||||
{
|
|
||||||
rcLabel.right -= (3 * nOffset);
|
rcLabel.right -= (3 * nOffset);
|
||||||
}
|
|
||||||
|
|
||||||
rcLabel.left += nOffset;
|
rcLabel.left += nOffset;
|
||||||
rcLabel.right -= nOffset;
|
rcLabel.right -= nOffset;
|
||||||
|
|
||||||
/* draw label */
|
/* draw label */
|
||||||
|
|
||||||
if ( rcLabel.left < rcLabel.right )
|
if ( rcLabel.left < rcLabel.right )
|
||||||
{
|
DrawText(hdc, tszText, -1, &rcLabel, uFormat );
|
||||||
::DrawText(hdc, tszText, -1, &rcLabel, uFormat );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* draw the arrow */
|
/* draw the arrow */
|
||||||
|
|
||||||
if ( lpdis->itemID == m_nSortCol )
|
if ( lpdis->itemID == m_nSortCol )
|
||||||
{
|
{
|
||||||
RECT rcIcon;
|
RECT rcIcon;
|
||||||
HPEN hpenLight, hpenShadow, hpenOld;
|
HPEN hpenLight, hpenShadow, hpenOld;
|
||||||
|
|
||||||
::CopyRect( &rcIcon, &(lpdis->rcItem) );
|
CopyRect( &rcIcon, &(lpdis->rcItem) );
|
||||||
|
|
||||||
hpenLight = ::CreatePen( PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT) );
|
hpenLight = ::CreatePen( PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT) );
|
||||||
hpenShadow = ::CreatePen( PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW) );
|
hpenShadow = ::CreatePen( PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW) );
|
||||||
|
@ -159,42 +119,31 @@ void CHeaderCtrl::OnDrawItem(
|
||||||
if (m_fSortAsc)
|
if (m_fSortAsc)
|
||||||
{
|
{
|
||||||
/* draw triangle pointing up */
|
/* draw triangle pointing up */
|
||||||
|
MoveToEx( hdc, rcIcon.right - 2 * nOffset, nOffset - 1, NULL );
|
||||||
|
LineTo( hdc, rcIcon.right - 3 * nOffset / 2, rcIcon.bottom - nOffset );
|
||||||
|
LineTo( hdc, rcIcon.right - 5 * nOffset / 2 - 2, rcIcon.bottom - nOffset );
|
||||||
|
MoveToEx( hdc, rcIcon.right - 5 * nOffset / 2 - 1, rcIcon.bottom - nOffset, NULL );
|
||||||
|
|
||||||
::MoveToEx( hdc, rcIcon.right - 2 * nOffset, nOffset - 1, NULL );
|
SelectObject( hdc, hpenShadow );
|
||||||
::LineTo( hdc, rcIcon.right - 3 * nOffset / 2,
|
LineTo( hdc, rcIcon.right - 2 * nOffset, nOffset - 2 );
|
||||||
rcIcon.bottom - nOffset );
|
|
||||||
::LineTo( hdc, rcIcon.right - 5 * nOffset / 2 - 2,
|
|
||||||
rcIcon.bottom - nOffset );
|
|
||||||
::MoveToEx( hdc, rcIcon.right - 5 * nOffset / 2 - 1,
|
|
||||||
rcIcon.bottom - nOffset, NULL );
|
|
||||||
|
|
||||||
::SelectObject( hdc, hpenShadow );
|
|
||||||
::LineTo( hdc, rcIcon.right - 2 * nOffset, nOffset - 2 );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* draw triangle pointing down */
|
/* draw triangle pointing down */
|
||||||
|
MoveToEx( hdc, rcIcon.right - 3 * nOffset / 2, nOffset - 1, NULL );
|
||||||
|
LineTo( hdc, rcIcon.right - 2 * nOffset - 1, rcIcon.bottom - nOffset );
|
||||||
|
LineTo( hdc, rcIcon.right - 2 * nOffset - 1, rcIcon.bottom - nOffset );
|
||||||
|
MoveToEx( hdc, rcIcon.right - 2 * nOffset - 1, rcIcon.bottom - nOffset, NULL );
|
||||||
|
|
||||||
::MoveToEx( hdc, rcIcon.right - 3 * nOffset / 2, nOffset - 1,
|
SelectObject( hdc, hpenShadow );
|
||||||
NULL );
|
LineTo( hdc, rcIcon.right - 5 * nOffset / 2 - 1, nOffset - 1 );
|
||||||
::LineTo( hdc, rcIcon.right - 2 * nOffset - 1,
|
LineTo( hdc, rcIcon.right - 3 * nOffset / 2, nOffset - 1 );
|
||||||
rcIcon.bottom - nOffset );
|
|
||||||
::LineTo( hdc, rcIcon.right - 2 * nOffset - 1,
|
|
||||||
rcIcon.bottom - nOffset );
|
|
||||||
::MoveToEx( hdc, rcIcon.right - 2 * nOffset - 1,
|
|
||||||
rcIcon.bottom - nOffset, NULL );
|
|
||||||
|
|
||||||
::SelectObject( hdc, hpenShadow );
|
|
||||||
::LineTo( hdc, rcIcon.right - 5 * nOffset / 2 - 1,
|
|
||||||
nOffset - 1 );
|
|
||||||
::LineTo( hdc, rcIcon.right - 3 * nOffset / 2,
|
|
||||||
nOffset - 1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
::SelectObject( hdc, hpenOld );
|
SelectObject( hdc, hpenOld );
|
||||||
::DeleteObject( hpenShadow );
|
DeleteObject( hpenShadow );
|
||||||
::DeleteObject( hpenLight );
|
DeleteObject( hpenLight );
|
||||||
}
|
}
|
||||||
|
|
||||||
::RestoreDC( hdc, nSavedDC );
|
RestoreDC( hdc, nSavedDC );
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,27 +4,22 @@
|
||||||
//
|
//
|
||||||
#ifndef HDRCTL_H
|
#ifndef HDRCTL_H
|
||||||
#define HDRCTL_H
|
#define HDRCTL_H
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Wnd.hxx"
|
#include "Wnd.hxx"
|
||||||
|
|
||||||
class CHeaderCtrl : public CWnd
|
class CHeaderCtrl : public CWnd
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CHeaderCtrl();
|
CHeaderCtrl();
|
||||||
|
|
||||||
void SetSortCol(int nCol, BOOL fAscending);
|
void SetSortCol(int col, BOOL fAscending);
|
||||||
int GetSortCol(void) const;
|
int GetSortCol(void) const;
|
||||||
BOOL GetSortAsc(void) const;
|
BOOL GetSortAsc(void) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
LRESULT WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL& rfHandled);
|
||||||
LRESULT WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
|
|
||||||
BOOL& rfHandled);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void OnDrawItem(HWND hwnd, UINT idCtl, LPDRAWITEMSTRUCT lpdis);
|
void OnDrawItem(HWND hwnd, UINT idCtl, LPDRAWITEMSTRUCT lpdis);
|
||||||
|
|
||||||
UINT m_nSortCol;
|
UINT m_nSortCol;
|
||||||
|
@ -32,21 +27,14 @@ private:
|
||||||
|
|
||||||
CHeaderCtrl( const CHeaderCtrl& ); // no implementation
|
CHeaderCtrl( const CHeaderCtrl& ); // no implementation
|
||||||
void operator=( const CHeaderCtrl& ); // no implementation
|
void operator=( const CHeaderCtrl& ); // no implementation
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline int CHeaderCtrl::GetSortCol
|
inline int CHeaderCtrl::GetSortCol( void ) const
|
||||||
(
|
|
||||||
void
|
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
return m_nSortCol;
|
return m_nSortCol;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BOOL CHeaderCtrl::GetSortAsc
|
inline BOOL CHeaderCtrl::GetSortAsc( void ) const
|
||||||
(
|
|
||||||
void
|
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
return m_fSortAsc;
|
return m_fSortAsc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: MainDlg.cxx,v 1.4 2004-07-10 22:25:58 stephena Exp $
|
// $Id: MainDlg.cxx,v 1.5 2004-07-11 22:04:22 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include "pch.hxx"
|
#include "pch.hxx"
|
||||||
|
@ -35,14 +35,21 @@
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
MainDlg::MainDlg( CGlobalData& rGlobalData, HINSTANCE hInstance )
|
MainDlg::MainDlg( CGlobalData& rGlobalData, HINSTANCE hInstance )
|
||||||
: myGlobalData(rGlobalData),
|
: myGlobalData(rGlobalData),
|
||||||
m_hInstance(hInstance)
|
myHInstance(hInstance)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
MainDlg::~MainDlg( void )
|
||||||
|
{
|
||||||
|
// Just to be safe, make sure we don't have a memory leak
|
||||||
|
ListView_Clear();
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
int MainDlg::DoModal( HWND hwndParent )
|
int MainDlg::DoModal( HWND hwndParent )
|
||||||
{
|
{
|
||||||
return DialogBoxParam( m_hInstance,
|
return DialogBoxParam( myHInstance,
|
||||||
MAKEINTRESOURCE(IDD),
|
MAKEINTRESOURCE(IDD),
|
||||||
hwndParent,
|
hwndParent,
|
||||||
StaticDialogFunc,
|
StaticDialogFunc,
|
||||||
|
@ -138,7 +145,7 @@ MainDlg::DialogFunc( UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||||
case WM_SYSCOMMAND:
|
case WM_SYSCOMMAND:
|
||||||
// Allow Alt-F4 to close the window
|
// Allow Alt-F4 to close the window
|
||||||
if ( wParam == SC_CLOSE )
|
if ( wParam == SC_CLOSE )
|
||||||
::EndDialog( myHwnd, IDCANCEL );
|
Quit(myHwnd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +161,7 @@ BOOL MainDlg::OnInitDialog( void )
|
||||||
HWND hwnd = *this;
|
HWND hwnd = *this;
|
||||||
|
|
||||||
// Set dialog icon
|
// Set dialog icon
|
||||||
HICON hicon = ::LoadIcon(m_hInstance, MAKEINTRESOURCE(IDI_APP));
|
HICON hicon = ::LoadIcon(myHInstance, MAKEINTRESOURCE(IDI_APP));
|
||||||
::SendMessage( hwnd, WM_SETICON, ICON_BIG, (LPARAM)hicon );
|
::SendMessage( hwnd, WM_SETICON, ICON_BIG, (LPARAM)hicon );
|
||||||
::SendMessage( hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hicon );
|
::SendMessage( hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hicon );
|
||||||
|
|
||||||
|
@ -199,16 +206,24 @@ BOOL MainDlg::OnInitDialog( void )
|
||||||
int columnHeader[] = { IDS_NAME, IDS_MANUFACTURER, IDS_RARITY };
|
int columnHeader[] = { IDS_NAME, IDS_MANUFACTURER, IDS_RARITY };
|
||||||
|
|
||||||
// Set the column widths
|
// Set the column widths
|
||||||
LONG lTotalWidth = rc.right-rc.left - GetSystemMetrics(SM_CXVSCROLL);
|
|
||||||
int columnWidth[3];
|
int columnWidth[3];
|
||||||
|
columnWidth[0] = myGlobalData.settings().getInt("namecolwidth");
|
||||||
|
columnWidth[1] = myGlobalData.settings().getInt("manufacturercolwidth");
|
||||||
|
columnWidth[2] = myGlobalData.settings().getInt("raritycolwidth");
|
||||||
|
|
||||||
|
// Make sure there are sane values for the column widths
|
||||||
|
if (columnWidth[0] <= 0 || columnWidth[1] <= 0 || columnWidth[2] <= 0)
|
||||||
|
{
|
||||||
|
LONG lTotalWidth = rc.right-rc.left - GetSystemMetrics(SM_CXVSCROLL);
|
||||||
columnWidth[0] = (int) (0.58 * lTotalWidth);
|
columnWidth[0] = (int) (0.58 * lTotalWidth);
|
||||||
columnWidth[1] = (int) (0.25 * lTotalWidth);
|
columnWidth[1] = (int) (0.25 * lTotalWidth);
|
||||||
columnWidth[2] = lTotalWidth - columnWidth[0] - columnWidth[1];
|
columnWidth[2] = lTotalWidth - columnWidth[0] - columnWidth[1];
|
||||||
|
}
|
||||||
|
|
||||||
// Set up the column headings
|
// Set up the column headings
|
||||||
for (int i = 0; i < sizeof(columnHeader)/sizeof(int); ++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
{
|
{
|
||||||
LoadString( m_hInstance, columnHeader[i], psz, nMaxString );
|
LoadString( myHInstance, columnHeader[i], psz, nMaxString );
|
||||||
|
|
||||||
LV_COLUMN lvc;
|
LV_COLUMN lvc;
|
||||||
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
|
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
|
||||||
|
@ -222,7 +237,7 @@ BOOL MainDlg::OnInitDialog( void )
|
||||||
UpdateRomList();
|
UpdateRomList();
|
||||||
|
|
||||||
// Set default button
|
// Set default button
|
||||||
::SendMessage( hwnd, DM_SETDEFID, IDC_PLAY, 0 );
|
SendMessage( hwnd, DM_SETDEFID, IDC_PLAY, 0 );
|
||||||
|
|
||||||
// return FALSE if SetFocus is called
|
// return FALSE if SetFocus is called
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -247,7 +262,7 @@ BOOL MainDlg::OnCommand( int id, HWND hwndCtl, UINT codeNotify )
|
||||||
ASSERT( nItem != -1 );
|
ASSERT( nItem != -1 );
|
||||||
if ( nItem == -1 )
|
if ( nItem == -1 )
|
||||||
{
|
{
|
||||||
MessageBox( m_hInstance, hwnd, IDS_NO_ITEM_SELECTED );
|
MessageBox( myHInstance, hwnd, IDS_NO_ITEM_SELECTED );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,8 +277,7 @@ BOOL MainDlg::OnCommand( int id, HWND hwndCtl, UINT codeNotify )
|
||||||
break; // case IDC_PLAY
|
break; // case IDC_PLAY
|
||||||
|
|
||||||
case IDC_EXIT:
|
case IDC_EXIT:
|
||||||
ListView_Clear();
|
Quit(hwnd);
|
||||||
EndDialog( hwnd, IDCANCEL );
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
break; // case IDC_EXIT
|
break; // case IDC_EXIT
|
||||||
|
|
||||||
|
@ -295,7 +309,7 @@ BOOL MainDlg::OnCommand( int id, HWND hwndCtl, UINT codeNotify )
|
||||||
case IDC_RELOAD:
|
case IDC_RELOAD:
|
||||||
{
|
{
|
||||||
LoadRomListFromDisk();
|
LoadRomListFromDisk();
|
||||||
|
ListView_SortByColumn( myHwndList, myGlobalData.settings().getInt("sortcol") );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
break; // case IDC_RELOAD
|
break; // case IDC_RELOAD
|
||||||
}
|
}
|
||||||
|
@ -315,13 +329,13 @@ BOOL MainDlg::OnNotify( int idCtrl, LPNMHDR pnmh )
|
||||||
OnItemChanged( (LPNMLISTVIEW)pnmh );
|
OnItemChanged( (LPNMLISTVIEW)pnmh );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
// case LVN_COLUMNCLICK:
|
case LVN_COLUMNCLICK:
|
||||||
// OnColumnClick( (LPNMLISTVIEW)pnmh );
|
OnColumnClick( (LPNMLISTVIEW)pnmh );
|
||||||
// return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case NM_DBLCLK:
|
case NM_DBLCLK:
|
||||||
// send out an ok click to play
|
// send out an ok click to play
|
||||||
::SendDlgItemMessage( *this, IDC_PLAY, BM_CLICK, 0, 0 );
|
SendDlgItemMessage( *this, IDC_PLAY, BM_CLICK, 0, 0 );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,6 +370,12 @@ void MainDlg::OnItemChanged( LPNMLISTVIEW pnmv )
|
||||||
EnableWindow( GetDlgItem( hwnd, IDC_PLAY ), TRUE );
|
EnableWindow( GetDlgItem( hwnd, IDC_PLAY ), TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void MainDlg::OnColumnClick( LPNMLISTVIEW pnmv )
|
||||||
|
{
|
||||||
|
ListView_SortByColumn( pnmv->hdr.hwndFrom, pnmv->iSubItem );
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
static void ScreenToClient( HWND hwnd, LPRECT lpRect )
|
static void ScreenToClient( HWND hwnd, LPRECT lpRect )
|
||||||
{
|
{
|
||||||
|
@ -393,7 +413,7 @@ BOOL MainDlg::OnEraseBkgnd( HDC hdc )
|
||||||
|
|
||||||
HDC hdcMem = CreateCompatibleDC(hdc);
|
HDC hdcMem = CreateCompatibleDC(hdc);
|
||||||
|
|
||||||
HBITMAP hbmpTile = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_TILE) );
|
HBITMAP hbmpTile = LoadBitmap( myHInstance, MAKEINTRESOURCE(IDB_TILE) );
|
||||||
|
|
||||||
BITMAP bm;
|
BITMAP bm;
|
||||||
GetObject(hbmpTile, sizeof(bm), &bm);
|
GetObject(hbmpTile, sizeof(bm), &bm);
|
||||||
|
@ -436,6 +456,31 @@ HBRUSH MainDlg::OnCtlColorStatic( HDC hdcStatic, HWND hwndStatic )
|
||||||
return (HBRUSH)GetStockObject(NULL_BRUSH);
|
return (HBRUSH)GetStockObject(NULL_BRUSH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void MainDlg::Quit( HWND hwnd )
|
||||||
|
{
|
||||||
|
// OK, reload the settings to make sure we have the most current ones
|
||||||
|
myGlobalData.settings().loadConfig();
|
||||||
|
|
||||||
|
// Save the current sort column
|
||||||
|
int sortcol = myHeader.GetSortCol();
|
||||||
|
myGlobalData.settings().setInt("sortcol", sortcol);
|
||||||
|
|
||||||
|
// Save the column widths
|
||||||
|
myGlobalData.settings().setInt("namecolwidth",
|
||||||
|
ListView_GetColWidth( hwnd, 0 ));
|
||||||
|
myGlobalData.settings().setInt("manufacturercolwidth",
|
||||||
|
ListView_GetColWidth( hwnd, 1 ));
|
||||||
|
myGlobalData.settings().setInt("raritycolwidth",
|
||||||
|
ListView_GetColWidth( hwnd, 2 ));
|
||||||
|
|
||||||
|
// Now, save the settings
|
||||||
|
myGlobalData.settings().saveConfig();
|
||||||
|
|
||||||
|
ListView_Clear();
|
||||||
|
EndDialog( hwnd, IDCANCEL );
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void MainDlg::UpdateRomList( void )
|
void MainDlg::UpdateRomList( void )
|
||||||
{
|
{
|
||||||
|
@ -447,22 +492,13 @@ void MainDlg::UpdateRomList( void )
|
||||||
|
|
||||||
// if items added, select first item and enable play button
|
// if items added, select first item and enable play button
|
||||||
int nCount = ListView_GetItemCount( myHwndList );
|
int nCount = ListView_GetItemCount( myHwndList );
|
||||||
if (nCount != 0)
|
if (nCount == 0)
|
||||||
{
|
EnableWindow(GetDlgItem( *this, IDC_PLAY), FALSE );
|
||||||
myHeader.SetSortCol( 0, TRUE );
|
|
||||||
// ListView_SortItems( myHwndList, ListViewCompareFunc, (LPARAM)this );
|
|
||||||
ListView_SetItemState( myHwndList, 0, LVIS_SELECTED | LVIS_FOCUSED,
|
|
||||||
LVIS_SELECTED | LVIS_FOCUSED );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
::EnableWindow(::GetDlgItem( *this, IDC_PLAY), FALSE );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show status text
|
// Show status text
|
||||||
TCHAR psz[256 + 1];
|
TCHAR psz[256 + 1];
|
||||||
TCHAR pszStatus[256 + 1];
|
TCHAR pszStatus[256 + 1];
|
||||||
LoadString(m_hInstance, IDS_STATUSTEXT, pszStatus, 256);
|
LoadString(myHInstance, IDS_STATUSTEXT, pszStatus, 256);
|
||||||
wsprintf( psz, pszStatus, nCount );
|
wsprintf( psz, pszStatus, nCount );
|
||||||
hwndText = GetDlgItem( *this, IDC_ROMCOUNT );
|
hwndText = GetDlgItem( *this, IDC_ROMCOUNT );
|
||||||
GetWindowRect(hwndText, &rc);
|
GetWindowRect(hwndText, &rc);
|
||||||
|
@ -492,6 +528,7 @@ bool MainDlg::PopulateRomList( void )
|
||||||
else
|
else
|
||||||
result = LoadRomListFromDisk();
|
result = LoadRomListFromDisk();
|
||||||
|
|
||||||
|
ListView_SortByColumn( myHwndList, myGlobalData.settings().getInt("sortcol") );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -594,7 +631,10 @@ bool MainDlg::LoadRomListFromDisk()
|
||||||
strncpy(name, g->name().c_str(), 255);
|
strncpy(name, g->name().c_str(), 255);
|
||||||
|
|
||||||
// Update the current game
|
// Update the current game
|
||||||
// To save memory, 'Note' is the only item that needs to be saved
|
g->setMd5( md5 );
|
||||||
|
g->setName( name );
|
||||||
|
g->setRarity( rarity );
|
||||||
|
g->setManufacturer( manufacturer );
|
||||||
g->setNote( props.get("Cartridge.Note") );
|
g->setNote( props.get("Cartridge.Note") );
|
||||||
|
|
||||||
// Update the cachefile with this game
|
// Update the cachefile with this game
|
||||||
|
@ -648,9 +688,13 @@ bool MainDlg::LoadRomListFromCache()
|
||||||
in.getline(manufacturer, 255);
|
in.getline(manufacturer, 255);
|
||||||
in.getline(note, 255);
|
in.getline(note, 255);
|
||||||
|
|
||||||
// These are the only things we really need to save
|
// And save it to this game object
|
||||||
g->setAvailable( true );
|
g->setAvailable( true );
|
||||||
g->setRom( rom );
|
g->setRom( rom );
|
||||||
|
g->setMd5( md5 );
|
||||||
|
g->setName( name );
|
||||||
|
g->setRarity( rarity );
|
||||||
|
g->setManufacturer( manufacturer );
|
||||||
g->setNote( note );
|
g->setNote( note );
|
||||||
|
|
||||||
LV_ITEM lvi;
|
LV_ITEM lvi;
|
||||||
|
@ -725,6 +769,42 @@ LPARAM MainDlg::ListView_GetItemData( HWND hwndList, int iItem )
|
||||||
return lvi.lParam;
|
return lvi.lParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void MainDlg::ListView_SortByColumn( HWND hwndList, int col )
|
||||||
|
{
|
||||||
|
HCURSOR hcur = SetCursor(LoadCursor(NULL, IDC_WAIT));
|
||||||
|
|
||||||
|
int nCount = ListView_GetItemCount( hwndList );
|
||||||
|
if (nCount != 0)
|
||||||
|
{
|
||||||
|
myHeader.SetSortCol( col, TRUE );
|
||||||
|
ListView_SortItems( hwndList, ListViewCompareFunc, (LPARAM)this );
|
||||||
|
ListView_SetItemState( hwndList, 0, LVIS_SELECTED | LVIS_FOCUSED,
|
||||||
|
LVIS_SELECTED | LVIS_FOCUSED );
|
||||||
|
}
|
||||||
|
|
||||||
|
// ensure the selected item is visible
|
||||||
|
int nItem = ListView_GetNextItem( myHwndList, -1, LVNI_SELECTED );
|
||||||
|
if (nItem != -1)
|
||||||
|
ListView_EnsureVisible( myHwndList, nItem, TRUE );
|
||||||
|
|
||||||
|
SetCursor(hcur);
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
int MainDlg::ListView_GetColWidth( HWND hwndList, int col )
|
||||||
|
{
|
||||||
|
// Although there seems to be a similar function in the Win32 API
|
||||||
|
// to do this, I couldn't get it to work, so it's quicker to
|
||||||
|
// write this one and use it ...
|
||||||
|
LV_COLUMN lvc;
|
||||||
|
lvc.mask = LVCF_WIDTH;
|
||||||
|
if (ListView_GetColumn( myHwndList, col, &lvc ) == TRUE)
|
||||||
|
return lvc.cx;
|
||||||
|
else
|
||||||
|
return 0; // the next time StellaX starts, it will recreate a sane value
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void MainDlg::ListView_Clear( void )
|
void MainDlg::ListView_Clear( void )
|
||||||
{
|
{
|
||||||
|
@ -735,3 +815,41 @@ void MainDlg::ListView_Clear( void )
|
||||||
|
|
||||||
ListView_DeleteAllItems( myHwndList );
|
ListView_DeleteAllItems( myHwndList );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
int CALLBACK
|
||||||
|
MainDlg::ListViewCompareFunc( LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort )
|
||||||
|
{
|
||||||
|
MainDlg* dlg = reinterpret_cast<MainDlg*>( lParamSort );
|
||||||
|
|
||||||
|
int sortCol = dlg->myHeader.GetSortCol();
|
||||||
|
|
||||||
|
Game* g1 = reinterpret_cast<Game*>( lParam1 );
|
||||||
|
Game* g2 = reinterpret_cast<Game*>( lParam2 );
|
||||||
|
|
||||||
|
string s1 = "", s2 = "";
|
||||||
|
switch (sortCol)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
s1 = g1->name();
|
||||||
|
s2 = g2->name();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
s1 = g1->manufacturer();
|
||||||
|
s2 = g2->manufacturer();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
s1 = g1->rarity();
|
||||||
|
s2 = g2->rarity();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s1 > s2)
|
||||||
|
return 1;
|
||||||
|
else if (s1 < s2)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: MainDlg.hxx,v 1.3 2004-07-10 22:25:58 stephena Exp $
|
// $Id: MainDlg.hxx,v 1.4 2004-07-11 22:04:22 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef __MAINDLG_H_
|
#ifndef __MAINDLG_H_
|
||||||
|
@ -37,6 +37,7 @@ class MainDlg
|
||||||
enum { IDD = IDD_MAIN };
|
enum { IDD = IDD_MAIN };
|
||||||
|
|
||||||
MainDlg( CGlobalData& rGlobalData, HINSTANCE hInstance );
|
MainDlg( CGlobalData& rGlobalData, HINSTANCE hInstance );
|
||||||
|
virtual ~MainDlg( void );
|
||||||
|
|
||||||
virtual int DoModal( HWND hwndParent );
|
virtual int DoModal( HWND hwndParent );
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@ class MainDlg
|
||||||
|
|
||||||
// wm_notify handlers
|
// wm_notify handlers
|
||||||
void OnItemChanged( LPNMLISTVIEW pnmv );
|
void OnItemChanged( LPNMLISTVIEW pnmv );
|
||||||
// void OnColumnClick( LPNMLISTVIEW pnmv );
|
void OnColumnClick( LPNMLISTVIEW pnmv );
|
||||||
|
|
||||||
// cool caption handlers
|
// cool caption handlers
|
||||||
void OnDestroy( void );
|
void OnDestroy( void );
|
||||||
|
@ -74,6 +75,7 @@ class MainDlg
|
||||||
// callback methods
|
// callback methods
|
||||||
BOOL CALLBACK DialogFunc( UINT uMsg, WPARAM wParam, LPARAM lParam );
|
BOOL CALLBACK DialogFunc( UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||||
static BOOL CALLBACK StaticDialogFunc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
static BOOL CALLBACK StaticDialogFunc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||||
|
static int CALLBACK ListViewCompareFunc( LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort );
|
||||||
|
|
||||||
// internal data
|
// internal data
|
||||||
void UpdateRomList();
|
void UpdateRomList();
|
||||||
|
@ -81,11 +83,14 @@ class MainDlg
|
||||||
bool LoadRomListFromDisk();
|
bool LoadRomListFromDisk();
|
||||||
bool LoadRomListFromCache();
|
bool LoadRomListFromCache();
|
||||||
|
|
||||||
HINSTANCE m_hInstance;
|
void Quit( HWND hwnd );
|
||||||
|
|
||||||
|
HINSTANCE myHInstance;
|
||||||
|
|
||||||
// stuff in list
|
|
||||||
HWND myHwndList;
|
HWND myHwndList;
|
||||||
LPARAM ListView_GetItemData( HWND hwndList, int iItem );
|
LPARAM ListView_GetItemData( HWND hwndList, int iItem );
|
||||||
|
void ListView_SortByColumn( HWND hwndList, int col );
|
||||||
|
int ListView_GetColWidth( HWND hwndList, int col );
|
||||||
void ListView_Clear();
|
void ListView_Clear();
|
||||||
|
|
||||||
HFONT m_hfontRomNote;
|
HFONT m_hfontRomNote;
|
||||||
|
|
Loading…
Reference in New Issue