mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 00:43:11 +00:00
[MSPAINT] Allow paletteWindow to be bottom-aligned (#5216)
The user will be able to move the palette window to bottom by dragging. - Add Bar1ID registry setting. - Move paletteWindow to top or bottom in mainWindow's WM_SIZE handling. - Track the mouse dragging on paletteWindow. - If the dragging is beyond the center point, then move paletteWindow. CORE-18867
This commit is contained in:
parent
ccef43f3b0
commit
d0c657074d
6 changed files with 74 additions and 6 deletions
|
@ -132,6 +132,7 @@ LRESULT CPaletteWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, B
|
||||||
INT iColor = DoHitTest(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
INT iColor = DoHitTest(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||||
if (iColor != -1)
|
if (iColor != -1)
|
||||||
paletteModel.SetFgColor(paletteModel.GetColor(iColor));
|
paletteModel.SetFgColor(paletteModel.GetColor(iColor));
|
||||||
|
SetCapture();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,3 +179,36 @@ LRESULT CPaletteWindow::OnPaletteModelPaletteChanged(UINT nMsg, WPARAM wParam, L
|
||||||
InvalidateRect(NULL, FALSE);
|
InvalidateRect(NULL, FALSE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LRESULT CPaletteWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
if (::GetCapture() != m_hWnd)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
||||||
|
ClientToScreen(&pt);
|
||||||
|
|
||||||
|
RECT rc;
|
||||||
|
mainWindow.GetWindowRect(&rc);
|
||||||
|
|
||||||
|
POINT ptCenter = { (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2 };
|
||||||
|
|
||||||
|
DWORD dwExpectedBar1ID = ((pt.y < ptCenter.y) ? BAR1ID_TOP : BAR1ID_BOTTOM);
|
||||||
|
|
||||||
|
if (registrySettings.Bar1ID != dwExpectedBar1ID)
|
||||||
|
{
|
||||||
|
registrySettings.Bar1ID = dwExpectedBar1ID;
|
||||||
|
mainWindow.PostMessage(WM_SIZE, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CPaletteWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
if (::GetCapture() != m_hWnd)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
::ReleaseCapture();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ public:
|
||||||
MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown)
|
MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown)
|
||||||
MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk)
|
MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk)
|
||||||
MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnRButtonDblClk)
|
MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnRButtonDblClk)
|
||||||
|
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
|
||||||
|
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
|
||||||
MESSAGE_HANDLER(WM_PALETTEMODELCOLORCHANGED, OnPaletteModelColorChanged)
|
MESSAGE_HANDLER(WM_PALETTEMODELCOLORCHANGED, OnPaletteModelColorChanged)
|
||||||
MESSAGE_HANDLER(WM_PALETTEMODELPALETTECHANGED, OnPaletteModelPaletteChanged)
|
MESSAGE_HANDLER(WM_PALETTEMODELPALETTECHANGED, OnPaletteModelPaletteChanged)
|
||||||
END_MSG_MAP()
|
END_MSG_MAP()
|
||||||
|
@ -34,6 +36,8 @@ public:
|
||||||
LRESULT OnRButtonDown(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 OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnRButtonDblClk(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 OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnPaletteModelPaletteChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnPaletteModelPaletteChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,7 @@ void RegistrySettings::LoadPresets(INT nCmdShow)
|
||||||
ShowStatusBar = TRUE;
|
ShowStatusBar = TRUE;
|
||||||
ShowPalette = TRUE;
|
ShowPalette = TRUE;
|
||||||
ShowToolBox = TRUE;
|
ShowToolBox = TRUE;
|
||||||
|
Bar1ID = BAR1ID_TOP;
|
||||||
Bar2ID = BAR2ID_LEFT;
|
Bar2ID = BAR2ID_LEFT;
|
||||||
|
|
||||||
LOGFONT lf;
|
LOGFONT lf;
|
||||||
|
@ -142,6 +143,12 @@ void RegistrySettings::Load(INT nCmdShow)
|
||||||
ReadString(text, _T("TypeFaceName"), strFontName, strFontName);
|
ReadString(text, _T("TypeFaceName"), strFontName, strFontName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CRegKey bar1;
|
||||||
|
if (bar1.Open(paint, _T("General-Bar1"), KEY_READ) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
ReadDWORD(bar1, _T("BarID"), Bar1ID);
|
||||||
|
}
|
||||||
|
|
||||||
CRegKey bar2;
|
CRegKey bar2;
|
||||||
if (bar2.Open(paint, _T("General-Bar2"), KEY_READ) == ERROR_SUCCESS)
|
if (bar2.Open(paint, _T("General-Bar2"), KEY_READ) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -220,6 +227,12 @@ void RegistrySettings::Store()
|
||||||
text.SetStringValue(_T("TypeFaceName"), strFontName);
|
text.SetStringValue(_T("TypeFaceName"), strFontName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CRegKey bar1;
|
||||||
|
if (bar1.Create(paint, _T("General-Bar1")) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
bar1.SetDWORDValue(_T("BarID"), Bar1ID);
|
||||||
|
}
|
||||||
|
|
||||||
CRegKey bar2;
|
CRegKey bar2;
|
||||||
if (bar2.Create(paint, _T("General-Bar2")) == ERROR_SUCCESS)
|
if (bar2.Create(paint, _T("General-Bar2")) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,8 +43,14 @@ public:
|
||||||
DWORD ShowStatusBar;
|
DWORD ShowStatusBar;
|
||||||
DWORD ShowPalette;
|
DWORD ShowPalette;
|
||||||
DWORD ShowToolBox;
|
DWORD ShowToolBox;
|
||||||
|
DWORD Bar1ID;
|
||||||
DWORD Bar2ID;
|
DWORD Bar2ID;
|
||||||
|
|
||||||
|
// Values for Bar1ID.
|
||||||
|
// I think these values are Win2k3 mspaint compatible but sometimes not working...
|
||||||
|
#define BAR1ID_TOP 0x0000e81b
|
||||||
|
#define BAR1ID_BOTTOM 0x0000e81e
|
||||||
|
|
||||||
// Values for Bar2ID.
|
// Values for Bar2ID.
|
||||||
// I think these values are Win2k3 mspaint compatible but sometimes not working...
|
// I think these values are Win2k3 mspaint compatible but sometimes not working...
|
||||||
#define BAR2ID_LEFT 0x0000e81c
|
#define BAR2ID_LEFT 0x0000e81c
|
||||||
|
|
|
@ -147,7 +147,7 @@ LRESULT CToolBox::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHa
|
||||||
RECT rc;
|
RECT rc;
|
||||||
mainWindow.GetWindowRect(&rc);
|
mainWindow.GetWindowRect(&rc);
|
||||||
|
|
||||||
POINT ptCenter = { (rc.left + rc.right) / 2, (rc.bottom - rc.top) / 2 };
|
POINT ptCenter = { (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2 };
|
||||||
|
|
||||||
DWORD dwExpectedBar2ID = ((pt.x < ptCenter.x) ? BAR2ID_LEFT : BAR2ID_RIGHT);
|
DWORD dwExpectedBar2ID = ((pt.x < ptCenter.x) ? BAR2ID_LEFT : BAR2ID_RIGHT);
|
||||||
|
|
||||||
|
|
|
@ -108,11 +108,22 @@ void CMainWindow::alignChildrenToMainWindow()
|
||||||
|
|
||||||
if (::IsWindowVisible(paletteWindow))
|
if (::IsWindowVisible(paletteWindow))
|
||||||
{
|
{
|
||||||
hDWP = ::DeferWindowPos(hDWP, paletteWindow, NULL,
|
if (registrySettings.Bar1ID == BAR1ID_BOTTOM)
|
||||||
rcSpace.left, rcSpace.top,
|
{
|
||||||
rcSpace.right - rcSpace.left, CY_PALETTE,
|
hDWP = ::DeferWindowPos(hDWP, paletteWindow, NULL,
|
||||||
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREPOSITION);
|
rcSpace.left, rcSpace.bottom - CY_PALETTE,
|
||||||
rcSpace.top += CY_PALETTE;
|
rcSpace.right - rcSpace.left, CY_PALETTE,
|
||||||
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREPOSITION);
|
||||||
|
rcSpace.bottom -= CY_PALETTE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hDWP = ::DeferWindowPos(hDWP, paletteWindow, NULL,
|
||||||
|
rcSpace.left, rcSpace.top,
|
||||||
|
rcSpace.right - rcSpace.left, CY_PALETTE,
|
||||||
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREPOSITION);
|
||||||
|
rcSpace.top += CY_PALETTE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canvasWindow.IsWindow())
|
if (canvasWindow.IsWindow())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue