george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2004 TightVNC Team. All Rights Reserved. |
| 2 | * |
| 3 | * This is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This software is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this software; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 16 | * USA. |
| 17 | */ |
| 18 | |
| 19 | // -=- OptionsDialog.h |
| 20 | |
| 21 | #include <rfb_win32/Dialog.h> |
| 22 | |
| 23 | #include <rfbplayer/PlayerOptions.h> |
| 24 | |
| 25 | class OptionsDialog : public rfb::win32::Dialog { |
| 26 | public: |
| 27 | OptionsDialog(PlayerOptions *_options) |
| 28 | : Dialog(GetModuleHandle(0)), options(_options), combo(0) {} |
| 29 | // - Show the dialog and return true if OK was clicked, |
| 30 | // false in case of error or Cancel |
| 31 | virtual bool showDialog() { |
| 32 | return Dialog::showDialog(MAKEINTRESOURCE(IDD_OPTIONS)); |
| 33 | } |
| 34 | protected: |
| 35 | |
| 36 | // Dialog methods (protected) |
| 37 | virtual void initDialog() { |
| 38 | combo = GetDlgItem(handle, IDC_PIXELFORMAT); |
| 39 | SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)("Auto")); |
| 40 | SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)("8 bit depth (RGB332)")); |
| 41 | SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)("16 bit depth (RGB655)")); |
| 42 | SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)("24 bit depth (RGB888)")); |
| 43 | SendMessage(combo, CB_SETCURSEL, options->pixelFormat, 0); |
| 44 | if (options->askPixelFormat) { |
| 45 | setItemChecked(IDC_ASK_PF, true); |
| 46 | enableItem(IDC_PIXELFORMAT, false); |
| 47 | } |
| 48 | setItemChecked(IDC_ACCEPT_BELL, options->acceptBell); |
| 49 | setItemChecked(IDC_ACCEPT_CUT_TEXT, options->acceptCutText); |
| 50 | setItemChecked(IDC_AUTO_STORE_PARAM, options->autoStoreSettings); |
| 51 | setItemChecked(IDC_AUTOPLAY, options->autoPlay); |
| 52 | } |
| 53 | virtual bool onOk() { |
| 54 | if (!isItemChecked(IDC_ASK_PF)) { |
| 55 | options->pixelFormat = SendMessage(combo, CB_GETCURSEL, 0, 0); |
| 56 | } |
| 57 | options->askPixelFormat = isItemChecked(IDC_ASK_PF); |
| 58 | options->acceptBell = isItemChecked(IDC_ACCEPT_BELL); |
| 59 | options->acceptCutText = isItemChecked(IDC_ACCEPT_CUT_TEXT); |
| 60 | options->autoStoreSettings = isItemChecked(IDC_AUTO_STORE_PARAM); |
| 61 | options->autoPlay = isItemChecked(IDC_AUTOPLAY); |
| 62 | options->writeToRegistry(); |
| 63 | return true; |
| 64 | } |
| 65 | virtual bool onCommand(int item, int cmd) { |
| 66 | if (item == IDC_ASK_PF) { |
| 67 | enableItem(IDC_PIXELFORMAT, !isItemChecked(IDC_ASK_PF)); |
| 68 | } |
| 69 | if (item == IDC_DEFAULT) { |
| 70 | SendMessage(combo, CB_SETCURSEL, DEFAULT_PF, 0); |
| 71 | enableItem(IDC_PIXELFORMAT, !DEFAULT_ASK_PF); |
| 72 | setItemChecked(IDC_ASK_PF, DEFAULT_ASK_PF); |
| 73 | setItemChecked(IDC_ACCEPT_BELL, DEFAULT_ACCEPT_BELL); |
| 74 | setItemChecked(IDC_ACCEPT_CUT_TEXT, DEFAULT_ACCEPT_CUT_TEXT); |
| 75 | setItemChecked(IDC_AUTO_STORE_PARAM, DEFAULT_STORE_SETTINGS); |
| 76 | setItemChecked(IDC_AUTOPLAY, DEFAULT_AUTOPLAY); |
| 77 | } |
| 78 | return false; |
| 79 | } |
| 80 | |
| 81 | HWND combo; |
| 82 | PlayerOptions *options; |
| 83 | }; |