Permalink
Fetching contributors…
Cannot retrieve contributors at this time
9114 lines (7065 sloc) 266 KB
// prefsp1.cpp : implementation file
//
#include "stdafx.h"
#include "..\..\MUSHclient.h"
#include "..\..\mainfrm.h"
#include "..\..\doc.h"
#include "..\..\TextDocument.h"
#include "..\..\MUSHview.h"
#include "..\..\sendvw.h"
#include "..\..\scripting\errors.h"
#include "..\..\childfrm.h"
#include "editmac.h"
#include "aliasdlg.h"
#include "triggdlg.h"
#include "TimerDlg.h"
#include "EditVariable.h"
#include "..\FindDlg.h"
#include "TabDefaultsDlg.h"
#include "TreePropertySheet.h"
#include "..\Splash.h"
#include "CommandOptionsDlg.h"
#include "..\MXPscriptRoutinesDlg.h"
#include "..\ColourPickerDlg.h"
#include "..\EditMultiLine.h"
#include "..\CreditsDlg.h"
#include "..\ProxyServerPasswordDlg.h"
#include "..\ProgDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
#pragma warning (disable : 4800) // forcing value to bool 'true' or 'false' (performance warning)
bool NotFound (CFindInfo & FindInfo);
#define NL "\r\n"
static inline short get_style (int style)
{
return style & 0x0F;
} // end of get_style
// - see copy in mushview.cpp
static inline short get_foreground (int style)
{
return (style >> 4) & 0x07;
} // end of get_foreground
static inline short get_background (int style)
{
return (style >> 8) & 0x07;
} // end of get_background
// The field below is needed to initialise the browse directory dialog
// with the initial directory
extern CString strStartingDirectory;
// function prototypes needed for folder browsing
int __stdcall BrowseCallbackProc(
HWND hwnd,
UINT uMsg,
LPARAM lParam,
LPARAM lpData
);
void RemoveTrailingBackslash (CString& str);
/////////////////////////////////////////////////////////////////////////////
// CPrefsP1 property page
IMPLEMENT_DYNCREATE(CPrefsP1, CPropertyPage)
CPrefsP1::CPrefsP1() : CPropertyPage(CPrefsP1::IDD)
{
//{{AFX_DATA_INIT(CPrefsP1)
m_port = 0;
m_mush_name = _T("");
m_server = _T("");
m_bSaveWorldAutomatically = FALSE;
m_strMudListAddress = _T("");
m_strBugReportAddress = _T("");
m_iSocksProcessing = -1;
m_strProxyServerName = _T("");
m_iProxyServerPort = 0;
//}}AFX_DATA_INIT
m_page_number = 1;
m_doc = NULL;
}
CPrefsP1::~CPrefsP1()
{
}
void CPrefsP1::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPrefsP1)
DDX_Text(pDX, IDC_CHANNEL, m_port);
DDV_MinMaxLong(pDX, m_port, 0, 65535);
DDX_Text(pDX, IDC_MUSH_NAME, m_mush_name);
DDX_Text(pDX, IDC_SERVER, m_server);
DDX_Check(pDX, IDC_SAVE_AUTOMATICALLY, m_bSaveWorldAutomatically);
DDX_Text(pDX, IDC_MUD_LISTS, m_strMudListAddress);
DDX_Text(pDX, IDC_BUG_REPORT, m_strBugReportAddress);
DDX_CBIndex(pDX, IDC_PROXY_TYPE, m_iSocksProcessing);
DDX_Text(pDX, IDC_PROXY_SERVER_NAME, m_strProxyServerName);
DDX_Text(pDX, IDC_PROXY_PORT, m_iProxyServerPort);
DDV_MinMaxLong(pDX, m_iProxyServerPort, 0, 65535);
//}}AFX_DATA_MAP
if(pDX->m_bSaveAndValidate)
{
m_mush_name.TrimLeft (); // don't let them get away with a single space
m_mush_name.TrimRight ();
if(m_mush_name.IsEmpty ())
{
::TMessageBox("Your world name cannot be blank.\n\n"
"You must fill in your world name, TCP/IP address and "
"port number before tabbing to other configuration screens");
DDX_Text(pDX, IDC_MUSH_NAME, m_mush_name);
pDX->Fail();
} // end of MUSH name being blank
m_server.TrimLeft (); // don't let them get away with a single space
m_server.TrimRight ();
if(m_server.IsEmpty ())
{
::TMessageBox("The world IP address cannot be blank.");
DDX_Text(pDX, IDC_SERVER, m_server);
pDX->Fail();
} // end of server name being blank
if (m_port == 0)
{
::TMessageBox("The world port number must be specified.");
DDX_Text(pDX, IDC_CHANNEL, m_port);
pDX->Fail();
} // end of port being zero
m_strProxyServerName.TrimLeft ();
m_strProxyServerName.TrimRight ();
switch (m_iSocksProcessing)
{
case eProxyServerNone:
break; // nothing needed here
case eProxyServerSocks4: // socks 4
case eProxyServerSocks5: // socks 5
if (m_strProxyServerName.IsEmpty ())
{
::TMessageBox("The proxy server address cannot be blank.");
DDX_Text(pDX, IDC_PROXY_SERVER_NAME, m_strProxyServerName);
pDX->Fail();
} // end of proxy server name being blank
if (m_iProxyServerPort == 0)
{
::TMessageBox("The proxy server port must be specified.");
DDX_Text(pDX, IDC_PROXY_PORT, m_iProxyServerPort);
pDX->Fail();
} // end of proxy server port being zero
break;
default:
::TMessageBox("Unknown proxy server type.");
pDX->Fail();
break;
} // end of switch
} // end of saving and validating
}
BOOL CPrefsP1::OnInitDialog()
{
// subclass static controls.
m_MudListLink.SubclassDlgItem(IDC_MUD_LISTS, this);
m_strMudListAddress = MUD_LIST;
m_BugReportLink.SubclassDlgItem(IDC_BUG_REPORT, this);
m_strBugReportAddress = BUG_REPORT_PAGE;
return CPropertyPage::OnInitDialog();
}
BEGIN_MESSAGE_MAP(CPrefsP1, CPropertyPage)
//{{AFX_MSG_MAP(CPrefsP1)
ON_BN_CLICKED(IDC_PROXY_SERVER_PASSWORD, OnProxyServerPassword)
ON_BN_CLICKED(IDC_CLEAR_CACHED, OnClearCached)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_KICKIDLE, OnKickIdle)
ON_UPDATE_COMMAND_UI(IDC_CLEAR_CACHED, OnUpdateCanClearCache)
END_MESSAGE_MAP()
void CPrefsP1::OnProxyServerPassword()
{
CProxyServerPasswordDlg dlg;
dlg.m_strProxyUserName = m_strProxyUserName;
dlg.m_strProxyPassword = m_strProxyPassword;
if (dlg.DoModal () != IDOK)
return;
m_strProxyUserName = dlg.m_strProxyUserName;
m_strProxyPassword = dlg.m_strProxyPassword;
}
void CPrefsP1::OnClearCached()
{
m_doc->ResetIP ();
}
LRESULT CPrefsP1::OnKickIdle(WPARAM, LPARAM)
{
UpdateDialogControls (AfxGetApp()->m_pMainWnd, false);
return 0;
} // end of CPrefsP1::OnKickIdle
void CPrefsP1::OnUpdateCanClearCache(CCmdUI* pCmdUI)
{
pCmdUI->Enable (m_doc->m_sockAddr.sin_addr.s_addr != 0 ||
m_doc->m_ProxyAddr.sin_addr.s_addr != 0);
} // end of CPrefsP1::OnUpdateCanClearCache
/////////////////////////////////////////////////////////////////////////////
// CPrefsP1 message handlers
/////////////////////////////////////////////////////////////////////////////
// CPrefsP2 property page
IMPLEMENT_DYNCREATE(CPrefsP2, CPropertyPage)
CPrefsP2::CPrefsP2() : CPropertyPage(CPrefsP2::IDD)
{
//{{AFX_DATA_INIT(CPrefsP2)
m_sound_pathname = _T("");
//}}AFX_DATA_INIT
m_page_number = 1;
m_doc = NULL;
}
CPrefsP2::~CPrefsP2()
{
}
void CPrefsP2::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPrefsP2)
DDX_Text(pDX, IDC_SOUND_PATH, m_sound_pathname);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPrefsP2, CPropertyPage)
//{{AFX_MSG_MAP(CPrefsP2)
ON_BN_CLICKED(IDC_BROWSE_SOUNDS, OnBrowseSounds)
ON_BN_CLICKED(IDC_TEST_SOUND, OnTestSound)
ON_BN_CLICKED(IDC_NO_SOUND, OnNoSound)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPrefsP2 message handlers
void CPrefsP2::OnBrowseSounds()
{
}
void CPrefsP2::OnTestSound()
{
}
void CPrefsP2::OnNoSound()
{
}
LRESULT CPrefsP2::OnKickIdle(WPARAM, LPARAM)
{
UpdateDialogControls (AfxGetApp()->m_pMainWnd, false);
return 0;
} // end of CPrefsP2::OnKickIdle
void CPrefsP2::OnUpdateNeedSound(CCmdUI* pCmdUI)
{
pCmdUI->Enable (!m_sound_pathname.IsEmpty () && m_sound_pathname != NOSOUNDLIT);
} // end of CPrefsP2::OnUpdateNeedSound
/////////////////////////////////////////////////////////////////////////////
// CPrefsP3 property page
IMPLEMENT_DYNCREATE(CPrefsP3, CPropertyPage)
CPrefsP3::CPrefsP3() : CPropertyPage(CPrefsP3::IDD)
{
//{{AFX_DATA_INIT(CPrefsP3)
//}}AFX_DATA_INIT
m_page_number = 1;
m_RH_click_count = 0;
m_doc = NULL;
m_prefsp5 = NULL;
}
CPrefsP3::~CPrefsP3()
{
}
void CPrefsP3::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPrefsP3)
DDX_Control(pDX, IDC_CUSTOM_NAME9, m_ctlCustomName9);
DDX_Control(pDX, IDC_CUSTOM_NAME8, m_ctlCustomName8);
DDX_Control(pDX, IDC_CUSTOM_NAME7, m_ctlCustomName7);
DDX_Control(pDX, IDC_CUSTOM_NAME6, m_ctlCustomName6);
DDX_Control(pDX, IDC_CUSTOM_NAME5, m_ctlCustomName5);
DDX_Control(pDX, IDC_CUSTOM_NAME4, m_ctlCustomName4);
DDX_Control(pDX, IDC_CUSTOM_NAME3, m_ctlCustomName3);
DDX_Control(pDX, IDC_CUSTOM_NAME2, m_ctlCustomName2);
DDX_Control(pDX, IDC_CUSTOM_NAME16, m_ctlCustomName16);
DDX_Control(pDX, IDC_CUSTOM_NAME15, m_ctlCustomName15);
DDX_Control(pDX, IDC_CUSTOM_NAME14, m_ctlCustomName14);
DDX_Control(pDX, IDC_CUSTOM_NAME13, m_ctlCustomName13);
DDX_Control(pDX, IDC_CUSTOM_NAME12, m_ctlCustomName12);
DDX_Control(pDX, IDC_CUSTOM_NAME11, m_ctlCustomName11);
DDX_Control(pDX, IDC_CUSTOM_NAME10, m_ctlCustomName10);
DDX_Control(pDX, IDC_CUSTOM_NAME1, m_ctlCustomName1);
DDX_Control(pDX, IDC_SWATCH_CUSTOM9, m_ctlCustom9);
DDX_Control(pDX, IDC_SWATCH_CUSTOM8, m_ctlCustom8);
DDX_Control(pDX, IDC_SWATCH_CUSTOM7, m_ctlCustom7);
DDX_Control(pDX, IDC_SWATCH_CUSTOM6, m_ctlCustom6);
DDX_Control(pDX, IDC_SWATCH_CUSTOM5, m_ctlCustom5);
DDX_Control(pDX, IDC_SWATCH_CUSTOM4, m_ctlCustom4);
DDX_Control(pDX, IDC_SWATCH_CUSTOM32, m_ctlCustom32);
DDX_Control(pDX, IDC_SWATCH_CUSTOM31, m_ctlCustom31);
DDX_Control(pDX, IDC_SWATCH_CUSTOM30, m_ctlCustom30);
DDX_Control(pDX, IDC_SWATCH_CUSTOM3, m_ctlCustom3);
DDX_Control(pDX, IDC_SWATCH_CUSTOM29, m_ctlCustom29);
DDX_Control(pDX, IDC_SWATCH_CUSTOM28, m_ctlCustom28);
DDX_Control(pDX, IDC_SWATCH_CUSTOM27, m_ctlCustom27);
DDX_Control(pDX, IDC_SWATCH_CUSTOM26, m_ctlCustom26);
DDX_Control(pDX, IDC_SWATCH_CUSTOM25, m_ctlCustom25);
DDX_Control(pDX, IDC_SWATCH_CUSTOM24, m_ctlCustom24);
DDX_Control(pDX, IDC_SWATCH_CUSTOM23, m_ctlCustom23);
DDX_Control(pDX, IDC_SWATCH_CUSTOM22, m_ctlCustom22);
DDX_Control(pDX, IDC_SWATCH_CUSTOM21, m_ctlCustom21);
DDX_Control(pDX, IDC_SWATCH_CUSTOM20, m_ctlCustom20);
DDX_Control(pDX, IDC_SWATCH_CUSTOM2, m_ctlCustom2);
DDX_Control(pDX, IDC_SWATCH_CUSTOM19, m_ctlCustom19);
DDX_Control(pDX, IDC_SWATCH_CUSTOM18, m_ctlCustom18);
DDX_Control(pDX, IDC_SWATCH_CUSTOM17, m_ctlCustom17);
DDX_Control(pDX, IDC_SWATCH_CUSTOM16, m_ctlCustom16);
DDX_Control(pDX, IDC_SWATCH_CUSTOM15, m_ctlCustom15);
DDX_Control(pDX, IDC_SWATCH_CUSTOM14, m_ctlCustom14);
DDX_Control(pDX, IDC_SWATCH_CUSTOM13, m_ctlCustom13);
DDX_Control(pDX, IDC_SWATCH_CUSTOM12, m_ctlCustom12);
DDX_Control(pDX, IDC_SWATCH_CUSTOM11, m_ctlCustom11);
DDX_Control(pDX, IDC_SWATCH_CUSTOM10, m_ctlCustom10);
DDX_Control(pDX, IDC_SWATCH_CUSTOM1, m_ctlCustom1);
DDX_Control(pDX, IDC_YELLOW_SWATCH_BOLD, m_ctlYellowSwatchBold);
DDX_Control(pDX, IDC_YELLOW_SWATCH, m_ctlYellowSwatch);
DDX_Control(pDX, IDC_WHITE_SWATCH_BOLD, m_ctlWhiteSwatchBold);
DDX_Control(pDX, IDC_WHITE_SWATCH, m_ctlWhiteSwatch);
DDX_Control(pDX, IDC_RED_SWATCH_BOLD, m_ctlRedSwatchBold);
DDX_Control(pDX, IDC_RED_SWATCH, m_ctlRedSwatch);
DDX_Control(pDX, IDC_MAGENTA_SWATCH_BOLD, m_ctlMagentaSwatchBold);
DDX_Control(pDX, IDC_MAGENTA_SWATCH, m_ctlMagentaSwatch);
DDX_Control(pDX, IDC_GREEN_SWATCH_BOLD, m_ctlGreenSwatchBold);
DDX_Control(pDX, IDC_GREEN_SWATCH, m_ctlGreenSwatch);
DDX_Control(pDX, IDC_CYAN_SWATCH_BOLD, m_ctlCyanSwatchBold);
DDX_Control(pDX, IDC_CYAN_SWATCH, m_ctlCyanSwatch);
DDX_Control(pDX, IDC_BLUE_SWATCH_BOLD, m_ctlBlueSwatchBold);
DDX_Control(pDX, IDC_BLUE_SWATCH, m_ctlBlueSwatch);
DDX_Control(pDX, IDC_BLACK_SWATCH_BOLD, m_ctlBlackSwatchBold);
DDX_Control(pDX, IDC_BLACK_SWATCH, m_ctlBlackSwatch);
//}}AFX_DATA_MAP
DDX_MinMaxString(pDX, IDC_CUSTOM_NAME1, m_strCustomName [0]);
DDV_MinMaxString(pDX, m_strCustomName [0], 1, 30);
DDX_MinMaxString(pDX, IDC_CUSTOM_NAME2, m_strCustomName [1]);
DDV_MinMaxString(pDX, m_strCustomName [1], 1, 30);
DDX_MinMaxString(pDX, IDC_CUSTOM_NAME3, m_strCustomName [2]);
DDV_MinMaxString(pDX, m_strCustomName [2], 1, 30);
DDX_MinMaxString(pDX, IDC_CUSTOM_NAME4, m_strCustomName [3]);
DDV_MinMaxString(pDX, m_strCustomName [3], 1, 30);
DDX_MinMaxString(pDX, IDC_CUSTOM_NAME5, m_strCustomName [4]);
DDV_MinMaxString(pDX, m_strCustomName [4], 1, 30);
DDX_MinMaxString(pDX, IDC_CUSTOM_NAME6, m_strCustomName [5]);
DDV_MinMaxString(pDX, m_strCustomName [5], 1, 30);
DDX_MinMaxString(pDX, IDC_CUSTOM_NAME7, m_strCustomName [6]);
DDV_MinMaxString(pDX, m_strCustomName [6], 1, 30);
DDX_MinMaxString(pDX, IDC_CUSTOM_NAME8, m_strCustomName [7]);
DDV_MinMaxString(pDX, m_strCustomName [7], 1, 30);
DDX_MinMaxString(pDX, IDC_CUSTOM_NAME9, m_strCustomName [8]);
DDV_MinMaxString(pDX, m_strCustomName [8], 1, 30);
DDX_MinMaxString(pDX, IDC_CUSTOM_NAME10, m_strCustomName [9]);
DDV_MinMaxString(pDX, m_strCustomName [9], 1, 30);
DDX_MinMaxString(pDX, IDC_CUSTOM_NAME11, m_strCustomName [10]);
DDV_MinMaxString(pDX, m_strCustomName [10], 1, 30);
DDX_MinMaxString(pDX, IDC_CUSTOM_NAME12, m_strCustomName [11]);
DDV_MinMaxString(pDX, m_strCustomName [11], 1, 30);
DDX_MinMaxString(pDX, IDC_CUSTOM_NAME13, m_strCustomName [12]);
DDV_MinMaxString(pDX, m_strCustomName [12], 1, 30);
DDX_MinMaxString(pDX, IDC_CUSTOM_NAME14, m_strCustomName [13]);
DDV_MinMaxString(pDX, m_strCustomName [13], 1, 30);
DDX_MinMaxString(pDX, IDC_CUSTOM_NAME15, m_strCustomName [14]);
DDV_MinMaxString(pDX, m_strCustomName [14], 1, 30);
DDX_MinMaxString(pDX, IDC_CUSTOM_NAME16, m_strCustomName [15]);
DDV_MinMaxString(pDX, m_strCustomName [15], 1, 30);
}
BEGIN_MESSAGE_MAP(CPrefsP3, CPropertyPage)
//{{AFX_MSG_MAP(CPrefsP3)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM1, OnSwatchCustom1)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM2, OnSwatchCustom2)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM10, OnSwatchCustom10)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM11, OnSwatchCustom11)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM12, OnSwatchCustom12)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM13, OnSwatchCustom13)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM14, OnSwatchCustom14)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM15, OnSwatchCustom15)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM16, OnSwatchCustom16)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM17, OnSwatchCustom17)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM18, OnSwatchCustom18)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM19, OnSwatchCustom19)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM20, OnSwatchCustom20)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM21, OnSwatchCustom21)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM22, OnSwatchCustom22)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM23, OnSwatchCustom23)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM24, OnSwatchCustom24)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM25, OnSwatchCustom25)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM26, OnSwatchCustom26)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM27, OnSwatchCustom27)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM28, OnSwatchCustom28)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM29, OnSwatchCustom29)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM3, OnSwatchCustom3)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM30, OnSwatchCustom30)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM31, OnSwatchCustom31)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM32, OnSwatchCustom32)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM4, OnSwatchCustom4)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM5, OnSwatchCustom5)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM6, OnSwatchCustom6)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM7, OnSwatchCustom7)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM8, OnSwatchCustom8)
ON_BN_CLICKED(IDC_SWATCH_CUSTOM9, OnSwatchCustom9)
ON_WM_RBUTTONDOWN()
ON_BN_CLICKED(IDC_INVERT, OnInvert)
ON_BN_CLICKED(IDC_ALL_LIGHTER, OnAllLighter)
ON_BN_CLICKED(IDC_ALL_DARKER, OnAllDarker)
ON_BN_CLICKED(IDC_ALL_MORE_COLOUR, OnAllMoreColour)
ON_BN_CLICKED(IDC_ALL_LESS_COLOUR, OnAllLessColour)
ON_BN_CLICKED(IDC_DEFAULTS, OnDefaults)
ON_BN_CLICKED(IDC_SWAP, OnSwap)
ON_BN_CLICKED(IDC_RANDOM, OnRandom)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_KICKIDLE, OnKickIdle)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM1, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM2, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM10, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM11, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM12, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM13, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM14, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM15, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM16, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM17, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM18, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM19, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM20, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM21, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM22, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM23, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM24, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM25, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM26, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM27, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM28, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM29, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM3, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM30, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM31, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM32, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM4, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM5, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM6, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM7, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM8, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_SWATCH_CUSTOM9, OnUpdateNotUsingDefaults)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPrefsP3 message handlers
void CPrefsP3::amendcolour (CColourButton & whichcolour)
{
CColourPickerDlg dlg;
dlg.m_iColour = whichcolour.m_colour;
dlg.m_bPickColour = true;
/*
CColorDialog dlg (whichcolour.m_colour,
CC_RGBINIT | CC_FULLOPEN,
GetOwner());
*/
if (dlg.DoModal () != IDOK)
return;
whichcolour.m_colour = dlg.GetColor ();
whichcolour.RedrawWindow();
} // end of amendcolour
BOOL CPrefsP3::OnInitDialog()
{
CPropertyPage::OnInitDialog();
LoadSwatches ();
bool bEnable = !m_prefsp5->m_bUseDefaultColours ||
App.m_strDefaultColoursFile.IsEmpty ();
m_ctlCustom1.EnableWindow (bEnable);
m_ctlCustom2.EnableWindow (bEnable);
m_ctlCustom3.EnableWindow (bEnable);
m_ctlCustom4.EnableWindow (bEnable);
m_ctlCustom5.EnableWindow (bEnable);
m_ctlCustom6.EnableWindow (bEnable);
m_ctlCustom7.EnableWindow (bEnable);
m_ctlCustom8.EnableWindow (bEnable);
m_ctlCustom9.EnableWindow (bEnable);
m_ctlCustom10.EnableWindow (bEnable);
m_ctlCustom11.EnableWindow (bEnable);
m_ctlCustom12.EnableWindow (bEnable);
m_ctlCustom13.EnableWindow (bEnable);
m_ctlCustom14.EnableWindow (bEnable);
m_ctlCustom15.EnableWindow (bEnable);
m_ctlCustom16.EnableWindow (bEnable);
m_ctlCustom17.EnableWindow (bEnable);
m_ctlCustom18.EnableWindow (bEnable);
m_ctlCustom19.EnableWindow (bEnable);
m_ctlCustom20.EnableWindow (bEnable);
m_ctlCustom21.EnableWindow (bEnable);
m_ctlCustom22.EnableWindow (bEnable);
m_ctlCustom23.EnableWindow (bEnable);
m_ctlCustom24.EnableWindow (bEnable);
m_ctlCustom25.EnableWindow (bEnable);
m_ctlCustom26.EnableWindow (bEnable);
m_ctlCustom27.EnableWindow (bEnable);
m_ctlCustom28.EnableWindow (bEnable);
m_ctlCustom29.EnableWindow (bEnable);
m_ctlCustom30.EnableWindow (bEnable);
m_ctlCustom31.EnableWindow (bEnable);
m_ctlCustom32.EnableWindow (bEnable);
m_RH_last_click = CTime::GetCurrentTime ();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPrefsP3::OnOK( )
{
SaveSwatches ();
CPropertyPage::OnOK ();
}
// save colours when our window becomes inactive, so they show up in other windows
BOOL CPrefsP3::OnKillActive()
{
SaveSwatches ();
return CPropertyPage::OnKillActive();
}
void CPrefsP3::SaveSwatches(void)
{
// custom text colours
m_customtext [0] = m_ctlCustom1.m_colour;
m_customtext [1] = m_ctlCustom2.m_colour;
m_customtext [2] = m_ctlCustom3.m_colour;
m_customtext [3] = m_ctlCustom4.m_colour;
m_customtext [4] = m_ctlCustom5.m_colour;
m_customtext [5] = m_ctlCustom6.m_colour;
m_customtext [6] = m_ctlCustom7.m_colour;
m_customtext [7] = m_ctlCustom8.m_colour;
m_customtext [8] = m_ctlCustom9.m_colour;
m_customtext [9] = m_ctlCustom10.m_colour;
m_customtext [10] = m_ctlCustom11.m_colour;
m_customtext [11] = m_ctlCustom12.m_colour;
m_customtext [12] = m_ctlCustom13.m_colour;
m_customtext [13] = m_ctlCustom14.m_colour;
m_customtext [14] = m_ctlCustom15.m_colour;
m_customtext [15] = m_ctlCustom16.m_colour;
// custom background colours
m_customback [0] = m_ctlCustom17.m_colour;
m_customback [1] = m_ctlCustom18.m_colour;
m_customback [2] = m_ctlCustom19.m_colour;
m_customback [3] = m_ctlCustom20.m_colour;
m_customback [4] = m_ctlCustom21.m_colour;
m_customback [5] = m_ctlCustom22.m_colour;
m_customback [6] = m_ctlCustom23.m_colour;
m_customback [7] = m_ctlCustom24.m_colour;
m_customback [8] = m_ctlCustom25.m_colour;
m_customback [9] = m_ctlCustom26.m_colour;
m_customback [10] = m_ctlCustom27.m_colour;
m_customback [11] = m_ctlCustom28.m_colour;
m_customback [12] = m_ctlCustom29.m_colour;
m_customback [13] = m_ctlCustom30.m_colour;
m_customback [14] = m_ctlCustom31.m_colour;
m_customback [15] = m_ctlCustom32.m_colour;
m_strCustomName [0] = GetText (m_ctlCustomName1);
m_strCustomName [1] = GetText (m_ctlCustomName2);
m_strCustomName [2] = GetText (m_ctlCustomName3);
m_strCustomName [3] = GetText (m_ctlCustomName4);
m_strCustomName [4] = GetText (m_ctlCustomName5);
m_strCustomName [5] = GetText (m_ctlCustomName6);
m_strCustomName [6] = GetText (m_ctlCustomName7);
m_strCustomName [7] = GetText (m_ctlCustomName8);
m_strCustomName [8] = GetText (m_ctlCustomName9);
m_strCustomName [9] = GetText (m_ctlCustomName10);
m_strCustomName [10] = GetText (m_ctlCustomName11);
m_strCustomName [11] = GetText (m_ctlCustomName12);
m_strCustomName [12] = GetText (m_ctlCustomName13);
m_strCustomName [13] = GetText (m_ctlCustomName14);
m_strCustomName [14] = GetText (m_ctlCustomName15);
m_strCustomName [15] = GetText (m_ctlCustomName16);
}
void CPrefsP3::LoadSwatches(void)
{
// custom text colours
m_ctlCustom1.m_colour = m_customtext [0];
m_ctlCustom2.m_colour = m_customtext [1];
m_ctlCustom3.m_colour = m_customtext [2];
m_ctlCustom4.m_colour = m_customtext [3];
m_ctlCustom5.m_colour = m_customtext [4];
m_ctlCustom6.m_colour = m_customtext [5];
m_ctlCustom7.m_colour = m_customtext [6];
m_ctlCustom8.m_colour = m_customtext [7];
m_ctlCustom9.m_colour = m_customtext [8];
m_ctlCustom10.m_colour = m_customtext [9];
m_ctlCustom11.m_colour = m_customtext [10];
m_ctlCustom12.m_colour = m_customtext [11];
m_ctlCustom13.m_colour = m_customtext [12];
m_ctlCustom14.m_colour = m_customtext [13];
m_ctlCustom15.m_colour = m_customtext [14];
m_ctlCustom16.m_colour = m_customtext [15];
// custom background colours
m_ctlCustom17.m_colour = m_customback [0];
m_ctlCustom18.m_colour = m_customback [1];
m_ctlCustom19.m_colour = m_customback [2];
m_ctlCustom20.m_colour = m_customback [3];
m_ctlCustom21.m_colour = m_customback [4];
m_ctlCustom22.m_colour = m_customback [5];
m_ctlCustom23.m_colour = m_customback [6];
m_ctlCustom24.m_colour = m_customback [7];
m_ctlCustom25.m_colour = m_customback [8];
m_ctlCustom26.m_colour = m_customback [9];
m_ctlCustom27.m_colour = m_customback [10];
m_ctlCustom28.m_colour = m_customback [11];
m_ctlCustom29.m_colour = m_customback [12];
m_ctlCustom30.m_colour = m_customback [13];
m_ctlCustom31.m_colour = m_customback [14];
m_ctlCustom32.m_colour = m_customback [15];
m_ctlCustomName1.SetWindowText (m_strCustomName [0]);
m_ctlCustomName2.SetWindowText (m_strCustomName [1]);
m_ctlCustomName3.SetWindowText (m_strCustomName [2]);
m_ctlCustomName4.SetWindowText (m_strCustomName [3]);
m_ctlCustomName5.SetWindowText (m_strCustomName [4]);
m_ctlCustomName6.SetWindowText (m_strCustomName [5]);
m_ctlCustomName7.SetWindowText (m_strCustomName [6]);
m_ctlCustomName8.SetWindowText (m_strCustomName [7]);
m_ctlCustomName9.SetWindowText (m_strCustomName [8]);
m_ctlCustomName10.SetWindowText (m_strCustomName [9]);
m_ctlCustomName11.SetWindowText (m_strCustomName [10]);
m_ctlCustomName12.SetWindowText (m_strCustomName [11]);
m_ctlCustomName13.SetWindowText (m_strCustomName [12]);
m_ctlCustomName14.SetWindowText (m_strCustomName [13]);
m_ctlCustomName15.SetWindowText (m_strCustomName [14]);
m_ctlCustomName16.SetWindowText (m_strCustomName [15]);
// ansi colours
m_ctlBlackSwatch.m_colour = m_prefsp5->m_normalcolour [BLACK];
m_ctlBlueSwatch.m_colour = m_prefsp5->m_normalcolour [BLUE];
m_ctlCyanSwatch.m_colour = m_prefsp5->m_normalcolour [CYAN];
m_ctlGreenSwatch.m_colour = m_prefsp5->m_normalcolour [GREEN];
m_ctlMagentaSwatch.m_colour = m_prefsp5->m_normalcolour [MAGENTA];
m_ctlRedSwatch.m_colour = m_prefsp5->m_normalcolour [RED];
m_ctlWhiteSwatch.m_colour = m_prefsp5->m_normalcolour [WHITE];
m_ctlYellowSwatch.m_colour = m_prefsp5->m_normalcolour [YELLOW];
m_ctlBlackSwatchBold.m_colour = m_prefsp5->m_boldcolour [BLACK];
m_ctlBlueSwatchBold.m_colour = m_prefsp5->m_boldcolour [BLUE];
m_ctlCyanSwatchBold.m_colour = m_prefsp5->m_boldcolour [CYAN];
m_ctlGreenSwatchBold.m_colour = m_prefsp5->m_boldcolour [GREEN];
m_ctlMagentaSwatchBold.m_colour = m_prefsp5->m_boldcolour [MAGENTA];
m_ctlRedSwatchBold.m_colour = m_prefsp5->m_boldcolour [RED];
m_ctlWhiteSwatchBold.m_colour = m_prefsp5->m_boldcolour [WHITE];
m_ctlYellowSwatchBold.m_colour = m_prefsp5->m_boldcolour [YELLOW];
}
void CPrefsP3::OnSwatchCustom1()
{
amendcolour (m_ctlCustom1);
}
void CPrefsP3::OnSwatchCustom2()
{
amendcolour (m_ctlCustom2);
}
void CPrefsP3::OnSwatchCustom10()
{
amendcolour (m_ctlCustom10);
}
void CPrefsP3::OnSwatchCustom11()
{
amendcolour (m_ctlCustom11);
}
void CPrefsP3::OnSwatchCustom12()
{
amendcolour (m_ctlCustom12);
}
void CPrefsP3::OnSwatchCustom13()
{
amendcolour (m_ctlCustom13);
}
void CPrefsP3::OnSwatchCustom14()
{
amendcolour (m_ctlCustom14);
}
void CPrefsP3::OnSwatchCustom15()
{
amendcolour (m_ctlCustom15);
}
void CPrefsP3::OnSwatchCustom16()
{
amendcolour (m_ctlCustom16);
}
void CPrefsP3::OnSwatchCustom17()
{
amendcolour (m_ctlCustom17);
}
void CPrefsP3::OnSwatchCustom18()
{
amendcolour (m_ctlCustom18);
}
void CPrefsP3::OnSwatchCustom19()
{
amendcolour (m_ctlCustom19);
}
void CPrefsP3::OnSwatchCustom20()
{
amendcolour (m_ctlCustom20);
}
void CPrefsP3::OnSwatchCustom21()
{
amendcolour (m_ctlCustom21);
}
void CPrefsP3::OnSwatchCustom22()
{
amendcolour (m_ctlCustom22);
}
void CPrefsP3::OnSwatchCustom23()
{
amendcolour (m_ctlCustom23);
}
void CPrefsP3::OnSwatchCustom24()
{
amendcolour (m_ctlCustom24);
}
void CPrefsP3::OnSwatchCustom25()
{
amendcolour (m_ctlCustom25);
}
void CPrefsP3::OnSwatchCustom26()
{
amendcolour (m_ctlCustom26);
}
void CPrefsP3::OnSwatchCustom27()
{
amendcolour (m_ctlCustom27);
}
void CPrefsP3::OnSwatchCustom28()
{
amendcolour (m_ctlCustom28);
}
void CPrefsP3::OnSwatchCustom29()
{
amendcolour (m_ctlCustom29);
}
void CPrefsP3::OnSwatchCustom3()
{
amendcolour (m_ctlCustom3);
}
void CPrefsP3::OnSwatchCustom30()
{
amendcolour (m_ctlCustom30);
}
void CPrefsP3::OnSwatchCustom31()
{
amendcolour (m_ctlCustom31);
}
void CPrefsP3::OnSwatchCustom32()
{
amendcolour (m_ctlCustom32);
}
void CPrefsP3::OnSwatchCustom4()
{
amendcolour (m_ctlCustom4);
}
void CPrefsP3::OnSwatchCustom5()
{
amendcolour (m_ctlCustom5);
}
void CPrefsP3::OnSwatchCustom6()
{
amendcolour (m_ctlCustom6);
}
void CPrefsP3::OnSwatchCustom7()
{
amendcolour (m_ctlCustom7);
}
void CPrefsP3::OnSwatchCustom8()
{
amendcolour (m_ctlCustom8);
}
void CPrefsP3::OnSwatchCustom9()
{
amendcolour (m_ctlCustom9);
}
// Easter egg - click slowly or it will count as a double-click
// Instructions: *slowly* control-RH-click anywhere on *custom* colours page *except* a button
// or other control. On every third click you will see the message.
void CPrefsP3::OnRButtonDown(UINT nFlags, CPoint point)
{
if (nFlags & MK_CONTROL)
{
CTime now = CTime::GetCurrentTime ();
// make sure each click occurs within 5 seconds
if (now.GetTime () > (m_RH_last_click.GetTime () + 5))
m_RH_click_count = 0;
m_RH_last_click = now;
if ((++m_RH_click_count % 3) == 0)
{
// ::TMessageBox ("But does it get goat's blood out?", MB_YESNO |MB_ICONQUESTION);
// CEasterEggDlg dlg;
// dlg.DoModal ();
CSplashWnd::ShowSplashScreen(&Frame, IDB_NICK);
}
} // end of ctrl+RH-click
CPropertyPage::OnRButtonDown(nFlags, point);
}
LRESULT CPrefsP3::OnKickIdle(WPARAM, LPARAM)
{
UpdateDialogControls (AfxGetApp()->m_pMainWnd, false);
return 0;
} // end of CPrefsP3::OnKickIdle
void CPrefsP3::OnUpdateNotUsingDefaults(CCmdUI* pCmdUI)
{
pCmdUI->Enable (m_prefsp5->m_ctlUseDefaultColours.GetCheck () == 0 ||
App.m_strDefaultColoursFile.IsEmpty ());
} // end of CPrefsP3::OnUpdateNotUsingDefaults
void CPrefsP3::OnInvert()
{
int i;
SaveSwatches ();
for (i = 0; i < MAX_CUSTOM; i++)
{
m_customtext [i] = ::AdjustColour (m_customtext [i], ADJUST_COLOUR_INVERT);
m_customback [i] = ::AdjustColour (m_customback [i], ADJUST_COLOUR_INVERT);
}
LoadSwatches ();
Invalidate (false);
}
void CPrefsP3::OnAllLighter()
{
int i;
SaveSwatches ();
for (i = 0; i < MAX_CUSTOM; i++)
{
m_customtext [i] = ::AdjustColour (m_customtext [i], ADJUST_COLOUR_LIGHTER);
m_customback [i] = ::AdjustColour (m_customback [i], ADJUST_COLOUR_LIGHTER);
}
LoadSwatches ();
Invalidate (false);
}
void CPrefsP3::OnAllDarker()
{
int i;
SaveSwatches ();
for (i = 0; i < MAX_CUSTOM; i++)
{
m_customtext [i] = ::AdjustColour (m_customtext [i], ADJUST_COLOUR_DARKER);
m_customback [i] = ::AdjustColour (m_customback [i], ADJUST_COLOUR_DARKER);
}
LoadSwatches ();
Invalidate (false);
}
void CPrefsP3::OnAllMoreColour()
{
int i;
SaveSwatches ();
for (i = 0; i < MAX_CUSTOM; i++)
{
m_customtext [i] = ::AdjustColour (m_customtext [i], ADJUST_COLOUR_MORE_COLOUR);
m_customback [i] = ::AdjustColour (m_customback [i], ADJUST_COLOUR_MORE_COLOUR);
}
LoadSwatches ();
Invalidate (false);
}
void CPrefsP3::OnAllLessColour()
{
int i;
SaveSwatches ();
for (i = 0; i < MAX_CUSTOM; i++)
{
m_customtext [i] = ::AdjustColour (m_customtext [i], ADJUST_COLOUR_LESS_COLOUR);
m_customback [i] = ::AdjustColour (m_customback [i], ADJUST_COLOUR_LESS_COLOUR);
}
LoadSwatches ();
Invalidate (false);
}
void CPrefsP3::OnDefaults()
{
if (::TMessageBox ("Reset all custom colours to MUSHclient defaults?",
MB_YESNO | MB_ICONQUESTION) != IDYES)
return;
SetDefaultCustomColours (m_customtext, m_customback);
LoadSwatches ();
Invalidate (false);
}
void CPrefsP3::OnSwap()
{
SaveSwatches ();
for (int i = 0; i < MAX_CUSTOM; i++)
{
COLORREF temp;
temp = m_customtext [i];
m_customtext [i] = m_customback [i];
m_customback [i] = temp;
}
LoadSwatches ();
Invalidate (false);
}
void CPrefsP3::OnRandom()
{
if (::TMessageBox ("Make all colours random?",
MB_YESNO | MB_ICONQUESTION) != IDYES)
return;
for (int i = 0; i < MAX_CUSTOM; i++)
{
m_customtext [i] = genrand () * (double) 0x1000000;
m_customback [i] = genrand () * (double) 0x1000000;
}
LoadSwatches ();
Invalidate (false);
}
/////////////////////////////////////////////////////////////////////////////
// CPrefsP4 property page
IMPLEMENT_DYNCREATE(CPrefsP4, CPropertyPage)
CPrefsP4::CPrefsP4() : CPropertyPage(CPrefsP4::IDD)
{
//{{AFX_DATA_INIT(CPrefsP4)
m_log_input = FALSE;
m_bLogNotes = FALSE;
m_strLogFilePreamble = _T("");
m_strAutoLogFileName = _T("");
m_bWriteWorldNameToLog = FALSE;
m_strLogLinePreambleOutput = _T("");
m_strLogLinePreambleInput = _T("");
m_strLogLinePreambleNotes = _T("");
m_strLogFilePostamble = _T("");
m_strLogLinePostambleOutput = _T("");
m_strLogLinePostambleInput = _T("");
m_strLogLinePostambleNotes = _T("");
m_bLogOutput = FALSE;
m_bLogHTML = FALSE;
m_bLogInColour = FALSE;
m_bLogRaw = FALSE;
//}}AFX_DATA_INIT
m_page_number = 1;
m_doc = NULL;
}
CPrefsP4::~CPrefsP4()
{
}
void CPrefsP4::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPrefsP4)
DDX_Control(pDX, IDC_LOG_FILE_POSTAMBLE, m_ctlPostamble);
DDX_Control(pDX, IDC_LOG_FILE_PREAMBLE, m_ctlPreamble);
DDX_Control(pDX, IDC_LOG_HTML, m_ctlLogHTML);
DDX_Control(pDX, IDC_LOG_FILE, m_ctlLogFileName);
DDX_Check(pDX, IDC_LOG_INPUT, m_log_input);
DDX_Check(pDX, IDC_LOG_NOTES, m_bLogNotes);
DDX_Text(pDX, IDC_LOG_FILE_PREAMBLE, m_strLogFilePreamble);
DDX_Text(pDX, IDC_LOG_FILE, m_strAutoLogFileName);
DDX_Check(pDX, IDC_WRITE_WORLD_NAME, m_bWriteWorldNameToLog);
DDX_Text(pDX, IDC_LINE_PREAMBLE_OUTPUT, m_strLogLinePreambleOutput);
DDX_Text(pDX, IDC_LINE_PREAMBLE_INPUT, m_strLogLinePreambleInput);
DDX_Text(pDX, IDC_LINE_PREAMBLE_NOTES, m_strLogLinePreambleNotes);
DDX_Text(pDX, IDC_LOG_FILE_POSTAMBLE, m_strLogFilePostamble);
DDX_Text(pDX, IDC_LINE_POSTAMBLE_OUTPUT, m_strLogLinePostambleOutput);
DDX_Text(pDX, IDC_LINE_POSTAMBLE_INPUT, m_strLogLinePostambleInput);
DDX_Text(pDX, IDC_LINE_POSTAMBLE_NOTES, m_strLogLinePostambleNotes);
DDX_Check(pDX, IDC_LOG_OUTPUT, m_bLogOutput);
DDX_Check(pDX, IDC_LOG_HTML, m_bLogHTML);
DDX_Check(pDX, IDC_LOG_COLOUR, m_bLogInColour);
DDX_Check(pDX, IDC_RAW_LOG, m_bLogRaw);
//}}AFX_DATA_MAP
if (pDX->m_bSaveAndValidate)
{
// check if output is not logged, sounds strange.
if (!m_bLogOutput && !m_bLogRaw)
if (::TMessageBox ("You are not logging output from the MUD - is this intentional?",
MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2)
!= IDYES)
pDX->Fail();
} // end of save and validate
}
BEGIN_MESSAGE_MAP(CPrefsP4, CPropertyPage)
//{{AFX_MSG_MAP(CPrefsP4)
ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
ON_BN_CLICKED(IDC_STANDARD_PREAMBLE, OnStandardPreamble)
ON_BN_CLICKED(IDC_EDIT_PREAMBLE, OnEditPreamble)
ON_BN_CLICKED(IDC_EDIT_POSTAMBLE, OnEditPostamble)
ON_BN_CLICKED(IDC_SUBSITUTION_HELP, OnSubsitutionHelp)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_KICKIDLE, OnKickIdle)
ON_UPDATE_COMMAND_UI(IDC_LOG_COLOUR, OnUpdateNeedHTML)
ON_UPDATE_COMMAND_UI(IDC_STANDARD_PREAMBLE, OnUpdateNeedHTML)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPrefsP4 message handlers
void CPrefsP4::OnBrowse()
{
CFileDialog dlg(FALSE, // FALSE for FileSave
"txt", // default extension
"",
OFN_HIDEREADONLY|OFN_PATHMUSTEXIST,
"Text files (*.txt)|*.txt||",
this);
dlg.m_ofn.lpstrTitle = "Log file name";
// use default log file directory
dlg.m_ofn.lpstrInitialDir = Make_Absolute_Path (App.m_strDefaultLogFileDirectory);
ChangeToFileBrowsingDirectory ();
int nResult = dlg.DoModal();
ChangeToStartupDirectory ();
if (nResult != IDOK)
return;
m_ctlLogFileName.SetWindowText (dlg.GetPathName());
}
LRESULT CPrefsP4::OnKickIdle(WPARAM, LPARAM)
{
UpdateDialogControls (AfxGetApp()->m_pMainWnd, false);
return 0;
} // end of CPrefsP4::OnKickIdle
void CPrefsP4::OnUpdateNeedHTML(CCmdUI* pCmdUI)
{
pCmdUI->Enable (m_ctlLogHTML.GetCheck () != FALSE);
} // end of CPrefsP4::OnUpdateNeedHTML
void CPrefsP4::OnStandardPreamble()
{
m_ctlPreamble.SetWindowText (
"<html>" NL
" <head>" NL
" <title>Log of %N session</title>" NL
" <style type=\"text/css\">" NL
" body {background-color: black;}" NL
" </style>" NL
" </head>" NL
" <body>" NL
" <pre><code>" NL
" <font size=2 face=\"FixedSys, Lucida Console, Courier New, Courier\">" NL
);
m_ctlPostamble.SetWindowText (
"</font></code></pre>" NL
"</body>" NL
"</html>" NL
);
}
void CPrefsP4::OnEditPreamble()
{
CEditMultiLine dlg;
dlg.m_strText = GetText (m_ctlPreamble);
dlg.m_strTitle = "Edit log file preamble";
if (dlg.DoModal () != IDOK)
return;
m_ctlPreamble.SetWindowText (dlg.m_strText);
}
void CPrefsP4::OnEditPostamble()
{
CEditMultiLine dlg;
dlg.m_strText = GetText (m_ctlPostamble);
dlg.m_strTitle = "Edit log file postamble";
if (dlg.DoModal () != IDOK)
return;
m_ctlPostamble.SetWindowText (dlg.m_strText);
}
void CPrefsP4::OnSubsitutionHelp()
{
CCreditsDlg dlg;
dlg.m_iResourceID = IDR_SUBSTITUTION;
dlg.m_strTitle = "Special characters";
dlg.DoModal ();
}
/////////////////////////////////////////////////////////////////////////////
// CPrefsP5 property page
IMPLEMENT_DYNCREATE(CPrefsP5, CPropertyPage)
CPrefsP5::CPrefsP5() : CPropertyPage(CPrefsP5::IDD)
{
//{{AFX_DATA_INIT(CPrefsP5)
m_bUseDefaultColours = FALSE;
m_bCustom16isDefaultColour = FALSE;
//}}AFX_DATA_INIT
m_page_number = 1;
m_doc = NULL;
m_prefsp3 = NULL;
}
CPrefsP5::~CPrefsP5()
{
}
void CPrefsP5::DoDataExchange(CDataExchange* pDX)
{
// check they really want to use defaults
if (pDX->m_bSaveAndValidate)
if (m_ctlUseDefaultColours.GetCheck ())
if (m_ctlUseDefaultColours.GetCheck () != m_bUseDefaultColours)
if (::TMessageBox ("By checking the option \"Override with default colours\" "
" your existing colours will be PERMANENTLY discarded next time you open this world.\n\n"
"Are you SURE you want to do this?",
MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2 ) != IDYES)
pDX->Fail ();
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPrefsP5)
DDX_Control(pDX, IDC_USE_DEFAULT_COLOURS, m_ctlUseDefaultColours);
DDX_Control(pDX, IDC_YELLOW_SWATCH_BOLD, m_ctlYellowSwatchBold);
DDX_Control(pDX, IDC_YELLOW_SWATCH, m_ctlYellowSwatch);
DDX_Control(pDX, IDC_WHITE_SWATCH_BOLD, m_ctlWhiteSwatchBold);
DDX_Control(pDX, IDC_WHITE_SWATCH, m_ctlWhiteSwatch);
DDX_Control(pDX, IDC_RED_SWATCH_BOLD, m_ctlRedSwatchBold);
DDX_Control(pDX, IDC_RED_SWATCH, m_ctlRedSwatch);
DDX_Control(pDX, IDC_MAGENTA_SWATCH_BOLD, m_ctlMagentaSwatchBold);
DDX_Control(pDX, IDC_MAGENTA_SWATCH, m_ctlMagentaSwatch);
DDX_Control(pDX, IDC_GREEN_SWATCH_BOLD, m_ctlGreenSwatchBold);
DDX_Control(pDX, IDC_GREEN_SWATCH, m_ctlGreenSwatch);
DDX_Control(pDX, IDC_CYAN_SWATCH_BOLD, m_ctlCyanSwatchBold);
DDX_Control(pDX, IDC_CYAN_SWATCH, m_ctlCyanSwatch);
DDX_Control(pDX, IDC_BLUE_SWATCH_BOLD, m_ctlBlueSwatchBold);
DDX_Control(pDX, IDC_BLUE_SWATCH, m_ctlBlueSwatch);
DDX_Control(pDX, IDC_BLACK_SWATCH_BOLD, m_ctlBlackSwatchBold);
DDX_Control(pDX, IDC_BLACK_SWATCH, m_ctlBlackSwatch);
DDX_Check(pDX, IDC_USE_DEFAULT_COLOURS, m_bUseDefaultColours);
DDX_Check(pDX, IDC_USE_CUSTOM_COLOUR_16, m_bCustom16isDefaultColour);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPrefsP5, CPropertyPage)
//{{AFX_MSG_MAP(CPrefsP5)
ON_BN_CLICKED(IDC_SAVE_COLOURS, OnSaveColours)
ON_BN_CLICKED(IDC_LOAD_COLOURS, OnLoadColours)
ON_BN_CLICKED(IDC_ANSI_COLOURS, OnAnsiColours)
ON_BN_CLICKED(IDC_BLACK_SWATCH, OnBlackSwatch)
ON_BN_CLICKED(IDC_RED_SWATCH, OnRedSwatch)
ON_BN_CLICKED(IDC_GREEN_SWATCH, OnGreenSwatch)
ON_BN_CLICKED(IDC_YELLOW_SWATCH, OnYellowSwatch)
ON_BN_CLICKED(IDC_BLUE_SWATCH, OnBlueSwatch)
ON_BN_CLICKED(IDC_MAGENTA_SWATCH, OnMagentaSwatch)
ON_BN_CLICKED(IDC_CYAN_SWATCH, OnCyanSwatch)
ON_BN_CLICKED(IDC_WHITE_SWATCH, OnWhiteSwatch)
ON_BN_CLICKED(IDC_BLACK_SWATCH_BOLD, OnBlackSwatchBold)
ON_BN_CLICKED(IDC_RED_SWATCH_BOLD, OnRedSwatchBold)
ON_BN_CLICKED(IDC_GREEN_SWATCH_BOLD, OnGreenSwatchBold)
ON_BN_CLICKED(IDC_YELLOW_SWATCH_BOLD, OnYellowSwatchBold)
ON_BN_CLICKED(IDC_BLUE_SWATCH_BOLD, OnBlueSwatchBold)
ON_BN_CLICKED(IDC_MAGENTA_SWATCH_BOLD, OnMagentaSwatchBold)
ON_BN_CLICKED(IDC_CYAN_SWATCH_BOLD, OnCyanSwatchBold)
ON_BN_CLICKED(IDC_WHITE_SWATCH_BOLD, OnWhiteSwatchBold)
ON_BN_CLICKED(IDC_SWAP, OnSwap)
ON_BN_CLICKED(IDC_NORMAL_LIGHTER, OnNormalLighter)
ON_BN_CLICKED(IDC_NORMAL_DARKER, OnNormalDarker)
ON_BN_CLICKED(IDC_BOLD_LIGHTER, OnBoldLighter)
ON_BN_CLICKED(IDC_BOLD_DARKER, OnBoldDarker)
ON_BN_CLICKED(IDC_ALL_LIGHTER, OnAllLighter)
ON_BN_CLICKED(IDC_ALL_DARKER, OnAllDarker)
ON_BN_CLICKED(IDC_ALL_MORE_COLOUR, OnAllMoreColour)
ON_BN_CLICKED(IDC_ALL_LESS_COLOUR, OnAllLessColour)
ON_BN_CLICKED(IDC_COPY_TO_CUSTOM, OnCopyToCustom)
ON_BN_CLICKED(IDC_INVERT, OnInvert)
ON_BN_CLICKED(IDC_RANDOM, OnRandom)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_KICKIDLE, OnKickIdle)
ON_UPDATE_COMMAND_UI(IDC_SWAP, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_LOAD_COLOURS, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_ANSI_COLOURS, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_BLACK_SWATCH, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_RED_SWATCH, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_GREEN_SWATCH, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_YELLOW_SWATCH, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_BLUE_SWATCH, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_MAGENTA_SWATCH, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_CYAN_SWATCH, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_WHITE_SWATCH, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_BLACK_SWATCH_BOLD, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_RED_SWATCH_BOLD, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_GREEN_SWATCH_BOLD, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_YELLOW_SWATCH_BOLD, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_BLUE_SWATCH_BOLD, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_MAGENTA_SWATCH_BOLD, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_CYAN_SWATCH_BOLD, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_WHITE_SWATCH_BOLD, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_USE_DEFAULT_COLOURS, OnUpdateHaveDefaults)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPrefsP5 message handlers
BOOL CPrefsP5::OnInitDialog()
{
CPropertyPage::OnInitDialog();
LoadSwatches ();
bool bEnable = !m_bUseDefaultColours ||
App.m_strDefaultColoursFile.IsEmpty ();
m_ctlYellowSwatchBold.EnableWindow (bEnable);
m_ctlYellowSwatch.EnableWindow (bEnable);
m_ctlWhiteSwatchBold.EnableWindow (bEnable);
m_ctlWhiteSwatch.EnableWindow (bEnable);
m_ctlRedSwatchBold.EnableWindow (bEnable);
m_ctlRedSwatch.EnableWindow (bEnable);
m_ctlMagentaSwatchBold.EnableWindow (bEnable);
m_ctlMagentaSwatch.EnableWindow (bEnable);
m_ctlGreenSwatchBold.EnableWindow (bEnable);
m_ctlGreenSwatch.EnableWindow (bEnable);
m_ctlCyanSwatchBold.EnableWindow (bEnable);
m_ctlCyanSwatch.EnableWindow (bEnable);
m_ctlBlueSwatchBold.EnableWindow (bEnable);
m_ctlBlueSwatch.EnableWindow (bEnable);
m_ctlBlackSwatchBold.EnableWindow (bEnable);
m_ctlBlackSwatch.EnableWindow (bEnable);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPrefsP5::OnOK()
{
SaveSwatches ();
CPropertyPage::OnOK();
}
BOOL CPrefsP5::OnKillActive()
{
SaveSwatches ();
return CPropertyPage::OnKillActive();
}
void CPrefsP5::amendcolour (CColourButton & whichcolour)
{
int i;
CColourPickerDlg dlg;
dlg.m_iColour = whichcolour.m_colour;
dlg.m_bPickColour = true;
/*
CColorDialog dlg (whichcolour.m_colour,
CC_RGBINIT | CC_FULLOPEN,
GetOwner());
*/
for (i = BLACK; i <= WHITE; i++)
{
dlg.m_iCustColour [i] = m_normalcolour [i];
dlg.m_iCustColour [i + 8] = m_boldcolour [i];
}
if (dlg.DoModal () != IDOK)
return;
whichcolour.m_colour = dlg.GetColor ();
whichcolour.RedrawWindow();
} // end of amendcolour
void CPrefsP5::OnAnsiColours()
{
if (::TMessageBox ("Reset all colours to the ANSI defaults?",
MB_YESNO | MB_ICONQUESTION) != IDYES)
return;
SetDefaultAnsiColours (m_normalcolour, m_boldcolour);
LoadSwatches ();
Invalidate (false);
}
void CPrefsP5::OnSaveColours()
{
// To save the colours we must copy the swatches back to our array
SaveSwatches ();
// and must copy the array to the document, as that is what "Save_Set" uses
// ansi colours
memcpy (m_doc->m_normalcolour, m_normalcolour, sizeof (m_doc->m_normalcolour));
memcpy (m_doc->m_boldcolour, m_boldcolour, sizeof (m_doc->m_boldcolour));
// custom colours
memcpy (m_doc->m_customtext, m_prefsp3->m_customtext, sizeof (m_doc->m_customtext));
memcpy (m_doc->m_customback, m_prefsp3->m_customback, sizeof (m_doc->m_customback));
// As we have now changed the document, we may as well redraw all views
// immediately
m_doc->UpdateAllViews (NULL);
// They can no longer cancel the propery sheet, the document has changed
CancelToClose ();
// save the colours
if (m_doc->Save_Set (COLOUR, this))
return;
}
void CPrefsP5::OnLoadColours()
{
if (m_doc->Load_Set (COLOUR, "", this))
return;
memcpy (m_normalcolour, m_doc->m_normalcolour, sizeof (m_normalcolour));
memcpy (m_boldcolour, m_doc->m_boldcolour, sizeof (m_boldcolour));
memcpy (m_prefsp3->m_customtext, m_doc->m_customtext, sizeof (m_prefsp3->m_customtext));
memcpy (m_prefsp3->m_customback, m_doc->m_customback, sizeof (m_prefsp3->m_customback));
LoadSwatches ();
Invalidate (); // redraw swatches
UpdateData (FALSE);
// As we have now changed the document, we may as well redraw all views
// immediately
m_doc->UpdateAllViews (NULL);
// They can no longer cancel the propery sheet, the document has changed
CancelToClose ();
}
void CPrefsP5::OnBlackSwatch()
{
amendcolour (m_ctlBlackSwatch);
}
void CPrefsP5::OnRedSwatch()
{
amendcolour (m_ctlRedSwatch);
}
void CPrefsP5::OnGreenSwatch()
{
amendcolour (m_ctlGreenSwatch);
}
void CPrefsP5::OnYellowSwatch()
{
amendcolour (m_ctlYellowSwatch);
}
void CPrefsP5::OnBlueSwatch()
{
amendcolour (m_ctlBlueSwatch);
}
void CPrefsP5::OnMagentaSwatch()
{
amendcolour (m_ctlMagentaSwatch);
}
void CPrefsP5::OnCyanSwatch()
{
amendcolour (m_ctlCyanSwatch);
}
void CPrefsP5::OnWhiteSwatch()
{
amendcolour (m_ctlWhiteSwatch);
}
void CPrefsP5::OnBlackSwatchBold()
{
amendcolour (m_ctlBlackSwatchBold);
}
void CPrefsP5::OnRedSwatchBold()
{
amendcolour (m_ctlRedSwatchBold);
}
void CPrefsP5::OnGreenSwatchBold()
{
amendcolour (m_ctlGreenSwatchBold);
}
void CPrefsP5::OnYellowSwatchBold()
{
amendcolour (m_ctlYellowSwatchBold);
}
void CPrefsP5::OnBlueSwatchBold()
{
amendcolour (m_ctlBlueSwatchBold);
}
void CPrefsP5::OnMagentaSwatchBold()
{
amendcolour (m_ctlMagentaSwatchBold);
}
void CPrefsP5::OnCyanSwatchBold()
{
amendcolour (m_ctlCyanSwatchBold);
}
void CPrefsP5::OnWhiteSwatchBold()
{
amendcolour (m_ctlWhiteSwatchBold);
}
void CPrefsP5::OnSwap()
{
COLORREF oldColours [8];
// To swap the colours we must copy the swatches back to our array
SaveSwatches ();
// save normal ones
oldColours [BLACK] = m_normalcolour [BLACK] ;
oldColours [BLUE] = m_normalcolour [BLUE] ;
oldColours [CYAN] = m_normalcolour [CYAN] ;
oldColours [GREEN] = m_normalcolour [GREEN] ;
oldColours [MAGENTA]= m_normalcolour [MAGENTA] ;
oldColours [RED] = m_normalcolour [RED] ;
oldColours [WHITE] = m_normalcolour [WHITE] ;
oldColours [YELLOW] = m_normalcolour [YELLOW] ;
// make normal bold
m_normalcolour [BLACK] = m_boldcolour [BLACK];
m_normalcolour [BLUE] = m_boldcolour [BLUE] ;
m_normalcolour [CYAN] = m_boldcolour [CYAN] ;
m_normalcolour [GREEN] = m_boldcolour [GREEN];
m_normalcolour [MAGENTA] = m_boldcolour [MAGENTA];
m_normalcolour [RED] = m_boldcolour [RED] ;
m_normalcolour [WHITE] = m_boldcolour [WHITE] ;
m_normalcolour [YELLOW] = m_boldcolour [YELLOW] ;
// and make bold normal
m_boldcolour [BLACK] = oldColours [BLACK];
m_boldcolour [BLUE] = oldColours [BLUE] ;
m_boldcolour [CYAN] = oldColours [CYAN] ;
m_boldcolour [GREEN] = oldColours [GREEN];
m_boldcolour [MAGENTA] = oldColours [MAGENTA];
m_boldcolour [RED] = oldColours [RED] ;
m_boldcolour [WHITE] = oldColours [WHITE] ;
m_boldcolour [YELLOW] = oldColours [YELLOW] ;
LoadSwatches ();
Invalidate (false);
}
void CPrefsP5::SaveSwatches(void)
{
// ansi colours
m_normalcolour [BLACK] = m_ctlBlackSwatch.m_colour ;
m_normalcolour [BLUE] = m_ctlBlueSwatch.m_colour ;
m_normalcolour [CYAN] = m_ctlCyanSwatch.m_colour ;
m_normalcolour [GREEN] = m_ctlGreenSwatch.m_colour ;
m_normalcolour [MAGENTA] = m_ctlMagentaSwatch.m_colour ;
m_normalcolour [RED] = m_ctlRedSwatch.m_colour ;
m_normalcolour [WHITE] = m_ctlWhiteSwatch.m_colour ;
m_normalcolour [YELLOW] = m_ctlYellowSwatch.m_colour ;
m_boldcolour [BLACK] = m_ctlBlackSwatchBold.m_colour ;
m_boldcolour [BLUE] = m_ctlBlueSwatchBold.m_colour ;
m_boldcolour [CYAN] = m_ctlCyanSwatchBold.m_colour ;
m_boldcolour [GREEN] = m_ctlGreenSwatchBold.m_colour ;
m_boldcolour [MAGENTA] = m_ctlMagentaSwatchBold.m_colour;
m_boldcolour [RED] = m_ctlRedSwatchBold.m_colour ;
m_boldcolour [WHITE] = m_ctlWhiteSwatchBold.m_colour ;
m_boldcolour [YELLOW] = m_ctlYellowSwatchBold.m_colour ;
m_bUseDefaultColours = m_ctlUseDefaultColours.GetCheck ();
}
void CPrefsP5::LoadSwatches(void)
{
// ansi colours
m_ctlBlackSwatch.m_colour = m_normalcolour [BLACK];
m_ctlBlueSwatch.m_colour = m_normalcolour [BLUE];
m_ctlCyanSwatch.m_colour = m_normalcolour [CYAN];
m_ctlGreenSwatch.m_colour = m_normalcolour [GREEN];
m_ctlMagentaSwatch.m_colour = m_normalcolour [MAGENTA];
m_ctlRedSwatch.m_colour = m_normalcolour [RED];
m_ctlWhiteSwatch.m_colour = m_normalcolour [WHITE];
m_ctlYellowSwatch.m_colour = m_normalcolour [YELLOW];
m_ctlBlackSwatchBold.m_colour = m_boldcolour [BLACK];
m_ctlBlueSwatchBold.m_colour = m_boldcolour [BLUE];
m_ctlCyanSwatchBold.m_colour = m_boldcolour [CYAN];
m_ctlGreenSwatchBold.m_colour = m_boldcolour [GREEN];
m_ctlMagentaSwatchBold.m_colour = m_boldcolour [MAGENTA];
m_ctlRedSwatchBold.m_colour = m_boldcolour [RED];
m_ctlWhiteSwatchBold.m_colour = m_boldcolour [WHITE];
m_ctlYellowSwatchBold.m_colour = m_boldcolour [YELLOW];
}
void CPrefsP5::OnNormalLighter()
{
SaveSwatches ();
for (int i = BLACK; i <= WHITE; i++)
m_normalcolour [i] = ::AdjustColour (m_normalcolour [i], ADJUST_COLOUR_LIGHTER);
LoadSwatches ();
Invalidate (false);
}
void CPrefsP5::OnNormalDarker()
{
SaveSwatches ();
for (int i = BLACK; i <= WHITE; i++)
m_normalcolour [i] = ::AdjustColour (m_normalcolour [i], ADJUST_COLOUR_DARKER);
LoadSwatches ();
Invalidate (false);
}
void CPrefsP5::OnBoldLighter()
{
SaveSwatches ();
for (int i = BLACK; i <= WHITE; i++)
m_boldcolour [i] = ::AdjustColour (m_boldcolour [i], ADJUST_COLOUR_LIGHTER);
LoadSwatches ();
Invalidate (false);
}
void CPrefsP5::OnBoldDarker()
{
SaveSwatches ();
for (int i = BLACK; i <= WHITE; i++)
m_boldcolour [i] = ::AdjustColour (m_boldcolour [i], ADJUST_COLOUR_DARKER);
LoadSwatches ();
Invalidate (false);
}
void CPrefsP5::OnAllLighter()
{
OnNormalLighter ();
OnBoldLighter ();
}
void CPrefsP5::OnAllDarker()
{
OnNormalDarker ();
OnBoldDarker ();
}
void CPrefsP5::OnAllMoreColour()
{
SaveSwatches ();
for (int i = BLACK; i <= WHITE; i++)
{
m_normalcolour [i] = ::AdjustColour (m_normalcolour [i], ADJUST_COLOUR_MORE_COLOUR);
m_boldcolour [i] = ::AdjustColour (m_boldcolour [i], ADJUST_COLOUR_MORE_COLOUR);
}
LoadSwatches ();
Invalidate (false);
}
void CPrefsP5::OnAllLessColour()
{
SaveSwatches ();
for (int i = BLACK; i <= WHITE; i++)
{
m_normalcolour [i] = ::AdjustColour (m_normalcolour [i], ADJUST_COLOUR_LESS_COLOUR);
m_boldcolour [i] = ::AdjustColour (m_boldcolour [i], ADJUST_COLOUR_LESS_COLOUR);
}
LoadSwatches ();
Invalidate (false);
}
LRESULT CPrefsP5::OnKickIdle(WPARAM, LPARAM)
{
UpdateDialogControls (AfxGetApp()->m_pMainWnd, false);
return 0;
} // end of CPrefsP5::OnKickIdle
void CPrefsP5::OnUpdateNotUsingDefaults(CCmdUI* pCmdUI)
{
pCmdUI->Enable (m_ctlUseDefaultColours.GetCheck () == 0 ||
App.m_strDefaultColoursFile.IsEmpty ());
} // end of CPrefsP5::OnUpdateNotUsingDefaults
void CPrefsP5::OnUpdateHaveDefaults(CCmdUI* pCmdUI)
{
pCmdUI->Enable (!App.m_strDefaultColoursFile.IsEmpty ());
} // end of CPrefsP5::OnUpdateHaveDefaults
void CPrefsP5::OnCopyToCustom()
{
if (::TMessageBox ("Copy all 16 colours to the custom colours?",
MB_YESNO | MB_ICONQUESTION) != IDYES)
return;
SaveSwatches ();
m_prefsp3->m_customtext [0] = m_normalcolour [0];
m_prefsp3->m_customtext [1] = m_normalcolour [1];
m_prefsp3->m_customtext [2] = m_normalcolour [2];
m_prefsp3->m_customtext [3] = m_normalcolour [3];
m_prefsp3->m_customtext [4] = m_normalcolour [4];
m_prefsp3->m_customtext [5] = m_normalcolour [5];
m_prefsp3->m_customtext [6] = m_normalcolour [6];
m_prefsp3->m_customtext [7] = m_normalcolour [7];
m_prefsp3->m_customtext [8] = m_boldcolour [0];
m_prefsp3->m_customtext [9] = m_boldcolour [1];
m_prefsp3->m_customtext [10] = m_boldcolour [2];
m_prefsp3->m_customtext [11] = m_boldcolour [3];
m_prefsp3->m_customtext [12] = m_boldcolour [4];
m_prefsp3->m_customtext [13] = m_boldcolour [5];
m_prefsp3->m_customtext [14] = m_boldcolour [6];
m_prefsp3->m_customtext [15] = m_boldcolour [7];
for (int i = 0; i < 16; i++)
m_prefsp3->m_customback [i] = RGB (0, 0, 0); // black backgrounds
m_prefsp3->LoadSwatches ();
}
void CPrefsP5::OnInvert()
{
SaveSwatches ();
for (int i = BLACK; i <= WHITE; i++)
{
m_normalcolour [i] = ::AdjustColour (m_normalcolour [i], ADJUST_COLOUR_INVERT);
m_boldcolour [i] = ::AdjustColour (m_boldcolour [i], ADJUST_COLOUR_INVERT);
}
LoadSwatches ();
Invalidate (false);
}
void CPrefsP5::OnRandom()
{
if (::TMessageBox ("Make all colours random?",
MB_YESNO | MB_ICONQUESTION) != IDYES)
return;
for (int i = BLACK; i <= WHITE; i++)
{
m_normalcolour [i] = genrand () * (double) 0x1000000;
m_boldcolour [i] = genrand () * (double) 0x1000000;
}
LoadSwatches ();
Invalidate (false);
}
CString strMacroDescriptions [MACRO_COUNT] = {
"up",
"down",
"north",
"south",
"east",
"west",
"examine",
"look",
"page",
"say",
"whisper",
"doing",
"who",
"drop",
"take",
"F2",
"F3",
"F4",
"F5",
"F7",
"F8",
"F9",
"F10",
"F11",
"F12",
"F2+Shift",
"F3+Shift",
"F4+Shift",
"F5+Shift",
"F6+Shift",
"F7+Shift",
"F8+Shift",
"F9+Shift",
"F10+Shift",
"F11+Shift",
"F12+Shift",
"F2+Ctrl",
"F3+Ctrl",
"F5+Ctrl",
"F7+Ctrl",
"F8+Ctrl",
"F9+Ctrl",
"F10+Ctrl",
"F11+Ctrl",
"F12+Ctrl",
"logout",
"quit",
// new ones in v 3.42
"Alt+A",
"Alt+B",
"Alt+J",
"Alt+K",
"Alt+L",
"Alt+M",
"Alt+N",
"Alt+O",
"Alt+P",
"Alt+Q",
"Alt+R",
"Alt+S",
"Alt+T",
"Alt+U",
"Alt+X",
"Alt+Y",
"Alt+Z",
// new ones in v 3.44
"F1",
"F1+Ctrl",
"F1+Shift",
"F6",
"F6+Ctrl"
};
CString strKeypadNames [eKeypad_Max_Items] =
{
// normal
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
".",
"/",
"*",
"-",
"+",
// ctrl
"Ctrl+0",
"Ctrl+1",
"Ctrl+2",
"Ctrl+3",
"Ctrl+4",
"Ctrl+5",
"Ctrl+6",
"Ctrl+7",
"Ctrl+8",
"Ctrl+9",
"Ctrl+.",
"Ctrl+/",
"Ctrl+*",
"Ctrl+-",
"Ctrl++"
};
/////////////////////////////////////////////////////////////////////////////
// CPrefsP6 property page
IMPLEMENT_DYNCREATE(CPrefsP6, CPropertyPage)
CPrefsP6::CPrefsP6() : CPropertyPage(CPrefsP6::IDD)
{
//{{AFX_DATA_INIT(CPrefsP6)
m_bUseDefaultMacros = FALSE;
//}}AFX_DATA_INIT
m_page_number = 1;
m_pMacrosFindInfo = NULL;
m_doc = NULL;
// default to sorting in name order
m_last_col = eColumnName;
m_reverse = FALSE;
}
CPrefsP6::~CPrefsP6()
{
}
void CPrefsP6::DoDataExchange(CDataExchange* pDX)
{
// check they really want to use defaults
if (pDX->m_bSaveAndValidate)
if (m_ctlUseDefaultMacros.GetCheck ())
if (m_ctlUseDefaultMacros.GetCheck () != m_bUseDefaultMacros)
if (::TMessageBox ("By checking the option \"Override with default macros\" "
" your existing macros will be PERMANENTLY discarded next time you open this world.\n\n"
"Are you SURE you want to do this?",
MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2 ) != IDYES)
pDX->Fail ();
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPrefsP6)
DDX_Control(pDX, IDC_USE_DEFAULT_MACROS, m_ctlUseDefaultMacros);
DDX_Control(pDX, IDC_MACROS_LIST, m_ctlMacroList);
DDX_Check(pDX, IDC_USE_DEFAULT_MACROS, m_bUseDefaultMacros);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPrefsP6, CPropertyPage)
//{{AFX_MSG_MAP(CPrefsP6)
ON_BN_CLICKED(IDC_EDIT_MACRO, OnEditMacro)
ON_NOTIFY(NM_DBLCLK, IDC_MACROS_LIST, OnDblclkMacrosList)
ON_NOTIFY(LVN_COLUMNCLICK, IDC_MACROS_LIST, OnColumnclickMacrosList)
ON_BN_CLICKED(IDC_LOAD_MACRO, OnLoadMacro)
ON_BN_CLICKED(IDC_SAVE_MACRO, OnSaveMacro)
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_FIND, OnFind)
ON_BN_CLICKED(IDC_FIND_NEXT, OnFindNext)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_KICKIDLE, OnKickIdle)
ON_UPDATE_COMMAND_UI(IDC_EDIT_MACRO, OnUpdateNeedSelection)
ON_UPDATE_COMMAND_UI(IDC_SAVE_MACRO, OnUpdateNeedEntries)
ON_UPDATE_COMMAND_UI(IDC_LOAD_MACRO, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_USE_DEFAULT_MACROS, OnUpdateHaveDefaults)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPrefsP6 message handlers
void CPrefsP6::OnEditMacro()
{
// don't do it if they are using defaults
if (m_ctlUseDefaultMacros.GetCheck () != 0 &&
!App.m_strDefaultMacrosFile.IsEmpty ())
return;
for (int nItem = -1;
(nItem = m_ctlMacroList.GetNextItem(nItem, LVNI_SELECTED)) != -1;)
{
int subscript = m_ctlMacroList.GetItemData (nItem);
CEditMacro dlg;
dlg.m_macro_desc = strMacroDescriptions [subscript];
dlg.m_macro = m_macros [subscript];
dlg.m_macro_type = m_macro_type [subscript];
dlg.m_strTitle = "Edit macro " + strMacroDescriptions [subscript];
if (dlg.DoModal () != IDOK)
continue;
m_macros [subscript] = dlg.m_macro;
m_macro_type [subscript] = dlg.m_macro_type;
switch (m_macro_type [subscript])
{
case REPLACE_COMMAND: m_macro_type_alpha [subscript] = "Replace";
break;
case SEND_NOW: m_macro_type_alpha [subscript] = "Send now";
break;
case ADD_TO_COMMAND: m_macro_type_alpha [subscript] = "Insert";
break;
default: m_macro_type_alpha [subscript] = "Unknown";
break;
} // end of switch
// re-setup list with amended details
m_ctlMacroList.SetItemText(nItem, eColumnText,
Replace (m_macros [subscript], ENDLINE, "\\n", true));
m_ctlMacroList.SetItemText(nItem, eColumnAction, m_macro_type_alpha [subscript]);
m_ctlMacroList.RedrawItems (nItem, nItem);
}
}
void CPrefsP6::OnDblclkMacrosList(NMHDR* pNMHDR, LRESULT* pResult)
{
OnEditMacro ();
*pResult = 1;
}
typedef struct
{
CPrefsP6 * dlg;
int sortkey;
int reverse;
} t_p6_sort_param;
int CALLBACK CPrefsP6::CompareFunc ( LPARAM lParam1,
LPARAM lParam2,
LPARAM lParamSort)
{
t_p6_sort_param * psort_param = (t_p6_sort_param *) lParamSort;
int iResult;
switch (psort_param->sortkey) // which sort key
{
case eColumnName: iResult = strMacroDescriptions [lParam1].CompareNoCase
(strMacroDescriptions [lParam2]); break;
case eColumnText: iResult = psort_param->dlg->m_macros [lParam1].CompareNoCase
(psort_param->dlg->m_macros [lParam2]); break;
case eColumnAction: iResult = psort_param->dlg->m_macro_type_alpha [lParam1].CompareNoCase
(psort_param->dlg->m_macro_type_alpha [lParam2]); break;
default: return 0;
} // end of switch
// if reverse sort wanted, reverse sense of result
if (psort_param->reverse)
iResult *= -1;
return iResult;
} // end of CompareFunc
void CPrefsP6::OnColumnclickMacrosList(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
int col = pNMListView->iSubItem;
if (col == m_last_col)
m_reverse = !m_reverse;
else
m_reverse = FALSE;
m_last_col = col;
t_p6_sort_param sort_param;
sort_param.dlg = this;
sort_param.sortkey = m_last_col;
sort_param.reverse = m_reverse;
m_ctlMacroList.SortItems (CompareFunc, (LPARAM) &sort_param);
*pResult = 0;
}
void CPrefsP6::OnLoadMacro()
{
int i;
if (m_doc->Load_Set (MACRO, "", this))
return;
for (i = 0; i < NUMITEMS (m_doc->m_macros); i++)
{
m_macros [i] = m_doc->m_macros [i];
m_macro_type [i] = m_doc->m_macro_type [i];
switch (m_doc->m_macro_type [i])
{
case REPLACE_COMMAND: m_macro_type_alpha [i] = "Replace";
break;
case SEND_NOW: m_macro_type_alpha [i] = "Send now";
break;
case ADD_TO_COMMAND: m_macro_type_alpha [i] = "Insert";
break;
default: m_macro_type_alpha [i] = "Unknown";
break;
} // end of switch
}
load_list ();
CancelToClose (); // this change is irrevocable
}
void CPrefsP6::OnSaveMacro()
{
if (m_doc->Save_Set (MACRO, this))
return;
}
void CPrefsP6::load_list (void)
{
m_ctlMacroList.DeleteAllItems ();
BYTE fVirt;
WORD key;
// Item data
int nInsertItem = 0;
for (int nItem = 0; nItem < NUMITEMS (strMacroDescriptions); nItem++)
{
// extra code for version 3.53 - don't show in list if it is an accelerator
try
{
const char * sKey = strMacroDescriptions [nItem];
// all lower-case words (like north, quit etc.) won't be keycodes
bool bLower = true;
for (const char * p = sKey; *p; p++)
if (!islower (*p))
bLower = false;
if (bLower)
{
fVirt = 0; // won't be in list
key = 0;
}
else
StringToKeyCode (sKey, fVirt, key);
}
catch (CException* e)
{
e->Delete ();
fVirt = 0; // won't be in list
key = 0;
} // end of catch
fVirt |= FNOINVERT; // no inverting of menus
// make a flags/keystroke combination
long virt_plus_key = ((long) fVirt) << 16 | key;
// see if we have allocated that accelerator
map<long, WORD>::const_iterator it = m_doc->m_AcceleratorToCommandMap.find (virt_plus_key);
if (it != m_doc->m_AcceleratorToCommandMap.end ())
continue;
m_ctlMacroList.InsertItem (nInsertItem, strMacroDescriptions [nItem]); // eColumnName
m_ctlMacroList.SetItemText(nInsertItem, eColumnText,
Replace (m_macros [nItem], ENDLINE, "\\n", true));
m_ctlMacroList.SetItemText(nInsertItem, eColumnAction, m_macro_type_alpha [nItem]);
m_ctlMacroList.SetItemData(nInsertItem, nItem);
nInsertItem++;
} // end of inserting items
t_p6_sort_param sort_param;
sort_param.dlg = this;
sort_param.sortkey = m_last_col;
sort_param.reverse = m_reverse;
m_ctlMacroList.SortItems (CompareFunc, (LPARAM) &sort_param);
// set the 1st item to be selected - we do this here because sorting the
// list means our first item is not necessarily the 1st item in the list
m_ctlMacroList.SetItemState (0, LVIS_FOCUSED | LVIS_SELECTED,
LVIS_FOCUSED | LVIS_SELECTED);
} // end of load_list
BOOL CPrefsP6::OnInitDialog()
{
CPropertyPage::OnInitDialog();
int iColOrder [eColumnCount] = {0, 1, 2},
iColWidth [eColumnCount] = {100, 180, 0};
RECT rect;
m_ctlMacroList.GetClientRect (&rect);
iColWidth [eColumnAction] = rect.right - rect.left - // get width of control
GetSystemMetrics (SM_CXVSCROLL) - // minus vertical scroll bar
iColWidth [eColumnName] -
iColWidth [eColumnText] ; // minus width of other items
App.RestoreColumnConfiguration ("Macro List", eColumnCount, m_ctlMacroList,
iColOrder, iColWidth, m_last_col, m_reverse);
m_ctlMacroList.InsertColumn(0, TranslateHeading ("Macro name"), LVCFMT_LEFT, iColWidth [eColumnName]);
m_ctlMacroList.InsertColumn(1, TranslateHeading ("Text"), LVCFMT_LEFT, iColWidth [eColumnText]);
m_ctlMacroList.InsertColumn(2, TranslateHeading ("Action"), LVCFMT_LEFT, iColWidth [eColumnAction]);
// recover column sequence
m_ctlMacroList.SendMessage (LVM_SETCOLUMNORDERARRAY, eColumnCount, (DWORD) iColOrder);
load_list ();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPrefsP6::OnDestroy()
{
App.SaveColumnConfiguration ("Macro List", eColumnCount, m_ctlMacroList, m_last_col, m_reverse);
CPropertyPage::OnDestroy();
}
LRESULT CPrefsP6::OnKickIdle(WPARAM, LPARAM)
{
UpdateDialogControls (AfxGetApp()->m_pMainWnd, false);
return 0;
} // end of CPrefsP6::OnKickIdle
void CPrefsP6::OnUpdateNeedSelection(CCmdUI* pCmdUI)
{
pCmdUI->Enable (m_ctlMacroList.GetSelectedCount () != 0 &&
(m_ctlUseDefaultMacros.GetCheck () == 0 ||
App.m_strDefaultMacrosFile.IsEmpty ()));
} // end of CPrefsP6::OnUpdateNeedSelection
void CPrefsP6::OnUpdateNeedEntries(CCmdUI* pCmdUI)
{
pCmdUI->Enable (m_ctlMacroList.GetItemCount () != 0);
} // end of CPrefsP6::OnUpdateNeedEntries
void CPrefsP6::OnUpdateNotUsingDefaults(CCmdUI* pCmdUI)
{
pCmdUI->Enable (m_ctlUseDefaultMacros.GetCheck () == 0 ||
App.m_strDefaultMacrosFile.IsEmpty ());
} // end of CPrefsP6::OnUpdateNotUsingDefaults
void CPrefsP6::OnUpdateHaveDefaults(CCmdUI* pCmdUI)
{
pCmdUI->Enable (!App.m_strDefaultMacrosFile.IsEmpty ());
} // end of CPrefsP6::OnUpdateHaveDefaults
void CPrefsP6::OnFind()
{
DoFind (false);
}
void CPrefsP6::OnFindNext()
{
DoFind (true);
}
void CPrefsP6::DoFind (bool bAgain)
{
m_pMacrosFindInfo->m_bAgain = bAgain;
m_pMacrosFindInfo->m_nTotalLines = m_ctlMacroList.GetItemCount ();
bool found = FindRoutine (&m_ctlMacroList, // passed back to callback routines
*m_pMacrosFindInfo, // finding structure
InitiateSearch, // how to re-initiate a find
GetNextLine); // get the next line
// unselect everything first
for (int i = 0; i < m_ctlMacroList.GetItemCount (); i++)
m_ctlMacroList.SetItemState (i, 0, LVIS_FOCUSED | LVIS_SELECTED);
if (found)
{
m_ctlMacroList.SetItemState (m_pMacrosFindInfo->m_nCurrentLine,
LVIS_FOCUSED | LVIS_SELECTED,
LVIS_FOCUSED | LVIS_SELECTED);
m_ctlMacroList.EnsureVisible (m_pMacrosFindInfo->m_nCurrentLine, false);
m_ctlMacroList.RedrawItems (m_pMacrosFindInfo->m_nCurrentLine,
m_pMacrosFindInfo->m_nCurrentLine);
}
} // end of CPrefsP6::DoFind
void CPrefsP6::InitiateSearch (const CObject * pObject,
CFindInfo & FindInfo)
{
CListCtrl* pList = (CListCtrl*) pObject;
if (FindInfo.m_bAgain)
FindInfo.m_pFindPosition = (POSITION) FindInfo.m_nCurrentLine;
else
if (FindInfo.m_bForwards)
FindInfo.m_pFindPosition = 0;
else
FindInfo.m_pFindPosition = (POSITION) pList->GetItemCount () - 1;
} // end of CPrefsP6::InitiateSearch
bool CPrefsP6::GetNextLine (const CObject * pObject,
CFindInfo & FindInfo,
CString & strLine)
{
CListCtrl* pList = (CListCtrl*) pObject;
if ((long) FindInfo.m_pFindPosition < 0 ||
(long) FindInfo.m_pFindPosition >= pList->GetItemCount ())
return true;
strLine = pList->GetItemText((long) FindInfo.m_pFindPosition, eColumnName);
strLine += '\t';
strLine += pList->GetItemText((long) FindInfo.m_pFindPosition, eColumnText);
strLine += '\t';
strLine += pList->GetItemText((long) FindInfo.m_pFindPosition, eColumnAction);
if (FindInfo.m_bForwards)
FindInfo.m_pFindPosition++;
else
FindInfo.m_pFindPosition--;
return false;
} // end of CPrefsP6::GetNextLine
/////////////////////////////////////////////////////////////////////////////
// CPrefsP7 property page
IMPLEMENT_DYNCREATE(CPrefsP7, CGenPropertyPage)
CPrefsP7::CPrefsP7() : CGenPropertyPage(CPrefsP7::IDD)
{
//{{AFX_DATA_INIT(CPrefsP7)
m_enable_aliases = FALSE;
m_bUseDefaultAliases = FALSE;
//}}AFX_DATA_INIT
m_doc = NULL;
m_last_col = eColumnSequence;
m_reverse = false;
}
CPrefsP7::~CPrefsP7()
{
}
void CPrefsP7::DoDataExchange(CDataExchange* pDX)
{
// check they really want to use defaults
if (pDX->m_bSaveAndValidate)
if (m_ctlUseDefaultAliases.GetCheck ())
if (m_ctlUseDefaultAliases.GetCheck () != m_bUseDefaultAliases)
if (m_doc->m_AliasMap.GetCount () > 0)
if (::UMessageBox (TFormat ("By checking the option \"Override with default aliases\" "
" your existing %i aliase(s) will be PERMANENTLY discarded next time you open this world.\n\n"
"Are you SURE you want to do this?", m_doc->m_AliasMap.GetCount ()),
MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2 ) != IDYES)
pDX->Fail ();
CGenPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPrefsP7)
DDX_Control(pDX, IDC_COUNT, m_ctlSummary);
DDX_Control(pDX, IDC_FILTER, m_ctlFilter);
DDX_Control(pDX, IDC_USE_DEFAULT_ALIASES, m_ctlUseDefaultAliases);
DDX_Control(pDX, IDC_ALIASES_LIST, m_ctlAliasList);
DDX_Check(pDX, IDC_ENABLE_ALIASES, m_enable_aliases);
DDX_Check(pDX, IDC_USE_DEFAULT_ALIASES, m_bUseDefaultAliases);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPrefsP7, CGenPropertyPage)
//{{AFX_MSG_MAP(CPrefsP7)
ON_BN_CLICKED(IDC_ADD_ALIAS, OnAddAlias)
ON_BN_CLICKED(IDC_CHANGE_ALIAS, OnChangeAlias)
ON_BN_CLICKED(IDC_DELETE_ALIAS, OnDeleteAlias)
ON_NOTIFY(NM_DBLCLK, IDC_ALIASES_LIST, OnDblclkAliasesList)
ON_NOTIFY(LVN_COLUMNCLICK, IDC_ALIASES_LIST, OnColumnclickAliasesList)
ON_BN_CLICKED(IDC_LOAD_ALIAS, OnLoadAlias)
ON_BN_CLICKED(IDC_SAVE_ALIAS, OnSaveAlias)
ON_BN_CLICKED(IDC_COPY, OnCopy)
ON_BN_CLICKED(IDC_PASTE, OnPaste)
ON_BN_CLICKED(IDC_MOVE_UP, OnMoveUp)
ON_BN_CLICKED(IDC_MOVE_DOWN, OnMoveDown)
ON_BN_CLICKED(IDC_FILTER, OnFilter)
ON_BN_CLICKED(IDC_EDIT_FILTER, OnEditFilter)
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_FIND, OnFind)
ON_BN_CLICKED(IDC_FIND_NEXT, OnFindNext)
ON_UPDATE_COMMAND_UI(IDC_COPY, OnUpdateNeedSelection)
ON_UPDATE_COMMAND_UI(IDC_PASTE, OnUpdateNeedXMLClipboard)
ON_UPDATE_COMMAND_UI(IDC_CHANGE_ALIAS, OnUpdateNeedOneSelection)
ON_UPDATE_COMMAND_UI(IDC_DELETE_ALIAS, OnUpdateNeedSelection)
ON_UPDATE_COMMAND_UI(IDC_SAVE_ALIAS, OnUpdateNeedEntries)
ON_UPDATE_COMMAND_UI(IDC_FIND, OnUpdateNeedEntries)
ON_UPDATE_COMMAND_UI(IDC_FIND_NEXT, OnUpdateNeedEntries)
ON_UPDATE_COMMAND_UI(IDC_ADD_ALIAS, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_LOAD_ALIAS, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_USE_DEFAULT_ALIASES, OnUpdateHaveDefaults)
ON_UPDATE_COMMAND_UI(IDC_MOVE_UP, OnUpdateCanSequence)
ON_UPDATE_COMMAND_UI(IDC_MOVE_DOWN, OnUpdateCanSequence)
ON_NOTIFY(NM_DBLCLK, ID_TREEVIEW, OnDblclkAliasesList)
ON_BN_CLICKED(ID_USE_TREEVIEW, OnUseTreeViewChecked)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPrefsP7 message handlers
void CPrefsP7::InitDialog (CDialog * pDlg)
{
CAliasDlg * dlg = (CAliasDlg *) pDlg;
ASSERT_VALID (dlg);
ASSERT( dlg->IsKindOf( RUNTIME_CLASS( CAliasDlg ) ) );
dlg->m_pDoc = m_doc;
dlg->m_bIgnoreCase = m_doc->m_bDefaultAliasIgnoreCase;
dlg->m_bEnabled = TRUE;
dlg->m_bExpandVariables = m_doc->m_bDefaultAliasExpandVariables;
dlg->m_bOmitFromLogFile = FALSE;
dlg->m_bRegexp = m_doc->m_bDefaultAliasRegexp;
dlg->m_iSequence = m_doc->m_iDefaultAliasSequence;
dlg->m_bKeepEvaluating = m_doc->m_bDefaultAliasKeepEvaluating;
dlg->m_bOneShot = FALSE;
dlg->m_bEchoAlias = FALSE;
dlg->m_bOmitFromCommandHistory = FALSE;
dlg->m_bTemporary = FALSE;
// dlg->m_bDelayed = FALSE;
dlg->m_iSendTo = m_doc->m_iDefaultAliasSendTo;
dlg->m_pAliasMap = &m_doc->m_AliasMap;
dlg->m_current_alias = NULL;
} // end of CPrefsP7::InitDialog
void CPrefsP7::LoadDialog (CDialog * pDlg, CObject * pItem)
{
CAliasDlg * dlg = (CAliasDlg *) pDlg;
CAlias * alias_item = (CAlias *) pItem;
ASSERT_VALID (dlg);
ASSERT( dlg->IsKindOf( RUNTIME_CLASS( CAliasDlg ) ) );
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
dlg->m_pDoc = m_doc;
dlg->m_name = alias_item->name;
dlg->m_contents = alias_item->contents;
dlg->m_bIgnoreCase = alias_item->bIgnoreCase;
// dlg->m_bDelayed = alias_item->bDelayed;
dlg->m_strLabel = alias_item->strLabel;
dlg->m_strProcedure = alias_item->strProcedure;
dlg->m_bEnabled = alias_item->bEnabled;
dlg->m_bExpandVariables = alias_item->bExpandVariables;
dlg->m_bOmitFromLogFile = alias_item->bOmitFromLog;
dlg->m_bRegexp = alias_item->bRegexp;
dlg->m_bOmitFromOutput = alias_item->bOmitFromOutput;
dlg->m_bMenu = alias_item->bMenu;
dlg->m_bTemporary = alias_item->bTemporary;
dlg->m_strGroup = alias_item->strGroup;
dlg->m_strVariable = alias_item->strVariable;
dlg->m_iSendTo = alias_item->iSendTo;
dlg->m_iSequence = alias_item->iSequence;
dlg->m_bKeepEvaluating = alias_item->bKeepEvaluating;
dlg->m_bOneShot = alias_item->bOneShot;
dlg->m_bEchoAlias = alias_item->bEchoAlias;
dlg->m_bOmitFromCommandHistory = alias_item->bOmitFromCommandHistory;
dlg->m_pAliasMap = &m_doc->m_AliasMap;
dlg->m_current_alias = alias_item;
if (alias_item->regexp &&
alias_item->regexp->m_program == NULL &&
alias_item->regexp->m_iExecutionError < PCRE_ERROR_NOMATCH)
dlg->m_strRegexpError =
TFormat ("Error: %s ", Convert_PCRE_Runtime_Error (alias_item->regexp->m_iExecutionError));
// NB - also see MapDlg.cpp for alias processing
} // end of CPrefsP7::LoadDialog
void CPrefsP7::UnloadDialog (CDialog * pDlg, CObject * pItem)
{
CAliasDlg * dlg = (CAliasDlg *) pDlg;
CAlias * alias_item = (CAlias *) pItem;
ASSERT_VALID (dlg);
ASSERT( dlg->IsKindOf( RUNTIME_CLASS( CAliasDlg ) ) );
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
alias_item->name = dlg->m_name;
alias_item->contents = dlg->m_contents;
alias_item->bIgnoreCase = dlg->m_bIgnoreCase;
// alias_item->bDelayed = dlg->m_bDelayed;
alias_item->strLabel = dlg->m_strLabel;
alias_item->strProcedure = dlg->m_strProcedure;
alias_item->bEnabled = dlg->m_bEnabled;
alias_item->bExpandVariables = dlg->m_bExpandVariables;
alias_item->bOmitFromLog = dlg->m_bOmitFromLogFile;
alias_item->bRegexp = dlg->m_bRegexp;
alias_item->bOmitFromOutput = dlg->m_bOmitFromOutput;
alias_item->iSendTo = dlg->m_iSendTo;
alias_item->bMenu = dlg->m_bMenu;
alias_item->bTemporary = dlg->m_bTemporary;
alias_item->strGroup = dlg->m_strGroup;
alias_item->strVariable = dlg->m_strVariable;
alias_item->iSequence = dlg->m_iSequence;
alias_item->bKeepEvaluating = dlg->m_bKeepEvaluating;
alias_item->bOneShot = dlg->m_bOneShot;
alias_item->bEchoAlias = dlg->m_bEchoAlias;
alias_item->bOmitFromCommandHistory = dlg->m_bOmitFromCommandHistory;
delete alias_item->regexp; // get rid of earlier regular expression
alias_item->regexp = NULL;
// all aliass are now regular expressions
CString strRegexp;
if (alias_item->bRegexp)
strRegexp = alias_item->name;
else
strRegexp = ConvertToRegularExpression (alias_item->name);
alias_item->regexp = regcomp (strRegexp,
(alias_item->bIgnoreCase ? PCRE_CASELESS : 0)
#if ALIASES_USE_UTF8
| (m_pDoc->m_bUTF_8 ? PCRE_UTF8 : 0)
#endif // ALIASES_USE_UTF8
);
// NB - also see MapDlg.cpp for alias processing
} // end of CPrefsP7::UnloadDialog
CString CPrefsP7::GetObjectName (CDialog * pDlg) const
{
CAliasDlg * dlg = (CAliasDlg *) pDlg;
ASSERT_VALID (dlg);
ASSERT( dlg->IsKindOf( RUNTIME_CLASS( CAliasDlg ) ) );
return dlg->m_strLabel;
} // end of CPrefsP7::GetObjectName
CString CPrefsP7::GetScriptName (CObject * pItem) const
{
CAlias * alias_item = (CAlias *) pItem;
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
return alias_item->strProcedure;
} // end of CPrefsP7::GetScriptName
CString CPrefsP7::GetLabel (CObject * pItem) const
{
CAlias * alias_item = (CAlias *) pItem;
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
return alias_item->strLabel;
} // end of CPrefsP7::GetLabel
CString CPrefsP7::GetGroup (CObject * pItem) const
{
CAlias * alias_item = (CAlias *) pItem;
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
return alias_item->strGroup;
} // end of CPrefsP7::GetGroup
CString CPrefsP7::GetDescription (CObject * pItem) const
{
CAlias * alias_item = (CAlias *) pItem;
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
return alias_item->name;
} // end of CPrefsP7::GetDescription
int CPrefsP7::GetSequence (CObject * pItem) const
{
CAlias * alias_item = (CAlias *) pItem;
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
return alias_item->iSequence;
} // end of CPrefsP7::GetSequence
CString CPrefsP7::GetFindText (CObject * pItem) const
{
CAlias * alias_item = (CAlias *) pItem;
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
CString strResult = alias_item->name;
strResult += "\t" + alias_item->contents +
"\t" + alias_item->strLabel +
"\t" + alias_item->strGroup +
"\t" + alias_item->strProcedure;
return strResult;
} // end of CPrefsP7::GetFindText
void CPrefsP7::SetDispatchID (CObject * pItem, const DISPID dispid)
{
CAlias * alias_item = (CAlias *) pItem;
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
alias_item->dispid = dispid;
} // end of CPrefsP7::SetDispatchID
void CPrefsP7::SetInternalName (CObject * pItem, const CString strName)
{
CAlias * alias_item = (CAlias *) pItem;
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
alias_item->strInternalName = strName;
} // end of CPrefsP7::SetInternalName
void CPrefsP7::SetDefaultSequence ()
{
m_last_col = eColumnSequence;
m_reverse = false;
} // end of CPrefsP7::SetDefaultSequence
CObject * CPrefsP7::MakeNewObject (void)
{
return (CObject *) new CAlias;
} // end of CPrefsP7::MakeNewObject
__int64 CPrefsP7::GetModificationNumber (CObject * pItem) const
{
CAlias * alias_item = (CAlias *) pItem;
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
return alias_item->nUpdateNumber;
} // end of CPrefsP7::GetModificationNumber
void CPrefsP7::SetModificationNumber (CObject * pItem, __int64 nUpdateNumber)
{
CAlias * alias_item = (CAlias *) pItem;
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
alias_item->nUpdateNumber = nUpdateNumber;
} // end of CPrefsP7::SetModificationNumber
bool CPrefsP7::CheckIfChanged (CDialog * pDlg, CObject * pItem) const
{
CAliasDlg * dlg = (CAliasDlg *) pDlg;
CAlias * alias_item = (CAlias *) pItem;
ASSERT_VALID (dlg);
ASSERT( dlg->IsKindOf( RUNTIME_CLASS( CAliasDlg ) ) );
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
if (alias_item->name == dlg->m_name &&
alias_item->contents == dlg->m_contents &&
alias_item->bIgnoreCase == dlg->m_bIgnoreCase &&
// alias_item->bDelayed == dlg->m_bDelayed &&
alias_item->bOmitFromLog == dlg->m_bOmitFromLogFile &&
alias_item->strLabel == dlg->m_strLabel &&
alias_item->strProcedure == dlg->m_strProcedure &&
alias_item->bEnabled == dlg->m_bEnabled &&
alias_item->bExpandVariables == dlg->m_bExpandVariables &&
alias_item->bRegexp == dlg->m_bRegexp &&
alias_item->bOmitFromOutput == dlg->m_bOmitFromOutput &&
alias_item->iSendTo == dlg->m_iSendTo &&
alias_item->bMenu == dlg->m_bMenu &&
alias_item->bTemporary == (bool) dlg->m_bTemporary &&
alias_item->strGroup == dlg->m_strGroup &&
alias_item->strVariable == dlg->m_strVariable &&
alias_item->iSequence == dlg->m_iSequence &&
alias_item->bKeepEvaluating == dlg->m_bKeepEvaluating &&
alias_item->bOneShot == dlg->m_bOneShot &&
alias_item->bEchoAlias == dlg->m_bEchoAlias &&
alias_item->bOmitFromCommandHistory == dlg->m_bOmitFromCommandHistory
) return false; // no need to set modified flag if nothing changed
return true;
} // end of CPrefsP7::CheckIfChanged
void CPrefsP7::OnAddAlias()
{
CAliasDlg dlg;
dlg.m_pDoc = m_doc;
OnAddItem (dlg);
m_doc->SortAliases ();
} // end of CPrefsP7::OnAddAlias
void CPrefsP7::OnChangeAlias()
{
// don't do it if they are using defaults
if (m_ctlUseDefaultAliases.GetCheck () != 0 &&
!App.m_strDefaultAliasesFile.IsEmpty ())
return;
CAliasDlg dlg;
dlg.m_pDoc = m_doc;
OnChangeItem (dlg);
m_doc->SortAliases ();
} // end of CPrefsP7::OnChangeAlias
void CPrefsP7::OnDeleteAlias()
{
OnDeleteItem ();
m_doc->SortAliases ();
} // end of CPrefsP7::OnDeleteAlias
void CPrefsP7::OnDblclkAliasesList(NMHDR* pNMHDR, LRESULT* pResult)
{
OnChangeAlias ();
*pResult = 1;
} // end of CPrefsP7::OnDblclkAliasesList
int CPrefsP7::CompareObjects (const int iColumn, const CObject * item1, const CObject * item2)
{
CAlias * alias1 = (CAlias *) item1,
* alias2 = (CAlias *) item2;
ASSERT_VALID (alias1);
ASSERT( alias1->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
ASSERT_VALID (alias2);
ASSERT( alias2->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
int iResult;
switch (iColumn) // which sort key
{
case eColumnSequence:
if (alias1->iSequence < alias2->iSequence)
iResult = -1;
else if (alias1->iSequence > alias2->iSequence)
iResult = 1;
else
// if same sequence, sort in alias match order
iResult = alias1->name.CompareNoCase (alias2->name);
break;
case eColumnGroup: iResult = alias1->strGroup.CompareNoCase (alias2->strGroup);
if (iResult)
break;
case eColumnLabel: iResult = alias1->strLabel.CompareNoCase (alias2->strLabel);
if (iResult)
break;
case eColumnAlias: iResult = alias1->name.CompareNoCase (alias2->name);
break;
case eColumnContents: iResult = alias1->contents.CompareNoCase (alias2->contents); break;
default: iResult = 0;
} // end of switch
return iResult;
} // end of CPrefsP7::CompareObjects
void CPrefsP7::OnColumnclickAliasesList(NMHDR* pNMHDR, LRESULT* pResult)
{
OnColumnclickItemList (pNMHDR, pResult);
} // end of CPrefsP7::OnColumnclickAliasesList
void CPrefsP7::OnLoadAlias()
{
if (m_doc->Load_Set (ALIAS, "", this))
return;
LoadList ();
// They can no longer cancel the propery sheet, the document has changed
CancelToClose ();
m_doc->SetModifiedFlag (TRUE);
// resolve all entry points for triggers, aliases etc.
// if scripting active, find entry points
if (m_doc->m_ScriptEngine)
m_doc->FindAllEntryPoints ();
} // end of CPrefsP7::OnLoadAlias
void CPrefsP7::OnSaveAlias()
{
if (m_doc->Save_Set (ALIAS, this))
return;
} // end of CPrefsP7::OnSaveAlias
int CPrefsP7::AddItem (CObject * pItem,
const int item_number,
const BOOL insert)
{
CAlias * alias_item = (CAlias * ) pItem;
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
int nItem;
if (insert)
{
nItem = m_ctlAliasList.GetItemCount ();
m_ctlAliasList.InsertItem (nItem, alias_item->name); // eColumnAlias
}
else
{
nItem = item_number;
m_ctlAliasList.SetItemText(nItem, eColumnAlias, alias_item->name);
}
m_ctlAliasList.SetItemText (nItem, eColumnSequence, CFormat ("%i", alias_item->iSequence));
m_ctlAliasList.SetItemText (nItem, eColumnContents,
Replace (alias_item->contents, ENDLINE, "\\n", true));
m_ctlAliasList.SetItemText (nItem, eColumnLabel, alias_item->strLabel);
m_ctlAliasList.SetItemText (nItem, eColumnGroup, alias_item->strGroup);
return nItem;
} // end of CPrefsP7::AddItem
BOOL CPrefsP7::OnInitDialog()
{
CGenPropertyPage::OnInitDialog();
// fix up last column to exactly fit the list view
RECT rect;
m_ctlAliasList.GetClientRect (&rect);
m_iColWidth [eColumnContents] = rect.right - rect.left - // get width of control
GetSystemMetrics (SM_CXVSCROLL) - // minus vertical scroll bar
m_iColWidth [eColumnAlias]; // minus width of other items
return FALSE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
} // end of CPrefsP7::OnInitDialog
void CPrefsP7::OnMoveUp()
{
CString strMsg;
int nItem = 0;
HTREEITEM hdlItem = NULL;
CString * pstrObjectName;
if (m_bWantTreeControl)
{
hdlItem = m_cTreeCtrl.GetSelectedItem ();
if (hdlItem == NULL)
return; // no selection!
pstrObjectName = (CString *) m_cTreeCtrl.GetItemData (hdlItem);
} // end tree control
else
{
nItem = m_ctlList->GetNextItem (-1, LVNI_SELECTED);
if (nItem == -1)
return; // no selection!
pstrObjectName = (CString *) m_ctlList->GetItemData (nItem);
} // end list control
ASSERT (pstrObjectName != NULL);
CObject * pItem;
// check object is still there (it might have gone while we looked at the list box)
if (!m_ObjectMap->Lookup (*pstrObjectName, pItem))
{
if (hdlItem)
{
HTREEITEM hdlParent = m_cTreeCtrl.GetParentItem (hdlItem);
m_cTreeCtrl.DeleteItem (hdlItem);
CheckParentHasChildren (hdlParent);
}
else
{
m_ctlList->DeleteItem (nItem); // it's gone, so delete it from the list view
m_ctlList->RedrawItems (0, m_ctlList->GetItemCount () - 1); // redraw the list
}
strMsg = TFormat ("The %s named \"%s\" is no longer in the %s list",
(LPCTSTR) m_strObjectType,
(LPCTSTR) *pstrObjectName,
(LPCTSTR) m_strObjectType);
::UMessageBox (strMsg);
delete pstrObjectName; // and get rid of its name string
return;
}
ASSERT_VALID (pItem);
ASSERT( pItem->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
CAlias * alias = (CAlias *) pItem;
int iSeq = alias->iSequence;
if (iSeq == 0)
::TMessageBox ("Cannot move up - already has a sequence of zero");
else
{
int iLower = -1;
int bSame = false;
for (int iItem = 0; iItem < m_doc->m_AliasMap.GetCount (); iItem++)
if (m_doc->m_AliasArray [iItem] != alias)
if (m_doc->m_AliasArray [iItem]->iSequence < alias->iSequence)
iLower = m_doc->m_AliasArray [iItem]->iSequence;
else if (m_doc->m_AliasArray [iItem]->iSequence == alias->iSequence)
bSame = true;
if (bSame)
alias->iSequence--; // make a lower sequence (drop out of group)
else
if (iLower == -1)
::TMessageBox ("Cannot move up - already at top of list");
else
alias->iSequence = iLower; // move into lower group
m_doc->SortAliases ();
// They can no longer cancel the propery sheet, the document has changed
CancelToClose ();
m_doc->SetModifiedFlag (TRUE);
// re-setup list with amended details
if (!m_bWantTreeControl)
add_list_item (pItem, pstrObjectName, nItem, FALSE);
}
// resort the list
SortItems ();
if (!m_bWantTreeControl)
m_ctlList->RedrawItems (0, m_ctlList->GetItemCount () - 1); // redraw the list
} // end of CPrefsP7::OnMoveUp
void CPrefsP7::OnMoveDown()
{
CString strMsg;
int nItem = 0;
HTREEITEM hdlItem = NULL;
CString * pstrObjectName;
if (m_bWantTreeControl)
{
hdlItem = m_cTreeCtrl.GetSelectedItem ();
if (hdlItem == NULL)
return; // no selection!
pstrObjectName = (CString *) m_cTreeCtrl.GetItemData (hdlItem);
} // end tree control
else
{
nItem = m_ctlList->GetNextItem (-1, LVNI_SELECTED);
if (nItem == -1)
return; // no selection!
pstrObjectName = (CString *) m_ctlList->GetItemData (nItem);
} // end list control
ASSERT (pstrObjectName != NULL);
CObject * pItem;
// check object is still there (it might have gone while we looked at the list box)
if (!m_ObjectMap->Lookup (*pstrObjectName, pItem))
{
if (hdlItem)
{
HTREEITEM hdlParent = m_cTreeCtrl.GetParentItem (hdlItem);
m_cTreeCtrl.DeleteItem (hdlItem);
CheckParentHasChildren (hdlParent);
}
else
{
m_ctlList->DeleteItem (nItem); // it's gone, so delete it from the list view
m_ctlList->RedrawItems (0, m_ctlList->GetItemCount () - 1); // redraw the list
}
strMsg = TFormat ("The %s named \"%s\" is no longer in the %s list",
(LPCTSTR) m_strObjectType,
(LPCTSTR) *pstrObjectName,
(LPCTSTR) m_strObjectType);
::UMessageBox (strMsg);
delete pstrObjectName; // and get rid of its name string
return;
}
ASSERT_VALID (pItem);
ASSERT( pItem->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
CAlias * alias = (CAlias *) pItem;
int iSeq = alias->iSequence;
if (iSeq == 10000)
::TMessageBox ("Cannot move down - already has a sequence of 10000");
else
{
int iHigher = -1;
int bSame = false;
for (int iItem = 0; iItem < m_doc->m_AliasMap.GetCount (); iItem++)
if (m_doc->m_AliasArray [iItem] != alias)
if (m_doc->m_AliasArray [iItem]->iSequence > alias->iSequence &&
iHigher == -1)
iHigher = m_doc->m_AliasArray [iItem]->iSequence;
else if (m_doc->m_AliasArray [iItem]->iSequence == alias->iSequence)
bSame = true;
if (bSame)
alias->iSequence++; // make a higher sequence (jump out of group)
else
if (iHigher == -1)
::TMessageBox ("Cannot move down - already at bottom of list");
else
alias->iSequence = iHigher; // move into Higher group
m_doc->SortAliases ();
// They can no longer cancel the propery sheet, the document has changed
CancelToClose ();
m_doc->SetModifiedFlag (TRUE);
// re-setup list with amended details
if (m_bWantTreeControl)
{
// m_cTreeCtrl.DeleteItem (hdlItem);
// HTREEITEM hItem = add_tree_item (pItem, pstrObjectName);
}
else
add_list_item (pItem, pstrObjectName, nItem, FALSE);
}
// resort the list
SortItems ();
if (!m_bWantTreeControl)
m_ctlList->RedrawItems (0, m_ctlList->GetItemCount () - 1); // redraw the list
} // end of CPrefsP7::OnMoveDown
void CPrefsP7::OnUpdateNotUsingDefaults(CCmdUI* pCmdUI)
{
pCmdUI->Enable (m_ctlUseDefaultAliases.GetCheck () == 0 ||
App.m_strDefaultAliasesFile.IsEmpty ());
} // end of CPrefsP7::OnUpdateNotUsingDefaults
void CPrefsP7::OnUpdateHaveDefaults(CCmdUI* pCmdUI)
{
pCmdUI->Enable (!App.m_strDefaultAliasesFile.IsEmpty ());
} // end of CPrefsP7::OnUpdateHaveDefaults
void CPrefsP7::OnUpdateNeedSelection(CCmdUI* pCmdUI)
{
pCmdUI->Enable ((GetSelectedItemCount () != 0 || GetSelectedGroupCount () != 0) &&
(m_ctlUseDefaultAliases.GetCheck () == 0 ||
App.m_strDefaultAliasesFile.IsEmpty ()));
} // end of CPrefsP7::OnUpdateNeedSelection
void CPrefsP7::OnUpdateNeedOneSelection(CCmdUI* pCmdUI)
{
pCmdUI->Enable (GetSelectedItemCount () == 1 &&
(m_ctlUseDefaultAliases.GetCheck () == 0 ||
App.m_strDefaultAliasesFile.IsEmpty ()));
} // end of CPrefsP7::OnUpdateNeedOneSelection
void CPrefsP7::OnUpdateNeedXMLClipboard(CCmdUI* pCmdUI)
{
pCmdUI->Enable (IsClipboardXML ());
} // end of CPrefsP7::OnUpdateNeedXMLClipboard
void CPrefsP7::OnCopy()
{
OnCopyItem ();
}
void CPrefsP7::OnPaste()
{
OnPasteItem ();
}
bool CPrefsP7::CheckIfIncluded (CObject * pItem)
{
CAlias * alias_item = (CAlias *) pItem;
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
return alias_item->bIncluded;
} // end of CPrefsP7::CheckIfIncluded
bool CPrefsP7::CheckIfTemporary (CObject * pItem)
{
CAlias * alias_item = (CAlias *) pItem;
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
return alias_item->bTemporary;
} // end of CPrefsP7::CheckIfTemporary
bool CPrefsP7::CheckIfExecuting (CObject * pItem)
{
CAlias * alias_item = (CAlias *) pItem;
ASSERT_VALID (alias_item);
ASSERT( alias_item->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
return alias_item->bExecutingScript;
} // end of CPrefsP7::CheckIfExecuting
void CPrefsP7::OnUpdateCanSequence(CCmdUI* pCmdUI)
{
pCmdUI->Enable (m_last_col == eColumnSequence && !m_reverse &&
GetSelectedItemCount () == 1 &&
(m_ctlUseDefaultAliases.GetCheck () == 0 ||
App.m_strDefaultAliasesFile.IsEmpty ()));
} // end of CPrefsP7::OnUpdateCanSequence
bool CPrefsP7::GetFilterFlag () // is filtering enabled?
{
return m_ctlFilter.GetCheck ();
}
CString CPrefsP7::GetFilterScript () // get the filter script
{
return m_doc->m_strAliasesFilter;
}
void CPrefsP7::OnFilter()
{
LoadList (); // need to reload the list now
}
void CPrefsP7::OnEditFilter()
{
if (EditFilterText (m_doc->m_strAliasesFilter))
LoadList (); // need to reload the list now
}
void CPrefsP7::OnUseTreeViewChecked()
{
GetSelectedItem (); // remember old selection
m_bWantTreeControl = ((CButton *) GetDlgItem (ID_USE_TREEVIEW))->GetCheck () != 0;
LoadList ();
} // end of CPrefsP7::OnUseTreeViewChecked
void CPrefsP7::GetFilterInfo (CObject * pItem, lua_State * L)
{
CAlias * alias = (CAlias *) pItem;
ASSERT_VALID (alias);
ASSERT( alias->IsKindOf( RUNTIME_CLASS( CAlias ) ) );
// the table of stuff
lua_newtable(L);
MakeTableItemBool (L, "echo_alias", alias->bEchoAlias);
MakeTableItemBool (L, "enabled", alias->bEnabled);
MakeTableItemBool (L, "expand_variables", alias->bExpandVariables);
MakeTableItem (L, "group", alias->strGroup);
MakeTableItemBool (L, "ignore_case", alias->bIgnoreCase);
MakeTableItemBool (L, "keep_evaluating", alias->bKeepEvaluating);
MakeTableItem (L, "match", alias->name);
MakeTableItemBool (L, "menu", alias->bMenu);
MakeTableItem (L, "name", alias->strLabel);
MakeTableItemBool (L, "omit_from_command_history", alias->bOmitFromCommandHistory);
MakeTableItemBool (L, "omit_from_log", alias->bOmitFromLog);
MakeTableItemBool (L, "omit_from_output", alias->bOmitFromOutput);
MakeTableItemBool (L, "one_shot", alias->bOneShot);
MakeTableItemBool (L, "regexp", alias->bRegexp);
MakeTableItem (L, "script", alias->strProcedure);
MakeTableItem (L, "send", alias->contents);
MakeTableItem (L, "send_to", alias->iSendTo);
MakeTableItem (L, "sequence", alias->iSequence);
MakeTableItem (L, "user", alias->iUserOption);
MakeTableItem (L, "variable", alias->strVariable);
// stuff below is not part of the world file but calculated at runtime
// GetAliasInfo (10)
MakeTableItem (L, "invocation_count", alias->nInvocationCount);
// GetAliasInfo (11)
MakeTableItem (L, "times_matched", alias->nMatched);
// GetAliasInfo (13)
if (alias->tWhenMatched.GetTime ())
MakeTableItem (L, "when_matched", COleDateTime (alias->tWhenMatched.GetTime ()));
// GetAliasInfo (14)
MakeTableItemBool (L, "temporary", alias->bTemporary);
// GetAliasInfo (15)
MakeTableItemBool (L, "included", alias->bIncluded);
// GetAliasInfo (24)
if (alias->regexp)
MakeTableItem (L, "match_count", alias->regexp->m_iCount);
// GetAliasInfo (25)
if (alias->regexp)
MakeTableItem (L, "last_match", alias->regexp->m_sTarget);
// GetAliasInfo (27)
MakeTableItemBool (L, "script_valid", alias->dispid != DISPID_UNKNOWN);
// GetAliasInfo (28)
if (alias->regexp && alias->regexp->m_program == NULL)
MakeTableItem (L, "execution_error", alias->regexp->m_iExecutionError);
// GetAliasInfo (30)
if (alias->regexp && App.m_iCounterFrequency)
MakeTableItem (L, "execution_time", ((double) alias->regexp->iTimeTaken) /
((double) App.m_iCounterFrequency));
// GetAliasInfo (31)
if (alias->regexp)
MakeTableItem (L, "match_attempts", alias->regexp->m_iMatchAttempts);
} // end of CPrefsP7::GetFilterInfo
/////////////////////////////////////////////////////////////////////////////
// CPrefsP8 property page
IMPLEMENT_DYNCREATE(CPrefsP8, CGenPropertyPage)
CPrefsP8::CPrefsP8() : CGenPropertyPage(CPrefsP8::IDD)
{
//{{AFX_DATA_INIT(CPrefsP8)
m_enable_triggers = FALSE;
m_enable_trigger_sounds = FALSE;
m_bUseDefaultTriggers = FALSE;
m_bFilter = FALSE;
//}}AFX_DATA_INIT
m_last_col = eColumnSequence;
m_doc = NULL;
m_prefsp3 = NULL;
m_prefsp14 = NULL;
}
CPrefsP8::~CPrefsP8()
{
}
void CPrefsP8::DoDataExchange(CDataExchange* pDX)
{
// check they really want to use defaults
if (pDX->m_bSaveAndValidate)
if (m_ctlUseDefaultTriggers.GetCheck ())
if (m_ctlUseDefaultTriggers.GetCheck () != m_bUseDefaultTriggers)
if (m_doc->m_TriggerMap.GetCount () > 0)
if (::UMessageBox (TFormat ("By checking the option \"Override with default triggers\" "
" your existing %i trigger%s will be PERMANENTLY discarded next time you open this world.\n\n"
"Are you SURE you want to do this?", PLURAL (m_doc->m_TriggerMap.GetCount ())),
MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2 ) != IDYES)
pDX->Fail ();
CGenPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPrefsP8)
DDX_Control(pDX, IDC_COUNT, m_ctlSummary);
DDX_Control(pDX, IDC_FILTER, m_ctlFilter);
DDX_Control(pDX, IDC_USE_DEFAULT_TRIGGERS, m_ctlUseDefaultTriggers);
DDX_Control(pDX, IDC_TRIGGERS_LIST, m_ctlTriggerList);
DDX_Check(pDX, IDC_ENABLE_TRIGGERS, m_enable_triggers);
DDX_Check(pDX, IDC_ENABLE_TRIGGERS_SOUNDS, m_enable_trigger_sounds);
DDX_Check(pDX, IDC_USE_DEFAULT_TRIGGERS, m_bUseDefaultTriggers);
DDX_Check(pDX, IDC_FILTER, m_bFilter);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPrefsP8, CGenPropertyPage)
//{{AFX_MSG_MAP(CPrefsP8)
ON_BN_CLICKED(IDC_ADD_TRIGGER, OnAddTrigger)
ON_BN_CLICKED(IDC_CHANGE_TRIGGER, OnChangeTrigger)
ON_BN_CLICKED(IDC_DELETE_TRIGGER, OnDeleteTrigger)
ON_NOTIFY(NM_DBLCLK, IDC_TRIGGERS_LIST, OnDblclkTriggersList)
ON_NOTIFY(LVN_COLUMNCLICK, IDC_TRIGGERS_LIST, OnColumnclickTriggersList)
ON_BN_CLICKED(IDC_LOAD_TRIGGER, OnLoadTrigger)
ON_BN_CLICKED(IDC_SAVE_TRIGGER, OnSaveTrigger)
ON_BN_CLICKED(IDC_MOVE_UP, OnMoveUp)
ON_BN_CLICKED(IDC_MOVE_DOWN, OnMoveDown)
ON_BN_CLICKED(IDC_COPY, OnCopy)
ON_BN_CLICKED(IDC_PASTE, OnPaste)
ON_BN_CLICKED(IDC_EDIT_FILTER, OnEditFilter)
ON_BN_CLICKED(IDC_FILTER, OnFilter)
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_FIND, OnFind)
ON_BN_CLICKED(IDC_FIND_NEXT, OnFindNext)
ON_UPDATE_COMMAND_UI(IDC_CHANGE_TRIGGER, OnUpdateNeedOneSelection)
ON_UPDATE_COMMAND_UI(IDC_DELETE_TRIGGER, OnUpdateNeedSelection)
ON_UPDATE_COMMAND_UI(IDC_COPY, OnUpdateNeedSelection)
ON_UPDATE_COMMAND_UI(IDC_PASTE, OnUpdateNeedXMLClipboard)
ON_UPDATE_COMMAND_UI(IDC_SAVE_TRIGGER, OnUpdateNeedEntries)
ON_UPDATE_COMMAND_UI(IDC_FIND, OnUpdateNeedEntries)
ON_UPDATE_COMMAND_UI(IDC_FIND_NEXT, OnUpdateNeedEntries)
ON_UPDATE_COMMAND_UI(IDC_MOVE_UP, OnUpdateCanSequence)
ON_UPDATE_COMMAND_UI(IDC_MOVE_DOWN, OnUpdateCanSequence)
ON_UPDATE_COMMAND_UI(IDC_ADD_TRIGGER, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_LOAD_TRIGGER, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_USE_DEFAULT_TRIGGERS, OnUpdateHaveDefaults)
ON_NOTIFY(NM_DBLCLK, ID_TREEVIEW, OnDblclkTriggersList)
ON_BN_CLICKED(ID_USE_TREEVIEW, OnUseTreeViewChecked)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPrefsP8 message handlers
void CPrefsP8::InitDialog (CDialog * pDlg)
{
CTriggerDlg * dlg = (CTriggerDlg *) pDlg;
ASSERT_VALID (dlg);
ASSERT( dlg->IsKindOf( RUNTIME_CLASS( CTriggerDlg ) ) );
dlg->m_pDoc = m_doc;
dlg->m_bUTF_8 = m_doc->m_bUTF_8;
dlg->m_ignore_case = m_doc->m_bDefaultTriggerIgnoreCase;
dlg->m_colour = 0; // no change
dlg->m_sound_pathname = NOSOUNDLIT;
dlg->m_omit_from_log = FALSE;
dlg->m_pTriggerMap = &m_doc->m_TriggerMap;
dlg->m_current_trigger = NULL;
dlg->m_bOmitFromOutput = FALSE;
dlg->m_bKeepEvaluating = m_doc->m_bDefaultTriggerKeepEvaluating;
dlg->m_bOneShot = FALSE;
dlg->m_bEnabled = TRUE;
dlg->m_iClipboardArg = 0;
dlg->m_iSendTo = m_doc->m_iDefaultTriggerSendTo;
dlg->m_bRegexp = m_doc->m_bDefaultTriggerRegexp;
dlg->m_bRepeat = FALSE;
dlg->m_bExpandVariables = m_doc->m_bDefaultTriggerExpandVariables;
dlg->m_iSequence = m_doc->m_iDefaultTriggerSequence;
dlg->m_iMatchTextColour = 0; // any
dlg->m_iMatchBackColour = 0; // any
dlg->m_iMatchBold = 2; // any
dlg->m_iMatchItalic = 2; // any
dlg->m_iMatchInverse = 2; // any
dlg->m_bShowBold = m_prefsp14->m_bShowBold;
dlg->m_bShowItalic = m_prefsp14->m_bShowItalic;
dlg->m_bShowUnderline = m_prefsp14->m_bShowUnderline;
dlg->m_bTemporary = FALSE;
dlg->m_iOtherForeground = 0;
dlg->m_iOtherBackground = 0;
dlg->m_bMultiLine = FALSE;
dlg->m_iLinesToMatch = 0;
dlg->m_iColourChangeType = TRIGGER_COLOUR_CHANGE_BOTH;
// m_imglIcons.Create (IDR_TRIGGERIMAGES, 16, 1, RGB (255, 0, 255));
// m_ctlTriggerList.SetImageList (&m_imglIcons, TVSIL_NORMAL);
} // end of CPrefsP8::InitDialog
void CPrefsP8::LoadDialog (CDialog * pDlg, CObject * pItem)
{
CTriggerDlg * dlg = (CTriggerDlg *) pDlg;
CTrigger * trigger_item = (CTrigger *) pItem;
ASSERT_VALID (dlg);
ASSERT( dlg->IsKindOf( RUNTIME_CLASS( CTriggerDlg ) ) );
ASSERT_VALID (trigger_item);
ASSERT( trigger_item->IsKindOf( RUNTIME_CLASS( CTrigger ) ) );
dlg->m_pDoc = m_doc;
dlg->m_bUTF_8 = m_doc->m_bUTF_8;
dlg->m_trigger = trigger_item->trigger;
dlg->m_contents = trigger_item->contents;
dlg->m_ignore_case = trigger_item->ignore_case;
dlg->m_colour = trigger_item->colour == SAMECOLOUR ? 0 : trigger_item->colour + 1;
if (trigger_item->sound_to_play.IsEmpty ())
dlg->m_sound_pathname = NOSOUNDLIT;
else
dlg->m_sound_pathname = trigger_item->sound_to_play;
dlg->m_omit_from_log = trigger_item->omit_from_log;
dlg->m_bOmitFromOutput = trigger_item->bOmitFromOutput;
dlg->m_bKeepEvaluating = trigger_item->bKeepEvaluating;
dlg->m_bOneShot = trigger_item->bOneShot;
dlg->m_bEnabled = trigger_item->bEnabled;
dlg->m_strProcedure = trigger_item->strProcedure;
dlg->m_strLabel = trigger_item->strLabel;
dlg->m_iClipboardArg = trigger_item->iClipboardArg;
dlg->m_iSendTo = trigger_item->iSendTo;
dlg->m_bRegexp = trigger_item->bRegexp;
dlg->m_bRepeat = trigger_item->bRepeat;
dlg->m_bExpandVariables = trigger_item->bExpandVariables;
dlg->m_iSequence = trigger_item->iSequence;
dlg->m_bSoundIfInactive = trigger_item->bSoundIfInactive;
dlg->m_bLowercaseWildcard = trigger_item->bLowercaseWildcard;
dlg->m_bBold = (trigger_item->iStyle & HILITE) != 0;
dlg->m_bItalic = (trigger_item->iStyle & BLINK) != 0;
dlg->m_bUnderline = (trigger_item->iStyle & UNDERLINE) != 0;
dlg->m_pTriggerMap = &m_doc->m_TriggerMap;
dlg->m_current_trigger = trigger_item;
dlg->m_bShowBold = m_prefsp14->m_bShowBold;
dlg->m_bShowItalic = m_prefsp14->m_bShowItalic;
dlg->m_bShowUnderline = m_prefsp14->m_bShowUnderline;
dlg->m_bTemporary = trigger_item->bTemporary;
dlg->m_strGroup = trigger_item->strGroup;
switch (trigger_item->iSendTo)
{
case eSendToVariable: dlg->m_strVariable = trigger_item->strVariable; break;
#ifdef PANE
case eSendToPane: dlg->m_strVariable = trigger_item->strPane; break;
#endif // PANE
default: dlg->m_strVariable = ""; break;
} // end of switch
// set up matching colours
if (trigger_item->iMatch & TRIGGER_MATCH_TEXT)
dlg->m_iMatchTextColour = get_foreground (trigger_item->iMatch) + 1;
else
dlg->m_iMatchTextColour = 0; // any
if (trigger_item->iMatch & TRIGGER_MATCH_BACK)
dlg->m_iMatchBackColour = get_background (trigger_item->iMatch) + 1;
else
dlg->m_iMatchBackColour = 0; // any
if (trigger_item->iMatch & TRIGGER_MATCH_HILITE)
dlg->m_iMatchBold = (get_style (trigger_item->iMatch) & HILITE) != 0;
else
dlg->m_iMatchBold = 2; // any
if (trigger_item->iMatch & TRIGGER_MATCH_BLINK)
dlg->m_iMatchItalic = (get_style (trigger_item->iMatch) & BLINK) != 0;
else
dlg->m_iMatchItalic = 2; // any
if (trigger_item->iMatch & TRIGGER_MATCH_INVERSE)
dlg->m_iMatchInverse = (get_style (trigger_item->iMatch) & INVERSE) != 0;
else
dlg->m_iMatchInverse = 2; // any
dlg->m_iOtherForeground = trigger_item->iOtherForeground;
dlg->m_iOtherBackground = trigger_item->iOtherBackground;
dlg->m_bMultiLine = trigger_item->bMultiLine;
dlg->m_iLinesToMatch = trigger_item->iLinesToMatch;
dlg->m_iColourChangeType = trigger_item->iColourChangeType;
if (trigger_item->regexp &&
trigger_item->regexp->m_program == NULL &&
trigger_item->regexp->m_iExecutionError < PCRE_ERROR_NOMATCH)
dlg->m_strRegexpError =
TFormat ("Error: %s ", Convert_PCRE_Runtime_Error (trigger_item->regexp->m_iExecutionError));
} // end of CPrefsP8::LoadDialog
void CPrefsP8::UnloadDialog (CDialog * pDlg, CObject * pItem)
{
CTriggerDlg * dlg = (CTriggerDlg *) pDlg;
CTrigger * trigger_item = (CTrigger *) pItem;
ASSERT_VALID (dlg);
ASSERT( dlg->IsKindOf( RUNTIME_CLASS( CTriggerDlg ) ) );
ASSERT_VALID (trigger_item);
ASSERT( trigger_item->IsKindOf( RUNTIME_CLASS( CTrigger ) ) );
trigger_item->trigger = dlg->m_trigger;
trigger_item->contents = dlg->m_contents;
trigger_item->ignore_case = dlg->m_ignore_case;
trigger_item->colour = dlg->m_colour - 1;
trigger_item->bOmitFromOutput = dlg->m_bOmitFromOutput;
trigger_item->bKeepEvaluating = dlg->m_bKeepEvaluating;
trigger_item->bOneShot = dlg->m_bOneShot;
trigger_item->bEnabled = dlg->m_bEnabled;
trigger_item->strProcedure = dlg->m_strProcedure;
trigger_item->strLabel = dlg->m_strLabel;
trigger_item->iClipboardArg = dlg->m_iClipboardArg;
trigger_item->iSendTo = dlg->m_iSendTo;
trigger_item->bRegexp = dlg->m_bRegexp;
trigger_item->bRepeat = dlg->m_bRepeat;
trigger_item->bExpandVariables = dlg->m_bExpandVariables;
trigger_item->iSequence = dlg->m_iSequence;
trigger_item->bSoundIfInactive = dlg->m_bSoundIfInactive;
trigger_item->bLowercaseWildcard = dlg->m_bLowercaseWildcard;
trigger_item->strGroup = dlg->m_strGroup;
switch (trigger_item->iSendTo)
{
case eSendToVariable: trigger_item->strVariable = dlg->m_strVariable; break;
#ifdef PANE
case eSendToPane: trigger_item->strPane = dlg->m_strVariable;break;
#endif // PANE
default: dlg->m_strVariable = ""; break;
} // end of switch
trigger_item->iOtherForeground = dlg->m_iOtherForeground;
trigger_item->iOtherBackground = dlg->m_iOtherBackground;
trigger_item->bMultiLine = dlg->m_bMultiLine;
trigger_item->iLinesToMatch = dlg->m_iLinesToMatch;
trigger_item->iColourChangeType = dlg->m_iColourChangeType;
trigger_item->iStyle = 0;
if (dlg->m_bBold)
trigger_item->iStyle |= HILITE;
if (dlg->m_bItalic)
trigger_item->iStyle |= BLINK;
if (dlg->m_bUnderline)
trigger_item->iStyle |= UNDERLINE;
trigger_item->bTemporary = dlg->m_bTemporary;
// do matching colours
trigger_item->iMatch = 0; // no matches yet
if (dlg->m_iMatchTextColour > 0) // colour selected
{
trigger_item->iMatch |= TRIGGER_MATCH_TEXT;
trigger_item->iMatch |= ((dlg->m_iMatchTextColour - 1) & 7) << 4;
}
if (dlg->m_iMatchBackColour > 0) // colour selected
{
trigger_item->iMatch |= TRIGGER_MATCH_BACK;
trigger_item->iMatch |= ((dlg->m_iMatchBackColour - 1) & 7) << 8;
}
if (dlg->m_iMatchBold != 2)
{
trigger_item->iMatch |= TRIGGER_MATCH_HILITE;
trigger_item->iMatch |= dlg->m_iMatchBold ? HILITE : 0;
}
if (dlg->m_iMatchItalic != 2)
{
trigger_item->iMatch |= TRIGGER_MATCH_BLINK;
trigger_item->iMatch |= dlg->m_iMatchItalic ? BLINK : 0;
}
if (dlg->m_iMatchInverse != 2)
{
trigger_item->iMatch |= TRIGGER_MATCH_INVERSE;
trigger_item->iMatch |= dlg->m_iMatchInverse ? INVERSE : 0;
}
if (dlg->m_sound_pathname == NOSOUNDLIT)
trigger_item->sound_to_play.Empty ();
else
trigger_item->sound_to_play = dlg->m_sound_pathname;
trigger_item->omit_from_log = dlg->m_omit_from_log;
LONGLONG iOldTimeTaken = 0;
// remember time taken to execute them
if (trigger_item->regexp)
iOldTimeTaken = trigger_item->regexp->iTimeTaken;
delete trigger_item->regexp; // get rid of earlier regular expression
trigger_item->regexp = NULL;
// all triggers are now regular expressions
CString strRegexp;
if (trigger_item->bRegexp)
strRegexp = trigger_item->trigger;
else
strRegexp = ConvertToRegularExpression (trigger_item->trigger);
trigger_item->regexp = regcomp (strRegexp,
(trigger_item->ignore_case ? PCRE_CASELESS : 0) |
(trigger_item->bMultiLine ? PCRE_MULTILINE : 0) |
(m_doc->m_bUTF_8 ? PCRE_UTF8 : 0));
// add back execution time
if (trigger_item->regexp)
trigger_item->regexp->iTimeTaken += iOldTimeTaken;
} // end of CPrefsP8::UnloadDialog
CString CPrefsP8::GetObjectName (CDialog * pDlg) const
{
CTriggerDlg * dlg = (CTriggerDlg *) pDlg;
ASSERT_VALID (dlg);
ASSERT( dlg->IsKindOf( RUNTIME_CLASS( CTriggerDlg ) ) );
return dlg->m_strLabel;
} // end of CPrefsP8::GetObjectName
CString CPrefsP8::GetScriptName (CObject * pItem) const
{
CTrigger * trigger_item = (CTrigger *) pItem;
ASSERT_VALID (trigger_item);
ASSERT( trigger_item->IsKindOf( RUNTIME_CLASS( CTrigger ) ) );
return trigger_item->strProcedure;
} // end of CPrefsP8::GetScriptName
CString CPrefsP8::GetLabel (CObject * pItem) const
{
CTrigger * trigger_item = (CTrigger *) pItem;
ASSERT_VALID (trigger_item);
ASSERT( trigger_item->IsKindOf( RUNTIME_CLASS( CTrigger ) ) );
return trigger_item->strLabel;
} // end of CPrefsP8::GetLabel
CString CPrefsP8::GetGroup (CObject * pItem) const
{
CTrigger * trigger_item = (CTrigger *) pItem;
ASSERT_VALID (trigger_item);
ASSERT( trigger_item->IsKindOf( RUNTIME_CLASS( CTrigger ) ) );
return trigger_item->strGroup;
} // end of CPrefsP8::GetGroup
CString CPrefsP8::GetDescription (CObject * pItem) const
{
CTrigger * trigger_item = (CTrigger *) pItem;
ASSERT_VALID (trigger_item);
ASSERT( trigger_item->IsKindOf( RUNTIME_CLASS( CTrigger ) ) );
return trigger_item->trigger;
} // end of CPrefsP8::GetDescription
int CPrefsP8::GetSequence (CObject * pItem) const
{
CTrigger * trigger_item = (CTrigger *) pItem;
ASSERT_VALID (trigger_item);
ASSERT( trigger_item->IsKindOf( RUNTIME_CLASS( CTrigger ) ) );
return trigger_item->iSequence;
} // end of CPrefsP8::GetSequence
CString CPrefsP8::GetFindText (CObject * pItem) const
{
CTrigger * trigger_item = (CTrigger *) pItem;
ASSERT_VALID (trigger_item);
ASSERT( trigger_item->IsKindOf( RUNTIME_CLASS( CTrigger ) ) );
CString strResult = trigger_item->trigger;
strResult += "\t" + trigger_item->contents +
"\t" + trigger_item->strLabel +
"\t" + trigger_item->strGroup +
"\t" + trigger_item->strProcedure;
return strResult;
} // end of CPrefsP8::GetFindText
void CPrefsP8::SetDispatchID (CObject * pItem, const DISPID dispid)
{
CTrigger * trigger_item = (CTrigger *) pItem;
ASSERT_VALID (trigger_item);
ASSERT( trigger_item->IsKindOf( RUNTIME_CLASS( CTrigger ) ) );
trigger_item->dispid = dispid;
} // end of CPrefsP8::SetDispatchID
void CPrefsP8::SetInternalName (CObject * pItem, const CString strName)
{
CTrigger * trigger_item = (CTrigger *) pItem;
ASSERT_VALID (trigger_item);
ASSERT( trigger_item->IsKindOf( RUNTIME_CLASS( CTrigger ) ) );
trigger_item->strInternalName = strName;
} // end of CPrefsP8::SetInternalName
void CPrefsP8::SetDefaultSequence ()
{
m_last_col = eColumnSequence;
m_reverse = false;
} // end of CPrefsP8::SetDefaultSequence
CObject * CPrefsP8::MakeNewObject (void)
{
return (CObject *) new CTrigger;
} // end of CPrefsP8::MakeNewObject
__int64 CPrefsP8::GetModificationNumber (CObject * pItem) const
{
CTrigger * trigger_item = (CTrigger *) pItem;
ASSERT_VALID (trigger_item);
ASSERT( trigger_item->IsKindOf( RUNTIME_CLASS( CTrigger ) ) );
return trigger_item->nUpdateNumber;
} // end of CPrefsP8::GetModificationNumber
void CPrefsP8::SetModificationNumber (CObject * pItem, __int64 nUpdateNumber)
{
CTrigger * trigger_item = (CTrigger *) pItem;
ASSERT_VALID (trigger_item);
ASSERT( trigger_item->IsKindOf( RUNTIME_CLASS( CTrigger ) ) );
trigger_item->nUpdateNumber = nUpdateNumber;
} // end of CPrefsP8::SetModificationNumber
bool CPrefsP8::CheckIfChanged (CDialog * pDlg, CObject * pItem) const
{
CTriggerDlg * dlg = (CTriggerDlg *) pDlg;
CTrigger * trigger_item = (CTrigger *) pItem;
ASSERT_VALID (dlg);
ASSERT( dlg->IsKindOf( RUNTIME_CLASS( CTriggerDlg ) ) );
ASSERT_VALID (trigger_item);
ASSERT( trigger_item->IsKindOf( RUNTIME_CLASS( CTrigger ) ) );
// do matching colours
unsigned short iMatch = 0; // no matches yet
if (dlg->m_iMatchTextColour > 0) // colour selected
{
iMatch |= TRIGGER_MATCH_TEXT;
iMatch |= ((dlg->m_iMatchTextColour - 1) & 7) << 4;
}
if (dlg->m_iMatchBackColour > 0) // colour selected
{
iMatch |= TRIGGER_MATCH_BACK;
iMatch |= ((dlg->m_iMatchBackColour - 1) & 7) << 8;
}
if (dlg->m_iMatchBold != 2)
{
iMatch |= TRIGGER_MATCH_HILITE;
iMatch |= dlg->m_iMatchBold ? HILITE : 0;
}
if (dlg->m_iMatchItalic != 2)
{
iMatch |= TRIGGER_MATCH_BLINK;
iMatch |= dlg->m_iMatchItalic ? BLINK : 0;
}
if (dlg->m_iMatchInverse != 2)
{
iMatch |= TRIGGER_MATCH_INVERSE;
iMatch |= dlg->m_iMatchInverse ? INVERSE : 0;
}
bool bChanged = false;
switch (trigger_item->iSendTo)
{
case eSendToVariable:
if (trigger_item->strVariable != dlg->m_strVariable)
bChanged = true;
#ifdef PANE
case eSendToPane:
if (trigger_item->strPane != dlg->m_strVariable)
bChanged = true;
#endif // PANE
default: break;
} // end of switch
if (!bChanged &&
trigger_item->trigger == dlg->m_trigger &&
trigger_item->contents == dlg->m_contents &&
trigger_item->ignore_case == dlg->m_ignore_case &&
trigger_item->omit_from_log == dlg->m_omit_from_log &&
trigger_item->colour == (dlg->m_colour - 1) &&
trigger_item->bOmitFromOutput == dlg->m_bOmitFromOutput &&
trigger_item->bKeepEvaluating == dlg->m_bKeepEvaluating &&
trigger_item->bOneShot == dlg->m_bOneShot &&
trigger_item->bEnabled == dlg->m_bEnabled &&
trigger_item->strProcedure == dlg->m_strProcedure &&
trigger_item->strLabel == dlg->m_strLabel &&
trigger_item->iClipboardArg == dlg->m_iClipboardArg &&
trigger_item->iSendTo == dlg->m_iSendTo &&
trigger_item->bRegexp == dlg->m_bRegexp &&
trigger_item->bRepeat == dlg->m_bRepeat &&
trigger_item->bExpandVariables == dlg->m_bExpandVariables &&
trigger_item->iSequence == dlg->m_iSequence &&
trigger_item->bSoundIfInactive == dlg->m_bSoundIfInactive &&
trigger_item->bLowercaseWildcard == (bool) dlg->m_bLowercaseWildcard &&
trigger_item->iMatch == iMatch && // colour matching
((trigger_item->iStyle & HILITE) != 0) == dlg->m_bBold &&
((trigger_item->iStyle & BLINK) != 0) == dlg->m_bItalic &&
((trigger_item->iStyle & UNDERLINE) != 0) == dlg->m_bUnderline &&
((trigger_item->sound_to_play == dlg->m_sound_pathname) ||
(trigger_item->sound_to_play.IsEmpty () &&
(dlg->m_sound_pathname == NOSOUNDLIT))) &&
trigger_item->bTemporary == (bool) dlg->m_bTemporary &&
trigger_item->strGroup == dlg->m_strGroup &&
trigger_item->strVariable == dlg->m_strVariable &&
trigger_item->iOtherForeground == dlg->m_iOtherForeground &&
trigger_item->iOtherBackground == dlg->m_iOtherBackground &&
trigger_item->iLinesToMatch == dlg->m_iLinesToMatch &&