blob: ada820b3ab02c60a2c8dd4bd9ac159ddf848646d [file] [log] [blame]
george823d0c56e2005-03-09 08:30:27 +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// -=- ChoosePixelFormatDialog.h
20
21#include <rfb_win32/Dialog.h>
22
23class ChoosePixelFormatDialog : public rfb::win32::Dialog {
24public:
george82c7e9f792005-03-20 12:52:46 +000025 ChoosePixelFormatDialog(PixelFormatList *_supportedPF)
26 : Dialog(GetModuleHandle(0)), supportedPF(_supportedPF), combo(0) {}
george823d0c56e2005-03-09 08:30:27 +000027 // - Show the dialog and return true if OK was clicked,
28 // false in case of error or Cancel
george82d9957b72005-03-11 14:22:14 +000029 virtual bool showDialog(HWND parent) {
30 return Dialog::showDialog(MAKEINTRESOURCE(IDD_PIXELFORMAT), parent);
george823d0c56e2005-03-09 08:30:27 +000031 }
george82c7e9f792005-03-20 12:52:46 +000032 const long getPFIndex() const {return pfIndex;}
33 bool isBigEndian() {return isItemChecked(IDC_BIG_ENDIAN);}
george823d0c56e2005-03-09 08:30:27 +000034protected:
35
36 // Dialog methods (protected)
37 virtual void initDialog() {
38 combo = GetDlgItem(handle, IDC_PIXELFORMAT);
39 SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)("Auto"));
george82acb56582005-03-20 09:46:44 +000040 for (int i = 0; i < supportedPF->count(); i++) {
41 SendMessage(combo, CB_ADDSTRING,
george8210326862005-03-28 12:07:31 +000042 0, (LPARAM)(LPCTSTR)(((*supportedPF)[i])->format_name));
george82acb56582005-03-20 09:46:44 +000043 }
44 SendMessage(combo, CB_SETCURSEL, pfIndex + 1, 0);
george82c7e9f792005-03-20 12:52:46 +000045 setItemChecked(IDC_BIG_ENDIAN, bigEndian);
george823d0c56e2005-03-09 08:30:27 +000046 }
47 virtual bool onOk() {
george82acb56582005-03-20 09:46:44 +000048 pfIndex = SendMessage(combo, CB_GETCURSEL, 0, 0) - 1;
george82c7e9f792005-03-20 12:52:46 +000049 bigEndian = isItemChecked(IDC_BIG_ENDIAN);
george823d0c56e2005-03-09 08:30:27 +000050 return true;
51 }
52 virtual bool onCancel() {
george823d0c56e2005-03-09 08:30:27 +000053 return false;
54 }
george82c7e9f792005-03-20 12:52:46 +000055 static long pfIndex;
56 static bool bigEndian;
george82acb56582005-03-20 09:46:44 +000057 PixelFormatList *supportedPF;
george823d0c56e2005-03-09 08:30:27 +000058 HWND combo;
59};