Author: hbelusca
Date: Sat Dec 12 21:15:53 2015
New Revision: 70331
URL:
http://svn.reactos.org/svn/reactos?rev=70331&view=rev
Log:
[CLIPBRD]
Start scrolling support, work in progress. By Ricardo Hanke
CORE-10679
Added:
trunk/reactos/base/applications/clipbrd/scrollutils.c (with props)
Modified:
trunk/reactos/base/applications/clipbrd/CMakeLists.txt
trunk/reactos/base/applications/clipbrd/clipbrd.c
trunk/reactos/base/applications/clipbrd/fileutils.h
trunk/reactos/base/applications/clipbrd/precomp.h
trunk/reactos/base/applications/clipbrd/winutils.h
Modified: trunk/reactos/base/applications/clipbrd/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/CMakeLists.txt [iso-8859-1] Sat Dec 12
21:15:53 2015
@@ -4,6 +4,7 @@
cliputils.c
winutils.c
fileutils.c
+ scrollutils.c
precomp.h)
add_executable(clipbrd ${SOURCE} clipbrd.rc)
Modified: trunk/reactos/base/applications/clipbrd/clipbrd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/clipbrd.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/clipbrd.c [iso-8859-1] Sat Dec 12 21:15:53
2015
@@ -11,6 +11,7 @@
static const WCHAR szClassName[] = L"ClipBookWClass";
CLIPBOARD_GLOBALS Globals;
+SCROLLSTATE Scrollstate;
static void SaveClipboardToFile(void)
{
@@ -124,8 +125,15 @@
Globals.uDisplayFormat = uFormat;
}
+ if (Globals.hDspBmp)
+ {
+ DeleteObject(Globals.hDspBmp);
+ }
+
+ ZeroMemory(&Scrollstate, sizeof(Scrollstate));
+ UpdateWindowScrollState(Globals.hMainWnd, Globals.hDspBmp, &Scrollstate);
+
InvalidateRect(Globals.hMainWnd, NULL, TRUE);
- UpdateWindow(Globals.hMainWnd);
}
static void InitMenuPopup(HMENU hMenu, LPARAM index)
@@ -330,10 +338,40 @@
break;
}
+ case WM_KEYDOWN:
+ {
+ HandleKeyboardScrollEvents(hWnd, uMsg, wParam, lParam);
+ break;
+ }
+
+ case WM_HSCROLL:
+ {
+ HandleHorizontalScrollEvents(hWnd, uMsg, wParam, lParam, &Scrollstate);
+ break;
+ }
+
+ case WM_VSCROLL:
+ {
+ HandleVerticalScrollEvents(hWnd, uMsg, wParam, lParam, &Scrollstate);
+ break;
+ }
+
case WM_SIZE:
{
- InvalidateRect(hWnd, NULL, TRUE);
- UpdateWindow(hWnd);
+ UpdateWindowScrollState(hWnd, Globals.hDspBmp, &Scrollstate);
+
+ if ((Globals.uDisplayFormat == CF_METAFILEPICT) ||
+ (Globals.uDisplayFormat == CF_ENHMETAFILE) ||
+ (Globals.uDisplayFormat == CF_DSPENHMETAFILE) ||
+ (Globals.uDisplayFormat == CF_DSPMETAFILEPICT))
+ {
+ InvalidateRect(Globals.hMainWnd, NULL, FALSE);
+ }
+ else if (!IsClipboardFormatSupported(Globals.uDisplayFormat))
+ {
+ InvalidateRect(Globals.hMainWnd, NULL, TRUE);
+ }
+
break;
}
@@ -428,6 +466,12 @@
UpdateWindow(hWnd);
}
}
+ break;
+ }
+
+ case WM_SYSCOLORCHANGE:
+ {
+ SetDisplayFormat(Globals.uDisplayFormat);
break;
}
@@ -510,5 +554,10 @@
}
}
+ if (Globals.hDspBmp)
+ {
+ DeleteObject(Globals.hDspBmp);
+ }
+
return (int)msg.wParam;
}
Modified: trunk/reactos/base/applications/clipbrd/fileutils.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/fileutils.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/fileutils.h [iso-8859-1] Sat Dec 12 21:15:53
2015
@@ -1,7 +1,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Clipboard Viewer
- * FILE: base/applications/clipbrd/fileutils.c
+ * FILE: base/applications/clipbrd/fileutils.h
* PURPOSE: Clipboard file format helper functions.
* PROGRAMMERS: Ricardo Hanke
*/
Modified: trunk/reactos/base/applications/clipbrd/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/precomp.h [iso-8859-1] Sat Dec 12 21:15:53
2015
@@ -15,6 +15,7 @@
#include "cliputils.h"
#include "fileutils.h"
#include "winutils.h"
+#include "scrollutils.h"
#define MAX_STRING_LEN 255
#define DISPLAY_MENU_POS 2
@@ -28,6 +29,7 @@
HMENU hMenu;
UINT uDisplayFormat;
UINT uCheckedItem;
+ HBITMAP hDspBmp;
} CLIPBOARD_GLOBALS;
extern CLIPBOARD_GLOBALS Globals;
Added: trunk/reactos/base/applications/clipbrd/scrollutils.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/scrollutils.c (added)
+++ trunk/reactos/base/applications/clipbrd/scrollutils.c [iso-8859-1] Sat Dec 12 21:15:53
2015
@@ -0,0 +1,267 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS Clipboard Viewer
+ * FILE: base/applications/clipbrd/scrollutils.c
+ * PURPOSE: Scrolling releated helper functions.
+ * PROGRAMMERS: Ricardo Hanke
+ */
+
+#include "precomp.h"
+
+static int InternalSetScrollInfo(HWND hWnd, int nMin, int nMax, UINT nPage, int nPos, int
fnBar)
+{
+ SCROLLINFO si;
+
+ ZeroMemory(&si, sizeof(si));
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_DISABLENOSCROLL;
+ si.nMin = nMin;
+ si.nMax = nMax;
+ si.nPage = nPage;
+ si.nPos = nPos;
+
+ return SetScrollInfo(hWnd, fnBar, &si, TRUE);
+}
+
+void HandleKeyboardScrollEvents(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch (wParam)
+ {
+ case VK_UP:
+ {
+ SendMessage(hWnd, WM_VSCROLL, MAKELONG(SB_LINEUP, 0), 0);
+ break;
+ }
+
+ case VK_DOWN:
+ {
+ SendMessage(hWnd, WM_VSCROLL, MAKELONG(SB_LINEDOWN, 0), 0);
+ break;
+ }
+
+ case VK_LEFT:
+ {
+ SendMessage(hWnd, WM_HSCROLL, MAKELONG(SB_LINEUP, 0), 0);
+ break;
+ }
+
+ case VK_RIGHT:
+ {
+ SendMessage(hWnd, WM_HSCROLL, MAKELONG(SB_LINEDOWN, 0), 0);
+ break;
+ }
+
+ case VK_PRIOR:
+ {
+ SendMessage(hWnd, WM_VSCROLL, MAKELONG(SB_PAGEUP, 0), 0);
+ break;
+ }
+
+ case VK_NEXT:
+ {
+ SendMessage(hWnd, WM_VSCROLL, MAKELONG(SB_PAGEDOWN, 0), 0);
+ break;
+ }
+
+ default:
+ {
+ break;
+ }
+ }
+}
+
+void HandleHorizontalScrollEvents(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
LPSCROLLSTATE state)
+{
+ SCROLLINFO si;
+ int Delta;
+ int NewPos;
+
+ ZeroMemory(&si, sizeof(si));
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_PAGE | SIF_TRACKPOS;
+ GetScrollInfo(hWnd, SB_HORZ, &si);
+
+ switch (LOWORD(wParam))
+ {
+ case SB_THUMBPOSITION:
+ case SB_THUMBTRACK:
+ {
+ NewPos = si.nTrackPos;
+ break;
+ }
+
+ case SB_LINELEFT:
+ {
+ NewPos = state->CurrentX - 5;
+ break;
+ }
+
+ case SB_LINERIGHT:
+ {
+ NewPos = state->CurrentX + 5;
+ break;
+ }
+
+ case SB_PAGELEFT:
+ {
+ NewPos = state->CurrentX - si.nPage;
+ break;
+ }
+
+ case SB_PAGERIGHT:
+ {
+ NewPos = state->CurrentX + si.nPage;
+ break;
+ }
+
+ default:
+ {
+ NewPos = state->CurrentX;
+ break;
+ }
+ }
+
+ NewPos = min(state->MaxX, max(0, NewPos));
+
+ if (NewPos == state->CurrentX)
+ {
+ return;
+ }
+
+ Delta = NewPos - state->CurrentX;
+
+ state->CurrentX = NewPos;
+
+ ScrollWindowEx(hWnd, -Delta, 0, NULL, NULL, NULL, NULL, SW_INVALIDATE);
+
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_POS;
+ si.nPos = state->CurrentX;
+ SetScrollInfo(hWnd, SB_HORZ, &si, TRUE);
+}
+
+void HandleVerticalScrollEvents(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
LPSCROLLSTATE state)
+{
+ SCROLLINFO si;
+ int Delta;
+ int NewPos;
+
+ ZeroMemory(&si, sizeof(si));
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_PAGE | SIF_TRACKPOS;
+ GetScrollInfo(hWnd, SB_VERT, &si);
+
+ switch (LOWORD(wParam))
+ {
+ case SB_THUMBPOSITION:
+ case SB_THUMBTRACK:
+ {
+ NewPos = si.nTrackPos;
+ break;
+ }
+
+ case SB_LINEUP:
+ {
+ NewPos = state->CurrentY - 5;
+ break;
+ }
+
+ case SB_LINEDOWN:
+ {
+ NewPos = state->CurrentY + 5;
+ break;
+ }
+
+ case SB_PAGEUP:
+ {
+ NewPos = state->CurrentY - si.nPage;
+ break;
+ }
+
+ case SB_PAGEDOWN:
+ {
+ NewPos = state->CurrentY + si.nPage;
+ break;
+ }
+
+ default:
+ {
+ NewPos = state->CurrentY;
+ break;
+ }
+ }
+
+ NewPos = min(state->MaxY, max(0, NewPos));
+
+ if (NewPos == state->CurrentY)
+ {
+ return;
+ }
+
+ Delta = NewPos - state->CurrentY;
+
+ state->CurrentY = NewPos;
+
+ ScrollWindowEx(hWnd, 0, -Delta, NULL, NULL, NULL, NULL, SW_INVALIDATE);
+
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_POS;
+ si.nPos = state->CurrentY;
+ SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
+}
+
+void UpdateWindowScrollState(HWND hWnd, HBITMAP hBitmap, LPSCROLLSTATE lpState)
+{
+ BITMAP bmp;
+ RECT rc;
+
+ if (!GetObject(hBitmap, sizeof(BITMAP), &bmp))
+ {
+ bmp.bmWidth = 0;
+ bmp.bmHeight = 0;
+ }
+
+ if (!GetClientRect(hWnd, &rc))
+ {
+ SetRectEmpty(&rc);
+ }
+
+ lpState->MaxX = max(bmp.bmWidth - rc.right, 0);
+ lpState->CurrentX = min(lpState->CurrentX, lpState->MaxX);
+ InternalSetScrollInfo(hWnd, 0, bmp.bmWidth, rc.right, lpState->CurrentX,
SB_HORZ);
+
+ lpState->MaxY = max(bmp.bmHeight - rc.bottom, 0);
+ lpState->CurrentY = min(lpState->CurrentY, lpState->MaxY);
+ InternalSetScrollInfo(hWnd, 0, bmp.bmHeight, rc.bottom, lpState->CurrentY,
SB_VERT);
+}
+
+BOOL ScrollBlt(PAINTSTRUCT ps, HBITMAP hBmp, SCROLLSTATE state)
+{
+ RECT rect;
+ BOOL ret;
+ HDC hdc;
+ int xpos;
+ int ypos;
+
+ rect.left = ps.rcPaint.left;
+ rect.top = ps.rcPaint.top;
+ rect.right = (ps.rcPaint.right - ps.rcPaint.left);
+ rect.bottom = (ps.rcPaint.bottom - ps.rcPaint.top);
+
+ xpos = ps.rcPaint.left + state.CurrentX;
+ ypos = ps.rcPaint.top + state.CurrentY;
+
+ ret = FALSE;
+
+ hdc = CreateCompatibleDC(ps.hdc);
+ if (hdc)
+ {
+ if (SelectObject(hdc, hBmp))
+ {
+ ret = BitBlt(ps.hdc, rect.left, rect.top, rect.right, rect.bottom, hdc, xpos,
ypos, SRCCOPY);
+ }
+ DeleteDC(hdc);
+ }
+
+ return ret;
+}
Propchange: trunk/reactos/base/applications/clipbrd/scrollutils.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/base/applications/clipbrd/winutils.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/winutils.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/winutils.h [iso-8859-1] Sat Dec 12 21:15:53
2015
@@ -1,7 +1,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Clipboard Viewer
- * FILE: base/applications/clipbrd/winutils.c
+ * FILE: base/applications/clipbrd/winutils.h
* PURPOSE: Miscellaneous helper functions.
* PROGRAMMERS: Ricardo Hanke
*/