[MAGNIFY] Minor whitespace / formatting fixes; use the new file headers + some code simplifications here and there...

This commit is contained in:
Hermès Bélusca-Maïto 2019-06-15 19:09:28 +02:00
parent 4e91b6d5db
commit 16646fb19c
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
3 changed files with 190 additions and 215 deletions

View file

@ -1,11 +1,9 @@
/*
* PROJECT: ReactOS Magnify
* LICENSE: GPL - See COPYING in the top level directory
* FILE: base/applications/magnify/magnifier.c
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Magnification of parts of the screen.
* AUTHORS:
* Marc Piulachs <marc.piulachs@codexchange.net>
* David Quintana <gigaherz@gmail.com>
* COPYRIGHT: Copyright 2007-2019 Marc Piulachs <marc.piulachs@codexchange.net>
* Copyright 2015-2019 David Quintana <gigaherz@gmail.com>
*/
/* TODO: Support AppBar types other than ABE_TOP */
@ -197,7 +195,6 @@ void DoAppBarStuff(DWORD mode)
data.uEdge = AppBarConfig.uEdge;
uState = SHAppBarMessage(ABM_QUERYPOS, &data);
uState = SHAppBarMessage(ABM_SETPOS, &data);
rcw = data.rc.right-data.rc.left;
@ -286,8 +283,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
}
/* Create the Window */
hMainWnd = CreateWindowEx(
exStyles,
hMainWnd = CreateWindowEx(exStyles,
szWindowClass,
szTitle,
dwStyles,
@ -299,20 +295,18 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
NULL,
hInstance,
NULL);
if (!hMainWnd)
return FALSE;
if (AppBarConfig.uEdge>=0) DoAppBarStuff(ABM_NEW);
else SetWindowPos(hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
if (AppBarConfig.uEdge >= 0)
DoAppBarStuff(ABM_NEW);
else
SetWindowPos(hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
// In Windows 2003's Magnifier, the "Start Minimized" setting
// refers exclusively to the options dialog, not the main window itself.
hOptionsDialog = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOGOPTIONS), hMainWnd, OptionsProc);
if (bStartMinimized)
ShowWindow(hOptionsDialog, SW_HIDE);
else
ShowWindow(hOptionsDialog, SW_SHOW);
ShowWindow(hOptionsDialog, (bStartMinimized ? SW_HIDE : SW_SHOW));
if (bShowWarning)
DialogBox(hInstance, MAKEINTRESOURCE(IDD_WARNINGDIALOG), hMainWnd, WarningProc);
@ -320,7 +314,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
return TRUE;
}
void Refresh()
void Refresh(void)
{
if (!IsIconic(hMainWnd))
{
@ -411,8 +405,7 @@ void Draw(HDC aDc)
hdcOffscreen = CreateCompatibleDC(desktopHdc);
/* Create a bitmap compatible with the client area DC */
hbmpOffscreen = CreateCompatibleBitmap(
desktopHdc,
hbmpOffscreen = CreateCompatibleBitmap(desktopHdc,
sourceWidth,
sourceHeight);
@ -429,8 +422,7 @@ void Draw(HDC aDc)
GetBestOverlapWithMonitors(&sourceRect);
/* Paint the screen bitmap to our in memory DC */
BitBlt(
hdcOffscreen,
BitBlt(hdcOffscreen,
0,
0,
sourceWidth,
@ -447,15 +439,13 @@ void Draw(HDC aDc)
}
/* Draw the mouse pointer in the right position */
DrawIcon(
hdcOffscreen ,
DrawIcon(hdcOffscreen,
pMouse.x - iinfo.xHotspot - sourceRect.left, // - 10,
pMouse.y - iinfo.yHotspot - sourceRect.top, // - 10,
cinfo.hCursor);
/* Blast the stretched image from memory DC to window DC */
StretchBlt(
aDc,
StretchBlt(aDc,
0,
0,
AppWidth,
@ -611,14 +601,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
switch (wmId)
{
case IDM_OPTIONS:
if(bOptionsDialog)
{
ShowWindow(hOptionsDialog, SW_HIDE);
}
else
{
ShowWindow(hOptionsDialog, SW_SHOW);
}
ShowWindow(hOptionsDialog, (bOptionsDialog ? SW_HIDE : SW_SHOW));
break;
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, AboutProc);
@ -661,6 +644,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
}
case WM_MOUSEMOVE:
if (GetCapture() == hWnd)
{
@ -725,6 +709,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Refresh();
}
break;
case WM_LBUTTONUP:
if (GetCapture() == hWnd)
{
@ -737,7 +722,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
case WM_SIZE:
if(AppBarConfig.uEdge>=0) DoAppBarStuff(ABM_SETPOS);
if (AppBarConfig.uEdge >= 0)
DoAppBarStuff(ABM_SETPOS);
/* fallthrough */
case WM_DISPLAYCHANGE:
bRecreateOffscreenDC = TRUE;
@ -823,10 +809,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
}
case ABN_WINDOWARRANGE:
if(lParam)
ShowWindow(hMainWnd, SW_HIDE);
else
ShowWindow(hMainWnd, SW_SHOW);
ShowWindow(hMainWnd, (lParam ? SW_HIDE : SW_SHOW));
break;
}
return 0;
@ -837,11 +820,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return 0;
case WM_ACTIVATE:
if(AppBarConfig.uEdge>=0) DoAppBarStuff(ABM_ACTIVATE);
if (AppBarConfig.uEdge >= 0)
DoAppBarStuff(ABM_ACTIVATE);
break;
case WM_WINDOWPOSCHANGED:
if(AppBarConfig.uEdge>=0) DoAppBarStuff(ABM_WINDOWPOSCHANGED);
if (AppBarConfig.uEdge >= 0)
DoAppBarStuff(ABM_WINDOWPOSCHANGED);
Refresh();
break;
@ -875,11 +860,9 @@ INT_PTR CALLBACK AboutProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
INT_PTR CALLBACK OptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_SHOWWINDOW:
bOptionsDialog = wParam;
break;
case WM_INITDIALOG:
{
/* Add the zoom items */
@ -917,6 +900,10 @@ INT_PTR CALLBACK OptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
return (INT_PTR)TRUE;
}
case WM_SHOWWINDOW:
bOptionsDialog = wParam;
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
@ -929,6 +916,7 @@ INT_PTR CALLBACK OptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
/* Unimplemented */
MessageBox(hDlg, TEXT("Magnifier help not available yet!"), TEXT("Help"), MB_OK);
break;
case IDC_ZOOM:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
@ -950,6 +938,7 @@ INT_PTR CALLBACK OptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
Refresh();
}
break;
case IDC_INVERTCOLORSCHECK:
bInvertColors = IsDlgButtonChecked(hDlg, IDC_INVERTCOLORSCHECK);
Refresh();
@ -968,10 +957,7 @@ INT_PTR CALLBACK OptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
break;
case IDC_SHOWMAGNIFIER:
bShowMagnifier = IsDlgButtonChecked(hDlg, IDC_SHOWMAGNIFIERCHECK);
if (bShowMagnifier)
ShowWindow (hMainWnd , SW_SHOW);
else
ShowWindow (hMainWnd , SW_HIDE);
ShowWindow(hMainWnd, (bShowMagnifier ? SW_SHOW : SW_HIDE));
break;
}
}

View file

@ -1,21 +1,9 @@
/*
* WineCalc (magnifier.h)
*
* Copyright 2007 Marc Piulachs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* PROJECT: ReactOS Magnify
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Magnification of parts of the screen.
* COPYRIGHT: Copyright 2007-2019 Marc Piulachs <marc.piulachs@codexchange.net>
* Copyright 2015-2019 David Quintana <gigaherz@gmail.com>
*/
#ifndef _MAGNIFIER_H_
@ -26,7 +14,8 @@
extern UINT uiZoom;
struct _AppBarConfig_t {
struct _AppBarConfig_t
{
DWORD cbSize;
INT uEdge;
DWORD value3;

View file

@ -1,10 +1,9 @@
/*
* PROJECT: ReactOS Magnify
* LICENSE: GPL - See COPYING in the top level directory
* FILE: base/applications/magnify/settings.c
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Magnification of parts of the screen.
* COPYRIGHT: Copyright 2007 Marc Piulachs <marc.piulachs@codexchange.net>
*
* COPYRIGHT: Copyright 2007-2019 Marc Piulachs <marc.piulachs@codexchange.net>
* Copyright 2015-2019 David Quintana <gigaherz@gmail.com>
*/
#include "magnifier.h"
@ -24,7 +23,8 @@ BOOL bInvertColors = FALSE;
BOOL bStartMinimized = FALSE;
BOOL bShowMagnifier = TRUE;
struct _AppBarConfig_t AppBarConfig = {
struct _AppBarConfig_t AppBarConfig =
{
sizeof(struct _AppBarConfig_t),
-2 /* ABE_TOP */,
0, 1, /* unknown */
@ -32,15 +32,16 @@ struct _AppBarConfig_t AppBarConfig = {
{ 20, 20, 600, 200 }, /* floating window rect */
};
void LoadSettings()
void LoadSettings(void)
{
HKEY hkey;
LONG value;
ULONG len;
struct _AppBarConfig_t config_temp;
if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0, KEY_READ, &hkey) == ERROR_SUCCESS)
{
if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0, KEY_READ, &hkey) != ERROR_SUCCESS)
return;
len = sizeof(AppBarConfig);
if (RegQueryValueEx(hkey, _T("AppBar"), 0, 0, (BYTE *)&config_temp, &len) == ERROR_SUCCESS)
{
@ -59,43 +60,43 @@ void LoadSettings()
len = sizeof(value);
if (RegQueryValueEx(hkey, _T("ShowWarning"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
bShowWarning = (value == 0 ? FALSE : TRUE);
bShowWarning = !!value;
len = sizeof(value);
if (RegQueryValueEx(hkey, _T("StationaryInvertColors"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
bInvertColors = (value == 0 ? FALSE : TRUE);
bInvertColors = !!value;
len = sizeof(value);
if (RegQueryValueEx(hkey, _T("StationaryStartMinimized"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
bStartMinimized = (value == 0 ? FALSE : TRUE);
bStartMinimized = !!value;
len = sizeof(value);
if (RegQueryValueEx(hkey, _T("StationaryTrackCursor"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
bFollowMouse = (value == 0 ? FALSE : TRUE);
bFollowMouse = !!value;
len = sizeof(value);
if (RegQueryValueEx(hkey, _T("StationaryTrackFocus"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
bFollowFocus = (value == 0 ? FALSE : TRUE);
bFollowFocus = !!value;
len = sizeof(value);
if (RegQueryValueEx(hkey, _T("StationaryTrackSecondaryFocus"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
bFollowFocus = (value == 0 ? FALSE : TRUE);
bFollowFocus = !!value;
len = sizeof(value);
if (RegQueryValueEx(hkey, _T("StationaryTrackText"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
bFollowCaret = (value == 0 ? FALSE : TRUE);
bFollowCaret = !!value;
RegCloseKey(hkey);
}
}
void SaveSettings()
void SaveSettings(void)
{
HKEY hkey;
LONG value;
if (RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0, _T(""), 0, KEY_WRITE, NULL, &hkey, NULL) == ERROR_SUCCESS)
{
if (RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0, _T(""), 0, KEY_WRITE, NULL, &hkey, NULL) != ERROR_SUCCESS)
return;
RegSetValueEx(hkey, _T("AppBar"), 0, REG_BINARY, (BYTE *)&AppBarConfig, sizeof(AppBarConfig));
value = uiZoom;
@ -124,4 +125,3 @@ void SaveSettings()
RegCloseKey(hkey);
}
}