[MSPAINT] Some minor improvements (#4264)
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Mon, 10 Jan 2022 12:44:13 +0000 (21:44 +0900)
committerGitHub <noreply@github.com>
Mon, 10 Jan 2022 12:44:13 +0000 (21:44 +0900)
- Fix Japanese IDS_MINIATURETITLE resource string.
- Fix Japanese IDM_VIEWSHOWMINIATURE menu item text.
- Fix DWORD as COLORREF.
- Improve some OnPaint's.
CORE-17969

base/applications/mspaint/drawing.cpp
base/applications/mspaint/drawing.h
base/applications/mspaint/imgarea.cpp
base/applications/mspaint/lang/ja-JP.rc
base/applications/mspaint/palette.cpp
base/applications/mspaint/selection.cpp
base/applications/mspaint/selection.h
base/applications/mspaint/toolsettings.cpp

index d7453ff..0595592 100644 (file)
@@ -246,7 +246,7 @@ RectSel(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2)
 }
 
 void
-SelectionFrame(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, DWORD system_selection_color)
+SelectionFrame(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF system_selection_color)
 {
     HBRUSH oldBrush;
     LOGBRUSH logbrush;
index 737d035..017b71f 100644 (file)
@@ -32,6 +32,6 @@ 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 SelectionFrame(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, DWORD system_selection_color);
+void SelectionFrame(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF system_selection_color);
 
 void Text(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LPCTSTR lpchText, HFONT font, LONG style);
index 6c11759..cfa9a84 100644 (file)
@@ -143,8 +143,10 @@ LRESULT CImgAreaWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& b
         DeleteObject(SelectObject(hdc, oldPen));
     }
     EndPaint(&ps);
-    selectionWindow.Invalidate(FALSE);
-    miniature.Invalidate(FALSE);
+    if (selectionWindow.IsWindowVisible())
+        selectionWindow.Invalidate(FALSE);
+    if (miniature.IsWindowVisible())
+        miniature.Invalidate(FALSE);
     if (textEditWindow.IsWindowVisible())
         textEditWindow.Invalidate(FALSE);
     return 0;
index 02fa632..8da4c05 100644 (file)
@@ -71,7 +71,7 @@ BEGIN
             END
             MENUITEM SEPARATOR
             MENUITEM "グリッドを表示(&G)\tCtrl+G", IDM_VIEWSHOWGRID
-            MENUITEM "実寸表示(&H)", IDM_VIEWSHOWMINIATURE
+            MENUITEM "縮小表示(&H)", IDM_VIEWSHOWMINIATURE
         END
         MENUITEM "全画面表示(&F)\tCtrl+F", IDM_VIEWFULLSCREEN
     END
@@ -212,7 +212,7 @@ BEGIN
     IDS_INFOTEXT "GNU Lesser General Public License (LGPL, 詳細は www.gnu.org) の下で利用可能です。"
     IDS_SAVEPROMPTTEXT "%s の変更内容を保存しますか?"
     IDS_DEFAULTFILENAME "無題"
-    IDS_MINIATURETITLE "縮小"
+    IDS_MINIATURETITLE "縮小表示"
     IDS_TOOLTIP1 "自由選択"
     IDS_TOOLTIP2 "選択"
     IDS_TOOLTIP3 "消しゴム"
index c83dad8..9667397 100644 (file)
 LRESULT CPaletteWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
     RECT rc = { 0, 0, 31, 32 };
-    HDC hDC = GetDC();
     HPEN oldPen;
     HBRUSH oldBrush;
     int i, a, b;
 
     DefWindowProc(WM_PAINT, wParam, lParam);
 
+    HDC hDC = GetDC();
     for(b = 2; b < 30; b++)
         for(a = 2; a < 29; a++)
             if ((a + b) % 2 == 1)
index 90bcbde..c2c3288 100644 (file)
@@ -22,7 +22,9 @@ const LPCTSTR CSelectionWindow::m_lpszCursorLUT[9] = { /* action to mouse cursor
 };
 
 BOOL
-ColorKeyedMaskBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, HBITMAP hbmMask, int xMask, int yMask, DWORD dwRop, COLORREF keyColor)
+ColorKeyedMaskBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight,
+                  HDC hdcSrc, int nXSrc, int nYSrc, HBITMAP hbmMask, int xMask, int yMask,
+                  DWORD dwRop, COLORREF keyColor)
 {
     HDC hTempDC;
     HDC hTempDC2;
@@ -88,13 +90,14 @@ int CSelectionWindow::IdentifyCorner(int iXPos, int iYPos, int iWidth, int iHeig
 
 LRESULT CSelectionWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
+    DefWindowProc(WM_PAINT, wParam, lParam);
     if (!m_bMoving)
     {
         HDC hDC = GetDC();
-        DefWindowProc(WM_PAINT, wParam, lParam);
-        SelectionFrame(hDC, 1, 1, Zoomed(selectionModel.GetDestRectWidth()) + 5,
-                       Zoomed(selectionModel.GetDestRectHeight()) + 5,
-                       m_dwSystemSelectionColor);
+        SelectionFrame(hDC, 1, 1,
+                       Zoomed(selectionModel.GetDestRectWidth()) + (GRIP_SIZE * 2) - 1,
+                       Zoomed(selectionModel.GetDestRectHeight()) + (GRIP_SIZE * 2) - 1,
+                       GetSysColor(COLOR_HIGHLIGHT));
         ReleaseDC(hDC);
     }
     return 0;
@@ -103,7 +106,7 @@ LRESULT CSelectionWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
 LRESULT CSelectionWindow::OnEraseBkgnd(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
     // do nothing => transparent background
-    return 0;
+    return TRUE;
 }
 
 LRESULT CSelectionWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
@@ -111,16 +114,14 @@ LRESULT CSelectionWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
     m_bMoving = FALSE;
     m_iAction = ACTION_MOVE;
     /* update the system selection color */
-    m_dwSystemSelectionColor = GetSysColor(COLOR_HIGHLIGHT);
-    SendMessage(WM_PAINT, 0, MAKELPARAM(0, 0));
+    Invalidate();
     return 0;
 }
 
 LRESULT CSelectionWindow::OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
     /* update the system selection color */
-    m_dwSystemSelectionColor = GetSysColor(COLOR_HIGHLIGHT);
-    SendMessage(WM_PAINT, 0, MAKELPARAM(0, 0));
+    Invalidate();
     return 0;
 }
 
index 4dcd554..82ba84a 100644 (file)
@@ -55,7 +55,6 @@ private:
     POINT m_ptPos;
     POINT m_ptFrac;
     POINT m_ptDelta;
-    DWORD m_dwSystemSelectionColor;
 
     int IdentifyCorner(int iXPos, int iYPos, int iWidth, int iHeight);
 };
index 4639d81..0c3d3e0 100644 (file)
@@ -33,12 +33,12 @@ LRESULT CToolSettingsWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam,
 
 LRESULT CToolSettingsWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
-    HDC hdc = GetDC();
     RECT rect1 = { 0, 0, 42, 66 };
     RECT rect2 = { 0, 70, 42, 136 };
 
     DefWindowProc(WM_PAINT, wParam, lParam);
 
+    HDC hdc = GetDC();
     DrawEdge(hdc, &rect1, BDR_SUNKENOUTER, (toolsModel.GetActiveTool() == TOOL_ZOOM) ? BF_RECT : BF_RECT | BF_MIDDLE);
     DrawEdge(hdc, &rect2, (toolsModel.GetActiveTool() >= TOOL_RECT) ? BDR_SUNKENOUTER : 0, BF_RECT | BF_MIDDLE);
     switch (toolsModel.GetActiveTool())