- allow to cange zoom factor and display zoom factor
- add accelerator table

svn path=/trunk/; revision=18415
This commit is contained in:
Martin Fuchs 2005-10-12 20:20:18 +00:00
parent e7045161ac
commit 4fe5d38bfa
6 changed files with 76 additions and 52 deletions

View file

@ -42,9 +42,32 @@ static RECT s_lastSrc = {-1,-1,-1,-1}; // last cursor position
BOOL s_dragging = FALSE;
// zoom range
#define MIN_ZOOM 1
#define MAX_ZOOM 16
////////////////////////////////////////////////////////////////////////////////
// Local module support methods
//
// FUNCTION: SetZoom()
//
// PURPOSE: Change zoom level
//
static void SetZoom(HWND hWnd, int factor)
{
TCHAR buffer[MAX_LOADSTRING];
if (factor>=MIN_ZOOM && factor<=MAX_ZOOM) {
s_factor = factor;
SetScrollPos(hWnd, SB_VERT, s_factor, TRUE);
wsprintf(buffer, TEXT("%s %dx"), szTitle, s_factor);
SetWindowText(hWnd, buffer);
}
}
////////////////////////////////////////////////////////////////////////////////
@ -70,6 +93,10 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
// TODO:
break;
case ID_REFRESH:
InvalidateRect(hWnd, NULL, FALSE);
break;
default:
return FALSE;
}
@ -89,6 +116,8 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
switch (message) {
case WM_CREATE:
SetTimer(hWnd, 0, 200, NULL); // refresh display all 200 ms
SetScrollRange(hWnd, SB_VERT, 1, MAX_ZOOM, FALSE);
SetZoom(hWnd, s_factor);
break;
case WM_COMMAND:
@ -107,10 +136,11 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
hdcMem = GetDC(GetDesktopWindow());
GetClientRect(hWnd, &clnt);
size.cx = clnt.right / s_factor;
size.cy = clnt.bottom / s_factor;
size.cx = (clnt.right + s_factor-1) / s_factor;
size.cy = (clnt.bottom + s_factor-1) / s_factor;
StretchBlt(ps.hdc, 0, 0, size.cx*s_factor, size.cy*s_factor, hdcMem, s_srcPos.x, s_srcPos.y, size.cx, size.cy, SRCCOPY);
StretchBlt(ps.hdc, 0, 0, size.cx*s_factor, size.cy*s_factor,
hdcMem, s_srcPos.x, s_srcPos.y, size.cx, size.cy, SRCCOPY);
ReleaseDC(GetDesktopWindow(), hdcMem);
EndPaint(hWnd, &ps);
@ -181,6 +211,20 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
}
break;
case WM_VSCROLL:
switch(wParam) {
case SB_LINEUP:
case SB_PAGEUP:
SetZoom(hWnd, s_factor-1);
break;
case SB_LINEDOWN:
case SB_PAGEDOWN:
SetZoom(hWnd, s_factor+1);
break;
}
break;
case WM_DESTROY:
KillTimer(hWnd, 0);
PostQuitMessage(0);

View file

@ -23,17 +23,10 @@
#ifndef __FRAMEWND_H__
#define __FRAMEWND_H__
#ifdef __cplusplus
extern "C" {
#endif
LRESULT CALLBACK FrameWndProc(HWND, UINT, WPARAM, LPARAM);
#ifdef __cplusplus
};
#endif
#define WNDCLASS_ZOOMIN TEXT("ZOOMIN")
#endif // __FRAMEWND_H__

View file

@ -38,7 +38,6 @@ HWND hFrameWnd;
HMENU hMenuFrame;
TCHAR szTitle[MAX_LOADSTRING];
TCHAR szFrameClass[MAX_LOADSTRING];
////////////////////////////////////////////////////////////////////////////////
@ -61,7 +60,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
LoadCursor(0, IDC_ARROW),
0,//(HBRUSH)(COLOR_BTNFACE+1),
0/*lpszMenuName*/,
szFrameClass,
WNDCLASS_ZOOMIN,
(HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_ZOOMIN), IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
};
@ -70,7 +69,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_ZOOMIN_MENU));
hFrameWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle,
WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE,
WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE | WS_VSCROLL,
CW_USEDEFAULT, CW_USEDEFAULT, 250, 250,
NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
@ -80,6 +79,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
ShowWindow(hFrameWnd, nCmdShow);
UpdateWindow(hFrameWnd);
return TRUE;
}
@ -97,22 +97,21 @@ int APIENTRY WinMain(HINSTANCE hInstance,
int nCmdShow)
{
MSG msg;
HACCEL hAccel;
HACCEL hAccel;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_ZOOMIN, szFrameClass, MAX_LOADSTRING);
// Perform application initialization:
if (!InitInstance(hInstance, nCmdShow)) {
return FALSE;
}
hAccel = LoadAccelerators(hInstance, (LPCTSTR)IDC_ZOOMIN);
hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ZOOMIN));
// Main message loop:
while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
if (!TranslateAccelerator(msg.hwnd, hAccel, &msg)) {
if (!TranslateAccelerator(msg.hwnd, hAccel, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}

View file

@ -23,11 +23,6 @@
#ifndef __MAIN_H__
#define __MAIN_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "resource.h"
#define MAX_LOADSTRING 100
@ -40,11 +35,6 @@ extern HWND hFrameWnd;
extern HMENU hMenuFrame;
extern TCHAR szTitle[];
extern TCHAR szFrameClass[];
#ifdef __cplusplus
};
#endif
#endif // __MAIN_H__

View file

@ -7,9 +7,8 @@
#define IDS_APP_TITLE 103
#define IDI_ZOOMIN 107
#define IDI_SMALL 108
#define IDC_ZOOMIN 109
#define IDR_ZOOMIN_MENU 110
#define IDD_DIALOG1 111
#define IDR_ZOOMIN_MENU 109
#define IDR_ZOOMIN 110
#define ID_EDIT_EXIT 32700
#define ID_EDIT_COPY 32701
@ -17,5 +16,7 @@
#define ID_OPTIONS_REFRESH_RATE 32704
#define ID_HELP_ABOUT 32703
#define ID_REFRESH 40001
#define IDC_STATIC -1

View file

@ -31,12 +31,14 @@ IDI_ZOOMIN ICON DISCARDABLE "res/zoomin.ico"
IDR_ZOOMIN_MENU MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit\tAlt-F4", ID_EDIT_EXIT
END
POPUP "&Edit"
BEGIN
MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY, GRAYED
MENUITEM "&Refresh\tF5", ID_EDIT_REFRESH, GRAYED
MENUITEM SEPARATOR
MENUITEM "E&xit\tAlt-F4", ID_EDIT_EXIT
MENUITEM "&Refresh\tF5", ID_EDIT_REFRESH
END
POPUP "&Options"
BEGIN
@ -67,21 +69,6 @@ BEGIN
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 186, 95
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
END
/////////////////////////////////////////////////////////////////////////////
//
// String Table
@ -90,5 +77,15 @@ END
STRINGTABLE DISCARDABLE
BEGIN
IDS_APP_TITLE "ReactOS Zoomin"
IDC_ZOOMIN "ZOOMIN"
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_ZOOMIN ACCELERATORS DISCARDABLE
BEGIN
VK_F5, ID_REFRESH, VIRTKEY, NOINVERT
END