Added ability to set screen options from the windows launch dialog.

This commit is contained in:
crs 2003-01-25 13:34:51 +00:00
parent 188d89108b
commit 6b3e451b83
5 changed files with 132 additions and 17 deletions

View File

@ -35,6 +35,7 @@ class CScreenInfo {
public: public:
CString m_screen; CString m_screen;
CStringList m_aliases; CStringList m_aliases;
CConfig::CScreenOptions m_options;
}; };
class CChildWaitInfo { class CChildWaitInfo {
@ -266,6 +267,14 @@ addScreen(HWND hwnd)
ARG->m_config.addAlias(info.m_screen, *index); ARG->m_config.addAlias(info.m_screen, *index);
} }
// set options
ARG->m_config.removeOptions(info.m_screen);
for (CConfig::CScreenOptions::const_iterator
index = info.m_options.begin();
index != info.m_options.end(); ++index) {
ARG->m_config.addOption(info.m_screen, index->first, index->second);
}
// update neighbors // update neighbors
updateNeighbors(hwnd); updateNeighbors(hwnd);
enableScreensControls(hwnd); enableScreensControls(hwnd);
@ -295,6 +304,11 @@ editScreen(HWND hwnd)
info.m_aliases.push_back(index->first); info.m_aliases.push_back(index->first);
} }
} }
const CConfig::CScreenOptions* options =
ARG->m_config.getOptions(info.m_screen);
if (options != NULL) {
info.m_options = *options;
}
// save current info // save current info
CScreenInfo oldInfo = info; CScreenInfo oldInfo = info;
@ -320,6 +334,14 @@ editScreen(HWND hwnd)
ARG->m_config.addAlias(info.m_screen, *index); ARG->m_config.addAlias(info.m_screen, *index);
} }
// set options
ARG->m_config.removeOptions(info.m_screen);
for (CConfig::CScreenOptions::const_iterator
index = info.m_options.begin();
index != info.m_options.end(); ++index) {
ARG->m_config.addOption(info.m_screen, index->first, index->second);
}
// update list // update list
CString item = CStringUtil::print("%d. %s", CString item = CStringUtil::print("%d. %s",
index + 1, info.m_screen.c_str()); index + 1, info.m_screen.c_str());
@ -740,6 +762,18 @@ addDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_INITDIALOG: { case WM_INITDIALOG: {
info = (CScreenInfo*)lParam; info = (CScreenInfo*)lParam;
// set title
CString title;
if (info->m_screen.empty()) {
title = getString(IDS_ADD_SCREEN);
}
else {
title = CStringUtil::format(
getString(IDS_EDIT_SCREEN).c_str(),
info->m_screen.c_str());
}
SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)title.c_str());
// fill in screen name // fill in screen name
HWND child = getItem(hwnd, IDC_ADD_SCREEN_NAME_EDIT); HWND child = getItem(hwnd, IDC_ADD_SCREEN_NAME_EDIT);
SendMessage(child, WM_SETTEXT, 0, (LPARAM)info->m_screen.c_str()); SendMessage(child, WM_SETTEXT, 0, (LPARAM)info->m_screen.c_str());
@ -756,6 +790,25 @@ addDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
child = getItem(hwnd, IDC_ADD_ALIASES_EDIT); child = getItem(hwnd, IDC_ADD_ALIASES_EDIT);
SendMessage(child, WM_SETTEXT, 0, (LPARAM)aliases.c_str()); SendMessage(child, WM_SETTEXT, 0, (LPARAM)aliases.c_str());
// set options
CConfig::CScreenOptions::const_iterator index;
child = getItem(hwnd, IDC_ADD_HD_CAPS_CHECK);
index = info->m_options.find(kOptionHalfDuplexCapsLock);
if (index != info->m_options.end() && index->second != 0) {
SendMessage(child, BM_SETCHECK, BST_CHECKED, 0);
}
else {
SendMessage(child, BM_SETCHECK, BST_UNCHECKED, 0);
}
child = getItem(hwnd, IDC_ADD_HD_NUM_CHECK);
index = info->m_options.find(kOptionHalfDuplexNumLock);
if (index != info->m_options.end() && index->second != 0) {
SendMessage(child, BM_SETCHECK, BST_CHECKED, 0);
}
else {
SendMessage(child, BM_SETCHECK, BST_UNCHECKED, 0);
}
return TRUE; return TRUE;
} }
@ -824,10 +877,26 @@ addDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
} }
// save data // save name data
info->m_screen = newName; info->m_screen = newName;
info->m_aliases = newAliases; info->m_aliases = newAliases;
// save options
child = getItem(hwnd, IDC_ADD_HD_CAPS_CHECK);
if (SendMessage(child, BM_GETCHECK, 0, 0) == BST_CHECKED) {
info->m_options[kOptionHalfDuplexCapsLock] = 1;
}
else {
info->m_options.erase(kOptionHalfDuplexCapsLock);
}
child = getItem(hwnd, IDC_ADD_HD_NUM_CHECK);
if (SendMessage(child, BM_GETCHECK, 0, 0) == BST_CHECKED) {
info->m_options[kOptionHalfDuplexNumLock] = 1;
}
else {
info->m_options.erase(kOptionHalfDuplexNumLock);
}
// success // success
EndDialog(hwnd, 1); EndDialog(hwnd, 1);
info = NULL; info = NULL;

View File

@ -106,18 +106,25 @@ BEGIN
PUSHBUTTON "Quit",IDCANCEL,243,241,50,14 PUSHBUTTON "Quit",IDCANCEL,243,241,50,14
END END
IDD_ADD DIALOG DISCARDABLE 0, 0, 172, 95 IDD_ADD DIALOG DISCARDABLE 0, 0, 192, 170
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
CAPTION "Add Screen" CAPTION "Add Screen"
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
LTEXT "Screen Name:",IDC_STATIC,7,9,46,8 LTEXT "&Screen Name:",IDC_STATIC,7,9,46,8
EDITTEXT IDC_ADD_SCREEN_NAME_EDIT,59,7,106,12,ES_AUTOHSCROLL EDITTEXT IDC_ADD_SCREEN_NAME_EDIT,79,7,106,12,ES_AUTOHSCROLL
LTEXT "Aliases:",IDC_STATIC,7,25,25,8 LTEXT "&Aliases:",IDC_STATIC,7,25,25,8
EDITTEXT IDC_ADD_ALIASES_EDIT,59,26,106,40,ES_MULTILINE | EDITTEXT IDC_ADD_ALIASES_EDIT,79,26,106,40,ES_MULTILINE |
ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN
DEFPUSHBUTTON "OK",IDOK,59,74,50,14 LTEXT "If your Caps Lock or Num Lock keys behave strangely on this client screen then try turning the half-duplex options on and reconnect the client.",
PUSHBUTTON "Cancel",IDCANCEL,115,74,50,14 IDC_STATIC,13,82,165,25
CONTROL "Half-duplex &Caps Lock",IDC_ADD_HD_CAPS_CHECK,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,13,110,165,10
CONTROL "Half-duplex &Num Lock",IDC_ADD_HD_NUM_CHECK,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,13,122,165,10
DEFPUSHBUTTON "OK",IDOK,79,149,50,14
PUSHBUTTON "Cancel",IDCANCEL,135,149,50,14
GROUPBOX "Options",IDC_STATIC,7,72,178,64
END END
IDD_WAIT DIALOG DISCARDABLE 0, 0, 186, 54 IDD_WAIT DIALOG DISCARDABLE 0, 0, 186, 54
@ -170,9 +177,9 @@ BEGIN
IDD_ADD, DIALOG IDD_ADD, DIALOG
BEGIN BEGIN
LEFTMARGIN, 7 LEFTMARGIN, 7
RIGHTMARGIN, 165 RIGHTMARGIN, 185
TOPMARGIN, 7 TOPMARGIN, 7
BOTTOMMARGIN, 88 BOTTOMMARGIN, 163
END END
IDD_WAIT, DIALOG IDD_WAIT, DIALOG
@ -255,6 +262,8 @@ BEGIN
IDS_INVALID_SERVER_NAME "Server name `%{1}' is invalid." IDS_INVALID_SERVER_NAME "Server name `%{1}' is invalid."
IDS_TITLE "Synergy - Version %{1}" IDS_TITLE "Synergy - Version %{1}"
IDS_SERVER_IS_CLIENT "Please enter the computer name of the synergy server, not\nthe name of this computer, in the Server Host Name field." IDS_SERVER_IS_CLIENT "Please enter the computer name of the synergy server, not\nthe name of this computer, in the Server Host Name field."
IDS_ADD_SCREEN "Add Screen"
IDS_EDIT_SCREEN "Edit Screen %{1}"
END END
#endif // English (U.S.) resources #endif // English (U.S.) resources

View File

@ -38,6 +38,8 @@
#define IDS_INVALID_SERVER_NAME 34 #define IDS_INVALID_SERVER_NAME 34
#define IDS_TITLE 35 #define IDS_TITLE 35
#define IDS_SERVER_IS_CLIENT 36 #define IDS_SERVER_IS_CLIENT 36
#define IDS_ADD_SCREEN 37
#define IDS_EDIT_SCREEN 38
#define IDD_MAIN 101 #define IDD_MAIN 101
#define IDD_ADD 102 #define IDD_ADD 102
#define IDD_WAIT 103 #define IDD_WAIT 103
@ -59,6 +61,7 @@
#define IDC_ADD_SCREEN_NAME_EDIT 1020 #define IDC_ADD_SCREEN_NAME_EDIT 1020
#define IDC_MAIN_SERVER_REMOVE_BUTTON 1020 #define IDC_MAIN_SERVER_REMOVE_BUTTON 1020
#define IDC_ADD_ALIASES_EDIT 1021 #define IDC_ADD_ALIASES_EDIT 1021
#define IDC_MAIN_SERVER_OPTIONS_BUTTON 1021
#define IDC_MAIN_SERVER_LEFT_COMBO 1022 #define IDC_MAIN_SERVER_LEFT_COMBO 1022
#define IDC_MAIN_SERVER_RIGHT_COMBO 1023 #define IDC_MAIN_SERVER_RIGHT_COMBO 1023
#define IDC_MAIN_SERVER_TOP_COMBO 1024 #define IDC_MAIN_SERVER_TOP_COMBO 1024
@ -74,6 +77,8 @@
#define IDC_AUTOSTART_INSTALL_SYSTEM 1034 #define IDC_AUTOSTART_INSTALL_SYSTEM 1034
#define IDC_MAIN_AUTOSTART 1035 #define IDC_MAIN_AUTOSTART 1035
#define IDC_MAIN_DEBUG 1036 #define IDC_MAIN_DEBUG 1036
#define IDC_ADD_HD_CAPS_CHECK 1037
#define IDC_ADD_HD_NUM_CHECK 1038
// Next default values for new objects // Next default values for new objects
// //
@ -82,7 +87,7 @@
#define _APS_NO_MFC 1 #define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 106 #define _APS_NEXT_RESOURCE_VALUE 106
#define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1037 #define _APS_NEXT_CONTROL_VALUE 1038
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101
#endif #endif
#endif #endif

View File

@ -241,7 +241,7 @@ CConfig::setHTTPAddress(const CNetworkAddress& addr)
} }
bool bool
CConfig::addOption(const CString& name, UInt32 option, SInt32 value) CConfig::addOption(const CString& name, OptionID option, OptionValue value)
{ {
// find cell // find cell
CCellMap::iterator index = m_map.find(name); CCellMap::iterator index = m_map.find(name);
@ -255,7 +255,7 @@ CConfig::addOption(const CString& name, UInt32 option, SInt32 value)
} }
bool bool
CConfig::removeOption(const CString& name, UInt32 option) CConfig::removeOption(const CString& name, OptionID option)
{ {
// find cell // find cell
CCellMap::iterator index = m_map.find(name); CCellMap::iterator index = m_map.find(name);
@ -268,6 +268,20 @@ CConfig::removeOption(const CString& name, UInt32 option)
return true; return true;
} }
bool
CConfig::removeOptions(const CString& name)
{
// find cell
CCellMap::iterator index = m_map.find(name);
if (index == m_map.end()) {
return false;
}
// remove option
index->second.m_options.clear();
return true;
}
bool bool
CConfig::isValidScreenName(const CString& name) const CConfig::isValidScreenName(const CString& name) const
{ {
@ -421,6 +435,17 @@ CConfig::operator==(const CConfig& x) const
for (CCellMap::const_iterator index1 = m_map.begin(), for (CCellMap::const_iterator index1 = m_map.begin(),
index2 = x.m_map.begin(); index2 = x.m_map.begin();
index1 != m_map.end(); ++index1, ++index2) { index1 != m_map.end(); ++index1, ++index2) {
// compare names
if (!CStringUtil::CaselessCmp::equal(index1->first, index2->first)) {
return false;
}
// compare options
if (index1->second.m_options != index2->second.m_options) {
return false;
}
// compare neighbors
for (UInt32 i = 0; i <= kLastDirection - kFirstDirection; ++i) { for (UInt32 i = 0; i <= kLastDirection - kFirstDirection; ++i) {
if (!CStringUtil::CaselessCmp::equal(index1->second.m_neighbor[i], if (!CStringUtil::CaselessCmp::equal(index1->second.m_neighbor[i],
index2->second.m_neighbor[i])) { index2->second.m_neighbor[i])) {

View File

@ -188,7 +188,7 @@ public:
is a known screen. is a known screen.
*/ */
bool addOption(const CString& name, bool addOption(const CString& name,
UInt32 option, SInt32 value); OptionID option, OptionValue value);
//! Remove a screen option //! Remove a screen option
/*! /*!
@ -196,7 +196,14 @@ public:
nothing if the option doesn't exist on the screen. Returns true nothing if the option doesn't exist on the screen. Returns true
iff \c name is a known screen. iff \c name is a known screen.
*/ */
bool removeOption(const CString& name, UInt32 option); bool removeOption(const CString& name, OptionID option);
//! Remove a screen options
/*!
Removes all options and values from the named screen. Returns true
iff \c name is a known screen.
*/
bool removeOptions(const CString& name);
//@} //@}
//! @name accessors //! @name accessors