]> source.dussan.org Git - tigervnc.git/commitdiff
Now OptionsDialog allow the user to choose the pixel format
authorgeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Sun, 20 Mar 2005 09:47:56 +0000 (09:47 +0000)
committergeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Sun, 20 Mar 2005 09:47:56 +0000 (09:47 +0000)
from supported pixel formats list wich consist of default pixel formats
and user defined pixel formats.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@256 3789f03b-4d11-0410-bbf8-ca57d06f2519

rfbplayer/OptionsDialog.h

index 484791ad1c4a53b9987d74d9a1a72bc48ae89f2b..8a9acfd928027b81ea6eb8c2d644928c97266241 100644 (file)
@@ -24,8 +24,9 @@
 
 class OptionsDialog : public rfb::win32::Dialog {
 public:
-  OptionsDialog(PlayerOptions *_options) 
-  : Dialog(GetModuleHandle(0)), options(_options), combo(0) {}
+  OptionsDialog(PlayerOptions *_options, PixelFormatList *_supportedPF) 
+  : Dialog(GetModuleHandle(0)), options(_options), combo(0),
+  supportedPF(_supportedPF) {}
   // - Show the dialog and return true if OK was clicked,
   //   false in case of error or Cancel
   virtual bool showDialog(HWND parent) {
@@ -37,10 +38,11 @@ protected:
   virtual void initDialog() {
     combo = GetDlgItem(handle, IDC_PIXELFORMAT);
     SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)("Auto"));
-    SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)("8 bit depth (RGB332)"));
-    SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)("16 bit depth (RGB655)"));
-    SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)("24 bit depth (RGB888)"));
-    SendMessage(combo, CB_SETCURSEL, options->pixelFormatIndex, 0);
+    for (int i = 0; i < supportedPF->count(); i++) {
+      SendMessage(combo, CB_ADDSTRING, 
+        0, (LPARAM)(LPCTSTR)(((*supportedPF)[i]).format_name));
+    }
+    SendMessage(combo, CB_SETCURSEL, options->pixelFormatIndex + 1, 0);
     if (options->askPixelFormat) {
       setItemChecked(IDC_ASK_PF, true);
       enableItem(IDC_PIXELFORMAT, false);
@@ -52,7 +54,13 @@ protected:
   }
   virtual bool onOk() {
     if (!isItemChecked(IDC_ASK_PF)) {
-      options->pixelFormatIndex = SendMessage(combo, CB_GETCURSEL, 0, 0);
+      options->pixelFormatIndex = SendMessage(combo, CB_GETCURSEL, 0, 0) - 1;
+      if (options->pixelFormatIndex < 0) {
+        options->autoDetectPF = true;
+      } else {
+        options->setPF(&((*supportedPF)[options->pixelFormatIndex]).PF);
+        options->autoDetectPF = false;
+      }
     }
     options->askPixelFormat = isItemChecked(IDC_ASK_PF);
     options->acceptBell = isItemChecked(IDC_ACCEPT_BELL);
@@ -67,7 +75,7 @@ protected:
       enableItem(IDC_PIXELFORMAT, !isItemChecked(IDC_ASK_PF));
     }
     if (item == IDC_DEFAULT) {
-      SendMessage(combo, CB_SETCURSEL, DEFAULT_PF, 0);
+      SendMessage(combo, CB_SETCURSEL, DEFAULT_PF_INDEX, 0);
       enableItem(IDC_PIXELFORMAT, !DEFAULT_ASK_PF);
       setItemChecked(IDC_ASK_PF, DEFAULT_ASK_PF);
       setItemChecked(IDC_ACCEPT_BELL, DEFAULT_ACCEPT_BELL);
@@ -80,4 +88,5 @@ protected:
 
   HWND combo;
   PlayerOptions *options;
+  PixelFormatList *supportedPF;
 };
\ No newline at end of file