Compare commits

..

3 Commits

Author SHA1 Message Date
Joachim Henze
b09ee4e0a0 [TASKMGR] et-EE.rc is better this way and with less changes
to existing translations.
2023-10-06 12:15:39 +02:00
Joachim Henze
3c1eb7f920 [TASKMGR] fr-FR.rc Respect the french speciality
We verified Win7-en and Win2k3-en to behave as proposed in this PR (R for properties, P for priority).
But *french* Windows (I believe Hermes picture was from WinVista-fr or Win7-fr or Win10-fr maybe) does it differently.
2023-10-05 10:18:37 +02:00
Joachim Henze
1d31de59d1 [TASKMGR] *.rc: Fix accelerator collisions &Priority <-> &Properties
We had them in almost all languages.
Try to fix them in a uniform way:
&Priority
P&roperties

We introduced them during 0.4.15-dev'ing when
MENUITEM ID_PROCESS_PAGE_PROPERTIES
and
MENUITEM ID_PROCESS_PAGE_OPENFILELOCATION
were added.

Yes, I know that kind of stuff is hard to review. Not my fault.
I will PR anyway.

nl-NL.rc had another collision.
2023-10-03 21:14:18 +02:00
684 changed files with 13647 additions and 26089 deletions

View File

@@ -336,12 +336,14 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to
add_subdirectory(sdk/include/reactos/mc)
add_subdirectory(sdk/include/asm)
if(ARCH MATCHES "64$")
include(sdk/cmake/baseaddress64.cmake)
elseif(NO_ROSSYM)
if(NO_ROSSYM)
include(sdk/cmake/baseaddress_dwarf.cmake)
elseif(MSVC)
include(sdk/cmake/baseaddress_msvc.cmake)
if (ARCH STREQUAL "amd64")
include(sdk/cmake/baseaddress_msvc_x64.cmake)
else()
include(sdk/cmake/baseaddress_msvc.cmake)
endif()
else()
include(sdk/cmake/baseaddress.cmake)
endif()

View File

@@ -19,7 +19,7 @@
*/
#include <windef.h>
#include <winuser.rh>
#include <winuser.h>
#include "resource.h"

View File

@@ -1,11 +1,4 @@
/*
* PROJECT: ReactOS Clipboard
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Romanian resource file
* TRANSLATORS: Copyright 2011-2019 Ștefan Fulea <stefan.fulea@mail.com>
* Copyright 2023 Andrei Miloiu <miloiuandrei@gmail.com>
*/
/* Translator: Ștefan Fulea (stefan dot fulea at mail dot com) */
LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL
ID_ACCEL ACCELERATORS
@@ -18,7 +11,7 @@ BEGIN
POPUP "&Fișier"
BEGIN
MENUITEM "&Deschidere…", CMD_OPEN
MENUITEM "S&alvează ca…", CMD_SAVE_AS
MENUITEM "Păst&rare ca…", CMD_SAVE_AS
MENUITEM SEPARATOR
MENUITEM "I&eșire", CMD_EXIT
END

View File

@@ -1,9 +1,7 @@
/*
* PROJECT: ReactOS DX Diagnostic
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Romanian resource file
* TRANSLATORS: Copyright 2011-2019 Ștefan Fulea <stefan.fulea@mail.com>
* Copyright 2023 Andrei Miloiu <miloiuandrei@gmail.com>
* FILE: base/applications/dxdiag/lang/ro-RO.rc
* ReactOS Project (https://reactos.org)
* TRANSLATOR: Ștefan Fulea (stefan dot fulea at mail dot com)
*/
LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL
@@ -17,7 +15,7 @@ BEGIN
CONTROL "Tab1", IDC_TAB_CONTROL, "SysTabControl32", WS_TABSTOP, 2, 2, 474, 250
PUSHBUTTON "&Manual…", IDC_BUTTON_HELP, 2, 260, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED
DEFPUSHBUTTON "&Următorul compartiment", IDC_BUTTON_NEXT, 187, 260, 120, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "S&alvare informații…", IDC_BUTTON_SAVE_INFO, 311, 260, 110, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED
PUSHBUTTON "&Păstrare informații…", IDC_BUTTON_SAVE_INFO, 311, 260, 110, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED
PUSHBUTTON "Î&nchide", IDC_BUTTON_EXIT, 425, 260, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
END

View File

@@ -4,7 +4,7 @@
* PURPOSE: Romanian resource file
* TRANSLATORS: Copyright 2009 Petru Dimitriu <petrimetri@gmail.com>
* Copyright 2011-2018 Ștefan Fulea <stefan.fulea@mail.com>
* Copyright 2022-2023 Andrei Miloiu <miloiuandrei@gmail.com>
* Copyright 2022 Andrei Miloiu <miloiuandrei@gmail.com>
*/
LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL
@@ -25,7 +25,7 @@ BEGIN
AUTORADIOBUTTON "Fă&ră", IDC_OPT_NOSCORE, 107, 45, 60, 10
AUTOCHECKBOX "&Afișează timp", IDC_OPT_SHOWTIME, 7 ,51 ,65 ,10, WS_TABSTOP
AUTOCHECKBOX "&Bară de stare", IDC_OPT_STATUSBAR, 7, 66, 64, 10, WS_TABSTOP
AUTOCHECKBOX "Salvea&ză scorul", IDC_OPT_KEEPSCORE, 100, 66, 65, 10, WS_TABSTOP
AUTOCHECKBOX "&Păstrează scorul", IDC_OPT_KEEPSCORE, 100, 66, 65, 10, WS_TABSTOP
DEFPUSHBUTTON "Con&firmă", IDOK, 35, 97, 50, 14
PUSHBUTTON "A&nulează", IDCANCEL, 101, 97, 50, 14
END

View File

@@ -145,9 +145,16 @@ static VOID UpdateLayoutList(HKL hKL OPTIONAL)
if (!hKL)
{
HWND hwndTarget = (g_hwndLastActive ? g_hwndLastActive : GetForegroundWindow());
DWORD dwTID = GetWindowThreadProcessId(hwndTarget, NULL);
hKL = GetKeyboardLayout(dwTID);
if (0 <= (g_nCurrentLayoutNum - 1) && (g_nCurrentLayoutNum - 1) < g_cKLs)
{
hKL = g_ahKLs[g_nCurrentLayoutNum - 1];
}
else
{
HWND hwndTarget = (g_hwndLastActive ? g_hwndLastActive : GetForegroundWindow());
DWORD dwTID = GetWindowThreadProcessId(hwndTarget, NULL);
hKL = GetKeyboardLayout(dwTID);
}
}
g_cKLs = GetKeyboardLayoutList(ARRAYSIZE(g_ahKLs), g_ahKLs);
@@ -730,8 +737,6 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
case WM_RBUTTONUP:
case WM_LBUTTONUP:
{
UpdateLayoutList(NULL);
GetCursorPos(&pt);
SetForegroundWindow(hwnd);

View File

@@ -28,8 +28,8 @@ BEGIN
BEGIN
MENUITEM "&Nou\tCtrl+N", IDM_FILE_NEW
MENUITEM "&Deschide\tCtrl+O", IDM_FILE_OPEN
MENUITEM "S&alvează", IDM_FILE_SAVE
MENUITEM "Sal&vează ca…", IDM_FILE_SAVEAS
MENUITEM "&Păstrează", IDM_FILE_SAVE
MENUITEM "Păst&rare în…", IDM_FILE_SAVEAS
MENUITEM SEPARATOR
MENUITEM "I&eșire\tAlt+F4", IDM_FILE_EXIT
END

View File

@@ -28,7 +28,7 @@ list(APPEND SOURCE
winproc.cpp
precomp.h)
file(GLOB mspaint_rc_deps img/*.*)
file(GLOB mspaint_rc_deps icons/*.*)
add_rc_deps(rsrc.rc ${mspaint_rc_deps})
add_executable(mspaint ${SOURCE} rsrc.rc)
set_module_type(mspaint win32gui UNICODE)

View File

@@ -69,7 +69,7 @@ public:
return TRUE;
}
HRESULT LoadDx(LPCWSTR pszFileName, float *pxDpi, float *pyDpi) throw()
HRESULT LoadDx(LPCTSTR pszFileName, float *pxDpi, float *pyDpi) throw()
{
using namespace Gdiplus;
@@ -111,7 +111,7 @@ public:
return (status == Ok ? S_OK : E_FAIL);
}
HRESULT SaveDx(LPCWSTR pszFileName, REFGUID guidFileType = GUID_NULL,
HRESULT SaveDx(LPCTSTR pszFileName, REFGUID guidFileType = GUID_NULL,
float xDpi = 0, float yDpi = 0) throw()
{
using namespace Gdiplus;
@@ -141,7 +141,7 @@ public:
CLSID clsid;
if (::IsEqualGUID(guidFileType, GUID_NULL))
{
CStringW strExt(PathFindExtensionW(pszFileName));
CString strExt(PathFindExtension(pszFileName));
clsid = FindCodecForExtension(strExt, pEncoders, cEncoders);
}
else
@@ -300,23 +300,23 @@ protected:
// CImage::FindCodecForExtension is private. We have to duplicate it at here...
static CLSID
FindCodecForExtension(LPCWSTR dotext, const Gdiplus::ImageCodecInfo *pCodecs, UINT nCodecs)
FindCodecForExtension(LPCTSTR dotext, const Gdiplus::ImageCodecInfo *pCodecs, UINT nCodecs)
{
for (UINT i = 0; i < nCodecs; ++i)
{
CStringW strSpecs(pCodecs[i].FilenameExtension);
CString strSpecs(pCodecs[i].FilenameExtension);
int ichOld = 0, ichSep;
for (;;)
{
ichSep = strSpecs.Find(L';', ichOld);
ichSep = strSpecs.Find(TEXT(';'), ichOld);
CStringW strSpec;
CString strSpec;
if (ichSep < 0)
strSpec = strSpecs.Mid(ichOld);
else
strSpec = strSpecs.Mid(ichOld, ichSep - ichOld);
int ichDot = strSpec.ReverseFind(L'.');
int ichDot = strSpec.ReverseFind(TEXT('.'));
if (ichDot >= 0)
strSpec = strSpec.Mid(ichDot);

View File

@@ -29,6 +29,18 @@ CCanvasWindow::~CCanvasWindow()
::DeleteObject(m_ahbmCached[1]);
}
VOID CCanvasWindow::drawZoomFrame(INT mouseX, INT mouseY)
{
// FIXME: Draw the border of the area that is to be zoomed in
CRect rc;
GetImageRect(rc);
ImageToCanvas(rc);
HDC hdc = GetDC();
DrawXorRect(hdc, &rc);
ReleaseDC(hdc);
}
RECT CCanvasWindow::GetBaseRect()
{
CRect rcBase;
@@ -89,88 +101,31 @@ HITTEST CCanvasWindow::CanvasHitTest(POINT pt)
return getSizeBoxHitTest(pt, &rcBase);
}
VOID CCanvasWindow::getNewZoomRect(CRect& rcView, INT newZoom, CPoint ptTarget)
{
CRect rcImage;
GetImageRect(rcImage);
ImageToCanvas(rcImage);
// Calculate the zoom rectangle
INT oldZoom = toolsModel.GetZoom();
GetClientRect(rcView);
LONG cxView = rcView.right * oldZoom / newZoom, cyView = rcView.bottom * oldZoom / newZoom;
::SetRect(&rcView, ptTarget.x - cxView / 2, ptTarget.y - cyView / 2,
ptTarget.x + cxView / 2, ptTarget.y + cyView / 2);
// Shift the rectangle if necessary
INT dx = 0, dy = 0;
if (rcView.left < rcImage.left)
dx = rcImage.left - rcView.left;
else if (rcImage.right < rcView.right)
dx = rcImage.right - rcView.right;
if (rcView.top < rcImage.top)
dy = rcImage.top - rcView.top;
else if (rcImage.bottom < rcView.bottom)
dy = rcImage.bottom - rcView.bottom;
rcView.OffsetRect(dx, dy);
rcView.IntersectRect(&rcView, &rcImage);
}
VOID CCanvasWindow::zoomTo(INT newZoom, LONG left, LONG top)
{
POINT pt = { left, top };
CanvasToImage(pt);
toolsModel.SetZoom(newZoom);
ImageToCanvas(pt);
pt.x += GetScrollPos(SB_HORZ);
pt.y += GetScrollPos(SB_VERT);
updateScrollRange();
updateScrollPos(pt.x, pt.y);
Invalidate(TRUE);
}
VOID CCanvasWindow::DoDraw(HDC hDC, RECT& rcClient, RECT& rcPaint)
{
// This is the target area we have to draw on
CRect rcCanvasDraw;
rcCanvasDraw.IntersectRect(&rcClient, &rcPaint);
// We use a memory bitmap to reduce flickering
HDC hdcMem0 = ::CreateCompatibleDC(hDC);
m_ahbmCached[0] = CachedBufferDIB(m_ahbmCached[0], rcClient.right, rcClient.bottom);
HGDIOBJ hbm0Old = ::SelectObject(hdcMem0, m_ahbmCached[0]);
// Fill the background on hdcMem0
::FillRect(hdcMem0, &rcCanvasDraw, (HBRUSH)(COLOR_APPWORKSPACE + 1));
::FillRect(hdcMem0, &rcPaint, (HBRUSH)(COLOR_APPWORKSPACE + 1));
// Draw the sizeboxes if necessary
RECT rcBase = GetBaseRect();
if (!selectionModel.m_bShow && !::IsWindowVisible(textEditWindow))
drawSizeBoxes(hdcMem0, &rcBase, FALSE, &rcCanvasDraw);
drawSizeBoxes(hdcMem0, &rcBase, FALSE, &rcPaint);
// Calculate image size
CRect rcImage;
GetImageRect(rcImage);
SIZE sizeImage = { imageModel.GetWidth(), imageModel.GetHeight() };
// Calculate the target area on the image
CRect rcImageDraw = rcCanvasDraw;
CanvasToImage(rcImageDraw);
rcImageDraw.IntersectRect(&rcImageDraw, &rcImage);
// Consider rounding down by zooming
rcImageDraw.right += 1;
rcImageDraw.bottom += 1;
// hdcMem1 <-- imageModel
HDC hdcMem1 = ::CreateCompatibleDC(hDC);
m_ahbmCached[1] = CachedBufferDIB(m_ahbmCached[1], sizeImage.cx, sizeImage.cy);
HGDIOBJ hbm1Old = ::SelectObject(hdcMem1, m_ahbmCached[1]);
::BitBlt(hdcMem1, rcImageDraw.left, rcImageDraw.top, rcImageDraw.Width(), rcImageDraw.Height(),
imageModel.GetDC(), rcImageDraw.left, rcImageDraw.top, SRCCOPY);
BitBlt(hdcMem1, 0, 0, sizeImage.cx, sizeImage.cy, imageModel.GetDC(), 0, 0, SRCCOPY);
// Draw overlay #1 on hdcMem1
toolsModel.OnDrawOverlayOnImage(hdcMem1);
@@ -215,15 +170,17 @@ VOID CCanvasWindow::DoDraw(HDC hDC, RECT& rcClient, RECT& rcPaint)
DrawXorRect(hdcMem0, &m_rcResizing);
// Transfer the bits (hDC <-- hdcMem0)
::BitBlt(hDC, rcCanvasDraw.left, rcCanvasDraw.top, rcCanvasDraw.Width(), rcCanvasDraw.Height(),
hdcMem0, rcCanvasDraw.left, rcCanvasDraw.top, SRCCOPY);
::BitBlt(hDC,
rcPaint.left, rcPaint.top,
rcPaint.right - rcPaint.left, rcPaint.bottom - rcPaint.top,
hdcMem0, rcPaint.left, rcPaint.top, SRCCOPY);
// Clean up hdcMem0
::SelectObject(hdcMem0, hbm0Old);
::DeleteDC(hdcMem0);
}
VOID CCanvasWindow::updateScrollRange()
VOID CCanvasWindow::Update(HWND hwndFrom)
{
CRect rcClient;
GetClientRect(&rcClient);
@@ -254,16 +211,10 @@ VOID CCanvasWindow::updateScrollRange()
SetScrollInfo(SB_VERT, &si);
}
VOID CCanvasWindow::updateScrollPos(INT x, INT y)
{
SetScrollPos(SB_HORZ, x);
SetScrollPos(SB_VERT, y);
}
LRESULT CCanvasWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if (m_hWnd)
updateScrollRange();
Update(m_hWnd);
return 0;
}
@@ -278,7 +229,7 @@ VOID CCanvasWindow::OnHVScroll(WPARAM wParam, INT fnBar)
{
case SB_THUMBTRACK:
case SB_THUMBPOSITION:
si.nPos = (SHORT)HIWORD(wParam);
si.nPos = HIWORD(wParam);
break;
case SB_LINELEFT:
si.nPos -= 5;
@@ -293,9 +244,9 @@ VOID CCanvasWindow::OnHVScroll(WPARAM wParam, INT fnBar)
si.nPos += si.nPage;
break;
}
si.nPos = max(min(si.nPos, si.nMax), si.nMin);
SetScrollInfo(fnBar, &si);
Invalidate();
Update(m_hWnd);
Invalidate(FALSE); // FIXME: Flicker
}
LRESULT CCanvasWindow::OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
@@ -310,21 +261,10 @@ LRESULT CCanvasWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
return 0;
}
LRESULT CCanvasWindow::OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
LRESULT CCanvasWindow::OnLRButtonDown(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
m_nMouseDownMsg = nMsg;
BOOL bLeftButton = (nMsg == WM_LBUTTONDOWN);
if (nMsg == WM_MBUTTONDOWN)
{
m_ptOrig = pt;
SetCapture();
::SetCursor(::LoadCursorW(g_hinstExe, MAKEINTRESOURCEW(IDC_HANDDRAG)));
return 0;
}
HITTEST hitSelection = SelectionHitTest(pt);
if (hitSelection != HIT_NONE)
{
@@ -344,7 +284,7 @@ LRESULT CCanvasWindow::OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
}
else
{
ClientToScreen(&pt);
canvasWindow.ClientToScreen(&pt);
mainWindow.TrackPopupMenu(pt, 0);
}
return 0;
@@ -357,14 +297,14 @@ LRESULT CCanvasWindow::OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
{
case TOOL_BEZIER:
case TOOL_SHAPE:
toolsModel.OnEndDraw(TRUE);
Invalidate();
toolsModel.OnCancelDraw();
canvasWindow.Invalidate();
break;
case TOOL_FREESEL:
case TOOL_RECTSEL:
toolsModel.OnEndDraw(FALSE);
Invalidate();
toolsModel.OnFinishDraw();
canvasWindow.Invalidate();
break;
default:
@@ -397,40 +337,45 @@ LRESULT CCanvasWindow::OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
return 0;
}
LRESULT CCanvasWindow::OnButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
LRESULT CCanvasWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
return OnLRButtonDown(TRUE, nMsg, wParam, lParam, bHandled);
}
LRESULT CCanvasWindow::OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
return OnLRButtonDown(FALSE, nMsg, wParam, lParam, bHandled);
}
LRESULT CCanvasWindow::OnLRButtonDblClk(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
CanvasToImage(pt);
m_drawing = FALSE;
::ReleaseCapture();
m_nMouseDownMsg = 0;
ReleaseCapture();
toolsModel.OnButtonDown(nMsg == WM_LBUTTONDBLCLK, pt.x, pt.y, TRUE);
toolsModel.OnButtonDown(bLeftButton, pt.x, pt.y, TRUE);
toolsModel.resetTool();
Invalidate(FALSE);
return 0;
}
LRESULT CCanvasWindow::OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
return OnLRButtonDblClk(TRUE, nMsg, wParam, lParam, bHandled);
}
LRESULT CCanvasWindow::OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
return OnLRButtonDblClk(FALSE, nMsg, wParam, lParam, bHandled);
}
LRESULT CCanvasWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
if (m_nMouseDownMsg == WM_MBUTTONDOWN)
{
INT x = GetScrollPos(SB_HORZ) - (pt.x - m_ptOrig.x);
INT y = GetScrollPos(SB_VERT) - (pt.y - m_ptOrig.y);
SendMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, x), 0);
SendMessage(WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, y), 0);
m_ptOrig = pt;
return 0;
}
CanvasToImage(pt);
if (toolsModel.GetActiveTool() == TOOL_ZOOM)
Invalidate();
if (m_hitSelection != HIT_NONE)
{
SelectionDragging(pt);
@@ -439,6 +384,14 @@ LRESULT CCanvasWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
if (!m_drawing || toolsModel.GetActiveTool() <= TOOL_AIRBRUSH)
{
if (toolsModel.GetActiveTool() == TOOL_ZOOM)
{
Invalidate(FALSE);
UpdateWindow();
CanvasToImage(pt);
drawZoomFrame(pt.x, pt.y);
}
TRACKMOUSEEVENT tme = { sizeof(tme) };
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = m_hWnd;
@@ -447,19 +400,86 @@ LRESULT CCanvasWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
if (!m_drawing)
{
RECT rcImage;
GetImageRect(rcImage);
CStringW strCoord;
if (::PtInRect(&rcImage, pt))
strCoord.Format(L"%ld, %ld", pt.x, pt.y);
::SendMessageW(g_hStatusBar, SB_SETTEXT, 1, (LPARAM)(LPCWSTR)strCoord);
CString strCoord;
strCoord.Format(_T("%ld, %ld"), pt.x, pt.y);
::SendMessage(g_hStatusBar, SB_SETTEXT, 1, (LPARAM) (LPCTSTR) strCoord);
}
}
if (m_drawing)
{
toolsModel.DrawWithMouseTool(pt, wParam);
// values displayed in statusbar
LONG xRel = pt.x - g_ptStart.x;
LONG yRel = pt.y - g_ptStart.y;
switch (toolsModel.GetActiveTool())
{
// freesel, rectsel and text tools always show numbers limited to fit into image area
case TOOL_FREESEL:
case TOOL_RECTSEL:
case TOOL_TEXT:
if (xRel < 0)
xRel = (pt.x < 0) ? -g_ptStart.x : xRel;
else if (pt.x > imageModel.GetWidth())
xRel = imageModel.GetWidth() - g_ptStart.x;
if (yRel < 0)
yRel = (pt.y < 0) ? -g_ptStart.y : yRel;
else if (pt.y > imageModel.GetHeight())
yRel = imageModel.GetHeight() - g_ptStart.y;
break;
// while drawing, update cursor coordinates only for tools 3, 7, 8, 9, 14
case TOOL_RUBBER:
case TOOL_PEN:
case TOOL_BRUSH:
case TOOL_AIRBRUSH:
case TOOL_SHAPE:
{
CString strCoord;
strCoord.Format(_T("%ld, %ld"), pt.x, pt.y);
::SendMessage(g_hStatusBar, SB_SETTEXT, 1, (LPARAM) (LPCTSTR) strCoord);
break;
}
default:
break;
}
// rectsel and shape tools always show non-negative numbers when drawing
if (toolsModel.GetActiveTool() == TOOL_RECTSEL || toolsModel.GetActiveTool() == TOOL_SHAPE)
{
if (xRel < 0)
xRel = -xRel;
if (yRel < 0)
yRel = -yRel;
}
if (wParam & MK_LBUTTON)
{
toolsModel.OnMouseMove(TRUE, pt.x, pt.y);
Invalidate(FALSE);
if ((toolsModel.GetActiveTool() >= TOOL_TEXT) || toolsModel.IsSelection())
{
CString strSize;
if ((toolsModel.GetActiveTool() >= TOOL_LINE) && (GetAsyncKeyState(VK_SHIFT) < 0))
yRel = xRel;
strSize.Format(_T("%ld x %ld"), xRel, yRel);
::SendMessage(g_hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize);
}
}
if (wParam & MK_RBUTTON)
{
toolsModel.OnMouseMove(FALSE, pt.x, pt.y);
Invalidate(FALSE);
if (toolsModel.GetActiveTool() >= TOOL_TEXT)
{
CString strSize;
if ((toolsModel.GetActiveTool() >= TOOL_LINE) && (GetAsyncKeyState(VK_SHIFT) < 0))
yRel = xRel;
strSize.Format(_T("%ld x %ld"), xRel, yRel);
::SendMessage(g_hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize);
}
}
return 0;
}
@@ -511,9 +531,9 @@ LRESULT CCanvasWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
cyImage = min(MAXWORD, cyImage);
// Display new size
CStringW strSize;
strSize.Format(L"%d x %d", cxImage, cyImage);
::SendMessageW(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)(LPCWSTR)strSize);
CString strSize;
strSize.Format(_T("%d x %d"), cxImage, cyImage);
::SendMessage(g_hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize);
// Dragging now... Fix the position...
CRect rcResizing = { 0, 0, cxImage, cyImage };
@@ -544,22 +564,19 @@ LRESULT CCanvasWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
return 0;
}
LRESULT CCanvasWindow::OnButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
LRESULT CCanvasWindow::OnLRButtonUp(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
CanvasToImage(pt);
::ReleaseCapture();
BOOL bLeftButton = (m_nMouseDownMsg == WM_LBUTTONDOWN);
m_nMouseDownMsg = 0;
if (m_drawing)
{
m_drawing = FALSE;
toolsModel.OnButtonUp(bLeftButton, pt.x, pt.y);
Invalidate(FALSE);
::SendMessageW(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)L"");
::SendMessage(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)_T(""));
return 0;
}
else if (m_hitSelection != HIT_NONE && bLeftButton)
@@ -610,11 +627,21 @@ LRESULT CCanvasWindow::OnButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
m_hitCanvasSizeBox = HIT_NONE;
toolsModel.resetTool(); // resets the point-buffer of the polygon and bezier functions
updateScrollRange();
Update(NULL);
Invalidate(TRUE);
return 0;
}
LRESULT CCanvasWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
return OnLRButtonUp(TRUE, nMsg, wParam, lParam, bHandled);
}
LRESULT CCanvasWindow::OnRButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
return OnLRButtonUp(FALSE, nMsg, wParam, lParam, bHandled);
}
LRESULT CCanvasWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if (CWaitCursor::IsWaiting())
@@ -623,12 +650,6 @@ LRESULT CCanvasWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
return 0;
}
if (m_nMouseDownMsg == WM_MBUTTONDOWN)
{
::SetCursor(::LoadCursorW(g_hinstExe, MAKEINTRESOURCEW(IDC_HANDDRAG)));
return 0;
}
POINT pt;
::GetCursorPos(&pt);
ScreenToClient(&pt);
@@ -646,7 +667,7 @@ LRESULT CCanvasWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
if (hitSelection != HIT_NONE)
{
if (!setCursorOnSizeBox(hitSelection))
::SetCursor(::LoadCursorW(NULL, (LPCWSTR)IDC_SIZEALL));
::SetCursor(::LoadCursor(NULL, IDC_SIZEALL));
return 0;
}
@@ -659,22 +680,22 @@ LRESULT CCanvasWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
switch (toolsModel.GetActiveTool())
{
case TOOL_FILL:
::SetCursor(::LoadCursorW(g_hinstExe, MAKEINTRESOURCEW(IDC_FILL)));
::SetCursor(::LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDC_FILL)));
break;
case TOOL_COLOR:
::SetCursor(::LoadCursorW(g_hinstExe, MAKEINTRESOURCEW(IDC_COLOR)));
::SetCursor(::LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDC_COLOR)));
break;
case TOOL_ZOOM:
::SetCursor(::LoadCursorW(g_hinstExe, MAKEINTRESOURCEW(IDC_ZOOM)));
::SetCursor(::LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDC_ZOOM)));
break;
case TOOL_PEN:
::SetCursor(::LoadCursorW(g_hinstExe, MAKEINTRESOURCEW(IDC_PEN)));
::SetCursor(::LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDC_PEN)));
break;
case TOOL_AIRBRUSH:
::SetCursor(::LoadCursorW(g_hinstExe, MAKEINTRESOURCEW(IDC_AIRBRUSH)));
::SetCursor(::LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDC_AIRBRUSH)));
break;
default:
::SetCursor(::LoadCursorW(NULL, (LPCWSTR)IDC_CROSS));
::SetCursor(::LoadCursor(NULL, IDC_CROSS));
}
return 0;
}
@@ -691,7 +712,6 @@ LRESULT CCanvasWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
{
// Cancel dragging
::ReleaseCapture();
m_nMouseDownMsg = 0;
m_hitCanvasSizeBox = HIT_NONE;
::SetRectEmpty(&m_rcResizing);
Invalidate(TRUE);
@@ -711,12 +731,12 @@ LRESULT CCanvasWindow::OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
LRESULT CCanvasWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
return ::SendMessageW(GetParent(), nMsg, wParam, lParam);
return ::SendMessage(GetParent(), nMsg, wParam, lParam);
}
LRESULT CCanvasWindow::OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
::SendMessageW(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)L"");
::SendMessage(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)_T(""));
return 0;
}
@@ -743,13 +763,13 @@ VOID CCanvasWindow::cancelDrawing()
selectionModel.ClearMaskImage();
m_hitSelection = HIT_NONE;
m_drawing = FALSE;
toolsModel.OnEndDraw(TRUE);
toolsModel.OnCancelDraw();
Invalidate(FALSE);
}
VOID CCanvasWindow::finishDrawing()
{
toolsModel.OnEndDraw(FALSE);
toolsModel.OnFinishDraw();
m_drawing = FALSE;
Invalidate(FALSE);
}

View File

@@ -10,7 +10,7 @@
class CCanvasWindow : public CWindowImpl<CCanvasWindow>
{
public:
DECLARE_WND_CLASS_EX(L"ReactOSPaintCanvas", CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW,
DECLARE_WND_CLASS_EX(_T("ReactOSPaintCanvas"), CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW,
COLOR_APPWORKSPACE)
BEGIN_MSG_MAP(CCanvasWindow)
@@ -20,15 +20,13 @@ public:
MESSAGE_HANDLER(WM_HSCROLL, OnHScroll)
MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnButtonDown)
MESSAGE_HANDLER(WM_RBUTTONDOWN, OnButtonDown)
MESSAGE_HANDLER(WM_MBUTTONDOWN, OnButtonDown)
MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnButtonDblClk)
MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnButtonDblClk)
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown)
MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk)
MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnRButtonDblClk)
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
MESSAGE_HANDLER(WM_LBUTTONUP, OnButtonUp)
MESSAGE_HANDLER(WM_RBUTTONUP, OnButtonUp)
MESSAGE_HANDLER(WM_MBUTTONUP, OnButtonUp)
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
MESSAGE_HANDLER(WM_RBUTTONUP, OnRButtonUp)
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel)
MESSAGE_HANDLER(WM_CANCELMODE, OnCancelMode)
@@ -44,8 +42,7 @@ public:
VOID cancelDrawing();
VOID finishDrawing();
VOID updateScrollRange();
VOID updateScrollPos(INT x = 0, INT y = 0);
VOID Update(HWND hwndFrom);
VOID ImageToCanvas(POINT& pt);
VOID ImageToCanvas(RECT& rc);
@@ -53,8 +50,6 @@ public:
VOID CanvasToImage(RECT& rc, BOOL bZoomed = FALSE);
VOID GetImageRect(RECT& rc);
VOID MoveSelection(INT xDelta, INT yDelta);
VOID getNewZoomRect(CRect& rcView, INT newZoom, CPoint ptTarget);
VOID zoomTo(INT newZoom, LONG left = 0, LONG top = 0);
protected:
HITTEST m_hitSelection;
@@ -67,6 +62,7 @@ protected:
RECT GetBaseRect();
VOID DoDraw(HDC hDC, RECT& rcClient, RECT& rcPaint);
VOID OnHVScroll(WPARAM wParam, INT fnBar);
VOID drawZoomFrame(INT mouseX, INT mouseY);
HITTEST SelectionHitTest(POINT ptImage);
VOID StartSelectionDrag(HITTEST hit, POINT ptImage);
@@ -78,8 +74,14 @@ protected:
LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnEraseBkgnd(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnRButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
@@ -87,8 +89,7 @@ protected:
LRESULT OnCtlColorEdit(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
UINT m_nMouseDownMsg = 0;
LRESULT OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLRButtonDown(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLRButtonDblClk(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLRButtonUp(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
};

View File

@@ -43,7 +43,7 @@ enum HITTEST // hit
/* FUNCTIONS ********************************************************/
void ShowOutOfMemory(void);
BOOL zoomTo(int newZoom, int mouseX, int mouseY);
BOOL nearlyEqualPoints(INT x0, INT y0, INT x1, INT y1);
BOOL OpenMailer(HWND hWnd, LPCWSTR pszPathName);

View File

@@ -113,21 +113,22 @@ LRESULT CAttributesDialog::OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam,
if (g_isAFile)
{
WCHAR date[100], temp[100];
GetDateFormatW(LOCALE_USER_DEFAULT, 0, &g_fileTime, NULL, date, _countof(date));
GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &g_fileTime, NULL, temp, _countof(temp));
StringCchCatW(date, _countof(date), L" ");
StringCchCatW(date, _countof(date), temp);
CStringW strSize;
TCHAR date[100];
TCHAR temp[100];
GetDateFormat(LOCALE_USER_DEFAULT, 0, &g_fileTime, NULL, date, _countof(date));
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &g_fileTime, NULL, temp, _countof(temp));
_tcscat(date, _T(" "));
_tcscat(date, temp);
CString strSize;
strSize.Format(IDS_FILESIZE, g_fileSize);
SetDlgItemText(IDD_ATTRIBUTESTEXT6, date);
SetDlgItemText(IDD_ATTRIBUTESTEXT7, strSize);
}
CStringW strUnit;
CString strUnit;
GetDlgItemText(IDD_ATTRIBUTESTEXT8, strUnit);
CStringW strRes;
CString strRes;
if (strUnit == L"dpi")
strRes.Format(IDS_PRINTRES, ROUND(g_xDpi), ROUND(g_yDpi));
else
@@ -172,10 +173,10 @@ LRESULT CAttributesDialog::OnRadioButton1(WORD wNotifyCode, WORD wID, HWND hWndC
if (IsDlgButtonChecked(IDD_ATTRIBUTESRB1) != BST_CHECKED)
return 0;
CStringW strNum;
strNum.Format(L"%.3lf", newWidth / g_xDpi);
CString strNum;
strNum.Format(_T("%.3lf"), newWidth / g_xDpi);
SetDlgItemText(IDD_ATTRIBUTESEDIT1, strNum);
strNum.Format(L"%.3lf", newHeight / g_yDpi);
strNum.Format(_T("%.3lf"), newHeight / g_yDpi);
SetDlgItemText(IDD_ATTRIBUTESEDIT2, strNum);
return 0;
}
@@ -185,10 +186,10 @@ LRESULT CAttributesDialog::OnRadioButton2(WORD wNotifyCode, WORD wID, HWND hWndC
if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2) != BST_CHECKED)
return 0;
CStringW strNum;
strNum.Format(L"%.3lf", newWidth / PpcmFromDpi(g_xDpi));
CString strNum;
strNum.Format(_T("%.3lf"), newWidth / PpcmFromDpi(g_xDpi));
SetDlgItemText(IDD_ATTRIBUTESEDIT1, strNum);
strNum.Format(L"%.3lf", newHeight / PpcmFromDpi(g_yDpi));
strNum.Format(_T("%.3lf"), newHeight / PpcmFromDpi(g_yDpi));
SetDlgItemText(IDD_ATTRIBUTESEDIT2, strNum);
return 0;
}
@@ -207,21 +208,21 @@ LRESULT CAttributesDialog::OnEdit1(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOO
{
if (Edit_GetModify(hWndCtl))
{
WCHAR tempS[100];
TCHAR tempS[100];
if (IsDlgButtonChecked(IDD_ATTRIBUTESRB1))
{
GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, _countof(tempS));
newWidth = max(1, (int)(wcstod(tempS, NULL) * g_xDpi));
newWidth = max(1, (int) (_tcstod(tempS, NULL) * g_xDpi));
}
else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2))
{
GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, _countof(tempS));
newWidth = max(1, (int)(wcstod(tempS, NULL) * PpcmFromDpi(g_xDpi)));
newWidth = max(1, (int) (_tcstod(tempS, NULL) * PpcmFromDpi(g_xDpi)));
}
else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB3))
{
GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, _countof(tempS));
newWidth = max(1, _wtoi(tempS));
newWidth = max(1, _tstoi(tempS));
}
Edit_SetModify(hWndCtl, FALSE);
}
@@ -232,21 +233,21 @@ LRESULT CAttributesDialog::OnEdit2(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOO
{
if (Edit_GetModify(hWndCtl))
{
WCHAR tempS[100];
TCHAR tempS[100];
if (IsDlgButtonChecked(IDD_ATTRIBUTESRB1))
{
GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, _countof(tempS));
newHeight = max(1, (int)(wcstod(tempS, NULL) * g_yDpi));
newHeight = max(1, (int) (_tcstod(tempS, NULL) * g_yDpi));
}
else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2))
{
GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, _countof(tempS));
newHeight = max(1, (int)(wcstod(tempS, NULL) * PpcmFromDpi(g_yDpi)));
newHeight = max(1, (int) (_tcstod(tempS, NULL) * PpcmFromDpi(g_yDpi)));
}
else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB3))
{
GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, _countof(tempS));
newHeight = max(1, _wtoi(tempS));
newHeight = max(1, _tstoi(tempS));
}
Edit_SetModify(hWndCtl, FALSE);
}
@@ -272,7 +273,9 @@ LRESULT CStretchSkewDialog::OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
LRESULT CStretchSkewDialog::OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
CStringW strrcIntNumbers, strrcPercentage, strrcAngle;
CString strrcIntNumbers;
CString strrcPercentage;
CString strrcAngle;
BOOL tr1, tr2, tr3, tr4;
strrcIntNumbers.LoadString(g_hinstExe, IDS_INTNUMBERS);
@@ -302,11 +305,11 @@ LRESULT CStretchSkewDialog::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, B
}
static INT CALLBACK
EnumFontFamProc(ENUMLOGFONTW *lpelf, NEWTEXTMETRICW *lpntm, INT FontType, LPARAM lParam)
EnumFontFamProc(ENUMLOGFONT *lpelf, NEWTEXTMETRIC *lpntm, INT FontType, LPARAM lParam)
{
CSimpleArray<CStringW>& arrFontNames = *reinterpret_cast<CSimpleArray<CStringW>*>(lParam);
LPWSTR name = lpelf->elfLogFont.lfFaceName;
if (name[0] == L'@') // Vertical fonts
CSimpleArray<CString>& arrFontNames = *reinterpret_cast<CSimpleArray<CString>*>(lParam);
LPTSTR name = lpelf->elfLogFont.lfFaceName;
if (name[0] == TEXT('@')) // Vertical fonts
return TRUE;
for (INT i = 0; i < arrFontNames.GetSize(); ++i)
@@ -328,24 +331,24 @@ CFontsDialog::CFontsDialog()
void CFontsDialog::InitFontNames()
{
// List the fonts
CSimpleArray<CStringW> arrFontNames;
CSimpleArray<CString> arrFontNames;
HDC hDC = CreateCompatibleDC(NULL);
if (hDC)
{
EnumFontFamiliesW(hDC, NULL, (FONTENUMPROCW)EnumFontFamProc,
reinterpret_cast<LPARAM>(&arrFontNames));
::DeleteDC(hDC);
EnumFontFamilies(hDC, NULL, (FONTENUMPROC)EnumFontFamProc,
reinterpret_cast<LPARAM>(&arrFontNames));
DeleteDC(hDC);
}
// Actually add them to the combobox
HWND hwndNames = GetDlgItem(IDD_FONTSNAMES);
::SendMessageW(hwndNames, CB_RESETCONTENT, 0, 0);
SendMessage(hwndNames, CB_RESETCONTENT, 0, 0);
for (INT i = 0; i < arrFontNames.GetSize(); ++i)
{
ComboBox_AddString(hwndNames, arrFontNames[i]);
}
::SetWindowTextW(hwndNames, registrySettings.strFontName);
::SetWindowText(hwndNames, registrySettings.strFontName);
}
void CFontsDialog::InitFontSizes()
@@ -358,10 +361,10 @@ void CFontsDialog::InitFontSizes()
HWND hwndSizes = GetDlgItem(IDD_FONTSSIZES);
ComboBox_ResetContent(hwndSizes);
WCHAR szText[16];
TCHAR szText[16];
for (UINT i = 0; i < _countof(s_sizes); ++i)
{
StringCchPrintfW(szText, _countof(szText), L"%d", s_sizes[i]);
wsprintf(szText, TEXT("%d"), s_sizes[i]);
INT iItem = ComboBox_AddString(hwndSizes, szText);
if (s_sizes[i] == (INT)registrySettings.PointSize)
ComboBox_SetCurSel(hwndSizes, iItem);
@@ -369,27 +372,27 @@ void CFontsDialog::InitFontSizes()
if (ComboBox_GetCurSel(hwndSizes) == CB_ERR)
{
StringCchPrintfW(szText, _countof(szText), L"%d", (INT)registrySettings.PointSize);
::SetWindowTextW(hwndSizes, szText);
wsprintf(szText, TEXT("%d"), (INT)registrySettings.PointSize);
::SetWindowText(hwndSizes, szText);
}
}
void CFontsDialog::InitToolbar()
{
HWND hwndToolbar = GetDlgItem(IDD_FONTSTOOLBAR);
::SendMessageW(hwndToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
::SendMessageW(hwndToolbar, TB_SETBITMAPSIZE, 0, MAKELPARAM(16, 16));
::SendMessageW(hwndToolbar, TB_SETBUTTONWIDTH, 0, MAKELPARAM(20, 20));
SendMessage(hwndToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
SendMessage(hwndToolbar, TB_SETBITMAPSIZE, 0, MAKELPARAM(16, 16));
SendMessage(hwndToolbar, TB_SETBUTTONWIDTH, 0, MAKELPARAM(20, 20));
TBADDBITMAP AddBitmap;
AddBitmap.hInst = g_hinstExe;
AddBitmap.nID = IDB_FONTSTOOLBAR;
::SendMessageW(hwndToolbar, TB_ADDBITMAP, 4, (LPARAM)&AddBitmap);
SendMessage(hwndToolbar, TB_ADDBITMAP, 4, (LPARAM)&AddBitmap);
HIMAGELIST himl = ImageList_LoadImage(g_hinstExe, MAKEINTRESOURCEW(IDB_FONTSTOOLBAR),
HIMAGELIST himl = ImageList_LoadImage(g_hinstExe, MAKEINTRESOURCE(IDB_FONTSTOOLBAR),
16, 8, RGB(255, 0, 255), IMAGE_BITMAP,
LR_CREATEDIBSECTION);
::SendMessageW(hwndToolbar, TB_SETIMAGELIST, 0, (LPARAM)himl);
SendMessage(hwndToolbar, TB_SETIMAGELIST, 0, (LPARAM)himl);
TBBUTTON buttons[] =
{
@@ -398,11 +401,11 @@ void CFontsDialog::InitToolbar()
{ 2, IDM_UNDERLINE, TBSTATE_ENABLED, TBSTYLE_CHECK },
{ 3, IDM_VERTICAL, 0, TBSTYLE_CHECK }, // TODO:
};
::SendMessageW(hwndToolbar, TB_ADDBUTTONS, _countof(buttons), (LPARAM)&buttons);
SendMessage(hwndToolbar, TB_ADDBUTTONS, _countof(buttons), (LPARAM)&buttons);
::SendMessageW(hwndToolbar, TB_CHECKBUTTON, IDM_BOLD, registrySettings.Bold);
::SendMessageW(hwndToolbar, TB_CHECKBUTTON, IDM_ITALIC, registrySettings.Italic);
::SendMessageW(hwndToolbar, TB_CHECKBUTTON, IDM_UNDERLINE, registrySettings.Underline);
SendMessage(hwndToolbar, TB_CHECKBUTTON, IDM_BOLD, registrySettings.Bold);
SendMessage(hwndToolbar, TB_CHECKBUTTON, IDM_ITALIC, registrySettings.Italic);
SendMessage(hwndToolbar, TB_CHECKBUTTON, IDM_UNDERLINE, registrySettings.Underline);
}
LRESULT CFontsDialog::OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
@@ -438,7 +441,7 @@ void CFontsDialog::OnFontName(UINT codeNotify)
HWND hwndNames = GetDlgItem(IDD_FONTSNAMES);
INT iItem = CB_ERR;
UINT cch;
WCHAR szText[LF_FACESIZE];
TCHAR szText[LF_FACESIZE];
switch (codeNotify)
{
@@ -446,7 +449,9 @@ void CFontsDialog::OnFontName(UINT codeNotify)
iItem = ComboBox_GetCurSel(hwndNames);
cch = ComboBox_GetLBTextLen(hwndNames, iItem);
if (iItem != CB_ERR && 0 < cch && cch < _countof(szText))
{
ComboBox_GetLBText(hwndNames, iItem, szText);
}
break;
case CBN_EDITCHANGE:
@@ -477,13 +482,13 @@ void CFontsDialog::OnFontSize(UINT codeNotify)
if (iItem != CB_ERR && 0 < cch && cch < _countof(szText))
{
ComboBox_GetLBText(hwndSizes, iItem, szText);
PointSize = _wtoi(szText);
PointSize = _ttoi(szText);
}
break;
case CBN_EDITCHANGE:
::GetWindowTextW(hwndSizes, szText, _countof(szText));
PointSize = _wtoi(szText);
::GetWindowText(hwndSizes, szText, _countof(szText));
PointSize = _ttoi(szText);
break;
}
@@ -499,7 +504,7 @@ LRESULT CFontsDialog::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& b
UINT id = LOWORD(wParam);
UINT codeNotify = HIWORD(wParam);
HWND hwndToolbar = GetDlgItem(IDD_FONTSTOOLBAR);
BOOL bChecked = (BOOL)::SendMessageW(hwndToolbar, TB_ISBUTTONCHECKED, id, 0);
BOOL bChecked = ::SendMessage(hwndToolbar, TB_ISBUTTONCHECKED, id, 0);
switch (id)
{
@@ -543,14 +548,14 @@ LRESULT CFontsDialog::OnNotify(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
NMHDR *pnmhdr = reinterpret_cast<NMHDR *>(lParam);
if (pnmhdr->code == TTN_NEEDTEXT)
{
LPTOOLTIPTEXTW pToolTip = reinterpret_cast<LPTOOLTIPTEXTW>(lParam);
LPTOOLTIPTEXT pToolTip = reinterpret_cast<LPTOOLTIPTEXT>(lParam);
pToolTip->hinst = g_hinstExe;
switch (pnmhdr->idFrom)
{
case IDM_BOLD: pToolTip->lpszText = MAKEINTRESOURCEW(IDS_BOLD); break;
case IDM_ITALIC: pToolTip->lpszText = MAKEINTRESOURCEW(IDS_ITALIC); break;
case IDM_UNDERLINE: pToolTip->lpszText = MAKEINTRESOURCEW(IDS_UNDERLINE); break;
case IDM_VERTICAL: pToolTip->lpszText = MAKEINTRESOURCEW(IDS_VERTICAL); break;
case IDM_BOLD: pToolTip->lpszText = MAKEINTRESOURCE(IDS_BOLD); break;
case IDM_ITALIC: pToolTip->lpszText = MAKEINTRESOURCE(IDS_ITALIC); break;
case IDM_UNDERLINE: pToolTip->lpszText = MAKEINTRESOURCE(IDS_UNDERLINE); break;
case IDM_VERTICAL: pToolTip->lpszText = MAKEINTRESOURCE(IDS_VERTICAL); break;
default:
break;
@@ -599,29 +604,29 @@ LRESULT CFontsDialog::OnDrawItem(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
if (pDrawItem->itemID == (UINT)-1)
return TRUE;
::SetBkMode(pDrawItem->hDC, TRANSPARENT);
SetBkMode(pDrawItem->hDC, TRANSPARENT);
HWND hwndItem = pDrawItem->hwndItem;
RECT rcItem = pDrawItem->rcItem;
if (pDrawItem->itemState & ODS_SELECTED)
{
::FillRect(pDrawItem->hDC, &rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
::SetTextColor(pDrawItem->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
FillRect(pDrawItem->hDC, &rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
SetTextColor(pDrawItem->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
}
else
{
::FillRect(pDrawItem->hDC, &rcItem, GetSysColorBrush(COLOR_WINDOW));
::SetTextColor(pDrawItem->hDC, GetSysColor(COLOR_WINDOWTEXT));
FillRect(pDrawItem->hDC, &rcItem, GetSysColorBrush(COLOR_WINDOW));
SetTextColor(pDrawItem->hDC, GetSysColor(COLOR_WINDOWTEXT));
}
WCHAR szText[LF_FACESIZE];
TCHAR szText[LF_FACESIZE];
if ((UINT)ComboBox_GetLBTextLen(hwndItem, pDrawItem->itemID) < _countof(szText))
{
szText[0] = 0;
ComboBox_GetLBText(hwndItem, pDrawItem->itemID, szText);
rcItem.left += 24;
::DrawTextW(pDrawItem->hDC, szText, -1, &rcItem, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
DrawText(pDrawItem->hDC, szText, -1, &rcItem, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
}
if (pDrawItem->itemState & ODS_FOCUS)

View File

@@ -87,7 +87,7 @@ CreateColorDIB(int width, int height, COLORREF rgb)
HBITMAP CopyMonoImage(HBITMAP hbm, INT cx, INT cy)
{
BITMAP bm;
if (!::GetObjectW(hbm, sizeof(bm), &bm))
if (!GetObject(hbm, sizeof(bm), &bm))
return NULL;
if (cx == 0 || cy == 0)
@@ -96,19 +96,19 @@ HBITMAP CopyMonoImage(HBITMAP hbm, INT cx, INT cy)
cy = bm.bmHeight;
}
HBITMAP hbmNew = ::CreateBitmap(cx, cy, 1, 1, NULL);
HBITMAP hbmNew = CreateBitmap(cx, cy, 1, 1, NULL);
if (!hbmNew)
return NULL;
HDC hdc1 = ::CreateCompatibleDC(NULL);
HDC hdc2 = ::CreateCompatibleDC(NULL);
HGDIOBJ hbm1Old = ::SelectObject(hdc1, hbm);
HGDIOBJ hbm2Old = ::SelectObject(hdc2, hbmNew);
::StretchBlt(hdc2, 0, 0, cx, cy, hdc1, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
::SelectObject(hdc1, hbm1Old);
::SelectObject(hdc2, hbm2Old);
::DeleteDC(hdc1);
::DeleteDC(hdc2);
HDC hdc1 = CreateCompatibleDC(NULL);
HDC hdc2 = CreateCompatibleDC(NULL);
HGDIOBJ hbm1Old = SelectObject(hdc1, hbm);
HGDIOBJ hbm2Old = SelectObject(hdc2, hbmNew);
StretchBlt(hdc2, 0, 0, cx, cy, hdc1, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
SelectObject(hdc1, hbm1Old);
SelectObject(hdc2, hbm2Old);
DeleteDC(hdc1);
DeleteDC(hdc2);
return hbmNew;
}
@@ -120,7 +120,7 @@ HBITMAP CachedBufferDIB(HBITMAP hbm, int minimalWidth, int minimalHeight)
minimalHeight = 1;
BITMAP bm;
if (!GetObjectW(hbm, sizeof(bm), &bm))
if (!GetObject(hbm, sizeof(bm), &bm))
hbm = NULL;
if (hbm && minimalWidth <= bm.bmWidth && minimalHeight <= bm.bmHeight)
@@ -136,7 +136,7 @@ int
GetDIBWidth(HBITMAP hBitmap)
{
BITMAP bm;
::GetObjectW(hBitmap, sizeof(BITMAP), &bm);
GetObject(hBitmap, sizeof(BITMAP), &bm);
return bm.bmWidth;
}
@@ -144,7 +144,7 @@ int
GetDIBHeight(HBITMAP hBitmap)
{
BITMAP bm;
::GetObjectW(hBitmap, sizeof(BITMAP), &bm);
GetObject(hBitmap, sizeof(BITMAP), &bm);
return bm.bmHeight;
}
@@ -211,8 +211,8 @@ void SetFileInfo(LPCWSTR name, LPWIN32_FIND_DATAW pFound, BOOL isAFile)
}
// set title
CStringW strTitle;
strTitle.Format(IDS_WINDOWTITLE, PathFindFileNameW(g_szFileName));
CString strTitle;
strTitle.Format(IDS_WINDOWTITLE, PathFindFileName(g_szFileName));
mainWindow.SetWindowText(strTitle);
// update file info and recent
@@ -228,14 +228,11 @@ HBITMAP InitializeImage(LPCWSTR name, LPWIN32_FIND_DATAW pFound, BOOL isFile)
COLORREF white = RGB(255, 255, 255);
HBITMAP hBitmap = CreateColorDIB(registrySettings.BMPWidth, registrySettings.BMPHeight, white);
if (hBitmap == NULL)
{
ShowOutOfMemory();
return NULL;
}
HDC hScreenDC = ::GetDC(NULL);
g_xDpi = (float)::GetDeviceCaps(hScreenDC, LOGPIXELSX);
g_yDpi = (float)::GetDeviceCaps(hScreenDC, LOGPIXELSY);
g_xDpi = ::GetDeviceCaps(hScreenDC, LOGPIXELSX);
g_yDpi = ::GetDeviceCaps(hScreenDC, LOGPIXELSY);
::ReleaseDC(NULL, hScreenDC);
return SetBitmapAndInfo(hBitmap, name, pFound, isFile);
@@ -244,7 +241,6 @@ HBITMAP InitializeImage(LPCWSTR name, LPWIN32_FIND_DATAW pFound, BOOL isFile)
HBITMAP SetBitmapAndInfo(HBITMAP hBitmap, LPCWSTR name, LPWIN32_FIND_DATAW pFound, BOOL isFile)
{
// update image
canvasWindow.updateScrollPos();
imageModel.PushImageForUndo(hBitmap);
imageModel.ClearHistory();
@@ -258,7 +254,7 @@ HBITMAP DoLoadImageFile(HWND hwnd, LPCWSTR name, BOOL fIsMainFile)
CWaitCursor waitCursor;
// find the file
WIN32_FIND_DATAW find;
WIN32_FIND_DATA find;
HANDLE hFind = ::FindFirstFileW(name, &find);
if (hFind == INVALID_HANDLE_VALUE) // does not exist
{
@@ -278,14 +274,8 @@ HBITMAP DoLoadImageFile(HWND hwnd, LPCWSTR name, BOOL fIsMainFile)
CImageDx img;
float xDpi = 0, yDpi = 0;
HRESULT hr = img.LoadDx(name, &xDpi, &yDpi);
if (FAILED(hr) && fIsMainFile)
{
imageModel.ClearHistory();
hr = img.LoadDx(name, &xDpi, &yDpi);
}
if (FAILED(hr))
{
ATLTRACE("hr: 0x%08lX\n", hr);
ShowError(IDS_LOADERRORTEXT, name);
return NULL;
}
@@ -297,8 +287,8 @@ HBITMAP DoLoadImageFile(HWND hwnd, LPCWSTR name, BOOL fIsMainFile)
if (xDpi <= 0 || yDpi <= 0)
{
HDC hDC = ::GetDC(NULL);
xDpi = (float)::GetDeviceCaps(hDC, LOGPIXELSX);
yDpi = (float)::GetDeviceCaps(hDC, LOGPIXELSY);
xDpi = ::GetDeviceCaps(hDC, LOGPIXELSX);
yDpi = ::GetDeviceCaps(hDC, LOGPIXELSY);
::ReleaseDC(NULL, hDC);
}
@@ -358,7 +348,7 @@ HBITMAP SkewDIB(HDC hDC1, HBITMAP hbm, INT nDegree, BOOL bVertical, BOOL bMono)
const double eTan = tan(abs(nDegree) * M_PI / 180);
BITMAP bm;
::GetObjectW(hbm, sizeof(bm), &bm);
GetObjectW(hbm, sizeof(bm), &bm);
INT cx = bm.bmWidth, cy = bm.bmHeight, dx = 0, dy = 0;
if (bVertical)
dy = INT(cx * eTan);
@@ -384,9 +374,9 @@ HBITMAP SkewDIB(HDC hDC1, HBITMAP hbm, INT nDegree, BOOL bVertical, BOOL bMono)
{
INT delta = INT(x * eTan);
if (nDegree > 0)
::BitBlt(hDC2, x, (dy - delta), 1, cy, hDC1, x, 0, SRCCOPY);
BitBlt(hDC2, x, (dy - delta), 1, cy, hDC1, x, 0, SRCCOPY);
else
::BitBlt(hDC2, x, delta, 1, cy, hDC1, x, 0, SRCCOPY);
BitBlt(hDC2, x, delta, 1, cy, hDC1, x, 0, SRCCOPY);
}
}
else
@@ -395,9 +385,9 @@ HBITMAP SkewDIB(HDC hDC1, HBITMAP hbm, INT nDegree, BOOL bVertical, BOOL bMono)
{
INT delta = INT(y * eTan);
if (nDegree > 0)
::BitBlt(hDC2, (dx - delta), y, cx, 1, hDC1, 0, y, SRCCOPY);
BitBlt(hDC2, (dx - delta), y, cx, 1, hDC1, 0, y, SRCCOPY);
else
::BitBlt(hDC2, delta, y, cx, 1, hDC1, 0, y, SRCCOPY);
BitBlt(hDC2, delta, y, cx, 1, hDC1, 0, y, SRCCOPY);
}
}
@@ -416,7 +406,7 @@ HGLOBAL BitmapToClipboardDIB(HBITMAP hBitmap)
CWaitCursor waitCursor;
BITMAP bm;
if (!GetObjectW(hBitmap, sizeof(BITMAP), &bm))
if (!GetObject(hBitmap, sizeof(BITMAP), &bm))
return NULL;
BITMAPINFODX bmi;
@@ -600,7 +590,7 @@ HBITMAP ConvertToBlackAndWhite(HBITMAP hbm)
CWaitCursor waitCursor;
BITMAP bm;
if (!::GetObjectW(hbm, sizeof(bm), &bm))
if (!::GetObject(hbm, sizeof(bm), &bm))
return NULL;
BITMAPINFOEX bmi;

View File

@@ -253,37 +253,38 @@ RectSel(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2)
}
void
Text(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LPCWSTR lpchText, HFONT font, LONG style)
Text(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LPCTSTR lpchText, HFONT font, LONG style)
{
INT iSaveDC = ::SaveDC(hdc); // We will modify the clipping region. Save now.
INT iSaveDC = SaveDC(hdc); // We will modify the clipping region. Save now.
RECT rc;
::SetRect(&rc, x1, y1, x2, y2);
SetRect(&rc, x1, y1, x2, y2);
if (style == 0) // Transparent
{
::SetBkMode(hdc, TRANSPARENT);
SetBkMode(hdc, TRANSPARENT);
GetBkColor(hdc);
}
else // Opaque
{
::SetBkMode(hdc, OPAQUE);
::SetBkColor(hdc, bg);
SetBkMode(hdc, OPAQUE);
SetBkColor(hdc, bg);
HBRUSH hbr = ::CreateSolidBrush(bg);
::FillRect(hdc, &rc, hbr); // Fill the background
::DeleteObject(hbr);
HBRUSH hbr = CreateSolidBrush(bg);
FillRect(hdc, &rc, hbr); // Fill the background
DeleteObject(hbr);
}
IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
HGDIOBJ hFontOld = ::SelectObject(hdc, font);
::SetTextColor(hdc, fg);
HGDIOBJ hFontOld = SelectObject(hdc, font);
SetTextColor(hdc, fg);
const UINT uFormat = DT_LEFT | DT_TOP | DT_EDITCONTROL | DT_NOPREFIX | DT_NOCLIP |
DT_EXPANDTABS | DT_WORDBREAK;
::DrawTextW(hdc, lpchText, -1, &rc, uFormat);
::SelectObject(hdc, hFontOld);
DrawText(hdc, lpchText, -1, &rc, uFormat);
SelectObject(hdc, hFontOld);
::RestoreDC(hdc, iSaveDC); // Restore
RestoreDC(hdc, iSaveDC); // Restore
}
BOOL

View File

@@ -31,7 +31,7 @@ void Brush(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG sty
void RectSel(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2);
void Text(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LPCWSTR lpchText, HFONT font, LONG style);
void Text(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LPCTSTR lpchText, HFONT font, LONG style);
BOOL
ColorKeyedMaskBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight,

View File

@@ -22,8 +22,8 @@ HWND CFullscreenWindow::DoCreate()
LRESULT CFullscreenWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
SendMessage(WM_SETICON, ICON_BIG, (LPARAM)::LoadIconW(g_hinstExe, MAKEINTRESOURCEW(IDI_APPICON)));
SendMessage(WM_SETICON, ICON_SMALL, (LPARAM)::LoadIconW(g_hinstExe, MAKEINTRESOURCEW(IDI_APPICON)));
SendMessage(WM_SETICON, ICON_BIG, (LPARAM) LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON)));
SendMessage(WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON)));
return 0;
}

View File

@@ -10,7 +10,7 @@
class CFullscreenWindow : public CWindowImpl<CFullscreenWindow>
{
public:
DECLARE_WND_CLASS_EX(L"FullscreenWindow", CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW,
DECLARE_WND_CLASS_EX(_T("FullscreenWindow"), CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW,
COLOR_BACKGROUND)
BEGIN_MSG_MAP(CFullscreenWindow)

View File

@@ -11,9 +11,11 @@
extern BOOL g_askBeforeEnlarging;
extern POINT g_ptStart, g_ptEnd;
extern HINSTANCE g_hinstExe;
extern WCHAR g_szFileName[MAX_LONG_PATH];
extern TCHAR g_szFileName[MAX_LONG_PATH];
extern BOOL g_isAFile;
extern BOOL g_imageSaved;
extern BOOL g_showGrid;

View File

@@ -15,13 +15,9 @@ ImageModel imageModel;
void ImageModel::NotifyImageChanged()
{
if (canvasWindow.IsWindow())
{
canvasWindow.updateScrollRange();
canvasWindow.Invalidate();
}
canvasWindow.Invalidate(FALSE);
if (miniature.IsWindow())
miniature.Invalidate();
miniature.Invalidate(FALSE);
}
ImageModel::ImageModel()
@@ -89,46 +85,31 @@ void ImageModel::Redo()
NotifyImageChanged();
}
void ImageModel::ClearHistory()
void ImageModel::ResetToPrevious()
{
for (int i = 0; i < HISTORYSIZE; ++i)
{
if (m_hBms[i] && i != m_currInd)
{
::DeleteObject(m_hBms[i]);
m_hBms[i] = NULL;
}
}
ATLTRACE("%s: %d\n", __FUNCTION__, m_currInd);
m_undoSteps = 0;
m_redoSteps = 0;
// Revert current item with previous item
::DeleteObject(m_hBms[m_currInd]);
m_hBms[m_currInd] = CopyDIBImage(m_hBms[(m_currInd + HISTORYSIZE - 1) % HISTORYSIZE]);
::SelectObject(m_hDrawingDC, m_hBms[m_currInd]);
NotifyImageChanged();
}
void ImageModel::PushImageForUndo()
void ImageModel::ClearHistory()
{
HBITMAP hbm = CopyBitmap();
if (hbm == NULL)
{
ShowOutOfMemory();
return;
}
PushImageForUndo(hbm);
m_undoSteps = 0;
m_redoSteps = 0;
}
void ImageModel::PushImageForUndo(HBITMAP hbm)
{
ATLTRACE("%s: %d\n", __FUNCTION__, m_currInd);
if (hbm == NULL)
{
ShowOutOfMemory();
return;
}
// Go to the next item with an HBITMAP or current item
::DeleteObject(m_hBms[(m_currInd + 1) % HISTORYSIZE]);
m_hBms[(m_currInd + 1) % HISTORYSIZE] = hbm;
m_hBms[(m_currInd + 1) % HISTORYSIZE] = (hbm ? hbm : CopyDIBImage(m_hBms[m_currInd]));
m_currInd = (m_currInd + 1) % HISTORYSIZE;
::SelectObject(m_hDrawingDC, m_hBms[m_currInd]);
@@ -151,10 +132,7 @@ void ImageModel::Crop(int nWidth, int nHeight, int nOffsetX, int nOffsetY)
// Create an HBITMAP
HBITMAP hbmCropped = CreateDIBWithProperties(nWidth, nHeight);
if (!hbmCropped)
{
ShowOutOfMemory();
return;
}
// Select the HBITMAP by memory DC
HDC hdcMem = ::CreateCompatibleDC(m_hDrawingDC);
@@ -179,7 +157,7 @@ void ImageModel::Crop(int nWidth, int nHeight, int nOffsetX, int nOffsetY)
NotifyImageChanged();
}
void ImageModel::SaveImage(LPCWSTR lpFileName)
void ImageModel::SaveImage(LPCTSTR lpFileName)
{
SaveDIBToFile(m_hBms[m_currInd], lpFileName, TRUE);
}
@@ -260,14 +238,15 @@ void ImageModel::RotateNTimes90Degrees(int iN)
case 3:
{
HBITMAP hbm = Rotate90DegreeBlt(m_hDrawingDC, GetWidth(), GetHeight(), iN == 1, FALSE);
PushImageForUndo(hbm);
if (hbm)
PushImageForUndo(hbm);
break;
}
case 2:
{
PushImageForUndo();
::StretchBlt(m_hDrawingDC, GetWidth() - 1, GetHeight() - 1, -GetWidth(), -GetHeight(),
m_hDrawingDC, 0, 0, GetWidth(), GetHeight(), SRCCOPY);
StretchBlt(m_hDrawingDC, GetWidth() - 1, GetHeight() - 1, -GetWidth(), -GetHeight(),
m_hDrawingDC, 0, 0, GetWidth(), GetHeight(), SRCCOPY);
break;
}
}
@@ -302,7 +281,8 @@ void ImageModel::PushBlackAndWhite()
HBITMAP hNewBitmap = ConvertToBlackAndWhite(hBitmap);
UnlockBitmap(hBitmap);
PushImageForUndo(hNewBitmap);
if (hNewBitmap)
PushImageForUndo(hNewBitmap);
}
HBITMAP ImageModel::LockBitmap()
@@ -326,7 +306,7 @@ void ImageModel::SelectionClone(BOOL bUndoable)
return;
if (bUndoable)
PushImageForUndo();
PushImageForUndo(CopyBitmap());
selectionModel.DrawSelection(m_hDrawingDC, paletteModel.GetBgColor(),
toolsModel.IsBackgroundTransparent());

View File

@@ -19,13 +19,13 @@ public:
HDC GetDC();
BOOL CanUndo() const { return m_undoSteps > 0; }
BOOL CanRedo() const { return m_redoSteps > 0; }
void PushImageForUndo();
void PushImageForUndo(HBITMAP hbm);
void PushImageForUndo(HBITMAP hbm = NULL);
void ResetToPrevious(void);
void Undo(BOOL bClearRedo = FALSE);
void Redo(void);
void ClearHistory(void);
void Crop(int nWidth, int nHeight, int nOffsetX = 0, int nOffsetY = 0);
void SaveImage(LPCWSTR lpFileName);
void SaveImage(LPCTSTR lpFileName);
BOOL IsImageSaved() const;
void StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSkewDegX = 0, int nSkewDegY = 0);
int GetWidth() const;

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 766 B

After

Width:  |  Height:  |  Size: 766 B

View File

Before

Width:  |  Height:  |  Size: 766 B

After

Width:  |  Height:  |  Size: 766 B

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 766 B

After

Width:  |  Height:  |  Size: 766 B

View File

Before

Width:  |  Height:  |  Size: 766 B

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

View File

@@ -8,7 +8,7 @@
LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-bg-BG.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-bg-BG.bmp"
ID_MENU MENU
BEGIN

View File

@@ -8,7 +8,7 @@
LANGUAGE LANG_CZECH, SUBLANG_DEFAULT
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-cs-CZ.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-cs-CZ.bmp"
ID_MENU MENU
BEGIN

View File

@@ -7,7 +7,7 @@
LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-de-DE.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-de-DE.bmp"
ID_MENU MENU
BEGIN

View File

@@ -7,7 +7,7 @@
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-en-GB.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-en-GB.bmp"
ID_MENU MENU
BEGIN

View File

@@ -8,7 +8,7 @@
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar.bmp"
IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar.bmp"
ID_MENU MENU
BEGIN

View File

@@ -10,7 +10,7 @@
LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-es-ES.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-es-ES.bmp"
ID_MENU MENU
BEGIN

View File

@@ -7,7 +7,7 @@
LANGUAGE LANG_ESTONIAN, SUBLANG_DEFAULT
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-et-EE.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-et-EE.bmp"
ID_MENU MENU
BEGIN

View File

@@ -8,7 +8,7 @@
LANGUAGE LANG_BASQUE, SUBLANG_DEFAULT
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-eu-ES.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-eu-ES.bmp"
ID_MENU MENU
BEGIN

View File

@@ -8,7 +8,7 @@
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-fr-FR.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-fr-FR.bmp"
ID_MENU MENU
BEGIN

View File

@@ -7,7 +7,7 @@
LANGUAGE LANG_HEBREW, SUBLANG_DEFAULT
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-he-IL.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-he-IL.bmp"
ID_MENU MENU
BEGIN

View File

@@ -8,7 +8,7 @@
LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-hu-HU.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-hu-HU.bmp"
ID_MENU MENU
BEGIN

View File

@@ -7,7 +7,7 @@
LANGUAGE LANG_INDONESIAN, SUBLANG_DEFAULT
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-id-ID.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-id-ID.bmp"
ID_MENU MENU
BEGIN

View File

@@ -8,7 +8,7 @@
LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-it-IT.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-it-IT.bmp"
ID_MENU MENU
BEGIN

View File

@@ -9,7 +9,7 @@
LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-ja-JP.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-ja-JP.bmp"
ID_MENU MENU
BEGIN

View File

@@ -7,7 +7,7 @@
LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-nl-NL.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-nl-NL.bmp"
ID_MENU MENU
BEGIN

View File

@@ -7,7 +7,7 @@
LANGUAGE LANG_NORWEGIAN, SUBLANG_NEUTRAL
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-no-NO.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-no-NO.bmp"
ID_MENU MENU
BEGIN

View File

@@ -10,7 +10,7 @@
LANGUAGE LANG_POLISH, SUBLANG_DEFAULT
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-pl-PL.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-pl-PL.bmp"
ID_MENU MENU
BEGIN

View File

@@ -8,7 +8,7 @@
LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE_BRAZILIAN
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-pt-BR.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-pt-BR.bmp"
ID_MENU MENU
BEGIN

View File

@@ -8,7 +8,7 @@
LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-pt-PT.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-pt-PT.bmp"
ID_MENU MENU
BEGIN

View File

@@ -9,7 +9,7 @@
LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-ro-RO.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-ro-RO.bmp"
ID_MENU MENU
BEGIN
@@ -17,8 +17,8 @@ BEGIN
BEGIN
MENUITEM "&Nou\tCtrl+N", IDM_FILENEW
MENUITEM "&Deschidere...\tCtrl+O", IDM_FILEOPEN
MENUITEM "&Salvează\tCtrl+S", IDM_FILESAVE
MENUITEM "Salvea&ză ca...", IDM_FILESAVEAS
MENUITEM "&Păstrează\tCtrl+S", IDM_FILESAVE
MENUITEM "Păst&rare în...", IDM_FILESAVEAS
MENUITEM SEPARATOR
MENUITEM "Din aparat media...", IDM_FILEFROMSCANNERORCAMERA
MENUITEM SEPARATOR
@@ -234,7 +234,7 @@ BEGIN
IDS_WINDOWTITLE "%s - Pictare"
IDS_INFOTITLE "Pictare pentru ReactOS"
IDS_INFOTEXT "Disponibilă sub licența GNU Lesser General Public (vedeți www.gnu.org)"
IDS_SAVEPROMPTTEXT "Doriți salvarea modificărilor din %s?"
IDS_SAVEPROMPTTEXT "Doriți păstrarea modificărilor din %s?"
IDS_DEFAULTFILENAME "Fără nume"
IDS_MINIATURETITLE "Miniatură"
IDS_TOOLTIP1 "Golire selecție"
@@ -267,7 +267,7 @@ BEGIN
IDS_VERTICAL "Vertical"
IDS_PRINTRES "%d x %d pixeli/cm"
IDS_CANTPASTE "Nu a putut fi lipit din clipboard. Formatul de date este fie incorect, fie nesuportat."
IDS_SAVEERROR "Eșec în salvarea imaginii bitmap („hartă de biți”) în fișierul:\n\n%s"
IDS_SAVEERROR "Eșec în păstrarea imaginii bitmap („hartă de biți”) în fișierul:\n\n%s"
IDS_CANTSENDMAIL "Eșec în trimiterea unei scrisori."
IDS_LOSECOLOR "În această operațiune informațiile legate de culoare vor fi pierdute. Sigur veți continua?"
END

View File

@@ -11,7 +11,7 @@
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-ru-RU.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-ru-RU.bmp"
ID_MENU MENU
BEGIN

View File

@@ -7,7 +7,7 @@
LANGUAGE LANG_SLOVAK, SUBLANG_DEFAULT
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-sk-SK.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-sk-SK.bmp"
ID_MENU MENU
BEGIN

View File

@@ -7,7 +7,7 @@
LANGUAGE LANG_ALBANIAN, SUBLANG_NEUTRAL
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-sq-AL.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-sq-AL.bmp"
ID_MENU MENU
BEGIN

View File

@@ -8,7 +8,7 @@
LANGUAGE LANG_SWEDISH, SUBLANG_NEUTRAL
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-sv-SE.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-sv-SE.bmp"
ID_MENU MENU
BEGIN

View File

@@ -8,7 +8,7 @@
LANGUAGE LANG_TURKISH, SUBLANG_DEFAULT
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-tr-TR.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-tr-TR.bmp"
ID_MENU MENU
BEGIN

View File

@@ -9,7 +9,7 @@
LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-uk-UA.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-uk-UA.bmp"
ID_MENU MENU
BEGIN

View File

@@ -7,7 +7,7 @@
LANGUAGE LANG_VIETNAMESE, SUBLANG_VIETNAMESE_VIETNAM
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-vi-VN.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-vi-VN.bmp"
ID_MENU MENU
BEGIN

View File

@@ -10,7 +10,7 @@
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-zh-CN.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-zh-CN.bmp"
ID_MENU MENU
BEGIN

View File

@@ -8,7 +8,7 @@
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_HONGKONG
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-zh-HK.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-zh-HK.bmp"
ID_MENU MENU
BEGIN

View File

@@ -8,7 +8,7 @@
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL
//IDB_FONTSTOOLBAR BITMAP "img/fontstoolbar-zh-TW.bmp"
//IDB_FONTSTOOLBAR BITMAP "icons/fontstoolbar-zh-TW.bmp"
ID_MENU MENU
BEGIN

View File

@@ -7,12 +7,13 @@
#include "precomp.h"
#include <dlgs.h>
#include <mapi.h>
#include <mapicode.h>
POINT g_ptStart, g_ptEnd;
BOOL g_askBeforeEnlarging = FALSE; // TODO: initialize from registry
HINSTANCE g_hinstExe = NULL;
WCHAR g_szFileName[MAX_LONG_PATH] = { 0 };
TCHAR g_szFileName[MAX_LONG_PATH] = { 0 };
WCHAR g_szMailTempFile[MAX_LONG_PATH] = { 0 };
BOOL g_isAFile = FALSE;
BOOL g_imageSaved = FALSE;
@@ -22,32 +23,20 @@ CMainWindow mainWindow;
/* FUNCTIONS ********************************************************/
void ShowOutOfMemory(void)
{
WCHAR szText[256];
::FormatMessageW(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
ERROR_OUTOFMEMORY,
0,
szText, _countof(szText),
NULL);
mainWindow.MessageBox(szText, NULL, MB_ICONERROR);
}
// get file name extension from filter string
static BOOL
FileExtFromFilter(LPWSTR pExt, OPENFILENAME *pOFN)
FileExtFromFilter(LPTSTR pExt, OPENFILENAME *pOFN)
{
LPWSTR pchExt = pExt;
LPTSTR pchExt = pExt;
*pchExt = 0;
DWORD nIndex = 1;
for (LPCWSTR pch = pOFN->lpstrFilter; *pch; ++nIndex)
for (LPCTSTR pch = pOFN->lpstrFilter; *pch; ++nIndex)
{
pch += lstrlen(pch) + 1;
if (pOFN->nFilterIndex == nIndex)
{
for (++pch; *pch && *pch != L';'; ++pch)
for (++pch; *pch && *pch != _T(';'); ++pch)
{
*pchExt++ = *pch;
}
@@ -55,7 +44,7 @@ FileExtFromFilter(LPWSTR pExt, OPENFILENAME *pOFN)
CharLower(pExt);
return TRUE;
}
pch += wcslen(pch) + 1;
pch += lstrlen(pch) + 1;
}
return FALSE;
}
@@ -65,19 +54,19 @@ static UINT_PTR APIENTRY
OFNHookProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HWND hParent;
OFNOTIFYW *pon;
WCHAR Path[MAX_PATH];
OFNOTIFY *pon;
switch (uMsg)
{
case WM_NOTIFY:
pon = (OFNOTIFYW *)lParam;
pon = (OFNOTIFY *)lParam;
if (pon->hdr.code == CDN_TYPECHANGE)
{
hParent = GetParent(hwnd);
SendMessageW(hParent, CDM_GETFILEPATH, _countof(Path), (LPARAM)Path);
FileExtFromFilter(PathFindExtensionW(Path), pon->lpOFN);
SendMessageW(hParent, CDM_SETCONTROLTEXT, cmb13, (LPARAM)PathFindFileNameW(Path));
StringCchCopyW(pon->lpOFN->lpstrFile, pon->lpOFN->nMaxFile, Path);
TCHAR Path[MAX_PATH];
SendMessage(hParent, CDM_GETFILEPATH, _countof(Path), (LPARAM)Path);
FileExtFromFilter(PathFindExtension(Path), pon->lpOFN);
SendMessage(hParent, CDM_SETCONTROLTEXT, 0x047c, (LPARAM)PathFindFileName(Path));
lstrcpyn(pon->lpOFN->lpstrFile, Path, pon->lpOFN->nMaxFile);
}
break;
}
@@ -194,22 +183,21 @@ BOOL OpenMailer(HWND hWnd, LPCWSTR pszPathName)
return FALSE; // Failure
}
BOOL CMainWindow::GetOpenFileName(IN OUT LPWSTR pszFile, INT cchMaxFile)
BOOL CMainWindow::GetOpenFileName(IN OUT LPTSTR pszFile, INT cchMaxFile)
{
static OPENFILENAMEW ofn = { 0 };
static CStringW strFilter;
static OPENFILENAME ofn = { 0 };
static CString strFilter;
if (ofn.lStructSize == 0)
{
// The "All Files" item text
CStringW strAllPictureFiles;
CString strAllPictureFiles;
strAllPictureFiles.LoadString(g_hinstExe, IDS_ALLPICTUREFILES);
// Get the import filter
CSimpleArray<GUID> aguidFileTypesI;
CImage::GetImporterFilterString(strFilter, aguidFileTypesI, strAllPictureFiles,
CImage::excludeDefaultLoad, L'|');
strFilter.Replace(L'|', UNICODE_NULL);
CImage::excludeDefaultLoad, _T('\0'));
// Initializing the OPENFILENAME structure for GetOpenFileName
ZeroMemory(&ofn, sizeof(ofn));
@@ -223,21 +211,20 @@ BOOL CMainWindow::GetOpenFileName(IN OUT LPWSTR pszFile, INT cchMaxFile)
ofn.lpstrFile = pszFile;
ofn.nMaxFile = cchMaxFile;
return ::GetOpenFileNameW(&ofn);
return ::GetOpenFileName(&ofn);
}
BOOL CMainWindow::GetSaveFileName(IN OUT LPWSTR pszFile, INT cchMaxFile)
BOOL CMainWindow::GetSaveFileName(IN OUT LPTSTR pszFile, INT cchMaxFile)
{
static OPENFILENAMEW sfn = { 0 };
static CStringW strFilter;
static OPENFILENAME sfn = { 0 };
static CString strFilter;
if (sfn.lStructSize == 0)
{
// Get the export filter
CSimpleArray<GUID> aguidFileTypesE;
CImage::GetExporterFilterString(strFilter, aguidFileTypesE, NULL,
CImage::excludeDefaultSave, L'|');
strFilter.Replace(L'|', UNICODE_NULL);
CImage::excludeDefaultSave, _T('\0'));
// Initializing the OPENFILENAME structure for GetSaveFileName
ZeroMemory(&sfn, sizeof(sfn));
@@ -253,7 +240,7 @@ BOOL CMainWindow::GetSaveFileName(IN OUT LPWSTR pszFile, INT cchMaxFile)
if (*pchDotExt == UNICODE_NULL)
{
// Choose PNG
StringCchCatW(pszFile, cchMaxFile, L".png");
wcscat(pszFile, L".png");
for (INT i = 0; i < aguidFileTypesE.GetSize(); ++i)
{
if (aguidFileTypesE[i] == Gdiplus::ImageFormatPNG)
@@ -267,7 +254,7 @@ BOOL CMainWindow::GetSaveFileName(IN OUT LPWSTR pszFile, INT cchMaxFile)
sfn.lpstrFile = pszFile;
sfn.nMaxFile = cchMaxFile;
return ::GetSaveFileNameW(&sfn);
return ::GetSaveFileName(&sfn);
}
BOOL CMainWindow::ChooseColor(IN OUT COLORREF *prgbColor)
@@ -299,9 +286,9 @@ BOOL CMainWindow::ChooseColor(IN OUT COLORREF *prgbColor)
HWND CMainWindow::DoCreate()
{
::LoadStringW(g_hinstExe, IDS_DEFAULTFILENAME, g_szFileName, _countof(g_szFileName));
::LoadString(g_hinstExe, IDS_DEFAULTFILENAME, g_szFileName, _countof(g_szFileName));
CStringW strTitle;
CString strTitle;
strTitle.Format(IDS_WINDOWTITLE, PathFindFileName(g_szFileName));
RECT& rc = registrySettings.WindowPlacement.rcNormalPosition;
@@ -310,8 +297,13 @@ HWND CMainWindow::DoCreate()
// entry point
INT WINAPI
wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, INT nCmdShow)
_tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, INT nCmdShow)
{
#ifdef _DEBUG
// Report any memory leaks on exit
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
g_hinstExe = hInstance;
// Initialize common controls library
@@ -326,7 +318,7 @@ wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, INT nCm
// Create the main window
if (!mainWindow.DoCreate())
{
MessageBox(NULL, L"Failed to create main window.", NULL, MB_ICONERROR);
MessageBox(NULL, TEXT("Failed to create main window."), NULL, MB_ICONERROR);
return 1;
}
@@ -338,7 +330,7 @@ wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, INT nCm
mainWindow.ShowWindow(registrySettings.WindowPlacement.showCmd);
// Load the access keys
HACCEL hAccel = ::LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(800));
HACCEL hAccel = ::LoadAccelerators(hInstance, MAKEINTRESOURCE(800));
// The message loop
MSG msg;
@@ -347,7 +339,7 @@ wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, INT nCm
if (fontsDialog.IsWindow() && fontsDialog.IsDialogMessage(&msg))
continue;
if (::TranslateAcceleratorW(mainWindow, hAccel, &msg))
if (::TranslateAccelerator(mainWindow, hAccel, &msg))
continue;
::TranslateMessage(&msg);

View File

@@ -36,8 +36,8 @@ HWND CMiniatureWindow::DoCreate(HWND hwndParent)
(LONG)(registrySettings.ThumbYPos + registrySettings.ThumbHeight)
};
WCHAR strTitle[100];
::LoadStringW(g_hinstExe, IDS_MINIATURETITLE, strTitle, _countof(strTitle));
TCHAR strTitle[100];
::LoadString(g_hinstExe, IDS_MINIATURETITLE, strTitle, _countof(strTitle));
DWORD style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME;
return Create(hwndParent, rc, strTitle, style, WS_EX_PALETTEWINDOW);

View File

@@ -11,7 +11,7 @@
class CMiniatureWindow : public CWindowImpl<CMiniatureWindow>
{
public:
DECLARE_WND_CLASS_EX(L"MiniatureWindow", CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW,
DECLARE_WND_CLASS_EX(_T("MiniatureWindow"), CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW,
COLOR_BTNFACE)
BEGIN_MSG_MAP(CMiniatureWindow)

View File

@@ -3,7 +3,7 @@
* LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
* PURPOSE: Things which should not be in the mouse event handler itself
* COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
* Copyright 2021-2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
* Copyright 2021 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
/* INCLUDES *********************************************************/
@@ -12,7 +12,6 @@
INT ToolBase::s_pointSP = 0;
POINT ToolBase::s_pointStack[256] = { { 0 } };
static POINT g_ptStart, g_ptEnd;
/* FUNCTIONS ********************************************************/
@@ -63,7 +62,13 @@ void ToolBase::reset()
}
}
void ToolBase::OnEndDraw(BOOL bCancel)
void ToolBase::OnCancelDraw()
{
reset();
imageModel.NotifyImageChanged();
}
void ToolBase::OnFinishDraw()
{
reset();
imageModel.NotifyImageChanged();
@@ -170,13 +175,16 @@ struct FreeSelTool : ToolBase
return TRUE;
}
void OnEndDraw(BOOL bCancel) override
void OnFinishDraw() override
{
if (bCancel)
selectionModel.HideSelection();
else
selectionModel.Landing();
ToolBase::OnEndDraw(bCancel);
selectionModel.Landing();
ToolBase::OnFinishDraw();
}
void OnCancelDraw() override
{
selectionModel.HideSelection();
ToolBase::OnCancelDraw();
}
void OnSpecialTweak(BOOL bMinus) override
@@ -252,13 +260,16 @@ struct RectSelTool : ToolBase
return TRUE;
}
void OnEndDraw(BOOL bCancel) override
void OnFinishDraw() override
{
if (bCancel)
selectionModel.HideSelection();
else
selectionModel.Landing();
ToolBase::OnEndDraw(bCancel);
selectionModel.Landing();
ToolBase::OnFinishDraw();
}
void OnCancelDraw() override
{
selectionModel.HideSelection();
ToolBase::OnCancelDraw();
}
void OnSpecialTweak(BOOL bMinus) override
@@ -298,10 +309,16 @@ struct TwoPointDrawTool : ToolBase
return TRUE;
}
void OnEndDraw(BOOL bCancel) override
void OnFinishDraw() override
{
m_bDrawing = FALSE;
ToolBase::OnEndDraw(bCancel);
ToolBase::OnFinishDraw();
}
void OnCancelDraw() override
{
m_bDrawing = FALSE;
ToolBase::OnCancelDraw();
}
void OnSpecialTweak(BOOL bMinus) override
@@ -404,7 +421,6 @@ RestrictDrawDirection(DIRECTION dir, LONG x0, LONG y0, LONG& x1, LONG& y1)
struct SmoothDrawTool : ToolBase
{
DIRECTION m_direction = NO_DIRECTION;
BOOL m_bShiftDown = FALSE;
SmoothDrawTool(TOOLTYPE type) : ToolBase(type)
{
@@ -417,12 +433,11 @@ struct SmoothDrawTool : ToolBase
m_direction = NO_DIRECTION;
imageModel.PushImageForUndo();
imageModel.NotifyImageChanged();
m_bShiftDown = (::GetKeyState(VK_SHIFT) & 0x8000); // Is Shift key pressed?
}
BOOL OnMouseMove(BOOL bLeftButton, LONG& x, LONG& y) override
{
if (m_bShiftDown)
if (::GetKeyState(VK_SHIFT) < 0) // Shift key is pressed
{
if (m_direction == NO_DIRECTION)
{
@@ -435,10 +450,14 @@ struct SmoothDrawTool : ToolBase
}
else
{
draw(bLeftButton, x, y);
g_ptStart.x = g_ptEnd.x = x;
g_ptStart.y = g_ptEnd.y = y;
return TRUE;
if (m_direction != NO_DIRECTION)
{
m_direction = NO_DIRECTION;
draw(bLeftButton, x, y);
g_ptStart.x = g_ptEnd.x = x;
g_ptStart.y = g_ptEnd.y = y;
return TRUE;
}
}
draw(bLeftButton, x, y);
@@ -448,25 +467,27 @@ struct SmoothDrawTool : ToolBase
BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
{
if (m_bShiftDown && m_direction != NO_DIRECTION)
if (m_direction != NO_DIRECTION)
{
RestrictDrawDirection(m_direction, g_ptStart.x, g_ptStart.y, x, y);
}
draw(bLeftButton, x, y);
OnEndDraw(FALSE);
OnFinishDraw();
return TRUE;
}
void OnEndDraw(BOOL bCancel) override
void OnFinishDraw() override
{
if (bCancel)
{
LONG x = 0, y = 0;
OnButtonUp(FALSE, x, y);
imageModel.Undo(TRUE);
}
ToolBase::OnEndDraw(bCancel);
ToolBase::OnFinishDraw();
}
void OnCancelDraw() override
{
LONG x = 0, y = 0;
OnButtonUp(FALSE, x, y);
imageModel.Undo(TRUE);
ToolBase::OnCancelDraw();
}
};
@@ -544,67 +565,26 @@ struct ColorTool : ToolBase
// TOOL_ZOOM
struct ZoomTool : ToolBase
{
BOOL m_bZoomed = FALSE;
ZoomTool() : ToolBase(TOOL_ZOOM)
{
}
BOOL getNewZoomRect(CRect& rcView, INT newZoom);
void OnDrawOverlayOnCanvas(HDC hdc) override
{
CRect rcView;
INT oldZoom = toolsModel.GetZoom();
if (oldZoom < MAX_ZOOM && getNewZoomRect(rcView, oldZoom * 2))
DrawXorRect(hdc, &rcView);
}
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
{
INT newZoom, oldZoom = toolsModel.GetZoom();
imageModel.PushImageForUndo();
if (bLeftButton)
newZoom = (oldZoom < MAX_ZOOM) ? (oldZoom * 2) : MIN_ZOOM;
else
newZoom = (oldZoom > MIN_ZOOM) ? (oldZoom / 2) : MAX_ZOOM;
m_bZoomed = FALSE;
if (oldZoom != newZoom)
{
CRect rcView;
if (getNewZoomRect(rcView, newZoom))
{
canvasWindow.zoomTo(newZoom, rcView.left, rcView.top);
m_bZoomed = TRUE;
}
if (toolsModel.GetZoom() < MAX_ZOOM)
zoomTo(toolsModel.GetZoom() * 2, x, y);
}
else
{
if (toolsModel.GetZoom() > MIN_ZOOM)
zoomTo(toolsModel.GetZoom() / 2, x, y);
}
}
BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
{
if (m_bZoomed)
toolsModel.SetActiveTool(toolsModel.GetOldActiveTool());
return TRUE;
}
};
BOOL ZoomTool::getNewZoomRect(CRect& rcView, INT newZoom)
{
CPoint pt;
::GetCursorPos(&pt);
canvasWindow.ScreenToClient(&pt);
canvasWindow.getNewZoomRect(rcView, newZoom, pt);
CRect rc;
canvasWindow.GetImageRect(rc);
canvasWindow.ImageToCanvas(rc);
return rc.PtInRect(pt);
}
// TOOL_PEN
struct PenTool : SmoothDrawTool
{
@@ -704,7 +684,7 @@ struct TextTool : ToolBase
void draw(HDC hdc)
{
CStringW szText;
CString szText;
textEditWindow.GetWindowText(szText);
RECT rc;
@@ -780,19 +760,21 @@ struct TextTool : ToolBase
return TRUE;
}
void OnEndDraw(BOOL bCancel) override
void OnFinishDraw() override
{
if (!bCancel)
if (textEditWindow.GetWindowTextLength() > 0)
{
if (::IsWindowVisible(textEditWindow) &&
textEditWindow.GetWindowTextLength() > 0)
{
imageModel.PushImageForUndo();
draw(m_hdc);
}
imageModel.PushImageForUndo();
draw(m_hdc);
}
quit();
ToolBase::OnEndDraw(bCancel);
ToolBase::OnFinishDraw();
}
void OnCancelDraw() override
{
quit();
ToolBase::OnCancelDraw();
}
};
@@ -880,22 +862,25 @@ struct BezierTool : ToolBase
s_pointStack[s_pointSP].y = y;
if (s_pointSP >= 3)
{
OnEndDraw(FALSE);
OnFinishDraw();
return TRUE;
}
imageModel.NotifyImageChanged();
return TRUE;
}
void OnEndDraw(BOOL bCancel) override
void OnCancelDraw() override
{
if (!bCancel)
{
imageModel.PushImageForUndo();
OnDrawOverlayOnImage(m_hdc);
}
m_bDrawing = FALSE;
ToolBase::OnEndDraw(bCancel);
ToolBase::OnCancelDraw();
}
void OnFinishDraw() override
{
imageModel.PushImageForUndo();
OnDrawOverlayOnImage(m_hdc);
m_bDrawing = FALSE;
ToolBase::OnFinishDraw();
}
void OnSpecialTweak(BOOL bMinus) override
@@ -958,7 +943,7 @@ struct ShapeTool : ToolBase
if (s_pointSP && bDoubleClick)
{
OnEndDraw(FALSE);
OnFinishDraw();
return;
}
@@ -992,7 +977,7 @@ struct ShapeTool : ToolBase
m_bClosed = FALSE;
if (nearlyEqualPoints(x, y, s_pointStack[0].x, s_pointStack[0].y))
{
OnEndDraw(FALSE);
OnFinishDraw();
return TRUE;
}
else
@@ -1009,22 +994,26 @@ struct ShapeTool : ToolBase
return TRUE;
}
void OnEndDraw(BOOL bCancel) override
void OnCancelDraw() override
{
if (!bCancel)
{
if (s_pointSP)
{
--s_pointSP;
m_bClosed = TRUE;
ToolBase::OnCancelDraw();
}
imageModel.PushImageForUndo();
OnDrawOverlayOnImage(m_hdc);
}
m_bClosed = FALSE;
s_pointSP = 0;
void OnFinishDraw() override
{
if (s_pointSP)
{
--s_pointSP;
m_bClosed = TRUE;
imageModel.PushImageForUndo();
OnDrawOverlayOnImage(m_hdc);
}
ToolBase::OnEndDraw(bCancel);
m_bClosed = FALSE;
s_pointSP = 0;
ToolBase::OnFinishDraw();
}
void OnSpecialTweak(BOOL bMinus) override
@@ -1098,129 +1087,3 @@ ToolBase::createToolObject(TOOLTYPE type)
UNREACHABLE;
return NULL;
}
void ToolsModel::OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
{
m_pToolObject->beginEvent();
g_ptStart.x = g_ptEnd.x = x;
g_ptStart.y = g_ptEnd.y = y;
m_pToolObject->OnButtonDown(bLeftButton, x, y, bDoubleClick);
m_pToolObject->endEvent();
}
void ToolsModel::OnMouseMove(BOOL bLeftButton, LONG x, LONG y)
{
m_pToolObject->beginEvent();
if (m_pToolObject->OnMouseMove(bLeftButton, x, y))
{
g_ptEnd.x = x;
g_ptEnd.y = y;
}
m_pToolObject->endEvent();
}
void ToolsModel::OnButtonUp(BOOL bLeftButton, LONG x, LONG y)
{
m_pToolObject->beginEvent();
if (m_pToolObject->OnButtonUp(bLeftButton, x, y))
{
g_ptEnd.x = x;
g_ptEnd.y = y;
}
m_pToolObject->endEvent();
}
void ToolsModel::OnEndDraw(BOOL bCancel)
{
ATLTRACE("ToolsModel::OnEndDraw(%d)\n", bCancel);
m_pToolObject->beginEvent();
m_pToolObject->OnEndDraw(bCancel);
m_pToolObject->endEvent();
}
void ToolsModel::OnDrawOverlayOnImage(HDC hdc)
{
m_pToolObject->OnDrawOverlayOnImage(hdc);
}
void ToolsModel::OnDrawOverlayOnCanvas(HDC hdc)
{
m_pToolObject->OnDrawOverlayOnCanvas(hdc);
}
void ToolsModel::SpecialTweak(BOOL bMinus)
{
m_pToolObject->OnSpecialTweak(bMinus);
}
void ToolsModel::DrawWithMouseTool(POINT pt, WPARAM wParam)
{
LONG xRel = pt.x - g_ptStart.x, yRel = pt.y - g_ptStart.y;
switch (m_activeTool)
{
// freesel, rectsel and text tools always show numbers limited to fit into image area
case TOOL_FREESEL:
case TOOL_RECTSEL:
case TOOL_TEXT:
if (xRel < 0)
xRel = (pt.x < 0) ? -g_ptStart.x : xRel;
else if (pt.x > imageModel.GetWidth())
xRel = imageModel.GetWidth() - g_ptStart.x;
if (yRel < 0)
yRel = (pt.y < 0) ? -g_ptStart.y : yRel;
else if (pt.y > imageModel.GetHeight())
yRel = imageModel.GetHeight() - g_ptStart.y;
break;
// while drawing, update cursor coordinates only for tools 3, 7, 8, 9, 14
case TOOL_RUBBER:
case TOOL_PEN:
case TOOL_BRUSH:
case TOOL_AIRBRUSH:
case TOOL_SHAPE:
{
CStringW strCoord;
strCoord.Format(L"%ld, %ld", pt.x, pt.y);
::SendMessageW(g_hStatusBar, SB_SETTEXT, 1, (LPARAM)(LPCWSTR)strCoord);
break;
}
default:
break;
}
// rectsel and shape tools always show non-negative numbers when drawing
if (m_activeTool == TOOL_RECTSEL || m_activeTool == TOOL_SHAPE)
{
xRel = labs(xRel);
yRel = labs(yRel);
}
if (wParam & MK_LBUTTON)
{
OnMouseMove(TRUE, pt.x, pt.y);
canvasWindow.Invalidate(FALSE);
if ((m_activeTool >= TOOL_TEXT) || IsSelection())
{
CStringW strSize;
if ((m_activeTool >= TOOL_LINE) && (GetAsyncKeyState(VK_SHIFT) < 0))
yRel = xRel;
strSize.Format(L"%ld x %ld", xRel, yRel);
::SendMessageW(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)(LPCWSTR)strSize);
}
}
if (wParam & MK_RBUTTON)
{
OnMouseMove(FALSE, pt.x, pt.y);
canvasWindow.Invalidate(FALSE);
if (m_activeTool >= TOOL_TEXT)
{
CStringW strSize;
if ((m_activeTool >= TOOL_LINE) && (GetAsyncKeyState(VK_SHIFT) < 0))
yRel = xRel;
strSize.Format(L"%ld x %ld", xRel, yRel);
::SendMessageW(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)(LPCWSTR)strSize);
}
}
}

View File

@@ -14,7 +14,7 @@
class CPaletteWindow : public CWindowImpl<CPaletteWindow>
{
public:
DECLARE_WND_CLASS_EX(L"Palette", CS_DBLCLKS, COLOR_BTNFACE)
DECLARE_WND_CLASS_EX(_T("Palette"), CS_DBLCLKS, COLOR_BTNFACE)
BEGIN_MSG_MAP(CPaletteWindow)
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)

View File

@@ -25,8 +25,11 @@
#include <math.h>
#include <shellapi.h>
#include <htmlhelp.h>
#include <strsafe.h>
#include "atlimagedx.h"
#ifdef _DEBUG
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#endif
#include <debug.h>

View File

@@ -15,18 +15,18 @@ RegistrySettings registrySettings;
/* FUNCTIONS ********************************************************/
static void ReadDWORD(CRegKey &key, LPCWSTR lpName, DWORD &dwValue)
static void ReadDWORD(CRegKey &key, LPCTSTR lpName, DWORD &dwValue)
{
DWORD dwTemp;
if (key.QueryDWORDValue(lpName, dwTemp) == ERROR_SUCCESS)
dwValue = dwTemp;
}
static void ReadString(CRegKey &key, LPCWSTR lpName, CStringW &strValue, LPCWSTR lpDefault = L"")
static void ReadString(CRegKey &key, LPCTSTR lpName, CString &strValue, LPCTSTR lpDefault = TEXT(""))
{
CStringW strTemp;
CString strTemp;
ULONG nChars = MAX_PATH;
LPWSTR psz = strTemp.GetBuffer(nChars);
LPTSTR psz = strTemp.GetBuffer(nChars);
LONG error = key.QueryStringValue(lpName, psz, &nChars);
strTemp.ReleaseBuffer();
@@ -36,15 +36,15 @@ static void ReadString(CRegKey &key, LPCWSTR lpName, CStringW &strValue, LPCWSTR
strValue = lpDefault;
}
void RegistrySettings::SetWallpaper(LPCWSTR szFileName, RegistrySettings::WallpaperStyle style)
void RegistrySettings::SetWallpaper(LPCTSTR szFileName, RegistrySettings::WallpaperStyle style)
{
CRegKey desktop;
if (desktop.Open(HKEY_CURRENT_USER, L"Control Panel\\Desktop") == ERROR_SUCCESS)
if (desktop.Open(HKEY_CURRENT_USER, _T("Control Panel\\Desktop")) == ERROR_SUCCESS)
{
desktop.SetStringValue(L"Wallpaper", szFileName);
desktop.SetStringValue(_T("Wallpaper"), szFileName);
desktop.SetStringValue(L"WallpaperStyle", (style == RegistrySettings::STRETCHED) ? L"2" : L"0");
desktop.SetStringValue(L"TileWallpaper", (style == RegistrySettings::TILED) ? L"1" : L"0");
desktop.SetStringValue(_T("WallpaperStyle"), (style == RegistrySettings::STRETCHED) ? _T("2") : _T("0"));
desktop.SetStringValue(_T("TileWallpaper"), (style == RegistrySettings::TILED) ? _T("1") : _T("0"));
}
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (PVOID) szFileName, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
@@ -77,8 +77,8 @@ void RegistrySettings::LoadPresets(INT nCmdShow)
Bar1ID = BAR1ID_TOP;
Bar2ID = BAR2ID_LEFT;
LOGFONTW lf;
::GetObjectW(GetStockObject(DEFAULT_GUI_FONT), sizeof(lf), &lf);
LOGFONT lf;
GetObject(GetStockObject(DEFAULT_GUI_FONT), sizeof(lf), &lf);
strFontName = lf.lfFaceName;
ZeroMemory(&WindowPlacement, sizeof(WindowPlacement));
@@ -94,76 +94,76 @@ void RegistrySettings::Load(INT nCmdShow)
LoadPresets(nCmdShow);
CRegKey paint;
if (paint.Open(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint", KEY_READ) != ERROR_SUCCESS)
if (paint.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint"), KEY_READ) != ERROR_SUCCESS)
return;
CRegKey view;
if (view.Open(paint, L"View", KEY_READ) == ERROR_SUCCESS)
if (view.Open(paint, _T("View"), KEY_READ) == ERROR_SUCCESS)
{
ReadDWORD(view, L"BMPHeight", BMPHeight);
ReadDWORD(view, L"BMPWidth", BMPWidth);
ReadDWORD(view, L"GridExtent", GridExtent);
ReadDWORD(view, L"NoStretching", NoStretching);
ReadDWORD(view, L"ShowThumbnail", ShowThumbnail);
ReadDWORD(view, L"SnapToGrid", SnapToGrid);
ReadDWORD(view, L"ThumbHeight", ThumbHeight);
ReadDWORD(view, L"ThumbWidth", ThumbWidth);
ReadDWORD(view, L"ThumbXPos", ThumbXPos);
ReadDWORD(view, L"ThumbYPos", ThumbYPos);
ReadDWORD(view, L"UnitSetting", UnitSetting);
ReadDWORD(view, L"ShowStatusBar", ShowStatusBar);
ReadDWORD(view, _T("BMPHeight"), BMPHeight);
ReadDWORD(view, _T("BMPWidth"), BMPWidth);
ReadDWORD(view, _T("GridExtent"), GridExtent);
ReadDWORD(view, _T("NoStretching"), NoStretching);
ReadDWORD(view, _T("ShowThumbnail"), ShowThumbnail);
ReadDWORD(view, _T("SnapToGrid"), SnapToGrid);
ReadDWORD(view, _T("ThumbHeight"), ThumbHeight);
ReadDWORD(view, _T("ThumbWidth"), ThumbWidth);
ReadDWORD(view, _T("ThumbXPos"), ThumbXPos);
ReadDWORD(view, _T("ThumbYPos"), ThumbYPos);
ReadDWORD(view, _T("UnitSetting"), UnitSetting);
ReadDWORD(view, _T("ShowStatusBar"), ShowStatusBar);
ULONG pnBytes = sizeof(WINDOWPLACEMENT);
view.QueryBinaryValue(L"WindowPlacement", &WindowPlacement, &pnBytes);
view.QueryBinaryValue(_T("WindowPlacement"), &WindowPlacement, &pnBytes);
}
CRegKey files;
if (files.Open(paint, L"Recent File List", KEY_READ) == ERROR_SUCCESS)
if (files.Open(paint, _T("Recent File List"), KEY_READ) == ERROR_SUCCESS)
{
WCHAR szName[64];
TCHAR szName[64];
for (INT i = 0; i < MAX_RECENT_FILES; ++i)
{
StringCchPrintfW(szName, _countof(szName), L"File%u", i + 1);
wsprintf(szName, _T("File%u"), i + 1);
ReadString(files, szName, strFiles[i]);
}
}
CRegKey text;
if (text.Open(paint, L"Text", KEY_READ) == ERROR_SUCCESS)
if (text.Open(paint, _T("Text"), KEY_READ) == ERROR_SUCCESS)
{
ReadDWORD(text, L"Bold", Bold);
ReadDWORD(text, L"Italic", Italic);
ReadDWORD(text, L"Underline", Underline);
ReadDWORD(text, L"CharSet", CharSet);
ReadDWORD(text, L"PointSize", PointSize);
ReadDWORD(text, L"PositionX", FontsPositionX);
ReadDWORD(text, L"PositionY", FontsPositionY);
ReadDWORD(text, L"ShowTextTool", ShowTextTool);
ReadString(text, L"TypeFaceName", strFontName, strFontName);
ReadDWORD(text, _T("Bold"), Bold);
ReadDWORD(text, _T("Italic"), Italic);
ReadDWORD(text, _T("Underline"), Underline);
ReadDWORD(text, _T("CharSet"), CharSet);
ReadDWORD(text, _T("PointSize"), PointSize);
ReadDWORD(text, _T("PositionX"), FontsPositionX);
ReadDWORD(text, _T("PositionY"), FontsPositionY);
ReadDWORD(text, _T("ShowTextTool"), ShowTextTool);
ReadString(text, _T("TypeFaceName"), strFontName, strFontName);
}
CRegKey bar1;
if (bar1.Open(paint, L"General-Bar1", KEY_READ) == ERROR_SUCCESS)
if (bar1.Open(paint, _T("General-Bar1"), KEY_READ) == ERROR_SUCCESS)
{
ReadDWORD(bar1, L"BarID", Bar1ID);
ReadDWORD(bar1, _T("BarID"), Bar1ID);
}
CRegKey bar2;
if (bar2.Open(paint, L"General-Bar2", KEY_READ) == ERROR_SUCCESS)
if (bar2.Open(paint, _T("General-Bar2"), KEY_READ) == ERROR_SUCCESS)
{
ReadDWORD(bar2, L"BarID", Bar2ID);
ReadDWORD(bar2, _T("BarID"), Bar2ID);
}
CRegKey bar3;
if (bar3.Open(paint, L"General-Bar3", KEY_READ) == ERROR_SUCCESS)
if (bar3.Open(paint, _T("General-Bar3"), KEY_READ) == ERROR_SUCCESS)
{
ReadDWORD(bar3, L"Visible", ShowToolBox);
ReadDWORD(bar3, _T("Visible"), ShowToolBox);
}
CRegKey bar4;
if (bar4.Open(paint, L"General-Bar4", KEY_READ) == ERROR_SUCCESS)
if (bar4.Open(paint, _T("General-Bar4"), KEY_READ) == ERROR_SUCCESS)
{
ReadDWORD(bar4, L"Visible", ShowPalette);
ReadDWORD(bar4, _T("Visible"), ShowPalette);
}
// Fix the bitmap size if too large
@@ -179,79 +179,79 @@ void RegistrySettings::Store()
BMPHeight = imageModel.GetHeight();
CRegKey paint;
if (paint.Create(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint") != ERROR_SUCCESS)
if (paint.Create(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint")) != ERROR_SUCCESS)
return;
CRegKey view;
if (view.Create(paint, L"View") == ERROR_SUCCESS)
if (view.Create(paint, _T("View")) == ERROR_SUCCESS)
{
view.SetDWORDValue(L"BMPHeight", BMPHeight);
view.SetDWORDValue(L"BMPWidth", BMPWidth);
view.SetDWORDValue(L"GridExtent", GridExtent);
view.SetDWORDValue(L"NoStretching", NoStretching);
view.SetDWORDValue(L"ShowThumbnail", ShowThumbnail);
view.SetDWORDValue(L"SnapToGrid", SnapToGrid);
view.SetDWORDValue(L"ThumbHeight", ThumbHeight);
view.SetDWORDValue(L"ThumbWidth", ThumbWidth);
view.SetDWORDValue(L"ThumbXPos", ThumbXPos);
view.SetDWORDValue(L"ThumbYPos", ThumbYPos);
view.SetDWORDValue(L"UnitSetting", UnitSetting);
view.SetDWORDValue(L"ShowStatusBar", ShowStatusBar);
view.SetDWORDValue(_T("BMPHeight"), BMPHeight);
view.SetDWORDValue(_T("BMPWidth"), BMPWidth);
view.SetDWORDValue(_T("GridExtent"), GridExtent);
view.SetDWORDValue(_T("NoStretching"), NoStretching);
view.SetDWORDValue(_T("ShowThumbnail"), ShowThumbnail);
view.SetDWORDValue(_T("SnapToGrid"), SnapToGrid);
view.SetDWORDValue(_T("ThumbHeight"), ThumbHeight);
view.SetDWORDValue(_T("ThumbWidth"), ThumbWidth);
view.SetDWORDValue(_T("ThumbXPos"), ThumbXPos);
view.SetDWORDValue(_T("ThumbYPos"), ThumbYPos);
view.SetDWORDValue(_T("UnitSetting"), UnitSetting);
view.SetDWORDValue(_T("ShowStatusBar"), ShowStatusBar);
view.SetBinaryValue(L"WindowPlacement", &WindowPlacement, sizeof(WINDOWPLACEMENT));
view.SetBinaryValue(_T("WindowPlacement"), &WindowPlacement, sizeof(WINDOWPLACEMENT));
}
CRegKey files;
if (files.Create(paint, L"Recent File List") == ERROR_SUCCESS)
if (files.Create(paint, _T("Recent File List")) == ERROR_SUCCESS)
{
WCHAR szName[64];
TCHAR szName[64];
for (INT iFile = 0; iFile < MAX_RECENT_FILES; ++iFile)
{
StringCchPrintfW(szName, _countof(szName), L"File%u", iFile + 1);
wsprintf(szName, _T("File%u"), iFile + 1);
files.SetStringValue(szName, strFiles[iFile]);
}
}
CRegKey text;
if (text.Create(paint, L"Text") == ERROR_SUCCESS)
if (text.Create(paint, _T("Text")) == ERROR_SUCCESS)
{
text.SetDWORDValue(L"Bold", Bold);
text.SetDWORDValue(L"Italic", Italic);
text.SetDWORDValue(L"Underline", Underline);
text.SetDWORDValue(L"CharSet", CharSet);
text.SetDWORDValue(L"PointSize", PointSize);
text.SetDWORDValue(L"PositionX", FontsPositionX);
text.SetDWORDValue(L"PositionY", FontsPositionY);
text.SetDWORDValue(L"ShowTextTool", ShowTextTool);
text.SetStringValue(L"TypeFaceName", strFontName);
text.SetDWORDValue(_T("Bold"), Bold);
text.SetDWORDValue(_T("Italic"), Italic);
text.SetDWORDValue(_T("Underline"), Underline);
text.SetDWORDValue(_T("CharSet"), CharSet);
text.SetDWORDValue(_T("PointSize"), PointSize);
text.SetDWORDValue(_T("PositionX"), FontsPositionX);
text.SetDWORDValue(_T("PositionY"), FontsPositionY);
text.SetDWORDValue(_T("ShowTextTool"), ShowTextTool);
text.SetStringValue(_T("TypeFaceName"), strFontName);
}
CRegKey bar1;
if (bar1.Create(paint, L"General-Bar1") == ERROR_SUCCESS)
if (bar1.Create(paint, _T("General-Bar1")) == ERROR_SUCCESS)
{
bar1.SetDWORDValue(L"BarID", Bar1ID);
bar1.SetDWORDValue(_T("BarID"), Bar1ID);
}
CRegKey bar2;
if (bar2.Create(paint, L"General-Bar2") == ERROR_SUCCESS)
if (bar2.Create(paint, _T("General-Bar2")) == ERROR_SUCCESS)
{
bar2.SetDWORDValue(L"BarID", Bar2ID);
bar2.SetDWORDValue(_T("BarID"), Bar2ID);
}
CRegKey bar3;
if (bar3.Create(paint, L"General-Bar3") == ERROR_SUCCESS)
if (bar3.Create(paint, _T("General-Bar3")) == ERROR_SUCCESS)
{
bar3.SetDWORDValue(L"Visible", ShowToolBox);
bar3.SetDWORDValue(_T("Visible"), ShowToolBox);
}
CRegKey bar4;
if (bar4.Create(paint, L"General-Bar4") == ERROR_SUCCESS)
if (bar4.Create(paint, _T("General-Bar4")) == ERROR_SUCCESS)
{
bar4.SetDWORDValue(L"Visible", ShowPalette);
bar4.SetDWORDValue(_T("Visible"), ShowPalette);
}
}
void RegistrySettings::SetMostRecentFile(LPCWSTR szPathName)
void RegistrySettings::SetMostRecentFile(LPCTSTR szPathName)
{
// Register the file to the user's 'Recent' folder
if (szPathName && szPathName[0])
@@ -265,7 +265,7 @@ void RegistrySettings::SetMostRecentFile(LPCWSTR szPathName)
if (iFound >= 0)
{
CStringW tmp = strFiles[i];
CString tmp = strFiles[i];
strFiles[i] = strFiles[i - 1];
strFiles[i - 1] = tmp;
}

View File

@@ -28,9 +28,9 @@ public:
DWORD UnitSetting;
WINDOWPLACEMENT WindowPlacement;
CStringW strFiles[MAX_RECENT_FILES];
CString strFiles[MAX_RECENT_FILES];
CStringW strFontName;
CString strFontName;
DWORD PointSize;
DWORD Bold;
DWORD Italic;
@@ -61,9 +61,9 @@ public:
STRETCHED
};
static void SetWallpaper(LPCWSTR szFileName, WallpaperStyle style);
static void SetWallpaper(LPCTSTR szFileName, WallpaperStyle style);
void Load(INT nCmdShow);
void Store();
void SetMostRecentFile(LPCWSTR szPathName);
void SetMostRecentFile(LPCTSTR szPathName);
};

View File

@@ -22,7 +22,6 @@
#define IDC_ZOOM 532
#define IDC_PEN 533
#define IDC_AIRBRUSH 534
#define IDC_HANDDRAG 535
#define IDI_HORZSTRETCH 535
#define IDI_VERTSTRETCH 536

View File

@@ -8,7 +8,7 @@
/* INCLUDES *********************************************************/
#include <windef.h>
#include <winuser.rh>
#include <winuser.h>
#include <commctrl.h>
#include "resource.h"
@@ -21,24 +21,23 @@
/* Icons */
IDI_APPICON ICON "img/paint.ico"
IDI_APPICON ICON "icons/paint.ico"
IDB_TOOLBARICONS BITMAP "img/iconbar.bmp"
IDB_TOOLBARICONS BITMAP "icons/iconbar.bmp"
IDI_TRANSPARENT ICON "img/transparent.ico"
IDI_NONTRANSPARENT ICON "img/nontransparent.ico"
IDI_TRANSPARENT ICON "icons/transparent.ico"
IDI_NONTRANSPARENT ICON "icons/nontransparent.ico"
IDC_FILL CURSOR "img/fill.cur"
IDC_COLOR CURSOR "img/color.cur"
IDC_ZOOM CURSOR "img/zoom.cur"
IDC_PEN CURSOR "img/pen.cur"
IDC_AIRBRUSH CURSOR "img/airbrush.cur"
IDC_HANDDRAG CURSOR "img/handdrag.cur"
IDC_FILL ICON "icons/fill_cur.ico"
IDC_COLOR ICON "icons/color_cur.ico"
IDC_ZOOM ICON "icons/zoom_cur.ico"
IDC_PEN ICON "icons/pen_cur.ico"
IDC_AIRBRUSH ICON "icons/airbrush_cur.ico"
IDI_HORZSTRETCH ICON "img/horzstretch.ico"
IDI_VERTSTRETCH ICON "img/vertstretch.ico"
IDI_HORZSKEW ICON "img/horzskew.ico"
IDI_VERTSKEW ICON "img/vertskew.ico"
IDI_HORZSTRETCH ICON "icons/horzstretch.ico"
IDI_VERTSTRETCH ICON "icons/vertstretch.ico"
IDI_HORZSKEW ICON "icons/horzskew.ico"
IDI_VERTSKEW ICON "icons/vertskew.ico"
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "mspaint.exe.manifest"

View File

@@ -139,7 +139,7 @@ void SelectionModel::DrawSelection(HDC hDCImage, COLORREF crBg, BOOL bBgTranspar
return;
BITMAP bm;
if (!GetObjectW(m_hbmColor, sizeof(BITMAP), &bm))
if (!GetObject(m_hbmColor, sizeof(BITMAP), &bm))
return;
COLORREF keyColor = (bBgTransparent ? crBg : CLR_INVALID);
@@ -152,19 +152,16 @@ void SelectionModel::DrawSelection(HDC hDCImage, COLORREF crBg, BOOL bBgTranspar
DeleteDC(hMemDC);
}
HBITMAP SelectionModel::GetSelectionContents()
void SelectionModel::GetSelectionContents(HDC hDCImage)
{
if (m_hbmColor)
return CopyDIBImage(m_hbmColor, m_rc.Width(), m_rc.Height());
ClearColorImage();
HDC hMemDC = ::CreateCompatibleDC(NULL);
HBITMAP hBitmap = CreateColorDIB(m_rc.Width(), m_rc.Height(), RGB(255, 255, 255));
HGDIOBJ hbmOld = ::SelectObject(hMemDC, hBitmap);
::BitBlt(hMemDC, 0, 0, m_rc.Width(), m_rc.Height(), imageModel.GetDC(), m_rc.left, m_rc.top, SRCCOPY);
m_hbmColor = CreateColorDIB(m_rc.Width(), m_rc.Height(), RGB(255, 255, 255));
HGDIOBJ hbmOld = ::SelectObject(hMemDC, m_hbmColor);
::BitBlt(hMemDC, 0, 0, m_rc.Width(), m_rc.Height(), hDCImage, m_rc.left, m_rc.top, SRCCOPY);
::SelectObject(hMemDC, hbmOld);
::DeleteDC(hMemDC);
return hBitmap;
}
BOOL SelectionModel::IsLanded() const
@@ -181,8 +178,7 @@ BOOL SelectionModel::TakeOff()
m_rgbBack = paletteModel.GetBgColor();
// Get the contents of the selection area
ClearColorImage();
m_hbmColor = GetSelectionContents();
GetSelectionContents(imageModel.GetDC());
// RectSel doesn't need the mask image
if (toolsModel.GetActiveTool() == TOOL_RECTSEL)
@@ -410,6 +406,13 @@ void SelectionModel::StretchSkew(int nStretchPercentX, int nStretchPercentY, int
NotifyContentChanged();
}
HBITMAP SelectionModel::CopyBitmap()
{
if (m_hbmColor == NULL)
GetSelectionContents(imageModel.GetDC());
return CopyDIBImage(m_hbmColor);
}
int SelectionModel::PtStackSize() const
{
return m_iPtSP;
@@ -516,7 +519,7 @@ void SelectionModel::InvertSelection()
TakeOff();
BITMAP bm;
::GetObjectW(m_hbmColor, sizeof(bm), &bm);
::GetObject(m_hbmColor, sizeof(bm), &bm);
HDC hdc = ::CreateCompatibleDC(NULL);
HGDIOBJ hbmOld = ::SelectObject(hdc, m_hbmColor);
@@ -542,6 +545,18 @@ void SelectionModel::SwapWidthAndHeight()
m_rc.bottom = m_rc.top + cx;
}
HBITMAP SelectionModel::LockBitmap()
{
HBITMAP hbm = m_hbmColor;
m_hbmColor = NULL;
return hbm;
}
void SelectionModel::UnlockBitmap(HBITMAP hbmLocked)
{
m_hbmColor = hbmLocked;
}
void SelectionModel::StretchSelection(BOOL bShrink)
{
if (!m_bShow)

View File

@@ -40,7 +40,10 @@ public:
void HideSelection();
void DeleteSelection();
HBITMAP GetSelectionContents();
HBITMAP CopyBitmap();
HBITMAP LockBitmap();
void UnlockBitmap(HBITMAP hbmLocked);
void GetSelectionContents(HDC hDCImage);
void DrawFramePoly(HDC hDCImage);
void DrawBackground(HDC hDCImage);
void DrawBackgroundPoly(HDC hDCImage, COLORREF crBg);

View File

@@ -21,7 +21,7 @@ BOOL setCursorOnSizeBox(HITTEST hit)
{
if (HIT_UPPER_LEFT <= hit && hit <= HIT_LOWER_RIGHT)
{
::SetCursor(::LoadCursorW(NULL, s_cursor_shapes[hit - HIT_UPPER_LEFT]));
::SetCursor(::LoadCursor(NULL, s_cursor_shapes[hit - HIT_UPPER_LEFT]));
return TRUE;
}
return FALSE;

View File

@@ -44,9 +44,9 @@ void CTextEditWindow::DrawGrip(HDC hDC, RECT& rc)
drawSizeBoxes(hDC, &rc, TRUE, NULL);
}
void CTextEditWindow::FixEditPos(LPCWSTR pszOldText)
void CTextEditWindow::FixEditPos(LPCTSTR pszOldText)
{
CStringW szText;
CString szText;
GetWindowText(szText);
RECT rcParent;
@@ -62,10 +62,10 @@ void CTextEditWindow::FixEditPos(LPCWSTR pszOldText)
SelectObject(hDC, m_hFontZoomed);
TEXTMETRIC tm;
GetTextMetrics(hDC, &tm);
szText += L"x"; // This is a trick to enable the g_ptEnd newlines
szText += TEXT("x"); // This is a trick to enable the g_ptEnd newlines
const UINT uFormat = DT_LEFT | DT_TOP | DT_EDITCONTROL | DT_NOPREFIX | DT_NOCLIP |
DT_EXPANDTABS | DT_WORDBREAK;
DrawTextW(hDC, szText, -1, &rcText, uFormat | DT_CALCRECT);
DrawText(hDC, szText, -1, &rcText, uFormat | DT_CALCRECT);
if (tm.tmDescent > 0)
rcText.bottom += tm.tmDescent;
ReleaseDC(hDC);
@@ -91,7 +91,7 @@ LRESULT CTextEditWindow::OnChar(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& b
if (wParam == VK_TAB)
return 0; // FIXME: Tabs
CStringW szText;
CString szText;
GetWindowText(szText);
LRESULT ret = DefWindowProc(nMsg, wParam, lParam);
@@ -104,11 +104,11 @@ LRESULT CTextEditWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
{
if (wParam == VK_ESCAPE)
{
toolsModel.OnEndDraw(TRUE);
toolsModel.OnCancelDraw();
return 0;
}
CStringW szText;
CString szText;
GetWindowText(szText);
LRESULT ret = DefWindowProc(nMsg, wParam, lParam);
@@ -135,7 +135,7 @@ LRESULT CTextEditWindow::OnEraseBkGnd(UINT nMsg, WPARAM wParam, LPARAM lParam, B
FillRect(hDC, &rc, hbr);
DeleteObject(hbr);
}
::SetTextColor(hDC, paletteModel.GetFgColor());
SetTextColor(hDC, paletteModel.GetFgColor());
return TRUE;
}
@@ -196,7 +196,7 @@ LRESULT CTextEditWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BO
UINT nHitTest = LOWORD(lParam);
if (nHitTest == HTCAPTION)
{
::SetCursor(::LoadCursorW(NULL, (LPCWSTR)IDC_SIZEALL)); // Enable drag move
::SetCursor(::LoadCursor(NULL, IDC_SIZEALL)); // Enable drag move
return FALSE;
}
return DefWindowProc(nMsg, wParam, lParam);
@@ -336,13 +336,13 @@ void CTextEditWindow::UpdateFont()
m_hFontZoomed = NULL;
}
LOGFONTW lf;
LOGFONT lf;
ZeroMemory(&lf, sizeof(lf));
lf.lfCharSet = DEFAULT_CHARSET; // registrySettings.CharSet; // Ignore
lf.lfWeight = (registrySettings.Bold ? FW_BOLD : FW_NORMAL);
lf.lfItalic = (BYTE)registrySettings.Italic;
lf.lfUnderline = (BYTE)registrySettings.Underline;
StringCchCopyW(lf.lfFaceName, _countof(lf.lfFaceName), registrySettings.strFontName);
lf.lfItalic = registrySettings.Italic;
lf.lfUnderline = registrySettings.Underline;
lstrcpyn(lf.lfFaceName, registrySettings.strFontName, _countof(lf.lfFaceName));
HDC hdc = GetDC();
if (hdc)
@@ -493,7 +493,7 @@ LRESULT CTextEditWindow::OnSizing(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
LRESULT CTextEditWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
return ::SendMessageW(GetParent(), nMsg, wParam, lParam);
return ::SendMessage(GetParent(), nMsg, wParam, lParam);
}
LRESULT CTextEditWindow::OnCut(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)

View File

@@ -17,7 +17,7 @@ public:
HWND Create(HWND hwndParent);
void DoFillBack(HWND hwnd, HDC hDC);
void FixEditPos(LPCWSTR pszOldText);
void FixEditPos(LPCTSTR pszOldText);
void InvalidateEditRect();
void UpdateFont();
BOOL GetEditRect(LPRECT prc) const;

View File

@@ -20,12 +20,12 @@ CPaintToolBar::ToolBarWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam
{
// We have to detect clicking on toolbar even if no change of pressed button
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
INT index = (INT)::SendMessageW(hwnd, TB_HITTEST, 0, (LPARAM)&pt);
INT index = (INT)::SendMessage(hwnd, TB_HITTEST, 0, (LPARAM)&pt);
if (index >= 0)
{
TBBUTTON button;
if (::SendMessageW(hwnd, TB_GETBUTTON, index, (LPARAM)&button))
::PostMessageW(::GetParent(hwnd), WM_COMMAND, button.idCommand, 0);
if (::SendMessage(hwnd, TB_GETBUTTON, index, (LPARAM)&button))
::PostMessage(::GetParent(hwnd), WM_COMMAND, button.idCommand, 0);
}
}
return ::CallWindowProc(oldWndProc, hwnd, uMsg, wParam, lParam);
@@ -34,34 +34,29 @@ CPaintToolBar::ToolBarWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam
BOOL CPaintToolBar::DoCreate(HWND hwndParent)
{
// NOTE: The horizontal line above the toolbar is hidden by CCS_NODIVIDER style.
RECT toolbarPos =
{
0, 0,
CX_TOOLBAR + 2 * GetSystemMetrics(SM_CXBORDER),
CY_TOOLBAR + 2 * GetSystemMetrics(SM_CYBORDER)
};
RECT toolbarPos = { 0, 0, CX_TOOLBAR, CY_TOOLBAR };
DWORD style = WS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN | CCS_VERT | CCS_NORESIZE |
TBSTYLE_TOOLTIPS | TBSTYLE_FLAT;
if (!CWindow::Create(TOOLBARCLASSNAMEW, hwndParent, toolbarPos, NULL, style))
if (!CWindow::Create(TOOLBARCLASSNAME, hwndParent, toolbarPos, NULL, style))
return FALSE;
HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 16, 0);
SendMessage(TB_SETIMAGELIST, 0, (LPARAM)hImageList);
HBITMAP hbmIcons = (HBITMAP)::LoadImageW(g_hinstExe, MAKEINTRESOURCEW(IDB_TOOLBARICONS),
IMAGE_BITMAP, 256, 16, 0);
HBITMAP hbmIcons = (HBITMAP)::LoadImage(g_hinstExe, MAKEINTRESOURCE(IDB_TOOLBARICONS),
IMAGE_BITMAP, 256, 16, 0);
ImageList_AddMasked(hImageList, hbmIcons, RGB(255, 0, 255));
::DeleteObject(hbmIcons);
SendMessage(TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
WCHAR szToolTip[30];
TCHAR szToolTip[30];
TBBUTTON tbbutton;
ZeroMemory(&tbbutton, sizeof(tbbutton));
tbbutton.fsStyle = TBSTYLE_CHECKGROUP;
for (INT i = 0; i < NUM_TOOLS; i++)
{
::LoadStringW(g_hinstExe, IDS_TOOLTIP1 + i, szToolTip, _countof(szToolTip));
::LoadString(g_hinstExe, IDS_TOOLTIP1 + i, szToolTip, _countof(szToolTip));
tbbutton.iString = (INT_PTR)szToolTip;
tbbutton.fsState = TBSTATE_ENABLED | ((i % 2 == 1) ? TBSTATE_WRAP : 0);
tbbutton.idCommand = ID_FREESEL + i;

View File

@@ -24,7 +24,7 @@ public:
class CToolBox : public CWindowImpl<CToolBox>
{
public:
DECLARE_WND_CLASS_EX(L"ToolBox", CS_DBLCLKS, COLOR_BTNFACE)
DECLARE_WND_CLASS_EX(_T("ToolBox"), CS_DBLCLKS, COLOR_BTNFACE)
BEGIN_MSG_MAP(CToolBox)
MESSAGE_HANDLER(WM_CREATE, OnCreate)

View File

@@ -21,10 +21,6 @@
#define MARGIN1 3
#define MARGIN2 2
#define MAX_ZOOM_TRACK 6
#define MIN_ZOOM_TRACK 0
#define DEFAULT_ZOOM_TRACK 3
static const BYTE s_AirRadius[4] = { 5, 8, 3, 12 };
CToolSettingsWindow toolSettingsWindow;
@@ -281,21 +277,18 @@ VOID CToolSettingsWindow::drawBox(HDC hdc, LPCRECT prc)
}
}
LRESULT CToolSettingsWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
LRESULT CToolSettingsWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, WINBOOL& bHandled)
{
/* preloading the draw transparent/nontransparent icons for later use */
m_hNontranspIcon = (HICON)LoadImageW(g_hinstExe, MAKEINTRESOURCEW(IDI_NONTRANSPARENT),
IMAGE_ICON, CX_TRANS_ICON, CY_TRANS_ICON, LR_DEFAULTCOLOR);
m_hTranspIcon = (HICON)LoadImageW(g_hinstExe, MAKEINTRESOURCEW(IDI_TRANSPARENT),
IMAGE_ICON, CX_TRANS_ICON, CY_TRANS_ICON, LR_DEFAULTCOLOR);
RECT trackbarZoomPos, rect2;
calculateTwoBoxes(trackbarZoomPos, rect2);
::InflateRect(&trackbarZoomPos, -1, -1);
m_hNontranspIcon = (HICON)LoadImage(g_hinstExe, MAKEINTRESOURCE(IDI_NONTRANSPARENT),
IMAGE_ICON, CX_TRANS_ICON, CY_TRANS_ICON, LR_DEFAULTCOLOR);
m_hTranspIcon = (HICON)LoadImage(g_hinstExe, MAKEINTRESOURCE(IDI_TRANSPARENT),
IMAGE_ICON, CX_TRANS_ICON, CY_TRANS_ICON, LR_DEFAULTCOLOR);
RECT trackbarZoomPos = {1, 1, 1 + 40, 1 + 64};
trackbarZoom.Create(TRACKBAR_CLASS, m_hWnd, trackbarZoomPos, NULL, WS_CHILD | TBS_VERT | TBS_AUTOTICKS);
trackbarZoom.SendMessage(TBM_SETRANGE, TRUE, MAKELPARAM(MIN_ZOOM_TRACK, MAX_ZOOM_TRACK));
trackbarZoom.SendMessage(TBM_SETPOS, TRUE, DEFAULT_ZOOM_TRACK);
trackbarZoom.SendMessage(TBM_SETRANGE, (WPARAM) TRUE, MAKELPARAM(0, 6));
trackbarZoom.SendMessage(TBM_SETPOS, (WPARAM) TRUE, (LPARAM) 3);
return 0;
}
@@ -308,30 +301,9 @@ LRESULT CToolSettingsWindow::OnDestroy(UINT nMsg, WPARAM wParam, LPARAM lParam,
LRESULT CToolSettingsWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
INT trackPos = MAX_ZOOM_TRACK - (INT)trackbarZoom.SendMessage(TBM_GETPOS, 0, 0);
canvasWindow.zoomTo(MIN_ZOOM << trackPos);
INT zoomRate = toolsModel.GetZoom();
CStringW strZoom;
if (zoomRate % 10 == 0)
strZoom.Format(L"%d%%", zoomRate / 10);
else
strZoom.Format(L"%d.%d%%", zoomRate / 10, zoomRate % 10);
::SendMessageW(g_hStatusBar, SB_SETTEXT, 1, (LPARAM)(LPCWSTR)strZoom);
OnToolsModelZoomChanged(nMsg, wParam, lParam, bHandled);
return 0;
}
LRESULT CToolSettingsWindow::OnNotify(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
NMHDR *pnmhdr = (NMHDR*)lParam;
if (pnmhdr->code == NM_CUSTOMDRAW)
if (!zoomTo(125 << trackbarZoom.SendMessage(TBM_GETPOS, 0, 0), 0, 0))
{
NMCUSTOMDRAW *pCustomDraw = (NMCUSTOMDRAW*)pnmhdr;
pCustomDraw->uItemState &= ~CDIS_FOCUS; // Do not draw the focus
OnToolsModelZoomChanged(nMsg, wParam, lParam, bHandled);
}
return 0;
}
@@ -358,7 +330,9 @@ LRESULT CToolSettingsWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BO
PAINTSTRUCT ps;
HDC hdc = BeginPaint(&ps);
if (toolsModel.GetActiveTool() != TOOL_ZOOM)
if (toolsModel.GetActiveTool() == TOOL_ZOOM)
::DrawEdge(hdc, &rect1, BDR_SUNKENOUTER, BF_RECT);
else
::DrawEdge(hdc, &rect1, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE);
if (toolsModel.GetActiveTool() >= TOOL_RECT)
@@ -484,7 +458,7 @@ LRESULT CToolSettingsWindow::OnToolsModelSettingsChanged(UINT nMsg, WPARAM wPara
LRESULT CToolSettingsWindow::OnToolsModelZoomChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
int tbPos = MIN_ZOOM_TRACK;
int tbPos = 0;
int tempZoom = toolsModel.GetZoom();
while (tempZoom > MIN_ZOOM)
@@ -492,7 +466,6 @@ LRESULT CToolSettingsWindow::OnToolsModelZoomChanged(UINT nMsg, WPARAM wParam, L
tbPos++;
tempZoom = tempZoom >> 1;
}
trackbarZoom.SendMessage(TBM_SETPOS, TRUE, MAX_ZOOM_TRACK - tbPos);
trackbarZoom.SendMessage(TBM_SETPOS, (WPARAM) TRUE, (LPARAM) tbPos);
return 0;
}

View File

@@ -10,14 +10,13 @@
class CToolSettingsWindow : public CWindowImpl<CToolSettingsWindow>
{
public:
DECLARE_WND_CLASS_EX(L"ToolSettings", CS_DBLCLKS, COLOR_BTNFACE)
DECLARE_WND_CLASS_EX(_T("ToolSettings"), CS_DBLCLKS, COLOR_BTNFACE)
BEGIN_MSG_MAP(CToolSettingsWindow)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
MESSAGE_HANDLER(WM_TOOLSMODELTOOLCHANGED, OnToolsModelToolChanged)
MESSAGE_HANDLER(WM_TOOLSMODELSETTINGSCHANGED, OnToolsModelSettingsChanged)
MESSAGE_HANDLER(WM_TOOLSMODELZOOMCHANGED, OnToolsModelZoomChanged)
@@ -44,7 +43,6 @@ private:
LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnNotify(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnToolsModelSettingsChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnToolsModelZoomChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

View File

@@ -22,20 +22,22 @@ ToolsModel::ToolsModel()
m_rubberRadius = 4;
m_transpBg = FALSE;
m_zoom = 1000;
ZeroMemory(&m_tools, sizeof(m_tools));
m_pToolObject = GetOrCreateTool(m_activeTool);
}
ToolsModel::~ToolsModel()
{
delete m_pToolObject;
m_pToolObject = NULL;
for (size_t i = 0; i < _countof(m_tools); ++i)
delete m_tools[i];
}
ToolBase *ToolsModel::GetOrCreateTool(TOOLTYPE nTool)
{
delete m_pToolObject;
m_pToolObject = ToolBase::createToolObject(nTool);
return m_pToolObject;
if (!m_tools[nTool])
m_tools[nTool] = ToolBase::createToolObject(nTool);
return m_tools[nTool];
}
BOOL ToolsModel::IsSelection() const
@@ -143,7 +145,7 @@ TOOLTYPE ToolsModel::GetOldActiveTool() const
void ToolsModel::SetActiveTool(TOOLTYPE nActiveTool)
{
OnEndDraw(FALSE);
OnFinishDraw();
selectionModel.Landing();
@@ -255,6 +257,63 @@ void ToolsModel::NotifyZoomChanged()
canvasWindow.SendMessage(WM_TOOLSMODELZOOMCHANGED);
}
void ToolsModel::OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
{
m_pToolObject->beginEvent();
g_ptStart.x = g_ptEnd.x = x;
g_ptStart.y = g_ptEnd.y = y;
m_pToolObject->OnButtonDown(bLeftButton, x, y, bDoubleClick);
m_pToolObject->endEvent();
}
void ToolsModel::OnMouseMove(BOOL bLeftButton, LONG x, LONG y)
{
m_pToolObject->beginEvent();
if (m_pToolObject->OnMouseMove(bLeftButton, x, y))
{
g_ptEnd.x = x;
g_ptEnd.y = y;
}
m_pToolObject->endEvent();
}
void ToolsModel::OnButtonUp(BOOL bLeftButton, LONG x, LONG y)
{
m_pToolObject->beginEvent();
if (m_pToolObject->OnButtonUp(bLeftButton, x, y))
{
g_ptEnd.x = x;
g_ptEnd.y = y;
}
m_pToolObject->endEvent();
}
void ToolsModel::OnCancelDraw()
{
ATLTRACE("ToolsModel::OnCancelDraw()\n");
m_pToolObject->beginEvent();
m_pToolObject->OnCancelDraw();
m_pToolObject->endEvent();
}
void ToolsModel::OnFinishDraw()
{
ATLTRACE("ToolsModel::OnFinishDraw()\n");
m_pToolObject->beginEvent();
m_pToolObject->OnFinishDraw();
m_pToolObject->endEvent();
}
void ToolsModel::OnDrawOverlayOnImage(HDC hdc)
{
m_pToolObject->OnDrawOverlayOnImage(hdc);
}
void ToolsModel::OnDrawOverlayOnCanvas(HDC hdc)
{
m_pToolObject->OnDrawOverlayOnCanvas(hdc);
}
void ToolsModel::resetTool()
{
m_pToolObject->reset();
@@ -267,3 +326,8 @@ void ToolsModel::selectAll()
OnMouseMove(TRUE, imageModel.GetWidth(), imageModel.GetHeight());
OnButtonUp(TRUE, imageModel.GetWidth(), imageModel.GetHeight());
}
void ToolsModel::SpecialTweak(BOOL bMinus)
{
m_pToolObject->OnSpecialTweak(bMinus);
}

View File

@@ -53,13 +53,14 @@ struct ToolBase
virtual BOOL OnMouseMove(BOOL bLeftButton, LONG& x, LONG& y) { return TRUE; }
virtual BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) { return TRUE; }
virtual void OnCancelDraw();
virtual void OnFinishDraw();
virtual void OnDrawOverlayOnImage(HDC hdc) { }
virtual void OnDrawOverlayOnCanvas(HDC hdc) { }
virtual void OnSpecialTweak(BOOL bMinus) { }
virtual void OnEndDraw(BOOL bCancel);
void beginEvent();
void endEvent();
void reset();
@@ -84,6 +85,7 @@ private:
int m_rubberRadius;
BOOL m_transpBg;
int m_zoom;
ToolBase* m_tools[TOOL_MAX + 1];
ToolBase *m_pToolObject;
ToolBase *GetOrCreateTool(TOOLTYPE nTool);
@@ -133,7 +135,8 @@ public:
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick);
void OnMouseMove(BOOL bLeftButton, LONG x, LONG y);
void OnButtonUp(BOOL bLeftButton, LONG x, LONG y);
void OnEndDraw(BOOL bCancel);
void OnCancelDraw();
void OnFinishDraw();
void OnDrawOverlayOnImage(HDC hdc);
void OnDrawOverlayOnCanvas(HDC hdc);
@@ -145,8 +148,6 @@ public:
void NotifyZoomChanged();
void SpecialTweak(BOOL bMinus);
void DrawWithMouseTool(POINT pt, WPARAM wParam);
};
extern ToolsModel toolsModel;

View File

@@ -29,7 +29,7 @@ static HWND DoHtmlHelpW(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_P
{
// The function loads the system library, not local
GetSystemDirectoryW(szPath, _countof(szPath));
StringCchCatW(szPath, _countof(szPath), L"\\hhctrl.ocx");
wcscat(szPath, L"\\hhctrl.ocx");
s_hHHCTRL_OCX = LoadLibraryW(szPath);
if (s_hHHCTRL_OCX)
s_pHtmlHelpW = (FN_HtmlHelpW)GetProcAddress(s_hHHCTRL_OCX, "HtmlHelpW");
@@ -41,6 +41,37 @@ static HWND DoHtmlHelpW(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_P
return s_pHtmlHelpW(hwndCaller, pszFile, uCommand, dwData);
}
BOOL
zoomTo(int newZoom, int mouseX, int mouseY)
{
int x, y, w, h;
RECT clientRectScrollbox;
canvasWindow.GetClientRect(&clientRectScrollbox);
RECT clientRectImageArea;
::SetRect(&clientRectImageArea, 0, 0, imageModel.GetWidth(), imageModel.GetHeight());
Zoomed(clientRectImageArea);
w = clientRectImageArea.right * newZoom / toolsModel.GetZoom();
h = clientRectImageArea.bottom * newZoom / toolsModel.GetZoom();
if (!w || !h)
{
return FALSE;
}
w = clientRectImageArea.right * clientRectScrollbox.right / w;
h = clientRectImageArea.bottom * clientRectScrollbox.bottom / h;
x = max(0, min(clientRectImageArea.right - w, mouseX - w / 2)) * newZoom / toolsModel.GetZoom();
y = max(0, min(clientRectImageArea.bottom - h, mouseY - h / 2)) * newZoom / toolsModel.GetZoom();
toolsModel.SetZoom(newZoom);
canvasWindow.Invalidate(TRUE);
canvasWindow.SendMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, x), 0);
canvasWindow.SendMessage(WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, y), 0);
return TRUE;
}
void CMainWindow::alignChildrenToMainWindow()
{
RECT clientRect, rc;
@@ -144,11 +175,11 @@ void CMainWindow::InsertSelectionFromHBITMAP(HBITMAP bitmap, HWND window)
if (g_askBeforeEnlarging)
{
WCHAR programname[20];
WCHAR shouldEnlargePromptText[100];
TCHAR programname[20];
TCHAR shouldEnlargePromptText[100];
::LoadStringW(g_hinstExe, IDS_PROGRAMNAME, programname, _countof(programname));
::LoadStringW(g_hinstExe, IDS_ENLARGEPROMPTTEXT, shouldEnlargePromptText, _countof(shouldEnlargePromptText));
LoadString(g_hinstExe, IDS_PROGRAMNAME, programname, _countof(programname));
LoadString(g_hinstExe, IDS_ENLARGEPROMPTTEXT, shouldEnlargePromptText, _countof(shouldEnlargePromptText));
switch (MessageBox(shouldEnlargePromptText, programname, MB_YESNOCANCEL | MB_ICONQUESTION))
{
@@ -185,20 +216,20 @@ LRESULT CMainWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
{
INT zDelta = (SHORT)HIWORD(wParam);
if (::GetKeyState(VK_CONTROL) < 0) // Ctrl+Wheel
if (::GetAsyncKeyState(VK_CONTROL) < 0)
{
if (zDelta < 0)
{
if (toolsModel.GetZoom() > MIN_ZOOM)
canvasWindow.zoomTo(toolsModel.GetZoom() / 2);
zoomTo(toolsModel.GetZoom() / 2, 0, 0);
}
else if (zDelta > 0)
{
if (toolsModel.GetZoom() < MAX_ZOOM)
canvasWindow.zoomTo(toolsModel.GetZoom() * 2);
zoomTo(toolsModel.GetZoom() * 2, 0, 0);
}
}
else // Wheel only
else
{
UINT nCount = 3;
if (::GetAsyncKeyState(VK_SHIFT) < 0)
@@ -233,7 +264,7 @@ LRESULT CMainWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
LRESULT CMainWindow::OnDropFiles(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
WCHAR droppedfile[MAX_PATH];
TCHAR droppedfile[MAX_PATH];
HDROP hDrop = (HDROP)wParam;
DragQueryFile(hDrop, 0, droppedfile, _countof(droppedfile));
@@ -247,14 +278,14 @@ LRESULT CMainWindow::OnDropFiles(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
LRESULT CMainWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
// Loading and setting the window menu from resource
m_hMenu = ::LoadMenuW(g_hinstExe, MAKEINTRESOURCEW(ID_MENU));
m_hMenu = ::LoadMenu(g_hinstExe, MAKEINTRESOURCE(ID_MENU));
SetMenu(m_hMenu);
// Create the status bar
DWORD style = SBARS_SIZEGRIP | WS_CHILD | (registrySettings.ShowStatusBar ? WS_VISIBLE : 0);
g_hStatusBar = ::CreateWindowExW(0, STATUSCLASSNAME, NULL, style, 0, 0, 0, 0, m_hWnd,
NULL, g_hinstExe, NULL);
::SendMessageW(g_hStatusBar, SB_SETMINHEIGHT, 21, 0);
g_hStatusBar = ::CreateWindowEx(0, STATUSCLASSNAME, NULL, style, 0, 0, 0, 0, m_hWnd,
NULL, g_hinstExe, NULL);
::SendMessage(g_hStatusBar, SB_SETMINHEIGHT, 21, 0);
// Create the tool box
toolBoxContainer.DoCreate(m_hWnd);
@@ -276,8 +307,8 @@ LRESULT CMainWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHa
}
// Set icon
SendMessage(WM_SETICON, ICON_BIG, (LPARAM)::LoadIconW(g_hinstExe, MAKEINTRESOURCEW(IDI_APPICON)));
SendMessage(WM_SETICON, ICON_SMALL, (LPARAM)::LoadIconW(g_hinstExe, MAKEINTRESOURCEW(IDI_APPICON)));
SendMessage(WM_SETICON, ICON_BIG, (LPARAM) LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON)));
SendMessage(WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON)));
return 0;
}
@@ -314,10 +345,10 @@ BOOL CMainWindow::ConfirmSave()
if (imageModel.IsImageSaved())
return TRUE;
CStringW strProgramName;
CString strProgramName;
strProgramName.LoadString(IDS_PROGRAMNAME);
CStringW strSavePromptText;
CString strSavePromptText;
strSavePromptText.Format(IDS_SAVEPROMPTTEXT, PathFindFileName(g_szFileName));
switch (MessageBox(strSavePromptText, strProgramName, MB_YESNOCANCEL | MB_ICONQUESTION))
@@ -345,11 +376,11 @@ LRESULT CMainWindow::OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHan
void CMainWindow::ProcessFileMenu(HMENU hPopupMenu)
{
LPCWSTR dotext = PathFindExtensionW(g_szFileName);
LPCTSTR dotext = PathFindExtensionW(g_szFileName);
BOOL isBMP = FALSE;
if (_wcsicmp(dotext, L".bmp") == 0 ||
_wcsicmp(dotext, L".dib") == 0 ||
_wcsicmp(dotext, L".rle") == 0)
if (_tcsicmp(dotext, _T(".bmp")) == 0 ||
_tcsicmp(dotext, _T(".dib")) == 0 ||
_tcsicmp(dotext, _T(".rle")) == 0)
{
isBMP = TRUE;
}
@@ -371,7 +402,7 @@ void CMainWindow::ProcessFileMenu(HMENU hPopupMenu)
for (INT iItem = 0; iItem < MAX_RECENT_FILES; ++iItem)
{
CStringW& strFile = registrySettings.strFiles[iItem];
CString& strFile = registrySettings.strFiles[iItem];
if (strFile.IsEmpty())
break;
@@ -379,11 +410,11 @@ void CMainWindow::ProcessFileMenu(HMENU hPopupMenu)
#define MAX_RECENT_PATHNAME_DISPLAY 30
CPath pathFile(strFile);
pathFile.CompactPathEx(MAX_RECENT_PATHNAME_DISPLAY);
assert(wcslen((LPCWSTR)pathFile) <= MAX_RECENT_PATHNAME_DISPLAY);
assert(_tcslen((LPCTSTR)pathFile) <= MAX_RECENT_PATHNAME_DISPLAY);
// Add an accelerator (by '&') to the item number for quick access
WCHAR szText[4 + MAX_RECENT_PATHNAME_DISPLAY + 1];
StringCchPrintfW(szText, _countof(szText), L"&%u %s", iItem + 1, (LPCWSTR)pathFile);
TCHAR szText[4 + MAX_RECENT_PATHNAME_DISPLAY + 1];
wsprintf(szText, _T("&%u %s"), iItem + 1, (LPCTSTR)pathFile);
INT iMenuItem = (cMenuItems - 2) + iItem;
InsertMenu(hPopupMenu, iMenuItem, MF_BYPOSITION | MF_STRING, IDM_FILE1 + iItem, szText);
@@ -489,8 +520,8 @@ LRESULT CMainWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHand
int test[] = { LOWORD(lParam) - 260, LOWORD(lParam) - 140, LOWORD(lParam) - 20 };
if (::IsWindow(g_hStatusBar))
{
::SendMessageW(g_hStatusBar, WM_SIZE, 0, 0);
::SendMessageW(g_hStatusBar, SB_SETPARTS, 3, (LPARAM)&test);
::SendMessage(g_hStatusBar, WM_SIZE, 0, 0);
::SendMessage(g_hStatusBar, SB_SETPARTS, 3, (LPARAM)&test);
}
alignChildrenToMainWindow();
return 0;
@@ -516,7 +547,7 @@ LRESULT CMainWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
if (canvasWindow.m_hWnd == hwndCapture ||
fullscreenWindow.m_hWnd == hwndCapture)
{
::SendMessageW(hwndCapture, nMsg, wParam, lParam);
::SendMessage(hwndCapture, nMsg, wParam, lParam);
}
}
else if (selectionModel.m_bShow)
@@ -551,7 +582,7 @@ LRESULT CMainWindow::OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, B
{
/* Redirect message to common controls */
HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL);
::SendMessageW(hToolbar, WM_SYSCOLORCHANGE, 0, 0);
SendMessage(hToolbar, WM_SYSCOLORCHANGE, 0, 0);
return 0;
}
@@ -569,11 +600,12 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
{
case IDM_HELPINFO:
{
WCHAR infotitle[100], infotext[200];
::LoadStringW(g_hinstExe, IDS_INFOTITLE, infotitle, _countof(infotitle));
::LoadStringW(g_hinstExe, IDS_INFOTEXT, infotext, _countof(infotext));
::ShellAboutW(m_hWnd, infotitle, infotext,
LoadIconW(g_hinstExe, MAKEINTRESOURCEW(IDI_APPICON)));
TCHAR infotitle[100];
TCHAR infotext[200];
LoadString(g_hinstExe, IDS_INFOTITLE, infotitle, _countof(infotitle));
LoadString(g_hinstExe, IDS_INFOTEXT, infotext, _countof(infotext));
ShellAbout(m_hWnd, infotitle, infotext,
LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON)));
break;
}
case IDM_HELPHELPTOPICS:
@@ -590,7 +622,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
break;
case IDM_FILEOPEN:
{
WCHAR szFileName[MAX_LONG_PATH] = L"";
TCHAR szFileName[MAX_LONG_PATH] = _T("");
if (ConfirmSave() && GetOpenFileName(szFileName, _countof(szFileName)))
{
DoLoadImageFile(m_hWnd, szFileName, TRUE);
@@ -627,7 +659,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
pd.nMaxPage = 0xffff;
if (PrintDlg(&pd) == TRUE)
{
::BitBlt(pd.hDC, 0, 0, imageModel.GetWidth(), imageModel.GetHeight(), imageModel.GetDC(), 0, 0, SRCCOPY);
BitBlt(pd.hDC, 0, 0, imageModel.GetWidth(), imageModel.GetHeight(), imageModel.GetDC(), 0, 0, SRCCOPY);
DeleteDC(pd.hDC);
}
if (pd.hDevMode)
@@ -719,13 +751,14 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
selectionModel.TakeOff();
{
HBITMAP hbmCopy = selectionModel.GetSelectionContents();
HGLOBAL hGlobal = BitmapToClipboardDIB(hbmCopy);
if (hGlobal)
::SetClipboardData(CF_DIB, hGlobal);
else
ShowOutOfMemory();
::DeleteObject(hbmCopy);
HBITMAP hbmLocked = selectionModel.LockBitmap();
if (hbmLocked)
{
HGLOBAL hGlobal = BitmapToClipboardDIB(hbmLocked);
if (hGlobal)
::SetClipboardData(CF_DIB, hGlobal);
selectionModel.UnlockBitmap(hbmLocked);
}
}
CloseClipboard();
@@ -794,7 +827,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
// Failed to paste
{
CStringW strText, strTitle;
CString strText, strTitle;
strText.LoadString(IDS_CANTPASTE);
strTitle.LoadString(IDS_PROGRAMNAME);
MessageBox(strText, strTitle, MB_ICONINFORMATION);
@@ -832,25 +865,19 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
break;
}
HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL);
::SendMessageW(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELPARAM(TRUE, 0));
SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELPARAM(TRUE, 0));
toolsModel.selectAll();
canvasWindow.Invalidate(TRUE);
break;
}
case IDM_EDITCOPYTO:
{
WCHAR szFileName[MAX_LONG_PATH];
::LoadStringW(g_hinstExe, IDS_DEFAULTFILENAME, szFileName, _countof(szFileName));
WCHAR szFileName[MAX_LONG_PATH] = L"*.png";
if (GetSaveFileName(szFileName, _countof(szFileName)))
{
HBITMAP hbmSelection = selectionModel.GetSelectionContents();
if (!hbmSelection)
{
ShowOutOfMemory();
break;
}
SaveDIBToFile(hbmSelection, szFileName, FALSE);
DeleteObject(hbmSelection);
HBITMAP hbmLocked = selectionModel.LockBitmap();
SaveDIBToFile(hbmLocked, szFileName, FALSE);
selectionModel.UnlockBitmap(hbmLocked);
}
break;
}
@@ -894,7 +921,6 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
case IDM_IMAGEROTATEMIRROR:
{
CWaitCursor waitCursor;
canvasWindow.updateScrollPos();
switch (mirrorRotateDialog.DoModal(mainWindow.m_hWnd))
{
case 1: /* flip horizontally */
@@ -947,8 +973,8 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
CWaitCursor waitCursor;
if (attributesDialog.m_bBlackAndWhite && !imageModel.IsBlackAndWhite())
{
CStringW strText(MAKEINTRESOURCEW(IDS_LOSECOLOR));
CStringW strTitle(MAKEINTRESOURCEW(IDS_PROGRAMNAME));
CString strText(MAKEINTRESOURCE(IDS_LOSECOLOR));
CString strTitle(MAKEINTRESOURCE(IDS_PROGRAMNAME));
INT id = MessageBox(strText, strTitle, MB_ICONINFORMATION | MB_YESNOCANCEL);
if (id != IDYES)
break;
@@ -986,12 +1012,9 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
toolsModel.SetBackgroundTransparent(!toolsModel.IsBackgroundTransparent());
break;
case IDM_IMAGECROP:
{
HBITMAP hbmCopy = selectionModel.GetSelectionContents();
imageModel.PushImageForUndo(hbmCopy);
imageModel.PushImageForUndo(selectionModel.CopyBitmap());
selectionModel.HideSelection();
break;
}
case IDM_VIEWTOOLBOX:
registrySettings.ShowToolBox = !toolBoxContainer.IsWindowVisible();
toolBoxContainer.ShowWindow(registrySettings.ShowToolBox ? SW_SHOWNOACTIVATE : SW_HIDE);
@@ -1030,25 +1053,25 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
break;
case IDM_VIEWZOOM125:
canvasWindow.zoomTo(125);
zoomTo(125, 0, 0);
break;
case IDM_VIEWZOOM25:
canvasWindow.zoomTo(250);
zoomTo(250, 0, 0);
break;
case IDM_VIEWZOOM50:
canvasWindow.zoomTo(500);
zoomTo(500, 0, 0);
break;
case IDM_VIEWZOOM100:
canvasWindow.zoomTo(1000);
zoomTo(1000, 0, 0);
break;
case IDM_VIEWZOOM200:
canvasWindow.zoomTo(2000);
zoomTo(2000, 0, 0);
break;
case IDM_VIEWZOOM400:
canvasWindow.zoomTo(4000);
zoomTo(4000, 0, 0);
break;
case IDM_VIEWZOOM800:
canvasWindow.zoomTo(8000);
zoomTo(8000, 0, 0);
break;
case IDM_VIEWFULLSCREEN:

View File

@@ -11,7 +11,7 @@
class CMainWindow : public CWindowImpl<CMainWindow>
{
public:
DECLARE_WND_CLASS_EX(L"MSPaintApp", CS_DBLCLKS, COLOR_BTNFACE)
DECLARE_WND_CLASS_EX(_T("MSPaintApp"), CS_DBLCLKS, COLOR_BTNFACE)
BEGIN_MSG_MAP(CMainWindow)
MESSAGE_HANDLER(WM_DROPFILES, OnDropFiles)
@@ -30,8 +30,8 @@ public:
CMainWindow() : m_hMenu(NULL) { }
HWND DoCreate();
BOOL GetOpenFileName(IN OUT LPWSTR pszFile, INT cchMaxFile);
BOOL GetSaveFileName(IN OUT LPWSTR pszFile, INT cchMaxFile);
BOOL GetOpenFileName(IN OUT LPTSTR pszFile, INT cchMaxFile);
BOOL GetSaveFileName(IN OUT LPTSTR pszFile, INT cchMaxFile);
BOOL ChooseColor(IN OUT COLORREF *prgbColor);
VOID TrackPopupMenu(POINT ptScreen, INT iSubMenu);
BOOL CanUndo() const;

View File

@@ -16,12 +16,12 @@ BEGIN
GROUPBOX "Gestiune conexiuni", IDC_STATIC, 7, 103, 228, 65
ICON "", IDC_LOGONICON, 15, 19, 20, 20
LTEXT "Introduceți adresa unui servitor.", IDC_STATIC, 47, 24, 121, 8
LTEXT "Server:", IDC_STATIC, 47, 41, 35, 8
LTEXT "Servitor:", IDC_STATIC, 47, 41, 35, 8
LTEXT "Nume utilizator:", IDC_STATIC, 47, 58, 58, 8
COMBOBOX IDC_SERVERCOMBO, 101, 39, 119, 13, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
EDITTEXT IDC_NAMEEDIT, 101, 55, 119, 14, WS_TABSTOP | ES_AUTOHSCROLL
PUSHBUTTON "S&alvează", IDC_SAVE, 57, 139, 50, 14
PUSHBUTTON "Sal&vează ca…", IDC_SAVEAS, 112, 139, 60, 14
PUSHBUTTON "&Păstrează", IDC_SAVE, 57, 139, 50, 14
PUSHBUTTON "Păst&rare în…", IDC_SAVEAS, 112, 139, 60, 14
PUSHBUTTON "&Deschidere…", IDC_OPEN, 177, 139, 50, 14
ICON "", IDC_CONNICON, 16, 114, 20, 20
LTEXT "Puteți păstra preferințele curente de conectare sau puteți deschide preferințe existente.", IDC_STATIC, 50, 115, 172, 20

View File

@@ -154,7 +154,7 @@ BEGIN
STRING_TEXT_FILES_TXT "Словесни файлове (*.txt)"
STRING_TOOLARGE "Файлът '%s' е твърде голям за бележника.\n\
Използвайте друг обработчик."
STRING_NOTEXT "Не сте въвел текст.\
STRING_NOTEXT "Не сте въвел текст. \
\nНапишете нещо и опитайте пак."
STRING_DOESNOTEXIST "Файлът '%s'\nне съществува\n\n\
Искате ли да създадете нов файл?"

View File

@@ -154,14 +154,14 @@ BEGIN
STRING_TEXT_FILES_TXT "Textové soubory (*.txt)"
STRING_TOOLARGE "Soubor '%s' je pro notepad příliš velký.\n\
Použijte jiný editor, prosím."
STRING_NOTEXT "Nebyl zadán žádný text.\
STRING_NOTEXT "Nebyl zadán žádný text. \
\nVložte nějaký text a zkuste to znovu."
STRING_DOESNOTEXIST "Soubor '%s'\nneexistuje.\n\n\
Chcete ho vytvořit?"
Chcete ho vytvořit ?"
STRING_NOTSAVED "Soubor '%s'\nbyl změněn.\n\n\
Chcete uložit změny?"
Chcete uložit změny ?"
STRING_NOTFOUND "'%s' nebyl nalezen."
STRING_OUT_OF_MEMORY "Není dost paměti na dokončení této úlohy.\
STRING_OUT_OF_MEMORY "Není dost paměti na dokončení této úlohy. \
\nUzavřete jednu či více aplikací, abyste získali více\nvolné \
paměti."
STRING_CANNOTFIND "Nelze nalézt '%s'"

View File

@@ -152,9 +152,9 @@ BEGIN
STRING_UNTITLED "Ikke-navngivet"
STRING_ALL_FILES "Alle filer (*.*)"
STRING_TEXT_FILES_TXT "Tekst filer (*.txt)"
STRING_TOOLARGE "Filen '%s' er for stor til Notesblok.\
STRING_TOOLARGE "Filen '%s' er for stor til Notesblok. \
\nBrug en anden editor til at redigere filen."
STRING_NOTEXT "Du har ikke skrevet noget tekst.\
STRING_NOTEXT "Du har ikke skrevet noget tekst. \
\nSkriv noget tekst, og prøv så igen"
STRING_DOESNOTEXIST "Filen '%s'\neksistere ikke\n\n\
Ønkser du at oprette en ny fil?"

Some files were not shown because too many files have changed in this diff Show More