blob: a0ac38896d9bbbef1711ff3b3d83654ee458cd09 [file] [log] [blame]
george825e7af742005-03-10 14:26:00 +00001/* 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
25class OptionsDialog : public rfb::win32::Dialog {
26public:
george829a7f9912005-03-20 09:47:56 +000027 OptionsDialog(PlayerOptions *_options, PixelFormatList *_supportedPF)
28 : Dialog(GetModuleHandle(0)), options(_options), combo(0),
29 supportedPF(_supportedPF) {}
george825e7af742005-03-10 14:26:00 +000030 // - Show the dialog and return true if OK was clicked,
31 // false in case of error or Cancel
george82d9957b72005-03-11 14:22:14 +000032 virtual bool showDialog(HWND parent) {
33 return Dialog::showDialog(MAKEINTRESOURCE(IDD_OPTIONS), parent);
george825e7af742005-03-10 14:26:00 +000034 }
35protected:
36
37 // Dialog methods (protected)
38 virtual void initDialog() {
39 combo = GetDlgItem(handle, IDC_PIXELFORMAT);
40 SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)("Auto"));
george829a7f9912005-03-20 09:47:56 +000041 for (int i = 0; i < supportedPF->count(); i++) {
42 SendMessage(combo, CB_ADDSTRING,
43 0, (LPARAM)(LPCTSTR)(((*supportedPF)[i]).format_name));
44 }
45 SendMessage(combo, CB_SETCURSEL, options->pixelFormatIndex + 1, 0);
george825e7af742005-03-10 14:26:00 +000046 setItemChecked(IDC_ACCEPT_BELL, options->acceptBell);
47 setItemChecked(IDC_ACCEPT_CUT_TEXT, options->acceptCutText);
48 setItemChecked(IDC_AUTO_STORE_PARAM, options->autoStoreSettings);
49 setItemChecked(IDC_AUTOPLAY, options->autoPlay);
george82c3950072005-03-20 12:01:54 +000050 setItemChecked(IDC_BIG_ENDIAN, options->bigEndianFlag);
51 if (options->askPixelFormat) {
52 setItemChecked(IDC_ASK_PF, true);
53 enableItem(IDC_PIXELFORMAT, false);
54 enableItem(IDC_BIG_ENDIAN, false);
55 }
george825e7af742005-03-10 14:26:00 +000056 }
57 virtual bool onOk() {
george825e7af742005-03-10 14:26:00 +000058 options->askPixelFormat = isItemChecked(IDC_ASK_PF);
59 options->acceptBell = isItemChecked(IDC_ACCEPT_BELL);
60 options->acceptCutText = isItemChecked(IDC_ACCEPT_CUT_TEXT);
61 options->autoStoreSettings = isItemChecked(IDC_AUTO_STORE_PARAM);
62 options->autoPlay = isItemChecked(IDC_AUTOPLAY);
george82c3950072005-03-20 12:01:54 +000063 options->bigEndianFlag = isItemChecked(IDC_BIG_ENDIAN);
george82c3950072005-03-20 12:01:54 +000064 if (!options->askPixelFormat) {
george82dfb557b2005-03-21 18:26:50 +000065 options->pixelFormatIndex = int(SendMessage(combo, CB_GETCURSEL, 0, 0)) - 1;
george82c3950072005-03-20 12:01:54 +000066 if (options->pixelFormatIndex < 0) {
67 options->autoDetectPF = true;
68 } else {
69 options->setPF(&((*supportedPF)[options->pixelFormatIndex]).PF);
70 options->pixelFormat.bigEndian = options->bigEndianFlag;
71 options->autoDetectPF = false;
72 }
73 }
george82dfb557b2005-03-21 18:26:50 +000074 options->writeToRegistry();
george825e7af742005-03-10 14:26:00 +000075 return true;
76 }
77 virtual bool onCommand(int item, int cmd) {
78 if (item == IDC_ASK_PF) {
79 enableItem(IDC_PIXELFORMAT, !isItemChecked(IDC_ASK_PF));
george82c3950072005-03-20 12:01:54 +000080 enableItem(IDC_BIG_ENDIAN, !isItemChecked(IDC_ASK_PF));
george825e7af742005-03-10 14:26:00 +000081 }
82 if (item == IDC_DEFAULT) {
george829a7f9912005-03-20 09:47:56 +000083 SendMessage(combo, CB_SETCURSEL, DEFAULT_PF_INDEX, 0);
george825e7af742005-03-10 14:26:00 +000084 enableItem(IDC_PIXELFORMAT, !DEFAULT_ASK_PF);
85 setItemChecked(IDC_ASK_PF, DEFAULT_ASK_PF);
86 setItemChecked(IDC_ACCEPT_BELL, DEFAULT_ACCEPT_BELL);
87 setItemChecked(IDC_ACCEPT_CUT_TEXT, DEFAULT_ACCEPT_CUT_TEXT);
88 setItemChecked(IDC_AUTO_STORE_PARAM, DEFAULT_STORE_SETTINGS);
89 setItemChecked(IDC_AUTOPLAY, DEFAULT_AUTOPLAY);
george82c3950072005-03-20 12:01:54 +000090 setItemChecked(IDC_BIG_ENDIAN, DEFAULT_BIG_ENDIAN);
george825e7af742005-03-10 14:26:00 +000091 }
92 return false;
93 }
94
95 HWND combo;
96 PlayerOptions *options;
george829a7f9912005-03-20 09:47:56 +000097 PixelFormatList *supportedPF;
george825e7af742005-03-10 14:26:00 +000098};