mirror of
https://github.com/reactos/reactos.git
synced 2025-02-20 15:35:04 +00:00
[MSPAINT] Refactoring (_countof and resource.h) (#4202)
- Use Microsoft standard _countof macro instead of SIZEOF. - Rename definitions.h as resource.h. - Move some macro definitions to its proper place. CORE-17931
This commit is contained in:
parent
ad49da70a1
commit
2ca3ff5bc6
9 changed files with 56 additions and 58 deletions
|
@ -2,7 +2,7 @@
|
|||
* PROJECT: PAINT for ReactOS
|
||||
* LICENSE: LGPL
|
||||
* FILE: base/applications/mspaint/common.h
|
||||
* PURPOSE: Commonly used functions
|
||||
* PURPOSE: Commonly used functions and definitions
|
||||
* PROGRAMMERS: Benedikt Freisen
|
||||
* Stanislav Motylkov
|
||||
* Katayama Hirofumi MZ
|
||||
|
@ -10,6 +10,22 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define GRIP_SIZE 3
|
||||
#define MIN_ZOOM 125
|
||||
#define MAX_ZOOM 8000
|
||||
|
||||
/* width of the rectangle defined by a RECT structure */
|
||||
#define RECT_WIDTH(a) ((a).right - (a).left)
|
||||
|
||||
/* height of the rectangle defined by a RECT structure */
|
||||
#define RECT_HEIGHT(a) ((a).bottom - (a).top)
|
||||
|
||||
/* this simplifies checking and unchecking menu items */
|
||||
#define CHECKED_IF(a) ((a) ? (MF_CHECKED | MF_BYCOMMAND) : (MF_UNCHECKED | MF_BYCOMMAND))
|
||||
|
||||
/* this simplifies enabling or graying menu items */
|
||||
#define ENABLED_IF(a) ((a) ? (MF_ENABLED | MF_BYCOMMAND) : (MF_GRAYED | MF_BYCOMMAND))
|
||||
|
||||
/* FUNCTIONS ********************************************************/
|
||||
|
||||
BOOL zoomTo(int newZoom, int mouseX, int mouseY);
|
||||
|
@ -24,7 +40,3 @@ static inline int UnZoomed(int xy)
|
|||
{
|
||||
return xy * 1000 / toolsModel.GetZoom();
|
||||
}
|
||||
|
||||
#define GRIP_SIZE 3
|
||||
#define MIN_ZOOM 125
|
||||
#define MAX_ZOOM 8000
|
||||
|
|
|
@ -88,8 +88,8 @@ LRESULT CAttributesDialog::OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam,
|
|||
{
|
||||
TCHAR date[100];
|
||||
TCHAR temp[100];
|
||||
GetDateFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, date, SIZEOF(date));
|
||||
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, temp, SIZEOF(temp));
|
||||
GetDateFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, date, _countof(date));
|
||||
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, temp, _countof(temp));
|
||||
_tcscat(date, _T(" "));
|
||||
_tcscat(date, temp);
|
||||
CString strSize;
|
||||
|
@ -166,17 +166,17 @@ LRESULT CAttributesDialog::OnEdit1(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOO
|
|||
TCHAR tempS[100];
|
||||
if (IsDlgButtonChecked(IDD_ATTRIBUTESRB1))
|
||||
{
|
||||
GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, SIZEOF(tempS));
|
||||
GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, _countof(tempS));
|
||||
newWidth = max(1, (int) (_tcstod(tempS, NULL) * fileHPPM * 0.0254));
|
||||
}
|
||||
else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2))
|
||||
{
|
||||
GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, SIZEOF(tempS));
|
||||
GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, _countof(tempS));
|
||||
newWidth = max(1, (int) (_tcstod(tempS, NULL) * fileHPPM / 100));
|
||||
}
|
||||
else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB3))
|
||||
{
|
||||
GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, SIZEOF(tempS));
|
||||
GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, _countof(tempS));
|
||||
newWidth = max(1, _tstoi(tempS));
|
||||
}
|
||||
Edit_SetModify(hWndCtl, FALSE);
|
||||
|
@ -191,17 +191,17 @@ LRESULT CAttributesDialog::OnEdit2(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOO
|
|||
TCHAR tempS[100];
|
||||
if (IsDlgButtonChecked(IDD_ATTRIBUTESRB1))
|
||||
{
|
||||
GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, SIZEOF(tempS));
|
||||
GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, _countof(tempS));
|
||||
newHeight = max(1, (int) (_tcstod(tempS, NULL) * fileVPPM * 0.0254));
|
||||
}
|
||||
else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2))
|
||||
{
|
||||
GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, SIZEOF(tempS));
|
||||
GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, _countof(tempS));
|
||||
newHeight = max(1, (int) (_tcstod(tempS, NULL) * fileVPPM / 100));
|
||||
}
|
||||
else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB3))
|
||||
{
|
||||
GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, SIZEOF(tempS));
|
||||
GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, _countof(tempS));
|
||||
newHeight = max(1, _tstoi(tempS));
|
||||
}
|
||||
Edit_SetModify(hWndCtl, FALSE);
|
||||
|
|
|
@ -137,9 +137,9 @@ HBITMAP SetBitmapAndInfo(HBITMAP hBitmap, LPCTSTR name, DWORD dwFileSize, BOOL i
|
|||
|
||||
// update filepathname
|
||||
if (name && name[0])
|
||||
GetFullPathName(name, SIZEOF(filepathname), filepathname, NULL);
|
||||
GetFullPathName(name, _countof(filepathname), filepathname, NULL);
|
||||
else
|
||||
LoadString(hProgInstance, IDS_DEFAULTFILENAME, filepathname, SIZEOF(filepathname));
|
||||
LoadString(hProgInstance, IDS_DEFAULTFILENAME, filepathname, _countof(filepathname));
|
||||
|
||||
// set title
|
||||
CString strTitle;
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
/* HISTORYSIZE = number of possible undo-steps + 1 */
|
||||
#define HISTORYSIZE 11
|
||||
|
||||
class ImageModel
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -120,7 +120,7 @@ OFNHookProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
{
|
||||
hParent = GetParent(hwnd);
|
||||
TCHAR Path[MAX_PATH];
|
||||
SendMessage(hParent, CDM_GETFILEPATH, SIZEOF(Path), (LPARAM)Path);
|
||||
SendMessage(hParent, CDM_GETFILEPATH, _countof(Path), (LPARAM)Path);
|
||||
LPTSTR pchTitle = _tcsrchr(Path, _T('\\'));
|
||||
if (pchTitle == NULL)
|
||||
pchTitle = _tcsrchr(Path, _T('/'));
|
||||
|
@ -173,12 +173,12 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
/* initialize common controls library */
|
||||
InitCommonControls();
|
||||
|
||||
LoadString(hThisInstance, IDS_DEFAULTFILENAME, filepathname, SIZEOF(filepathname));
|
||||
LoadString(hThisInstance, IDS_DEFAULTFILENAME, filepathname, _countof(filepathname));
|
||||
CPath pathFileName(filepathname);
|
||||
pathFileName.StripPath();
|
||||
CString strTitle;
|
||||
strTitle.Format(IDS_WINDOWTITLE, (LPCTSTR)pathFileName);
|
||||
LoadString(hThisInstance, IDS_MINIATURETITLE, miniaturetitle, SIZEOF(miniaturetitle));
|
||||
LoadString(hThisInstance, IDS_MINIATURETITLE, miniaturetitle, _countof(miniaturetitle));
|
||||
|
||||
/* load settings from registry */
|
||||
registrySettings.Load();
|
||||
|
@ -279,9 +279,9 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
ofn.hInstance = hThisInstance;
|
||||
ofn.lpstrFilter = strImporters;
|
||||
ofn.lpstrFile = ofnFilename;
|
||||
ofn.nMaxFile = SIZEOF(ofnFilename);
|
||||
ofn.nMaxFile = _countof(ofnFilename);
|
||||
ofn.lpstrFileTitle = ofnFiletitle;
|
||||
ofn.nMaxFileTitle = SIZEOF(ofnFiletitle);
|
||||
ofn.nMaxFileTitle = _countof(ofnFiletitle);
|
||||
ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
|
||||
ofn.lpstrDefExt = L"png";
|
||||
|
||||
|
@ -295,9 +295,9 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
sfn.hInstance = hThisInstance;
|
||||
sfn.lpstrFilter = strExporters;
|
||||
sfn.lpstrFile = sfnFilename;
|
||||
sfn.nMaxFile = SIZEOF(sfnFilename);
|
||||
sfn.nMaxFile = _countof(sfnFilename);
|
||||
sfn.lpstrFileTitle = sfnFiletitle;
|
||||
sfn.nMaxFileTitle = SIZEOF(sfnFiletitle);
|
||||
sfn.nMaxFileTitle = _countof(sfnFiletitle);
|
||||
sfn.Flags = OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_EXPLORER | OFN_ENABLEHOOK;
|
||||
sfn.lpfnHook = OFNHookProc;
|
||||
sfn.lpstrDefExt = L"png";
|
||||
|
|
|
@ -21,7 +21,16 @@
|
|||
#include <shellapi.h>
|
||||
#include <htmlhelp.h>
|
||||
|
||||
#include "definitions.h"
|
||||
#define WM_TOOLSMODELTOOLCHANGED (WM_APP + 0)
|
||||
#define WM_TOOLSMODELSETTINGSCHANGED (WM_APP + 1)
|
||||
#define WM_TOOLSMODELZOOMCHANGED (WM_APP + 2)
|
||||
#define WM_PALETTEMODELCOLORCHANGED (WM_APP + 3)
|
||||
#define WM_PALETTEMODELPALETTECHANGED (WM_APP + 4)
|
||||
#define WM_IMAGEMODELDIMENSIONSCHANGED (WM_APP + 5)
|
||||
#define WM_IMAGEMODELIMAGECHANGED (WM_APP + 6)
|
||||
#define WM_SELECTIONMODELREFRESHNEEDED (WM_APP + 7)
|
||||
|
||||
#include "resource.h"
|
||||
#include "drawing.h"
|
||||
#include "dib.h"
|
||||
#include "fullscreen.h"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* PROJECT: PAINT for ReactOS
|
||||
* LICENSE: LGPL
|
||||
* FILE: base/applications/mspaint/definitions.h
|
||||
* PURPOSE: Defines the resource ids and other stuff
|
||||
* FILE: base/applications/mspaint/resource.h
|
||||
* PURPOSE: Defines the resource IDs
|
||||
* PROGRAMMERS: Benedikt Freisen
|
||||
*/
|
||||
|
||||
|
@ -10,23 +10,6 @@
|
|||
|
||||
/* DEFINES **********************************************************/
|
||||
|
||||
#define HISTORYSIZE 11
|
||||
/* HISTORYSIZE = number of possible undo-steps + 1 */
|
||||
|
||||
#define SIZEOF(a) (sizeof(a) / sizeof((a)[0]))
|
||||
/* sizeof for string constants; equals max. number of characters */
|
||||
|
||||
#define RECT_WIDTH(a) ((a).right - (a).left)
|
||||
/* width of the rectangle defined by a RECT structure */
|
||||
|
||||
#define RECT_HEIGHT(a) ((a).bottom - (a).top)
|
||||
/* height of the rectangle defined by a RECT structure */
|
||||
|
||||
#define CHECKED_IF(a) ((a) ? (MF_CHECKED | MF_BYCOMMAND) : (MF_UNCHECKED | MF_BYCOMMAND))
|
||||
/* simplifies checking and unchecking menu items */
|
||||
#define ENABLED_IF(a) ((a) ? (MF_ENABLED | MF_BYCOMMAND) : (MF_GRAYED | MF_BYCOMMAND))
|
||||
/* simplifies enabling or graying menu items */
|
||||
|
||||
#define IDI_APPICON 500
|
||||
|
||||
#define IDB_TOOLBARICONS 510
|
||||
|
@ -219,12 +202,3 @@
|
|||
|
||||
#define IDS_LOADERRORTEXT 933
|
||||
#define IDS_ENLARGEPROMPTTEXT 934
|
||||
|
||||
#define WM_TOOLSMODELTOOLCHANGED WM_APP
|
||||
#define WM_TOOLSMODELSETTINGSCHANGED (WM_APP + 1)
|
||||
#define WM_TOOLSMODELZOOMCHANGED (WM_APP + 2)
|
||||
#define WM_PALETTEMODELCOLORCHANGED (WM_APP + 3)
|
||||
#define WM_PALETTEMODELPALETTECHANGED (WM_APP + 4)
|
||||
#define WM_IMAGEMODELDIMENSIONSCHANGED (WM_APP + 5)
|
||||
#define WM_IMAGEMODELIMAGECHANGED (WM_APP + 6)
|
||||
#define WM_SELECTIONMODELREFRESHNEEDED (WM_APP + 7)
|
|
@ -11,7 +11,7 @@
|
|||
#include <windef.h>
|
||||
#include <winuser.h>
|
||||
|
||||
#include "definitions.h"
|
||||
#include "resource.h"
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Paint"
|
||||
#define REACTOS_STR_INTERNAL_NAME "mspaint"
|
||||
|
|
|
@ -94,7 +94,7 @@ void CMainWindow::saveImage(BOOL overwrite)
|
|||
else if (GetSaveFileName(&sfn) != 0)
|
||||
{
|
||||
imageModel.SaveImage(sfn.lpstrFile);
|
||||
_tcsncpy(filepathname, sfn.lpstrFile, SIZEOF(filepathname));
|
||||
_tcsncpy(filepathname, sfn.lpstrFile, _countof(filepathname));
|
||||
CString strTitle;
|
||||
strTitle.Format(IDS_WINDOWTITLE, (LPCTSTR)sfn.lpstrFileTitle);
|
||||
SetWindowText(strTitle);
|
||||
|
@ -118,8 +118,8 @@ void CMainWindow::InsertSelectionFromHBITMAP(HBITMAP bitmap, HWND window)
|
|||
TCHAR programname[20];
|
||||
TCHAR shouldEnlargePromptText[100];
|
||||
|
||||
LoadString(hProgInstance, IDS_PROGRAMNAME, programname, SIZEOF(programname));
|
||||
LoadString(hProgInstance, IDS_ENLARGEPROMPTTEXT, shouldEnlargePromptText, SIZEOF(shouldEnlargePromptText));
|
||||
LoadString(hProgInstance, IDS_PROGRAMNAME, programname, _countof(programname));
|
||||
LoadString(hProgInstance, IDS_ENLARGEPROMPTTEXT, shouldEnlargePromptText, _countof(shouldEnlargePromptText));
|
||||
|
||||
switch (MessageBox(shouldEnlargePromptText, programname, MB_YESNOCANCEL | MB_ICONQUESTION))
|
||||
{
|
||||
|
@ -212,7 +212,7 @@ LRESULT CMainWindow::OnDropFiles(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
|
|||
TCHAR droppedfile[MAX_PATH];
|
||||
|
||||
HDROP hDrop = (HDROP)wParam;
|
||||
DragQueryFile(hDrop, 0, droppedfile, SIZEOF(droppedfile));
|
||||
DragQueryFile(hDrop, 0, droppedfile, _countof(droppedfile));
|
||||
DragFinish(hDrop);
|
||||
|
||||
ConfirmSave() && DoLoadImageFile(m_hWnd, droppedfile, TRUE);
|
||||
|
@ -430,8 +430,8 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
|||
HICON paintIcon = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON));
|
||||
TCHAR infotitle[100];
|
||||
TCHAR infotext[200];
|
||||
LoadString(hProgInstance, IDS_INFOTITLE, infotitle, SIZEOF(infotitle));
|
||||
LoadString(hProgInstance, IDS_INFOTEXT, infotext, SIZEOF(infotext));
|
||||
LoadString(hProgInstance, IDS_INFOTITLE, infotitle, _countof(infotitle));
|
||||
LoadString(hProgInstance, IDS_INFOTEXT, infotext, _countof(infotext));
|
||||
ShellAbout(m_hWnd, infotitle, infotext, paintIcon);
|
||||
DeleteObject(paintIcon);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue