blob: 8a9acfd928027b81ea6eb8c2d644928c97266241 [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 if (options->askPixelFormat) {
47 setItemChecked(IDC_ASK_PF, true);
48 enableItem(IDC_PIXELFORMAT, false);
49 }
50 setItemChecked(IDC_ACCEPT_BELL, options->acceptBell);
51 setItemChecked(IDC_ACCEPT_CUT_TEXT, options->acceptCutText);
52 setItemChecked(IDC_AUTO_STORE_PARAM, options->autoStoreSettings);
53 setItemChecked(IDC_AUTOPLAY, options->autoPlay);
54 }
55 virtual bool onOk() {
56 if (!isItemChecked(IDC_ASK_PF)) {
george829a7f9912005-03-20 09:47:56 +000057 options->pixelFormatIndex = SendMessage(combo, CB_GETCURSEL, 0, 0) - 1;
58 if (options->pixelFormatIndex < 0) {
59 options->autoDetectPF = true;
60 } else {
61 options->setPF(&((*supportedPF)[options->pixelFormatIndex]).PF);
62 options->autoDetectPF = false;
63 }
george825e7af742005-03-10 14:26:00 +000064 }
65 options->askPixelFormat = isItemChecked(IDC_ASK_PF);
66 options->acceptBell = isItemChecked(IDC_ACCEPT_BELL);
67 options->acceptCutText = isItemChecked(IDC_ACCEPT_CUT_TEXT);
68 options->autoStoreSettings = isItemChecked(IDC_AUTO_STORE_PARAM);
69 options->autoPlay = isItemChecked(IDC_AUTOPLAY);
70 options->writeToRegistry();
71 return true;
72 }
73 virtual bool onCommand(int item, int cmd) {
74 if (item == IDC_ASK_PF) {
75 enableItem(IDC_PIXELFORMAT, !isItemChecked(IDC_ASK_PF));
76 }
77 if (item == IDC_DEFAULT) {
george829a7f9912005-03-20 09:47:56 +000078 SendMessage(combo, CB_SETCURSEL, DEFAULT_PF_INDEX, 0);
george825e7af742005-03-10 14:26:00 +000079 enableItem(IDC_PIXELFORMAT, !DEFAULT_ASK_PF);
80 setItemChecked(IDC_ASK_PF, DEFAULT_ASK_PF);
81 setItemChecked(IDC_ACCEPT_BELL, DEFAULT_ACCEPT_BELL);
82 setItemChecked(IDC_ACCEPT_CUT_TEXT, DEFAULT_ACCEPT_CUT_TEXT);
83 setItemChecked(IDC_AUTO_STORE_PARAM, DEFAULT_STORE_SETTINGS);
84 setItemChecked(IDC_AUTOPLAY, DEFAULT_AUTOPLAY);
85 }
86 return false;
87 }
88
89 HWND combo;
90 PlayerOptions *options;
george829a7f9912005-03-20 09:47:56 +000091 PixelFormatList *supportedPF;
george825e7af742005-03-10 14:26:00 +000092};