george82 | 3d0c56e | 2005-03-09 08:30:27 +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 | // -=- ChoosePixelFormatDialog.h |
| 20 | |
| 21 | #include <rfb_win32/Dialog.h> |
| 22 | |
| 23 | class ChoosePixelFormatDialog : public rfb::win32::Dialog { |
| 24 | public: |
george82 | c7e9f79 | 2005-03-20 12:52:46 +0000 | [diff] [blame^] | 25 | ChoosePixelFormatDialog(PixelFormatList *_supportedPF) |
| 26 | : Dialog(GetModuleHandle(0)), supportedPF(_supportedPF), combo(0) {} |
george82 | 3d0c56e | 2005-03-09 08:30:27 +0000 | [diff] [blame] | 27 | // - Show the dialog and return true if OK was clicked, |
| 28 | // false in case of error or Cancel |
george82 | d9957b7 | 2005-03-11 14:22:14 +0000 | [diff] [blame] | 29 | virtual bool showDialog(HWND parent) { |
| 30 | return Dialog::showDialog(MAKEINTRESOURCE(IDD_PIXELFORMAT), parent); |
george82 | 3d0c56e | 2005-03-09 08:30:27 +0000 | [diff] [blame] | 31 | } |
george82 | c7e9f79 | 2005-03-20 12:52:46 +0000 | [diff] [blame^] | 32 | const long getPFIndex() const {return pfIndex;} |
| 33 | bool isBigEndian() {return isItemChecked(IDC_BIG_ENDIAN);} |
george82 | 3d0c56e | 2005-03-09 08:30:27 +0000 | [diff] [blame] | 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")); |
george82 | acb5658 | 2005-03-20 09:46:44 +0000 | [diff] [blame] | 40 | for (int i = 0; i < supportedPF->count(); i++) { |
| 41 | SendMessage(combo, CB_ADDSTRING, |
| 42 | 0, (LPARAM)(LPCTSTR)(((*supportedPF)[i]).format_name)); |
| 43 | } |
| 44 | SendMessage(combo, CB_SETCURSEL, pfIndex + 1, 0); |
george82 | c7e9f79 | 2005-03-20 12:52:46 +0000 | [diff] [blame^] | 45 | setItemChecked(IDC_BIG_ENDIAN, bigEndian); |
george82 | 3d0c56e | 2005-03-09 08:30:27 +0000 | [diff] [blame] | 46 | } |
| 47 | virtual bool onOk() { |
george82 | acb5658 | 2005-03-20 09:46:44 +0000 | [diff] [blame] | 48 | pfIndex = SendMessage(combo, CB_GETCURSEL, 0, 0) - 1; |
george82 | c7e9f79 | 2005-03-20 12:52:46 +0000 | [diff] [blame^] | 49 | bigEndian = isItemChecked(IDC_BIG_ENDIAN); |
george82 | 3d0c56e | 2005-03-09 08:30:27 +0000 | [diff] [blame] | 50 | return true; |
| 51 | } |
| 52 | virtual bool onCancel() { |
george82 | 3d0c56e | 2005-03-09 08:30:27 +0000 | [diff] [blame] | 53 | return false; |
| 54 | } |
george82 | c7e9f79 | 2005-03-20 12:52:46 +0000 | [diff] [blame^] | 55 | static long pfIndex; |
| 56 | static bool bigEndian; |
george82 | acb5658 | 2005-03-20 09:46:44 +0000 | [diff] [blame] | 57 | PixelFormatList *supportedPF; |
george82 | 3d0c56e | 2005-03-09 08:30:27 +0000 | [diff] [blame] | 58 | HWND combo; |
| 59 | }; |