diff options
author | george82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2005-03-28 12:07:31 +0000 |
---|---|---|
committer | george82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2005-03-28 12:07:31 +0000 |
commit | 103268619ba43c588bc6c831e575f7347f4bd917 (patch) | |
tree | 28666ddc3ab224c91300e81cfae21204d28abc72 | |
parent | 738f234897b15773afe5b72317687179b16fffb3 (diff) | |
download | tigervnc-103268619ba43c588bc6c831e575f7347f4bd917.tar.gz tigervnc-103268619ba43c588bc6c831e575f7347f4bd917.zip |
Implemented the possibility to add the user defined pixel formats.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@270 3789f03b-4d11-0410-bbf8-ca57d06f2519
-rw-r--r-- | rfbplayer/ChoosePixelFormatDialog.h | 2 | ||||
-rw-r--r-- | rfbplayer/EditPixelFormatDialog.h | 10 | ||||
-rw-r--r-- | rfbplayer/OptionsDialog.h | 18 | ||||
-rw-r--r-- | rfbplayer/UserPixelFormatsDialog.h | 46 | ||||
-rw-r--r-- | rfbplayer/rfbplayer.cxx | 5 |
5 files changed, 68 insertions, 13 deletions
diff --git a/rfbplayer/ChoosePixelFormatDialog.h b/rfbplayer/ChoosePixelFormatDialog.h index 8a3de457..ada820b3 100644 --- a/rfbplayer/ChoosePixelFormatDialog.h +++ b/rfbplayer/ChoosePixelFormatDialog.h @@ -39,7 +39,7 @@ protected: SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)("Auto")); for (int i = 0; i < supportedPF->count(); i++) { SendMessage(combo, CB_ADDSTRING, - 0, (LPARAM)(LPCTSTR)(((*supportedPF)[i]).format_name)); + 0, (LPARAM)(LPCTSTR)(((*supportedPF)[i])->format_name)); } SendMessage(combo, CB_SETCURSEL, pfIndex + 1, 0); setItemChecked(IDC_BIG_ENDIAN, bigEndian); diff --git a/rfbplayer/EditPixelFormatDialog.h b/rfbplayer/EditPixelFormatDialog.h index f0cdafe8..7a3d3e0a 100644 --- a/rfbplayer/EditPixelFormatDialog.h +++ b/rfbplayer/EditPixelFormatDialog.h @@ -20,6 +20,8 @@ #include <rfb_win32/Dialog.h> +#define MAX_STR_LEN 256 + class EditPixelFormatDialog : public rfb::win32::Dialog { public: EditPixelFormatDialog(PixelFormatList *_supportedPF, char *_format_name, @@ -68,8 +70,9 @@ protected: ((getItemString(IDC_BLUESHIFT_EDIT))[0] == '\0')) { strcpy(err_msg, "Please fill the all fields in the dialog."); } - if (supportedPF->getIndexByPFName(format_name) != - supportedPF->getIndexByPFName(getItemString(IDC_NAME_EDIT))) { + int newIndex = supportedPF->getIndexByPFName(getItemString(IDC_NAME_EDIT)); + if ((supportedPF->getIndexByPFName(format_name) != newIndex) && + (newIndex != -1)) { strcpy(err_msg, "The pixel format with that name is already exist."); } if (getItemInt(IDC_DEPTH_EDIT) <= 0) { @@ -80,8 +83,7 @@ protected: return false; } // Fill the pixel format structure - strncpy(format_name, getItemString(IDC_NAME_EDIT), sizeof(format_name)); - format_name[sizeof(format_name) - 1] = 0; + strCopy(format_name, getItemString(IDC_NAME_EDIT), MAX_STR_LEN); pf->bpp = getItemInt(IDC_BPP_COMBO); pf->depth = getItemInt(IDC_DEPTH_EDIT); pf->bigEndian = (SendMessage(GetDlgItem(handle, IDC_BIGENDIAN_COMBO), diff --git a/rfbplayer/OptionsDialog.h b/rfbplayer/OptionsDialog.h index 5ca67afc..a673844d 100644 --- a/rfbplayer/OptionsDialog.h +++ b/rfbplayer/OptionsDialog.h @@ -39,7 +39,7 @@ protected: SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)("Auto")); for (int i = 0; i < supportedPF->count(); i++) { SendMessage(combo, CB_ADDSTRING, - 0, (LPARAM)(LPCTSTR)(((*supportedPF)[i]).format_name)); + 0, (LPARAM)(LPCTSTR)(((*supportedPF)[i])->format_name)); } SendMessage(combo, CB_SETCURSEL, options->pixelFormatIndex + 1, 0); setItemChecked(IDC_ACCEPT_BELL, options->acceptBell); @@ -65,7 +65,7 @@ protected: if (options->pixelFormatIndex < 0) { options->autoDetectPF = true; } else { - options->setPF(&((*supportedPF)[options->pixelFormatIndex]).PF); + options->setPF(&((*supportedPF)[options->pixelFormatIndex])->PF); options->pixelFormat.bigEndian = options->bigEndianFlag; options->autoDetectPF = false; } @@ -90,7 +90,19 @@ protected: } if (item == IDC_EDIT_UPF) { UserPixelFormatsDialog UpfListDialog(supportedPF); - UpfListDialog.showDialog(handle); + if (UpfListDialog.showDialog(handle)) { + int index = SendMessage(combo, CB_GETCURSEL, 0, 0); + SendMessage(combo, CB_RESETCONTENT, 0, 0); + SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)("Auto")); + for (int i = 0; i < supportedPF->count(); i++) { + SendMessage(combo, CB_ADDSTRING, + 0, (LPARAM)(LPCTSTR)(((*supportedPF)[i])->format_name)); + } + if ( index > (SendMessage(combo, CB_GETCOUNT, 0, 0) - 1)) { + index = SendMessage(combo, CB_GETCOUNT, 0, 0) - 1; + } + SendMessage(combo, CB_SETCURSEL, index, 0); + } } return false; } diff --git a/rfbplayer/UserPixelFormatsDialog.h b/rfbplayer/UserPixelFormatsDialog.h index e3d1aa3d..72244e95 100644 --- a/rfbplayer/UserPixelFormatsDialog.h +++ b/rfbplayer/UserPixelFormatsDialog.h @@ -18,7 +18,9 @@ // -=- UserPixelFormatsDialog.h -#include <rfb_win32/Dialog.h> +#include <rfbplayer/EditPixelFormatDialog.h> + +#define UPF_REGISTRY_PATH "Software\\TightVnc\\RfbPlayer\\UserDefinedPF" class UserPixelFormatsDialog : public rfb::win32::Dialog { public: @@ -36,23 +38,63 @@ protected: pfList = GetDlgItem(handle, IDC_PF_LIST); for (int i = supportedPF->getDefaultPFCount(); i < supportedPF->count(); i++) { SendMessage(pfList, LB_ADDSTRING, - 0, (LPARAM)(LPCTSTR)(((*supportedPF)[i]).format_name)); + 0, (LPARAM)(LPCTSTR)(((*supportedPF)[i])->format_name)); } SendMessage(pfList, LB_SETCURSEL, 0, 0); } virtual bool onCommand(int item, int cmd) { switch (item) { case IDC_ADD_BUTTON: + { + char format_name[MAX_STR_LEN] = ""; + PixelFormat pf(32, 24, 0, 1, 0, 0, 0, 0, 0, 0); + EditPixelFormatDialog edit(supportedPF, format_name, &pf); + if (edit.showDialog(handle)) { + supportedPF->add(format_name, pf); + SendMessage(pfList, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)format_name); + }; + (*supportedPF)[15]; + } break; case IDC_REMOVE_BUTTON: + { + int index = SendMessage(pfList, LB_GETCURSEL, 0, 0); + if (index == LB_ERR) { + MessageBox(handle, "You must select the pixel format for remove.", + "RfbPlayer", MB_OK | MB_ICONWARNING); + return false; + } else { + supportedPF->remove(supportedPF->getDefaultPFCount() + index); + SendMessage(pfList, LB_DELETESTRING, index, 0); + } + } break; + case IDC_PF_LIST: + if (cmd != LBN_DBLCLK) break; case IDC_EDIT_BUTTON: + { + int index = SendMessage(pfList, LB_GETCURSEL, 0, 0); + PixelFormat *pf = + &(supportedPF->operator[](index + supportedPF->getDefaultPFCount())->PF); + char *format_name = + (supportedPF)->operator[](index + supportedPF->getDefaultPFCount())->format_name; + EditPixelFormatDialog edit(supportedPF, format_name, pf); + if (edit.showDialog(handle)) { + SendMessage(pfList, LB_DELETESTRING, index, 0); + SendMessage(pfList, LB_INSERTSTRING, index, (LPARAM)(LPCTSTR)format_name); + SendMessage(pfList, LB_SETCURSEL, index, 0); + }; + } break; default: break; } return false; } + virtual bool onOk() { + supportedPF->writeUserDefinedPF(HKEY_CURRENT_USER, UPF_REGISTRY_PATH); + return true; + } HWND pfList; PixelFormatList *supportedPF; diff --git a/rfbplayer/rfbplayer.cxx b/rfbplayer/rfbplayer.cxx index da479993..3e9357df 100644 --- a/rfbplayer/rfbplayer.cxx +++ b/rfbplayer/rfbplayer.cxx @@ -65,7 +65,6 @@ char usage_msg[] = // -=- RfbPlayer's defines #define strcasecmp _stricmp -#define UPF_REGISTRY_PATH "Software\\TightVnc\\RfbPlayer\\UserDefinedPF" #define MAX_SPEED 10.00 #define CALCULATION_ERROR MAX_SPEED / 1000 #define MAX_POS_TRACKBAR_RANGE 50 @@ -919,7 +918,7 @@ void RfbPlayer::serverInit() { options.setPF((PixelFormat *)&cp.pf()); } else { options.autoDetectPF = false; - options.setPF(&supportedPF[pixelFormatIndex].PF); + options.setPF(&supportedPF[pixelFormatIndex]->PF); options.pixelFormat.bigEndian = choosePixelFormatDialog.isBigEndian(); } } else { @@ -931,7 +930,7 @@ void RfbPlayer::serverInit() { if (options.autoDetectPF) { options.setPF((PixelFormat *)&cp.pf()); } else { - options.setPF(&supportedPF[options.pixelFormatIndex].PF); + options.setPF(&supportedPF[options.pixelFormatIndex]->PF); options.pixelFormat.bigEndian = options.bigEndianFlag; } } |