]> source.dussan.org Git - tigervnc.git/commitdiff
1. Added PlayerOptions class for managing the player options.
authorgeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Thu, 10 Mar 2005 14:26:00 +0000 (14:26 +0000)
committergeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Thu, 10 Mar 2005 14:26:00 +0000 (14:26 +0000)
2. Added OptionsDialog.
3. Added ChoosePixelFormatDialog class. It is used for choosing the pixel
format before the session playing.
4. Code improvements.

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

rfbplayer/ChoosePixelFormatDialog.h
rfbplayer/OptionsDialog.h [new file with mode: 0644]
rfbplayer/PlayerOptions.cxx [new file with mode: 0644]
rfbplayer/PlayerOptions.h [new file with mode: 0644]
rfbplayer/resource.h
rfbplayer/rfbplayer.cxx
rfbplayer/rfbplayer.dsp
rfbplayer/rfbplayer.h
rfbplayer/rfbplayer.rc

index 5e54f5a6c8d3f08571197c870386a81a56e0d53d..b85d4d992b02861007acbe276d8a1714d5d512cd 100644 (file)
@@ -39,7 +39,6 @@ protected:
     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_ADDSTRING, 0, (LPARAM)(LPCTSTR)("24 bit depth (RGB888)"));
     SendMessage(combo, CB_SETCURSEL, pf, 0);
   }
   virtual bool onOk() {
diff --git a/rfbplayer/OptionsDialog.h b/rfbplayer/OptionsDialog.h
new file mode 100644 (file)
index 0000000..c7affca
--- /dev/null
@@ -0,0 +1,83 @@
+/* Copyright (C) 2004 TightVNC Team.  All Rights Reserved.
+ *    
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+
+// -=- OptionsDialog.h
+
+#include <rfb_win32/Dialog.h>
+
+#include <rfbplayer/PlayerOptions.h>
+
+class OptionsDialog : public rfb::win32::Dialog {
+public:
+  OptionsDialog(PlayerOptions *_options) 
+  : Dialog(GetModuleHandle(0)), options(_options), combo(0) {}
+  // - Show the dialog and return true if OK was clicked,
+  //   false in case of error or Cancel
+  virtual bool showDialog() {
+    return Dialog::showDialog(MAKEINTRESOURCE(IDD_OPTIONS));
+  }
+protected:
+
+  // Dialog methods (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->pixelFormat, 0);
+    if (options->askPixelFormat) {
+      setItemChecked(IDC_ASK_PF, true);
+      enableItem(IDC_PIXELFORMAT, false);
+    }
+    setItemChecked(IDC_ACCEPT_BELL, options->acceptBell);
+    setItemChecked(IDC_ACCEPT_CUT_TEXT, options->acceptCutText);
+    setItemChecked(IDC_AUTO_STORE_PARAM, options->autoStoreSettings);
+    setItemChecked(IDC_AUTOPLAY, options->autoPlay);
+  }
+  virtual bool onOk() {
+    if (!isItemChecked(IDC_ASK_PF)) {
+      options->pixelFormat = SendMessage(combo, CB_GETCURSEL, 0, 0);
+    }
+    options->askPixelFormat = isItemChecked(IDC_ASK_PF);
+    options->acceptBell = isItemChecked(IDC_ACCEPT_BELL);
+    options->acceptCutText = isItemChecked(IDC_ACCEPT_CUT_TEXT);
+    options->autoStoreSettings = isItemChecked(IDC_AUTO_STORE_PARAM);
+    options->autoPlay = isItemChecked(IDC_AUTOPLAY);
+    options->writeToRegistry();
+    return true;
+  }
+  virtual bool onCommand(int item, int cmd) { 
+    if (item == IDC_ASK_PF) {
+      enableItem(IDC_PIXELFORMAT, !isItemChecked(IDC_ASK_PF));
+    }
+    if (item == IDC_DEFAULT) {
+      SendMessage(combo, CB_SETCURSEL, DEFAULT_PF, 0);
+      enableItem(IDC_PIXELFORMAT, !DEFAULT_ASK_PF);
+      setItemChecked(IDC_ASK_PF, DEFAULT_ASK_PF);
+      setItemChecked(IDC_ACCEPT_BELL, DEFAULT_ACCEPT_BELL);
+      setItemChecked(IDC_ACCEPT_CUT_TEXT, DEFAULT_ACCEPT_CUT_TEXT);
+      setItemChecked(IDC_AUTO_STORE_PARAM, DEFAULT_STORE_SETTINGS);
+      setItemChecked(IDC_AUTOPLAY, DEFAULT_AUTOPLAY);
+    }
+    return false;
+  }
+
+  HWND combo;
+  PlayerOptions *options;
+};
\ No newline at end of file
diff --git a/rfbplayer/PlayerOptions.cxx b/rfbplayer/PlayerOptions.cxx
new file mode 100644 (file)
index 0000000..fc38c2d
--- /dev/null
@@ -0,0 +1,75 @@
+/* Copyright (C) 2004 TightVNC Team.  All Rights Reserved.
+ *    
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+
+// -=- PlayerOptions class
+
+#include <rfbplayer/PlayerOptions.h>
+
+using namespace rfb::win32;
+
+PlayerOptions::PlayerOptions() { 
+  writeDefaults();
+};
+
+void PlayerOptions::readFromRegistry() {
+  try {
+    RegKey regKey;
+    regKey.createKey(HKEY_CURRENT_USER, _T("Software\\TightVnc\\RfbPlayer"));
+    autoPlay = regKey.getBool(_T("AutoPlay"), DEFAULT_AUTOPLAY);
+    pixelFormat = regKey.getInt(_T("PixelFormat"), DEFAULT_PF);
+    acceptBell = regKey.getBool(_T("AcceptBell"), DEFAULT_ACCEPT_BELL);
+    acceptCutText = regKey.getBool(_T("AcceptCutText"), DEFAULT_ACCEPT_CUT_TEXT);
+    autoStoreSettings = regKey.getBool(_T("AutoStoreSettings"), DEFAULT_STORE_SETTINGS);
+    autoPlay = regKey.getBool(_T("AutoPlay"), DEFAULT_AUTOPLAY);
+    loopPlayback = regKey.getBool(_T("LoopPlayback"), DEFAULT_LOOP_PLAYBACK);
+    askPixelFormat = regKey.getBool(_T("AskPixelFormat"), DEFAULT_ASK_PF);
+  } catch (rdr::Exception e) {
+    MessageBox(0, e.str(), e.type(), MB_OK | MB_ICONERROR);
+  }
+}
+
+void PlayerOptions::writeToRegistry() {
+  try {
+    RegKey regKey;
+    regKey.createKey(HKEY_CURRENT_USER, _T("Software\\TightVnc\\RfbPlayer"));
+    regKey.setBool(_T("AutoPlay"), autoPlay);
+    regKey.setInt(_T("PixelFormat"), pixelFormat);
+    regKey.setBool(_T("AcceptBell"), acceptBell);
+    regKey.setBool(_T("AcceptCutText"), acceptCutText);
+    regKey.setBool(_T("AutoStoreSettings"), autoStoreSettings);
+    regKey.setBool(_T("AutoPlay"), autoPlay);
+    regKey.setBool(_T("LoopPlayback"), loopPlayback);
+    regKey.setBool(_T("AskPixelFormat"), askPixelFormat);
+  } catch (rdr::Exception e) {
+    MessageBox(0, e.str(), e.type(), MB_OK | MB_ICONERROR);
+  }
+}
+
+void PlayerOptions::writeDefaults() {
+  initTime = DEFAULT_INIT_TIME;
+  playbackSpeed = DEFAULT_SPEED;
+  pixelFormat = PF_AUTO;
+  frameScale = DEFAULT_FRAME_SCALE;
+  autoPlay = DEFAULT_AUTOPLAY;
+  fullScreen = DEFAULT_FULL_SCREEN;
+  acceptBell = DEFAULT_ACCEPT_BELL; 
+  acceptCutText = DEFAULT_ACCEPT_CUT_TEXT;
+  loopPlayback = DEFAULT_LOOP_PLAYBACK;
+  askPixelFormat = DEFAULT_ASK_PF; 
+  autoStoreSettings = DEFAULT_STORE_SETTINGS;
+}
\ No newline at end of file
diff --git a/rfbplayer/PlayerOptions.h b/rfbplayer/PlayerOptions.h
new file mode 100644 (file)
index 0000000..79930c2
--- /dev/null
@@ -0,0 +1,65 @@
+/* Copyright (C) 2004 TightVNC Team.  All Rights Reserved.
+ *    
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+
+// -=- PlayerOptions.h
+
+// Definition of the PlayerOptions class, responsible for 
+// storing & retrieving the RfbPlayer's options.
+
+#include <windows.h>
+
+#include <rfb_win32/registry.h>
+
+// Supported pixel formats
+#define PF_AUTO 0
+#define PF_D8_RGB332 1
+#define PF_D16_RGB655 2
+#define PF_D24_RGB888 3
+#define PF_MODES 3
+
+// Default options values
+#define DEFAULT_PF PF_AUTO
+#define DEFAULT_INIT_TIME -1
+#define DEFAULT_SPEED 1.0
+#define DEFAULT_FRAME_SCALE 100
+#define DEFAULT_ACCEPT_BELL FALSE
+#define DEFAULT_ACCEPT_CUT_TEXT FALSE
+#define DEFAULT_LOOP_PLAYBACK FALSE
+#define DEFAULT_ASK_PF FALSE
+#define DEFAULT_AUTOPLAY FALSE
+#define DEFAULT_FULL_SCREEN FALSE
+#define DEFAULT_STORE_SETTINGS FALSE
+
+class PlayerOptions {
+public:
+  PlayerOptions();
+  void readFromRegistry();
+  void writeToRegistry();
+  void writeDefaults();
+  long initTime;
+  double playbackSpeed;
+  bool autoPlay;
+  bool fullScreen;
+  long pixelFormat;
+  bool acceptBell;
+  bool acceptCutText;
+  bool loopPlayback;
+  bool askPixelFormat;
+  long frameScale;
+  bool autoStoreSettings;
+};
\ No newline at end of file
index babf0f6a84c8ce0bbc8ff5c0a77a47d9431a42b9..54b40fcb9f8364fe51de98143afb5c92d2bd6500 100644 (file)
@@ -8,8 +8,15 @@
 #define IDB_TOOLBAR                     132
 #define IDD_GOTO                        133
 #define IDD_PIXELFORMAT                 134
+#define IDD_OPTIONS                     137
 #define IDC_GOTO_EDIT                   1003
 #define IDC_PIXELFORMAT                 1004
+#define IDC_ASK_PF                      1006
+#define IDC_DEFAULT                     1008
+#define IDC_ACCEPT_BELL                 1009
+#define IDC_ACCEPT_CUT_TEXT             1010
+#define IDC_AUTO_STORE_PARAM            1011
+#define IDC_AUTOPLAY                    1012
 #define ID_OPENFILE                     40011
 #define ID_CLOSEFILE                    40012
 #define ID_EXIT                         40013
@@ -33,9 +40,9 @@
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        136
+#define _APS_NEXT_RESOURCE_VALUE        138
 #define _APS_NEXT_COMMAND_VALUE         40045
-#define _APS_NEXT_CONTROL_VALUE         1005
+#define _APS_NEXT_CONTROL_VALUE         1013
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif
index ef64ba4fab38bdd727b6c264c2bc7f83e6536110..b46b2f317a185de515a22c3580e1ae618f18a6d5 100644 (file)
@@ -27,9 +27,6 @@
 
 #include <rfbplayer/rfbplayer.h>
 #include <rfbplayer/utils.h>
-#include <rfbplayer/resource.h>
-#include <rfbplayer/GotoPosDialog.h>
-#include <rfbplayer/ChoosePixelFormatDialog.h>
 
 using namespace rfb;
 using namespace rfb::win32;
@@ -59,8 +56,7 @@ char usage_msg[] =
  "                \t  is double speed, 0.5 is half speed. Default: 1.0.\n"
  "  -pos <ms>     \t- Sets initial time position in the session file,\n"
  "                \t  in milliseconds. Default: 0.\n"
- "  -autoplay     \t- Runs the player in the playback mode.\n"
- "  -bell         \t- Accepts the bell.\n";
+ "  -autoplay     \t- Runs the player in the playback mode.\n";
 
 // -=- RfbPlayer's defines
 
@@ -68,15 +64,10 @@ char usage_msg[] =
 #define MAX_SPEED 10.00
 #define CALCULATION_ERROR MAX_SPEED / 1000
 #define MAX_POS_TRACKBAR_RANGE 50
+#define CTRL_BAR_HEIGHT 28
 #define DEFAULT_PLAYER_WIDTH 640
 #define DEFAULT_PLAYER_HEIGHT 480 
 
-#define PF_AUTO 0
-#define PF_D8_RGB332 1
-#define PF_D16_RGB655 2
-#define PF_D24_RGB888 3
-#define PF_MODES 3
-
 #define ID_TOOLBAR 500
 #define ID_PLAY 510
 #define ID_PAUSE 520
@@ -223,19 +214,15 @@ RfbFrameClass frameClass;
 // -=- RfbPlayer instance implementation
 //
 
-RfbPlayer::RfbPlayer(char *_fileName, int _pixelFormat = PF_AUTO, 
-                     long _initTime = 0, double _playbackSpeed = 1.0, 
-                     bool _autoplay = false, bool _acceptBell = false)
-: RfbProto(_fileName), pixelFormat(_pixelFormat), initTime(_initTime), 
-  playbackSpeed(_playbackSpeed), autoplay(_autoplay), buffer(0), 
-  client_size(0, 0, 32, 32), window_size(0, 0, 32, 32), cutText(0), 
-  seekMode(false), fileName(_fileName), lastPos(0), timeStatic(0), 
-  speedEdit(0), posTrackBar(0), speedUpDown(0), acceptBell(_acceptBell), 
+RfbPlayer::RfbPlayer(char *_fileName, PlayerOptions *_options)
+: RfbProto(_fileName), fileName(_fileName), buffer(0), client_size(0, 0, 32, 32),
+  window_size(0, 0, 32, 32), cutText(0), seekMode(false), lastPos(0), 
+  timeStatic(0), speedEdit(0), posTrackBar(0), speedUpDown(0), 
   rfbReader(0), sessionTimeMs(0), sliderDraging(false), sliderStepMs(0), 
-  loopPlayback(false), imageDataStartTime(0), rewindFlag(false),
-  stopped(false) {
+  imageDataStartTime(0), rewindFlag(false), stopped(false) {
 
-  CTRL_BAR_HEIGHT = 28;
+  // Save the player options
+  memcpy(&options, _options, sizeof(options));
 
   // Reset the full session time
   strcpy(fullSessionTime, "00m:00s");
@@ -255,18 +242,22 @@ RfbPlayer::RfbPlayer(char *_fileName, int _pixelFormat = PF_AUTO,
   buffer = new win32::DIBSectionBuffer(getFrameHandle());
   setVisible(true);
 
-  // Open the session file
+  // If run with command-line parameters,
+  // open the session file with default settings, otherwise
+  // restore player settings from the registry
   if (fileName) {
     openSessionFile(fileName);
-    if (initTime > 0) setPos(initTime);
-    setSpeed(playbackSpeed);
+    if (options.initTime > 0) setPos(options.initTime);
+    setSpeed(options.playbackSpeed);
   } else {
+    options.readFromRegistry();
     disableTBandMenuItems();
     setTitle("None");
   }
 }
 
 RfbPlayer::~RfbPlayer() {
+  options.writeToRegistry();
   vlog.debug("~RfbPlayer");
   if (rfbReader) {
     delete rfbReader->join();
@@ -325,7 +316,6 @@ RfbPlayer::processMainMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
         ofn.lpstrDefExt = "rfb";
         ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
         if (GetOpenFileName(&ofn)) {
-          pixelFormat = PF_AUTO;
           openSessionFile(filename);
         }
       }
@@ -366,8 +356,8 @@ RfbPlayer::processMainMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
       MessageBox(getMainHandle(), "It is not working yet!", "RfbPlayer", MB_OK);
       break;
     case ID_LOOP:
-      loopPlayback = !loopPlayback;
-      if (loopPlayback) CheckMenuItem(hMenu, ID_LOOP, MF_CHECKED);
+      options.loopPlayback = !options.loopPlayback;
+      if (options.loopPlayback) CheckMenuItem(hMenu, ID_LOOP, MF_CHECKED);
       else CheckMenuItem(hMenu, ID_LOOP, MF_UNCHECKED);
       break;
     case ID_RETURN:
@@ -384,6 +374,12 @@ RfbPlayer::processMainMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
         setSpeed(speed);
       }
       break;
+    case ID_OPTIONS:
+      {
+        OptionsDialog optionsDialog(&options);
+        optionsDialog.showDialog();
+      }
+      break;
     case ID_EXIT:
       PostQuitMessage(0);
       break;
@@ -475,7 +471,7 @@ RfbPlayer::processMainMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
         sprintf(speedStr, "%.2f", speed);
         SetWindowText(speedEdit, speedStr);
         is->setSpeed(speed);
-        playbackSpeed = speed;
+        options.playbackSpeed = speed;
         return lResult;
       }
     }
@@ -807,7 +803,7 @@ void RfbPlayer::rewind() {
   blankBuffer();
   newSession(fileName);
   skipHandshaking();
-  is->setSpeed(playbackSpeed);
+  is->setSpeed(options.playbackSpeed);
   if (paused) is->pausePlayback();
   else is->resumePlayback();
 }
@@ -829,7 +825,7 @@ void RfbPlayer::processMsg() {
   } catch (rdr::Exception e) {
     if (strcmp(e.str(), "[End Of File]") == 0) {
       rewind();
-      setPaused(!loopPlayback);
+      setPaused(!options.loopPlayback);
       updatePos(getTimeOffset());
       SendMessage(posTrackBar, TBM_SETPOS, TRUE, 0);
       return;
@@ -865,6 +861,15 @@ void RfbPlayer::serverInit() {
     throw rdr::Exception("This version plays only true color session!");
 
   // Set the session pixel format
+  static long pixelFormat = PF_AUTO;
+  if (options.askPixelFormat) {
+    ChoosePixelFormatDialog choosePixelFormatDialog(pixelFormat);
+    if (choosePixelFormatDialog.showDialog()) {
+      pixelFormat = choosePixelFormatDialog.getPF();
+    }
+  } else {
+    pixelFormat = options.pixelFormat;
+  }
   switch (pixelFormat) {
   case PF_AUTO: 
     break;
@@ -898,7 +903,10 @@ void RfbPlayer::serverInit() {
   sliderStepMs = sessionTimeMs / SendMessage(posTrackBar, TBM_GETRANGEMAX, 0, 0);
   updatePos(getTimeOffset());
 
-  setPaused(!autoplay);
+  setPaused(!options.autoPlay);
+  // Restore the parameters from registry,
+  // which was replaced by command-line parameters.
+  options.readFromRegistry();
 }
 
 void RfbPlayer::setColourMapEntries(int first, int count, U16* rgbs) {
@@ -915,7 +923,7 @@ void RfbPlayer::setColourMapEntries(int first, int count, U16* rgbs) {
 } 
 
 void RfbPlayer::bell() {
-  if (acceptBell)
+  if (options.acceptBell)
     MessageBeep(-1);
 }
 
@@ -1010,10 +1018,10 @@ void RfbPlayer::closeSessionFile() {
   blankBuffer();
   setTitle("None");
   SetWindowText(timeStatic,"00m:00s (00m:00s)");
-  playbackSpeed = 1.0;
+  options.playbackSpeed = 1.0;
   SendMessage(speedUpDown, UDM_SETPOS, 
-    0, MAKELONG((short)(playbackSpeed / 0.5), 0));
-  sprintf(speedStr, "%.2f", playbackSpeed);
+    0, MAKELONG((short)(options.playbackSpeed / 0.5), 0));
+  sprintf(speedStr, "%.2f", options.playbackSpeed);
   SetWindowText(speedEdit, speedStr);
   SendMessage(posTrackBar, TBM_SETRANGE, TRUE, MAKELONG(0, 0));
     
@@ -1049,7 +1057,7 @@ void RfbPlayer::openSessionFile(char *_fileName) {
   }
   blankBuffer();
   newSession(fileName);
-  setSpeed(playbackSpeed);
+  setSpeed(options.playbackSpeed);
   rfbReader = new rfbSessionReader(this);
   rfbReader->start();
   SendMessage(posTrackBar, TBM_SETPOS, TRUE, 0);
@@ -1094,7 +1102,7 @@ void RfbPlayer::setSpeed(double speed) {
     char speedStr[20] = "\0";
     double newSpeed = min(speed, MAX_SPEED);
     is->setSpeed(newSpeed);
-    playbackSpeed = newSpeed;
+    options.playbackSpeed = newSpeed;
     SendMessage(speedUpDown, UDM_SETPOS, 
       0, MAKELONG((short)(newSpeed / 0.5), 0));
     sprintf(speedStr, "%.2f", newSpeed);
@@ -1168,13 +1176,12 @@ void programUsage() {
   MessageBox(0, usage_msg, "RfbPlayer", MB_OK | MB_ICONINFORMATION);
 }
 
-double playbackSpeed = 1.0;
-long initTime = -1;
-int pf = PF_AUTO;
-bool autoplay = false;
 char *fileName = 0;
+
+// playerOptions is the player options with default parameters values,
+// it is used only for run the player with command-line parameters
+PlayerOptions playerOptions;
 bool print_usage = false;
-bool acceptBell = false;
 
 bool processParams(int argc, char* argv[]) {
   for (int i = 1; i < argc; i++) {
@@ -1191,40 +1198,37 @@ bool processParams(int argc, char* argv[]) {
 
     if ((strcasecmp(argv[i], "-pf") == 0) ||
         (strcasecmp(argv[i], "/pf") == 0) && (i < argc-1)) {
-      pf = atoi(argv[++i]);
+      long pf = atoi(argv[++i]);
       if ((pf < 0) || (pf > PF_MODES)) {
         return false;
       }
+      playerOptions.pixelFormat = pf;
       continue;
     }
 
 
     if ((strcasecmp(argv[i], "-speed") == 0) ||
         (strcasecmp(argv[i], "/speed") == 0) && (i < argc-1)) {
-      playbackSpeed = atof(argv[++i]);
+      double playbackSpeed = atof(argv[++i]);
       if (playbackSpeed <= 0) {
         return false;
       }
+      playerOptions.playbackSpeed = playbackSpeed;
       continue;
     }
 
     if ((strcasecmp(argv[i], "-pos") == 0) ||
         (strcasecmp(argv[i], "/pos") == 0) && (i < argc-1)) {
-      initTime = atol(argv[++i]);
+      long initTime = atol(argv[++i]);
       if (initTime <= 0)
         return false;
+      playerOptions.initTime = initTime;
       continue;
     }
 
     if ((strcasecmp(argv[i], "-autoplay") == 0) ||
         (strcasecmp(argv[i], "/autoplay") == 0) && (i < argc-1)) {
-      autoplay = true;
-      continue;
-    }
-
-    if ((strcasecmp(argv[i], "-bell") == 0) ||
-        (strcasecmp(argv[i], "/bell") == 0) && (i < argc-1)) {
-      acceptBell  = true;
+      playerOptions.autoPlay = true;
       continue;
     }
 
@@ -1259,8 +1263,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prevInst, char* cmdLine, int cmdSho
   // Create the player
   RfbPlayer *player = NULL;
   try {
-    player = new RfbPlayer(fileName, pf, initTime, playbackSpeed, autoplay, 
-                           acceptBell);
+    player = new RfbPlayer(fileName, &playerOptions);
   } catch (rdr::Exception e) {
     MessageBox(NULL, e.str(), e.type(), MB_OK | MB_ICONERROR);
     delete player;
index ef770d85c761640148a938eb16b6eab111fbc36f..76a40cf4cfa8d1e9b2d3e73735ed142e48378151 100644 (file)
@@ -108,6 +108,10 @@ SOURCE=.\FbsInputStream.cxx
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\PlayerOptions.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\rfbplayer.cxx\r
 # End Source File\r
 # Begin Source File\r
@@ -140,6 +144,14 @@ SOURCE=.\GotoPosDialog.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\OptionsDialog.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\PlayerOptions.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\rfbplayer.h\r
 # End Source File\r
 # Begin Source File\r
index a54647c3ff8acccaf916b878c1986323b4434c82..20cf15a5d40a17a18a125c548efd949c4ae23779 100644 (file)
 
 #include <rfb_win32/DIBSectionBuffer.h>
 
+#include <rfbplayer/resource.h>
 #include <rfbplayer/ToolBar.h>
 #include <rfbplayer/rfbSessionReader.h>
+#include <rfbplayer/GotoPosDialog.h>
+#include <rfbplayer/ChoosePixelFormatDialog.h>
+#include <rfbplayer/OptionsDialog.h>
 
 using namespace rfb;
 using namespace rfb::win32;
 
 class RfbPlayer : public RfbProto {
   public:
-    RfbPlayer(char *filename, int _depth, long _pos, double _speed, 
-              bool _autoplay, bool _acceptBell);
+    RfbPlayer(char *fileName, PlayerOptions *options);
     ~RfbPlayer();
 
     // -=- Window Message handling
@@ -133,8 +136,6 @@ class RfbPlayer : public RfbProto {
     void setSpeed(double speed);
     double getSpeed();
 
-    char *fileName;
-
   protected:
     bool seekMode;
     bool stopped;
@@ -144,7 +145,7 @@ class RfbPlayer : public RfbProto {
     char fullSessionTime[20];
     int time_pos_m;
     int time_pos_s;
-    int CTRL_BAR_HEIGHT;
+    char *fileName;
     
     // rfbReader is a class which used to reading the rfb data from the file
     rfbSessionReader *rfbReader;
@@ -175,12 +176,7 @@ class RfbPlayer : public RfbProto {
     ToolBar tb;
 
     // The player's parameters
-    bool autoplay;
-    int pixelFormat;
-    double playbackSpeed;
+    PlayerOptions options;
     long imageDataStartTime;
-    long initTime;
-    bool acceptBell;
     long sessionTimeMs;
-    bool loopPlayback;
 };
index dd427c76e4d9193869783b5eb22ee1e140a0c1fa..6876b7faa2691500035bf6fedf43941e1173ba66 100644 (file)
@@ -152,7 +152,7 @@ BEGIN
         MENUITEM SEPARATOR
         MENUITEM "Extract...\tAlt+C",           ID_FRAMEEXTRACT
     END
-    MENUITEM "Options",                     65535
+    MENUITEM "Options",                     ID_OPTIONS
     POPUP "Help"
     BEGIN
         MENUITEM "Home Page",                   ID_HELP_HOMEPAGE
@@ -223,6 +223,34 @@ BEGIN
     LTEXT           "Choose the pixel format:",IDC_STATIC,7,7,130,13
 END
 
+IDD_OPTIONS DIALOG DISCARDABLE  0, 0, 187, 181
+STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Options"
+FONT 8, "MS Sans Serif"
+BEGIN
+    DEFPUSHBUTTON   "OK",IDOK,20,160,50,15
+    PUSHBUTTON      "Cancel",IDCANCEL,75,160,50,15
+    GROUPBOX        "Pixel format",IDC_STATIC,7,6,173,64
+    COMBOBOX        IDC_PIXELFORMAT,15,30,145,75,CBS_DROPDOWNLIST | 
+                    WS_VSCROLL | WS_TABSTOP
+    CONTROL         "Ask the pixel format before playing",IDC_ASK_PF,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,15,52,145,10
+    PUSHBUTTON      "Default",IDC_DEFAULT,130,160,50,15
+    LTEXT           "Forces the pixel format for the rfb session:",
+                    IDC_STATIC,15,17,145,13
+    GROUPBOX        "Other",IDC_STATIC,7,75,173,80
+    CONTROL         "Accept the bells",IDC_ACCEPT_BELL,"Button",
+                    BS_AUTOCHECKBOX | BS_TOP | WS_TABSTOP,15,90,145,15
+    CONTROL         "Accept the cut text",IDC_ACCEPT_CUT_TEXT,"Button",
+                    BS_AUTOCHECKBOX | BS_TOP | WS_TABSTOP,15,105,145,15
+    CONTROL         "Auto store the player settings",IDC_AUTO_STORE_PARAM,
+                    "Button",BS_AUTOCHECKBOX | BS_TOP | WS_TABSTOP,15,120,
+                    145,15
+    CONTROL         "Start play the session when it is opened",IDC_AUTOPLAY,
+                    "Button",BS_AUTOCHECKBOX | BS_TOP | WS_TABSTOP,15,135,
+                    145,15
+END
+
 
 /////////////////////////////////////////////////////////////////////////////
 //
@@ -261,6 +289,33 @@ BEGIN
         HORZGUIDE, 35
         HORZGUIDE, 40
     END
+
+    IDD_OPTIONS, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 180
+        VERTGUIDE, 15
+        VERTGUIDE, 20
+        VERTGUIDE, 70
+        VERTGUIDE, 75
+        VERTGUIDE, 125
+        VERTGUIDE, 130
+        VERTGUIDE, 160
+        TOPMARGIN, 6
+        BOTTOMMARGIN, 175
+        HORZGUIDE, 17
+        HORZGUIDE, 30
+        HORZGUIDE, 52
+        HORZGUIDE, 70
+        HORZGUIDE, 75
+        HORZGUIDE, 90
+        HORZGUIDE, 105
+        HORZGUIDE, 120
+        HORZGUIDE, 135
+        HORZGUIDE, 150
+        HORZGUIDE, 155
+        HORZGUIDE, 160
+    END
 END
 #endif    // APSTUDIO_INVOKED