From d070c694f2486812a9ed068ab4dad21dfb2a4552 Mon Sep 17 00:00:00 2001 From: george82 Date: Wed, 19 Jan 2005 16:44:04 +0000 Subject: [PATCH] Added the ToolBar to RfbPlayer. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@105 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- rfbplayer/resource.h | 7 +++- rfbplayer/rfbplayer.cxx | 88 +++++++++++++++++++++++++++++++++++------ rfbplayer/rfbplayer.h | 15 ++++--- rfbplayer/rfbplayer.rc | 10 ++--- 4 files changed, 93 insertions(+), 27 deletions(-) diff --git a/rfbplayer/resource.h b/rfbplayer/resource.h index 62235b84..f6e935b1 100644 --- a/rfbplayer/resource.h +++ b/rfbplayer/resource.h @@ -24,13 +24,18 @@ #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 diff --git a/rfbplayer/rfbplayer.cxx b/rfbplayer/rfbplayer.cxx index d8453af7..53c78eea 100644 --- a/rfbplayer/rfbplayer.cxx +++ b/rfbplayer/rfbplayer.cxx @@ -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() { diff --git a/rfbplayer/rfbplayer.h b/rfbplayer/rfbplayer.h index 880dcb8a..3d34991c 100644 --- a/rfbplayer/rfbplayer.h +++ b/rfbplayer/rfbplayer.h @@ -23,6 +23,7 @@ #include #include +#include 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; diff --git a/rfbplayer/rfbplayer.rc b/rfbplayer/rfbplayer.rc index 92c03eb2..e349cf8b 100644 --- a/rfbplayer/rfbplayer.rc +++ b/rfbplayer/rfbplayer.rc @@ -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 -- 2.39.5