]> source.dussan.org Git - tigervnc.git/commitdiff
Added the ToolBar to RfbPlayer.
authorgeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Wed, 19 Jan 2005 16:44:04 +0000 (16:44 +0000)
committergeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Wed, 19 Jan 2005 16:44:04 +0000 (16:44 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@105 3789f03b-4d11-0410-bbf8-ca57d06f2519

rfbplayer/resource.h
rfbplayer/rfbplayer.cxx
rfbplayer/rfbplayer.h
rfbplayer/rfbplayer.rc

index 62235b844c991fb8c5f1577dc3f28cf682b9add9..f6e935b1da248d7f01ef630c351fa035a990784a 100644 (file)
 #define ID_HELP_COMMANDLINESEITCHES     40026
 #define ID_HELP_ABOUT                   40027
 #define ID_OPTIONS                      40029
+#define ID_FULLSCREEN                   40030
+#define ID_STOP                         40031
+#define ID_GOTO                         40032
+#define ID_SETSPEED                     40033
+#define ID_LOOP                         40034
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        133
-#define _APS_NEXT_COMMAND_VALUE         40030
+#define _APS_NEXT_COMMAND_VALUE         40035
 #define _APS_NEXT_CONTROL_VALUE         1003
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
index d8453af74f0c1b0205a960eb0f8bd92cb04d0796..53c78eea80f5d98d163dbbfe74b39fc029d38b23 100644 (file)
@@ -45,6 +45,16 @@ extern const char* buildTime;
 
 #define strcasecmp _stricmp
 
+#define ID_TOOLBAR 500
+#define ID_PLAY 510
+#define ID_PAUSE 520
+#define ID_TIME_STATIC 530
+#define ID_SPEED_STATIC 540
+#define ID_SPEED_EDIT 550
+#define ID_POS_TRACKBAR 560
+#define ID_SPEED_UPDOWN 570
+
+
 //
 // -=- RfbPlayerClass
 
@@ -192,11 +202,11 @@ RfbPlayer::RfbPlayer(char *_fileName, long _initTime = 0, double _playbackSpeed
 : RfbProto(_fileName), initTime(_initTime), playbackSpeed(_playbackSpeed),
   autoplay(_autoplay), showControls(_showControls), buffer(0), client_size(0, 0, 32, 32), 
   window_size(0, 0, 32, 32), cutText(0), seekMode(false), fileName(_fileName), fRun(true), 
-  serverInitTime(0), btnStart(0), txtPos(0), editPos(0), txtSpeed(0), editSpeed(0), 
-  lastPos(0), acceptBell(_acceptBell) {
+  serverInitTime(0), lastPos(0), timeStatic(0), speedEdit(0), speedTrackBar(0),
+  speedUpDown(0), acceptBell(_acceptBell) {
 
   if (showControls)
-    CTRL_BAR_HEIGHT = 30;
+    CTRL_BAR_HEIGHT = 28;
   else
     CTRL_BAR_HEIGHT = 0;
 
@@ -239,6 +249,8 @@ RfbPlayer::processMainMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
         0, WS_CHILD | WS_VISIBLE, 0, CTRL_BAR_HEIGHT, 10, CTRL_BAR_HEIGHT + 10,
         hwnd, 0, frameClass.instance, this);
 
+      createToolBar(hwnd);
+
       return 0;
     }
   
@@ -254,6 +266,7 @@ RfbPlayer::processMainMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
   case WM_SIZE:
     {
+    
       Point old_offset = bufferToClient(Point(0, 0));
 
       // Update the cached sizing information
@@ -269,6 +282,9 @@ RfbPlayer::processMainMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
       // Determine whether scrollbars are required
       calculateScrollBars();
+         
+      // Resize the ToolBar
+      tb.autoSize();
 
       // Redraw if required
       if (!old_offset.equals(bufferToClient(Point(0, 0))))
@@ -426,9 +442,63 @@ void RfbPlayer::applyOptions() {
     setPos(initTime);
   setSpeed(playbackSpeed);
   setPaused(!autoplay);
+}
 
-  // Update the position
-  SetWindowText(editPos, LongToStr(initTime / 1000));
+void RfbPlayer::createToolBar(HWND parentHwnd) {
+  RECT tRect;
+  InitCommonControls();
+
+  tb.create(ID_TOOLBAR, parentHwnd);
+  tb.addBitmap(4, IDB_TOOLBAR);
+
+  // Create the control buttons
+  tb.addButton(0, ID_PLAY);
+  tb.addButton(1, ID_PAUSE);
+  tb.addButton(2, ID_STOP);
+  tb.addButton(0, 0, TBSTATE_ENABLED, TBSTYLE_SEP);
+  tb.addButton(3, ID_FULLSCREEN);
+  tb.addButton(0, 0, TBSTATE_ENABLED, TBSTYLE_SEP);
+
+  // Create the static control for the time output
+  tb.addButton(125, 0, TBSTATE_ENABLED, TBSTYLE_SEP);
+  tb.getButtonRect(6, &tRect);
+  timeStatic = CreateWindowEx(0, "Static", "00m:00s (00m:00s)", 
+    WS_CHILD | WS_VISIBLE, tRect.left, tRect.top+2, tRect.right-tRect.left, 
+    tRect.bottom-tRect.top, tb.getHandle(), (HMENU)ID_TIME_STATIC, 
+    GetModuleHandle(0), 0);
+  tb.addButton(0, 10, TBSTATE_ENABLED, TBSTYLE_SEP);
+    
+  // Create the trackbar control for the time position
+  tb.addButton(200, 0, TBSTATE_ENABLED, TBSTYLE_SEP);
+  tb.getButtonRect(8, &tRect);
+  speedTrackBar = CreateWindowEx(0, TRACKBAR_CLASS, "Trackbar Control", 
+    WS_CHILD | WS_VISIBLE | TBS_AUTOTICKS | TBS_ENABLESELRANGE,
+    tRect.left, tRect.top, tRect.right-tRect.left, tRect.bottom-tRect.top,
+    parentHwnd, (HMENU)ID_POS_TRACKBAR, GetModuleHandle(0), 0);
+  // It's need to send notify messages to toolbar parent window
+  SetParent(speedTrackBar, tb.getHandle());
+  tb.addButton(0, 10, TBSTATE_ENABLED, TBSTYLE_SEP);
+
+  // Create the label with "Speed:" caption
+  tb.addButton(50, 0, TBSTATE_ENABLED, TBSTYLE_SEP);
+  tb.getButtonRect(10, &tRect);
+  CreateWindowEx(0, "Static", "Speed:", WS_CHILD | WS_VISIBLE, 
+    tRect.left, tRect.top+2, tRect.right-tRect.left, tRect.bottom-tRect.top,
+    tb.getHandle(), (HMENU)ID_SPEED_STATIC, GetModuleHandle(0), 0);
+
+  // Create the edit control and the spin for the speed managing
+  tb.addButton(60, 0, TBSTATE_ENABLED, TBSTYLE_SEP);
+  tb.getButtonRect(11, &tRect);
+  speedEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", "1.00", 
+    WS_CHILD | WS_VISIBLE | ES_RIGHT, tRect.left, tRect.top, 
+    tRect.right-tRect.left, tRect.bottom-tRect.top, parentHwnd,
+    (HMENU)ID_SPEED_EDIT, GetModuleHandle(0), 0);
+  // It's need to send notify messages to toolbar parent window
+  SetParent(speedEdit, tb.getHandle());
+
+  speedUpDown = CreateUpDownControl(WS_CHILD | WS_VISIBLE  
+    | WS_BORDER | UDS_ALIGNRIGHT, 0, 0, 0, 0, tb.getHandle(),
+    ID_SPEED_UPDOWN, GetModuleHandle(0), speedEdit, 100, 1, 10);
 }
 
 void RfbPlayer::setVisible(bool visible) {
@@ -642,10 +712,8 @@ bool RfbPlayer::invalidateBufferRect(const Rect& crect) {
 
 void RfbPlayer::setPaused(bool paused) {
   if (paused) {
-    if (btnStart) SetWindowText(btnStart, "Start");
     is->pausePlayback();
   } else {
-    if (btnStart) SetWindowText(btnStart, "Stop");
     is->resumePlayback();
   }
 }
@@ -653,8 +721,6 @@ void RfbPlayer::setPaused(bool paused) {
 void RfbPlayer::setSpeed(double speed) {
   serverInitTime = serverInitTime * getSpeed() / speed;
   is->setSpeed(speed);
-  if (editSpeed)
-    SetWindowText(editSpeed, DoubleToStr(speed, 1));
 }
 
 double RfbPlayer::getSpeed() {
@@ -687,10 +753,6 @@ long RfbPlayer::getTimeOffset() {
 
 void RfbPlayer::updatePos() {
   long newPos = is->getTimeOffset() / 1000;
-  if (editPos && lastPos != newPos) {
-    lastPos = newPos;
-    SetWindowText(editPos, LongToStr(lastPos));
-  }
 }
 
 void RfbPlayer::skipHandshaking() {
index 880dcb8af06c5a3ef10377e9c49d4399b9961c87..3d34991c3b00fb2e2ca70329f4e24bf04ec1acff 100644 (file)
@@ -23,6 +23,7 @@
 #include <rfb_win32/DIBSectionBuffer.h>
 
 #include <rfbplayer/RfbProto.h>
+#include <rfbplayer/ToolBar.h>
 
 using namespace rfb;
 using namespace rfb::win32;
@@ -42,9 +43,7 @@ class RfbPlayer : public Thread, public RfbProto{
 
     HWND getMainHandle() const {return mainHwnd;}
     HWND getFrameHandle() const {return frameHwnd;}
-    HWND getStartBtn() const {return btnStart;}
-    HWND getPosEdit() const {return editPos;}
-    HWND getSpeedEdit() const {return editSpeed;}
+    void createToolBar(HWND parentHwnd);
     void setFrameSize(int width, int height);
     void setVisible(bool visible);
     void setTitle(const char *title);
@@ -145,18 +144,18 @@ class RfbPlayer : public Thread, public RfbProto{
 
     // Local window state
     HWND mainHwnd;
-    HWND btnStart;
-    HWND txtPos;
-    HWND editPos;
-    HWND txtSpeed;
-    HWND editSpeed;
     HWND frameHwnd;
+    HWND timeStatic;
+    HWND speedEdit;
+    HWND speedTrackBar;
+    HWND speedUpDown;
     Rect window_size;
     Rect client_size;
     Point scrolloffset;
     Point maxscrolloffset;
     char *cutText;
     win32::DIBSectionBuffer* buffer;
+    ToolBar tb;
 
     // The player's parameters
     bool showControls;
index 92c03eb2e95fd1aef1835e18e6297fb58c2c0ed0..e349cf8b4e88fdff00fff979d959c94ab7fea0fb 100644 (file)
@@ -130,7 +130,7 @@ BEGIN
     END
     POPUP "View"
     BEGIN
-        MENUITEM "Full Screen\tAlt+Enter",      ID_VIEW_FULLSCREEN
+        MENUITEM "Full Screen\tAlt+Enter",      ID_FULLSCREEN
         POPUP "Zoom"
         BEGIN
             MENUITEM "50%\tF5",                     ID_VIEW_ZOOM_50
@@ -141,11 +141,11 @@ BEGIN
     POPUP "Play"
     BEGIN
         MENUITEM "Play/Pause\tSpace",           ID_PLAY_PLAYPAUSE
-        MENUITEM "Stop\tC",                     ID_PLAY_STOP
-        MENUITEM "Go To...\tCtrl+G",            ID_PLAY_GOTO
-        MENUITEM "Set Speed...\tCtrl+S",        ID_PLAY_SETSPEED
+        MENUITEM "Stop\tC",                     ID_STOP
+        MENUITEM "Go To...\tCtrl+G",            ID_GOTO
+        MENUITEM "Set Speed...\tCtrl+S",        ID_SETSPEED
         MENUITEM SEPARATOR
-        MENUITEM "Loop\tCtrl+L",                ID_PLAY_LOOP
+        MENUITEM "Loop\tCtrl+L",                ID_LOOP
     END
     POPUP "Frame"
     BEGIN