ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
February 2024
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
17 participants
128 discussions
Start a n
N
ew thread
[reactos] 01/01: [MSCTFIME][CICERO] Implement CDefCompFrameWindow (#6512)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a55345be298e4f7ab4521…
commit a55345be298e4f7ab452109c77bf8b97e9e3ad18 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Wed Feb 21 10:36:32 2024 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Feb 21 10:36:32 2024 +0900 [MSCTFIME][CICERO] Implement CDefCompFrameWindow (#6512) Supporting TIPs... JIRA issue: CORE-19360 - Add delay link to uxtheme.dll. - Implement CDefCompFrameGripper, CCompFinalizeButton, CCompButtonFrameWindow, and CDefCompFrameWindow classes. --- dll/ime/msctfime/CMakeLists.txt | 2 +- dll/ime/msctfime/msctfime.h | 1 + dll/ime/msctfime/ui.cpp | 322 ++++++++++++++++++++++++++++++++++++++++ dll/ime/msctfime/ui.h | 95 ++++++++++++ sdk/lib/cicero/cicuif.cpp | 8 +- sdk/lib/cicero/cicuif.h | 4 +- 6 files changed, 425 insertions(+), 7 deletions(-) diff --git a/dll/ime/msctfime/CMakeLists.txt b/dll/ime/msctfime/CMakeLists.txt index 288c14afc7f..3a48a7cbabb 100644 --- a/dll/ime/msctfime/CMakeLists.txt +++ b/dll/ime/msctfime/CMakeLists.txt @@ -26,5 +26,5 @@ set_module_type(msctfime win32dll UNICODE) set_target_properties(msctfime PROPERTIES SUFFIX ".ime") target_link_libraries(msctfime wine uuid cicero) add_importlibs(msctfime user32 gdi32 advapi32 msvcrt kernel32 ntdll) -add_delay_importlibs(msctfime comctl32 msctf oleaut32 imm32) +add_delay_importlibs(msctfime uxtheme comctl32 msctf oleaut32 imm32) add_cd_file(TARGET msctfime DESTINATION reactos/system32 FOR all) diff --git a/dll/ime/msctfime/msctfime.h b/dll/ime/msctfime/msctfime.h index f7ada8fbd6e..7b2f2fff822 100644 --- a/dll/ime/msctfime/msctfime.h +++ b/dll/ime/msctfime/msctfime.h @@ -28,6 +28,7 @@ #include <cicarray.h> #include <cicimc.h> #include <cictf.h> +#include <cicreg.h> #include <ciccaret.h> #include <cicuif.h> #include <cicutb.h> diff --git a/dll/ime/msctfime/ui.cpp b/dll/ime/msctfime/ui.cpp index 74a8c733de0..660d20824d6 100644 --- a/dll/ime/msctfime/ui.cpp +++ b/dll/ime/msctfime/ui.cpp @@ -9,6 +9,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(msctfime); +/***********************************************************************/ + UINT WM_MSIME_SERVICE = 0; UINT WM_MSIME_UIREADY = 0; UINT WM_MSIME_RECONVERTREQUEST = 0; @@ -61,6 +63,326 @@ BOOL RegisterMSIMEMessage(VOID) WM_MSIME_KEYMAP); } +/***********************************************************************/ + +/// @implemented +CDefCompFrameGripper::CDefCompFrameGripper( + CDefCompFrameWindow *pDefCompFrameWindow, + LPCRECT prc, + DWORD style) : CUIFGripper(pDefCompFrameWindow, prc, style) +{ + m_pDefCompFrameWindow = pDefCompFrameWindow; +} + +/***********************************************************************/ + +/// @implemented +CCompFinalizeButton::CCompFinalizeButton( + CCompFrameWindow *pParent, + DWORD nObjectID, + LPCRECT prc, + DWORD style, + DWORD dwButtonFlags, + LPCWSTR pszText) + : CUIFToolbarButton(pParent, nObjectID, prc, style, dwButtonFlags, pszText) +{ + m_pCompFrameWindow = pParent; +} + +/// @implemented +CCompFinalizeButton::~CCompFinalizeButton() +{ + HICON hIcon = CUIFToolbarButton::GetIcon(); + if (hIcon) + { + ::DestroyIcon(hIcon); + CUIFToolbarButton::SetIcon(NULL); + } +} + +/// @implemented +void CCompFinalizeButton::OnLeftClick() +{ + HIMC hIMC = m_pCompFrameWindow->m_hIMC; + if (hIMC) + ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0); +} + +/***********************************************************************/ + +/// @implemented +CCompFrameWindow::CCompFrameWindow(HIMC hIMC, DWORD style) + : CUIFWindow(g_hInst, style) +{ + m_hIMC = hIMC; +} + +/***********************************************************************/ + +/// @implemented +CCompButtonFrameWindow::CCompButtonFrameWindow(HIMC hIMC, DWORD style) + : CCompFrameWindow(hIMC, style) +{ +} + +/// @implemented +void CCompButtonFrameWindow::Init() +{ + if (m_pFinalizeButton) + return; + + RECT rc = { 0, 0, 0, 0 }; + m_pFinalizeButton = new(cicNoThrow) CCompFinalizeButton(this, 0, &rc, 0, 0x10000, NULL); + + m_pFinalizeButton->Initialize(); + m_pFinalizeButton->Init(); + + HICON hIcon = (HICON)::LoadImageW(g_hInst, MAKEINTRESOURCEW(IDI_DOWN), IMAGE_ICON, 16, 16, 0); + m_pFinalizeButton->SetIcon(hIcon); + + WCHAR szText[256]; + LoadStringW(g_hInst, IDS_FINALIZE_STRING, szText, _countof(szText)); + m_pFinalizeButton->SetToolTip(szText); + + AddUIObj(m_pFinalizeButton); +} + +/// @implemented +void CCompButtonFrameWindow::MoveShow(LONG x, LONG y, BOOL bShow) +{ + INT nWidth = m_Margins.cxRightWidth + m_Margins.cxLeftWidth + 18; + INT nHeight = m_Margins.cyBottomHeight + m_Margins.cyTopHeight + 18; + Move(x, y, nWidth + 4, nHeight + 4); + + if (m_pFinalizeButton) + { + RECT rc = { 1, 1, nWidth + 1, nHeight + 1 }; + m_pFinalizeButton->SetRect(&rc); + } + + Show(bShow); +} + +/// @implemented +STDMETHODIMP_(void) CCompButtonFrameWindow::OnCreate(HWND hWnd) +{ + ::SetWindowTheme(hWnd, L"TOOLBAR", NULL); + + ZeroMemory(&m_Margins, sizeof(m_Margins)); + + CUIFTheme theme; + theme.m_hTheme = NULL; + theme.m_iPartId = 1; + theme.m_iStateId = 0; + theme.m_pszClassList = L"TOOLBAR"; + if (SUCCEEDED(theme.InternalOpenThemeData(hWnd))) + theme.GetThemeMargins(NULL, 1, 3602, NULL, &m_Margins); +} + +/***********************************************************************/ + +/// @implemented +CDefCompFrameWindow::CDefCompFrameWindow(HIMC hIMC, DWORD style) + : CCompFrameWindow(hIMC, style) +{ + LoadPosition(); + m_iPartId = 1; + m_iStateId = 1; + m_pszClassList = L"TASKBAR"; +} + +/// @implemented +CDefCompFrameWindow::~CDefCompFrameWindow() +{ + SavePosition(); +} + +/// @implemented +void CDefCompFrameWindow::Init() +{ + RECT rc; + + if (!m_pGripper) + { + ZeroMemory(&rc, sizeof(rc)); + m_pGripper = new(cicNoThrow) CDefCompFrameGripper(this, &rc, 0); + m_pGripper->Initialize(); + AddUIObj(m_pGripper); + } + + if (!m_pFinalizeButton) + { + ZeroMemory(&rc, sizeof(rc)); + m_pFinalizeButton = new(cicNoThrow) CCompFinalizeButton(this, 0, &rc, 0, 0x10000, NULL); + m_pFinalizeButton->Initialize(); + m_pFinalizeButton->Init(); + + HICON hIcon = (HICON)LoadImageW(g_hInst, MAKEINTRESOURCEW(IDI_DOWN), IMAGE_ICON, 16, 16, 0); + m_pFinalizeButton->SetIcon(hIcon); + + WCHAR szText[256]; + ::LoadStringW(g_hInst, IDS_FINALIZE_STRING, szText, _countof(szText)); + SetToolTip(szText); + + AddUIObj(m_pFinalizeButton); + } +} + +/// @implemented +INT CDefCompFrameWindow::GetGripperWidth() +{ + if (!m_pGripper || FAILED(m_pGripper->EnsureThemeData(m_hWnd))) + return 5; + + INT ret = -1; + HDC hDC = ::GetDC(m_hWnd); + SIZE partSize; + if (SUCCEEDED(m_pGripper->GetThemePartSize(hDC, 1, 0, TS_TRUE, &partSize))) + ret = partSize.cx + 4; + + ::ReleaseDC(m_hWnd, hDC); + + return ((ret < 0) ? 5 : ret); +} + +/// @implemented +void CDefCompFrameWindow::MyScreenToClient(LPPOINT ppt, LPRECT prc) +{ + if (ppt) + ::ScreenToClient(m_hWnd, ppt); + + if (prc) + { + ::ScreenToClient(m_hWnd, (LPPOINT)prc); + ::ScreenToClient(m_hWnd, (LPPOINT)&prc->right); + } +} + +/// @implemented +void CDefCompFrameWindow::SetCompStrRect(INT nWidth, INT nHeight, BOOL bShow) +{ + INT GripperWidth = GetGripperWidth(); + + RECT rc; + ::GetWindowRect(m_hWnd, &rc); + + Move(rc.left, rc.top, GripperWidth + nWidth + 24, nHeight + 10); + + if (m_pGripper) + { + rc = { 2, 3, GripperWidth + 2, nHeight + 7 }; + m_pGripper->SetRect(&rc); + } + + if (m_pFinalizeButton) + { + rc = { + GripperWidth + nWidth + 4, + 3, + m_Margins.cxLeftWidth + m_Margins.cxRightWidth + GripperWidth + nWidth + 22, + m_Margins.cyBottomHeight + m_Margins.cyTopHeight + 21 + }; + m_pFinalizeButton->SetRect(&rc); + } + + Show(bShow); + + ::MoveWindow(m_hwndDefCompFrame, GripperWidth + 2, 7, nWidth, nHeight, TRUE); + ::ShowWindow(m_hwndDefCompFrame, (bShow ? SW_SHOWNOACTIVATE : SW_HIDE)); +} + +/// @implemented +void CDefCompFrameWindow::LoadPosition() +{ + DWORD x = 0, y = 0; + + LSTATUS error; + CicRegKey regKey; + error = regKey.Open(HKEY_CURRENT_USER, + TEXT("SOFTWARE\\Microsoft\\CTF\\CUAS\\DefaultCompositionWindow")); + if (error == ERROR_SUCCESS) + { + regKey.QueryDword(TEXT("Left"), &x); + regKey.QueryDword(TEXT("Top"), &y); + } + + Move(x, y, 0, 0); +} + +/// @implemented +void CDefCompFrameWindow::SavePosition() +{ + LSTATUS error; + CicRegKey regKey; + error = regKey.Create(HKEY_CURRENT_USER, + TEXT("SOFTWARE\\Microsoft\\CTF\\CUAS\\DefaultCompositionWindow")); + if (error == ERROR_SUCCESS) + { + regKey.SetDword(TEXT("Left"), m_nLeft); + regKey.SetDword(TEXT("Top"), m_nTop); + } +} + +/// @implemented +STDMETHODIMP_(void) CDefCompFrameWindow::OnCreate(HWND hWnd) +{ + ::SetWindowTheme(hWnd, L"TASKBAR", NULL); + + ZeroMemory(&m_Margins, sizeof(m_Margins)); + + CUIFTheme theme; + theme.m_hTheme = NULL; + theme.m_iPartId = 1; + theme.m_iStateId = 0; + theme.m_pszClassList = L"TOOLBAR"; + if (SUCCEEDED(theme.InternalOpenThemeData(hWnd))) + GetThemeMargins(NULL, 1, 3602, NULL, &m_Margins); +} + +/// @implemented +STDMETHODIMP_(BOOL) CDefCompFrameWindow::OnSetCursor(UINT uMsg, LONG x, LONG y) +{ + if (!::IsWindow(m_hwndDefCompFrame)) + return FALSE; + + RECT rc; + ::GetWindowRect(m_hwndDefCompFrame, &rc); + MyScreenToClient(NULL, &rc); + POINT pt = { x, y }; + return ::PtInRect(&rc, pt); +} + +/// @implemented +STDMETHODIMP_(LRESULT) +CDefCompFrameWindow::OnWindowPosChanged(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + CicIMCLock imcLock(m_hIMC); + if (!imcLock) + imcLock.m_hr = E_FAIL; + if (SUCCEEDED(imcLock.m_hr)) + ::SendMessage(imcLock.get().hWnd, WM_IME_NOTIFY, 0xF, (LPARAM)m_hIMC); + return ::DefWindowProc(hWnd, uMsg, wParam, lParam); +} + +/// @implemented +STDMETHODIMP_(void) CDefCompFrameWindow::HandleMouseMsg(UINT uMsg, LONG x, LONG y) +{ + if (::IsWindow(m_hwndDefCompFrame)) + { + RECT rc; + ::GetWindowRect(m_hwndDefCompFrame, &rc); + MyScreenToClient(NULL, &rc); + + POINT pt = { x, y }; + if (::PtInRect(&rc, pt)) + ::SendMessage(m_hwndDefCompFrame, 0x7E8, 0, 0); + } + + CUIFWindow::HandleMouseMsg(uMsg, x, y); +} + +/***********************************************************************/ + // For GetWindowLongPtr/SetWindowLongPtr #define UIGWLP_HIMC 0 #define UIGWLP_UI sizeof(HIMC) diff --git a/dll/ime/msctfime/ui.h b/dll/ime/msctfime/ui.h index e9433fc734c..71b32ebb40d 100644 --- a/dll/ime/msctfime/ui.h +++ b/dll/ime/msctfime/ui.h @@ -7,6 +7,15 @@ #pragma once +class CUIFGripper; + class CDefCompFrameGripper; +class CUIFToolbarButton; + class CCompFinalizeButton; +class CUIFWindow; + class CCompFrameWindow; + class CCompButtonFrameWindow; + class CDefCompFrameWindow; + /***********************************************************************/ extern UINT WM_MSIME_SERVICE; @@ -25,6 +34,92 @@ BOOL RegisterMSIMEMessage(VOID); /***********************************************************************/ +class CDefCompFrameGripper : public CUIFGripper +{ +public: + CDefCompFrameWindow *m_pDefCompFrameWindow; + + CDefCompFrameGripper(CDefCompFrameWindow *pDefCompFrameWindow, LPCRECT prc, DWORD style); +}; + +/***********************************************************************/ + +class CCompFrameWindow; + +class CCompFinalizeButton : public CUIFToolbarButton +{ +public: + CCompFrameWindow *m_pCompFrameWindow; + + CCompFinalizeButton( + CCompFrameWindow *pParent, + DWORD nObjectID, + LPCRECT prc, + DWORD style, + DWORD dwButtonFlags, + LPCWSTR pszText); + ~CCompFinalizeButton() override; + + STDMETHOD_(void, OnLeftClick)() override; +}; + +/***********************************************************************/ + +class CCompFrameWindow : public CUIFWindow +{ +public: + HIMC m_hIMC; + + CCompFrameWindow(HIMC hIMC, DWORD style); +}; + +/***********************************************************************/ + +class CCompButtonFrameWindow : public CCompFrameWindow +{ +public: + MARGINS m_Margins; + CCompFinalizeButton *m_pFinalizeButton; + + CCompButtonFrameWindow(HIMC hIMC, DWORD style); + + void Init(); + void MoveShow(LONG x, LONG y, BOOL bShow); + + STDMETHOD_(void, OnCreate)(HWND hWnd) override; +}; + +/***********************************************************************/ + +class CDefCompFrameWindow : public CCompFrameWindow +{ +public: + HWND m_hwndDefCompFrame; + CDefCompFrameGripper *m_pGripper; + CCompFinalizeButton *m_pFinalizeButton; + MARGINS m_Margins; + +public: + CDefCompFrameWindow(HIMC hIMC, DWORD style); + ~CDefCompFrameWindow() override; + + void Init(); + INT GetGripperWidth(); + void MyScreenToClient(LPPOINT ppt, LPRECT prc); + void SetCompStrRect(INT nWidth, INT nHeight, BOOL bShow); + + void LoadPosition(); + void SavePosition(); + + STDMETHOD_(void, OnCreate)(HWND hWnd) override; + STDMETHOD_(BOOL, OnSetCursor)(UINT uMsg, LONG x, LONG y) override; + STDMETHOD_(LRESULT, OnWindowPosChanged)(HWND hWnd, UINT uMsg, WPARAM wParam, + LPARAM lParam) override; + STDMETHOD_(void, HandleMouseMsg)(UINT uMsg, LONG x, LONG y) override; +}; + +/***********************************************************************/ + struct UIComposition { void OnImeStartComposition(CicIMCLock& imcLock, HWND hUIWnd); diff --git a/sdk/lib/cicero/cicuif.cpp b/sdk/lib/cicero/cicuif.cpp index 322058e1ad3..3ef832053a9 100644 --- a/sdk/lib/cicero/cicuif.cpp +++ b/sdk/lib/cicero/cicuif.cpp @@ -3409,7 +3409,7 @@ STDMETHODIMP_(void) CUIFToolbarMenuButton::OnLButtonUp(LONG x, LONG y) { CUIFButton::OnLButtonUp(x, y); - m_pToolbarButton->OnUnknownMouse2(x, y); + m_pToolbarButton->OnUnknownMouse0(); } STDMETHODIMP_(BOOL) @@ -3444,16 +3444,16 @@ CUIFToolbarButtonElement::OnLButtonUp(LONG x, LONG y) { CUIFButton::OnLButtonUp(x, y); if ((m_pToolbarButton->m_dwToolbarButtonFlags & 0x30000) == 0x20000) - m_pToolbarButton->OnUnknownMouse2(x, y); + m_pToolbarButton->OnUnknownMouse0(); else - m_pToolbarButton->OnUnknownMouse1(x, y); + m_pToolbarButton->OnLeftClick(); } STDMETHODIMP_(void) CUIFToolbarButtonElement::OnRButtonUp(LONG x, LONG y) { if ((m_pToolbarButton->m_dwToolbarButtonFlags & 0x30000) != 0x20000) - m_pToolbarButton->OnUnknownMouse0(); + m_pToolbarButton->OnRightClick(); } ///////////////////////////////////////////////////////////////////////////// diff --git a/sdk/lib/cicero/cicuif.h b/sdk/lib/cicero/cicuif.h index e01518cb05d..6ec4f1deeb3 100644 --- a/sdk/lib/cicero/cicuif.h +++ b/sdk/lib/cicero/cicuif.h @@ -928,8 +928,8 @@ public: STDMETHOD_(void, SetToolTip)(LPCWSTR pszToolTip) override; STDMETHOD_(void, OnUnknownMouse0)() { } - STDMETHOD_(void, OnUnknownMouse1)(LONG x, LONG y) { } - STDMETHOD_(void, OnUnknownMouse2)(LONG x, LONG y) { } + STDMETHOD_(void, OnLeftClick)() { } + STDMETHOD_(void, OnRightClick)() { } }; /////////////////////////////////////////////////////////////////////////////
10 months, 1 week
1
0
0
0
[reactos] 01/01: [SETUPLIB][USETUP] Some cleanup for partition code.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b7ad4a2298edc0c232e00…
commit b7ad4a2298edc0c232e001c1662205dad022578f Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Thu Dec 7 23:29:28 2023 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Tue Feb 20 15:52:37 2024 +0100 [SETUPLIB][USETUP] Some cleanup for partition code. - Make the Create*Partition helpers take a size in bytes, not in sectors. This allows them to be easier to use by the caller, alleviating the need for making the size conversion into sectors. Instead it is done internally by the helpers. - Introduce helper macros to easily retrieve the size of a partition entry or a disk in bytes, from their internal representation in number of sectors. - The 'AutoCreate' variable being USETUP-specific, remove it from the PARTENTRY structure and use instead a flag set into the 'New' member. - Rename IsDiskSizeValid to IsPartitionLargeEnough, to better describe what the function is for. --- base/setup/lib/utils/osdetect.c | 6 +- base/setup/lib/utils/partlist.c | 104 ++++++++++++++++--------------- base/setup/lib/utils/partlist.h | 18 ++++-- base/setup/usetup/partlist.c | 4 +- base/setup/usetup/usetup.c | 134 ++++++++++++++++++++-------------------- 5 files changed, 139 insertions(+), 127 deletions(-) diff --git a/base/setup/lib/utils/osdetect.c b/base/setup/lib/utils/osdetect.c index 0ee246c60b1..cc45fa907c2 100644 --- a/base/setup/lib/utils/osdetect.c +++ b/base/setup/lib/utils/osdetect.c @@ -806,12 +806,11 @@ CreateNTOSInstallationsList( ASSERT(PartEntry->DiskEntry == DiskEntry); - DPRINT(" Primary Partition #%d, index %d - Type 0x%02x, IsLogical = %s, IsPartitioned = %s, IsNew = %s, AutoCreate = %s, FormatState = %lu -- Should I check it? %s\n", + DPRINT(" Primary Partition #%d, index %d - Type 0x%02x, IsLogical = %s, IsPartitioned = %s, IsNew = %s, FormatState = %lu -- Should I check it? %s\n", PartEntry->PartitionNumber, PartEntry->PartitionIndex, PartEntry->PartitionType, PartEntry->LogicalPartition ? "TRUE" : "FALSE", PartEntry->IsPartitioned ? "TRUE" : "FALSE", PartEntry->New ? "Yes" : "No", - PartEntry->AutoCreate ? "Yes" : "No", PartEntry->FormatState, ShouldICheckThisPartition(PartEntry) ? "YES!" : "NO!"); @@ -828,12 +827,11 @@ CreateNTOSInstallationsList( ASSERT(PartEntry->DiskEntry == DiskEntry); - DPRINT(" Logical Partition #%d, index %d - Type 0x%02x, IsLogical = %s, IsPartitioned = %s, IsNew = %s, AutoCreate = %s, FormatState = %lu -- Should I check it? %s\n", + DPRINT(" Logical Partition #%d, index %d - Type 0x%02x, IsLogical = %s, IsPartitioned = %s, IsNew = %s, FormatState = %lu -- Should I check it? %s\n", PartEntry->PartitionNumber, PartEntry->PartitionIndex, PartEntry->PartitionType, PartEntry->LogicalPartition ? "TRUE" : "FALSE", PartEntry->IsPartitioned ? "TRUE" : "FALSE", PartEntry->New ? "Yes" : "No", - PartEntry->AutoCreate ? "Yes" : "No", PartEntry->FormatState, ShouldICheckThisPartition(PartEntry) ? "YES!" : "NO!"); diff --git a/base/setup/lib/utils/partlist.c b/base/setup/lib/utils/partlist.c index 49c15e9ffe2..6bb16fed9d4 100644 --- a/base/setup/lib/utils/partlist.c +++ b/base/setup/lib/utils/partlist.c @@ -552,7 +552,7 @@ IsSuperFloppy( } /* The partition lengths should agree */ - PartitionLengthEstimate = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector; + PartitionLengthEstimate = GetDiskSizeInBytes(DiskEntry); if (PartitionInfo->PartitionLength.QuadPart != PartitionLengthEstimate) { DPRINT1("PartitionLength = %I64u is different from PartitionLengthEstimate = %I64u\n", @@ -676,26 +676,46 @@ CreateInsertBlankRegion( static BOOLEAN InitializePartitionEntry( - IN OUT PPARTENTRY PartEntry, - IN ULONGLONG SectorCount, - IN BOOLEAN AutoCreate) + _Inout_ PPARTENTRY PartEntry, + _In_opt_ ULONGLONG SizeBytes) { PDISKENTRY DiskEntry = PartEntry->DiskEntry; + ULONGLONG SectorCount; + + DPRINT1("Current entry sector count: %I64u\n", PartEntry->SectorCount.QuadPart); - DPRINT1("Current partition sector count: %I64u\n", PartEntry->SectorCount.QuadPart); + /* The entry must not be already partitioned and not be void */ + ASSERT(!PartEntry->IsPartitioned); + ASSERT(PartEntry->SectorCount.QuadPart); + + /* Convert the size in bytes to sector count. SizeBytes being + * zero means the caller wants to use all the empty space. */ + if ((SizeBytes == 0) || (SizeBytes == GetPartEntrySizeInBytes(PartEntry))) + { + /* Use all of the unpartitioned disk space */ + SectorCount = PartEntry->SectorCount.QuadPart; + } + else + { + SectorCount = SizeBytes / DiskEntry->BytesPerSector; + if (SectorCount == 0) + { + /* SizeBytes was certainly less than the minimal size, so fail */ + DPRINT1("Partition size %I64u too small\n", SizeBytes); + return FALSE; + } + } + DPRINT1(" New sector count: %I64u\n", SectorCount); - /* Fail if we try to initialize this partition entry with more sectors than what it actually contains */ + /* Fail if we request more sectors than what the entry actually contains */ if (SectorCount > PartEntry->SectorCount.QuadPart) return FALSE; - /* Fail if the partition is already in use */ - ASSERT(!PartEntry->IsPartitioned); - - if ((AutoCreate != FALSE) || + if ((SectorCount == 0) || (AlignDown(PartEntry->StartSector.QuadPart + SectorCount, DiskEntry->SectorAlignment) - PartEntry->StartSector.QuadPart == PartEntry->SectorCount.QuadPart)) { - PartEntry->AutoCreate = AutoCreate; + /* Reuse the whole current entry */ } else { @@ -703,7 +723,8 @@ InitializePartitionEntry( ULONGLONG SectorCount2; PPARTENTRY NewPartEntry; - /* Create a partition entry that represents the remaining space after the partition to be initialized */ + /* Create a partition entry that represents the remaining space + * after the partition to be initialized */ StartSector = AlignDown(PartEntry->StartSector.QuadPart + SectorCount, DiskEntry->SectorAlignment); SectorCount2 = PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - StartSector; @@ -735,7 +756,6 @@ InitializePartitionEntry( PartEntry->FormatState = Unformatted; PartEntry->FileSystem[0] = L'\0'; - // PartEntry->AutoCreate = AutoCreate; PartEntry->BootIndicator = FALSE; DPRINT1("First Sector : %I64u\n", PartEntry->StartSector.QuadPart); @@ -2390,37 +2410,24 @@ GetPrevPartition( return NULL; } -// static -FORCEINLINE +static inline BOOLEAN IsEmptyLayoutEntry( - IN PPARTITION_INFORMATION PartitionInfo) + _In_ PPARTITION_INFORMATION PartitionInfo) { - if (PartitionInfo->StartingOffset.QuadPart == 0 && - PartitionInfo->PartitionLength.QuadPart == 0) - { - return TRUE; - } - - return FALSE; + return (PartitionInfo->StartingOffset.QuadPart == 0 && + PartitionInfo->PartitionLength.QuadPart == 0); } -// static -FORCEINLINE +static inline BOOLEAN IsSamePrimaryLayoutEntry( - IN PPARTITION_INFORMATION PartitionInfo, - IN PDISKENTRY DiskEntry, - IN PPARTENTRY PartEntry) + _In_ PPARTITION_INFORMATION PartitionInfo, + _In_ PPARTENTRY PartEntry) { - if (PartitionInfo->StartingOffset.QuadPart == PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector && - PartitionInfo->PartitionLength.QuadPart == PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) + return ((PartitionInfo->StartingOffset.QuadPart == GetPartEntryOffsetInBytes(PartEntry)) && + (PartitionInfo->PartitionLength.QuadPart == GetPartEntrySizeInBytes(PartEntry))); // PartitionInfo->PartitionType == PartEntry->PartitionType - { - return TRUE; - } - - return FALSE; } static @@ -2578,12 +2585,12 @@ UpdateDiskLayout( PartEntry->OnDiskPartitionNumber = (!IsContainerPartition(PartEntry->PartitionType) ? PartitionNumber : 0); - if (!IsSamePrimaryLayoutEntry(PartitionInfo, DiskEntry, PartEntry)) + if (!IsSamePrimaryLayoutEntry(PartitionInfo, PartEntry)) { DPRINT1("Updating primary partition entry %lu\n", Index); - PartitionInfo->StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector; - PartitionInfo->PartitionLength.QuadPart = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector; + PartitionInfo->StartingOffset.QuadPart = GetPartEntryOffsetInBytes(PartEntry); + PartitionInfo->PartitionLength.QuadPart = GetPartEntrySizeInBytes(PartEntry); PartitionInfo->HiddenSectors = PartEntry->StartSector.LowPart; PartitionInfo->PartitionNumber = PartEntry->PartitionNumber; PartitionInfo->PartitionType = PartEntry->PartitionType; @@ -2624,8 +2631,8 @@ UpdateDiskLayout( DPRINT1("Updating logical partition entry %lu\n", Index); - PartitionInfo->StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector; - PartitionInfo->PartitionLength.QuadPart = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector; + PartitionInfo->StartingOffset.QuadPart = GetPartEntryOffsetInBytes(PartEntry); + PartitionInfo->PartitionLength.QuadPart = GetPartEntrySizeInBytes(PartEntry); PartitionInfo->HiddenSectors = DiskEntry->SectorAlignment; PartitionInfo->PartitionNumber = PartEntry->PartitionNumber; PartitionInfo->PartitionType = PartEntry->PartitionType; @@ -2862,12 +2869,11 @@ BOOLEAN CreatePartition( _In_ PPARTLIST List, _Inout_ PPARTENTRY PartEntry, - _In_ ULONGLONG SectorCount, - _In_ BOOLEAN AutoCreate) + _In_opt_ ULONGLONG SizeBytes) { ERROR_NUMBER Error; - DPRINT1("CreatePartition(%I64u)\n", SectorCount); + DPRINT1("CreatePartition(%I64u bytes)\n", SizeBytes); if (List == NULL || PartEntry == NULL || PartEntry->DiskEntry == NULL || PartEntry->IsPartitioned) @@ -2883,7 +2889,7 @@ CreatePartition( } /* Initialize the partition entry, inserting a new blank region if needed */ - if (!InitializePartitionEntry(PartEntry, SectorCount, AutoCreate)) + if (!InitializePartitionEntry(PartEntry, SizeBytes)) return FALSE; UpdateDiskLayout(PartEntry->DiskEntry); @@ -2924,11 +2930,11 @@ BOOLEAN CreateExtendedPartition( _In_ PPARTLIST List, _Inout_ PPARTENTRY PartEntry, - _In_ ULONGLONG SectorCount) + _In_opt_ ULONGLONG SizeBytes) { ERROR_NUMBER Error; - DPRINT1("CreateExtendedPartition(%I64u)\n", SectorCount); + DPRINT1("CreateExtendedPartition(%I64u bytes)\n", SizeBytes); if (List == NULL || PartEntry == NULL || PartEntry->DiskEntry == NULL || PartEntry->IsPartitioned) @@ -2944,7 +2950,7 @@ CreateExtendedPartition( } /* Initialize the partition entry, inserting a new blank region if needed */ - if (!InitializePartitionEntry(PartEntry, SectorCount, FALSE)) + if (!InitializePartitionEntry(PartEntry, SizeBytes)) return FALSE; ASSERT(PartEntry->LogicalPartition == FALSE); @@ -3933,7 +3939,7 @@ SetMountedDeviceValues( /* Assign a "\DosDevices\#:" mount point to this partition */ if (PartEntry->DriveLetter) { - StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector; + StartingOffset.QuadPart = GetPartEntryOffsetInBytes(PartEntry); if (!SetMountedDeviceValue(PartEntry->DriveLetter, DiskEntry->LayoutBuffer->Signature, StartingOffset)) @@ -3956,7 +3962,7 @@ SetMountedDeviceValues( /* Assign a "\DosDevices\#:" mount point to this partition */ if (PartEntry->DriveLetter) { - StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector; + StartingOffset.QuadPart = GetPartEntryOffsetInBytes(PartEntry); if (!SetMountedDeviceValue(PartEntry->DriveLetter, DiskEntry->LayoutBuffer->Signature, StartingOffset)) diff --git a/base/setup/lib/utils/partlist.h b/base/setup/lib/utils/partlist.h index c59b5e1f4b7..d5b20615455 100644 --- a/base/setup/lib/utils/partlist.h +++ b/base/setup/lib/utils/partlist.h @@ -70,9 +70,6 @@ typedef struct _PARTENTRY /* Partition is new, table does not exist on disk yet */ BOOLEAN New; - /* Partition was created automatically */ - BOOLEAN AutoCreate; - /* Partition must be checked */ BOOLEAN NeedsCheck; @@ -227,6 +224,16 @@ RoundingDivide( IN ULONGLONG Divisor); +#define GetPartEntryOffsetInBytes(PartEntry) \ + ((PartEntry)->StartSector.QuadPart * (PartEntry)->DiskEntry->BytesPerSector) + +#define GetPartEntrySizeInBytes(PartEntry) \ + ((PartEntry)->SectorCount.QuadPart * (PartEntry)->DiskEntry->BytesPerSector) + +#define GetDiskSizeInBytes(DiskEntry) \ + ((DiskEntry)->SectorCount.QuadPart * (DiskEntry)->BytesPerSector) + + BOOLEAN IsSuperFloppy( IN PDISKENTRY DiskEntry); @@ -306,14 +313,13 @@ BOOLEAN CreatePartition( _In_ PPARTLIST List, _Inout_ PPARTENTRY PartEntry, - _In_ ULONGLONG SectorCount, - _In_ BOOLEAN AutoCreate); + _In_opt_ ULONGLONG SizeBytes); BOOLEAN CreateExtendedPartition( _In_ PPARTLIST List, _Inout_ PPARTENTRY PartEntry, - _In_ ULONGLONG SectorCount); + _In_opt_ ULONGLONG SizeBytes); NTSTATUS DismountVolume( diff --git a/base/setup/usetup/partlist.c b/base/setup/usetup/partlist.c index 5feaf446529..72ae328cbde 100644 --- a/base/setup/usetup/partlist.c +++ b/base/setup/usetup/partlist.c @@ -156,7 +156,7 @@ PartitionDescription( PCSTR Unit; /* Get the partition size */ - PartSize = PartEntry->SectorCount.QuadPart * PartEntry->DiskEntry->BytesPerSector; + PartSize = GetPartEntrySizeInBytes(PartEntry); PrettifySize2(&PartSize, &Unit); if (PartEntry->IsPartitioned == FALSE) @@ -307,7 +307,7 @@ DiskDescription( PCSTR Unit; /* Get the disk size */ - DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector; + DiskSize = GetDiskSizeInBytes(DiskEntry); PrettifySize1(&DiskSize, &Unit); // diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c index 61fae743780..59593f38b59 100644 --- a/base/setup/usetup/usetup.c +++ b/base/setup/usetup/usetup.c @@ -79,6 +79,9 @@ static enum { PartTypeExtended // MBR-disk container } PartCreateType = PartTypeData; +/* Flag set in PARTENTRY::New when a partition is created automatically */ +#define PARTITION_NEW_AUTOCREATE 0x80 + /* List of supported file systems for the partition to be formatted */ static PFILE_SYSTEM_LIST FileSystemList = NULL; @@ -1503,18 +1506,18 @@ LayoutSettingsPage(PINPUT_RECORD Ir) } -static BOOL -IsDiskSizeValid(PPARTENTRY PartEntry) +static BOOLEAN +IsPartitionLargeEnough( + _In_ PPARTENTRY PartEntry) { - ULONGLONG size; + /* Retrieve the maximum size in MB (rounded up) */ + ULONGLONG PartSize = RoundingDivide(GetPartEntrySizeInBytes(PartEntry), MB); - size = PartEntry->SectorCount.QuadPart * PartEntry->DiskEntry->BytesPerSector; - size = (size + (512 * KB)) / MB; /* in MBytes */ - - if (size < USetupData.RequiredPartitionDiskSpace) + if (PartSize < USetupData.RequiredPartitionDiskSpace) { /* Partition is too small so ask for another one */ - DPRINT1("Partition is too small (size: %I64u MB), required disk space is %lu MB\n", size, USetupData.RequiredPartitionDiskSpace); + DPRINT1("Partition is too small (size: %I64u MB), required disk space is %lu MB\n", + PartSize, USetupData.RequiredPartitionDiskSpace); return FALSE; } else @@ -1608,13 +1611,15 @@ SelectPartitionPage(PINPUT_RECORD Ir) ASSERT(CurrentPartition != NULL); ASSERT(!IsContainerPartition(CurrentPartition->PartitionType)); + /* Automatically create the partition on the whole empty space; + * it will be formatted later with default parameters */ CreatePartition(PartitionList, CurrentPartition, - CurrentPartition->SectorCount.QuadPart, - TRUE); + 0ULL); + CurrentPartition->New |= PARTITION_NEW_AUTOCREATE; // FIXME?? Aren't we going to enter an infinite loop, if this test fails?? - if (!IsDiskSizeValid(CurrentPartition)) + if (!IsPartitionLargeEnough(CurrentPartition)) { MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE, Ir, POPUP_WAIT_ANY_KEY, USetupData.RequiredPartitionDiskSpace); @@ -1632,7 +1637,7 @@ SelectPartitionPage(PINPUT_RECORD Ir) DrawPartitionList(&ListUi); // FIXME: Doesn't make much sense... // FIXME?? Aren't we going to enter an infinite loop, if this test fails?? - if (!IsDiskSizeValid(InstallPartition)) + if (!IsPartitionLargeEnough(InstallPartition)) { MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE, Ir, POPUP_WAIT_ANY_KEY, USetupData.RequiredPartitionDiskSpace); @@ -1737,13 +1742,15 @@ SelectPartitionPage(PINPUT_RECORD Ir) return SELECT_PARTITION_PAGE; } + /* Automatically create the partition on the whole empty space; + * it will be formatted later with default parameters */ CreatePartition(PartitionList, CurrentPartition, - 0ULL, - TRUE); + 0ULL); + CurrentPartition->New |= PARTITION_NEW_AUTOCREATE; } - if (!IsDiskSizeValid(CurrentPartition)) + if (!IsPartitionLargeEnough(CurrentPartition)) { MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE, Ir, POPUP_WAIT_ANY_KEY, USetupData.RequiredPartitionDiskSpace); @@ -2040,11 +2047,9 @@ CreatePartitionPage(PINPUT_RECORD Ir) PPARTENTRY PartEntry; PDISKENTRY DiskEntry; ULONG uID; - BOOLEAN Quit; - BOOLEAN Cancel; ULONG MaxSize; - ULONGLONG PartSize; - ULONGLONG SectorCount; + ULONGLONG MaxPartSize, PartSize; + BOOLEAN Quit, Cancel; WCHAR InputBuffer[50]; CHAR LineBuffer[100]; @@ -2078,15 +2083,17 @@ CreatePartitionPage(PINPUT_RECORD Ir) CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION)); + MaxPartSize = GetPartEntrySizeInBytes(PartEntry); + while (TRUE) { - MaxSize = (PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) / MB; /* in MBytes (rounded) */ - if (MaxSize > PARTITION_MAXSIZE) - MaxSize = PARTITION_MAXSIZE; + /* Retrieve the maximum size in MB (rounded up) + * and cap it with what the user can enter */ + MaxSize = (ULONG)RoundingDivide(MaxPartSize, MB); + MaxSize = min(MaxSize, PARTITION_MAXSIZE); - ShowPartitionSizeInputBox(12, 14, xScreen - 12, 17, /* left, top, right, bottom */ + ShowPartitionSizeInputBox(12, 14, xScreen - 12, 17, MaxSize, InputBuffer, &Quit, &Cancel); - if (Quit) { if (ConfirmQuit(Ir)) @@ -2097,50 +2104,41 @@ CreatePartitionPage(PINPUT_RECORD Ir) { return SELECT_PARTITION_PAGE; } - else - { - PartSize = _wcstoui64(InputBuffer, NULL, 10); - /* Retry if too small or too large */ - if (PartSize < 1) - continue; - if (PartSize > MaxSize) - continue; - - /* Convert to bytes */ - if (PartSize == MaxSize) - { - /* Use all of the unpartitioned disk space */ - SectorCount = PartEntry->SectorCount.QuadPart; - } - else - { - /* Calculate the sector count from the size in MB */ - SectorCount = PartSize * MB / DiskEntry->BytesPerSector; + PartSize = _wcstoui64(InputBuffer, NULL, 10); - /* But never get larger than the unpartitioned disk space */ - if (SectorCount > PartEntry->SectorCount.QuadPart) - SectorCount = PartEntry->SectorCount.QuadPart; - } + /* Retry if too small or too large */ + if ((PartSize < 1) || (PartSize > MaxSize)) + continue; - DPRINT("Partition size: %I64u bytes\n", PartSize); + /* + * If the input size, given in MB, specifies the maximum partition + * size, it may slightly under- or over-estimate it due to rounding + * error. In this case, use all of the unpartitioned disk space. + * Otherwise, directly convert the size to bytes. + */ + if (PartSize == MaxSize) + PartSize = MaxPartSize; + else // if (PartSize < MaxSize) + PartSize *= MB; + DPRINT("Partition size: %I64u bytes\n", PartSize); - if (PartCreateType == PartTypeData) - { - CreatePartition(PartitionList, - CurrentPartition, - SectorCount, - FALSE); - } - else // if (PartCreateType == PartTypeExtended) - { - CreateExtendedPartition(PartitionList, - CurrentPartition, - SectorCount); - } + ASSERT(PartSize <= MaxPartSize); - return SELECT_PARTITION_PAGE; + if (PartCreateType == PartTypeData) + { + CreatePartition(PartitionList, + CurrentPartition, + PartSize); } + else // if (PartCreateType == PartTypeExtended) + { + CreateExtendedPartition(PartitionList, + CurrentPartition, + PartSize); + } + + return SELECT_PARTITION_PAGE; } return CREATE_PARTITION_PAGE; @@ -2392,10 +2390,14 @@ SelectFileSystemPage(PINPUT_RECORD Ir) */ if (!SystemPartition->IsPartitioned) { + /* Automatically create the partition; it will be + * formatted later with default parameters */ + // FIXME: Don't use the whole empty space, but a minimal size + // specified from the TXTSETUP.SIF or unattended setup. CreatePartition(PartitionList, SystemPartition, - 0LL, // SystemPartition->SectorCount.QuadPart, - TRUE); + 0ULL); + SystemPartition->New |= PARTITION_NEW_AUTOCREATE; ASSERT(SystemPartition->IsPartitioned); } @@ -2548,9 +2550,9 @@ SelectFileSystemPage(PINPUT_RECORD Ir) MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE); - if (PartEntry->AutoCreate) + if (PartEntry->New & PARTITION_NEW_AUTOCREATE) { - PartEntry->AutoCreate = FALSE; + PartEntry->New &= ~PARTITION_NEW_AUTOCREATE; CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION)); }
10 months, 1 week
1
0
0
0
[reactos] 01/01: [MSCTFIME] Restructuring (#6505)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b2ec78673d2f2fd8f4156…
commit b2ec78673d2f2fd8f41565fef070f40297e911da Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Feb 20 21:11:08 2024 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Tue Feb 20 21:11:08 2024 +0900 [MSCTFIME] Restructuring (#6505) Improve code flexibility. 3700+ lines of msctfime.cpp was too long. JIRA issue: CORE-19360 - Split msctfime.cpp code to some source files and header files. --- dll/ime/msctfime/CMakeLists.txt | 10 +- dll/ime/msctfime/bridge.cpp | 608 ++++++++ dll/ime/msctfime/bridge.h | 80 + dll/ime/msctfime/compartment.cpp | 163 ++ dll/ime/msctfime/compartment.h | 44 + dll/ime/msctfime/functions.cpp | 175 +++ dll/ime/msctfime/functions.h | 63 + dll/ime/msctfime/inputcontext.cpp | 323 ++++ dll/ime/msctfime/inputcontext.h | 91 ++ dll/ime/msctfime/msctfime.cpp | 3003 ++----------------------------------- dll/ime/msctfime/msctfime.h | 17 + dll/ime/msctfime/profile.cpp | 173 +++ dll/ime/msctfime/profile.h | 51 + dll/ime/msctfime/sinks.cpp | 539 +++++++ dll/ime/msctfime/sinks.h | 166 ++ dll/ime/msctfime/tls.cpp | 56 + dll/ime/msctfime/tls.h | 74 + dll/ime/msctfime/ui.cpp | 393 +++++ dll/ime/msctfime/ui.h | 68 + 19 files changed, 3177 insertions(+), 2920 deletions(-) diff --git a/dll/ime/msctfime/CMakeLists.txt b/dll/ime/msctfime/CMakeLists.txt index 5a034398964..288c14afc7f 100644 --- a/dll/ime/msctfime/CMakeLists.txt +++ b/dll/ime/msctfime/CMakeLists.txt @@ -5,7 +5,15 @@ include_directories( spec2def(msctfime.ime msctfime.spec) list(APPEND SOURCE - msctfime.cpp) + bridge.cpp + compartment.cpp + functions.cpp + inputcontext.cpp + msctfime.cpp + profile.cpp + sinks.cpp + tls.cpp + ui.cpp) file(GLOB msctfime_rc_deps res/*.*) add_rc_deps(msctfime.rc ${msctfime_rc_deps}) diff --git a/dll/ime/msctfime/bridge.cpp b/dll/ime/msctfime/bridge.cpp new file mode 100644 index 00000000000..de9e6ba10ef --- /dev/null +++ b/dll/ime/msctfime/bridge.cpp @@ -0,0 +1,608 @@ +/* + * PROJECT: ReactOS msctfime.ime + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Bridge + * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#include "msctfime.h" + +WINE_DEFAULT_DEBUG_CHANNEL(msctfime); + +/// @implemented +CicBridge::CicBridge() +{ + m_bImmxInited = FALSE; + m_bUnknown1 = FALSE; + m_bDeactivating = FALSE; + m_bUnknown2 = FALSE; + m_pKeystrokeMgr = NULL; + m_pDocMgr = NULL; + m_pThreadMgrEventSink = NULL; + m_cliendId = 0; + m_cRefs = 1; +} + +/// @implemented +STDMETHODIMP CicBridge::QueryInterface(REFIID riid, LPVOID* ppvObj) +{ + *ppvObj = NULL; + + if (!IsEqualIID(riid, IID_ITfSysHookSink)) + return E_NOINTERFACE; + + *ppvObj = this; + AddRef(); + + return S_OK; +} + +/// @implemented +STDMETHODIMP_(ULONG) CicBridge::AddRef() +{ + return ::InterlockedIncrement(&m_cRefs); +} + +/// @implemented +STDMETHODIMP_(ULONG) CicBridge::Release() +{ + if (::InterlockedDecrement(&m_cRefs) == 0) + { + delete this; + return 0; + } + return m_cRefs; +} + +/// @implemented +CicBridge::~CicBridge() +{ + TLS *pTLS = TLS::PeekTLS(); + if (!pTLS || !pTLS->m_pThreadMgr) + return; + + if (SUCCEEDED(DeactivateIMMX(pTLS, pTLS->m_pThreadMgr))) + UnInitIMMX(pTLS); +} + +void CicBridge::GetDocumentManager(_Inout_ CicIMCCLock<CTFIMECONTEXT>& imeContext) +{ + CicInputContext *pCicIC = imeContext.get().m_pCicIC; + if (pCicIC) + { + m_pDocMgr = pCicIC->m_pDocumentMgr; + m_pDocMgr->AddRef(); + } + else + { + m_pDocMgr->Release(); + m_pDocMgr = NULL; + } +} + +/// @unimplemented +HRESULT +CicBridge::CreateInputContext( + _Inout_ TLS *pTLS, + _In_ HIMC hIMC) +{ + CicIMCLock imcLock(hIMC); + HRESULT hr = imcLock.m_hr; + if (!imcLock) + hr = E_FAIL; + if (FAILED(hr)) + return hr; + + if (!imcLock.get().hCtfImeContext) + { + HIMCC hCtfImeContext = ImmCreateIMCC(sizeof(CTFIMECONTEXT)); + if (!hCtfImeContext) + return E_OUTOFMEMORY; + imcLock.get().hCtfImeContext = hCtfImeContext; + } + + CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext); + CicInputContext *pCicIC = imeContext.get().m_pCicIC; + if (!pCicIC) + { + pCicIC = new(cicNoThrow) CicInputContext(m_cliendId, &m_LibThread, hIMC); + if (!pCicIC) + { + imeContext.unlock(); + imcLock.unlock(); + DestroyInputContext(pTLS, hIMC); + return E_OUTOFMEMORY; + } + + if (!pTLS->m_pThreadMgr) + { + pCicIC->Release(); + imeContext.unlock(); + imcLock.unlock(); + DestroyInputContext(pTLS, hIMC); + return E_NOINTERFACE; + } + + imeContext.get().m_pCicIC = pCicIC; + } + + hr = pCicIC->CreateInputContext(pTLS->m_pThreadMgr, imcLock); + if (FAILED(hr)) + { + pCicIC->Release(); + imeContext.get().m_pCicIC = NULL; + } + else + { + if (imcLock.get().hWnd && imcLock.get().hWnd == ::GetFocus()) + { + GetDocumentManager(imeContext); + //FIXME + } + } + + return E_NOTIMPL; +} + +/// @implemented +HRESULT CicBridge::DestroyInputContext(TLS *pTLS, HIMC hIMC) +{ + CicIMCLock imcLock(hIMC); + HRESULT hr = imcLock.m_hr; + if (!imcLock) + hr = E_FAIL; + if (FAILED(hr)) + return hr; + + hr = E_FAIL; + CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext); + if (imeContext) + hr = imeContext.m_hr; + + if (SUCCEEDED(hr) && !(imeContext.get().m_dwCicFlags & 1)) + { + imeContext.get().m_dwCicFlags |= 1; + + CicInputContext *pCicIC = imeContext.get().m_pCicIC; + if (pCicIC) + { + imeContext.get().m_pCicIC = NULL; + hr = pCicIC->DestroyInputContext(); + pCicIC->Release(); + imeContext.get().m_pCicIC = NULL; + } + } + + if (imcLock.get().hCtfImeContext) + { + ImmDestroyIMCC(imcLock.get().hCtfImeContext); + imcLock.get().hCtfImeContext = NULL; + hr = S_OK; + } + + return hr; +} + +ITfContext * +CicBridge::GetInputContext(CicIMCCLock<CTFIMECONTEXT>& imeContext) +{ + CicInputContext *pCicIC = imeContext.get().m_pCicIC; + if (!pCicIC) + return NULL; + return pCicIC->m_pContext; +} + +/// @unimplemented +HRESULT CicBridge::OnSetOpenStatus( + TLS *pTLS, + ITfThreadMgr_P *pThreadMgr, + CicIMCLock& imcLock, + CicInputContext *pCicIC) +{ + return E_NOTIMPL; +} + +/// Selects the IME context. +/// @implemented +HRESULT +CicBridge::SelectEx( + _Inout_ TLS *pTLS, + _Inout_ ITfThreadMgr_P *pThreadMgr, + _In_ HIMC hIMC, + _In_ BOOL fSelect, + _In_ HKL hKL) +{ + CicIMCLock imcLock(hIMC); + if (FAILED(imcLock.m_hr)) + return imcLock.m_hr; + + CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext); + if (!imeContext) + imeContext.m_hr = E_FAIL; + if (FAILED(imeContext.m_hr)) + return imeContext.m_hr; + + CicInputContext *pCicIC = imeContext.get().m_pCicIC; + if (pCicIC) + pCicIC->m_bSelecting = TRUE; + + if (fSelect) + { + if (pCicIC) + pCicIC->m_dwUnknown6[1] &= ~1; + if (imcLock.get().fOpen) + OnSetOpenStatus(pTLS, pThreadMgr, imcLock, pCicIC); + } + else + { + ITfContext *pContext = GetInputContext(imeContext); + pThreadMgr->RequestPostponedLock(pContext); + if (pCicIC) + pCicIC->m_bSelecting = FALSE; + if (pContext) + pContext->Release(); + } + + return imeContext.m_hr; +} + +/// Used in CicBridge::EnumCreateInputContextCallback and +/// CicBridge::EnumDestroyInputContextCallback. +typedef struct ENUM_CREATE_DESTROY_IC +{ + TLS *m_pTLS; + CicBridge *m_pBridge; +} ENUM_CREATE_DESTROY_IC, *PENUM_CREATE_DESTROY_IC; + +/// Creates input context for the current thread. +/// @implemented +BOOL CALLBACK CicBridge::EnumCreateInputContextCallback(HIMC hIMC, LPARAM lParam) +{ + PENUM_CREATE_DESTROY_IC pData = (PENUM_CREATE_DESTROY_IC)lParam; + pData->m_pBridge->CreateInputContext(pData->m_pTLS, hIMC); + return TRUE; +} + +/// Destroys input context for the current thread. +/// @implemented +BOOL CALLBACK CicBridge::EnumDestroyInputContextCallback(HIMC hIMC, LPARAM lParam) +{ + PENUM_CREATE_DESTROY_IC pData = (PENUM_CREATE_DESTROY_IC)lParam; + pData->m_pBridge->DestroyInputContext(pData->m_pTLS, hIMC); + return TRUE; +} + +/// @implemented +HRESULT +CicBridge::ActivateIMMX( + _Inout_ TLS *pTLS, + _Inout_ ITfThreadMgr_P *pThreadMgr) +{ + HRESULT hr = pThreadMgr->ActivateEx(&m_cliendId, 1); + if (hr != S_OK) + { + m_cliendId = 0; + return E_FAIL; + } + + if (m_cActivateLocks++ != 0) + return S_OK; + + ITfSourceSingle *pSource = NULL; + hr = pThreadMgr->QueryInterface(IID_ITfSourceSingle, (void**)&pSource); + if (FAILED(hr)) + { + DeactivateIMMX(pTLS, pThreadMgr); + return hr; + } + + CFunctionProvider *pProvider = new(cicNoThrow) CFunctionProvider(m_cliendId); + if (!pProvider) + { + hr = E_FAIL; + goto Finish; + } + + pSource->AdviseSingleSink(m_cliendId, IID_ITfFunctionProvider, pProvider); + pProvider->Release(); + + if (!m_pDocMgr) + { + hr = pThreadMgr->CreateDocumentMgr(&m_pDocMgr); + if (FAILED(hr)) + { + hr = E_FAIL; + goto Finish; + } + + SetCompartmentDWORD(m_cliendId, m_pDocMgr, GUID_COMPARTMENT_CTFIME_DIMFLAGS, TRUE, FALSE); + } + + pThreadMgr->SetSysHookSink(this); + + hr = S_OK; + if (pTLS->m_bDestroyed) + { + ENUM_CREATE_DESTROY_IC Data = { pTLS, this }; + ImmEnumInputContext(0, CicBridge::EnumCreateInputContextCallback, (LPARAM)&Data); + } + +Finish: + if (FAILED(hr)) + DeactivateIMMX(pTLS, pThreadMgr); + if (pSource) + pSource->Release(); + return hr; +} + +/// @implemented +HRESULT +CicBridge::DeactivateIMMX( + _Inout_ TLS *pTLS, + _Inout_ ITfThreadMgr_P *pThreadMgr) +{ + if (m_bDeactivating) + return TRUE; + + m_bDeactivating = TRUE; + + if (m_cliendId) + { + ENUM_CREATE_DESTROY_IC Data = { pTLS, this }; + ImmEnumInputContext(0, CicBridge::EnumDestroyInputContextCallback, (LPARAM)&Data); + pTLS->m_bDestroyed = TRUE; + + ITfSourceSingle *pSource = NULL; + if (pThreadMgr->QueryInterface(IID_ITfSourceSingle, (void **)&pSource) == S_OK) + pSource->UnadviseSingleSink(m_cliendId, IID_ITfFunctionProvider); + + m_cliendId = 0; + + while (m_cActivateLocks > 0) + { + --m_cActivateLocks; + pThreadMgr->Deactivate(); + } + + if (pSource) + pSource->Release(); + } + + if (m_pDocMgr) + { + m_pDocMgr->Release(); + m_pDocMgr = NULL; + } + + pThreadMgr->SetSysHookSink(NULL); + + m_bDeactivating = FALSE; + + return S_OK; +} + +/// @implemented +HRESULT +CicBridge::InitIMMX(_Inout_ TLS *pTLS) +{ + if (m_bImmxInited) + return S_OK; + + HRESULT hr = S_OK; + if (!pTLS->m_pThreadMgr) + { + ITfThreadMgr *pThreadMgr = NULL; + hr = TF_CreateThreadMgr(&pThreadMgr); + if (FAILED(hr)) + return E_FAIL; + + hr = pThreadMgr->QueryInterface(IID_ITfThreadMgr_P, (void **)&pTLS->m_pThreadMgr); + if (pThreadMgr) + pThreadMgr->Release(); + if (FAILED(hr)) + return E_FAIL; + } + + if (!m_pThreadMgrEventSink) + { + m_pThreadMgrEventSink = + new(cicNoThrow) CThreadMgrEventSink(CThreadMgrEventSink::DIMCallback, NULL, NULL); + if (!m_pThreadMgrEventSink) + { + UnInitIMMX(pTLS); + return E_FAIL; + } + } + + m_pThreadMgrEventSink->SetCallbackPV(m_pThreadMgrEventSink); + m_pThreadMgrEventSink->_Advise(pTLS->m_pThreadMgr); + + if (!pTLS->m_pProfile) + { + pTLS->m_pProfile = new(cicNoThrow) CicProfile(); + if (!pTLS->m_pProfile) + return E_OUTOFMEMORY; + + hr = pTLS->m_pProfile->InitProfileInstance(pTLS); + if (FAILED(hr)) + { + UnInitIMMX(pTLS); + return E_FAIL; + } + } + + hr = pTLS->m_pThreadMgr->QueryInterface(IID_ITfKeystrokeMgr_P, (void **)&m_pKeystrokeMgr); + if (FAILED(hr)) + { + UnInitIMMX(pTLS); + return E_FAIL; + } + + hr = InitDisplayAttrbuteLib(&m_LibThread); + if (FAILED(hr)) + { + UnInitIMMX(pTLS); + return E_FAIL; + } + + m_bImmxInited = TRUE; + return S_OK; +} + +/// @implemented +BOOL CicBridge::UnInitIMMX(_Inout_ TLS *pTLS) +{ + UninitDisplayAttrbuteLib(&m_LibThread); + TFUninitLib_Thread(&m_LibThread); + + if (m_pKeystrokeMgr) + { + m_pKeystrokeMgr->Release(); + m_pKeystrokeMgr = NULL; + } + + if (pTLS->m_pProfile) + { + pTLS->m_pProfile->Release(); + pTLS->m_pProfile = NULL; + } + + if (m_pThreadMgrEventSink) + { + m_pThreadMgrEventSink->_Unadvise(); + m_pThreadMgrEventSink->Release(); + m_pThreadMgrEventSink = NULL; + } + + if (pTLS->m_pThreadMgr) + { + pTLS->m_pThreadMgr->Release(); + pTLS->m_pThreadMgr = NULL; + } + + m_bImmxInited = FALSE; + return TRUE; +} + +/// @implemented +STDMETHODIMP CicBridge::OnPreFocusDIM(HWND hwnd) +{ + return S_OK; +} + +/// @unimplemented +STDMETHODIMP CicBridge::OnSysKeyboardProc(UINT, LONG) +{ + return E_NOTIMPL; +} + +/// @implemented +STDMETHODIMP CicBridge::OnSysShellProc(INT, UINT, LONG) +{ + return S_OK; +} + +/// @implemented +void +CicBridge::PostTransMsg( + _In_ HWND hWnd, + _In_ INT cTransMsgs, + _In_ const TRANSMSG *pTransMsgs) +{ + for (INT i = 0; i < cTransMsgs; ++i, ++pTransMsgs) + { + ::PostMessageW(hWnd, pTransMsgs->message, pTransMsgs->wParam, pTransMsgs->lParam); + } +} + +/// @implemented +HRESULT +CicBridge::ConfigureGeneral( + _Inout_ TLS* pTLS, + _In_ ITfThreadMgr *pThreadMgr, + _In_ HKL hKL, + _In_ HWND hWnd) +{ + CicProfile *pProfile = pTLS->m_pProfile; + if (!pProfile) + return E_OUTOFMEMORY; + + TF_LANGUAGEPROFILE profile; + HRESULT hr = pProfile->GetActiveLanguageProfile(hKL, GUID_TFCAT_TIP_KEYBOARD, &profile); + if (FAILED(hr)) + return hr; + + ITfFunctionProvider *pProvider = NULL; + hr = pThreadMgr->GetFunctionProvider(profile.clsid, &pProvider); + if (FAILED(hr)) + return hr; + + ITfFnConfigure *pFnConfigure = NULL; + hr = pProvider->GetFunction(GUID_NULL, IID_ITfFnConfigure, (IUnknown**)&pFnConfigure); + if (FAILED(hr)) + { + pProvider->Release(); + return hr; + } + + hr = pFnConfigure->Show(hWnd, profile.langid, profile.guidProfile); + + pFnConfigure->Release(); + pProvider->Release(); + return hr; +} + +/// @implemented +HRESULT +CicBridge::ConfigureRegisterWord( + _Inout_ TLS* pTLS, + _In_ ITfThreadMgr *pThreadMgr, + _In_ HKL hKL, + _In_ HWND hWnd, + _Inout_opt_ LPVOID lpData) +{ + CicProfile *pProfile = pTLS->m_pProfile; + if (!pProfile) + return E_OUTOFMEMORY; + + TF_LANGUAGEPROFILE profile; + HRESULT hr = pProfile->GetActiveLanguageProfile(hKL, GUID_TFCAT_TIP_KEYBOARD, &profile); + if (FAILED(hr)) + return hr; + + ITfFunctionProvider *pProvider = NULL; + hr = pThreadMgr->GetFunctionProvider(profile.clsid, &pProvider); + if (FAILED(hr)) + return hr; + + ITfFnConfigureRegisterWord *pFunction = NULL; + hr = pProvider->GetFunction(GUID_NULL, IID_ITfFnConfigureRegisterWord, (IUnknown**)&pFunction); + if (FAILED(hr)) + { + pProvider->Release(); + return hr; + } + + REGISTERWORDW* pRegWord = (REGISTERWORDW*)lpData; + if (pRegWord) + { + if (pRegWord->lpWord) + { + hr = E_OUTOFMEMORY; + BSTR bstrWord = SysAllocString(pRegWord->lpWord); + if (bstrWord) + { + hr = pFunction->Show(hWnd, profile.langid, profile.guidProfile, bstrWord); + SysFreeString(bstrWord); + } + } + else + { + hr = pFunction->Show(hWnd, profile.langid, profile.guidProfile, NULL); + } + } + + pProvider->Release(); + pFunction->Release(); + return hr; +} diff --git a/dll/ime/msctfime/bridge.h b/dll/ime/msctfime/bridge.h new file mode 100644 index 00000000000..c8b8441203d --- /dev/null +++ b/dll/ime/msctfime/bridge.h @@ -0,0 +1,80 @@ +/* + * PROJECT: ReactOS msctfime.ime + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Bridge + * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#pragma once + +#include "sinks.h" +#include "tls.h" + +class CicBridge : public ITfSysHookSink +{ +protected: + LONG m_cRefs; + BOOL m_bImmxInited; + BOOL m_bUnknown1; + BOOL m_bDeactivating; + DWORD m_cActivateLocks; + ITfKeystrokeMgr *m_pKeystrokeMgr; + ITfDocumentMgr *m_pDocMgr; + CThreadMgrEventSink *m_pThreadMgrEventSink; + TfClientId m_cliendId; + CIC_LIBTHREAD m_LibThread; + BOOL m_bUnknown2; + + static BOOL CALLBACK EnumCreateInputContextCallback(HIMC hIMC, LPARAM lParam); + static BOOL CALLBACK EnumDestroyInputContextCallback(HIMC hIMC, LPARAM lParam); + +public: + CicBridge(); + virtual ~CicBridge(); + + // IUnknown interface + STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; + STDMETHODIMP_(ULONG) AddRef() override; + STDMETHODIMP_(ULONG) Release() override; + + // ITfSysHookSink interface + STDMETHODIMP OnPreFocusDIM(HWND hwnd) override; + STDMETHODIMP OnSysKeyboardProc(UINT, LONG) override; + STDMETHODIMP OnSysShellProc(INT, UINT, LONG) override; + + HRESULT InitIMMX(_Inout_ TLS *pTLS); + BOOL UnInitIMMX(_Inout_ TLS *pTLS); + HRESULT ActivateIMMX(_Inout_ TLS *pTLS, _Inout_ ITfThreadMgr_P *pThreadMgr); + HRESULT DeactivateIMMX(_Inout_ TLS *pTLS, _Inout_ ITfThreadMgr_P *pThreadMgr); + + HRESULT CreateInputContext(TLS *pTLS, HIMC hIMC); + HRESULT DestroyInputContext(TLS *pTLS, HIMC hIMC); + ITfContext *GetInputContext(CicIMCCLock<CTFIMECONTEXT>& imeContext); + + HRESULT SelectEx( + _Inout_ TLS *pTLS, + _Inout_ ITfThreadMgr_P *pThreadMgr, + _In_ HIMC hIMC, + _In_ BOOL fSelect, + _In_ HKL hKL); + HRESULT OnSetOpenStatus( + TLS *pTLS, + ITfThreadMgr_P *pThreadMgr, + CicIMCLock& imcLock, + CicInputContext *pCicIC); + + void PostTransMsg(_In_ HWND hWnd, _In_ INT cTransMsgs, _In_ const TRANSMSG *pTransMsgs); + void GetDocumentManager(_Inout_ CicIMCCLock<CTFIMECONTEXT>& imeContext); + + HRESULT + ConfigureGeneral(_Inout_ TLS* pTLS, + _In_ ITfThreadMgr *pThreadMgr, + _In_ HKL hKL, + _In_ HWND hWnd); + HRESULT ConfigureRegisterWord( + _Inout_ TLS* pTLS, + _In_ ITfThreadMgr *pThreadMgr, + _In_ HKL hKL, + _In_ HWND hWnd, + _Inout_opt_ LPVOID lpData); +}; diff --git a/dll/ime/msctfime/compartment.cpp b/dll/ime/msctfime/compartment.cpp new file mode 100644 index 00000000000..d92b1b526f4 --- /dev/null +++ b/dll/ime/msctfime/compartment.cpp @@ -0,0 +1,163 @@ +/* + * PROJECT: ReactOS msctfime.ime + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Supporting compartments + * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#include "msctfime.h" + +WINE_DEFAULT_DEBUG_CHANNEL(msctfime); + +/// @implemented +HRESULT +GetCompartment( + IUnknown *pUnknown, + REFGUID rguid, + ITfCompartment **ppComp, + BOOL bThread) +{ + *ppComp = NULL; + + ITfThreadMgr *pThreadMgr = NULL; + ITfCompartmentMgr *pCompMgr = NULL; + + HRESULT hr; + if (bThread) + { + hr = pUnknown->QueryInterface(IID_ITfThreadMgr, (void **)&pThreadMgr); + if (FAILED(hr)) + return hr; + + hr = pThreadMgr->GetGlobalCompartment(&pCompMgr); + } + else + { + hr = pUnknown->QueryInterface(IID_ITfCompartmentMgr, (void **)&pCompMgr); + } + + if (SUCCEEDED(hr)) + { + hr = E_FAIL; + if (pCompMgr) + { + hr = pCompMgr->GetCompartment(rguid, ppComp); + pCompMgr->Release(); + } + } + + if (pThreadMgr) + pThreadMgr->Release(); + + return hr; +} + +/// @implemented +HRESULT +SetCompartmentDWORD( + TfEditCookie cookie, + IUnknown *pUnknown, + REFGUID rguid, + DWORD dwValue, + BOOL bThread) +{ + ITfCompartment *pComp = NULL; + HRESULT hr = GetCompartment(pUnknown, rguid, &pComp, bThread); + if (FAILED(hr)) + return hr; + + VARIANT vari; + V_I4(&vari) = dwValue; + V_VT(&vari) = VT_I4; + hr = pComp->SetValue(cookie, &vari); + + pComp->Release(); + return hr; +} + +/// @implemented +HRESULT +GetCompartmentDWORD( + IUnknown *pUnknown, + REFGUID rguid, + LPDWORD pdwValue, + BOOL bThread) +{ + *pdwValue = 0; + + ITfCompartment *pComp = NULL; + HRESULT hr = GetCompartment(pUnknown, rguid, &pComp, bThread); + if (FAILED(hr)) + return hr; + + VARIANT vari; + hr = pComp->GetValue(&vari); + if (hr == S_OK) + *pdwValue = V_I4(&vari); + + pComp->Release(); + return hr; +} + +/// @implemented +HRESULT +SetCompartmentUnknown( + TfEditCookie cookie, + IUnknown *pUnknown, + REFGUID rguid, + IUnknown *punkValue) +{ + ITfCompartment *pComp = NULL; + HRESULT hr = GetCompartment(pUnknown, rguid, &pComp, FALSE); + if (FAILED(hr)) + return hr; + + VARIANT vari; + V_UNKNOWN(&vari) = punkValue; + V_VT(&vari) = VT_UNKNOWN; + hr = pComp->SetValue(cookie, &vari); + + pComp->Release(); + return hr; +} + +/// @implemented +HRESULT +ClearCompartment( + TfClientId tid, + IUnknown *pUnknown, + REFGUID rguid, + BOOL bThread) +{ + ITfCompartmentMgr *pCompMgr = NULL; + ITfThreadMgr *pThreadMgr = NULL; + + HRESULT hr; + if (bThread) + { + hr = pUnknown->QueryInterface(IID_ITfThreadMgr, (void **)&pThreadMgr); + if (FAILED(hr)) + return hr; + + hr = pThreadMgr->GetGlobalCompartment(&pCompMgr); + } + else + { + hr = pUnknown->QueryInterface(IID_ITfCompartmentMgr, (void **)&pCompMgr); + } + + if (SUCCEEDED(hr)) + { + hr = E_FAIL; + if (pCompMgr) + { + hr = pCompMgr->ClearCompartment(tid, rguid); + pCompMgr->Release(); + } + } + + if (pThreadMgr) + pThreadMgr->Release(); + + return hr; +} diff --git a/dll/ime/msctfime/compartment.h b/dll/ime/msctfime/compartment.h new file mode 100644 index 00000000000..88805566832 --- /dev/null +++ b/dll/ime/msctfime/compartment.h @@ -0,0 +1,44 @@ +/* + * PROJECT: ReactOS msctfime.ime + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Supporting compartments + * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#pragma once + +HRESULT +GetCompartment( + IUnknown *pUnknown, + REFGUID rguid, + ITfCompartment **ppComp, + BOOL bThread); + +HRESULT +SetCompartmentDWORD( + TfEditCookie cookie, + IUnknown *pUnknown, + REFGUID rguid, + DWORD dwValue, + BOOL bThread); + +HRESULT +GetCompartmentDWORD( + IUnknown *pUnknown, + REFGUID rguid, + LPDWORD pdwValue, + BOOL bThread); + +HRESULT +SetCompartmentUnknown( + TfEditCookie cookie, + IUnknown *pUnknown, + REFGUID rguid, + IUnknown *punkValue); + +HRESULT +ClearCompartment( + TfClientId tid, + IUnknown *pUnknown, + REFGUID rguid, + BOOL bThread); diff --git a/dll/ime/msctfime/functions.cpp b/dll/ime/msctfime/functions.cpp new file mode 100644 index 00000000000..c9832f90cff --- /dev/null +++ b/dll/ime/msctfime/functions.cpp @@ -0,0 +1,175 @@ +/* + * PROJECT: ReactOS msctfime.ime + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: The functions of msctfime.ime + * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#include "msctfime.h" + +WINE_DEFAULT_DEBUG_CHANNEL(msctfime); + +/// @implemented +CFunctionProviderBase::CFunctionProviderBase(_In_ TfClientId clientId) +{ + m_clientId = clientId; + m_guid = GUID_NULL; + m_bstr = NULL; + m_cRefs = 1; +} + +/// @implemented +CFunctionProviderBase::~CFunctionProviderBase() +{ + if (!DllShutdownInProgress()) + ::SysFreeString(m_bstr); +} + +/// @implemented +BOOL +CFunctionProviderBase::Init( + _In_ REFGUID rguid, + _In_ LPCWSTR psz) +{ + m_bstr = ::SysAllocString(psz); + m_guid = rguid; + return (m_bstr != NULL); +} + +/// @implemented +STDMETHODIMP +CFunctionProviderBase::QueryInterface( + _In_ REFIID riid, + _Out_ LPVOID* ppvObj) +{ + if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfFunctionProvider)) + { + *ppvObj = this; + AddRef(); + return S_OK; + } + return E_NOINTERFACE; +} + +/// @implemented +STDMETHODIMP_(ULONG) CFunctionProviderBase::AddRef() +{ + return ::InterlockedIncrement(&m_cRefs); +} + +/// @implemented +STDMETHODIMP_(ULONG) CFunctionProviderBase::Release() +{ + if (::InterlockedDecrement(&m_cRefs) == 0) + { + delete this; + return 0; + } + return m_cRefs; +} + +/// @implemented +STDMETHODIMP CFunctionProviderBase::GetType(_Out_ GUID *guid) +{ + *guid = m_guid; + return S_OK; +} + +/// @implemented +STDMETHODIMP CFunctionProviderBase::GetDescription(_Out_ BSTR *desc) +{ + *desc = ::SysAllocString(m_bstr); + return (*desc ? S_OK : E_OUTOFMEMORY); +} + +/***********************************************************************/ + +/// @implemented +CFunctionProvider::CFunctionProvider(_In_ TfClientId clientId) : CFunctionProviderBase(clientId) +{ + Init(CLSID_CAImmLayer, L"MSCTFIME::Function Provider"); +} + +/// @implemented +STDMETHODIMP +CFunctionProvider::GetFunction( + _In_ REFGUID guid, + _In_ REFIID riid, + _Out_ IUnknown **func) +{ + *func = NULL; + + if (IsEqualGUID(guid, GUID_NULL) && + IsEqualIID(riid, IID_IAImmFnDocFeed)) + { + *func = new(cicNoThrow) CFnDocFeed(); + if (*func) + return S_OK; + } + + return E_NOINTERFACE; +} + +/***********************************************************************/ + +CFnDocFeed::CFnDocFeed() +{ + m_cRefs = 1; +} + +CFnDocFeed::~CFnDocFeed() +{ +} + +/// @implemented +STDMETHODIMP CFnDocFeed::QueryInterface(_In_ REFIID riid, _Out_ LPVOID* ppvObj) +{ + if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IAImmFnDocFeed)) + { + *ppvObj = this; + AddRef(); + return S_OK; + } + return E_NOINTERFACE; +} + +/// @implemented +STDMETHODIMP_(ULONG) CFnDocFeed::AddRef() +{ + return ::InterlockedIncrement(&m_cRefs); +} + +/// @implemented +STDMETHODIMP_(ULONG) CFnDocFeed::Release() +{ + if (::InterlockedDecrement(&m_cRefs) == 0) + { + delete this; + return 0; + } + return m_cRefs; +} + +/// @unimplemented +STDMETHODIMP CFnDocFeed::DocFeed() +{ + return E_NOTIMPL; +} + +/// @unimplemented +STDMETHODIMP CFnDocFeed::ClearDocFeedBuffer() +{ + return E_NOTIMPL; +} + +/// @unimplemented +STDMETHODIMP CFnDocFeed::StartReconvert() +{ + return E_NOTIMPL; +} + +/// @unimplemented +STDMETHODIMP CFnDocFeed::StartUndoCompositionString() +{ + return E_NOTIMPL; +} diff --git a/dll/ime/msctfime/functions.h b/dll/ime/msctfime/functions.h new file mode 100644 index 00000000000..6938162a6e5 --- /dev/null +++ b/dll/ime/msctfime/functions.h @@ -0,0 +1,63 @@ +/* + * PROJECT: ReactOS msctfime.ime + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: The functions of msctfime.ime + * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +class CFunctionProviderBase : public ITfFunctionProvider +{ +protected: + TfClientId m_clientId; + GUID m_guid; + BSTR m_bstr; + LONG m_cRefs; + +public: + CFunctionProviderBase(_In_ TfClientId clientId); + virtual ~CFunctionProviderBase(); + + // IUnknown interface + STDMETHODIMP QueryInterface(_In_ REFIID riid, _Out_ LPVOID* ppvObj) override; + STDMETHODIMP_(ULONG) AddRef() override; + STDMETHODIMP_(ULONG) Release() override; + + // ITfFunctionProvider interface + STDMETHODIMP GetType(_Out_ GUID *guid) override; + STDMETHODIMP GetDescription(_Out_ BSTR *desc) override; + //STDMETHODIMP GetFunction(_In_ REFGUID guid, _In_ REFIID riid, _Out_ IUnknown **func) = 0; + + BOOL Init(_In_ REFGUID rguid, _In_ LPCWSTR psz); +}; + +/***********************************************************************/ + +class CFunctionProvider : public CFunctionProviderBase +{ +public: + CFunctionProvider(_In_ TfClientId clientId); + + STDMETHODIMP GetFunction(_In_ REFGUID guid, _In_ REFIID riid, _Out_ IUnknown **func) override; +}; + +/***********************************************************************/ + +class CFnDocFeed : public IAImmFnDocFeed +{ + LONG m_cRefs; + +public: + CFnDocFeed(); + virtual ~CFnDocFeed(); + + // IUnknown interface + STDMETHODIMP QueryInterface(_In_ REFIID riid, _Out_ LPVOID* ppvObj) override; + STDMETHODIMP_(ULONG) AddRef() override; + STDMETHODIMP_(ULONG) Release() override; + + // IAImmFnDocFeed interface + STDMETHODIMP DocFeed() override; + STDMETHODIMP ClearDocFeedBuffer() override; + STDMETHODIMP StartReconvert() override; + STDMETHODIMP StartUndoCompositionString() override; +}; diff --git a/dll/ime/msctfime/inputcontext.cpp b/dll/ime/msctfime/inputcontext.cpp new file mode 100644 index 00000000000..1bdf64cb62e --- /dev/null +++ b/dll/ime/msctfime/inputcontext.cpp @@ -0,0 +1,323 @@ +/* + * PROJECT: ReactOS msctfime.ime + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Input Context of msctfime.ime + * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#include "msctfime.h" + +WINE_DEFAULT_DEBUG_CHANNEL(msctfime); + +/// @unimplemented +CicInputContext::CicInputContext( + _In_ TfClientId cliendId, + _Inout_ PCIC_LIBTHREAD pLibThread, + _In_ HIMC hIMC) +{ + m_hIMC = hIMC; + m_guid = GUID_NULL; + m_dwQueryPos = 0; + m_cRefs = 1; +} + +/// @implemented +STDMETHODIMP CicInputContext::QueryInterface(REFIID riid, LPVOID* ppvObj) +{ + *ppvObj = NULL; + + if (IsEqualIID(riid, IID_ITfContextOwnerCompositionSink)) + { + *ppvObj = static_cast<ITfContextOwnerCompositionSink*>(this); + AddRef(); + return S_OK; + } + if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfCleanupContextSink)) + { + *ppvObj = this; + AddRef(); + return S_OK; + } + + return E_NOINTERFACE; +} + +/// @implemented +STDMETHODIMP_(ULONG) CicInputContext::AddRef() +{ + return ::InterlockedIncrement(&m_cRefs); +} + +/// @implemented +STDMETHODIMP_(ULONG) CicInputContext::Release() +{ + if (::InterlockedDecrement(&m_cRefs) == 0) + { + delete this; + return 0; + } + return m_cRefs; +} + +/// @implemented +STDMETHODIMP +CicInputContext::OnStartComposition( + ITfCompositionView *pComposition, + BOOL *pfOk) +{ + if ((m_cCompLocks <= 0) || m_dwUnknown6_5) + { + *pfOk = TRUE; + ++m_cCompLocks; + } + else + { + *pfOk = FALSE; + } + return S_OK; +} + +/// @implemented +STDMETHODIMP +CicInputContext::OnUpdateComposition( + ITfCompositionView *pComposition, + ITfRange *pRangeNew) +{ + return S_OK; +} + +/// @implemented +STDMETHODIMP +CicInputContext::OnEndComposition( + ITfCompositionView *pComposition) +{ + --m_cCompLocks; + return S_OK; +} + +/// @implemented +HRESULT +CicInputContext::GetGuidAtom( + _Inout_ CicIMCLock& imcLock, + _In_ BYTE iAtom, + _Out_opt_ LPDWORD pdwGuidAtom) +{ + CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCompStr); + HRESULT hr = imeContext.m_hr; + if (!imeContext) + hr = E_FAIL; + if (FAILED(hr)) + return hr; + + hr = E_FAIL; + if (iAtom < m_cGuidAtoms) + { + *pdwGuidAtom = m_adwGuidAtoms[iAtom]; + hr = S_OK; + } + + return hr; +} + +/// @unimplemented +HRESULT +CicInputContext::CreateInputContext( + _Inout_ ITfThreadMgr *pThreadMgr, + _Inout_ CicIMCLock& imcLock) +{ + //FIXME + return E_NOTIMPL; +} + +/// @unimplemented +HRESULT +CicInputContext::DestroyInputContext() +{ + ITfSourceSingle *pSource = NULL; + + if (m_pContext && m_pContext->QueryInterface(IID_ITfSourceSingle, (void **)&pSource) == S_OK) + pSource->UnadviseSingleSink(m_clientId, IID_ITfCleanupContextSink); + + //FIXME: m_dwUnknown5 + + if (m_pTextEventSink) + { + m_pTextEventSink->_Unadvise(); + m_pTextEventSink->Release(); + m_pTextEventSink = NULL; + } + + if (m_pCompEventSink2) + { + m_pCompEventSink2->_Unadvise(); + m_pCompEventSink2->Release(); + m_pCompEventSink2 = NULL; + } + + if (m_pCompEventSink1) + { + m_pCompEventSink1->_Unadvise(); + m_pCompEventSink1->Release(); + m_pCompEventSink1 = NULL; + } + + //FIXME: m_pInputContextOwner + + if (m_pDocumentMgr) + m_pDocumentMgr->Pop(1); + + if (m_pContext) + { + ClearCompartment(m_clientId, m_pContext, GUID_COMPARTMENT_CTFIME_CICINPUTCONTEXT, 0); + m_pContext->Release(); + m_pContext = NULL; + } + + if (m_pContextOwnerServices) + { + m_pContextOwnerServices->Release(); + m_pContextOwnerServices = NULL; + } + + // FIXME: m_pICOwnerCallback + + if (m_pDocumentMgr) + { + m_pDocumentMgr->Release(); + m_pDocumentMgr = NULL; + } + + if (pSource) + pSource->Release(); + + return S_OK; +} + +/// @implemented +STDMETHODIMP +CicInputContext::OnCompositionTerminated(TfEditCookie ecWrite, ITfComposition *pComposition) +{ + return S_OK; +} + +/// @implemented +STDMETHODIMP +CicInputContext::OnCleanupContext( + _In_ TfEditCookie ecWrite, + _Inout_ ITfContext *pic) +{ + TLS *pTLS = TLS::PeekTLS(); + if (!pTLS || !pTLS->m_pProfile) + return E_OUTOFMEMORY; + + LANGID LangID; + pTLS->m_pProfile->GetLangId(&LangID); + + IMEINFO IMEInfo; + WCHAR szPath[MAX_PATH]; + if (Inquire(&IMEInfo, szPath, 0, (HKL)UlongToHandle(LangID)) != S_OK) + return E_FAIL; + + ITfProperty *pProp = NULL; + if (!(IMEInfo.fdwProperty & IME_PROP_COMPLETE_ON_UNSELECT)) + return S_OK; + + HRESULT hr = pic->GetProperty(GUID_PROP_COMPOSING, &pProp); + if (FAILED(hr)) + return S_OK; + + IEnumTfRanges *pRanges = NULL; + hr = pProp->EnumRanges(ecWrite, &pRanges, NULL); + if (SUCCEEDED(hr)) + { + ITfRange *pRange = NULL; + while (pRanges->Next(1, &pRange, 0) == S_OK) + { + VARIANT vari; + V_VT(&vari) = VT_EMPTY; + pProp->GetValue(ecWrite, pRange, &vari); + if (V_VT(&vari) == VT_I4) + { + if (V_I4(&vari)) + pProp->Clear(ecWrite, pRange); + } + pRange->Release(); + pRange = NULL; + } + pRanges->Release(); + } + pProp->Release(); + + return S_OK; +} + +/// Retrieves the IME information. +/// @implemented +HRESULT +Inquire( + _Out_ LPIMEINFO lpIMEInfo, + _Out_ LPWSTR lpszWndClass, + _In_ DWORD dwSystemInfoFlags, + _In_ HKL hKL) +{ + if (!lpIMEInfo) + return E_OUTOFMEMORY; + + StringCchCopyW(lpszWndClass, 64, L"MSCTFIME UI"); + lpIMEInfo->dwPrivateDataSize = 0; + + switch (LOWORD(hKL)) // Language ID + { + case MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT): // Japanese + { + lpIMEInfo->fdwProperty = IME_PROP_COMPLETE_ON_UNSELECT | IME_PROP_SPECIAL_UI | + IME_PROP_AT_CARET | IME_PROP_NEED_ALTKEY | + IME_PROP_KBD_CHAR_FIRST; + lpIMEInfo->fdwConversionCaps = IME_CMODE_FULLSHAPE | IME_CMODE_KATAKANA | + IME_CMODE_NATIVE; + lpIMEInfo->fdwSentenceCaps = IME_SMODE_CONVERSATION | IME_SMODE_PLAURALCLAUSE; + lpIMEInfo->fdwSelectCaps = SELECT_CAP_SENTENCE | SELECT_CAP_CONVERSION; + lpIMEInfo->fdwSCSCaps = SCS_CAP_SETRECONVERTSTRING | SCS_CAP_MAKEREAD | + SCS_CAP_COMPSTR; + lpIMEInfo->fdwUICaps = UI_CAP_ROT90; + break; + } + case MAKELANGID(LANG_KOREAN, SUBLANG_DEFAULT): // Korean + { + lpIMEInfo->fdwProperty = IME_PROP_COMPLETE_ON_UNSELECT | IME_PROP_SPECIAL_UI | + IME_PROP_AT_CARET | IME_PROP_NEED_ALTKEY | + IME_PROP_KBD_CHAR_FIRST; + lpIMEInfo->fdwConversionCaps = IME_CMODE_FULLSHAPE | IME_CMODE_NATIVE; + lpIMEInfo->fdwSentenceCaps = 0; + lpIMEInfo->fdwSCSCaps = SCS_CAP_SETRECONVERTSTRING | SCS_CAP_COMPSTR; + lpIMEInfo->fdwSelectCaps = SELECT_CAP_CONVERSION; + lpIMEInfo->fdwUICaps = UI_CAP_ROT90; + break; + } + case MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED): // Simplified Chinese + case MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL): // Traditional Chinese + { + lpIMEInfo->fdwProperty = IME_PROP_SPECIAL_UI | IME_PROP_AT_CARET | + IME_PROP_NEED_ALTKEY | IME_PROP_KBD_CHAR_FIRST; + lpIMEInfo->fdwConversionCaps = IME_CMODE_FULLSHAPE | IME_CMODE_NATIVE; + lpIMEInfo->fdwSentenceCaps = SELECT_CAP_CONVERSION; + lpIMEInfo->fdwSelectCaps = 0; + lpIMEInfo->fdwSCSCaps = SCS_CAP_SETRECONVERTSTRING | SCS_CAP_MAKEREAD | + SCS_CAP_COMPSTR; + lpIMEInfo->fdwUICaps = UI_CAP_ROT90; + break; + } + default: // Otherwise + { + lpIMEInfo->fdwProperty = IME_PROP_UNICODE | IME_PROP_AT_CARET; + lpIMEInfo->fdwConversionCaps = 0; + lpIMEInfo->fdwSentenceCaps = 0; + lpIMEInfo->fdwSCSCaps = 0; + lpIMEInfo->fdwUICaps = 0; + lpIMEInfo->fdwSelectCaps = 0; + break; + } + } + + return S_OK; +} diff --git a/dll/ime/msctfime/inputcontext.h b/dll/ime/msctfime/inputcontext.h new file mode 100644 index 00000000000..2273161926e --- /dev/null +++ b/dll/ime/msctfime/inputcontext.h @@ -0,0 +1,91 @@ +/* + * PROJECT: ReactOS msctfime.ime + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Input Context of msctfime.ime + * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#pragma once + +#include "sinks.h" + +class CInputContextOwnerCallBack; +class CInputContextOwner; + +HRESULT +Inquire( + _Out_ LPIMEINFO lpIMEInfo, + _Out_ LPWSTR lpszWndClass, + _In_ DWORD dwSystemInfoFlags, + _In_ HKL hKL); + +/*********************************************************************** + * CicInputContext + * + * The msctfime.ime's input context. + */ +class CicInputContext + : public ITfCleanupContextSink + , public ITfContextOwnerCompositionSink + , public ITfCompositionSink +{ +public: + LONG m_cRefs; + HIMC m_hIMC; + ITfDocumentMgr *m_pDocumentMgr; + ITfContext *m_pContext; + ITfContextOwnerServices *m_pContextOwnerServices; + CInputContextOwnerCallBack *m_pICOwnerCallback; + CTextEventSink *m_pTextEventSink; + CCompartmentEventSink *m_pCompEventSink1; + CCompartmentEventSink *m_pCompEventSink2; + CInputContextOwner *m_pInputContextOwner; + DWORD m_dwUnknown3[3]; + DWORD m_dwUnknown4[2]; + DWORD m_dwQueryPos; + DWORD m_dwUnknown5; + GUID m_guid; + DWORD m_dwUnknown6[11]; + BOOL m_bSelecting; + DWORD m_dwUnknown6_5; + LONG m_cCompLocks; + DWORD m_dwUnknown7[5]; + WORD m_cGuidAtoms; + WORD m_padding; + DWORD m_adwGuidAtoms[256]; + DWORD m_dwUnknown8[17]; + TfClientId m_clientId; + DWORD m_dwUnknown9; + +public: + CicInputContext( + _In_ TfClientId cliendId, + _Inout_ PCIC_LIBTHREAD pLibThread, + _In_ HIMC hIMC); + virtual ~CicInputContext() { } + + // IUnknown interface + STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; + STDMETHODIMP_(ULONG) AddRef() override; + STDMETHODIMP_(ULONG) Release() override; + + // ITfCleanupContextSink interface + STDMETHODIMP OnCleanupContext(_In_ TfEditCookie ecWrite, _Inout_ ITfContext *pic) override; + + // ITfContextOwnerCompositionSink interface + STDMETHODIMP OnStartComposition(ITfCompositionView *pComposition, BOOL *pfOk) override; + STDMETHODIMP OnUpdateComposition(ITfCompositionView *pComposition, ITfRange *pRangeNew) override; + STDMETHODIMP OnEndComposition(ITfCompositionView *pComposition) override; + + // ITfCompositionSink interface + STDMETHODIMP OnCompositionTerminated(TfEditCookie ecWrite, ITfComposition *pComposition) override; + + HRESULT + GetGuidAtom( + _Inout_ CicIMCLock& imcLock, + _In_ BYTE iAtom, + _Out_opt_ LPDWORD pdwGuidAtom); + + HRESULT CreateInputContext(_Inout_ ITfThreadMgr *pThreadMgr, _Inout_ CicIMCLock& imcLock); + HRESULT DestroyInputContext(); +}; diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp index ccd442083ab..445998d6a9c 100644 --- a/dll/ime/msctfime/msctfime.cpp +++ b/dll/ime/msctfime/msctfime.cpp @@ -20,87 +20,31 @@ BOOL gfTFInitLib = FALSE; CRITICAL_SECTION g_csLock; CDispAttrPropCache *g_pPropCache = NULL; -DEFINE_GUID(GUID_COMPARTMENT_CTFIME_DIMFLAGS, 0xA94C5FD2, 0xC471, 0x4031, 0x95, 0x46, 0x70, 0x9C, 0x17, 0x30, 0x0C, 0xB9); -DEFINE_GUID(GUID_COMPARTMENT_CTFIME_CICINPUTCONTEXT, 0x85A688F7, 0x6DC8, 0x4F17, 0xA8, 0x3A, 0xB1, 0x1C, 0x09, 0xCD, 0xD7, 0xBF); - EXTERN_C void __cxa_pure_virtual(void) { ERR("__cxa_pure_virtual\n"); } -UINT WM_MSIME_SERVICE = 0; -UINT WM_MSIME_UIREADY = 0; -UINT WM_MSIME_RECONVERTREQUEST = 0; -UINT WM_MSIME_RECONVERT = 0; -UINT WM_MSIME_DOCUMENTFEED = 0; -UINT WM_MSIME_QUERYPOSITION = 0; -UINT WM_MSIME_MODEBIAS = 0; -UINT WM_MSIME_SHOWIMEPAD = 0; -UINT WM_MSIME_MOUSE = 0; -UINT WM_MSIME_KEYMAP = 0; - -/// @implemented -BOOL IsMsImeMessage(_In_ UINT uMsg) -{ - return (uMsg == WM_MSIME_SERVICE || - uMsg == WM_MSIME_UIREADY || - uMsg == WM_MSIME_RECONVERTREQUEST || - uMsg == WM_MSIME_RECONVERT || - uMsg == WM_MSIME_DOCUMENTFEED || - uMsg == WM_MSIME_QUERYPOSITION || - uMsg == WM_MSIME_MODEBIAS || - uMsg == WM_MSIME_SHOWIMEPAD || - uMsg == WM_MSIME_MOUSE || - uMsg == WM_MSIME_KEYMAP); -} - -/// @implemented -BOOL RegisterMSIMEMessage(VOID) -{ - // Using ANSI (A) version here can reduce binary size. - WM_MSIME_SERVICE = RegisterWindowMessageA("MSIMEService"); - WM_MSIME_UIREADY = RegisterWindowMessageA("MSIMEUIReady"); - WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageA("MSIMEReconvertRequest"); - WM_MSIME_RECONVERT = RegisterWindowMessageA("MSIMEReconvert"); - WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed"); - WM_MSIME_QUERYPOSITION = RegisterWindowMessageA("MSIMEQueryPosition"); - WM_MSIME_MODEBIAS = RegisterWindowMessageA("MSIMEModeBias"); - WM_MSIME_SHOWIMEPAD = RegisterWindowMessageA("MSIMEShowImePad"); - WM_MSIME_MOUSE = RegisterWindowMessageA("MSIMEMouseOperation"); - WM_MSIME_KEYMAP = RegisterWindowMessageA("MSIMEKeyMap"); - return (WM_MSIME_SERVICE && - WM_MSIME_UIREADY && - WM_MSIME_RECONVERTREQUEST && - WM_MSIME_RECONVERT && - WM_MSIME_DOCUMENTFEED && - WM_MSIME_QUERYPOSITION && - WM_MSIME_MODEBIAS && - WM_MSIME_SHOWIMEPAD && - WM_MSIME_MOUSE && - WM_MSIME_KEYMAP); -} - -typedef BOOLEAN (WINAPI *FN_DllShutDownInProgress)(VOID); +typedef BOOLEAN (WINAPI *FN_DllShutdownInProgress)(VOID); /// This function calls ntdll!RtlDllShutdownInProgress. /// It can detect the system is shutting down or not. /// @implemented -EXTERN_C BOOLEAN WINAPI -DllShutDownInProgress(VOID) +EXTERN_C BOOLEAN WINAPI DllShutdownInProgress(VOID) { HMODULE hNTDLL; - static FN_DllShutDownInProgress s_fnDllShutDownInProgress = NULL; + static FN_DllShutdownInProgress s_fnDllShutdownInProgress = NULL; - if (s_fnDllShutDownInProgress) - return s_fnDllShutDownInProgress(); + if (s_fnDllShutdownInProgress) + return s_fnDllShutdownInProgress(); hNTDLL = cicGetSystemModuleHandle(L"ntdll.dll", FALSE); - s_fnDllShutDownInProgress = - (FN_DllShutDownInProgress)GetProcAddress(hNTDLL, "RtlDllShutdownInProgress"); - if (!s_fnDllShutDownInProgress) + s_fnDllShutdownInProgress = + (FN_DllShutdownInProgress)GetProcAddress(hNTDLL, "RtlDllShutdownInProgress"); + if (!s_fnDllShutdownInProgress) return FALSE; - return s_fnDllShutDownInProgress(); + return s_fnDllShutdownInProgress(); } /// This function checks if the current user logon session is interactive. @@ -195,2533 +139,115 @@ HRESULT InitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread) } ::LeaveCriticalSection(&g_csLock); - return hr; -} - -HIMC GetActiveContext(VOID) -{ - HWND hwndFocus = ::GetFocus(); - if (!hwndFocus) - hwndFocus = ::GetActiveWindow(); - return ::ImmGetContext(hwndFocus); -} - -/// @implemented -HRESULT UninitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread) -{ - if (!pLibThread) - return E_FAIL; - - if (pLibThread->m_pDisplayAttrMgr) - { - pLibThread->m_pDisplayAttrMgr->Release(); - pLibThread->m_pDisplayAttrMgr = NULL; - } - - return S_OK; -} - -/// Gets the charset from a language ID. -/// @implemented -BYTE GetCharsetFromLangId(_In_ DWORD dwValue) -{ - CHARSETINFO info; - if (!::TranslateCharsetInfo((DWORD*)(DWORD_PTR)dwValue, &info, TCI_SRCLOCALE)) - return 0; - return info.ciCharset; -} - -/// Selects or unselects the input context. -/// @implemented -HRESULT -InternalSelectEx( - _In_ HIMC hIMC, - _In_ BOOL fSelect, - _In_ LANGID LangID) -{ - CicIMCLock imcLock(hIMC); - if (!imcLock) - imcLock.m_hr = E_FAIL; - if (FAILED(imcLock.m_hr)) - return imcLock.m_hr; - - if (PRIMARYLANGID(LangID) == LANG_CHINESE) - { - imcLock.get().cfCandForm[0].dwStyle = 0; - imcLock.get().cfCandForm[0].dwIndex = (DWORD)-1; - } - - if (!fSelect) - { - imcLock.get().fdwInit &= ~INIT_GUIDMAP; - return imcLock.m_hr; - } - - if (!imcLock.ClearCand()) - return imcLock.m_hr; - - // Populate conversion mode - if (!(imcLock.get().fdwInit & INIT_CONVERSION)) - { - DWORD dwConv = (imcLock.get().fdwConversion & IME_CMODE_SOFTKBD); - if (LangID) - { - if (PRIMARYLANGID(LangID) == LANG_JAPANESE) - { - dwConv |= IME_CMODE_ROMAN | IME_CMODE_FULLSHAPE | IME_CMODE_NATIVE; - } - else if (PRIMARYLANGID(LangID) != LANG_KOREAN) - { - dwConv |= IME_CMODE_NATIVE; - } - } - imcLock.get().fdwConversion |= dwConv; - imcLock.get().fdwInit |= INIT_CONVERSION; - } - - // Populate sentence mode - imcLock.get().fdwSentence |= IME_SMODE_PHRASEPREDICT; - - // Populate LOGFONT - if (!(imcLock.get().fdwInit & INIT_LOGFONT)) - { - // Get logical font - LOGFONTW lf; - HDC hDC = ::GetDC(imcLock.get().hWnd); - HGDIOBJ hFont = GetCurrentObject(hDC, OBJ_FONT); - ::GetObjectW(hFont, sizeof(LOGFONTW), &lf); - ::ReleaseDC(imcLock.get().hWnd, hDC); - - imcLock.get().lfFont.W = lf; - imcLock.get().fdwInit |= INIT_LOGFONT; - } - imcLock.get().lfFont.W.lfCharSet = GetCharsetFromLangId(LangID); - - imcLock.InitContext(); - - return imcLock.m_hr; -} - -/*********************************************************************** - * Compartment - */ - -/// @implemented -HRESULT -GetCompartment( - IUnknown *pUnknown, - REFGUID rguid, - ITfCompartment **ppComp, - BOOL bThread) -{ - *ppComp = NULL; - - ITfThreadMgr *pThreadMgr = NULL; - ITfCompartmentMgr *pCompMgr = NULL; - - HRESULT hr; - if (bThread) - { - hr = pUnknown->QueryInterface(IID_ITfThreadMgr, (void **)&pThreadMgr); - if (FAILED(hr)) - return hr; - - hr = pThreadMgr->GetGlobalCompartment(&pCompMgr); - } - else - { - hr = pUnknown->QueryInterface(IID_ITfCompartmentMgr, (void **)&pCompMgr); - } - - if (SUCCEEDED(hr)) - { - hr = E_FAIL; - if (pCompMgr) - { - hr = pCompMgr->GetCompartment(rguid, ppComp); - pCompMgr->Release(); - } - } - - if (pThreadMgr) - pThreadMgr->Release(); - - return hr; -} - -/// @implemented -HRESULT -SetCompartmentDWORD( - TfEditCookie cookie, - IUnknown *pUnknown, - REFGUID rguid, - DWORD dwValue, - BOOL bThread) -{ - ITfCompartment *pComp = NULL; - HRESULT hr = GetCompartment(pUnknown, rguid, &pComp, bThread); - if (FAILED(hr)) - return hr; - - VARIANT vari; - V_I4(&vari) = dwValue; - V_VT(&vari) = VT_I4; - hr = pComp->SetValue(cookie, &vari); - - pComp->Release(); - return hr; -} - -/// @implemented -HRESULT -GetCompartmentDWORD( - IUnknown *pUnknown, - REFGUID rguid, - LPDWORD pdwValue, - BOOL bThread) -{ - *pdwValue = 0; - - ITfCompartment *pComp = NULL; - HRESULT hr = GetCompartment(pUnknown, rguid, &pComp, bThread); - if (FAILED(hr)) - return hr; - - VARIANT vari; - hr = pComp->GetValue(&vari); - if (hr == S_OK) - *pdwValue = V_I4(&vari); - - pComp->Release(); - return hr; -} - -/// @implemented -HRESULT -SetCompartmentUnknown( - TfEditCookie cookie, - IUnknown *pUnknown, - REFGUID rguid, - IUnknown *punkValue) -{ - ITfCompartment *pComp = NULL; - HRESULT hr = GetCompartment(pUnknown, rguid, &pComp, FALSE); - if (FAILED(hr)) - return hr; - - VARIANT vari; - V_UNKNOWN(&vari) = punkValue; - V_VT(&vari) = VT_UNKNOWN; - hr = pComp->SetValue(cookie, &vari); - - pComp->Release(); - return hr; -} - -/// @implemented -HRESULT -ClearCompartment( - TfClientId tid, - IUnknown *pUnknown, - REFGUID rguid, - BOOL bThread) -{ - ITfCompartmentMgr *pCompMgr = NULL; - ITfThreadMgr *pThreadMgr = NULL; - - HRESULT hr; - if (bThread) - { - hr = pUnknown->QueryInterface(IID_ITfThreadMgr, (void **)&pThreadMgr); - if (FAILED(hr)) - return hr; - - hr = pThreadMgr->GetGlobalCompartment(&pCompMgr); - } - else - { - hr = pUnknown->QueryInterface(IID_ITfCompartmentMgr, (void **)&pCompMgr); - } - - if (SUCCEEDED(hr)) - { - hr = E_FAIL; - if (pCompMgr) - { - hr = pCompMgr->ClearCompartment(tid, rguid); - pCompMgr->Release(); - } - } - - if (pThreadMgr) - pThreadMgr->Release(); - - return hr; -} - -typedef struct CESMAP -{ - ITfCompartment *m_pComp; - DWORD m_dwCookie; -} CESMAP, *PCESMAP; - -typedef INT (CALLBACK *FN_EVENTSINK)(LPVOID, REFGUID); - -class CCompartmentEventSink : public ITfCompartmentEventSink -{ - CicArray<CESMAP> m_array; - LONG m_cRefs; - FN_EVENTSINK m_fnEventSink; - LPVOID m_pUserData; - -public: - CCompartmentEventSink(FN_EVENTSINK fnEventSink, LPVOID pUserData); - virtual ~CCompartmentEventSink(); - - HRESULT _Advise(IUnknown *pUnknown, REFGUID rguid, BOOL bThread); - HRESULT _Unadvise(); - - // IUnknown interface - STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; - STDMETHODIMP_(ULONG) AddRef() override; - STDMETHODIMP_(ULONG) Release() override; - - // ITfCompartmentEventSink interface - STDMETHODIMP OnChange(REFGUID rguid) override; -}; - -/// @implemented -CCompartmentEventSink::CCompartmentEventSink(FN_EVENTSINK fnEventSink, LPVOID pUserData) - : m_array() - , m_cRefs(1) - , m_fnEventSink(fnEventSink) - , m_pUserData(pUserData) -{ -} - -/// @implemented -CCompartmentEventSink::~CCompartmentEventSink() -{ -} - -/// @implemented -STDMETHODIMP CCompartmentEventSink::QueryInterface(REFIID riid, LPVOID* ppvObj) -{ - if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfCompartmentEventSink)) - { - *ppvObj = this; - AddRef(); - return S_OK; - } - - *ppvObj = NULL; - return E_NOINTERFACE; -} - -/// @implemented -STDMETHODIMP_(ULONG) CCompartmentEventSink::AddRef() -{ - return ::InterlockedIncrement(&m_cRefs); -} - -/// @implemented -STDMETHODIMP_(ULONG) CCompartmentEventSink::Release() -{ - if (::InterlockedDecrement(&m_cRefs) == 0) - { - delete this; - return 0; - } - return m_cRefs; -} - -/// @implemented -STDMETHODIMP CCompartmentEventSink::OnChange(REFGUID rguid) -{ - return m_fnEventSink(m_pUserData, rguid); -} - -/// @implemented -HRESULT -CCompartmentEventSink::_Advise(IUnknown *pUnknown, REFGUID rguid, BOOL bThread) -{ - CESMAP *pCesMap = m_array.Append(1); - if (!pCesMap) - return E_OUTOFMEMORY; - - ITfSource *pSource = NULL; - - HRESULT hr = GetCompartment(pUnknown, rguid, &pCesMap->m_pComp, bThread); - if (FAILED(hr)) - { - hr = pCesMap->m_pComp->QueryInterface(IID_ITfSource, (void **)&pSource); - if (FAILED(hr)) - { - hr = pSource->AdviseSink(IID_ITfCompartmentEventSink, this, &pCesMap->m_dwCookie); - if (FAILED(hr)) - { - if (pCesMap->m_pComp) - { - pCesMap->m_pComp->Release(); - pCesMap->m_pComp = NULL; - } - m_array.Remove(m_array.size() - 1, 1); - } - else - { - hr = S_OK; - } - } - } - - if (pSource) - pSource->Release(); - - return hr; -} - -/// @implemented -HRESULT CCompartmentEventSink::_Unadvise() -{ - CESMAP *pCesMap = m_array.data(); - size_t cItems = m_array.size(); - if (!cItems) - return S_OK; - - do - { - ITfSource *pSource = NULL; - HRESULT hr = pCesMap->m_pComp->QueryInterface(IID_ITfSource, (void **)&pSource); - if (SUCCEEDED(hr)) - pSource->UnadviseSink(pCesMap->m_dwCookie); - - if (pCesMap->m_pComp) - { - pCesMap->m_pComp->Release(); - pCesMap->m_pComp = NULL; - } - - if (pSource) - pSource->Release(); - - ++pCesMap; - --cItems; - } while (cItems); - - return S_OK; -} - -class CInputContextOwnerCallBack; -class CInputContextOwner; - -typedef INT (CALLBACK *FN_ENDEDIT)(INT, LPVOID, LPVOID); -typedef INT (CALLBACK *FN_LAYOUTCHANGE)(UINT nType, FN_ENDEDIT fnEndEdit, ITfContextView *pView); - -class CTextEventSink : public ITfTextEditSink, ITfTextLayoutSink -{ -protected: - LONG m_cRefs; - IUnknown *m_pUnknown; - DWORD m_dwEditSinkCookie; - DWORD m_dwLayoutSinkCookie; - union - { - UINT m_uFlags; - FN_LAYOUTCHANGE m_fnLayoutChange; - }; - FN_ENDEDIT m_fnEndEdit; - LPVOID m_pCallbackPV; - -public: - CTextEventSink(FN_ENDEDIT fnEndEdit, LPVOID pCallbackPV); - virtual ~CTextEventSink(); - - HRESULT _Advise(IUnknown *pUnknown, UINT uFlags); - HRESULT _Unadvise(); - - // IUnknown interface - STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; - STDMETHODIMP_(ULONG) AddRef() override; - STDMETHODIMP_(ULONG) Release() override; - - // ITfTextEditSink interface - STDMETHODIMP OnEndEdit( - ITfContext *pic, - TfEditCookie ecReadOnly, - ITfEditRecord *pEditRecord) override; - - // ITfTextLayoutSink interface - STDMETHODIMP - OnLayoutChange( - ITfContext *pContext, - TfLayoutCode lcode, - ITfContextView *pContextView) override; -}; - -/// @implemented -CTextEventSink::CTextEventSink(FN_ENDEDIT fnEndEdit, LPVOID pCallbackPV) -{ - m_cRefs = 1; - m_pUnknown = NULL; - m_dwEditSinkCookie = (DWORD)-1; - m_dwLayoutSinkCookie = (DWORD)-1; - m_fnLayoutChange = NULL; - m_fnEndEdit = fnEndEdit; - m_pCallbackPV = pCallbackPV; -} - -/// @implemented -CTextEventSink::~CTextEventSink() -{ -} - -/// @implemented -STDMETHODIMP CTextEventSink::QueryInterface(REFIID riid, LPVOID* ppvObj) -{ - if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfTextEditSink)) - { - *ppvObj = this; - AddRef(); - return S_OK; - } - if (IsEqualIID(riid, IID_ITfTextLayoutSink)) - { - *ppvObj = static_cast<ITfTextLayoutSink*>(this); - AddRef(); - return S_OK; - } - return E_NOINTERFACE; -} - -/// @implemented -STDMETHODIMP_(ULONG) CTextEventSink::AddRef() -{ - return ::InterlockedIncrement(&m_cRefs); -} - -/// @implemented -STDMETHODIMP_(ULONG) CTextEventSink::Release() -{ - if (::InterlockedDecrement(&m_cRefs) == 0) - { - delete this; - return 0; - } - return m_cRefs; -} - -struct TEXT_EVENT_SINK_END_EDIT -{ - TfEditCookie m_ecReadOnly; - ITfEditRecord *m_pEditRecord; - ITfContext *m_pContext; -}; - -/// @implemented -STDMETHODIMP CTextEventSink::OnEndEdit( - ITfContext *pic, - TfEditCookie ecReadOnly, - ITfEditRecord *pEditRecord) -{ - TEXT_EVENT_SINK_END_EDIT Data = { ecReadOnly, pEditRecord, pic }; - return m_fnEndEdit(1, m_pCallbackPV, (LPVOID)&Data); -} - -/// @implemented -STDMETHODIMP CTextEventSink::OnLayoutChange( - ITfContext *pContext, - TfLayoutCode lcode, - ITfContextView *pContextView) -{ - switch (lcode) - { - case TF_LC_CREATE: - return m_fnLayoutChange(3, m_fnEndEdit, pContextView); - case TF_LC_CHANGE: - return m_fnLayoutChange(2, m_fnEndEdit, pContextView); - case TF_LC_DESTROY: - return m_fnLayoutChange(4, m_fnEndEdit, pContextView); - default: - return E_INVALIDARG; - } -} - -/// @implemented -HRESULT CTextEventSink::_Advise(IUnknown *pUnknown, UINT uFlags) -{ - m_pUnknown = NULL; - m_uFlags = uFlags; - - ITfSource *pSource = NULL; - HRESULT hr = pUnknown->QueryInterface(IID_ITfSource, (void**)&pSource); - if (SUCCEEDED(hr)) - { - ITfTextEditSink *pSink = static_cast<ITfTextEditSink*>(this); - if (uFlags & 1) - hr = pSource->AdviseSink(IID_ITfTextEditSink, pSink, &m_dwEditSinkCookie); - if (SUCCEEDED(hr) && (uFlags & 2)) - hr = pSource->AdviseSink(IID_ITfTextLayoutSink, pSink, &m_dwLayoutSinkCookie); - - if (SUCCEEDED(hr)) - { - m_pUnknown = pUnknown; - pUnknown->AddRef(); - } - else - { - pSource->UnadviseSink(m_dwEditSinkCookie); - } - } - - if (pSource) - pSource->Release(); - - return hr; -} - -/// @implemented -HRESULT CTextEventSink::_Unadvise() -{ - if (!m_pUnknown) - return E_FAIL; - - ITfSource *pSource = NULL; - HRESULT hr = m_pUnknown->QueryInterface(IID_ITfSource, (void**)&pSource); - if (SUCCEEDED(hr)) - { - if (m_uFlags & 1) - hr = pSource->UnadviseSink(m_dwEditSinkCookie); - if (m_uFlags & 2) - hr = pSource->UnadviseSink(m_dwLayoutSinkCookie); - - pSource->Release(); - } - - m_pUnknown->Release(); - m_pUnknown = NULL; - - return E_NOTIMPL; -} - -/*********************************************************************** - * CicInputContext - * - * The msctfime.ime's input context. - */ -class CicInputContext - : public ITfCleanupContextSink - , public ITfContextOwnerCompositionSink - , public ITfCompositionSink -{ -public: - LONG m_cRefs; - HIMC m_hIMC; - ITfDocumentMgr *m_pDocumentMgr; - ITfContext *m_pContext; - ITfContextOwnerServices *m_pContextOwnerServices; - CInputContextOwnerCallBack *m_pICOwnerCallback; - CTextEventSink *m_pTextEventSink; - CCompartmentEventSink *m_pCompEventSink1; - CCompartmentEventSink *m_pCompEventSink2; - CInputContextOwner *m_pInputContextOwner; - DWORD m_dwUnknown3[3]; - DWORD m_dwUnknown4[2]; - DWORD m_dwQueryPos; - DWORD m_dwUnknown5; - GUID m_guid; - DWORD m_dwUnknown6[11]; - BOOL m_bSelecting; - DWORD m_dwUnknown6_5; - LONG m_cCompLocks; - DWORD m_dwUnknown7[5]; - WORD m_cGuidAtoms; - WORD m_padding; - DWORD m_adwGuidAtoms[256]; - DWORD m_dwUnknown8[17]; - TfClientId m_clientId; - DWORD m_dwUnknown9; - -public: - CicInputContext( - _In_ TfClientId cliendId, - _Inout_ PCIC_LIBTHREAD pLibThread, - _In_ HIMC hIMC); - virtual ~CicInputContext() { } - - // IUnknown interface - STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; - STDMETHODIMP_(ULONG) AddRef() override; - STDMETHODIMP_(ULONG) Release() override; - - // ITfCleanupContextSink interface - STDMETHODIMP OnCleanupContext(_In_ TfEditCookie ecWrite, _Inout_ ITfContext *pic) override; - - // ITfContextOwnerCompositionSink interface - STDMETHODIMP OnStartComposition(ITfCompositionView *pComposition, BOOL *pfOk) override; - STDMETHODIMP OnUpdateComposition(ITfCompositionView *pComposition, ITfRange *pRangeNew) override; - STDMETHODIMP OnEndComposition(ITfCompositionView *pComposition) override; - - // ITfCompositionSink interface - STDMETHODIMP OnCompositionTerminated(TfEditCookie ecWrite, ITfComposition *pComposition) override; - - HRESULT - GetGuidAtom( - _Inout_ CicIMCLock& imcLock, - _In_ BYTE iAtom, - _Out_opt_ LPDWORD pdwGuidAtom); - - HRESULT CreateInputContext(_Inout_ ITfThreadMgr *pThreadMgr, _Inout_ CicIMCLock& imcLock); - HRESULT DestroyInputContext(); -}; - -/// @unimplemented -CicInputContext::CicInputContext( - _In_ TfClientId cliendId, - _Inout_ PCIC_LIBTHREAD pLibThread, - _In_ HIMC hIMC) -{ - m_hIMC = hIMC; - m_guid = GUID_NULL; - m_dwQueryPos = 0; - m_cRefs = 1; -} - -/// @implemented -STDMETHODIMP CicInputContext::QueryInterface(REFIID riid, LPVOID* ppvObj) -{ - *ppvObj = NULL; - - if (IsEqualIID(riid, IID_ITfContextOwnerCompositionSink)) - { - *ppvObj = static_cast<ITfContextOwnerCompositionSink*>(this); - AddRef(); - return S_OK; - } - if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfCleanupContextSink)) - { - *ppvObj = this; - AddRef(); - return S_OK; - } - - return E_NOINTERFACE; -} - -/// @implemented -STDMETHODIMP_(ULONG) CicInputContext::AddRef() -{ - return ::InterlockedIncrement(&m_cRefs); -} - -/// @implemented -STDMETHODIMP_(ULONG) CicInputContext::Release() -{ - if (::InterlockedDecrement(&m_cRefs) == 0) - { - delete this; - return 0; - } - return m_cRefs; -} - -/// @implemented -STDMETHODIMP -CicInputContext::OnStartComposition( - ITfCompositionView *pComposition, - BOOL *pfOk) -{ - if ((m_cCompLocks <= 0) || m_dwUnknown6_5) - { - *pfOk = TRUE; - ++m_cCompLocks; - } - else - { - *pfOk = FALSE; - } - return S_OK; -} - -/// @implemented -STDMETHODIMP -CicInputContext::OnUpdateComposition( - ITfCompositionView *pComposition, - ITfRange *pRangeNew) -{ - return S_OK; -} - -/// @implemented -STDMETHODIMP -CicInputContext::OnEndComposition( - ITfCompositionView *pComposition) -{ - --m_cCompLocks; - return S_OK; -} - -/// @implemented -HRESULT -CicInputContext::GetGuidAtom( - _Inout_ CicIMCLock& imcLock, - _In_ BYTE iAtom, - _Out_opt_ LPDWORD pdwGuidAtom) -{ - CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCompStr); - HRESULT hr = imeContext.m_hr; - if (!imeContext) - hr = E_FAIL; - if (FAILED(hr)) - return hr; - - hr = E_FAIL; - if (iAtom < m_cGuidAtoms) - { - *pdwGuidAtom = m_adwGuidAtoms[iAtom]; - hr = S_OK; - } - - return hr; -} - -/// @unimplemented -HRESULT -CicInputContext::CreateInputContext( - _Inout_ ITfThreadMgr *pThreadMgr, - _Inout_ CicIMCLock& imcLock) -{ - //FIXME - return E_NOTIMPL; -} - -/// @unimplemented -HRESULT -CicInputContext::DestroyInputContext() -{ - ITfSourceSingle *pSource = NULL; - - if (m_pContext && m_pContext->QueryInterface(IID_ITfSourceSingle, (void **)&pSource) == S_OK) - pSource->UnadviseSingleSink(m_clientId, IID_ITfCleanupContextSink); - - //FIXME: m_dwUnknown5 - - if (m_pTextEventSink) - { - m_pTextEventSink->_Unadvise(); - m_pTextEventSink->Release(); - m_pTextEventSink = NULL; - } - - if (m_pCompEventSink2) - { - m_pCompEventSink2->_Unadvise(); - m_pCompEventSink2->Release(); - m_pCompEventSink2 = NULL; - } - - if (m_pCompEventSink1) - { - m_pCompEventSink1->_Unadvise(); - m_pCompEventSink1->Release(); - m_pCompEventSink1 = NULL; - } - - //FIXME: m_pInputContextOwner - - if (m_pDocumentMgr) - m_pDocumentMgr->Pop(1); - - if (m_pContext) - { - ClearCompartment(m_clientId, m_pContext, GUID_COMPARTMENT_CTFIME_CICINPUTCONTEXT, 0); - m_pContext->Release(); - m_pContext = NULL; - } - - if (m_pContextOwnerServices) - { - m_pContextOwnerServices->Release(); - m_pContextOwnerServices = NULL; - } - - // FIXME: m_pICOwnerCallback - - if (m_pDocumentMgr) - { - m_pDocumentMgr->Release(); - m_pDocumentMgr = NULL; - } - - if (pSource) - pSource->Release(); - - return S_OK; -} - -/// @implemented -STDMETHODIMP -CicInputContext::OnCompositionTerminated(TfEditCookie ecWrite, ITfComposition *pComposition) -{ - return S_OK; -} - -/// Retrieves the IME information. -/// @implemented -HRESULT -Inquire( - _Out_ LPIMEINFO lpIMEInfo, - _Out_ LPWSTR lpszWndClass, - _In_ DWORD dwSystemInfoFlags, - _In_ HKL hKL) -{ - if (!lpIMEInfo) - return E_OUTOFMEMORY; - - StringCchCopyW(lpszWndClass, 64, L"MSCTFIME UI"); - lpIMEInfo->dwPrivateDataSize = 0; - - switch (LOWORD(hKL)) // Language ID - { - case MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT): // Japanese - { - lpIMEInfo->fdwProperty = IME_PROP_COMPLETE_ON_UNSELECT | IME_PROP_SPECIAL_UI | - IME_PROP_AT_CARET | IME_PROP_NEED_ALTKEY | - IME_PROP_KBD_CHAR_FIRST; - lpIMEInfo->fdwConversionCaps = IME_CMODE_FULLSHAPE | IME_CMODE_KATAKANA | - IME_CMODE_NATIVE; - lpIMEInfo->fdwSentenceCaps = IME_SMODE_CONVERSATION | IME_SMODE_PLAURALCLAUSE; - lpIMEInfo->fdwSelectCaps = SELECT_CAP_SENTENCE | SELECT_CAP_CONVERSION; - lpIMEInfo->fdwSCSCaps = SCS_CAP_SETRECONVERTSTRING | SCS_CAP_MAKEREAD | - SCS_CAP_COMPSTR; - lpIMEInfo->fdwUICaps = UI_CAP_ROT90; - break; - } - case MAKELANGID(LANG_KOREAN, SUBLANG_DEFAULT): // Korean - { - lpIMEInfo->fdwProperty = IME_PROP_COMPLETE_ON_UNSELECT | IME_PROP_SPECIAL_UI | - IME_PROP_AT_CARET | IME_PROP_NEED_ALTKEY | - IME_PROP_KBD_CHAR_FIRST; - lpIMEInfo->fdwConversionCaps = IME_CMODE_FULLSHAPE | IME_CMODE_NATIVE; - lpIMEInfo->fdwSentenceCaps = 0; - lpIMEInfo->fdwSCSCaps = SCS_CAP_SETRECONVERTSTRING | SCS_CAP_COMPSTR; - lpIMEInfo->fdwSelectCaps = SELECT_CAP_CONVERSION; - lpIMEInfo->fdwUICaps = UI_CAP_ROT90; - break; - } - case MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED): // Simplified Chinese - case MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL): // Traditional Chinese - { - lpIMEInfo->fdwProperty = IME_PROP_SPECIAL_UI | IME_PROP_AT_CARET | - IME_PROP_NEED_ALTKEY | IME_PROP_KBD_CHAR_FIRST; - lpIMEInfo->fdwConversionCaps = IME_CMODE_FULLSHAPE | IME_CMODE_NATIVE; - lpIMEInfo->fdwSentenceCaps = SELECT_CAP_CONVERSION; - lpIMEInfo->fdwSelectCaps = 0; - lpIMEInfo->fdwSCSCaps = SCS_CAP_SETRECONVERTSTRING | SCS_CAP_MAKEREAD | - SCS_CAP_COMPSTR; - lpIMEInfo->fdwUICaps = UI_CAP_ROT90; - break; - } - default: // Otherwise - { - lpIMEInfo->fdwProperty = IME_PROP_UNICODE | IME_PROP_AT_CARET; - lpIMEInfo->fdwConversionCaps = 0; - lpIMEInfo->fdwSentenceCaps = 0; - lpIMEInfo->fdwSCSCaps = 0; - lpIMEInfo->fdwUICaps = 0; - lpIMEInfo->fdwSelectCaps = 0; - break; - } - } - - return S_OK; -} - -class TLS; - -typedef INT (CALLBACK *FN_INITDOCMGR)(UINT, ITfDocumentMgr *, ITfDocumentMgr *, LPVOID); -typedef INT (CALLBACK *FN_PUSHPOP)(UINT, ITfContext *, LPVOID); - -class CThreadMgrEventSink : public ITfThreadMgrEventSink -{ -protected: - ITfThreadMgr *m_pThreadMgr; - DWORD m_dwCookie; - FN_INITDOCMGR m_fnInit; - FN_PUSHPOP m_fnPushPop; - DWORD m_dw; - LPVOID m_pCallbackPV; - LONG m_cRefs; - -public: - CThreadMgrEventSink( - _In_ FN_INITDOCMGR fnInit, - _In_ FN_PUSHPOP fnPushPop = NULL, - _Inout_ LPVOID pvCallbackPV = NULL); - virtual ~CThreadMgrEventSink() { } - - void SetCallbackPV(_Inout_ LPVOID pv); - HRESULT _Advise(ITfThreadMgr *pThreadMgr); - HRESULT _Unadvise(); - - // IUnknown interface - STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; - STDMETHODIMP_(ULONG) AddRef() override; - STDMETHODIMP_(ULONG) Release() override; - - // ITfThreadMgrEventSink interface - STDMETHODIMP OnInitDocumentMgr(ITfDocumentMgr *pdim) override; - STDMETHODIMP OnUninitDocumentMgr(ITfDocumentMgr *pdim) override; - STDMETHODIMP OnSetFocus(ITfDocumentMgr *pdimFocus, ITfDocumentMgr *pdimPrevFocus) override; - STDMETHODIMP OnPushContext(ITfContext *pic) override; - STDMETHODIMP OnPopContext(ITfContext *pic) override; - - static INT CALLBACK DIMCallback( - UINT nCode, - ITfDocumentMgr *pDocMgr1, - ITfDocumentMgr *pDocMgr2, - LPVOID pUserData); -}; - -/// @implemented -CThreadMgrEventSink::CThreadMgrEventSink( - _In_ FN_INITDOCMGR fnInit, - _In_ FN_PUSHPOP fnPushPop, - _Inout_ LPVOID pvCallbackPV) -{ - m_fnInit = fnInit; - m_fnPushPop = fnPushPop; - m_pCallbackPV = pvCallbackPV; - m_cRefs = 1; -} - -/// @implemented -STDMETHODIMP CThreadMgrEventSink::QueryInterface(REFIID riid, LPVOID* ppvObj) -{ - if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfThreadMgrEventSink)) - { - *ppvObj = this; - AddRef(); - return S_OK; - } - *ppvObj = NULL; - return E_NOINTERFACE; -} - -/// @implemented -STDMETHODIMP_(ULONG) CThreadMgrEventSink::AddRef() -{ - return ::InterlockedIncrement(&m_cRefs); -} - -/// @implemented -STDMETHODIMP_(ULONG) CThreadMgrEventSink::Release() -{ - if (::InterlockedDecrement(&m_cRefs) == 0) - { - delete this; - return 0; - } - return m_cRefs; -} - -INT CALLBACK -CThreadMgrEventSink::DIMCallback( - UINT nCode, - ITfDocumentMgr *pDocMgr1, - ITfDocumentMgr *pDocMgr2, - LPVOID pUserData) -{ - return E_NOTIMPL; -} - -STDMETHODIMP CThreadMgrEventSink::OnInitDocumentMgr(ITfDocumentMgr *pdim) -{ - if (!m_fnInit) - return S_OK; - return m_fnInit(0, pdim, NULL, m_pCallbackPV); -} - -STDMETHODIMP CThreadMgrEventSink::OnUninitDocumentMgr(ITfDocumentMgr *pdim) -{ - if (!m_fnInit) - return S_OK; - return m_fnInit(1, pdim, NULL, m_pCallbackPV); -} - -STDMETHODIMP -CThreadMgrEventSink::OnSetFocus(ITfDocumentMgr *pdimFocus, ITfDocumentMgr *pdimPrevFocus) -{ - if (!m_fnInit) - return S_OK; - return m_fnInit(2, pdimFocus, pdimPrevFocus, m_pCallbackPV); -} - -STDMETHODIMP CThreadMgrEventSink::OnPushContext(ITfContext *pic) -{ - if (!m_fnPushPop) - return S_OK; - return m_fnPushPop(3, pic, m_pCallbackPV); -} - -STDMETHODIMP CThreadMgrEventSink::OnPopContext(ITfContext *pic) -{ - if (!m_fnPushPop) - return S_OK; - return m_fnPushPop(4, pic, m_pCallbackPV); -} - -void CThreadMgrEventSink::SetCallbackPV(_Inout_ LPVOID pv) -{ - if (!m_pCallbackPV) - m_pCallbackPV = pv; -} - -HRESULT CThreadMgrEventSink::_Advise(ITfThreadMgr *pThreadMgr) -{ - m_pThreadMgr = NULL; - - HRESULT hr = E_FAIL; - ITfSource *pSource = NULL; - if (pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK && - pSource->AdviseSink(IID_ITfThreadMgrEventSink, this, &m_dwCookie) == S_OK) - { - m_pThreadMgr = pThreadMgr; - pThreadMgr->AddRef(); - hr = S_OK; - } - - if (pSource) - pSource->Release(); - - return hr; -} - -HRESULT CThreadMgrEventSink::_Unadvise() -{ - HRESULT hr = E_FAIL; - ITfSource *pSource = NULL; - - if (m_pThreadMgr) - { - if (m_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK && - pSource->UnadviseSink(m_dwCookie) == S_OK) - { - hr = S_OK; - } - - if (pSource) - pSource->Release(); - } - - if (m_pThreadMgr) - { - m_pThreadMgr->Release(); - m_pThreadMgr = NULL; - } - - return hr; -} - -class CFunctionProviderBase : public ITfFunctionProvider -{ -protected: - TfClientId m_clientId; - GUID m_guid; - BSTR m_bstr; - LONG m_cRefs; - -public: - CFunctionProviderBase(_In_ TfClientId clientId); - virtual ~CFunctionProviderBase(); - - // IUnknown interface - STDMETHODIMP QueryInterface(_In_ REFIID riid, _Out_ LPVOID* ppvObj) override; - STDMETHODIMP_(ULONG) AddRef() override; - STDMETHODIMP_(ULONG) Release() override; - - // ITfFunctionProvider interface - STDMETHODIMP GetType(_Out_ GUID *guid) override; - STDMETHODIMP GetDescription(_Out_ BSTR *desc) override; - //STDMETHODIMP GetFunction(_In_ REFGUID guid, _In_ REFIID riid, _Out_ IUnknown **func) = 0; - - BOOL Init(_In_ REFGUID rguid, _In_ LPCWSTR psz); -}; - -/// @implemented -CFunctionProviderBase::CFunctionProviderBase(_In_ TfClientId clientId) -{ - m_clientId = clientId; - m_guid = GUID_NULL; - m_bstr = NULL; - m_cRefs = 1; -} - -/// @implemented -CFunctionProviderBase::~CFunctionProviderBase() -{ - if (!RtlDllShutdownInProgress()) - ::SysFreeString(m_bstr); -} - -/// @implemented -BOOL -CFunctionProviderBase::Init( - _In_ REFGUID rguid, - _In_ LPCWSTR psz) -{ - m_bstr = ::SysAllocString(psz); - m_guid = rguid; - return (m_bstr != NULL); -} - -class CFnDocFeed : public IAImmFnDocFeed -{ - LONG m_cRefs; - -public: - CFnDocFeed(); - virtual ~CFnDocFeed(); - - // IUnknown interface - STDMETHODIMP QueryInterface(_In_ REFIID riid, _Out_ LPVOID* ppvObj) override; - STDMETHODIMP_(ULONG) AddRef() override; - STDMETHODIMP_(ULONG) Release() override; - - // IAImmFnDocFeed interface - STDMETHODIMP DocFeed() override; - STDMETHODIMP ClearDocFeedBuffer() override; - STDMETHODIMP StartReconvert() override; - STDMETHODIMP StartUndoCompositionString() override; -}; - -CFnDocFeed::CFnDocFeed() -{ - m_cRefs = 1; -} - -CFnDocFeed::~CFnDocFeed() -{ -} - -/// @implemented -STDMETHODIMP CFnDocFeed::QueryInterface(_In_ REFIID riid, _Out_ LPVOID* ppvObj) -{ - if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IAImmFnDocFeed)) - { - *ppvObj = this; - AddRef(); - return S_OK; - } - return E_NOINTERFACE; -} - -/// @implemented -STDMETHODIMP_(ULONG) CFnDocFeed::AddRef() -{ - return ::InterlockedIncrement(&m_cRefs); -} - -/// @implemented -STDMETHODIMP_(ULONG) CFnDocFeed::Release() -{ - if (::InterlockedDecrement(&m_cRefs) == 0) - { - delete this; - return 0; - } - return m_cRefs; -} - -/// @unimplemented -STDMETHODIMP CFnDocFeed::DocFeed() -{ - return E_NOTIMPL; -} - -/// @unimplemented -STDMETHODIMP CFnDocFeed::ClearDocFeedBuffer() -{ - return E_NOTIMPL; -} - -/// @unimplemented -STDMETHODIMP CFnDocFeed::StartReconvert() -{ - return E_NOTIMPL; -} - -/// @unimplemented -STDMETHODIMP CFnDocFeed::StartUndoCompositionString() -{ - return E_NOTIMPL; -} - -/// @implemented -STDMETHODIMP -CFunctionProviderBase::QueryInterface( - _In_ REFIID riid, - _Out_ LPVOID* ppvObj) -{ - if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfFunctionProvider)) - { - *ppvObj = this; - AddRef(); - return S_OK; - } - return E_NOINTERFACE; -} - -/// @implemented -STDMETHODIMP_(ULONG) CFunctionProviderBase::AddRef() -{ - return ::InterlockedIncrement(&m_cRefs); -} - -/// @implemented -STDMETHODIMP_(ULONG) CFunctionProviderBase::Release() -{ - if (::InterlockedDecrement(&m_cRefs) == 0) - { - delete this; - return 0; - } - return m_cRefs; -} - -/// @implemented -STDMETHODIMP CFunctionProviderBase::GetType(_Out_ GUID *guid) -{ - *guid = m_guid; - return S_OK; -} - -/// @implemented -STDMETHODIMP CFunctionProviderBase::GetDescription(_Out_ BSTR *desc) -{ - *desc = ::SysAllocString(m_bstr); - return (*desc ? S_OK : E_OUTOFMEMORY); -} - -class CFunctionProvider : public CFunctionProviderBase -{ -public: - CFunctionProvider(_In_ TfClientId clientId); - - STDMETHODIMP GetFunction(_In_ REFGUID guid, _In_ REFIID riid, _Out_ IUnknown **func) override; -}; - -/// @implemented -CFunctionProvider::CFunctionProvider(_In_ TfClientId clientId) : CFunctionProviderBase(clientId) -{ - Init(CLSID_CAImmLayer, L"MSCTFIME::Function Provider"); -} - -/// @implemented -STDMETHODIMP -CFunctionProvider::GetFunction( - _In_ REFGUID guid, - _In_ REFIID riid, - _Out_ IUnknown **func) -{ - *func = NULL; - - if (IsEqualGUID(guid, GUID_NULL) && - IsEqualIID(riid, IID_IAImmFnDocFeed)) - { - *func = new(cicNoThrow) CFnDocFeed(); - if (*func) - return S_OK; - } - - return E_NOINTERFACE; -} - -/* FIXME */ -class CicBridge : public ITfSysHookSink -{ -protected: - LONG m_cRefs; - BOOL m_bImmxInited; - BOOL m_bUnknown1; - BOOL m_bDeactivating; - DWORD m_cActivateLocks; - ITfKeystrokeMgr *m_pKeystrokeMgr; - ITfDocumentMgr *m_pDocMgr; - CThreadMgrEventSink *m_pThreadMgrEventSink; - TfClientId m_cliendId; - CIC_LIBTHREAD m_LibThread; - BOOL m_bUnknown2; - - static BOOL CALLBACK EnumCreateInputContextCallback(HIMC hIMC, LPARAM lParam); - static BOOL CALLBACK EnumDestroyInputContextCallback(HIMC hIMC, LPARAM lParam); - -public: - CicBridge(); - virtual ~CicBridge(); - - // IUnknown interface - STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; - STDMETHODIMP_(ULONG) AddRef() override; - STDMETHODIMP_(ULONG) Release() override; - - // ITfSysHookSink interface - STDMETHODIMP OnPreFocusDIM(HWND hwnd) override; - STDMETHODIMP OnSysKeyboardProc(UINT, LONG) override; - STDMETHODIMP OnSysShellProc(INT, UINT, LONG) override; - - HRESULT InitIMMX(_Inout_ TLS *pTLS); - BOOL UnInitIMMX(_Inout_ TLS *pTLS); - HRESULT ActivateIMMX(_Inout_ TLS *pTLS, _Inout_ ITfThreadMgr_P *pThreadMgr); - HRESULT DeactivateIMMX(_Inout_ TLS *pTLS, _Inout_ ITfThreadMgr_P *pThreadMgr); - - HRESULT CreateInputContext(TLS *pTLS, HIMC hIMC); - HRESULT DestroyInputContext(TLS *pTLS, HIMC hIMC); - ITfContext *GetInputContext(CicIMCCLock<CTFIMECONTEXT>& imeContext); - - HRESULT SelectEx( - _Inout_ TLS *pTLS, - _Inout_ ITfThreadMgr_P *pThreadMgr, - _In_ HIMC hIMC, - _In_ BOOL fSelect, - _In_ HKL hKL); - HRESULT OnSetOpenStatus( - TLS *pTLS, - ITfThreadMgr_P *pThreadMgr, - CicIMCLock& imcLock, - CicInputContext *pCicIC); - - void PostTransMsg(_In_ HWND hWnd, _In_ INT cTransMsgs, _In_ const TRANSMSG *pTransMsgs); - void GetDocumentManager(_Inout_ CicIMCCLock<CTFIMECONTEXT>& imeContext); - - HRESULT - ConfigureGeneral(_Inout_ TLS* pTLS, - _In_ ITfThreadMgr *pThreadMgr, - _In_ HKL hKL, - _In_ HWND hWnd); - HRESULT ConfigureRegisterWord( - _Inout_ TLS* pTLS, - _In_ ITfThreadMgr *pThreadMgr, - _In_ HKL hKL, - _In_ HWND hWnd, - _Inout_opt_ LPVOID lpData); -}; - -class CActiveLanguageProfileNotifySink : public ITfActiveLanguageProfileNotifySink -{ -protected: - typedef INT (CALLBACK *FN_COMPARE)(REFGUID rguid1, REFGUID rguid2, BOOL fActivated, LPVOID pUserData); - LONG m_cRefs; - ITfThreadMgr *m_pThreadMgr; - DWORD m_dwConnection; - FN_COMPARE m_fnCompare; - LPVOID m_pUserData; - -public: - CActiveLanguageProfileNotifySink(_In_ FN_COMPARE fnCompare, _Inout_opt_ void *pUserData); - virtual ~CActiveLanguageProfileNotifySink(); - - HRESULT _Advise(ITfThreadMgr *pThreadMgr); - HRESULT _Unadvise(); - - // IUnknown interface - STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; - STDMETHODIMP_(ULONG) AddRef() override; - STDMETHODIMP_(ULONG) Release() override; - - // ITfActiveLanguageProfileNotifySink interface - STDMETHODIMP - OnActivated( - REFCLSID clsid, - REFGUID guidProfile, - BOOL fActivated) override; -}; - -/// @implemented -CActiveLanguageProfileNotifySink::CActiveLanguageProfileNotifySink( - _In_ FN_COMPARE fnCompare, - _Inout_opt_ void *pUserData) -{ - m_dwConnection = (DWORD)-1; - m_fnCompare = fnCompare; - m_cRefs = 1; - m_pUserData = pUserData; -} - -/// @implemented -CActiveLanguageProfileNotifySink::~CActiveLanguageProfileNotifySink() -{ -} - -/// @implemented -STDMETHODIMP CActiveLanguageProfileNotifySink::QueryInterface(REFIID riid, LPVOID* ppvObj) -{ - if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfActiveLanguageProfileNotifySink)) - { - *ppvObj = this; - AddRef(); - return S_OK; - } - *ppvObj = NULL; - return E_NOINTERFACE; -} - -/// @implemented -STDMETHODIMP_(ULONG) CActiveLanguageProfileNotifySink::AddRef() -{ - return ::InterlockedIncrement(&m_cRefs); -} - -/// @implemented -STDMETHODIMP_(ULONG) CActiveLanguageProfileNotifySink::Release() -{ - if (::InterlockedDecrement(&m_cRefs) == 0) - { - delete this; - return 0; - } - return m_cRefs; -} - -/// @implemented -STDMETHODIMP -CActiveLanguageProfileNotifySink::OnActivated( - REFCLSID clsid, - REFGUID guidProfile, - BOOL fActivated) -{ - if (!m_fnCompare) - return 0; - - return m_fnCompare(clsid, guidProfile, fActivated, m_pUserData); -} - -/// @implemented -HRESULT -CActiveLanguageProfileNotifySink::_Advise( - ITfThreadMgr *pThreadMgr) -{ - m_pThreadMgr = NULL; - - ITfSource *pSource = NULL; - HRESULT hr = pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource); - if (FAILED(hr)) - return E_FAIL; - - hr = pSource->AdviseSink(IID_ITfActiveLanguageProfileNotifySink, this, &m_dwConnection); - if (SUCCEEDED(hr)) - { - m_pThreadMgr = pThreadMgr; - pThreadMgr->AddRef(); - hr = S_OK; - } - else - { - hr = E_FAIL; - } - - if (pSource) - pSource->Release(); - - return hr; -} - -/// @implemented -HRESULT -CActiveLanguageProfileNotifySink::_Unadvise() -{ - if (!m_pThreadMgr) - return E_FAIL; - - ITfSource *pSource = NULL; - HRESULT hr = m_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource); - if (SUCCEEDED(hr)) - { - hr = pSource->UnadviseSink(m_dwConnection); - if (SUCCEEDED(hr)) - hr = S_OK; - } - - if (pSource) - pSource->Release(); - - if (m_pThreadMgr) - { - m_pThreadMgr->Release(); - m_pThreadMgr = NULL; - } - - return hr; -} - -/* FIXME */ -class CicProfile : public IUnknown -{ -protected: - ITfInputProcessorProfiles *m_pIPProfiles; - CActiveLanguageProfileNotifySink *m_pActiveLanguageProfileNotifySink; - LANGID m_LangID1; - WORD m_padding1; - DWORD m_dwFlags; - UINT m_nCodePage; - LANGID m_LangID2; - WORD m_padding2; - DWORD m_dwUnknown1; - LONG m_cRefs; - - static INT CALLBACK - ActiveLanguageProfileNotifySinkCallback( - REFGUID rguid1, - REFGUID rguid2, - BOOL fActivated, - LPVOID pUserData); - -public: - CicProfile(); - virtual ~CicProfile(); - - // IUnknown interface - STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; - STDMETHODIMP_(ULONG) AddRef() override; - STDMETHODIMP_(ULONG) Release() override; - - HRESULT - GetActiveLanguageProfile( - _In_ HKL hKL, - _In_ REFGUID rguid, - _Out_ TF_LANGUAGEPROFILE *pProfile); - HRESULT GetLangId(_Out_ LANGID *pLangID); - HRESULT GetCodePageA(_Out_ UINT *puCodePage); - - HRESULT InitProfileInstance(_Inout_ TLS *pTLS); -}; - -/// @implemented -CicProfile::CicProfile() -{ - m_dwFlags &= 0xFFFFFFF0; - m_cRefs = 1; - m_pIPProfiles = NULL; - m_pActiveLanguageProfileNotifySink = NULL; - m_LangID1 = 0; - m_nCodePage = CP_ACP; - m_LangID2 = 0; - m_dwUnknown1 = 0; -} - -/// @implemented -CicProfile::~CicProfile() -{ - if (m_pIPProfiles) - { - if (m_LangID1) - m_pIPProfiles->ChangeCurrentLanguage(m_LangID1); - - m_pIPProfiles->Release(); - m_pIPProfiles = NULL; - } - - if (m_pActiveLanguageProfileNotifySink) - { - m_pActiveLanguageProfileNotifySink->_Unadvise(); - m_pActiveLanguageProfileNotifySink->Release(); - m_pActiveLanguageProfileNotifySink = NULL; - } -} - -/// @implemented -STDMETHODIMP CicProfile::QueryInterface(REFIID riid, LPVOID* ppvObj) -{ - *ppvObj = NULL; - return E_NOINTERFACE; -} - -/// @implemented -STDMETHODIMP_(ULONG) CicProfile::AddRef() -{ - return ::InterlockedIncrement(&m_cRefs); -} - -/// @implemented -STDMETHODIMP_(ULONG) CicProfile::Release() -{ - if (::InterlockedDecrement(&m_cRefs) == 0) - { - delete this; - return 0; - } - return m_cRefs; -} - -/// @implemented -INT CALLBACK -CicProfile::ActiveLanguageProfileNotifySinkCallback( - REFGUID rguid1, - REFGUID rguid2, - BOOL fActivated, - LPVOID pUserData) -{ - CicProfile *pThis = (CicProfile *)pUserData; - pThis->m_dwFlags &= ~0xE; - return 0; -} - -/// @implemented -HRESULT CicProfile::GetCodePageA(_Out_ UINT *puCodePage) -{ - if (!puCodePage) - return E_INVALIDARG; - - if (m_dwFlags & 2) - { - *puCodePage = m_nCodePage; - return S_OK; - } - - *puCodePage = 0; - - LANGID LangID; - HRESULT hr = GetLangId(&LangID); - if (FAILED(hr)) - return E_FAIL; - - WCHAR szBuff[12]; - INT cch = ::GetLocaleInfoW(LangID, LOCALE_IDEFAULTANSICODEPAGE, szBuff, _countof(szBuff)); - if (cch) - { - szBuff[cch] = 0; - m_nCodePage = *puCodePage = wcstoul(szBuff, NULL, 10); - m_dwFlags |= 2; - } - - return S_OK; -} - -/// @implemented -HRESULT CicProfile::GetLangId(_Out_ LANGID *pLangID) -{ - *pLangID = 0; - - if (!m_pIPProfiles) - return E_FAIL; - - if (m_dwFlags & 4) - { - *pLangID = m_LangID2; - return S_OK; - } - - HRESULT hr = m_pIPProfiles->GetCurrentLanguage(pLangID); - if (SUCCEEDED(hr)) - { - m_dwFlags |= 4; - m_LangID2 = *pLangID; - } - - return hr; -} - -class TLS -{ -public: - static DWORD s_dwTlsIndex; - - DWORD m_dwSystemInfoFlags; - CicBridge *m_pBridge; - CicProfile *m_pProfile; - ITfThreadMgr_P *m_pThreadMgr; - DWORD m_dwFlags1; - DWORD m_dwFlags2; - DWORD m_dwUnknown2; - BOOL m_bDestroyed; - DWORD m_dwNowOpening; - DWORD m_NonEAComposition; - DWORD m_cWnds; - - /** - * @implemented - */ - static BOOL Initialize() - { - s_dwTlsIndex = ::TlsAlloc(); - return s_dwTlsIndex != (DWORD)-1; - } - - /** - * @implemented - */ - static VOID Uninitialize() - { - if (s_dwTlsIndex != (DWORD)-1) - { - ::TlsFree(s_dwTlsIndex); - s_dwTlsIndex = (DWORD)-1; - } - } - - /** - * @implemented - */ - static TLS* GetTLS() - { - if (s_dwTlsIndex == (DWORD)-1) - return NULL; - - return InternalAllocateTLS(); - } - - /** - * @implemented - */ - static TLS* PeekTLS() - { - return (TLS*)::TlsGetValue(TLS::s_dwTlsIndex); - } - - static TLS* InternalAllocateTLS(); - static BOOL InternalDestroyTLS(); - -}; - -DWORD TLS::s_dwTlsIndex = (DWORD)-1; - -/// @implemented -TLS* TLS::InternalAllocateTLS() -{ - TLS *pTLS = TLS::PeekTLS(); - if (pTLS) - return pTLS; - - if (DllShutDownInProgress()) - return NULL; - - pTLS = (TLS *)cicMemAllocClear(sizeof(TLS)); - if (!pTLS) - return NULL; - - if (!::TlsSetValue(s_dwTlsIndex, pTLS)) - { - cicMemFree(pTLS); - return NULL; - } - - pTLS->m_dwFlags1 |= 1; - pTLS->m_dwUnknown2 |= 1; - return pTLS; -} - -/// @implemented -BOOL TLS::InternalDestroyTLS() -{ - TLS *pTLS = TLS::PeekTLS(); - if (!pTLS) - return FALSE; - - if (pTLS->m_pBridge) - pTLS->m_pBridge->Release(); - if (pTLS->m_pProfile) - pTLS->m_pProfile->Release(); - if (pTLS->m_pThreadMgr) - pTLS->m_pThreadMgr->Release(); - - cicMemFree(pTLS); - ::TlsSetValue(s_dwTlsIndex, NULL); - return TRUE; -} - -/// @implemented -HRESULT -CicProfile::InitProfileInstance(_Inout_ TLS *pTLS) -{ - HRESULT hr = TF_CreateInputProcessorProfiles(&m_pIPProfiles); - if (FAILED(hr)) - return hr; - - if (!m_pActiveLanguageProfileNotifySink) - { - CActiveLanguageProfileNotifySink *pSink = - new(cicNoThrow) CActiveLanguageProfileNotifySink( - CicProfile::ActiveLanguageProfileNotifySinkCallback, this); - if (!pSink) - { - m_pIPProfiles->Release(); - m_pIPProfiles = NULL; - return E_FAIL; - } - m_pActiveLanguageProfileNotifySink = pSink; - } - - if (pTLS->m_pThreadMgr) - m_pActiveLanguageProfileNotifySink->_Advise(pTLS->m_pThreadMgr); - - return hr; -} - -/// @implemented -STDMETHODIMP -CicInputContext::OnCleanupContext( - _In_ TfEditCookie ecWrite, - _Inout_ ITfContext *pic) -{ - TLS *pTLS = TLS::PeekTLS(); - if (!pTLS || !pTLS->m_pProfile) - return E_OUTOFMEMORY; - - LANGID LangID; - pTLS->m_pProfile->GetLangId(&LangID); - - IMEINFO IMEInfo; - WCHAR szPath[MAX_PATH]; - if (Inquire(&IMEInfo, szPath, 0, (HKL)UlongToHandle(LangID)) != S_OK) - return E_FAIL; - - ITfProperty *pProp = NULL; - if (!(IMEInfo.fdwProperty & IME_PROP_COMPLETE_ON_UNSELECT)) - return S_OK; - - HRESULT hr = pic->GetProperty(GUID_PROP_COMPOSING, &pProp); - if (FAILED(hr)) - return S_OK; - - IEnumTfRanges *pRanges = NULL; - hr = pProp->EnumRanges(ecWrite, &pRanges, NULL); - if (SUCCEEDED(hr)) - { - ITfRange *pRange = NULL; - while (pRanges->Next(1, &pRange, 0) == S_OK) - { - VARIANT vari; - V_VT(&vari) = VT_EMPTY; - pProp->GetValue(ecWrite, pRange, &vari); - if (V_VT(&vari) == VT_I4) - { - if (V_I4(&vari)) - pProp->Clear(ecWrite, pRange); - } - pRange->Release(); - pRange = NULL; - } - pRanges->Release(); - } - pProp->Release(); - - return S_OK; -} - -/*********************************************************************** - * CicBridge - */ - -CicBridge::CicBridge() -{ - m_bImmxInited = FALSE; - m_bUnknown1 = FALSE; - m_bDeactivating = FALSE; - m_bUnknown2 = FALSE; - m_pKeystrokeMgr = NULL; - m_pDocMgr = NULL; - m_pThreadMgrEventSink = NULL; - m_cliendId = 0; - m_cRefs = 1; -} - -/// @implemented -STDMETHODIMP CicBridge::QueryInterface(REFIID riid, LPVOID* ppvObj) -{ - *ppvObj = NULL; - - if (!IsEqualIID(riid, IID_ITfSysHookSink)) - return E_NOINTERFACE; - - *ppvObj = this; - AddRef(); - - return S_OK; -} - -/// @implemented -STDMETHODIMP_(ULONG) CicBridge::AddRef() -{ - return ::InterlockedIncrement(&m_cRefs); -} - -/// @implemented -STDMETHODIMP_(ULONG) CicBridge::Release() -{ - if (::InterlockedDecrement(&m_cRefs) == 0) - { - delete this; - return 0; - } - return m_cRefs; -} - -/// @implemented -CicBridge::~CicBridge() -{ - TLS *pTLS = TLS::PeekTLS(); - if (!pTLS || !pTLS->m_pThreadMgr) - return; - - if (SUCCEEDED(DeactivateIMMX(pTLS, pTLS->m_pThreadMgr))) - UnInitIMMX(pTLS); -} - -void CicBridge::GetDocumentManager(_Inout_ CicIMCCLock<CTFIMECONTEXT>& imeContext) -{ - CicInputContext *pCicIC = imeContext.get().m_pCicIC; - if (pCicIC) - { - m_pDocMgr = pCicIC->m_pDocumentMgr; - m_pDocMgr->AddRef(); - } - else - { - m_pDocMgr->Release(); - m_pDocMgr = NULL; - } -} - -/// @unimplemented -HRESULT -CicBridge::CreateInputContext( - _Inout_ TLS *pTLS, - _In_ HIMC hIMC) -{ - CicIMCLock imcLock(hIMC); - HRESULT hr = imcLock.m_hr; - if (!imcLock) - hr = E_FAIL; - if (FAILED(hr)) - return hr; - - if (!imcLock.get().hCtfImeContext) - { - HIMCC hCtfImeContext = ImmCreateIMCC(sizeof(CTFIMECONTEXT)); - if (!hCtfImeContext) - return E_OUTOFMEMORY; - imcLock.get().hCtfImeContext = hCtfImeContext; - } - - CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext); - CicInputContext *pCicIC = imeContext.get().m_pCicIC; - if (!pCicIC) - { - pCicIC = new(cicNoThrow) CicInputContext(m_cliendId, &m_LibThread, hIMC); - if (!pCicIC) - { - imeContext.unlock(); - imcLock.unlock(); - DestroyInputContext(pTLS, hIMC); - return E_OUTOFMEMORY; - } - - if (!pTLS->m_pThreadMgr) - { - pCicIC->Release(); - imeContext.unlock(); - imcLock.unlock(); - DestroyInputContext(pTLS, hIMC); - return E_NOINTERFACE; - } - - imeContext.get().m_pCicIC = pCicIC; - } - - hr = pCicIC->CreateInputContext(pTLS->m_pThreadMgr, imcLock); - if (FAILED(hr)) - { - pCicIC->Release(); - imeContext.get().m_pCicIC = NULL; - } - else - { - if (imcLock.get().hWnd && imcLock.get().hWnd == ::GetFocus()) - { - GetDocumentManager(imeContext); - //FIXME - } - } - - return E_NOTIMPL; -} - -/// @implemented -HRESULT CicBridge::DestroyInputContext(TLS *pTLS, HIMC hIMC) -{ - CicIMCLock imcLock(hIMC); - HRESULT hr = imcLock.m_hr; - if (!imcLock) - hr = E_FAIL; - if (FAILED(hr)) - return hr; - - hr = E_FAIL; - CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext); - if (imeContext) - hr = imeContext.m_hr; - - if (SUCCEEDED(hr) && !(imeContext.get().m_dwCicFlags & 1)) - { - imeContext.get().m_dwCicFlags |= 1; - - CicInputContext *pCicIC = imeContext.get().m_pCicIC; - if (pCicIC) - { - imeContext.get().m_pCicIC = NULL; - hr = pCicIC->DestroyInputContext(); - pCicIC->Release(); - imeContext.get().m_pCicIC = NULL; - } - } - - if (imcLock.get().hCtfImeContext) - { - ImmDestroyIMCC(imcLock.get().hCtfImeContext); - imcLock.get().hCtfImeContext = NULL; - hr = S_OK; - } - - return hr; -} - -ITfContext * -CicBridge::GetInputContext(CicIMCCLock<CTFIMECONTEXT>& imeContext) -{ - CicInputContext *pCicIC = imeContext.get().m_pCicIC; - if (!pCicIC) - return NULL; - return pCicIC->m_pContext; -} - -/// @unimplemented -HRESULT CicBridge::OnSetOpenStatus( - TLS *pTLS, - ITfThreadMgr_P *pThreadMgr, - CicIMCLock& imcLock, - CicInputContext *pCicIC) -{ - return E_NOTIMPL; -} - -/// Selects the IME context. -/// @implemented -HRESULT -CicBridge::SelectEx( - _Inout_ TLS *pTLS, - _Inout_ ITfThreadMgr_P *pThreadMgr, - _In_ HIMC hIMC, - _In_ BOOL fSelect, - _In_ HKL hKL) -{ - CicIMCLock imcLock(hIMC); - if (FAILED(imcLock.m_hr)) - return imcLock.m_hr; - - CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext); - if (!imeContext) - imeContext.m_hr = E_FAIL; - if (FAILED(imeContext.m_hr)) - return imeContext.m_hr; - - CicInputContext *pCicIC = imeContext.get().m_pCicIC; - if (pCicIC) - pCicIC->m_bSelecting = TRUE; - - if (fSelect) - { - if (pCicIC) - pCicIC->m_dwUnknown6[1] &= ~1; - if (imcLock.get().fOpen) - OnSetOpenStatus(pTLS, pThreadMgr, imcLock, pCicIC); - } - else - { - ITfContext *pContext = GetInputContext(imeContext); - pThreadMgr->RequestPostponedLock(pContext); - if (pCicIC) - pCicIC->m_bSelecting = FALSE; - if (pContext) - pContext->Release(); - } - - return imeContext.m_hr; -} - -/// Used in CicBridge::EnumCreateInputContextCallback and -/// CicBridge::EnumDestroyInputContextCallback. -typedef struct ENUM_CREATE_DESTROY_IC -{ - TLS *m_pTLS; - CicBridge *m_pBridge; -} ENUM_CREATE_DESTROY_IC, *PENUM_CREATE_DESTROY_IC; - -/// Creates input context for the current thread. -/// @implemented -BOOL CALLBACK CicBridge::EnumCreateInputContextCallback(HIMC hIMC, LPARAM lParam) -{ - PENUM_CREATE_DESTROY_IC pData = (PENUM_CREATE_DESTROY_IC)lParam; - pData->m_pBridge->CreateInputContext(pData->m_pTLS, hIMC); - return TRUE; -} - -/// Destroys input context for the current thread. -/// @implemented -BOOL CALLBACK CicBridge::EnumDestroyInputContextCallback(HIMC hIMC, LPARAM lParam) -{ - PENUM_CREATE_DESTROY_IC pData = (PENUM_CREATE_DESTROY_IC)lParam; - pData->m_pBridge->DestroyInputContext(pData->m_pTLS, hIMC); - return TRUE; -} - -/// @implemented -HRESULT -CicBridge::ActivateIMMX( - _Inout_ TLS *pTLS, - _Inout_ ITfThreadMgr_P *pThreadMgr) -{ - HRESULT hr = pThreadMgr->ActivateEx(&m_cliendId, 1); - if (hr != S_OK) - { - m_cliendId = 0; - return E_FAIL; - } - - if (m_cActivateLocks++ != 0) - return S_OK; - - ITfSourceSingle *pSource = NULL; - hr = pThreadMgr->QueryInterface(IID_ITfSourceSingle, (void**)&pSource); - if (FAILED(hr)) - { - DeactivateIMMX(pTLS, pThreadMgr); - return hr; - } - - CFunctionProvider *pProvider = new(cicNoThrow) CFunctionProvider(m_cliendId); - if (!pProvider) - { - hr = E_FAIL; - goto Finish; - } - - pSource->AdviseSingleSink(m_cliendId, IID_ITfFunctionProvider, pProvider); - pProvider->Release(); - - if (!m_pDocMgr) - { - hr = pThreadMgr->CreateDocumentMgr(&m_pDocMgr); - if (FAILED(hr)) - { - hr = E_FAIL; - goto Finish; - } - - SetCompartmentDWORD(m_cliendId, m_pDocMgr, GUID_COMPARTMENT_CTFIME_DIMFLAGS, TRUE, FALSE); - } - - pThreadMgr->SetSysHookSink(this); - - hr = S_OK; - if (pTLS->m_bDestroyed) - { - ENUM_CREATE_DESTROY_IC Data = { pTLS, this }; - ImmEnumInputContext(0, CicBridge::EnumCreateInputContextCallback, (LPARAM)&Data); - } - -Finish: - if (FAILED(hr)) - DeactivateIMMX(pTLS, pThreadMgr); - if (pSource) - pSource->Release(); - return hr; -} - -/// @implemented -HRESULT -CicBridge::DeactivateIMMX( - _Inout_ TLS *pTLS, - _Inout_ ITfThreadMgr_P *pThreadMgr) -{ - if (m_bDeactivating) - return TRUE; - - m_bDeactivating = TRUE; - - if (m_cliendId) - { - ENUM_CREATE_DESTROY_IC Data = { pTLS, this }; - ImmEnumInputContext(0, CicBridge::EnumDestroyInputContextCallback, (LPARAM)&Data); - pTLS->m_bDestroyed = TRUE; - - ITfSourceSingle *pSource = NULL; - if (pThreadMgr->QueryInterface(IID_ITfSourceSingle, (void **)&pSource) == S_OK) - pSource->UnadviseSingleSink(m_cliendId, IID_ITfFunctionProvider); - - m_cliendId = 0; - - while (m_cActivateLocks > 0) - { - --m_cActivateLocks; - pThreadMgr->Deactivate(); - } - - if (pSource) - pSource->Release(); - } - - if (m_pDocMgr) - { - m_pDocMgr->Release(); - m_pDocMgr = NULL; - } - - pThreadMgr->SetSysHookSink(NULL); - - m_bDeactivating = FALSE; - - return S_OK; -} - -/// @implemented -HRESULT -CicBridge::InitIMMX(_Inout_ TLS *pTLS) -{ - if (m_bImmxInited) - return S_OK; - - HRESULT hr = S_OK; - if (!pTLS->m_pThreadMgr) - { - ITfThreadMgr *pThreadMgr = NULL; - hr = TF_CreateThreadMgr(&pThreadMgr); - if (FAILED(hr)) - return E_FAIL; - - hr = pThreadMgr->QueryInterface(IID_ITfThreadMgr_P, (void **)&pTLS->m_pThreadMgr); - if (pThreadMgr) - pThreadMgr->Release(); - if (FAILED(hr)) - return E_FAIL; - } - - if (!m_pThreadMgrEventSink) - { - m_pThreadMgrEventSink = - new(cicNoThrow) CThreadMgrEventSink(CThreadMgrEventSink::DIMCallback, NULL, NULL); - if (!m_pThreadMgrEventSink) - { - UnInitIMMX(pTLS); - return E_FAIL; - } - } - - m_pThreadMgrEventSink->SetCallbackPV(m_pThreadMgrEventSink); - m_pThreadMgrEventSink->_Advise(pTLS->m_pThreadMgr); - - if (!pTLS->m_pProfile) - { - pTLS->m_pProfile = new(cicNoThrow) CicProfile(); - if (!pTLS->m_pProfile) - return E_OUTOFMEMORY; - - hr = pTLS->m_pProfile->InitProfileInstance(pTLS); - if (FAILED(hr)) - { - UnInitIMMX(pTLS); - return E_FAIL; - } - } - - hr = pTLS->m_pThreadMgr->QueryInterface(IID_ITfKeystrokeMgr_P, (void **)&m_pKeystrokeMgr); - if (FAILED(hr)) - { - UnInitIMMX(pTLS); - return E_FAIL; - } - - hr = InitDisplayAttrbuteLib(&m_LibThread); - if (FAILED(hr)) - { - UnInitIMMX(pTLS); - return E_FAIL; - } - - m_bImmxInited = TRUE; - return S_OK; -} - -/// @implemented -BOOL CicBridge::UnInitIMMX(_Inout_ TLS *pTLS) -{ - UninitDisplayAttrbuteLib(&m_LibThread); - TFUninitLib_Thread(&m_LibThread); - - if (m_pKeystrokeMgr) - { - m_pKeystrokeMgr->Release(); - m_pKeystrokeMgr = NULL; - } - - if (pTLS->m_pProfile) - { - pTLS->m_pProfile->Release(); - pTLS->m_pProfile = NULL; - } - - if (m_pThreadMgrEventSink) - { - m_pThreadMgrEventSink->_Unadvise(); - m_pThreadMgrEventSink->Release(); - m_pThreadMgrEventSink = NULL; - } - - if (pTLS->m_pThreadMgr) - { - pTLS->m_pThreadMgr->Release(); - pTLS->m_pThreadMgr = NULL; - } - - m_bImmxInited = FALSE; - return TRUE; -} - -/// @implemented -STDMETHODIMP CicBridge::OnPreFocusDIM(HWND hwnd) -{ - return S_OK; -} - -/// @unimplemented -STDMETHODIMP CicBridge::OnSysKeyboardProc(UINT, LONG) -{ - return E_NOTIMPL; + return hr; } -/// @implemented -STDMETHODIMP CicBridge::OnSysShellProc(INT, UINT, LONG) +HIMC GetActiveContext(VOID) { - return S_OK; + HWND hwndFocus = ::GetFocus(); + if (!hwndFocus) + hwndFocus = ::GetActiveWindow(); + return ::ImmGetContext(hwndFocus); } /// @implemented -void -CicBridge::PostTransMsg( - _In_ HWND hWnd, - _In_ INT cTransMsgs, - _In_ const TRANSMSG *pTransMsgs) +HRESULT UninitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread) { - for (INT i = 0; i < cTransMsgs; ++i, ++pTransMsgs) + if (!pLibThread) + return E_FAIL; + + if (pLibThread->m_pDisplayAttrMgr) { - ::PostMessageW(hWnd, pTransMsgs->message, pTransMsgs->wParam, pTransMsgs->lParam); + pLibThread->m_pDisplayAttrMgr->Release(); + pLibThread->m_pDisplayAttrMgr = NULL; } + + return S_OK; } +/// Gets the charset from a language ID. /// @implemented -HRESULT -CicBridge::ConfigureGeneral( - _Inout_ TLS* pTLS, - _In_ ITfThreadMgr *pThreadMgr, - _In_ HKL hKL, - _In_ HWND hWnd) +BYTE GetCharsetFromLangId(_In_ DWORD dwValue) { - CicProfile *pProfile = pTLS->m_pProfile; - if (!pProfile) - return E_OUTOFMEMORY; - - TF_LANGUAGEPROFILE profile; - HRESULT hr = pProfile->GetActiveLanguageProfile(hKL, GUID_TFCAT_TIP_KEYBOARD, &profile); - if (FAILED(hr)) - return hr; - - ITfFunctionProvider *pProvider = NULL; - hr = pThreadMgr->GetFunctionProvider(profile.clsid, &pProvider); - if (FAILED(hr)) - return hr; - - ITfFnConfigure *pFnConfigure = NULL; - hr = pProvider->GetFunction(GUID_NULL, IID_ITfFnConfigure, (IUnknown**)&pFnConfigure); - if (FAILED(hr)) - { - pProvider->Release(); - return hr; - } - - hr = pFnConfigure->Show(hWnd, profile.langid, profile.guidProfile); - - pFnConfigure->Release(); - pProvider->Release(); - return hr; + CHARSETINFO info; + if (!::TranslateCharsetInfo((DWORD*)(DWORD_PTR)dwValue, &info, TCI_SRCLOCALE)) + return 0; + return info.ciCharset; } +/// Selects or unselects the input context. /// @implemented HRESULT -CicBridge::ConfigureRegisterWord( - _Inout_ TLS* pTLS, - _In_ ITfThreadMgr *pThreadMgr, - _In_ HKL hKL, - _In_ HWND hWnd, - _Inout_opt_ LPVOID lpData) +InternalSelectEx( + _In_ HIMC hIMC, + _In_ BOOL fSelect, + _In_ LANGID LangID) { - CicProfile *pProfile = pTLS->m_pProfile; - if (!pProfile) - return E_OUTOFMEMORY; - - TF_LANGUAGEPROFILE profile; - HRESULT hr = pProfile->GetActiveLanguageProfile(hKL, GUID_TFCAT_TIP_KEYBOARD, &profile); - if (FAILED(hr)) - return hr; + CicIMCLock imcLock(hIMC); + if (!imcLock) + imcLock.m_hr = E_FAIL; + if (FAILED(imcLock.m_hr)) + return imcLock.m_hr; - ITfFunctionProvider *pProvider = NULL; - hr = pThreadMgr->GetFunctionProvider(profile.clsid, &pProvider); - if (FAILED(hr)) - return hr; + if (PRIMARYLANGID(LangID) == LANG_CHINESE) + { + imcLock.get().cfCandForm[0].dwStyle = 0; + imcLock.get().cfCandForm[0].dwIndex = (DWORD)-1; + } - ITfFnConfigureRegisterWord *pFunction = NULL; - hr = pProvider->GetFunction(GUID_NULL, IID_ITfFnConfigureRegisterWord, (IUnknown**)&pFunction); - if (FAILED(hr)) + if (!fSelect) { - pProvider->Release(); - return hr; + imcLock.get().fdwInit &= ~INIT_GUIDMAP; + return imcLock.m_hr; } - REGISTERWORDW* pRegWord = (REGISTERWORDW*)lpData; - if (pRegWord) + if (!imcLock.ClearCand()) + return imcLock.m_hr; + + // Populate conversion mode + if (!(imcLock.get().fdwInit & INIT_CONVERSION)) { - if (pRegWord->lpWord) + DWORD dwConv = (imcLock.get().fdwConversion & IME_CMODE_SOFTKBD); + if (LangID) { - hr = E_OUTOFMEMORY; - BSTR bstrWord = SysAllocString(pRegWord->lpWord); - if (bstrWord) + if (PRIMARYLANGID(LangID) == LANG_JAPANESE) { - hr = pFunction->Show(hWnd, profile.langid, profile.guidProfile, bstrWord); - SysFreeString(bstrWord); + dwConv |= IME_CMODE_ROMAN | IME_CMODE_FULLSHAPE | IME_CMODE_NATIVE; + } + else if (PRIMARYLANGID(LangID) != LANG_KOREAN) + { + dwConv |= IME_CMODE_NATIVE; } } - else - { - hr = pFunction->Show(hWnd, profile.langid, profile.guidProfile, NULL); - } + imcLock.get().fdwConversion |= dwConv; + imcLock.get().fdwInit |= INIT_CONVERSION; } - pProvider->Release(); - pFunction->Release(); - return hr; -} + // Populate sentence mode + imcLock.get().fdwSentence |= IME_SMODE_PHRASEPREDICT; -/*********************************************************************** - * CicProfile - */ + // Populate LOGFONT + if (!(imcLock.get().fdwInit & INIT_LOGFONT)) + { + // Get logical font + LOGFONTW lf; + HDC hDC = ::GetDC(imcLock.get().hWnd); + HGDIOBJ hFont = GetCurrentObject(hDC, OBJ_FONT); + ::GetObjectW(hFont, sizeof(LOGFONTW), &lf); + ::ReleaseDC(imcLock.get().hWnd, hDC); -/// @unimplemented -HRESULT -CicProfile::GetActiveLanguageProfile( - _In_ HKL hKL, - _In_ REFGUID rguid, - _Out_ TF_LANGUAGEPROFILE *pProfile) -{ - return E_NOTIMPL; + imcLock.get().lfFont.W = lf; + imcLock.get().fdwInit |= INIT_LOGFONT; + } + imcLock.get().lfFont.W.lfCharSet = GetCharsetFromLangId(LangID); + + imcLock.InitContext(); + + return imcLock.m_hr; } +class TLS; + /*********************************************************************** * ImeInquire (MSCTFIME.@) * @@ -3332,367 +858,6 @@ CtfImeThreadDetach(VOID) return S_OK; } -/*********************************************************************** - * UIComposition - */ -struct UIComposition -{ - void OnImeStartComposition(CicIMCLock& imcLock, HWND hUIWnd); - void OnImeCompositionUpdate(CicIMCLock& imcLock); - void OnImeEndComposition(); - void OnImeSetContext(CicIMCLock& imcLock, HWND hUIWnd, WPARAM wParam, LPARAM lParam); - void OnPaintTheme(WPARAM wParam); - void OnDestroy(); - - static LRESULT CALLBACK CompWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -}; - -/// @unimplemented -void UIComposition::OnImeStartComposition(CicIMCLock& imcLock, HWND hUIWnd) -{ - //FIXME -} - -/// @unimplemented -void UIComposition::OnImeCompositionUpdate(CicIMCLock& imcLock) -{ - //FIXME -} - -/// @unimplemented -void UIComposition::OnImeEndComposition() -{ - //FIXME -} - -/// @unimplemented -void UIComposition::OnImeSetContext(CicIMCLock& imcLock, HWND hUIWnd, WPARAM wParam, LPARAM lParam) -{ - //FIXME -} - -/// @unimplemented -void UIComposition::OnPaintTheme(WPARAM wParam) -{ - //FIXME -} - -/// @unimplemented -void UIComposition::OnDestroy() -{ - //FIXME -} - -/// @unimplemented -LRESULT CALLBACK -UIComposition::CompWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - if (uMsg == WM_CREATE) - return -1; // FIXME - return 0; -} - -/*********************************************************************** - * UI - */ -struct UI -{ - HWND m_hWnd; - UIComposition *m_pComp; - - UI(HWND hWnd); - virtual ~UI(); - - HRESULT _Create(); - void _Destroy(); - - static void OnCreate(HWND hWnd); - static void OnDestroy(HWND hWnd); - void OnImeSetContext(CicIMCLock& imcLock, WPARAM wParam, LPARAM lParam); -}; - -// For GetWindowLongPtr/SetWindowLongPtr -#define UIGWLP_HIMC 0 -#define UIGWLP_UI sizeof(HIMC) -#define UIGWLP_SIZE (UIGWLP_UI + sizeof(UI*)) - -/// @implemented -UI::UI(HWND hWnd) : m_hWnd(hWnd) -{ -} - -/// @implemented -UI::~UI() -{ - delete m_pComp; -} - -/// @unimplemented -HRESULT UI::_Create() -{ - m_pComp = new(cicNoThrow) UIComposition(); - if (!m_pComp) - return E_OUTOFMEMORY; - - SetWindowLongPtrW(m_hWnd, UIGWLP_UI, (LONG_PTR)this); - //FIXME - return S_OK; -} - -/// @implemented -void UI::_Destroy() -{ - m_pComp->OnDestroy(); - SetWindowLongPtrW(m_hWnd, UIGWLP_UI, 0); -} - -/// @implemented -void UI::OnCreate(HWND hWnd) -{ - UI *pUI = (UI*)GetWindowLongPtrW(hWnd, UIGWLP_UI); - if (pUI) - return; - pUI = new(cicNoThrow) UI(hWnd); - if (pUI) - pUI->_Create(); -} - -/// @implemented -void UI::OnDestroy(HWND hWnd) -{ - UI *pUI = (UI*)GetWindowLongPtrW(hWnd, UIGWLP_UI); - if (!pUI) - return; - - pUI->_Destroy(); - delete pUI; -} - -/// @implemented -void UI::OnImeSetContext(CicIMCLock& imcLock, WPARAM wParam, LPARAM lParam) -{ - m_pComp->OnImeSetContext(imcLock, m_hWnd, wParam, lParam); -} - -/*********************************************************************** - * CIMEUIWindowHandler - */ - -struct CIMEUIWindowHandler -{ - static LRESULT CALLBACK ImeUIMsImeHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - static LRESULT CALLBACK ImeUIMsImeMouseHandler(HWND hWnd, WPARAM wParam, LPARAM lParam); - static LRESULT CALLBACK ImeUIMsImeModeBiasHandler(HWND hWnd, WPARAM wParam, LPARAM lParam); - static LRESULT CALLBACK ImeUIMsImeReconvertRequest(HWND hWnd, WPARAM wParam, LPARAM lParam); - static LRESULT CALLBACK ImeUIWndProcWorker(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -}; - -/// @unimplemented -LRESULT CALLBACK -CIMEUIWindowHandler::ImeUIMsImeMouseHandler(HWND hWnd, WPARAM wParam, LPARAM lParam) -{ - return 0; //FIXME -} - -/// @unimplemented -LRESULT CALLBACK -CIMEUIWindowHandler::ImeUIMsImeModeBiasHandler(HWND hWnd, WPARAM wParam, LPARAM lParam) -{ - return 0; //FIXME -} - -/// @unimplemented -LRESULT CALLBACK -CIMEUIWindowHandler::ImeUIMsImeReconvertRequest(HWND hWnd, WPARAM wParam, LPARAM lParam) -{ - return 0; //FIXME -} - -/// @implemented -LRESULT CALLBACK -CIMEUIWindowHandler::ImeUIMsImeHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - if (uMsg == WM_MSIME_MOUSE) - return ImeUIMsImeMouseHandler(hWnd, wParam, lParam); - if (uMsg == WM_MSIME_MODEBIAS) - return ImeUIMsImeModeBiasHandler(hWnd, wParam, lParam); - if (uMsg == WM_MSIME_RECONVERTREQUEST) - return ImeUIMsImeReconvertRequest(hWnd, wParam, lParam); - if (uMsg == WM_MSIME_SERVICE) - { - TLS *pTLS = TLS::GetTLS(); - if (pTLS && pTLS->m_pProfile) - { - LANGID LangID; - pTLS->m_pProfile->GetLangId(&LangID); - if (PRIMARYLANGID(LangID) == LANG_KOREAN) - return FALSE; - } - return TRUE; - } - return 0; -} - -/// @unimplemented -LRESULT CALLBACK -CIMEUIWindowHandler::ImeUIWndProcWorker(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - TLS *pTLS = TLS::GetTLS(); - if (pTLS && (pTLS->m_dwSystemInfoFlags & IME_SYSINFO_WINLOGON)) - { - if (uMsg == WM_CREATE) - return -1; - return DefWindowProcW(hWnd, uMsg, wParam, lParam); - } - - switch (uMsg) - { - case WM_CREATE: - { - UI::OnCreate(hWnd); - break; - } - case WM_DESTROY: - case WM_ENDSESSION: - { - UI::OnDestroy(hWnd); - break; - } - case WM_IME_STARTCOMPOSITION: - case WM_IME_COMPOSITION: - case WM_IME_ENDCOMPOSITION: - case WM_IME_SETCONTEXT: - case WM_IME_NOTIFY: - case WM_IME_SELECT: - case WM_TIMER: - { - HIMC hIMC = (HIMC)GetWindowLongPtrW(hWnd, UIGWLP_HIMC); - UI* pUI = (UI*)GetWindowLongPtrW(hWnd, UIGWLP_UI); - CicIMCLock imcLock(hIMC); - switch (uMsg) - { - case WM_IME_STARTCOMPOSITION: - { - pUI->m_pComp->OnImeStartComposition(imcLock, pUI->m_hWnd); - break; - } - case WM_IME_COMPOSITION: - { - if (lParam & GCS_COMPSTR) - { - pUI->m_pComp->OnImeCompositionUpdate(imcLock); - ::SetTimer(hWnd, 0, 10, NULL); - //FIXME - } - break; - } - case WM_IME_ENDCOMPOSITION: - { - ::KillTimer(hWnd, 0); - pUI->m_pComp->OnImeEndComposition(); - break; - } - case WM_IME_SETCONTEXT: - { - pUI->OnImeSetContext(imcLock, wParam, lParam); - ::KillTimer(hWnd, 1); - ::SetTimer(hWnd, 1, 300, NULL); - break; - } - case WM_TIMER: - { - //FIXME - ::KillTimer(hWnd, wParam); - break; - } - case WM_IME_NOTIFY: - case WM_IME_SELECT: - default: - { - pUI->m_pComp->OnPaintTheme(wParam); - break; - } - } - break; - } - default: - { - if (IsMsImeMessage(uMsg)) - return CIMEUIWindowHandler::ImeUIMsImeHandler(hWnd, uMsg, wParam, lParam); - return DefWindowProcW(hWnd, uMsg, wParam, lParam); - } - } - - return 0; -} - -/// @implemented -EXTERN_C LRESULT CALLBACK -UIWndProc( - _In_ HWND hWnd, - _In_ UINT uMsg, - _In_ WPARAM wParam, - _In_ LPARAM lParam) -{ - return CIMEUIWindowHandler::ImeUIWndProcWorker(hWnd, uMsg, wParam, lParam); -} - -/// @unimplemented -BOOL RegisterImeClass(VOID) -{ - WNDCLASSEXW wcx; - - if (!GetClassInfoExW(g_hInst, L"MSCTFIME UI", &wcx)) - { - ZeroMemory(&wcx, sizeof(wcx)); - wcx.cbSize = sizeof(WNDCLASSEXW); - wcx.cbWndExtra = UIGWLP_SIZE; - wcx.hIcon = LoadIconW(0, (LPCWSTR)IDC_ARROW); - wcx.hInstance = g_hInst; - wcx.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW); - wcx.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH); - wcx.style = CS_IME | CS_GLOBALCLASS; - wcx.lpfnWndProc = UIWndProc; - wcx.lpszClassName = L"MSCTFIME UI"; - if (!RegisterClassExW(&wcx)) - return FALSE; - } - - if (!GetClassInfoExW(g_hInst, L"MSCTFIME Composition", &wcx)) - { - ZeroMemory(&wcx, sizeof(wcx)); - wcx.cbSize = sizeof(WNDCLASSEXW); - wcx.cbWndExtra = sizeof(DWORD); - wcx.hIcon = NULL; - wcx.hInstance = g_hInst; - wcx.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_IBEAM); - wcx.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH); - wcx.style = CS_IME | CS_HREDRAW | CS_VREDRAW; - wcx.lpfnWndProc = UIComposition::CompWndProc; - wcx.lpszClassName = L"MSCTFIME Composition"; - if (!RegisterClassExW(&wcx)) - return FALSE; - } - - return TRUE; -} - -/// @implemented -VOID UnregisterImeClass(VOID) -{ - WNDCLASSEXW wcx; - - GetClassInfoExW(g_hInst, L"MSCTFIME UI", &wcx); - UnregisterClassW(L"MSCTFIME UI", g_hInst); - DestroyIcon(wcx.hIcon); - DestroyIcon(wcx.hIconSm); - - GetClassInfoExW(g_hInst, L"MSCTFIME Composition", &wcx); - UnregisterClassW(L"MSCTFIME Composition", g_hInst); - DestroyIcon(wcx.hIcon); - DestroyIcon(wcx.hIconSm); -} - /// @implemented BOOL AttachIME(VOID) { diff --git a/dll/ime/msctfime/msctfime.h b/dll/ime/msctfime/msctfime.h index 040ecc11c96..f7ada8fbd6e 100644 --- a/dll/ime/msctfime/msctfime.h +++ b/dll/ime/msctfime/msctfime.h @@ -34,6 +34,23 @@ #include <wine/debug.h> +EXTERN_C BOOLEAN WINAPI DllShutdownInProgress(VOID); + +HRESULT InitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread); +HRESULT UninitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread); + +DEFINE_GUID(GUID_COMPARTMENT_CTFIME_DIMFLAGS, 0xA94C5FD2, 0xC471, 0x4031, 0x95, 0x46, 0x70, 0x9C, 0x17, 0x30, 0x0C, 0xB9); +DEFINE_GUID(GUID_COMPARTMENT_CTFIME_CICINPUTCONTEXT, 0x85A688F7, 0x6DC8, 0x4F17, 0xA8, 0x3A, 0xB1, 0x1C, 0x09, 0xCD, 0xD7, 0xBF); + #include "resource.h" +#include "bridge.h" +#include "compartment.h" +#include "functions.h" +#include "inputcontext.h" +#include "profile.h" +#include "sinks.h" +#include "tls.h" +#include "ui.h" + extern HINSTANCE g_hInst; diff --git a/dll/ime/msctfime/profile.cpp b/dll/ime/msctfime/profile.cpp new file mode 100644 index 00000000000..9ec7cd12ff3 --- /dev/null +++ b/dll/ime/msctfime/profile.cpp @@ -0,0 +1,173 @@ +/* + * PROJECT: ReactOS msctfime.ime + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Profile of msctfime.ime + * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#include "msctfime.h" + +WINE_DEFAULT_DEBUG_CHANNEL(msctfime); + +/// @implemented +CicProfile::CicProfile() +{ + m_dwFlags &= 0xFFFFFFF0; + m_cRefs = 1; + m_pIPProfiles = NULL; + m_pActiveLanguageProfileNotifySink = NULL; + m_LangID1 = 0; + m_nCodePage = CP_ACP; + m_LangID2 = 0; + m_dwUnknown1 = 0; +} + +/// @implemented +CicProfile::~CicProfile() +{ + if (m_pIPProfiles) + { + if (m_LangID1) + m_pIPProfiles->ChangeCurrentLanguage(m_LangID1); + + m_pIPProfiles->Release(); + m_pIPProfiles = NULL; + } + + if (m_pActiveLanguageProfileNotifySink) + { + m_pActiveLanguageProfileNotifySink->_Unadvise(); + m_pActiveLanguageProfileNotifySink->Release(); + m_pActiveLanguageProfileNotifySink = NULL; + } +} + +/// @implemented +STDMETHODIMP CicProfile::QueryInterface(REFIID riid, LPVOID* ppvObj) +{ + *ppvObj = NULL; + return E_NOINTERFACE; +} + +/// @implemented +STDMETHODIMP_(ULONG) CicProfile::AddRef() +{ + return ::InterlockedIncrement(&m_cRefs); +} + +/// @implemented +STDMETHODIMP_(ULONG) CicProfile::Release() +{ + if (::InterlockedDecrement(&m_cRefs) == 0) + { + delete this; + return 0; + } + return m_cRefs; +} + +/// @implemented +INT CALLBACK +CicProfile::ActiveLanguageProfileNotifySinkCallback( + REFGUID rguid1, + REFGUID rguid2, + BOOL fActivated, + LPVOID pUserData) +{ + CicProfile *pThis = (CicProfile *)pUserData; + pThis->m_dwFlags &= ~0xE; + return 0; +} + +/// @implemented +HRESULT CicProfile::GetCodePageA(_Out_ UINT *puCodePage) +{ + if (!puCodePage) + return E_INVALIDARG; + + if (m_dwFlags & 2) + { + *puCodePage = m_nCodePage; + return S_OK; + } + + *puCodePage = 0; + + LANGID LangID; + HRESULT hr = GetLangId(&LangID); + if (FAILED(hr)) + return E_FAIL; + + WCHAR szBuff[12]; + INT cch = ::GetLocaleInfoW(LangID, LOCALE_IDEFAULTANSICODEPAGE, szBuff, _countof(szBuff)); + if (cch) + { + szBuff[cch] = 0; + m_nCodePage = *puCodePage = wcstoul(szBuff, NULL, 10); + m_dwFlags |= 2; + } + + return S_OK; +} + +/// @implemented +HRESULT CicProfile::GetLangId(_Out_ LANGID *pLangID) +{ + *pLangID = 0; + + if (!m_pIPProfiles) + return E_FAIL; + + if (m_dwFlags & 4) + { + *pLangID = m_LangID2; + return S_OK; + } + + HRESULT hr = m_pIPProfiles->GetCurrentLanguage(pLangID); + if (SUCCEEDED(hr)) + { + m_dwFlags |= 4; + m_LangID2 = *pLangID; + } + + return hr; +} + +/// @implemented +HRESULT +CicProfile::InitProfileInstance(_Inout_ TLS *pTLS) +{ + HRESULT hr = TF_CreateInputProcessorProfiles(&m_pIPProfiles); + if (FAILED(hr)) + return hr; + + if (!m_pActiveLanguageProfileNotifySink) + { + CActiveLanguageProfileNotifySink *pSink = + new(cicNoThrow) CActiveLanguageProfileNotifySink( + CicProfile::ActiveLanguageProfileNotifySinkCallback, this); + if (!pSink) + { + m_pIPProfiles->Release(); + m_pIPProfiles = NULL; + return E_FAIL; + } + m_pActiveLanguageProfileNotifySink = pSink; + } + + if (pTLS->m_pThreadMgr) + m_pActiveLanguageProfileNotifySink->_Advise(pTLS->m_pThreadMgr); + + return hr; +} + +/// @unimplemented +HRESULT +CicProfile::GetActiveLanguageProfile( + _In_ HKL hKL, + _In_ REFGUID rguid, + _Out_ TF_LANGUAGEPROFILE *pProfile) +{ + return E_NOTIMPL; +} diff --git a/dll/ime/msctfime/profile.h b/dll/ime/msctfime/profile.h new file mode 100644 index 00000000000..2943750ad46 --- /dev/null +++ b/dll/ime/msctfime/profile.h @@ -0,0 +1,51 @@ +/* + * PROJECT: ReactOS msctfime.ime + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Profile of msctfime.ime + * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#pragma once + +#include "sinks.h" + +class CicProfile : public IUnknown +{ +protected: + ITfInputProcessorProfiles *m_pIPProfiles; + CActiveLanguageProfileNotifySink *m_pActiveLanguageProfileNotifySink; + LANGID m_LangID1; + WORD m_padding1; + DWORD m_dwFlags; + UINT m_nCodePage; + LANGID m_LangID2; + WORD m_padding2; + DWORD m_dwUnknown1; + LONG m_cRefs; + + static INT CALLBACK + ActiveLanguageProfileNotifySinkCallback( + REFGUID rguid1, + REFGUID rguid2, + BOOL fActivated, + LPVOID pUserData); + +public: + CicProfile(); + virtual ~CicProfile(); + + // IUnknown interface + STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; + STDMETHODIMP_(ULONG) AddRef() override; + STDMETHODIMP_(ULONG) Release() override; + + HRESULT + GetActiveLanguageProfile( + _In_ HKL hKL, + _In_ REFGUID rguid, + _Out_ TF_LANGUAGEPROFILE *pProfile); + HRESULT GetLangId(_Out_ LANGID *pLangID); + HRESULT GetCodePageA(_Out_ UINT *puCodePage); + + HRESULT InitProfileInstance(_Inout_ TLS *pTLS); +}; diff --git a/dll/ime/msctfime/sinks.cpp b/dll/ime/msctfime/sinks.cpp new file mode 100644 index 00000000000..235079c4d94 --- /dev/null +++ b/dll/ime/msctfime/sinks.cpp @@ -0,0 +1,539 @@ +/* ... 1325 lines suppressed ...
10 months, 1 week
1
0
0
0
[reactos] 02/02: [DBGHELP] Avoid call of wine_get_dos_file_name
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0610bcb3f9894f552c6f7…
commit 0610bcb3f9894f552c6f742f71d1e76a84b57dcb Author: Jérôme Gardou <zefklop(a)users.noreply.github.com> AuthorDate: Sun Feb 18 23:56:09 2024 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Tue Feb 20 08:56:53 2024 +0100 [DBGHELP] Avoid call of wine_get_dos_file_name CORE-19444 --- dll/win32/dbghelp/path.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dll/win32/dbghelp/path.c b/dll/win32/dbghelp/path.c index 6639375d444..92db186be41 100644 --- a/dll/win32/dbghelp/path.c +++ b/dll/win32/dbghelp/path.c @@ -673,6 +673,7 @@ WCHAR *get_dos_file_name(const WCHAR *filename) WCHAR *dos_path; size_t len; +#ifndef __REACTOS__ if (*filename == '/') { char *unix_path; @@ -683,6 +684,7 @@ WCHAR *get_dos_file_name(const WCHAR *filename) heap_free(unix_path); } else +#endif { len = lstrlenW(filename); dos_path = heap_alloc((len + 1) * sizeof(WCHAR));
10 months, 1 week
1
0
0
0
[reactos] 01/02: [LIBWINE] Return empty path when given a UNIX path
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e706083d5027c592c75b0…
commit e706083d5027c592c75b0cc5783aa321189ceff6 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Feb 13 22:51:02 2024 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Tue Feb 20 08:56:53 2024 +0100 [LIBWINE] Return empty path when given a UNIX path CORE-19444 --- sdk/lib/3rdparty/libwine/path.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/lib/3rdparty/libwine/path.c b/sdk/lib/3rdparty/libwine/path.c index d8f11bdafc5..8c620024e11 100644 --- a/sdk/lib/3rdparty/libwine/path.c +++ b/sdk/lib/3rdparty/libwine/path.c @@ -61,6 +61,8 @@ WCHAR * CDECL wine_get_dos_file_name( LPCSTR str ) #ifdef __REACTOS__ ERR("Got absolute UNIX path name in function wine_get_dos_file_name. This is not UNIX. Please fix the caller!\n"); ERR("File name: %s\n", str); + /* Return empty path */ + return RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, 1 * sizeof(UNICODE_NULL)); #else len += 8; /* \??\unix prefix */ if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return NULL;
10 months, 1 week
1
0
0
0
[reactos] 01/01: [CTFMON][MSCTFIME][MSCTF][MSUTB][CICERO] Fix TFUninitLib (#6504)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6bc40d36f8b3151bbd705…
commit 6bc40d36f8b3151bbd7057d085a79fcc0bab5db7 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Feb 20 14:36:24 2024 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Tue Feb 20 14:36:24 2024 +0900 [CTFMON][MSCTFIME][MSCTF][MSUTB][CICERO] Fix TFUninitLib (#6504) Supporting the Language bar... JIRA issue: CORE-19363 - Delete TFInitLib and TFUninitLib calls from ctfmon.exe. - Delete TFUninitLib from Cicero library. - Implement InitDisplayAttrbuteLib in msctfime.ime. - Improve CIC_LIBTHREAD structure. --- base/applications/ctfmon/ctfmon.cpp | 6 --- dll/ime/msctfime/msctfime.cpp | 76 ++++++++++++++++++++++++++++++++++--- dll/win32/msctf/utils.cpp | 5 +++ dll/win32/msutb/msutb.cpp | 5 +++ sdk/lib/cicero/cicbase.cpp | 10 ----- sdk/lib/cicero/cicutb.h | 10 +++-- 6 files changed, 87 insertions(+), 25 deletions(-) diff --git a/base/applications/ctfmon/ctfmon.cpp b/base/applications/ctfmon/ctfmon.cpp index 6c255f18b2e..331fd19cc37 100644 --- a/base/applications/ctfmon/ctfmon.cpp +++ b/base/applications/ctfmon/ctfmon.cpp @@ -194,9 +194,6 @@ InitApp( g_bOnWow64 = cicIsWow64(); // Is the current process on WoW64? cicGetOSInfo(&g_uACP, &g_dwOsInfo); // Get OS info - // Initialize Cicero - TFInitLib(); - // Create a mutex for Cicero g_hCicMutex = TF_CreateCicLoadMutex(&g_fWinLogon); if (!g_hCicMutex) @@ -251,9 +248,6 @@ UninitApp(VOID) // Close Tipbar Popup ClosePopupTipbar(); - // Release Cicero - TFUninitLib(); - // Close the mutex ::CloseHandle(g_hCicMutex); g_hCicMutex = NULL; diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp index c1353076be1..ccd442083ab 100644 --- a/dll/ime/msctfime/msctfime.cpp +++ b/dll/ime/msctfime/msctfime.cpp @@ -10,12 +10,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(msctfime); +typedef CicArray<GUID> CDispAttrPropCache; + HINSTANCE g_hInst = NULL; /* The instance of this module */ BOOL g_bWinLogon = FALSE; UINT g_uACP = CP_ACP; DWORD g_dwOSInfo = 0; BOOL gfTFInitLib = FALSE; CRITICAL_SECTION g_csLock; +CDispAttrPropCache *g_pPropCache = NULL; DEFINE_GUID(GUID_COMPARTMENT_CTFIME_DIMFLAGS, 0xA94C5FD2, 0xC471, 0x4031, 0x95, 0x46, 0x70, 0x9C, 0x17, 0x30, 0x0C, 0xB9); DEFINE_GUID(GUID_COMPARTMENT_CTFIME_CICINPUTCONTEXT, 0x85A688F7, 0x6DC8, 0x4F17, 0xA8, 0x3A, 0xB1, 0x1C, 0x09, 0xCD, 0xD7, 0xBF); @@ -124,6 +127,33 @@ IsInteractiveUserLogon(VOID) return bOK && IsMember; } +/// @implemented +ITfCategoryMgr *GetUIMCat(PCIC_LIBTHREAD pLibThread) +{ + if (!pLibThread) + return NULL; + + if (pLibThread->m_pCategoryMgr) + return pLibThread->m_pCategoryMgr; + + if (FAILED(cicCoCreateInstance(CLSID_TF_CategoryMgr, NULL, CLSCTX_INPROC_SERVER, + IID_ITfCategoryMgr, (void **)&pLibThread->m_pCategoryMgr))) + { + return NULL; + } + return pLibThread->m_pCategoryMgr; +} + +/// @implemented +HRESULT LibEnumItemsInCategory(PCIC_LIBTHREAD pLibThread, REFGUID rguid, IEnumGUID **ppEnum) +{ + ITfCategoryMgr *pCat = GetUIMCat(pLibThread); + if (!pCat) + return E_FAIL; + return pCat->EnumItemsInCategory(rguid, ppEnum); +} + +/// @implemented HRESULT InitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread) { if (!pLibThread) @@ -135,8 +165,37 @@ HRESULT InitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread) pLibThread->m_pDisplayAttrMgr = NULL; } - //FIXME - return E_NOTIMPL; + if (FAILED(cicCoCreateInstance(CLSID_TF_DisplayAttributeMgr, NULL, CLSCTX_INPROC_SERVER, + IID_ITfDisplayAttributeMgr, + (void **)&pLibThread->m_pDisplayAttrMgr))) + { + return E_FAIL; + } + + IEnumGUID *pEnumGuid; + LibEnumItemsInCategory(pLibThread, GUID_TFCAT_DISPLAYATTRIBUTEPROPERTY, &pEnumGuid); + + HRESULT hr = E_OUTOFMEMORY; + + ::EnterCriticalSection(&g_csLock); + if (pEnumGuid && !g_pPropCache) + { + g_pPropCache = new(cicNoThrow) CDispAttrPropCache(); + if (g_pPropCache) + { + g_pPropCache->Add(GUID_PROP_ATTRIBUTE); + GUID guid; + while (pEnumGuid->Next(1, &guid, NULL) == S_OK) + { + if (!IsEqualGUID(guid, GUID_PROP_ATTRIBUTE)) + g_pPropCache->Add(guid); + } + hr = S_OK; + } + } + ::LeaveCriticalSection(&g_csLock); + + return hr; } HIMC GetActiveContext(VOID) @@ -3646,6 +3705,15 @@ VOID DetachIME(VOID) UnregisterImeClass(); } +EXTERN_C VOID TFUninitLib(VOID) +{ + if (g_pPropCache) + { + delete g_pPropCache; + g_pPropCache = NULL; + } +} + /// @implemented BOOL ProcessAttach(HINSTANCE hinstDLL) { @@ -3667,11 +3735,9 @@ BOOL ProcessAttach(HINSTANCE hinstDLL) return AttachIME(); } -/// @unimplemented +/// @implemented VOID ProcessDetach(HINSTANCE hinstDLL) { - // FIXME - TF_DllDetachInOther(); if (gfTFInitLib) diff --git a/dll/win32/msctf/utils.cpp b/dll/win32/msctf/utils.cpp index 4fc57a5ac0d..ec469ceef28 100644 --- a/dll/win32/msctf/utils.cpp +++ b/dll/win32/msctf/utils.cpp @@ -519,6 +519,11 @@ VOID InitCUASFlag(VOID) } } +EXTERN_C VOID TFUninitLib(VOID) +{ + // Do nothing +} + /** * @unimplemented */ diff --git a/dll/win32/msutb/msutb.cpp b/dll/win32/msutb/msutb.cpp index 74c537ede80..912edc45598 100644 --- a/dll/win32/msutb/msutb.cpp +++ b/dll/win32/msutb/msutb.cpp @@ -6207,6 +6207,11 @@ BEGIN_OBJECT_MAP(ObjectMap) #endif END_OBJECT_MAP() +EXTERN_C VOID TFUninitLib(VOID) +{ + // Do nothing +} + /// @implemented BOOL ProcessAttach(HINSTANCE hinstDLL) { diff --git a/sdk/lib/cicero/cicbase.cpp b/sdk/lib/cicero/cicbase.cpp index cf76100e1cd..5c93f858d54 100644 --- a/sdk/lib/cicero/cicbase.cpp +++ b/sdk/lib/cicero/cicbase.cpp @@ -254,13 +254,3 @@ TFInitLib(FN_CoCreateInstance fnCoCreateInstance) _cicGetSetUserCoCreateInstance(fnCoCreateInstance); return TRUE; } - -/** - * @unimplemented - */ -EXTERN_C -VOID -TFUninitLib(VOID) -{ - //FIXME -} diff --git a/sdk/lib/cicero/cicutb.h b/sdk/lib/cicero/cicutb.h index b831ecc82bf..18bfbc874f0 100644 --- a/sdk/lib/cicero/cicutb.h +++ b/sdk/lib/cicero/cicutb.h @@ -17,10 +17,12 @@ DEFINE_GUID(IID_ITfLangBarMgr_P, 0xD72C0FA9, 0xADD5, 0x4AF0, 0x87, DEFINE_GUID(IID_ITfLangBarEventSink_P, 0x7A460360, 0xDA21, 0x4B09, 0xA8, 0xA0, 0x8A, 0x69, 0xE7, 0x28, 0xD8, 0x93); DEFINE_GUID(CLSID_MSUTBDeskBand, 0x540D8A8B, 0x1C3F, 0x4E32, 0x81, 0x32, 0x53, 0x0F, 0x6A, 0x50, 0x20, 0x90); DEFINE_GUID(CATID_DeskBand, 0x00021492, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); +DEFINE_GUID( + GUID_TFCAT_DISPLAYATTRIBUTEPROPERTY, 0xB95F181B, 0xEA4C, 0x4AF1, 0x80, 0x56, 0x7C, 0x32, 0x1A, 0xBB, 0xB0, 0x91); typedef struct CIC_LIBTHREAD { - IUnknown *m_pUnknown1; + ITfCategoryMgr *m_pCategoryMgr; ITfDisplayAttributeMgr *m_pDisplayAttrMgr; } CIC_LIBTHREAD, *PCIC_LIBTHREAD; @@ -44,10 +46,10 @@ inline void TFUninitLib_Thread(PCIC_LIBTHREAD pLibThread) if (!pLibThread) return; - if (pLibThread->m_pUnknown1) + if (pLibThread->m_pCategoryMgr) { - pLibThread->m_pUnknown1->Release(); - pLibThread->m_pUnknown1 = NULL; + pLibThread->m_pCategoryMgr->Release(); + pLibThread->m_pCategoryMgr = NULL; } if (pLibThread->m_pDisplayAttrMgr) {
10 months, 1 week
1
0
0
0
[reactos] 01/01: [SHELL32] Tweak formatting and logging
by Joachim Henze
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6f91b6c0fe61728cdd9d9…
commit 6f91b6c0fe61728cdd9d97e97e5bfbee03ed881e Author: Joachim Henze <Joachim.Henze(a)reactos.org> AuthorDate: Tue Feb 20 02:08:56 2024 +0100 Commit: Joachim Henze <Joachim.Henze(a)reactos.org> CommitDate: Tue Feb 20 02:08:56 2024 +0100 [SHELL32] Tweak formatting and logging Some style-improvements I wanted to apply before a planned backport. E.g. The biggest source-file CDefView.cpp in [SHELL32] can be shrinked considerably by stripping some outdated comments from 10 and more years ago, when this class was still non-OOP and named ShellView. Less excessive line-lengths also here and there. In case it is not obvious when reviewing: In the beginning of CDevView.cpp in the declaration-part I just reduced the indentation-level by 4 spaces for a big block. Some shell classes were touched during 0.4.15-dev'ing for fixes like the 'unkown'-typo in 0.4.15-dev-6323-g 3854a5d8e93d2c50153bda26ea378e65cc4241fa for example or missing \n were added to dbgprints like in 0.4.15-dev-4492-g 03422451b3b4a7df96a9e9af5ce7533fd6cb55d9 Touched again here, because I want to port those improvements back, but don't intend to increase the size in older releases. The commit looks big, but does consist solely of trivialities. There is no functional change in this commit, aside the logging ofc. --- dll/win32/shell32/CDefView.cpp | 1047 +++++++++------------ dll/win32/shell32/CDefaultContextMenu.cpp | 2 +- dll/win32/shell32/COpenWithMenu.cpp | 4 +- dll/win32/shell32/CShellLink.cpp | 2 +- dll/win32/shell32/dialogs/folder_options.cpp | 2 +- dll/win32/shell32/droptargets/CFSDropTarget.cpp | 4 +- dll/win32/shell32/folders/CControlPanelFolder.cpp | 3 +- dll/win32/shell32/folders/CDrivesFolder.cpp | 50 +- dll/win32/shell32/folders/CRegFolder.cpp | 2 +- dll/win32/shell32/shellmenu/CStartMenu.cpp | 2 +- dll/win32/shell32/shlfolder.cpp | 3 - 11 files changed, 467 insertions(+), 654 deletions(-) diff --git a/dll/win32/shell32/CDefView.cpp b/dll/win32/shell32/CDefView.cpp index 49ccc18cdea..cc5d1624ff7 100644 --- a/dll/win32/shell32/CDefView.cpp +++ b/dll/win32/shell32/CDefView.cpp @@ -50,17 +50,17 @@ typedef struct #define SHV_CHANGE_NOTIFY WM_USER + 0x1111 -/* For the context menu of the def view, the id of the items are based on 1 because we need - to call TrackPopupMenu and let it use the 0 value as an indication that the menu was canceled */ +// For the context menu of the def view, the id of the items are based on 1 because we need +// to call TrackPopupMenu and let it use the 0 value as an indication that the menu was canceled #define CONTEXT_MENU_BASE_ID 1 -/* Convert client coordinates to listview coordinates */ +// Convert client coordinates to listview coordinates static void ClientToListView(HWND hwndLV, POINT *ppt) { POINT Origin = {}; - /* FIXME: LVM_GETORIGIN is broken. See CORE-17266 */ + // FIXME: LVM_GETORIGIN is broken. See CORE-17266 if (!ListView_GetOrigin(hwndLV, &Origin)) return; @@ -94,7 +94,6 @@ struct MenuCleanup } }; - class CDefView : public CWindowImpl<CDefView, CWindow, CControlWinTraits>, public CComObjectRootEx<CComMultiThreadModelNoCS>, @@ -107,302 +106,301 @@ class CDefView : public IViewObject, public IServiceProvider { - private: - CComPtr<IShellFolder> m_pSFParent; - CComPtr<IShellFolder2> m_pSF2Parent; - CComPtr<IShellFolderViewCB> m_pShellFolderViewCB; - CComPtr<IShellBrowser> m_pShellBrowser; - CComPtr<ICommDlgBrowser> m_pCommDlgBrowser; - CComPtr<IShellFolderViewDual> m_pShellFolderViewDual; - CListView m_ListView; - HWND m_hWndParent; - FOLDERSETTINGS m_FolderSettings; - HMENU m_hMenu; /* Handle to the menu bar of the browser */ - HMENU m_hMenuArrangeModes; /* Handle to the popup menu with the arrange modes */ - HMENU m_hMenuViewModes; /* Handle to the popup menu with the view modes */ - HMENU m_hContextMenu; /* Handle to the open context menu */ - BOOL m_bmenuBarInitialized; - UINT m_uState; - UINT m_cidl; - PCUITEMID_CHILD *m_apidl; - PIDLIST_ABSOLUTE m_pidlParent; - LISTVIEW_SORT_INFO m_sortInfo; - ULONG m_hNotify; /* Change notification handle */ - HACCEL m_hAccel; - DWORD m_dwAspects; - DWORD m_dwAdvf; - CComPtr<IAdviseSink> m_pAdvSink; - // for drag and drop - CComPtr<IDataObject> m_pSourceDataObject; - CComPtr<IDropTarget> m_pCurDropTarget; /* The sub-item, which is currently dragged over */ - CComPtr<IDataObject> m_pCurDataObject; /* The dragged data-object */ - LONG m_iDragOverItem; /* Dragged over item's index, iff m_pCurDropTarget != NULL */ - UINT m_cScrollDelay; /* Send a WM_*SCROLL msg every 250 ms during drag-scroll */ - POINT m_ptLastMousePos; /* Mouse position at last DragOver call */ - POINT m_ptFirstMousePos; /* Mouse position when the drag operation started */ - DWORD m_grfKeyState; - // - CComPtr<IContextMenu> m_pCM; - CComPtr<IContextMenu> m_pFileMenu; - - BOOL m_isEditing; - BOOL m_isParentFolderSpecial; - - CLSID m_Category; - BOOL m_Destroyed; - SFVM_CUSTOMVIEWINFO_DATA m_viewinfo_data; - - HICON m_hMyComputerIcon; - - private: - HRESULT _MergeToolbar(); - BOOL _Sort(); - HRESULT _DoFolderViewCB(UINT uMsg, WPARAM wParam, LPARAM lParam); - HRESULT _GetSnapToGrid(); - void _MoveSelectionOnAutoArrange(POINT pt); - INT _FindInsertableIndexFromPoint(POINT pt); - void _HandleStatusBarResize(int width); - void _ForceStatusBarResize(); - void _DoCopyToMoveToFolder(BOOL bCopy); - - public: - CDefView(); - ~CDefView(); - HRESULT WINAPI Initialize(IShellFolder *shellFolder); - HRESULT IncludeObject(PCUITEMID_CHILD pidl); - HRESULT OnDefaultCommand(); - HRESULT OnStateChange(UINT uFlags); - void UpdateStatusbar(); - void CheckToolbar(); - BOOL CreateList(); - void UpdateListColors(); - BOOL InitList(); - static INT CALLBACK ListViewCompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData); - - PCUITEMID_CHILD _PidlByItem(int i); - PCUITEMID_CHILD _PidlByItem(LVITEM& lvItem); - int LV_FindItemByPidl(PCUITEMID_CHILD pidl); - int LV_AddItem(PCUITEMID_CHILD pidl); - BOOLEAN LV_DeleteItem(PCUITEMID_CHILD pidl); - BOOLEAN LV_RenameItem(PCUITEMID_CHILD pidlOld, PCUITEMID_CHILD pidlNew); - BOOLEAN LV_ProdItem(PCUITEMID_CHILD pidl); - static INT CALLBACK fill_list(LPVOID ptr, LPVOID arg); - HRESULT FillList(); - HRESULT FillFileMenu(); - HRESULT FillEditMenu(); - HRESULT FillViewMenu(); - HRESULT FillArrangeAsMenu(HMENU hmenuArrange); - HRESULT CheckViewMode(HMENU hmenuView); - UINT GetSelections(); - HRESULT OpenSelectedItems(); - void OnDeactivate(); - void DoActivate(UINT uState); - HRESULT drag_notify_subitem(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect); - HRESULT InvokeContextMenuCommand(CComPtr<IContextMenu>& pCM, LPCSTR lpVerb, POINT* pt = NULL); - LRESULT OnExplorerCommand(UINT uCommand, BOOL bUseSelection); - - // *** IOleWindow methods *** - virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *lphwnd); - virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode); - - // *** IShellView methods *** - virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator(MSG *pmsg); - virtual HRESULT STDMETHODCALLTYPE EnableModeless(BOOL fEnable); - virtual HRESULT STDMETHODCALLTYPE UIActivate(UINT uState); - virtual HRESULT STDMETHODCALLTYPE Refresh(); - virtual HRESULT STDMETHODCALLTYPE CreateViewWindow(IShellView *psvPrevious, LPCFOLDERSETTINGS pfs, IShellBrowser *psb, RECT *prcView, HWND *phWnd); - virtual HRESULT STDMETHODCALLTYPE DestroyViewWindow(); - virtual HRESULT STDMETHODCALLTYPE GetCurrentInfo(LPFOLDERSETTINGS pfs); - virtual HRESULT STDMETHODCALLTYPE AddPropertySheetPages(DWORD dwReserved, LPFNSVADDPROPSHEETPAGE pfn, LPARAM lparam); - virtual HRESULT STDMETHODCALLTYPE SaveViewState(); - virtual HRESULT STDMETHODCALLTYPE SelectItem(PCUITEMID_CHILD pidlItem, SVSIF uFlags); - virtual HRESULT STDMETHODCALLTYPE GetItemObject(UINT uItem, REFIID riid, void **ppv); - - // *** IShellView2 methods *** - virtual HRESULT STDMETHODCALLTYPE GetView(SHELLVIEWID *view_guid, ULONG view_type); - virtual HRESULT STDMETHODCALLTYPE CreateViewWindow2(LPSV2CVW2_PARAMS view_params); - virtual HRESULT STDMETHODCALLTYPE HandleRename(LPCITEMIDLIST new_pidl); - virtual HRESULT STDMETHODCALLTYPE SelectAndPositionItem(LPCITEMIDLIST item, UINT flags, POINT *point); - - // *** IShellView3 methods *** - virtual HRESULT STDMETHODCALLTYPE CreateViewWindow3(IShellBrowser *psb, IShellView *psvPrevious, SV3CVW3_FLAGS view_flags, FOLDERFLAGS mask, FOLDERFLAGS flags, FOLDERVIEWMODE mode, const SHELLVIEWID *view_id, RECT *prcView, HWND *hwnd); - - // *** IFolderView methods *** - virtual HRESULT STDMETHODCALLTYPE GetCurrentViewMode(UINT *pViewMode); - virtual HRESULT STDMETHODCALLTYPE SetCurrentViewMode(UINT ViewMode); - virtual HRESULT STDMETHODCALLTYPE GetFolder(REFIID riid, void **ppv); - virtual HRESULT STDMETHODCALLTYPE Item(int iItemIndex, PITEMID_CHILD *ppidl); - virtual HRESULT STDMETHODCALLTYPE ItemCount(UINT uFlags, int *pcItems); - virtual HRESULT STDMETHODCALLTYPE Items(UINT uFlags, REFIID riid, void **ppv); - virtual HRESULT STDMETHODCALLTYPE GetSelectionMarkedItem(int *piItem); - virtual HRESULT STDMETHODCALLTYPE GetFocusedItem(int *piItem); - virtual HRESULT STDMETHODCALLTYPE GetItemPosition(PCUITEMID_CHILD pidl, POINT *ppt); - virtual HRESULT STDMETHODCALLTYPE GetSpacing(POINT *ppt); - virtual HRESULT STDMETHODCALLTYPE GetDefaultSpacing(POINT *ppt); - virtual HRESULT STDMETHODCALLTYPE GetAutoArrange(); - virtual HRESULT STDMETHODCALLTYPE SelectItem(int iItem, DWORD dwFlags); - virtual HRESULT STDMETHODCALLTYPE SelectAndPositionItems(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, POINT *apt, DWORD dwFlags); - - // *** IShellFolderView methods *** - virtual HRESULT STDMETHODCALLTYPE Rearrange(LPARAM sort); - virtual HRESULT STDMETHODCALLTYPE GetArrangeParam(LPARAM *sort); - virtual HRESULT STDMETHODCALLTYPE ArrangeGrid(); - virtual HRESULT STDMETHODCALLTYPE AutoArrange(); - virtual HRESULT STDMETHODCALLTYPE AddObject(PITEMID_CHILD pidl, UINT *item); - virtual HRESULT STDMETHODCALLTYPE GetObject(PITEMID_CHILD *pidl, UINT item); - virtual HRESULT STDMETHODCALLTYPE RemoveObject(PITEMID_CHILD pidl, UINT *item); - virtual HRESULT STDMETHODCALLTYPE GetObjectCount(UINT *count); - virtual HRESULT STDMETHODCALLTYPE SetObjectCount(UINT count, UINT flags); - virtual HRESULT STDMETHODCALLTYPE UpdateObject(PITEMID_CHILD pidl_old, PITEMID_CHILD pidl_new, UINT *item); - virtual HRESULT STDMETHODCALLTYPE RefreshObject(PITEMID_CHILD pidl, UINT *item); - virtual HRESULT STDMETHODCALLTYPE SetRedraw(BOOL redraw); - virtual HRESULT STDMETHODCALLTYPE GetSelectedCount(UINT *count); - virtual HRESULT STDMETHODCALLTYPE GetSelectedObjects(PCUITEMID_CHILD **pidl, UINT *items); - virtual HRESULT STDMETHODCALLTYPE IsDropOnSource(IDropTarget *drop_target); - virtual HRESULT STDMETHODCALLTYPE GetDragPoint(POINT *pt); - virtual HRESULT STDMETHODCALLTYPE GetDropPoint(POINT *pt); - virtual HRESULT STDMETHODCALLTYPE MoveIcons(IDataObject *obj); - virtual HRESULT STDMETHODCALLTYPE SetItemPos(PCUITEMID_CHILD pidl, POINT *pt); - virtual HRESULT STDMETHODCALLTYPE IsBkDropTarget(IDropTarget *drop_target); - virtual HRESULT STDMETHODCALLTYPE SetClipboard(BOOL move); - virtual HRESULT STDMETHODCALLTYPE SetPoints(IDataObject *obj); - virtual HRESULT STDMETHODCALLTYPE GetItemSpacing(ITEMSPACING *spacing); - virtual HRESULT STDMETHODCALLTYPE SetCallback(IShellFolderViewCB *new_cb, IShellFolderViewCB **old_cb); - virtual HRESULT STDMETHODCALLTYPE Select(UINT flags); - virtual HRESULT STDMETHODCALLTYPE QuerySupport(UINT *support); - virtual HRESULT STDMETHODCALLTYPE SetAutomationObject(IDispatch *disp); - - // *** IOleCommandTarget methods *** - virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT *pCmdText); - virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut); - - // *** IDropTarget methods *** - virtual HRESULT STDMETHODCALLTYPE DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect); - virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect); - virtual HRESULT STDMETHODCALLTYPE DragLeave(); - virtual HRESULT STDMETHODCALLTYPE Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect); - - // *** IDropSource methods *** - virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState); - virtual HRESULT STDMETHODCALLTYPE GiveFeedback(DWORD dwEffect); - - // *** IViewObject methods *** - virtual HRESULT STDMETHODCALLTYPE Draw(DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, - HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds, - BOOL ( STDMETHODCALLTYPE *pfnContinue )(ULONG_PTR dwContinue), ULONG_PTR dwContinue); - virtual HRESULT STDMETHODCALLTYPE GetColorSet(DWORD dwDrawAspect, LONG lindex, void *pvAspect, - DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet); - virtual HRESULT STDMETHODCALLTYPE Freeze(DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze); - virtual HRESULT STDMETHODCALLTYPE Unfreeze(DWORD dwFreeze); - virtual HRESULT STDMETHODCALLTYPE SetAdvise(DWORD aspects, DWORD advf, IAdviseSink *pAdvSink); - virtual HRESULT STDMETHODCALLTYPE GetAdvise(DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink); - - // *** IServiceProvider methods *** - virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppvObject); - - // Message handlers - LRESULT OnShowWindow(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnGetDlgCode(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnPrintClient(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnSysColorChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnGetShellBrowser(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnNCCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnChangeNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnCustomItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnSettingChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT OnInitMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - - virtual VOID OnFinalMessage(HWND) override; - - static ATL::CWndClassInfo& GetWndClassInfo() - { - static ATL::CWndClassInfo wc = - { - { sizeof(WNDCLASSEX), CS_PARENTDC, StartWindowProc, - 0, 0, NULL, NULL, - LoadCursor(NULL, IDC_ARROW), NULL, NULL, L"SHELLDLL_DefView", NULL - }, - NULL, NULL, IDC_ARROW, TRUE, 0, _T("") - }; - return wc; - } - - virtual WNDPROC GetWindowProc() +private: + CComPtr<IShellFolder> m_pSFParent; + CComPtr<IShellFolder2> m_pSF2Parent; + CComPtr<IShellFolderViewCB> m_pShellFolderViewCB; + CComPtr<IShellBrowser> m_pShellBrowser; + CComPtr<ICommDlgBrowser> m_pCommDlgBrowser; + CComPtr<IShellFolderViewDual> m_pShellFolderViewDual; + CListView m_ListView; + HWND m_hWndParent; + FOLDERSETTINGS m_FolderSettings; + HMENU m_hMenu; // Handle to the menu bar of the browser + HMENU m_hMenuArrangeModes; // Handle to the popup menu with the arrange modes + HMENU m_hMenuViewModes; // Handle to the popup menu with the view modes + HMENU m_hContextMenu; // Handle to the open context menu + BOOL m_bmenuBarInitialized; + UINT m_uState; + UINT m_cidl; + PCUITEMID_CHILD *m_apidl; + PIDLIST_ABSOLUTE m_pidlParent; + LISTVIEW_SORT_INFO m_sortInfo; + ULONG m_hNotify; // Change notification handle + HACCEL m_hAccel; + DWORD m_dwAspects; + DWORD m_dwAdvf; + CComPtr<IAdviseSink> m_pAdvSink; + // for drag and drop + CComPtr<IDataObject> m_pSourceDataObject; + CComPtr<IDropTarget> m_pCurDropTarget; // The sub-item, which is currently dragged over + CComPtr<IDataObject> m_pCurDataObject; // The dragged data-object + LONG m_iDragOverItem; // Dragged over item's index, if m_pCurDropTarget != NULL + UINT m_cScrollDelay; // Send a WM_*SCROLL msg every 250 ms during drag-scroll + POINT m_ptLastMousePos; // Mouse position at last DragOver call + POINT m_ptFirstMousePos; // Mouse position when the drag operation started + DWORD m_grfKeyState; + // + CComPtr<IContextMenu> m_pCM; + CComPtr<IContextMenu> m_pFileMenu; + + BOOL m_isEditing; + BOOL m_isParentFolderSpecial; + + CLSID m_Category; + BOOL m_Destroyed; + SFVM_CUSTOMVIEWINFO_DATA m_viewinfo_data; + + HICON m_hMyComputerIcon; + + HRESULT _MergeToolbar(); + BOOL _Sort(); + HRESULT _DoFolderViewCB(UINT uMsg, WPARAM wParam, LPARAM lParam); + HRESULT _GetSnapToGrid(); + void _MoveSelectionOnAutoArrange(POINT pt); + INT _FindInsertableIndexFromPoint(POINT pt); + void _HandleStatusBarResize(int width); + void _ForceStatusBarResize(); + void _DoCopyToMoveToFolder(BOOL bCopy); + +public: + CDefView(); + ~CDefView(); + HRESULT WINAPI Initialize(IShellFolder *shellFolder); + HRESULT IncludeObject(PCUITEMID_CHILD pidl); + HRESULT OnDefaultCommand(); + HRESULT OnStateChange(UINT uFlags); + void UpdateStatusbar(); + void CheckToolbar(); + BOOL CreateList(); + void UpdateListColors(); + BOOL InitList(); + static INT CALLBACK ListViewCompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData); + + PCUITEMID_CHILD _PidlByItem(int i); + PCUITEMID_CHILD _PidlByItem(LVITEM& lvItem); + int LV_FindItemByPidl(PCUITEMID_CHILD pidl); + int LV_AddItem(PCUITEMID_CHILD pidl); + BOOLEAN LV_DeleteItem(PCUITEMID_CHILD pidl); + BOOLEAN LV_RenameItem(PCUITEMID_CHILD pidlOld, PCUITEMID_CHILD pidlNew); + BOOLEAN LV_ProdItem(PCUITEMID_CHILD pidl); + static INT CALLBACK fill_list(LPVOID ptr, LPVOID arg); + HRESULT FillList(); + HRESULT FillFileMenu(); + HRESULT FillEditMenu(); + HRESULT FillViewMenu(); + HRESULT FillArrangeAsMenu(HMENU hmenuArrange); + HRESULT CheckViewMode(HMENU hmenuView); + UINT GetSelections(); + HRESULT OpenSelectedItems(); + void OnDeactivate(); + void DoActivate(UINT uState); + HRESULT drag_notify_subitem(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect); + HRESULT InvokeContextMenuCommand(CComPtr<IContextMenu>& pCM, LPCSTR lpVerb, POINT* pt = NULL); + LRESULT OnExplorerCommand(UINT uCommand, BOOL bUseSelection); + + // *** IOleWindow methods *** + virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *lphwnd); + virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode); + + // *** IShellView methods *** + virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator(MSG *pmsg); + virtual HRESULT STDMETHODCALLTYPE EnableModeless(BOOL fEnable); + virtual HRESULT STDMETHODCALLTYPE UIActivate(UINT uState); + virtual HRESULT STDMETHODCALLTYPE Refresh(); + virtual HRESULT STDMETHODCALLTYPE CreateViewWindow(IShellView *psvPrevious, LPCFOLDERSETTINGS pfs, IShellBrowser *psb, RECT *prcView, HWND *phWnd); + virtual HRESULT STDMETHODCALLTYPE DestroyViewWindow(); + virtual HRESULT STDMETHODCALLTYPE GetCurrentInfo(LPFOLDERSETTINGS pfs); + virtual HRESULT STDMETHODCALLTYPE AddPropertySheetPages(DWORD dwReserved, LPFNSVADDPROPSHEETPAGE pfn, LPARAM lparam); + virtual HRESULT STDMETHODCALLTYPE SaveViewState(); + virtual HRESULT STDMETHODCALLTYPE SelectItem(PCUITEMID_CHILD pidlItem, SVSIF uFlags); + virtual HRESULT STDMETHODCALLTYPE GetItemObject(UINT uItem, REFIID riid, void **ppv); + + // *** IShellView2 methods *** + virtual HRESULT STDMETHODCALLTYPE GetView(SHELLVIEWID *view_guid, ULONG view_type); + virtual HRESULT STDMETHODCALLTYPE CreateViewWindow2(LPSV2CVW2_PARAMS view_params); + virtual HRESULT STDMETHODCALLTYPE HandleRename(LPCITEMIDLIST new_pidl); + virtual HRESULT STDMETHODCALLTYPE SelectAndPositionItem(LPCITEMIDLIST item, UINT flags, POINT *point); + + // *** IShellView3 methods *** + virtual HRESULT STDMETHODCALLTYPE CreateViewWindow3(IShellBrowser *psb, IShellView *psvPrevious, SV3CVW3_FLAGS view_flags, FOLDERFLAGS mask, FOLDERFLAGS flags, FOLDERVIEWMODE mode, const SHELLVIEWID *view_id, RECT *prcView, HWND *hwnd); + + // *** IFolderView methods *** + virtual HRESULT STDMETHODCALLTYPE GetCurrentViewMode(UINT *pViewMode); + virtual HRESULT STDMETHODCALLTYPE SetCurrentViewMode(UINT ViewMode); + virtual HRESULT STDMETHODCALLTYPE GetFolder(REFIID riid, void **ppv); + virtual HRESULT STDMETHODCALLTYPE Item(int iItemIndex, PITEMID_CHILD *ppidl); + virtual HRESULT STDMETHODCALLTYPE ItemCount(UINT uFlags, int *pcItems); + virtual HRESULT STDMETHODCALLTYPE Items(UINT uFlags, REFIID riid, void **ppv); + virtual HRESULT STDMETHODCALLTYPE GetSelectionMarkedItem(int *piItem); + virtual HRESULT STDMETHODCALLTYPE GetFocusedItem(int *piItem); + virtual HRESULT STDMETHODCALLTYPE GetItemPosition(PCUITEMID_CHILD pidl, POINT *ppt); + virtual HRESULT STDMETHODCALLTYPE GetSpacing(POINT *ppt); + virtual HRESULT STDMETHODCALLTYPE GetDefaultSpacing(POINT *ppt); + virtual HRESULT STDMETHODCALLTYPE GetAutoArrange(); + virtual HRESULT STDMETHODCALLTYPE SelectItem(int iItem, DWORD dwFlags); + virtual HRESULT STDMETHODCALLTYPE SelectAndPositionItems(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, POINT *apt, DWORD dwFlags); + + // *** IShellFolderView methods *** + virtual HRESULT STDMETHODCALLTYPE Rearrange(LPARAM sort); + virtual HRESULT STDMETHODCALLTYPE GetArrangeParam(LPARAM *sort); + virtual HRESULT STDMETHODCALLTYPE ArrangeGrid(); + virtual HRESULT STDMETHODCALLTYPE AutoArrange(); + virtual HRESULT STDMETHODCALLTYPE AddObject(PITEMID_CHILD pidl, UINT *item); + virtual HRESULT STDMETHODCALLTYPE GetObject(PITEMID_CHILD *pidl, UINT item); + virtual HRESULT STDMETHODCALLTYPE RemoveObject(PITEMID_CHILD pidl, UINT *item); + virtual HRESULT STDMETHODCALLTYPE GetObjectCount(UINT *count); + virtual HRESULT STDMETHODCALLTYPE SetObjectCount(UINT count, UINT flags); + virtual HRESULT STDMETHODCALLTYPE UpdateObject(PITEMID_CHILD pidl_old, PITEMID_CHILD pidl_new, UINT *item); + virtual HRESULT STDMETHODCALLTYPE RefreshObject(PITEMID_CHILD pidl, UINT *item); + virtual HRESULT STDMETHODCALLTYPE SetRedraw(BOOL redraw); + virtual HRESULT STDMETHODCALLTYPE GetSelectedCount(UINT *count); + virtual HRESULT STDMETHODCALLTYPE GetSelectedObjects(PCUITEMID_CHILD **pidl, UINT *items); + virtual HRESULT STDMETHODCALLTYPE IsDropOnSource(IDropTarget *drop_target); + virtual HRESULT STDMETHODCALLTYPE GetDragPoint(POINT *pt); + virtual HRESULT STDMETHODCALLTYPE GetDropPoint(POINT *pt); + virtual HRESULT STDMETHODCALLTYPE MoveIcons(IDataObject *obj); + virtual HRESULT STDMETHODCALLTYPE SetItemPos(PCUITEMID_CHILD pidl, POINT *pt); + virtual HRESULT STDMETHODCALLTYPE IsBkDropTarget(IDropTarget *drop_target); + virtual HRESULT STDMETHODCALLTYPE SetClipboard(BOOL move); + virtual HRESULT STDMETHODCALLTYPE SetPoints(IDataObject *obj); + virtual HRESULT STDMETHODCALLTYPE GetItemSpacing(ITEMSPACING *spacing); + virtual HRESULT STDMETHODCALLTYPE SetCallback(IShellFolderViewCB *new_cb, IShellFolderViewCB **old_cb); + virtual HRESULT STDMETHODCALLTYPE Select(UINT flags); + virtual HRESULT STDMETHODCALLTYPE QuerySupport(UINT *support); + virtual HRESULT STDMETHODCALLTYPE SetAutomationObject(IDispatch *disp); + + // *** IOleCommandTarget methods *** + virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText); + virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut); + + // *** IDropTarget methods *** + virtual HRESULT STDMETHODCALLTYPE DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect); + virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect); + virtual HRESULT STDMETHODCALLTYPE DragLeave(); + virtual HRESULT STDMETHODCALLTYPE Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect); + + // *** IDropSource methods *** + virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState); + virtual HRESULT STDMETHODCALLTYPE GiveFeedback(DWORD dwEffect); + + // *** IViewObject methods *** + virtual HRESULT STDMETHODCALLTYPE Draw(DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, + HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds, + BOOL (STDMETHODCALLTYPE *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue); + virtual HRESULT STDMETHODCALLTYPE GetColorSet(DWORD dwDrawAspect, LONG lindex, void *pvAspect, + DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet); + virtual HRESULT STDMETHODCALLTYPE Freeze(DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze); + virtual HRESULT STDMETHODCALLTYPE Unfreeze(DWORD dwFreeze); + virtual HRESULT STDMETHODCALLTYPE SetAdvise(DWORD aspects, DWORD advf, IAdviseSink *pAdvSink); + virtual HRESULT STDMETHODCALLTYPE GetAdvise(DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink); + + // *** IServiceProvider methods *** + virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppvObject); + + // Message handlers + LRESULT OnShowWindow(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnGetDlgCode(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnPrintClient(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnSysColorChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnGetShellBrowser(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnNCCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnChangeNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnCustomItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnSettingChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnInitMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + + virtual VOID OnFinalMessage(HWND) override; + + static ATL::CWndClassInfo& GetWndClassInfo() + { + static ATL::CWndClassInfo wc = { - return WindowProc; - } - - static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) - { - CDefView *pThis; - LRESULT result; - - // Must hold a reference during message handling - pThis = reinterpret_cast<CDefView *>(hWnd); - pThis->AddRef(); - result = CWindowImpl<CDefView, CWindow, CControlWinTraits>::WindowProc(hWnd, uMsg, wParam, lParam); - pThis->Release(); - return result; - } - - BEGIN_MSG_MAP(CDefView) - MESSAGE_HANDLER(WM_SIZE, OnSize) - MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) - MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus) - MESSAGE_HANDLER(WM_NCCREATE, OnNCCreate) - MESSAGE_HANDLER(WM_CREATE, OnCreate) - MESSAGE_HANDLER(WM_ACTIVATE, OnActivate) - MESSAGE_HANDLER(WM_NOTIFY, OnNotify) - MESSAGE_HANDLER(WM_COMMAND, OnCommand) - MESSAGE_HANDLER(SHV_CHANGE_NOTIFY, OnChangeNotify) - MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu) - MESSAGE_HANDLER(WM_DRAWITEM, OnCustomItem) - MESSAGE_HANDLER(WM_MEASUREITEM, OnCustomItem) - MESSAGE_HANDLER(WM_SHOWWINDOW, OnShowWindow) - MESSAGE_HANDLER(WM_GETDLGCODE, OnGetDlgCode) - MESSAGE_HANDLER(WM_DESTROY, OnDestroy) - MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) - MESSAGE_HANDLER(WM_PRINTCLIENT, OnPrintClient) - MESSAGE_HANDLER(WM_SYSCOLORCHANGE, OnSysColorChange) - MESSAGE_HANDLER(CWM_GETISHELLBROWSER, OnGetShellBrowser) - MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange) - MESSAGE_HANDLER(WM_INITMENUPOPUP, OnInitMenuPopup) - END_MSG_MAP() - - BEGIN_COM_MAP(CDefView) - // Windows returns E_NOINTERFACE for IOleWindow - // COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IOleWindow) - COM_INTERFACE_ENTRY_IID(IID_IShellView, IShellView) - COM_INTERFACE_ENTRY_IID(IID_CDefView, IShellView) - COM_INTERFACE_ENTRY_IID(IID_IShellView2, IShellView2) - COM_INTERFACE_ENTRY_IID(IID_IFolderView, IFolderView) - COM_INTERFACE_ENTRY_IID(IID_IShellFolderView, IShellFolderView) - COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget) - COM_INTERFACE_ENTRY_IID(IID_IDropTarget, IDropTarget) - COM_INTERFACE_ENTRY_IID(IID_IDropSource, IDropSource) - COM_INTERFACE_ENTRY_IID(IID_IViewObject, IViewObject) - COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider) - END_COM_MAP() + { sizeof(WNDCLASSEX), CS_PARENTDC, StartWindowProc, + 0, 0, NULL, NULL, + LoadCursor(NULL, IDC_ARROW), NULL, NULL, L"SHELLDLL_DefView", NULL + }, + NULL, NULL, IDC_ARROW, TRUE, 0, _T("") + }; + return wc; + } + + virtual WNDPROC GetWindowProc() + { + return WindowProc; + } + + static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) + { + CDefView *pThis; + LRESULT result; + + // Must hold a reference during message handling + pThis = reinterpret_cast<CDefView *>(hWnd); + pThis->AddRef(); + result = CWindowImpl<CDefView, CWindow, CControlWinTraits>::WindowProc(hWnd, uMsg, wParam, lParam); + pThis->Release(); + return result; + } + + BEGIN_MSG_MAP(CDefView) + MESSAGE_HANDLER(WM_SIZE, OnSize) + MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) + MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus) + MESSAGE_HANDLER(WM_NCCREATE, OnNCCreate) + MESSAGE_HANDLER(WM_CREATE, OnCreate) + MESSAGE_HANDLER(WM_ACTIVATE, OnActivate) + MESSAGE_HANDLER(WM_NOTIFY, OnNotify) + MESSAGE_HANDLER(WM_COMMAND, OnCommand) + MESSAGE_HANDLER(SHV_CHANGE_NOTIFY, OnChangeNotify) + MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu) + MESSAGE_HANDLER(WM_DRAWITEM, OnCustomItem) + MESSAGE_HANDLER(WM_MEASUREITEM, OnCustomItem) + MESSAGE_HANDLER(WM_SHOWWINDOW, OnShowWindow) + MESSAGE_HANDLER(WM_GETDLGCODE, OnGetDlgCode) + MESSAGE_HANDLER(WM_DESTROY, OnDestroy) + MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) + MESSAGE_HANDLER(WM_PRINTCLIENT, OnPrintClient) + MESSAGE_HANDLER(WM_SYSCOLORCHANGE, OnSysColorChange) + MESSAGE_HANDLER(CWM_GETISHELLBROWSER, OnGetShellBrowser) + MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange) + MESSAGE_HANDLER(WM_INITMENUPOPUP, OnInitMenuPopup) + END_MSG_MAP() + + BEGIN_COM_MAP(CDefView) + // Windows returns E_NOINTERFACE for IOleWindow + // COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IOleWindow) + COM_INTERFACE_ENTRY_IID(IID_IShellView, IShellView) + COM_INTERFACE_ENTRY_IID(IID_CDefView, IShellView) + COM_INTERFACE_ENTRY_IID(IID_IShellView2, IShellView2) + COM_INTERFACE_ENTRY_IID(IID_IFolderView, IFolderView) + COM_INTERFACE_ENTRY_IID(IID_IShellFolderView, IShellFolderView) + COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget) + COM_INTERFACE_ENTRY_IID(IID_IDropTarget, IDropTarget) + COM_INTERFACE_ENTRY_IID(IID_IDropSource, IDropSource) + COM_INTERFACE_ENTRY_IID(IID_IViewObject, IViewObject) + COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider) + END_COM_MAP() }; -/*menu items */ +// menu items #define IDM_VIEW_FILES (FCIDM_SHVIEWFIRST + 0x500) #define IDM_VIEW_IDW (FCIDM_SHVIEWFIRST + 0x501) #define IDM_MYFILEITEM (FCIDM_SHVIEWFIRST + 0x502) #define ID_LISTVIEW 1 -/*windowsx.h */ +// windowsx.h #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp) #define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp) #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp) @@ -470,10 +468,8 @@ HRESULT WINAPI CDefView::Initialize(IShellFolder *shellFolder) return S_OK; } -/********************************************************** - * - * ##### helperfunctions for communication with ICommDlgBrowser ##### - */ +// ##### helperfunctions for communication with ICommDlgBrowser ##### + HRESULT CDefView::IncludeObject(PCUITEMID_CHILD pidl) { HRESULT ret = S_OK; @@ -564,7 +560,7 @@ void CDefView::UpdateStatusbar() LRESULT lResult; m_pShellBrowser->SendControlMsg(FCW_STATUS, SB_SETTEXT, 0, (LPARAM)szPartText, &lResult); - /* Don't bother with the extra processing if we only have one StatusBar part. */ + // Don't bother with the extra processing if we only have one StatusBar part if (!m_isParentFolderSpecial) { DWORD uTotalFileSize = 0; @@ -573,7 +569,7 @@ void CDefView::UpdateStatusbar() INT nItem = -1; bool bIsOnlyFoldersSelected = true; - /* If we have something selected then only count selected file sizes. */ + // If we have something selected then only count selected file sizes if (cSelectedItems) { uFileFlags = LVNI_SELECTED; @@ -591,8 +587,8 @@ void CDefView::UpdateStatusbar() } } - /* Don't show the file size text if there is 0 bytes in the folder - * OR we only have folders selected. */ + // Don't show the file size text if there is 0 bytes in the folder + // OR we only have folders selected if ((cSelectedItems && !bIsOnlyFoldersSelected) || uTotalFileSize) { StrFormatByteSizeW(uTotalFileSize, szPartText, _countof(szPartText)); @@ -604,7 +600,7 @@ void CDefView::UpdateStatusbar() m_pShellBrowser->SendControlMsg(FCW_STATUS, SB_SETTEXT, 1, (LPARAM)szPartText, &lResult); - /* If we are in a Recycle Bin folder then show no text for the location part. */ + // If we are in a Recycle Bin then show no text for the location part if (!_ILIsBitBucket(m_pidlParent)) { LoadStringW(shell32_hInstance, IDS_MYCOMPUTER, szPartText, _countof(szPartText)); @@ -616,16 +612,10 @@ void CDefView::UpdateStatusbar() } } -/********************************************************** - * - * ##### helperfunctions for initializing the view ##### - */ -/********************************************************** -* ShellView_CreateList() -* -* - creates the list view window -*/ +// ##### helperfunctions for initializing the view ##### + +// creates the list view window BOOL CDefView::CreateList() { HRESULT hr; @@ -646,7 +636,7 @@ BOOL CDefView::CreateList() } else { - dwStyle |= LVS_SHOWSELALWAYS; // MSDN says FWF_SHOWSELALWAYS is deprecated, always turn on for folders. + dwStyle |= LVS_SHOWSELALWAYS; // MSDN says FWF_SHOWSELALWAYS is deprecated, always turn on for folders dwStyle |= (m_FolderSettings.fFlags & FWF_ALIGNLEFT) ? LVS_ALIGNLEFT : LVS_ALIGNTOP; ListExStyle = LVS_EX_DOUBLEBUFFER; } @@ -666,19 +656,15 @@ BOOL CDefView::CreateList() case FVM_ICON: dwStyle |= LVS_ICON; break; - case FVM_DETAILS: dwStyle |= LVS_REPORT; break; - case FVM_SMALLICON: dwStyle |= LVS_SMALLICON; break; - case FVM_LIST: dwStyle |= LVS_LIST; break; - default: dwStyle |= LVS_LIST; break; @@ -704,7 +690,7 @@ BOOL CDefView::CreateList() #if 0 // FIXME: Because this is a negative, everyone gets the new flag by default unless they - // opt out. This code should be enabled when the shell looks like Vista instead of 2003. + // opt out. This code should be enabled when shell looks like Vista instead of 2003 if (!(m_FolderSettings.fFlags & FWF_NOHEADERINALLVIEWS)) ListExStyle |= LVS_EX_HEADERINALLVIEWS; #endif @@ -779,16 +765,12 @@ void CDefView::UpdateListColors() m_ListView.SetTextColor(clrText); - // Background is painted by the parent via WM_PRINTCLIENT. + // Background is painted by the parent via WM_PRINTCLIENT m_ListView.SetExtendedListViewStyle(LVS_EX_TRANSPARENTBKGND, LVS_EX_TRANSPARENTBKGND); } } -/********************************************************** -* ShellView_InitList() -* -* - adds all needed columns to the shellview -*/ +// adds all needed columns to the shellview BOOL CDefView::InitList() { SHELLDETAILS sd; @@ -869,7 +851,7 @@ BOOL CDefView::_Sort() hHeader = (HWND)m_ListView.SendMessage(LVM_GETHEADER, 0, 0); ZeroMemory(&hColumn, sizeof(hColumn)); - /* If the sorting column changed, remove the sorting style from the old column */ + // If the sorting column changed, remove sorting style from the old column if ( (m_sortInfo.nLastHeaderID != -1) && (m_sortInfo.nLastHeaderID != m_sortInfo.nHeaderID) ) { @@ -906,9 +888,6 @@ PCUITEMID_CHILD CDefView::_PidlByItem(LVITEM& lvItem) return reinterpret_cast<PCUITEMID_CHILD>(lvItem.lParam); } -/********************************************************** -* LV_FindItemByPidl() -*/ int CDefView::LV_FindItemByPidl(PCUITEMID_CHILD pidl) { ASSERT(m_ListView); @@ -924,9 +903,6 @@ int CDefView::LV_FindItemByPidl(PCUITEMID_CHILD pidl) return -1; } -/********************************************************** -* LV_AddItem() -*/ int CDefView::LV_AddItem(PCUITEMID_CHILD pidl) { LVITEMW lvItem; @@ -938,20 +914,17 @@ int CDefView::LV_AddItem(PCUITEMID_CHILD pidl) if (_DoFolderViewCB(SFVM_ADDINGOBJECT, 0, (LPARAM)pidl) == S_FALSE) return -1; - lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; /*set the mask*/ - lvItem.iItem = m_ListView.GetItemCount(); /*add the item to the end of the list*/ + lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; // set mask + lvItem.iItem = m_ListView.GetItemCount(); // add item to lists end lvItem.iSubItem = 0; - lvItem.lParam = reinterpret_cast<LPARAM>(ILClone(pidl)); /*set the item's data*/ - lvItem.pszText = LPSTR_TEXTCALLBACKW; /*get text on a callback basis*/ - lvItem.iImage = I_IMAGECALLBACK; /*get the image on a callback basis*/ + lvItem.lParam = reinterpret_cast<LPARAM>(ILClone(pidl)); // set item's data + lvItem.pszText = LPSTR_TEXTCALLBACKW; // get text on a callback basis + lvItem.iImage = I_IMAGECALLBACK; // get image on a callback basis lvItem.stateMask = LVIS_CUT; return m_ListView.InsertItem(&lvItem); } -/********************************************************** -* LV_DeleteItem() -*/ BOOLEAN CDefView::LV_DeleteItem(PCUITEMID_CHILD pidl) { int nIndex; @@ -967,9 +940,6 @@ BOOLEAN CDefView::LV_DeleteItem(PCUITEMID_CHILD pidl) return m_ListView.DeleteItem(nIndex); } -/********************************************************** -* LV_RenameItem() -*/ BOOLEAN CDefView::LV_RenameItem(PCUITEMID_CHILD pidlOld, PCUITEMID_CHILD pidlNew) { int nItem; @@ -981,35 +951,34 @@ BOOLEAN CDefView::LV_RenameItem(PCUITEMID_CHILD pidlOld, PCUITEMID_CHILD pidlNew nItem = LV_FindItemByPidl(pidlOld); - if ( -1 != nItem ) + if (-1 != nItem) { - lvItem.mask = LVIF_PARAM; /* only the pidl */ + lvItem.mask = LVIF_PARAM; // only the pidl lvItem.iItem = nItem; lvItem.iSubItem = 0; m_ListView.GetItem(&lvItem); - LPVOID oldPidl = reinterpret_cast<LPVOID>(lvItem.lParam); /* Store the old pidl until the new item is replaced */ + // Store old pidl until new item is replaced + LPVOID oldPidl = reinterpret_cast<LPVOID>(lvItem.lParam); lvItem.mask = LVIF_PARAM | LVIF_IMAGE | LVIF_TEXT; lvItem.iItem = nItem; lvItem.iSubItem = 0; - lvItem.lParam = reinterpret_cast<LPARAM>(ILClone(pidlNew)); /* set the item's data */ + lvItem.lParam = reinterpret_cast<LPARAM>(ILClone(pidlNew)); // set item's data lvItem.pszText = LPSTR_TEXTCALLBACKW; lvItem.iImage = SHMapPIDLToSystemImageListIndex(m_pSFParent, pidlNew, 0); m_ListView.SetItem(&lvItem); m_ListView.Update(nItem); - SHFree(oldPidl); /* Now that the new item is in place, we can safely release the old pidl */ + // Now that the new item is in place, we can safely release the old pidl + SHFree(oldPidl); - return TRUE; /* FIXME: better handling */ + return TRUE; // FIXME: better handling } return FALSE; } -/********************************************************** -* LV_ProdItem() -*/ BOOLEAN CDefView::LV_ProdItem(PCUITEMID_CHILD pidl) { int nItem; @@ -1035,19 +1004,12 @@ BOOLEAN CDefView::LV_ProdItem(PCUITEMID_CHILD pidl) return FALSE; } -/********************************************************** -* ShellView_FillList() -* -* - gets the objectlist from the shellfolder -* - sorts the list -* - fills the list into the view -*/ INT CALLBACK CDefView::fill_list(LPVOID ptr, LPVOID arg) { PITEMID_CHILD pidl = static_cast<PITEMID_CHILD>(ptr); CDefView *pThis = static_cast<CDefView *>(arg); - /* in a commdlg This works as a filemask*/ + // in a commdlg this works as a filemask if (pThis->IncludeObject(pidl) == S_OK && pThis->m_ListView) pThis->LV_AddItem(pidl); @@ -1055,6 +1017,10 @@ INT CALLBACK CDefView::fill_list(LPVOID ptr, LPVOID arg) return TRUE; } +/// +// - gets the objectlist from the shellfolder +// - sorts the list +// - fills the list into the view HRESULT CDefView::FillList() { CComPtr<IEnumIDList> pEnumIDList; @@ -1067,7 +1033,7 @@ HRESULT CDefView::FillList() TRACE("%p\n", this); - /* determine if there is a setting to show all the hidden files/folders */ + // determine if there is a setting to show all the hidden files/folders dwValue = 1; cbValue = sizeof(dwValue); SHGetValueW(HKEY_CURRENT_USER, @@ -1090,7 +1056,7 @@ HRESULT CDefView::FillList() m_ListView.SendMessageW(LVM_SETCALLBACKMASK, LVIS_CUT, 0); } - /* get the itemlist from the shfolder */ + // get the itemlist from the shfolder hRes = m_pSFParent->EnumObjects(m_hWnd, dFlags, &pEnumIDList); if (hRes != S_OK) { @@ -1099,14 +1065,12 @@ HRESULT CDefView::FillList() return(hRes); } - /* create a pointer array */ + // create a pointer array hdpa = DPA_Create(16); if (!hdpa) - { return(E_OUTOFMEMORY); - } - /* copy the items into the array*/ + // copy the items into the array while((S_OK == pEnumIDList->Next(1, &pidl, &dwFetched)) && dwFetched) { if (DPA_InsertPtr(hdpa, 0x7fff, pidl) == -1) @@ -1115,7 +1079,7 @@ HRESULT CDefView::FillList() } } - /*turn the listview's redrawing off*/ + // turn listview's redrawing off m_ListView.SetRedraw(FALSE); DPA_DestroyCallback( hdpa, fill_list, this); @@ -1142,7 +1106,7 @@ HRESULT CDefView::FillList() m_viewinfo_data.cbSize = sizeof(m_viewinfo_data); _DoFolderViewCB(SFVM_GET_CUSTOMVIEWINFO, 0, (LPARAM)&m_viewinfo_data); - /*turn the listview's redrawing back on and force it to draw*/ + // turn listview's redrawing back on and force it to draw m_ListView.SetRedraw(TRUE); UpdateListColors(); @@ -1276,9 +1240,6 @@ VOID CDefView::OnFinalMessage(HWND) this->Release(); } -/********************************************************** -* ShellView_OnCreate() -*/ LRESULT CDefView::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) { CComPtr<IDropTarget> pdt; @@ -1289,7 +1250,7 @@ LRESULT CDefView::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl if (SUCCEEDED(QueryInterface(IID_PPV_ARG(IDropTarget, &pdt)))) { if (FAILED(RegisterDragDrop(m_hWnd, pdt))) - ERR("Registering Drag Drop Failed\n"); + ERR("Error Registering DragDrop\n"); } /* register for receiving notifications */ @@ -1323,22 +1284,22 @@ LRESULT CDefView::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl SHCNE_ALLEVENTS, SHV_CHANGE_NOTIFY, 1, ntreg); - /* _DoFolderViewCB(SFVM_GETNOTIFY, ?? ??) */ + //_DoFolderViewCB(SFVM_GETNOTIFY, ?? ??) m_hAccel = LoadAcceleratorsW(shell32_hInstance, MAKEINTRESOURCEW(IDA_SHELLVIEW)); BOOL bPreviousParentSpecial = m_isParentFolderSpecial; - /* A folder is special if it is the Desktop folder, - * a network folder, or a Control Panel folder. */ - m_isParentFolderSpecial = _ILIsDesktop(m_pidlParent) || _ILIsNetHood(m_pidlParent) + // A folder is special if it is the Desktop folder, + // a network folder, or a Control Panel folder + m_isParentFolderSpecial = _ILIsDesktop(m_pidlParent) || _ILIsNetHood(m_pidlParent) || _ILIsControlPanel(ILFindLastID(m_pidlParent)); - /* Only force StatusBar part refresh if the state - * changed from the previous folder. */ + // Only force StatusBar part refresh if the state + // changed from the previous folder if (bPreviousParentSpecial != m_isParentFolderSpecial) { - /* This handles changing StatusBar parts. */ + // This handles changing StatusBar parts _ForceStatusBarResize(); } @@ -1347,9 +1308,7 @@ LRESULT CDefView::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl return S_OK; } -/********************************************************** - * #### Handling of the menus #### - */ +// #### Handling of the menus #### extern "C" DWORD WINAPI SHMenuIndexFromID(HMENU hMenu, UINT uID); @@ -1362,8 +1321,8 @@ HMENU GetSubmenuByID(HMENU hmenu, UINT id) return NULL; } -/* ReallyGetMenuItemID returns the id of an item even if it opens a submenu, - GetMenuItemID returns -1 if the specified item opens a submenu */ +// ReallyGetMenuItemID returns the id of an item even if it opens a submenu, +// GetMenuItemID returns -1 if the specified item opens a submenu UINT ReallyGetMenuItemID(HMENU hmenu, int i) { MENUITEMINFOW mii = {sizeof(mii), MIIM_ID}; @@ -1387,13 +1346,13 @@ HRESULT CDefView::FillFileMenu() DeleteMenu(hFileMenu, i, MF_BYPOSITION); } - /* In case we still have this left over, clean it up! */ + // In case we still have this left over, clean it up if (m_pFileMenu) { IUnknown_SetSite(m_pFileMenu, NULL); m_pFileMenu.Release(); } - /* Store the context menu in m_pFileMenu and keep it in order to invoke the selected command later on */ + // Store context menu in m_pFileMenu and keep it to invoke the selected command later on HRESULT hr = GetItemObject(SVGIO_SELECTION, IID_PPV_ARG(IContextMenu, &m_pFileMenu)); if (FAILED_UNEXPECTEDLY(hr)) return hr; @@ -1482,7 +1441,6 @@ HRESULT CDefView::FillArrangeAsMenu(HMENU hmenuArrange) CheckMenuItem(hmenuArrange, FCIDM_SHVIEW_ALIGNTOGRID, MF_UNCHECKED); } - return S_OK; } @@ -1499,14 +1457,11 @@ HRESULT CDefView::CheckViewMode(HMENU hmenuView) return S_OK; } -/********************************************************** -* ShellView_GetSelections() -* -* - fills the m_apidl list with the selected objects -* -* RETURNS -* number of selected items -*/ +/// +// - fills the m_apidl list with the selected objects +// +// RETURNS +// number of selected items UINT CDefView::GetSelections() { SHFree(m_apidl); @@ -1559,7 +1514,7 @@ HRESULT CDefView::InvokeContextMenuCommand(CComPtr<IContextMenu>& pCM, LPCSTR lp } HRESULT hr = pCM->InvokeCommand((LPCMINVOKECOMMANDINFO)&cmi); - // Most of our callers will do this, but in case they don't do that (File menu!) + // Most of our callers will do this, but if they would forget (File menu!) IUnknown_SetSite(pCM, NULL); pCM.Release(); @@ -1569,9 +1524,6 @@ HRESULT CDefView::InvokeContextMenuCommand(CComPtr<IContextMenu>& pCM, LPCSTR lp return S_OK; } -/********************************************************** - * ShellView_OpenSelectedItems() - */ HRESULT CDefView::OpenSelectedItems() { HMENU hMenu; @@ -1612,9 +1564,6 @@ HRESULT CDefView::OpenSelectedItems() return hResult; } -/********************************************************** - * ShellView_DoContextMenu() - */ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) { POINT pt; @@ -1625,7 +1574,7 @@ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b if (m_hContextMenu != NULL) { - ERR("HACK: Aborting context menu in nested call!\n"); + ERR("HACK: Aborting context menu in nested call\n"); return 0; } @@ -1633,7 +1582,7 @@ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b if (!m_hContextMenu) return E_FAIL; - if (lParam != ~0) // unless app key (menu key) was pressed + if (lParam != ~0) // unless app key (menu key) was pressed { pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam); @@ -1652,18 +1601,18 @@ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b } m_cidl = m_ListView.GetSelectedCount(); - /* In case we still have this left over, clean it up! */ - hResult = GetItemObject( m_cidl ? SVGIO_SELECTION : SVGIO_BACKGROUND, IID_PPV_ARG(IContextMenu, &m_pCM)); + // In case we still have this left over, clean it up + hResult = GetItemObject(m_cidl ? SVGIO_SELECTION : SVGIO_BACKGROUND, IID_PPV_ARG(IContextMenu, &m_pCM)); MenuCleanup _(m_pCM, m_hContextMenu); if (FAILED_UNEXPECTEDLY(hResult)) return 0; - /* Use 1 as the first id as we want 0 the mean that the user canceled the menu */ + // Use 1 as the first id we want. 0 means that user canceled the menu hResult = m_pCM->QueryContextMenu(m_hContextMenu, 0, CONTEXT_MENU_BASE_ID, FCIDM_SHVIEWLAST, CMF_NORMAL); if (FAILED_UNEXPECTEDLY(hResult)) return 0; - /* There is no position requested, so try to find one */ + // There is no position requested, so try to find one if (lParam == ~0) { HWND hFocus = ::GetFocus(); @@ -1671,17 +1620,17 @@ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b if (hFocus == m_ListView.m_hWnd || m_ListView.IsChild(hFocus)) { - /* Is there an item focused and selected? */ + // Is there an item focused and selected? lvIndex = m_ListView.GetNextItem(-1, LVIS_SELECTED|LVIS_FOCUSED); - /* If not, find the first selected item */ + // If not, find the first selected item if (lvIndex < 0) lvIndex = m_ListView.GetNextItem(-1, LVIS_SELECTED); } - /* We got something */ + // We got something if (lvIndex > -1) { - /* Let's find the center of the icon */ + // Find the center of the icon RECT rc = { LVIR_ICON }; m_ListView.SendMessage(LVM_GETITEMRECT, lvIndex, (LPARAM)&rc); pt.x = (rc.right + rc.left) / 2; @@ -1689,14 +1638,14 @@ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b } else { - /* We have to drop it somewhere.. */ + // We have to drop it somewhere pt.x = pt.y = 0; } m_ListView.ClientToScreen(&pt); } - // This runs the message loop, calling back to us with f.e. WM_INITPOPUP (hence why m_hContextMenu and m_pCM exist) + // This runs the message loop, calling back to us with f.e. WM_INITPOPUP (hence why m_hContextMenu and m_pCM exist) uCommand = TrackPopupMenu(m_hContextMenu, TPM_LEFTALIGN | TPM_RETURNCMD | TPM_LEFTBUTTON | TPM_RIGHTBUTTON, pt.x, pt.y, 0, m_hWnd, NULL); @@ -1717,7 +1666,7 @@ LRESULT CDefView::OnExplorerCommand(UINT uCommand, BOOL bUseSelection) HMENU hMenu = NULL; CComPtr<IContextMenu> pCM; - hResult = GetItemObject( bUseSelection ? SVGIO_SELECTION : SVGIO_BACKGROUND, IID_PPV_ARG(IContextMenu, &pCM)); + hResult = GetItemObject(bUseSelection ? SVGIO_SELECTION : SVGIO_BACKGROUND, IID_PPV_ARG(IContextMenu, &pCM)); if (FAILED_UNEXPECTEDLY(hResult)) return 0; @@ -1736,7 +1685,7 @@ LRESULT CDefView::OnExplorerCommand(UINT uCommand, BOOL bUseSelection) if (bUseSelection) { - // FIXME: we should cache this.... + // FIXME: we should cache this SFGAOF rfg = SFGAO_BROWSABLE | SFGAO_CANCOPY | SFGAO_CANLINK | SFGAO_CANMOVE | SFGAO_CANDELETE | SFGAO_CANRENAME | SFGAO_HASPROPSHEET | SFGAO_FILESYSTEM | SFGAO_FOLDER; hResult = m_pSFParent->GetAttributesOf(m_cidl, m_apidl, &rfg); if (FAILED_UNEXPECTEDLY(hResult)) @@ -1759,13 +1708,8 @@ LRESULT CDefView::OnExplorerCommand(UINT uCommand, BOOL bUseSelection) return 0; } -/********************************************************** - * ##### message handling ##### - */ +// ##### message handling ##### -/********************************************************** -* ShellView_OnSize() -*/ LRESULT CDefView::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) { WORD wWidth, wHeight; @@ -1790,12 +1734,7 @@ LRESULT CDefView::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled return 0; } -/********************************************************** -* ShellView_OnDeactivate() -* -* NOTES -* internal -*/ +// internal void CDefView::OnDeactivate() { TRACE("%p\n", this); @@ -1803,7 +1742,6 @@ void CDefView::OnDeactivate() if (m_uState != SVUIA_DEACTIVATE) { // TODO: cleanup menu after deactivation - m_uState = SVUIA_DEACTIVATE; } } @@ -1812,7 +1750,7 @@ void CDefView::DoActivate(UINT uState) { TRACE("%p uState=%x\n", this, uState); - /*don't do anything if the state isn't really changing */ + // don't do anything if the state isn't really changing if (m_uState == uState) { return; @@ -1865,19 +1803,12 @@ void CDefView::_DoCopyToMoveToFolder(BOOL bCopy) InvokeContextMenuCommand(pCM, (bCopy ? "copyto" : "moveto"), NULL); } -/********************************************************** -* ShellView_OnActivate() -*/ LRESULT CDefView::OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) { DoActivate(SVUIA_ACTIVATE_FOCUS); return 0; } -/********************************************************** -* ShellView_OnSetFocus() -* -*/ LRESULT CDefView::OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) { TRACE("%p\n", this); @@ -1898,9 +1829,6 @@ LRESULT CDefView::OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHan return 0; } -/********************************************************** -* ShellView_OnKillFocus() -*/ LRESULT CDefView::OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) { TRACE("(%p) stub\n", this); @@ -1912,12 +1840,7 @@ LRESULT CDefView::OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHa return 0; } -/********************************************************** -* ShellView_OnCommand() -* -* NOTES -* the CmdID's are the ones from the context menu -*/ +// the CmdID's are the ones from the context menu LRESULT CDefView::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) { DWORD dwCmdID; @@ -1938,25 +1861,21 @@ LRESULT CDefView::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHand m_ListView.ModifyStyle(LVS_TYPEMASK, LVS_SMALLICON); CheckToolbar(); break; - case FCIDM_SHVIEW_BIGICON: m_FolderSettings.ViewMode = FVM_ICON; m_ListView.ModifyStyle(LVS_TYPEMASK, LVS_ICON); CheckToolbar(); break; - case FCIDM_SHVIEW_LISTVIEW: m_FolderSettings.ViewMode = FVM_LIST; m_ListView.ModifyStyle(LVS_TYPEMASK, LVS_LIST); CheckToolbar(); break; - case FCIDM_SHVIEW_REPORTVIEW: m_FolderSettings.ViewMode = FVM_DETAILS; m_ListView.ModifyStyle(LVS_TYPEMASK, LVS_REPORT); CheckToolbar(); break; - /* the menu-ID's for sorting are 0x30... see shrec.rc */ case 0x30: case 0x31: @@ -1966,7 +1885,6 @@ LRESULT CDefView::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHand m_sortInfo.bIsAscending = TRUE; _Sort(); break; - case FCIDM_SHVIEW_SNAPTOGRID: m_ListView.Arrange(LVA_SNAPTOGRID); break; @@ -1985,17 +1903,14 @@ LRESULT CDefView::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHand case FCIDM_SHVIEW_SELECTALL: m_ListView.SetItemState(-1, LVIS_SELECTED, LVIS_SELECTED); break; - case FCIDM_SHVIEW_INVERTSELECTION: nCount = m_ListView.GetItemCount(); for (int i=0; i < nCount; i++) m_ListView.SetItemState(i, m_ListView.GetItemState(i, LVIS_SELECTED) ? 0 : LVIS_SELECTED, LVIS_SELECTED); break; - case FCIDM_SHVIEW_REFRESH: Refresh(); break; - case FCIDM_SHVIEW_DELETE: case FCIDM_SHVIEW_CUT: case FCIDM_SHVIEW_COPY: @@ -2003,29 +1918,24 @@ LRESULT CDefView::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHand case FCIDM_SHVIEW_PROPERTIES: if (SHRestricted(REST_NOVIEWCONTEXTMENU)) return 0; - return OnExplorerCommand(dwCmdID, TRUE); - case FCIDM_SHVIEW_COPYTO: case FCIDM_SHVIEW_MOVETO: _DoCopyToMoveToFolder(dwCmdID == FCIDM_SHVIEW_COPYTO); return 0; - case FCIDM_SHVIEW_INSERT: case FCIDM_SHVIEW_UNDO: case FCIDM_SHVIEW_INSERTLINK: case FCIDM_SHVIEW_NEWFOLDER: return OnExplorerCommand(dwCmdID, FALSE); default: - { - /* WM_COMMAND messages from the file menu are routed to the CDefView so as to let m_pFileMenu handle the command */ + // WM_COMMAND messages from file menu are routed to CDefView to let m_pFileMenu handle them if (m_pFileMenu && dwCmd == 0) { HMENU Dummy = NULL; MenuCleanup _(m_pFileMenu, Dummy); InvokeContextMenuCommand(m_pFileMenu, MAKEINTRESOURCEA(dwCmdID), NULL); } - } } return 0; @@ -2051,18 +1961,14 @@ SelectExtOnRename(void) return !!dwValue; } -/********************************************************** -* ShellView_OnNotify() -*/ - LRESULT CDefView::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) { - UINT CtlID; - LPNMHDR lpnmh; - LPNMLISTVIEW lpnmlv; - NMLVDISPINFOW *lpdi; - PCUITEMID_CHILD pidl; - BOOL unused; + UINT CtlID; + LPNMHDR lpnmh; + LPNMLISTVIEW lpnmlv; + NMLVDISPINFOW *lpdi; + PCUITEMID_CHILD pidl; + BOOL unused; CtlID = wParam; lpnmh = (LPNMHDR)lParam; @@ -2077,67 +1983,52 @@ LRESULT CDefView::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl TRACE("-- NM_SETFOCUS %p\n", this); OnSetFocus(0, 0, 0, unused); break; - case NM_KILLFOCUS: TRACE("-- NM_KILLFOCUS %p\n", this); OnDeactivate(); /* Notify the ICommDlgBrowser interface */ OnStateChange(CDBOSC_KILLFOCUS); break; - case NM_CUSTOMDRAW: TRACE("-- NM_CUSTOMDRAW %p\n", this); return CDRF_DODEFAULT; - case NM_RELEASEDCAPTURE: TRACE("-- NM_RELEASEDCAPTURE %p\n", this); break; - case NM_CLICK: TRACE("-- NM_CLICK %p\n", this); break; - case NM_RCLICK: TRACE("-- NM_RCLICK %p\n", this); break; - case NM_DBLCLK: TRACE("-- NM_DBLCLK %p\n", this); OpenSelectedItems(); break; - case NM_RETURN: TRACE("-- NM_RETURN %p\n", this); OpenSelectedItems(); break; - case HDN_ENDTRACKW: TRACE("-- HDN_ENDTRACKW %p\n", this); - /*nColumn1 = m_ListView.GetColumnWidth(0); - nColumn2 = m_ListView.GetColumnWidth(1);*/ + //nColumn1 = m_ListView.GetColumnWidth(0); + //nColumn2 = m_ListView.GetColumnWidth(1); break; - case LVN_DELETEITEM: TRACE("-- LVN_DELETEITEM %p\n", this); - /*delete the pidl because we made a copy of it*/ SHFree(reinterpret_cast<LPVOID>(lpnmlv->lParam)); - break; - case LVN_DELETEALLITEMS: TRACE("-- LVN_DELETEALLITEMS %p\n", this); return FALSE; - case LVN_INSERTITEM: TRACE("-- LVN_INSERTITEM (STUB)%p\n", this); break; - case LVN_ITEMACTIVATE: TRACE("-- LVN_ITEMACTIVATE %p\n", this); - OnStateChange(CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */ + OnStateChange(CDBOSC_SELCHANGE); // browser will get the IDataObject break; - case LVN_COLUMNCLICK: m_sortInfo.nHeaderID = lpnmlv->iSubItem; if (m_sortInfo.nLastHeaderID == m_sortInfo.nHeaderID) @@ -2146,7 +2037,6 @@ LRESULT CDefView::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl m_sortInfo.bIsAscending = TRUE; _Sort(); break; - case LVN_GETDISPINFOA: case LVN_GETDISPINFOW: TRACE("-- LVN_GETDISPINFO %p\n", this); @@ -2188,25 +2078,20 @@ LRESULT CDefView::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl if (SUCCEEDED(m_pSFParent->GetAttributesOf(1, &pidl, &attributes))) { if (attributes & SFGAO_HIDDEN) - { lpdi->item.state |= LVIS_CUT; - } } } lpdi->item.mask |= LVIF_DI_SETITEM; break; - case LVN_ITEMCHANGED: TRACE("-- LVN_ITEMCHANGED %p\n", this); - OnStateChange(CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */ + OnStateChange(CDBOSC_SELCHANGE); // browser will get the IDataObject UpdateStatusbar(); _DoFolderViewCB(SFVM_SELECTIONCHANGED, NULL/* FIXME */, NULL/* FIXME */); break; - case LVN_BEGINDRAG: case LVN_BEGINRDRAG: TRACE("-- LVN_BEGINDRAG\n"); - if (GetSelections()) { CComPtr<IDataObject> pda; @@ -2218,15 +2103,11 @@ LRESULT CDefView::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl LPNMLISTVIEW params = (LPNMLISTVIEW)lParam; if (SUCCEEDED(m_pSFParent->GetAttributesOf(m_cidl, m_apidl, &dwAttributes))) - { dwEffect |= dwAttributes & (SFGAO_CANCOPY | SFGAO_CANLINK); - } CComPtr<IAsyncOperation> piaso; if (SUCCEEDED(pda->QueryInterface(IID_PPV_ARG(IAsyncOperation, &piaso)))) - { piaso->SetAsyncMode(TRUE); - } DWORD dwEffect2; @@ -2243,14 +2124,11 @@ LRESULT CDefView::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl m_ListView.GetItemPosition(params->iItem, &ptItem); ImageList_BeginDrag(big_icons, iIcon, params->ptAction.x - ptItem.x, params->ptAction.y - ptItem.y); - DoDragDrop(pda, this, dwEffect, &dwEffect2); - m_pSourceDataObject.Release(); } } break; - case LVN_BEGINLABELEDITW: { DWORD dwAttr = SFGAO_CANRENAME; @@ -2264,7 +2142,7 @@ LRESULT CDefView::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl HWND hEdit = reinterpret_cast<HWND>(m_ListView.SendMessage(LVM_GETEDITCONTROL)); SHLimitInputEdit(hEdit, m_pSFParent); - /* smartass-renaming: See CORE-15242 */ + // smartass-renaming: See CORE-15242 if (!(dwAttr & SFGAO_FOLDER) && (dwAttr & SFGAO_FILESYSTEM) && (lpdi->item.mask & LVIF_TEXT) && !SelectExtOnRename()) { @@ -2286,14 +2164,11 @@ LRESULT CDefView::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl m_isEditing = TRUE; return FALSE; } - return TRUE; } - case LVN_ENDLABELEDITW: { TRACE("-- LVN_ENDLABELEDITW %p\n", this); - m_isEditing = FALSE; if (lpdi->item.pszText) @@ -2320,7 +2195,6 @@ LRESULT CDefView::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl return FALSE; } - default: TRACE("-- %p WM_COMMAND %x unhandled\n", this, lpnmh->code); break; @@ -2329,12 +2203,10 @@ LRESULT CDefView::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl return 0; } -/* - * This is just a quick hack to make the desktop work correctly. - * ITranslateShellChangeNotify's IsChildID is undocumented, but most likely the way that - * a folder should know if it should update upon a change notification. - * It is exported by merged folders at a minimum. - */ +// This is just a quick hack to make the desktop work correctly. +// ITranslateShellChangeNotify's IsChildID is undocumented, but most likely the +// way that a folder should know if it should update upon a change notification. +// It is exported by merged folders at a minimum. static BOOL ILIsParentOrSpecialParent(PCIDLIST_ABSOLUTE pidl1, PCIDLIST_ABSOLUTE pidl2) { if (!pidl1 || !pidl2) @@ -2378,12 +2250,9 @@ static BOOL ILIsParentOrSpecialParent(PCIDLIST_ABSOLUTE pidl1, PCIDLIST_ABSOLUTE return FALSE; } -/********************************************************** -* ShellView_OnChange() -*/ LRESULT CDefView::OnChangeNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) { - // The change notify can come before WM_CREATE. + // The change notify can come before WM_CREATE if (!m_ListView) return FALSE; @@ -2411,22 +2280,16 @@ LRESULT CDefView::OnChangeNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & if (bParent0) { if (LV_FindItemByPidl(ILFindLastID(Pidls[0])) == -1) - { LV_AddItem(ILFindLastID(Pidls[0])); - } else - { LV_ProdItem(ILFindLastID(Pidls[0])); - } } break; - case SHCNE_RMDIR: case SHCNE_DELETE: if (bParent0) LV_DeleteItem(ILFindLastID(Pidls[0])); break; - case SHCNE_RENAMEFOLDER: case SHCNE_RENAMEITEM: if (bParent0 && bParent1) @@ -2436,12 +2299,10 @@ LRESULT CDefView::OnChangeNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & else if (bParent1) LV_AddItem(ILFindLastID(Pidls[1])); break; - case SHCNE_UPDATEITEM: if (bParent0) LV_RenameItem(ILFindLastID(Pidls[0]), ILFindLastID(Pidls[0])); break; - case SHCNE_UPDATEDIR: Refresh(); break; @@ -2454,20 +2315,17 @@ LRESULT CDefView::OnChangeNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & HRESULT SHGetMenuIdFromMenuMsg(UINT uMsg, LPARAM lParam, UINT *CmdId); HRESULT SHSetMenuIdInMenuMsg(UINT uMsg, LPARAM lParam, UINT CmdId); -/********************************************************** -* CDefView::OnCustomItem -*/ LRESULT CDefView::OnCustomItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) { if (!m_pCM) { /* no menu */ - ERR("no context menu!!!\n"); + ERR("no context menu\n"); return FALSE; } - /* The lParam of WM_DRAWITEM WM_MEASUREITEM contain a menu id and this also needs to - be changed to a menu identifier offset */ + // lParam of WM_DRAWITEM WM_MEASUREITEM contains a menu id and + // this also needs to be changed to a menu identifier offset UINT CmdID; HRESULT hres = SHGetMenuIdFromMenuMsg(uMsg, lParam, &CmdID); if (SUCCEEDED(hres)) @@ -2489,9 +2347,6 @@ LRESULT CDefView::OnSettingChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL return S_OK; } -/********************************************************** -* CDefView::OnInitMenuPopup -*/ LRESULT CDefView::OnInitMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) { HMENU hmenu = (HMENU) wParam; @@ -2499,9 +2354,7 @@ LRESULT CDefView::OnInitMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL UINT menuItemId; if (m_pCM) - { OnCustomItem(uMsg, wParam, lParam, bHandled); - } HMENU hViewMenu = GetSubmenuByID(m_hMenu, FCIDM_MENU_VIEW); @@ -2552,18 +2405,9 @@ LRESULT CDefView::OnInitMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL return FALSE; } -/********************************************************** -* -* -* The INTERFACE of the IShellView object -* -* -********************************************************** -*/ -/********************************************************** -* ShellView_GetWindow -*/ +// The INTERFACE of the IShellView object + HRESULT WINAPI CDefView::GetWindow(HWND *phWnd) { TRACE("(%p)\n", this); @@ -2580,12 +2424,7 @@ HRESULT WINAPI CDefView::ContextSensitiveHelp(BOOL fEnterMode) return E_NOTIMPL; } -/********************************************************** -* IShellView_TranslateAccelerator -* -* FIXME: -* use the accel functions -*/ +// FIXME: use the accel functions HRESULT WINAPI CDefView::TranslateAccelerator(LPMSG lpmsg) { if (m_isEditing) @@ -2596,7 +2435,7 @@ HRESULT WINAPI CDefView::TranslateAccelerator(LPMSG lpmsg) if (::TranslateAcceleratorW(m_hWnd, m_hAccel, lpmsg) != 0) return S_OK; - TRACE("-- key=0x%04lx\n", lpmsg->wParam) ; + TRACE("-- key=0x%04lx\n", lpmsg->wParam); } return m_pShellBrowser->TranslateAcceleratorSB(lpmsg, 0); @@ -2604,30 +2443,27 @@ HRESULT WINAPI CDefView::TranslateAccelerator(LPMSG lpmsg) HRESULT WINAPI CDefView::EnableModeless(BOOL fEnable) { - FIXME("(%p) stub\n", this); - + FIXME("(%p)\n", this); return E_NOTIMPL; } HRESULT WINAPI CDefView::UIActivate(UINT uState) { - TRACE("(%p)->(state=%x) stub\n", this, uState); + TRACE("(%p)->(state=%x)\n", this, uState); - /* don't do anything if the state isn't really changing */ + // don't do anything if the state isn't changing if (m_uState == uState) - { return S_OK; - } - /* OnActivate handles the menu merging and internal state */ + // OnActivate handles the menu merging and internal state DoActivate(uState); - /* only do This if we are active */ + // only do this if we are active if (uState != SVUIA_DEACTIVATE) { _ForceStatusBarResize(); - /* Set the text for the status bar */ + // Set the text for the status bar UpdateStatusbar(); } @@ -2661,7 +2497,7 @@ HRESULT WINAPI CDefView::DestroyViewWindow() if (m_hAccel) { - // "Accelerator tables loaded from resources are freed automatically when the application terminates." -- MSDN + // MSDN: Accelerator tables loaded from resources are freed automatically when application terminates m_hAccel = NULL; } @@ -2815,7 +2651,6 @@ HRESULT WINAPI CDefView::GetItemObject(UINT uItem, REFIID riid, LPVOID *ppvOut) hr = m_pShellFolderViewDual->QueryInterface(riid, ppvOut); } break; - case SVGIO_SELECTION: GetSelections(); hr = m_pSFParent->GetUIObjectOf(m_hWnd, m_cidl, m_apidl, riid, 0, ppvOut); @@ -3050,9 +2885,8 @@ HRESULT STDMETHODCALLTYPE CDefView::SelectAndPositionItems(UINT cidl, PCUITEMID_ return S_OK; } -/********************************************************** - * IShellView2 implementation - */ + +// IShellView2 implementation HRESULT STDMETHODCALLTYPE CDefView::GetView(SHELLVIEWID *view_guid, ULONG view_type) { @@ -3159,9 +2993,8 @@ HRESULT STDMETHODCALLTYPE CDefView::SelectAndPositionItem(LPCITEMIDLIST item, UI return E_NOTIMPL; } -/********************************************************** - * IShellFolderView implementation - */ +// IShellFolderView implementation + HRESULT STDMETHODCALLTYPE CDefView::Rearrange(LPARAM sort) { FIXME("(%p)->(%ld) stub\n", this, sort); @@ -3378,9 +3211,6 @@ HRESULT STDMETHODCALLTYPE CDefView::SetAutomationObject(IDispatch *disp) return E_NOTIMPL; } -/********************************************************** - * ISVOleCmdTarget_QueryStatus (IOleCommandTarget) - */ HRESULT WINAPI CDefView::QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD *prgCmds, OLECMDTEXT *pCmdText) { FIXME("(%p)->(%p(%s) 0x%08x %p %p\n", @@ -3398,11 +3228,10 @@ HRESULT WINAPI CDefView::QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLE return OLECMDERR_E_UNKNOWNGROUP; } -/********************************************************** - * ISVOleCmdTarget_Exec (IOleCommandTarget) - * - * nCmdID is the OLECMDID_* enumeration - */ +/// +// ISVOleCmdTarget_Exec(IOleCommandTarget) +// +// nCmdID is the OLECMDID_* enumeration HRESULT WINAPI CDefView::Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) { FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08x Opt:0x%08x %p %p)\n", @@ -3424,7 +3253,7 @@ HRESULT WINAPI CDefView::Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCm if (m_hMenuViewModes) { - /* Duplicate all but the last two items of the view modes menu */ + // Duplicate all but the last two items of the view modes menu HMENU hmenuViewPopup = CreatePopupMenu(); Shell_MergeMenus(hmenuViewPopup, m_hMenuViewModes, 0, 0, 0xFFFF, 0); DeleteMenu(hmenuViewPopup, GetMenuItemCount(hmenuViewPopup) - 1, MF_BYPOSITION); @@ -3477,8 +3306,8 @@ HRESULT CDefView::drag_notify_subitem(DWORD grfKeyState, POINTL pt, DWORD *pdwEf to remember the last key state when the button was pressed */ m_grfKeyState = grfKeyState; - /* Map from global to client coordinates and query the index of the listview-item, which is - * currently under the mouse cursor. */ + // Map from global to client coordinates and query the index of the + // listview-item, which is currently under the mouse cursor. LVHITTESTINFO htinfo = {{pt.x, pt.y}, LVHT_ONITEM}; ScreenToClient(&htinfo.pt); lResult = m_ListView.HitTest(&htinfo); @@ -3487,9 +3316,9 @@ HRESULT CDefView::drag_notify_subitem(DWORD grfKeyState, POINTL pt, DWORD *pdwEf ::GetClientRect(m_ListView, &clientRect); if (htinfo.pt.x == m_ptLastMousePos.x && htinfo.pt.y == m_ptLastMousePos.y && (htinfo.pt.x < SCROLLAREAWIDTH || htinfo.pt.x > clientRect.right - SCROLLAREAWIDTH || - htinfo.pt.y < SCROLLAREAWIDTH || htinfo.pt.y > clientRect.bottom - SCROLLAREAWIDTH )) + htinfo.pt.y < SCROLLAREAWIDTH || htinfo.pt.y > clientRect.bottom - SCROLLAREAWIDTH)) { - m_cScrollDelay = (m_cScrollDelay + 1) % 5; /* DragOver is called every 50 ms */ + m_cScrollDelay = (m_cScrollDelay + 1) % 5; // DragOver is called every 50 ms if (m_cScrollDelay == 0) { /* Mouse did hover another 250 ms over the scroll-area */ @@ -3508,7 +3337,7 @@ HRESULT CDefView::drag_notify_subitem(DWORD grfKeyState, POINTL pt, DWORD *pdwEf } else { - m_cScrollDelay = 0; /* Reset, if the cursor is not over the listview's scroll-area */ + m_cScrollDelay = 0; // Reset, if cursor is not over the listview's scroll-area } m_ptLastMousePos = htinfo.pt; @@ -3530,11 +3359,11 @@ HRESULT CDefView::drag_notify_subitem(DWORD grfKeyState, POINTL pt, DWORD *pdwEf } } - /* If we are still over the previous sub-item, notify it via DragOver and return. */ + // If we are still over the previous sub-item, notify it via DragOver and return if (m_pCurDropTarget && lResult == m_iDragOverItem) return m_pCurDropTarget->DragOver(grfKeyState, pt, pdwEffect); - /* We've left the previous sub-item, notify it via DragLeave and Release it. */ + // We've left the previous sub-item, notify it via DragLeave and release it if (m_pCurDropTarget) { PCUITEMID_CHILD pidl = _PidlByItem(m_iDragOverItem); @@ -3549,23 +3378,23 @@ HRESULT CDefView::drag_notify_subitem(DWORD grfKeyState, POINTL pt, DWORD *pdwEf if (lResult == -1) { - /* We are not above one of the listview's subitems. Bind to the parent folder's - * DropTarget interface. */ + // We are not above one of the listview's subitems. Bind to the + // parent folder's DropTarget interface. hr = m_pSFParent->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget,&m_pCurDropTarget)); } else { - /* Query the relative PIDL of the shellfolder object represented by the currently - * dragged over listview-item ... */ + // Query the relative PIDL of the shellfolder object represented + // by the currently dragged over listview-item ... PCUITEMID_CHILD pidl = _PidlByItem(lResult); - /* ... and bind m_pCurDropTarget to the IDropTarget interface of an UIObject of this object */ + // ... and bind m_pCurDropTarget to the IDropTarget interface of an UIObject of this object hr = m_pSFParent->GetUIObjectOf(m_ListView, 1, &pidl, IID_NULL_PPV_ARG(IDropTarget, &m_pCurDropTarget)); } IUnknown_SetSite(m_pCurDropTarget, (IShellView *)this); - /* If anything failed, m_pCurDropTarget should be NULL now, which ought to be a save state. */ + // If anything failed, m_pCurDropTarget should be NULL now, which ought to be a save state if (FAILED(hr)) { *pdwEffect = DROPEFFECT_NONE; @@ -3577,7 +3406,7 @@ HRESULT CDefView::drag_notify_subitem(DWORD grfKeyState, POINTL pt, DWORD *pdwEf SelectItem(m_iDragOverItem, SVSI_SELECT); } - /* Notify the item just entered via DragEnter. */ + // Notify the item just entered via DragEnter return m_pCurDropTarget->DragEnter(m_pCurDataObject, grfKeyState, pt, pdwEffect); } @@ -3636,7 +3465,7 @@ INT CDefView::_FindInsertableIndexFromPoint(POINT pt) INT dx, dy; BOOL bSmall = ((m_ListView.GetStyle() & LVS_TYPEMASK) != LVS_ICON); - /* FIXME: LVM_GETORIGIN is broken. See CORE-17266 */ + // FIXME: LVM_GETORIGIN is broken. See CORE-17266 pt.x += m_ListView.GetScrollPos(SB_HORZ); pt.y += m_ListView.GetScrollPos(SB_VERT); @@ -3713,28 +3542,28 @@ void CDefView::_HandleStatusBarResize(int nWidth) const int nLocationPartLength = 150; const int nRightPartsLength = nFileSizePartLength + nLocationPartLength; int nObjectsPartLength = nWidth - nRightPartsLength; - - /* If the window is small enough just divide each part into thirds - * This is the behavior of Windows Server 2003. */ + + // If the window is small enough just divide each part into thirds + // to match the behavior of Windows Server 2003 if (nObjectsPartLength <= nLocationPartLength) nObjectsPartLength = nFileSizePartLength = nWidth / 3; int nPartArray[] = {nObjectsPartLength, nObjectsPartLength + nFileSizePartLength, -1}; - + m_pShellBrowser->SendControlMsg(FCW_STATUS, SB_SETPARTS, _countof(nPartArray), (LPARAM)nPartArray, &lResult); } void CDefView::_ForceStatusBarResize() { - /* Get the handle for the status bar */ + // Get the handle for the status bar HWND fStatusBar; m_pShellBrowser->GetControlWindow(FCW_STATUS, &fStatusBar); - /* Get the size of our status bar */ + // Get the size of our status bar RECT statusBarSize; ::GetWindowRect(fStatusBar, &statusBarSize); - /* Resize the status bar */ + // Resize the status bar _HandleStatusBarResize(statusBarSize.right - statusBarSize.left); } @@ -3864,10 +3693,6 @@ HRESULT WINAPI CDefView::Drop(IDataObject* pDataObject, DWORD grfKeyState, POINT return S_OK; } -/********************************************************** - * ISVDropSource implementation - */ - HRESULT WINAPI CDefView::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) { TRACE("(%p)\n", this); @@ -3887,35 +3712,27 @@ HRESULT WINAPI CDefView::GiveFeedback(DWORD dwEffect) return DRAGDROP_S_USEDEFAULTCURSORS; } -/********************************************************** - * ISVViewObject implementation - */ - HRESULT WINAPI CDefView::Draw(DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds, BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue) { FIXME("Stub: this=%p\n", this); - return E_NOTIMPL; } HRESULT WINAPI CDefView::GetColorSet(DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDevice, LOGPALETTE **ppColorSet) { FIXME("Stub: this=%p\n", this); - return E_NOTIMPL; } HRESULT WINAPI CDefView::Freeze(DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze) { FIXME("Stub: this=%p\n", this); - return E_NOTIMPL; } HRESULT WINAPI CDefView::Unfreeze(DWORD dwFreeze) { FIXME("Stub: this=%p\n", this); - return E_NOTIMPL; } @@ -3923,7 +3740,7 @@ HRESULT WINAPI CDefView::SetAdvise(DWORD aspects, DWORD advf, IAdviseSink *pAdvS { FIXME("partial stub: %p 0x%08x 0x%08x %p\n", this, aspects, advf, pAdvSink); - /* FIXME: we set the AdviseSink, but never use it to send any advice */ + // FIXME: we set the AdviseSink, but never use it to send any advice m_pAdvSink = pAdvSink; m_dwAspects = aspects; m_dwAdvf = advf; @@ -4005,8 +3822,8 @@ HRESULT CDefView_CreateInstance(IShellFolder *pFolder, REFIID riid, LPVOID * ppv } HRESULT WINAPI SHCreateShellFolderViewEx( - LPCSFV psvcbi, /* [in] shelltemplate struct */ - IShellView **ppsv) /* [out] IShellView pointer */ + LPCSFV psvcbi, // [in] shelltemplate struct + IShellView **ppsv) // [out] IShellView pointer { CComPtr<IShellView> psv; HRESULT hRes; @@ -4025,7 +3842,7 @@ HRESULT WINAPI SHCreateShellFolderViewEx( } HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *pcsfv, - IShellView **ppsv) + IShellView **ppsv) { CComPtr<IShellView> psv; HRESULT hRes; diff --git a/dll/win32/shell32/CDefaultContextMenu.cpp b/dll/win32/shell32/CDefaultContextMenu.cpp index 72913f36918..4d0f34a47d4 100644 --- a/dll/win32/shell32/CDefaultContextMenu.cpp +++ b/dll/win32/shell32/CDefaultContextMenu.cpp @@ -1193,7 +1193,7 @@ CDefaultContextMenu::TryToBrowse( hr = SHILCombine(m_pidlFolder, pidlChild, &pidl); if (FAILED_UNEXPECTEDLY(hr)) return hr; - + hr = psb->BrowseObject(pidl, wFlags & ~SBSP_RELATIVE); ILFree(pidl); return hr; diff --git a/dll/win32/shell32/COpenWithMenu.cpp b/dll/win32/shell32/COpenWithMenu.cpp index 759f6c41436..feb30a3a091 100644 --- a/dll/win32/shell32/COpenWithMenu.cpp +++ b/dll/win32/shell32/COpenWithMenu.cpp @@ -716,7 +716,7 @@ BOOL COpenWithList::SetDefaultHandler(SApp *pApp, LPCWSTR pwszFilename) /* Create file extension key */ if (RegCreateKeyExW(HKEY_CLASSES_ROOT, pwszExt, 0, NULL, 0, KEY_READ|KEY_WRITE, NULL, &hKey, NULL) != ERROR_SUCCESS) { - ERR("Cannot open ext key\n"); + ERR("Can't open ext key\n"); return FALSE; } @@ -870,7 +870,7 @@ BOOL COpenWithDialog::IsNoOpen(HWND hwnd) return TRUE; else if (dReturnValue == -1) { - ERR("IsNoOpen failed to load the dialog box.\n"); + ERR("IsNoOpen failed to load dialog box\n"); return TRUE; } } diff --git a/dll/win32/shell32/CShellLink.cpp b/dll/win32/shell32/CShellLink.cpp index bdd1b617082..aa1fbfbaba5 100644 --- a/dll/win32/shell32/CShellLink.cpp +++ b/dll/win32/shell32/CShellLink.cpp @@ -2572,7 +2572,7 @@ HRESULT STDMETHODCALLTYPE CShellLink::InvokeCommand(LPCMINVOKECOMMANDINFO lpici) HRESULT hr = Resolve(lpici->hwnd, 0); if (FAILED(hr)) { - TRACE("failed to resolve component with error 0x%08x\n", hr); + TRACE("failed to resolve component error 0x%08x\n", hr); return hr; } diff --git a/dll/win32/shell32/dialogs/folder_options.cpp b/dll/win32/shell32/dialogs/folder_options.cpp index bad8fc484c8..ea0e4ed4b4b 100644 --- a/dll/win32/shell32/dialogs/folder_options.cpp +++ b/dll/win32/shell32/dialogs/folder_options.cpp @@ -283,7 +283,7 @@ Options_RunDLLCommon(HWND hWnd, HINSTANCE hInst, int fOptions, DWORD nCmdShow) case 1: // show taskbar options dialog - FIXME("notify explorer to show taskbar options dialog\n"); + FIXME("notify explorer to show taskbar options dlg\n"); //PostMessage(GetShellWindow(), WM_USER+22, fOptions, 0); break; diff --git a/dll/win32/shell32/droptargets/CFSDropTarget.cpp b/dll/win32/shell32/droptargets/CFSDropTarget.cpp index f480ffa9808..4d9e506f870 100644 --- a/dll/win32/shell32/droptargets/CFSDropTarget.cpp +++ b/dll/win32/shell32/droptargets/CFSDropTarget.cpp @@ -491,7 +491,7 @@ HRESULT CFSDropTarget::_DoDrop(IDataObject *pDataObject, if (SUCCEEDED(pDataObject->QueryGetData(&fmt))) { hr = pDataObject->GetData(&fmt, &medium); - TRACE("CFSTR_SHELLIDLIST.\n"); + TRACE("CFSTR_SHELLIDLIST\n"); if (FAILED(hr)) { ERR("CFSTR_SHELLIDLIST failed\n"); @@ -721,7 +721,7 @@ HRESULT CFSDropTarget::_DoDrop(IDataObject *pDataObject, } else { - ERR("No viable drop format.\n"); + ERR("No viable drop format\n"); hr = E_FAIL; } return hr; diff --git a/dll/win32/shell32/folders/CControlPanelFolder.cpp b/dll/win32/shell32/folders/CControlPanelFolder.cpp index 085b074ee18..7306862f966 100644 --- a/dll/win32/shell32/folders/CControlPanelFolder.cpp +++ b/dll/win32/shell32/folders/CControlPanelFolder.cpp @@ -411,7 +411,7 @@ HRESULT WINAPI CControlPanelFolder::GetAttributesOf(UINT cidl, PCUITEMID_CHILD_A else if (_ILIsSpecialFolder(*apidl)) m_regFolder->GetAttributesOf(1, apidl, rgfInOut); else - ERR("Got an unknown pidl here!\n"); + ERR("Got unknown pidl\n"); apidl++; cidl--; } @@ -448,7 +448,6 @@ HRESULT WINAPI CControlPanelFolder::GetUIObjectOf(HWND hwndOwner, *ppvOut = NULL; if (IsEqualIID(riid, IID_IContextMenu) && (cidl >= 1)) { - /* HACK: We should use callbacks from CDefaultContextMenu instead of creating one on our own */ BOOL bHasCpl = FALSE; for (UINT i = 0; i < cidl; i++) diff --git a/dll/win32/shell32/folders/CDrivesFolder.cpp b/dll/win32/shell32/folders/CDrivesFolder.cpp index 2293884e9ea..cf76b47392d 100644 --- a/dll/win32/shell32/folders/CDrivesFolder.cpp +++ b/dll/win32/shell32/folders/CDrivesFolder.cpp @@ -24,7 +24,7 @@ #include <precomp.h> #include <process.h> -WINE_DEFAULT_DEBUG_CHANNEL (shell); +WINE_DEFAULT_DEBUG_CHANNEL(shell); /* CDrivesFolder should create a CRegFolder to represent the virtual items that exist only in @@ -599,7 +599,7 @@ CDrivesFolder::CDrivesFolder() CDrivesFolder::~CDrivesFolder() { - TRACE ("-- destroying IShellFolder(%p)\n", this); + TRACE("-- destroying IShellFolder(%p)\n", this); SHFree(pidlRoot); } @@ -680,13 +680,13 @@ HRESULT WINAPI CDrivesFolder::ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLEST else if (_ILIsSpecialFolder(pidlTemp)) m_regFolder->GetAttributesOf(1, &pidlTemp, pdwAttributes); else - ERR("Got an unknown pidl here!\n"); + ERR("Got unknown pidl\n"); } } *ppidl = pidlTemp; - TRACE ("(%p)->(-- ret=0x%08x)\n", this, hr); + TRACE("(%p)->(-- ret=0x%08x)\n", this, hr); return hr; } @@ -867,7 +867,7 @@ HRESULT WINAPI CDrivesFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVO SFV_CREATE sfvparams = {sizeof(SFV_CREATE), this}; hr = SHCreateShellFolderView(&sfvparams, (IShellView**)ppvOut); } - TRACE ("-- (%p)->(interface=%p)\n", this, ppvOut); + TRACE("-- (%p)->(interface=%p)\n", this, ppvOut); return hr; } @@ -876,8 +876,8 @@ HRESULT WINAPI CDrivesFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVO */ HRESULT WINAPI CDrivesFolder::GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD * rgfInOut) { - TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n", - this, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0); + TRACE("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n", + this, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0); if (cidl && !apidl) return E_INVALIDARG; @@ -911,7 +911,7 @@ HRESULT WINAPI CDrivesFolder::GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY a /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */ *rgfInOut &= ~SFGAO_VALIDATE; - TRACE ("-- result=0x%08x\n", *rgfInOut); + TRACE("-- result=0x%08x\n", *rgfInOut); return S_OK; } @@ -951,8 +951,8 @@ HRESULT WINAPI CDrivesFolder::GetUIObjectOf(HWND hwndOwner, } else if (IsEqualIID (riid, IID_IDataObject) && (cidl >= 1)) { - hr = IDataObject_Constructor (hwndOwner, - pidlRoot, apidl, cidl, TRUE, (IDataObject **)&pObj); + hr = IDataObject_Constructor(hwndOwner, + pidlRoot, apidl, cidl, TRUE, (IDataObject **)&pObj); } else if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid, IID_IExtractIconW)) && (cidl == 1)) { @@ -977,7 +977,7 @@ HRESULT WINAPI CDrivesFolder::GetUIObjectOf(HWND hwndOwner, hr = E_OUTOFMEMORY; *ppvOut = pObj; - TRACE ("(%p)->hr=0x%08x\n", this, hr); + TRACE("(%p)->hr=0x%08x\n", this, hr); return hr; } @@ -989,7 +989,7 @@ HRESULT WINAPI CDrivesFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFla LPWSTR pszPath; HRESULT hr = S_OK; - TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", this, pidl, dwFlags, strRet); + TRACE("(%p)->(pidl=%p,0x%08x,%p)\n", this, pidl, dwFlags, strRet); pdump (pidl); if (!strRet) @@ -1029,9 +1029,9 @@ HRESULT WINAPI CDrivesFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFla DWORD dwVolumeSerialNumber, dwMaximumComponentLength, dwFileSystemFlags; GetVolumeInformationW(wszDrive, pszPath, - MAX_PATH - 7, - &dwVolumeSerialNumber, - &dwMaximumComponentLength, &dwFileSystemFlags, NULL, 0); + MAX_PATH - 7, + &dwVolumeSerialNumber, + &dwMaximumComponentLength, &dwFileSystemFlags, NULL, 0); pszPath[MAX_PATH-1] = L'\0'; if (!wcslen(pszPath)) @@ -1062,10 +1062,10 @@ HRESULT WINAPI CDrivesFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFla } } } - wcscat (pszPath, L" ("); + wcscat(pszPath, L" ("); wszDrive[2] = L'\0'; - wcscat (pszPath, wszDrive); - wcscat (pszPath, L")"); + wcscat(pszPath, wszDrive); + wcscat(pszPath, L")"); } if (SUCCEEDED(hr)) @@ -1111,19 +1111,19 @@ HRESULT WINAPI CDrivesFolder::SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, HRESULT WINAPI CDrivesFolder::GetDefaultSearchGUID(GUID * pguid) { - FIXME ("(%p)\n", this); + FIXME("(%p)\n", this); return E_NOTIMPL; } HRESULT WINAPI CDrivesFolder::EnumSearches(IEnumExtraSearch ** ppenum) { - FIXME ("(%p)\n", this); + FIXME("(%p)\n", this); return E_NOTIMPL; } HRESULT WINAPI CDrivesFolder::GetDefaultColumn (DWORD dwRes, ULONG *pSort, ULONG *pDisplay) { - TRACE ("(%p)\n", this); + TRACE("(%p)\n", this); if (pSort) *pSort = 0; @@ -1134,7 +1134,7 @@ HRESULT WINAPI CDrivesFolder::GetDefaultColumn (DWORD dwRes, ULONG *pSort, ULONG HRESULT WINAPI CDrivesFolder::GetDefaultColumnState(UINT iColumn, DWORD * pcsFlags) { - TRACE ("(%p)\n", this); + TRACE("(%p)\n", this); if (!pcsFlags || iColumn >= _countof(MyComputerSFHeader)) return E_INVALIDARG; @@ -1144,7 +1144,7 @@ HRESULT WINAPI CDrivesFolder::GetDefaultColumnState(UINT iColumn, DWORD * pcsFla HRESULT WINAPI CDrivesFolder::GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID * pscid, VARIANT * pv) { - FIXME ("(%p)\n", this); + FIXME("(%p)\n", this); return E_NOTIMPL; } @@ -1152,7 +1152,7 @@ HRESULT WINAPI CDrivesFolder::GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn, S { HRESULT hr; - TRACE ("(%p)->(%p %i %p)\n", this, pidl, iColumn, psd); + TRACE("(%p)->(%p %i %p)\n", this, pidl, iColumn, psd); if (!psd || iColumn >= _countof(MyComputerSFHeader)) return E_INVALIDARG; @@ -1232,7 +1232,7 @@ HRESULT WINAPI CDrivesFolder::MapColumnToSCID(UINT column, SHCOLUMNID * pscid) */ HRESULT WINAPI CDrivesFolder::GetClassID(CLSID *lpClassId) { - TRACE ("(%p)\n", this); + TRACE("(%p)\n", this); if (!lpClassId) return E_POINTER; diff --git a/dll/win32/shell32/folders/CRegFolder.cpp b/dll/win32/shell32/folders/CRegFolder.cpp index 5b2d513569b..6c5c3f7f3cb 100644 --- a/dll/win32/shell32/folders/CRegFolder.cpp +++ b/dll/win32/shell32/folders/CRegFolder.cpp @@ -513,7 +513,7 @@ HRESULT WINAPI CRegFolder::GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apid if (_ILIsSpecialFolder(*apidl)) GetGuidItemAttributes(*apidl, rgfInOut); else - ERR("Got an unknown pidl here!\n"); + ERR("Got unknown pidl\n"); apidl++; cidl--; } diff --git a/dll/win32/shell32/shellmenu/CStartMenu.cpp b/dll/win32/shell32/shellmenu/CStartMenu.cpp index 85d61e9f3f7..311b6516124 100644 --- a/dll/win32/shell32/shellmenu/CStartMenu.cpp +++ b/dll/win32/shell32/shellmenu/CStartMenu.cpp @@ -533,7 +533,7 @@ RSHELL_CStartMenu_CreateInstance(REFIID riid, void **ppv) hr = SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAMS, &pidlProgramsAbsolute); if (FAILED_UNEXPECTEDLY(hr)) { - WARN("USER Programs folder not found.\n"); + WARN("USER Programs folder not found\n"); hr = SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_PROGRAMS, &pidlProgramsAbsolute); if (FAILED_UNEXPECTEDLY(hr)) return hr; diff --git a/dll/win32/shell32/shlfolder.cpp b/dll/win32/shell32/shlfolder.cpp index 92dff6c81ef..d4146506038 100644 --- a/dll/win32/shell32/shlfolder.cpp +++ b/dll/win32/shell32/shlfolder.cpp @@ -26,7 +26,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); - /*************************************************************************** * GetNextElement (internal function) * @@ -424,8 +423,6 @@ SHOpenFolderAndSelectItems(PCIDLIST_ABSOLUTE pidlFolder, return E_FAIL; } - - static DWORD WINAPI _ShowPropertiesDialogThread(LPVOID lpParameter)
10 months, 1 week
1
0
0
0
[reactos] 01/01: [SETUPLIB] Make the settings' Process* functions take an actual value instead of a GENERIC_LIST
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b02dd8eb22764267d2645…
commit b02dd8eb22764267d2645a0ed5823029cf7892c4 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Thu Feb 15 23:10:55 2024 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Feb 18 16:30:46 2024 +0100 [SETUPLIB] Make the settings' Process* functions take an actual value instead of a GENERIC_LIST The reason is to avoid enforcing the usage of a specific list container by the users of the setup library. This is a departure of what I originally thought would be the best, in commits 92692eae3 (r74553), 8f2c4f7a6 (r75700) This should actually make some parts of the GUI setup code simpler (e.g. using the win32 comboboxes to store the list contents). --- base/setup/lib/install.c | 10 +++++++- base/setup/lib/settings.c | 65 +++++++++++++---------------------------------- base/setup/lib/settings.h | 20 ++++++++------- base/setup/lib/setuplib.c | 50 +++++++++++++++++++++++------------- base/setup/lib/setuplib.h | 7 +++++ 5 files changed, 77 insertions(+), 75 deletions(-) diff --git a/base/setup/lib/install.c b/base/setup/lib/install.c index 46a36d2fa08..72f3ea92181 100644 --- a/base/setup/lib/install.c +++ b/base/setup/lib/install.c @@ -538,8 +538,16 @@ PrepareCopyInfFile( } /* Add specific files depending of computer type */ - if (!ProcessComputerFiles(InfFile, pSetupData->ComputerList, &AdditionalSectionName)) + { + PGENERIC_LIST_ENTRY Entry; + Entry = GetCurrentListEntry(pSetupData->ComputerList); + ASSERT(Entry); + pSetupData->ComputerType = ((PGENENTRY)GetListEntryData(Entry))->Id; + ASSERT(pSetupData->ComputerType); + + if (!ProcessComputerFiles(InfFile, pSetupData->ComputerType, &AdditionalSectionName)) return FALSE; + } if (AdditionalSectionName && !AddSectionToCopyQueue(pSetupData, InfFile, diff --git a/base/setup/lib/settings.c b/base/setup/lib/settings.c index 09d3c240fb4..44f3c97368f 100644 --- a/base/setup/lib/settings.c +++ b/base/setup/lib/settings.c @@ -785,33 +785,29 @@ CreateDisplayDriverList( BOOLEAN ProcessComputerFiles( - IN HINF InfFile, - IN PGENERIC_LIST List, - OUT PWSTR* AdditionalSectionName) + _In_ HINF InfFile, + _In_ PCWSTR ComputerType, + _Out_ PWSTR* AdditionalSectionName) { - PGENERIC_LIST_ENTRY Entry; static WCHAR SectionName[128]; - DPRINT("ProcessComputerFiles() called\n"); + DPRINT("ProcessComputerFiles(%S) called\n", ComputerType); - Entry = GetCurrentListEntry(List); - if (Entry == NULL) - return FALSE; - - RtlStringCchPrintfW(SectionName, ARRAYSIZE(SectionName), - L"Files.%s", ((PGENENTRY)GetListEntryData(Entry))->Id); + RtlStringCchPrintfW(SectionName, _countof(SectionName), + L"Files.%s", ComputerType); *AdditionalSectionName = SectionName; + // TODO: More things to do? + return TRUE; } BOOLEAN ProcessDisplayRegistry( - IN HINF InfFile, - IN PGENERIC_LIST List) + _In_ HINF InfFile, + _In_ PCWSTR DisplayType) { NTSTATUS Status; - PGENERIC_LIST_ENTRY Entry; INFCONTEXT Context; PCWSTR Buffer; PCWSTR ServiceName; @@ -822,15 +818,9 @@ ProcessDisplayRegistry( HANDLE KeyHandle; WCHAR RegPath[255]; - DPRINT("ProcessDisplayRegistry() called\n"); - - Entry = GetCurrentListEntry(List); - if (Entry == NULL) - return FALSE; + DPRINT("ProcessDisplayRegistry(%S) called\n", DisplayType); - if (!SpInfFindFirstLine(InfFile, L"Display", - ((PGENENTRY)GetListEntryData(Entry))->Id, - &Context)) + if (!SpInfFindFirstLine(InfFile, L"Display", DisplayType, &Context)) { DPRINT1("SpInfFindFirstLine() failed\n"); return FALSE; @@ -935,7 +925,7 @@ ProcessDisplayRegistry( return FALSE; } - Height = wcstoul(Buffer, 0, 0); + Height = wcstoul(Buffer, NULL, 10); Status = RtlWriteRegistryValue(RTL_REGISTRY_HANDLE, KeyHandle, L"DefaultSettings.YResolution", REG_DWORD, @@ -955,7 +945,7 @@ ProcessDisplayRegistry( return FALSE; } - Bpp = wcstoul(Buffer, 0, 0); + Bpp = wcstoul(Buffer, NULL, 10); Status = RtlWriteRegistryValue(RTL_REGISTRY_HANDLE, KeyHandle, L"DefaultSettings.BitsPerPel", REG_DWORD, @@ -977,25 +967,14 @@ ProcessDisplayRegistry( BOOLEAN ProcessLocaleRegistry( - IN PGENERIC_LIST List) + _In_ PCWSTR LanguageId) { - PGENERIC_LIST_ENTRY Entry; - PCWSTR LanguageId; OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING KeyName; UNICODE_STRING ValueName; - HANDLE KeyHandle; NTSTATUS Status; - Entry = GetCurrentListEntry(List); - if (Entry == NULL) - return FALSE; - - LanguageId = ((PGENENTRY)GetListEntryData(Entry))->Id; - if (LanguageId == NULL) - return FALSE; - DPRINT("LanguageId: %S\n", LanguageId); /* Open the default users locale key */ @@ -1286,22 +1265,15 @@ CreateKeyboardLayoutList( BOOLEAN ProcessKeyboardLayoutRegistry( - IN PGENERIC_LIST List, - IN PCWSTR LanguageId) + _In_ PCWSTR pszLayoutId, + _In_ PCWSTR LanguageId) { - PGENERIC_LIST_ENTRY Entry; - PCWSTR pszLayoutId; KLID LayoutId; const MUI_LAYOUTS* LayoutsList; MUI_LAYOUTS NewLayoutsList[20]; // HACK: Hardcoded fixed size "20" is a hack. Please verify against lang/*.h ULONG uIndex; ULONG uOldPos = 0; - Entry = GetCurrentListEntry(List); - if (Entry == NULL) - return FALSE; - - pszLayoutId = ((PGENENTRY)GetListEntryData(Entry))->Id; LayoutId = (KLID)(pszLayoutId ? wcstoul(pszLayoutId, NULL, 16) : 0); if (LayoutId == 0) return FALSE; @@ -1394,10 +1366,9 @@ SetGeoID( return TRUE; } - BOOLEAN SetDefaultPagefile( - IN WCHAR Drive) + _In_ WCHAR Drive) { NTSTATUS Status; HANDLE KeyHandle; diff --git a/base/setup/lib/settings.h b/base/setup/lib/settings.h index e77f15684c0..da6c7f2acd2 100644 --- a/base/setup/lib/settings.h +++ b/base/setup/lib/settings.h @@ -43,14 +43,14 @@ CreateDisplayDriverList( BOOLEAN ProcessComputerFiles( - IN HINF InfFile, - IN PGENERIC_LIST List, - OUT PWSTR* AdditionalSectionName); + _In_ HINF InfFile, + _In_ PCWSTR ComputerType, + _Out_ PWSTR* AdditionalSectionName); BOOLEAN ProcessDisplayRegistry( - IN HINF InfFile, - IN PGENERIC_LIST List); + _In_ HINF InfFile, + _In_ PCWSTR DisplayType); PGENERIC_LIST CreateKeyboardDriverList( @@ -72,16 +72,18 @@ GetDefaultLanguageIndex(VOID); BOOLEAN ProcessKeyboardLayoutRegistry( - IN PGENERIC_LIST List, - IN PCWSTR LanguageId); + _In_ PCWSTR pszLayoutId, + _In_ PCWSTR LanguageId); +#if 0 BOOLEAN ProcessKeyboardLayoutFiles( IN PGENERIC_LIST List); +#endif BOOLEAN ProcessLocaleRegistry( - IN PGENERIC_LIST List); + _In_ PCWSTR LanguageId); BOOLEAN SetGeoID( @@ -89,6 +91,6 @@ SetGeoID( BOOLEAN SetDefaultPagefile( - IN WCHAR Drive); + _In_ WCHAR Drive); /* EOF */ diff --git a/base/setup/lib/setuplib.c b/base/setup/lib/setuplib.c index 40e8c13b36f..4e3c5efe04a 100644 --- a/base/setup/lib/setuplib.c +++ b/base/setup/lib/setuplib.c @@ -789,12 +789,6 @@ InitializeSetup( { RtlZeroMemory(pSetupData, sizeof(*pSetupData)); - // pSetupData->ComputerList = NULL; - // pSetupData->DisplayList = NULL; - // pSetupData->KeyboardList = NULL; - // pSetupData->LayoutList = NULL; - // pSetupData->LanguageList = NULL; - /* Initialize error handling */ pSetupData->LastErrorNumber = ERROR_SUCCESS; pSetupData->ErrorRoutine = NULL; @@ -1059,23 +1053,36 @@ DoUpdate: { /* See the explanation for this test above */ + PGENERIC_LIST_ENTRY Entry; + PCWSTR LanguageId; // LocaleID; + + Entry = GetCurrentListEntry(pSetupData->DisplayList); + ASSERT(Entry); + pSetupData->DisplayType = ((PGENENTRY)GetListEntryData(Entry))->Id; + ASSERT(pSetupData->DisplayType); + /* Update display registry settings */ if (StatusRoutine) StatusRoutine(DisplaySettingsUpdate); - if (!ProcessDisplayRegistry(pSetupData->SetupInf, pSetupData->DisplayList)) + if (!ProcessDisplayRegistry(pSetupData->SetupInf, pSetupData->DisplayType)) { ErrorNumber = ERROR_UPDATE_DISPLAY_SETTINGS; goto Cleanup; } + Entry = GetCurrentListEntry(pSetupData->LanguageList); + ASSERT(Entry); + LanguageId = ((PGENENTRY)GetListEntryData(Entry))->Id; + ASSERT(LanguageId); + /* Set the locale */ if (StatusRoutine) StatusRoutine(LocaleSettingsUpdate); - if (!ProcessLocaleRegistry(pSetupData->LanguageList)) + if (!ProcessLocaleRegistry(/*pSetupData->*/LanguageId)) { ErrorNumber = ERROR_UPDATE_LOCALESETTINGS; goto Cleanup; } - /* Add keyboard layouts */ + /* Add the keyboard layouts for the given language (without user override) */ if (StatusRoutine) StatusRoutine(KeybLayouts); if (!AddKeyboardLayouts(SelectedLanguageId)) { @@ -1083,24 +1090,31 @@ DoUpdate: goto Cleanup; } - /* Set GeoID */ - if (!SetGeoID(MUIGetGeoID(SelectedLanguageId))) - { - ErrorNumber = ERROR_UPDATE_GEOID; - goto Cleanup; - } - if (!IsUnattendedSetup) { - /* Update keyboard layout settings */ + Entry = GetCurrentListEntry(pSetupData->LayoutList); + ASSERT(Entry); + pSetupData->LayoutId = ((PGENENTRY)GetListEntryData(Entry))->Id; + ASSERT(pSetupData->LayoutId); + + /* Update keyboard layout settings with user-overridden values */ + // FIXME: Wouldn't it be better to do it all at once + // with the AddKeyboardLayouts() step? if (StatusRoutine) StatusRoutine(KeybSettingsUpdate); - if (!ProcessKeyboardLayoutRegistry(pSetupData->LayoutList, SelectedLanguageId)) + if (!ProcessKeyboardLayoutRegistry(pSetupData->LayoutId, SelectedLanguageId)) { ErrorNumber = ERROR_UPDATE_KBSETTINGS; goto Cleanup; } } + /* Set GeoID */ + if (!SetGeoID(MUIGetGeoID(SelectedLanguageId))) + { + ErrorNumber = ERROR_UPDATE_GEOID; + goto Cleanup; + } + /* Add codepage information to registry */ if (StatusRoutine) StatusRoutine(CodePageInfoUpdate); if (!AddCodePage(SelectedLanguageId)) diff --git a/base/setup/lib/setuplib.h b/base/setup/lib/setuplib.h index 5d643ec3458..8988035f37d 100644 --- a/base/setup/lib/setuplib.h +++ b/base/setup/lib/setuplib.h @@ -122,6 +122,13 @@ typedef struct _USETUP_DATA PGENERIC_LIST LayoutList; PGENERIC_LIST LanguageList; +/* Settings *****/ + PCWSTR ComputerType; + PCWSTR DisplayType; + // PCWSTR KeyboardDriver; + // PCWSTR MouseDriver; + PCWSTR LayoutId; // DefaultKBLayout + /* Other stuff *****/ WCHAR LocaleID[9]; LANGID LanguageId;
10 months, 1 week
1
0
0
0
[reactos] 01/01: [SDK:LIB] Introduce Cicero static library (#6492)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fc3eeb61f3222524ea072…
commit fc3eeb61f3222524ea072ad3563dcf239c668d6a Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Sat Feb 17 09:53:50 2024 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Sat Feb 17 09:53:50 2024 +0900 [SDK:LIB] Introduce Cicero static library (#6492) Refactoring and reduce binary size. JIRA issue: CORE-19268 - Add cicero static library in sdk/lib/cicero folder. - Delete sdk/include/reactos/cicero folder. - Adapt the dependencies to these changes. - Make ctfmon, msutb, and msctf modules UNICODE. --- base/applications/ctfmon/CMakeLists.txt | 4 +- base/applications/ctfmon/precomp.h | 4 +- dll/ime/msctfime/CMakeLists.txt | 2 +- dll/ime/msctfime/msctfime.h | 13 +- dll/win32/msctf/CMakeLists.txt | 4 +- dll/win32/msctf/utils.cpp | 8 +- dll/win32/msutb/CMakeLists.txt | 4 +- dll/win32/msutb/msutb.cpp | 21 +- dll/win32/msutb/precomp.h | 8 +- sdk/include/reactos/cicero/cicreg.h | 177 -- sdk/lib/CMakeLists.txt | 1 + sdk/lib/cicero/CMakeLists.txt | 15 + sdk/lib/cicero/cicarray.cpp | 78 + sdk/{include/reactos => lib}/cicero/cicarray.h | 73 +- .../cicero/cicbase.h => lib/cicero/cicbase.cpp} | 240 +-- sdk/lib/cicero/cicbase.h | 133 ++ .../cicero/ciccaret.h => lib/cicero/ciccaret.cpp} | 47 +- sdk/lib/cicero/ciccaret.h | 32 + sdk/{include/reactos => lib}/cicero/cicevent.h | 0 .../cicero/cicfmap.h => lib/cicero/cicfmap.cpp} | 64 +- sdk/lib/cicero/cicfmap.h | 48 + sdk/lib/cicero/cicimc.cpp | 53 + sdk/{include/reactos => lib}/cicero/cicimc.h | 41 - sdk/{include/reactos => lib}/cicero/cicmutex.h | 0 sdk/lib/cicero/cicreg.cpp | 83 + sdk/lib/cicero/cicreg.h | 116 ++ sdk/{include/reactos => lib}/cicero/cictf.h | 0 .../cicero/cicuif.h => lib/cicero/cicuif.cpp} | 1994 +++++--------------- sdk/lib/cicero/cicuif.h | 1088 +++++++++++ sdk/{include/reactos => lib}/cicero/cicutb.h | 23 +- sdk/lib/cicero/precomp.h | 6 + 31 files changed, 2269 insertions(+), 2111 deletions(-) diff --git a/base/applications/ctfmon/CMakeLists.txt b/base/applications/ctfmon/CMakeLists.txt index 8ca1d7b5311..8ee72826571 100644 --- a/base/applications/ctfmon/CMakeLists.txt +++ b/base/applications/ctfmon/CMakeLists.txt @@ -6,9 +6,9 @@ list(APPEND SOURCE add_rc_deps(ctfmon.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/ctfmon.ico) add_executable(ctfmon ${SOURCE} ctfmon.rc) -set_module_type(ctfmon win32gui) +set_module_type(ctfmon win32gui UNICODE) add_dependencies(ctfmon msctf msutb) -target_link_libraries(ctfmon uuid) +target_link_libraries(ctfmon uuid cicero) add_importlibs(ctfmon msctf msutb advapi32 shell32 user32 msvcrt kernel32) add_pch(ctfmon precomp.h SOURCE) add_cd_file(TARGET ctfmon DESTINATION reactos/system32 FOR all) diff --git a/base/applications/ctfmon/precomp.h b/base/applications/ctfmon/precomp.h index b6ca0bdcb4d..44344559440 100644 --- a/base/applications/ctfmon/precomp.h +++ b/base/applications/ctfmon/precomp.h @@ -17,8 +17,8 @@ #include <msctf.h> #include <ctfutb.h> #include <ctffunc.h> -#include <cicero/cicbase.h> -#include <cicero/cicutb.h> +#include <cicbase.h> +#include <cicutb.h> #include "resource.h" diff --git a/dll/ime/msctfime/CMakeLists.txt b/dll/ime/msctfime/CMakeLists.txt index a3955cea141..5a034398964 100644 --- a/dll/ime/msctfime/CMakeLists.txt +++ b/dll/ime/msctfime/CMakeLists.txt @@ -16,7 +16,7 @@ add_library(msctfime MODULE ${CMAKE_CURRENT_BINARY_DIR}/msctfime.def) set_module_type(msctfime win32dll UNICODE) set_target_properties(msctfime PROPERTIES SUFFIX ".ime") -target_link_libraries(msctfime wine uuid) +target_link_libraries(msctfime wine uuid cicero) add_importlibs(msctfime user32 gdi32 advapi32 msvcrt kernel32 ntdll) add_delay_importlibs(msctfime comctl32 msctf oleaut32 imm32) add_cd_file(TARGET msctfime DESTINATION reactos/system32 FOR all) diff --git a/dll/ime/msctfime/msctfime.h b/dll/ime/msctfime/msctfime.h index 697aa8da684..040ecc11c96 100644 --- a/dll/ime/msctfime/msctfime.h +++ b/dll/ime/msctfime/msctfime.h @@ -24,12 +24,13 @@ #include <shlwapi.h> #include <strsafe.h> -#include <cicero/cicbase.h> -#include <cicero/cicarray.h> -#include <cicero/cicimc.h> -#include <cicero/cictf.h> -#include <cicero/ciccaret.h> -#include <cicero/cicuif.h> +#include <cicbase.h> +#include <cicarray.h> +#include <cicimc.h> +#include <cictf.h> +#include <ciccaret.h> +#include <cicuif.h> +#include <cicutb.h> #include <wine/debug.h> diff --git a/dll/win32/msctf/CMakeLists.txt b/dll/win32/msctf/CMakeLists.txt index d8caf9a8e04..a167162dc58 100644 --- a/dll/win32/msctf/CMakeLists.txt +++ b/dll/win32/msctf/CMakeLists.txt @@ -29,8 +29,8 @@ add_library(msctf MODULE version.rc ${CMAKE_CURRENT_BINARY_DIR}/msctf.def) -set_module_type(msctf win32dll) -target_link_libraries(msctf uuid wine) +set_module_type(msctf win32dll UNICODE) +target_link_libraries(msctf uuid wine cicero) add_importlibs(msctf user32 advapi32 advapi32_vista msvcrt kernel32 ntdll) add_delay_importlibs(msctf ole32 oleaut32) add_pch(msctf precomp.h SOURCE) diff --git a/dll/win32/msctf/utils.cpp b/dll/win32/msctf/utils.cpp index 1b26fa92684..4fc57a5ac0d 100644 --- a/dll/win32/msctf/utils.cpp +++ b/dll/win32/msctf/utils.cpp @@ -23,9 +23,9 @@ #include <shlwapi.h> #include <strsafe.h> -#include <cicero/cicreg.h> -#include <cicero/cicmutex.h> -#include <cicero/cicfmap.h> +#include <cicreg.h> +#include <cicmutex.h> +#include <cicfmap.h> #include <wine/debug.h> @@ -366,7 +366,7 @@ BOOL InitLangChangeHotKey(VOID) szLanguage[0] = szLayout[0] = TEXT('3'); szLanguage[1] = szLayout[1] = TEXT('\0'); - error = regKey.Open(HKEY_CURRENT_USER, "Keyboard Layout\\Toggle"); + error = regKey.Open(HKEY_CURRENT_USER, TEXT("Keyboard Layout\\Toggle")); if (error == ERROR_SUCCESS) { error = regKey.QuerySz(TEXT("Language Hotkey"), szLanguage, _countof(szLanguage)); diff --git a/dll/win32/msutb/CMakeLists.txt b/dll/win32/msutb/CMakeLists.txt index ee8204be2ff..c63dbb11cb2 100644 --- a/dll/win32/msutb/CMakeLists.txt +++ b/dll/win32/msutb/CMakeLists.txt @@ -11,9 +11,9 @@ add_library(msutb MODULE ${SOURCE} msutb.rc ${CMAKE_CURRENT_BINARY_DIR}/msutb.def) -set_module_type(msutb win32dll) +set_module_type(msutb win32dll UNICODE) add_dependencies(msutb msctf psdk) -target_link_libraries(msutb wine uuid atl_classes) +target_link_libraries(msutb wine uuid atl_classes cicero) add_importlibs(msutb user32 gdi32 advapi32 msvcrt kernel32 ntdll) add_delay_importlibs(msutb uxtheme imm32 comctl32 msctf ole32 oleacc oleaut32 shell32) add_cd_file(TARGET msutb DESTINATION reactos/system32 FOR all) diff --git a/dll/win32/msutb/msutb.cpp b/dll/win32/msutb/msutb.cpp index c5e3c337614..74c537ede80 100644 --- a/dll/win32/msutb/msutb.cpp +++ b/dll/win32/msutb/msutb.cpp @@ -20,7 +20,7 @@ LONG g_DllRefCount = 0; BOOL g_bWinLogon = FALSE; BOOL g_fInClosePopupTipbar = FALSE; HWND g_hwndParent = NULL; -LIBTHREAD g_libTLS = { NULL, NULL }; +CIC_LIBTHREAD g_libTLS = { NULL, NULL }; #ifdef ENABLE_DESKBAND BOOL g_bEnableDeskBand = TRUE; #else @@ -77,23 +77,6 @@ class CMsUtbModule : public CComModule CMsUtbModule gModule; -void TFUninitLib_Thread(LIBTHREAD *libThread) -{ - if (!libThread) - return; - - if (libThread->m_pUnknown1) - { - libThread->m_pUnknown1->Release(); - libThread->m_pUnknown1 = NULL; - } - if (libThread->m_pDisplayAttrMgr) - { - libThread->m_pDisplayAttrMgr->Release(); - libThread->m_pDisplayAttrMgr = NULL; - } -} - class CCicLibMenuItem; class CTipbarAccItem; class CUTBMenuItem; @@ -6075,7 +6058,7 @@ BOOL GetTipbarInternal(HWND hWnd, DWORD dwFlags, CDeskBand *pDeskBand) * * @implemented */ -EXTERN_C PLIBTHREAD WINAPI +EXTERN_C PCIC_LIBTHREAD WINAPI GetLibTls(VOID) { TRACE("()\n"); diff --git a/dll/win32/msutb/precomp.h b/dll/win32/msutb/precomp.h index 53e68d549b5..c2e3415a56d 100644 --- a/dll/win32/msutb/precomp.h +++ b/dll/win32/msutb/precomp.h @@ -9,7 +9,6 @@ #include <stdlib.h> -#define WIN32_NO_STATUS #define COBJMACROS #define INITGUID @@ -25,11 +24,10 @@ #include <atlbase.h> #include <atlcom.h> #include <strsafe.h> -#undef STATUS_NO_MEMORY #include "resource.h" -#include <cicero/cicreg.h> -#include <cicero/cicutb.h> -#include <cicero/cicuif.h> +#include <cicreg.h> +#include <cicutb.h> +#include <cicuif.h> #include <wine/debug.h> diff --git a/sdk/include/reactos/cicero/cicreg.h b/sdk/include/reactos/cicero/cicreg.h deleted file mode 100644 index b5a99658a15..00000000000 --- a/sdk/include/reactos/cicero/cicreg.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * PROJECT: ReactOS Cicero - * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) - * PURPOSE: Cicero registry handling - * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> - */ - -#pragma once - -#include "cicbase.h" - -class CicRegKey -{ -public: - HKEY m_hKey; - - CicRegKey() : m_hKey(NULL) { } - virtual ~CicRegKey() { Close(); } - - operator HKEY() { return m_hKey; } - - void Close(); - - LSTATUS Open( - HKEY hKey, - LPCTSTR lpSubKey, - REGSAM samDesired = KEY_READ); - - LSTATUS Create( - HKEY hKey, - LPCTSTR lpSubKey, - LPTSTR lpClass = NULL, - DWORD dwOptions = REG_OPTION_NON_VOLATILE, - REGSAM samDesired = KEY_ALL_ACCESS, - LPSECURITY_ATTRIBUTES lpSecurityAttributes = NULL, - LPDWORD pdwDisposition = NULL); - - LSTATUS QueryDword(LPCTSTR pszValueName, LPDWORD pdwValue) - { - DWORD cbData = sizeof(DWORD); - return ::RegQueryValueEx(m_hKey, pszValueName, 0, NULL, (LPBYTE)pdwValue, &cbData); - } - - LSTATUS SetDword(LPCTSTR pszValueName, DWORD dwValue) - { - return ::RegSetValueEx(m_hKey, pszValueName, 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(dwValue)); - } - - LSTATUS QuerySz(LPCTSTR pszValueName, LPTSTR pszValue, DWORD cchValueMax); - - LSTATUS SetSz(LPCTSTR pszValueName, LPCTSTR pszValue) - { - DWORD cbValue = (lstrlen(pszValue) + 1) * sizeof(TCHAR); - return ::RegSetValueEx(m_hKey, pszValueName, 0, REG_SZ, (LPBYTE)pszValue, cbValue); - } - LSTATUS SetSzW(LPCWSTR pszValueName, LPCWSTR pszValue) - { - DWORD cbValue = (lstrlenW(pszValue) + 1) * sizeof(WCHAR); - return ::RegSetValueExW(m_hKey, pszValueName, 0, REG_SZ, (LPBYTE)pszValue, cbValue); - } - - LSTATUS DeleteSubKey(LPCTSTR lpSubKey) - { - return ::RegDeleteKey(m_hKey, lpSubKey); - } - - LSTATUS RecurseDeleteKey(LPCTSTR lpSubKey); - - LSTATUS EnumValue(DWORD dwIndex, LPTSTR lpValueName, DWORD cchValueName); -}; - -/******************************************************************************/ - -inline void -CicRegKey::Close() -{ - if (!m_hKey) - return; - - ::RegCloseKey(m_hKey); - m_hKey = NULL; -} - -inline LSTATUS -CicRegKey::Open( - HKEY hKey, - LPCTSTR lpSubKey, - REGSAM samDesired) -{ - HKEY hNewKey = NULL; - LSTATUS error = ::RegOpenKeyEx(hKey, lpSubKey, 0, samDesired, &hNewKey); - if (error != ERROR_SUCCESS) - return error; - - Close(); - m_hKey = hNewKey; - return error; -} - -inline LSTATUS -CicRegKey::Create( - HKEY hKey, - LPCTSTR lpSubKey, - LPTSTR lpClass, - DWORD dwOptions, - REGSAM samDesired, - LPSECURITY_ATTRIBUTES lpSecurityAttributes, - LPDWORD pdwDisposition) -{ - HKEY hNewKey = NULL; - LSTATUS error = ::RegCreateKeyEx(hKey, - lpSubKey, - 0, - lpClass, - dwOptions, - samDesired, - lpSecurityAttributes, - &hNewKey, - pdwDisposition); - if (error != ERROR_SUCCESS) - return error; - - Close(); - m_hKey = hNewKey; - return error; -} - -inline LSTATUS -CicRegKey::QuerySz(LPCTSTR pszValueName, LPTSTR pszValue, DWORD cchValueMax) -{ - DWORD cchSaveMax = cchValueMax; - - cchValueMax *= sizeof(TCHAR); - LSTATUS error = ::RegQueryValueEx(m_hKey, pszValueName, 0, NULL, - (LPBYTE)pszValue, &cchValueMax); - if (cchSaveMax > 0) - pszValue[(error == ERROR_SUCCESS) ? (cchSaveMax - 1) : 0] = UNICODE_NULL; - - return error; -} - -inline LSTATUS -CicRegKey::RecurseDeleteKey(LPCTSTR lpSubKey) -{ - CicRegKey regKey; - LSTATUS error = regKey.Open(m_hKey, lpSubKey, KEY_READ | KEY_WRITE); - if (error != ERROR_SUCCESS) - return error; - - TCHAR szName[MAX_PATH]; - DWORD cchName; - do - { - cchName = _countof(szName); - error = ::RegEnumKeyEx(regKey, 0, szName, &cchName, NULL, NULL, NULL, NULL); - if (error != ERROR_SUCCESS) - break; - - szName[_countof(szName) - 1] = UNICODE_NULL; - error = regKey.RecurseDeleteKey(szName); - } while (error == ERROR_SUCCESS); - - regKey.Close(); - - return DeleteSubKey(lpSubKey); -} - -inline LSTATUS -CicRegKey::EnumValue(DWORD dwIndex, LPTSTR lpValueName, DWORD cchValueName) -{ - DWORD dwSaveLen = cchValueName; - LSTATUS error = ::RegEnumValue(m_hKey, dwIndex, lpValueName, &cchValueName, - NULL, NULL, NULL, NULL); - if (dwSaveLen) - lpValueName[error == ERROR_SUCCESS ? dwSaveLen - 1 : 0] = 0; - return error; -} diff --git a/sdk/lib/CMakeLists.txt b/sdk/lib/CMakeLists.txt index 61b051f6193..78958dd3de0 100644 --- a/sdk/lib/CMakeLists.txt +++ b/sdk/lib/CMakeLists.txt @@ -6,6 +6,7 @@ add_subdirectory(inflib) if(CMAKE_CROSSCOMPILING) add_subdirectory(3rdparty) +add_subdirectory(cicero) add_subdirectory(comsupp) add_subdirectory(conutils) add_subdirectory(cportlib) diff --git a/sdk/lib/cicero/CMakeLists.txt b/sdk/lib/cicero/CMakeLists.txt new file mode 100644 index 00000000000..b2cddda0f9a --- /dev/null +++ b/sdk/lib/cicero/CMakeLists.txt @@ -0,0 +1,15 @@ + +list(APPEND SOURCE + cicarray.cpp + cicbase.cpp + ciccaret.cpp + cicfmap.cpp + cicimc.cpp + cicreg.cpp + cicuif.cpp) + +add_library(cicero STATIC ${SOURCE}) +target_compile_definitions(cicero PRIVATE UNICODE _UNICODE) +add_dependencies(cicero psdk) +target_include_directories(cicero INTERFACE + $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}>) diff --git a/sdk/lib/cicero/cicarray.cpp b/sdk/lib/cicero/cicarray.cpp new file mode 100644 index 00000000000..293f2392c47 --- /dev/null +++ b/sdk/lib/cicero/cicarray.cpp @@ -0,0 +1,78 @@ +/* + * PROJECT: ReactOS Cicero + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Cicero dynamic array + * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#include "precomp.h" +#include "cicarray.h" + +CicArrayBase::CicArrayBase(size_t cbItem) +{ + m_cbItem = cbItem; + m_pb = NULL; + m_cItems = m_cCapacity = 0; +} + +CicArrayBase::~CicArrayBase() +{ + cicMemFree(m_pb); +} + +LPVOID CicArrayBase::Append(size_t cGrow) +{ + if (!Insert(m_cItems, cGrow)) + return NULL; + return &m_pb[(m_cItems - cGrow) * m_cbItem]; +} + +BOOL CicArrayBase::Insert(size_t iItem, size_t cGrow) +{ + size_t cNewCapacity = m_cItems + cGrow; + if (m_cCapacity < cNewCapacity) + { + if (cNewCapacity <= m_cItems + m_cItems / 2) + cNewCapacity = m_cItems + m_cItems / 2; + + LPBYTE pbNew = (LPBYTE)cicMemReAlloc(m_pb, cNewCapacity * m_cbItem); + if (!pbNew) + return FALSE; + + m_pb = pbNew; + m_cCapacity = cNewCapacity; + } + + if (iItem < m_cItems) + { + MoveMemory(&m_pb[(cGrow + iItem) * m_cbItem], + &m_pb[iItem * m_cbItem], + (m_cItems - iItem) * m_cbItem); + } + + m_cItems += cGrow; + return TRUE; +} + +void CicArrayBase::Remove(size_t iItem, size_t cRemove) +{ + if (iItem + cRemove < m_cItems) + { + MoveMemory(&m_pb[iItem * m_cbItem], + &m_pb[(iItem + cRemove) * m_cbItem], + (m_cItems - iItem - cRemove) * m_cbItem); + } + + m_cItems -= cRemove; + + size_t cHalfCapacity = m_cCapacity / 2; + if (cHalfCapacity <= m_cItems) + return; + + LPBYTE pb = (LPBYTE)cicMemReAlloc(m_pb, cHalfCapacity * m_cbItem); + if (pb) + { + m_pb = pb; + m_cCapacity = cHalfCapacity; + } +} diff --git a/sdk/include/reactos/cicero/cicarray.h b/sdk/lib/cicero/cicarray.h similarity index 50% rename from sdk/include/reactos/cicero/cicarray.h rename to sdk/lib/cicero/cicarray.h index 2df46e51c26..3a36f8f9b1c 100644 --- a/sdk/include/reactos/cicero/cicarray.h +++ b/sdk/lib/cicero/cicarray.h @@ -66,7 +66,7 @@ public: return TRUE; } - ssize_t Find(const T_ITEM& item) const + ptrdiff_t Find(const T_ITEM& item) const { for (size_t iItem = 0; iItem < m_cItems; ++iItem) { @@ -76,74 +76,3 @@ public: return -1; } }; - -/******************************************************************************/ - -inline CicArrayBase::CicArrayBase(size_t cbItem) -{ - m_cbItem = cbItem; - m_pb = NULL; - m_cItems = m_cCapacity = 0; -} - -inline CicArrayBase::~CicArrayBase() -{ - cicMemFree(m_pb); -} - -inline LPVOID CicArrayBase::Append(size_t cGrow) -{ - if (!Insert(m_cItems, cGrow)) - return NULL; - return &m_pb[(m_cItems - cGrow) * m_cbItem]; -} - -inline BOOL CicArrayBase::Insert(size_t iItem, size_t cGrow) -{ - size_t cNewCapacity = m_cItems + cGrow; - if (m_cCapacity < cNewCapacity) - { - if (cNewCapacity <= m_cItems + m_cItems / 2) - cNewCapacity = m_cItems + m_cItems / 2; - - LPBYTE pbNew = (LPBYTE)cicMemReAlloc(m_pb, cNewCapacity * m_cbItem); - if (!pbNew) - return FALSE; - - m_pb = pbNew; - m_cCapacity = cNewCapacity; - } - - if (iItem < m_cItems) - { - MoveMemory(&m_pb[(cGrow + iItem) * m_cbItem], - &m_pb[iItem * m_cbItem], - (m_cItems - iItem) * m_cbItem); - } - - m_cItems += cGrow; - return TRUE; -} - -inline void CicArrayBase::Remove(size_t iItem, size_t cRemove) -{ - if (iItem + cRemove < m_cItems) - { - MoveMemory(&m_pb[iItem * m_cbItem], - &m_pb[(iItem + cRemove) * m_cbItem], - (m_cItems - iItem - cRemove) * m_cbItem); - } - - m_cItems -= cRemove; - - size_t cHalfCapacity = m_cCapacity / 2; - if (cHalfCapacity <= m_cItems) - return; - - LPBYTE pb = (LPBYTE)cicMemReAlloc(m_pb, cHalfCapacity * m_cbItem); - if (pb) - { - m_pb = pb; - m_cCapacity = cHalfCapacity; - } -} diff --git a/sdk/include/reactos/cicero/cicbase.h b/sdk/lib/cicero/cicbase.cpp similarity index 58% rename from sdk/include/reactos/cicero/cicbase.h rename to sdk/lib/cicero/cicbase.cpp index 25c3710ec77..cf76100e1cd 100644 --- a/sdk/include/reactos/cicero/cicbase.h +++ b/sdk/lib/cicero/cicbase.cpp @@ -2,84 +2,84 @@ * PROJECT: ReactOS Cicero * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) * PURPOSE: Cicero base - * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + * COPYRIGHT: Copyright 2023-2024 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> */ -#pragma once +#include "precomp.h" +#include "cicbase.h" +#include <shlwapi.h> +#include <stdlib.h> +#include <string.h> +#include <tchar.h> +#include <strsafe.h> -#ifndef __cplusplus - #error Cicero needs C++. -#endif - -static inline LPVOID cicMemAlloc(SIZE_T size) -{ - return LocalAlloc(0, size); -} - -static inline LPVOID cicMemAllocClear(SIZE_T size) -{ - return LocalAlloc(LMEM_ZEROINIT, size); -} - -static inline LPVOID cicMemReAlloc(LPVOID ptr, SIZE_T newSize) -{ - if (!ptr) - return LocalAlloc(LMEM_ZEROINIT, newSize); - return LocalReAlloc(ptr, newSize, LMEM_ZEROINIT); -} - -static inline void cicMemFree(LPVOID ptr) -{ - if (ptr) - LocalFree(ptr); -} - -struct CicNoThrow { }; -#define cicNoThrow CicNoThrow{} - -inline void* operator new(size_t size, const CicNoThrow&) noexcept +void* operator new(size_t size, const CicNoThrow&) noexcept { return cicMemAllocClear(size); } -inline void* operator new[](size_t size, const CicNoThrow&) noexcept +void* operator new[](size_t size, const CicNoThrow&) noexcept { return cicMemAllocClear(size); } -inline void operator delete(void* ptr) noexcept +void operator delete(void* ptr) noexcept { cicMemFree(ptr); } -inline void operator delete[](void* ptr) noexcept +void operator delete[](void* ptr) noexcept { cicMemFree(ptr); } -inline void operator delete(void* ptr, size_t size) noexcept +void operator delete(void* ptr, size_t size) noexcept { cicMemFree(ptr); } -inline void operator delete[](void* ptr, size_t size) noexcept +void operator delete[](void* ptr, size_t size) noexcept { cicMemFree(ptr); } -typedef struct CIC_LIBTHREAD +// FIXME +typedef enum _PROCESSINFOCLASS +{ + ProcessBasicInformation = 0, + ProcessDebugPort = 7, + ProcessWow64Information = 26, + ProcessImageFileName = 27, + ProcessBreakOnTermination = 29 +} PROCESSINFOCLASS; + +// FIXME +typedef LONG NTSTATUS; + +/* ntdll!NtQueryInformationProcess */ +typedef NTSTATUS (WINAPI *FN_NtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG); + +EXTERN_C +BOOL cicIsWow64(VOID) { - IUnknown *m_pUnknown1; - ITfDisplayAttributeMgr *m_pDisplayAttrMgr; -} CIC_LIBTHREAD, *PCIC_LIBTHREAD; + static FN_NtQueryInformationProcess s_fnNtQueryInformationProcess = NULL; + ULONG_PTR Value; -/* The flags of cicGetOSInfo() */ -#define CIC_OSINFO_NT 0x01 -#define CIC_OSINFO_2KPLUS 0x02 -#define CIC_OSINFO_95 0x04 -#define CIC_OSINFO_98PLUS 0x08 -#define CIC_OSINFO_CJK 0x10 -#define CIC_OSINFO_IMM 0x20 -#define CIC_OSINFO_DBCS 0x40 -#define CIC_OSINFO_XPPLUS 0x80 + if (!s_fnNtQueryInformationProcess) + { + HMODULE hNTDLL = cicGetSystemModuleHandle(TEXT("ntdll.dll"), FALSE); + if (!hNTDLL) + return FALSE; -static inline void -cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo) + s_fnNtQueryInformationProcess = + (FN_NtQueryInformationProcess)GetProcAddress(hNTDLL, "NtQueryInformationProcess"); + if (!s_fnNtQueryInformationProcess) + return FALSE; + } + + Value = 0; + s_fnNtQueryInformationProcess(GetCurrentProcess(), ProcessWow64Information, + &Value, sizeof(Value), NULL); + return !!Value; +} + +EXTERN_C +void cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo) { *pdwOSInfo = 0; @@ -124,22 +124,9 @@ cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo) *pdwOSInfo |= CIC_OSINFO_DBCS; } -struct CicSystemModulePath -{ - TCHAR m_szPath[MAX_PATH + 2]; - SIZE_T m_cchPath; - - CicSystemModulePath() - { - m_szPath[0] = UNICODE_NULL; - m_cchPath = 0; - } - - BOOL Init(_In_ LPCTSTR pszFileName, _In_ BOOL bSysWinDir); -}; - // Get an instance handle that is already loaded -static inline HINSTANCE +EXTERN_C +HINSTANCE cicGetSystemModuleHandle( _In_ LPCTSTR pszFileName, _In_ BOOL bSysWinDir) @@ -151,7 +138,8 @@ cicGetSystemModuleHandle( } // Load a system library -static inline HINSTANCE +EXTERN_C +HINSTANCE cicLoadSystemLibrary( _In_ LPCTSTR pszFileName, _In_ BOOL bSysWinDir) @@ -162,54 +150,7 @@ cicLoadSystemLibrary( return ::LoadLibrary(ModPath.m_szPath); } -template <typename T_FN> -static inline BOOL -cicGetFN(HINSTANCE& hinstDLL, T_FN& fn, LPCTSTR pszDllName, LPCSTR pszFuncName) -{ - if (fn) - return TRUE; - if (!hinstDLL) - hinstDLL = cicLoadSystemLibrary(pszDllName, FALSE); - if (!hinstDLL) - return FALSE; - fn = reinterpret_cast<T_FN>(GetProcAddress(hinstDLL, pszFuncName)); - return !!fn; -} - -#include <ndk/pstypes.h> /* for PROCESSINFOCLASS */ - -/* ntdll!NtQueryInformationProcess */ -typedef NTSTATUS (WINAPI *FN_NtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG); - -/* Is the current process on WoW64? */ -static inline BOOL cicIsWow64(VOID) -{ - static FN_NtQueryInformationProcess s_fnNtQueryInformationProcess = NULL; - ULONG_PTR Value; - NTSTATUS Status; - - if (!s_fnNtQueryInformationProcess) - { - HMODULE hNTDLL = cicGetSystemModuleHandle(TEXT("ntdll.dll"), FALSE); - if (!hNTDLL) - return FALSE; - - s_fnNtQueryInformationProcess = - (FN_NtQueryInformationProcess)GetProcAddress(hNTDLL, "NtQueryInformationProcess"); - if (!s_fnNtQueryInformationProcess) - return FALSE; - } - - Value = 0; - Status = s_fnNtQueryInformationProcess(GetCurrentProcess(), ProcessWow64Information, - &Value, sizeof(Value), NULL); - if (!NT_SUCCESS(Status)) - return FALSE; - - return !!Value; -} - -inline BOOL +BOOL CicSystemModulePath::Init( _In_ LPCTSTR pszFileName, _In_ BOOL bSysWinDir) @@ -251,15 +192,7 @@ Failure: return FALSE; } -// ole32!CoCreateInstance -typedef HRESULT (WINAPI *FN_CoCreateInstance)( - REFCLSID rclsid, - LPUNKNOWN pUnkOuter, - DWORD dwClsContext, - REFIID iid, - LPVOID *ppv); - -static inline FN_CoCreateInstance +static FN_CoCreateInstance _cicGetSetUserCoCreateInstance(FN_CoCreateInstance fnUserCoCreateInstance) { static FN_CoCreateInstance s_fn = NULL; @@ -268,13 +201,14 @@ _cicGetSetUserCoCreateInstance(FN_CoCreateInstance fnUserCoCreateInstance) return s_fn; } -static inline HRESULT +EXTERN_C +HRESULT cicRealCoCreateInstance( - REFCLSID rclsid, - LPUNKNOWN pUnkOuter, - DWORD dwClsContext, - REFIID iid, - LPVOID *ppv) + _In_ REFCLSID rclsid, + _In_ LPUNKNOWN pUnkOuter, + _In_ DWORD dwClsContext, + _In_ REFIID iid, + _Out_ LPVOID *ppv) { static HINSTANCE s_hOle32 = NULL; static FN_CoCreateInstance s_fnCoCreateInstance = NULL; @@ -293,13 +227,13 @@ cicRealCoCreateInstance( /** * @implemented */ -static inline HRESULT +HRESULT cicCoCreateInstance( - REFCLSID rclsid, - LPUNKNOWN pUnkOuter, - DWORD dwClsContext, - REFIID iid, - LPVOID *ppv) + _In_ REFCLSID rclsid, + _In_ LPUNKNOWN pUnkOuter, + _In_ DWORD dwClsContext, + _In_ REFIID iid, + _Out_ LPVOID *ppv) { // NOTE: It looks like Cicero wants to hook CoCreateInstance FN_CoCreateInstance fnUserCoCreateInstance = _cicGetSetUserCoCreateInstance(NULL); @@ -312,8 +246,9 @@ cicCoCreateInstance( /** * @implemented */ -static inline BOOL -TFInitLib(FN_CoCreateInstance fnCoCreateInstance = NULL) +EXTERN_C +BOOL +TFInitLib(FN_CoCreateInstance fnCoCreateInstance) { if (fnCoCreateInstance) _cicGetSetUserCoCreateInstance(fnCoCreateInstance); @@ -323,30 +258,9 @@ TFInitLib(FN_CoCreateInstance fnCoCreateInstance = NULL) /** * @unimplemented */ -static inline VOID +EXTERN_C +VOID TFUninitLib(VOID) { //FIXME } - -/** - * @implemented - */ -static inline VOID -TFUninitLib_Thread(PCIC_LIBTHREAD pLibThread) -{ - if (!pLibThread) - return; - - if (pLibThread->m_pUnknown1) - { - pLibThread->m_pUnknown1->Release(); - pLibThread->m_pUnknown1 = NULL; - } - - if (pLibThread->m_pDisplayAttrMgr) - { - pLibThread->m_pDisplayAttrMgr->Release(); - pLibThread->m_pDisplayAttrMgr = NULL; - } -} diff --git a/sdk/lib/cicero/cicbase.h b/sdk/lib/cicero/cicbase.h new file mode 100644 index 00000000000..36a143fc9b9 --- /dev/null +++ b/sdk/lib/cicero/cicbase.h @@ -0,0 +1,133 @@ +/* + * PROJECT: ReactOS Cicero + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Cicero base + * COPYRIGHT: Copyright 2023-2024 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#pragma once + +static inline LPVOID cicMemAlloc(SIZE_T size) +{ + return LocalAlloc(0, size); +} + +static inline LPVOID cicMemAllocClear(SIZE_T size) +{ + return LocalAlloc(LMEM_ZEROINIT, size); +} + +static inline LPVOID cicMemReAlloc(LPVOID ptr, SIZE_T newSize) +{ + if (!ptr) + return LocalAlloc(LMEM_ZEROINIT, newSize); + return LocalReAlloc(ptr, newSize, LMEM_ZEROINIT); +} + +static inline void cicMemFree(LPVOID ptr) +{ + if (ptr) + LocalFree(ptr); +} + +struct CicNoThrow { }; +#define cicNoThrow CicNoThrow{} + +void* operator new(size_t size, const CicNoThrow&) noexcept; +void* operator new[](size_t size, const CicNoThrow&) noexcept; +void operator delete(void* ptr) noexcept; +void operator delete[](void* ptr) noexcept; +void operator delete(void* ptr, size_t size) noexcept; +void operator delete[](void* ptr, size_t size) noexcept; + +/* The flags of cicGetOSInfo() */ +#define CIC_OSINFO_NT 0x01 +#define CIC_OSINFO_2KPLUS 0x02 +#define CIC_OSINFO_95 0x04 +#define CIC_OSINFO_98PLUS 0x08 +#define CIC_OSINFO_CJK 0x10 +#define CIC_OSINFO_IMM 0x20 +#define CIC_OSINFO_DBCS 0x40 +#define CIC_OSINFO_XPPLUS 0x80 + +EXTERN_C +void cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo); + +#ifdef __cplusplus +struct CicSystemModulePath +{ + TCHAR m_szPath[MAX_PATH + 2]; + SIZE_T m_cchPath; + + CicSystemModulePath() + { + m_szPath[0] = UNICODE_NULL; + m_cchPath = 0; + } + + BOOL Init(_In_ LPCTSTR pszFileName, _In_ BOOL bSysWinDir); +}; +#endif + +// Get an instance handle that is already loaded +EXTERN_C +HINSTANCE +cicGetSystemModuleHandle( + _In_ LPCTSTR pszFileName, + _In_ BOOL bSysWinDir); + +// Load a system library +EXTERN_C +HINSTANCE +cicLoadSystemLibrary( + _In_ LPCTSTR pszFileName, + _In_ BOOL bSysWinDir); + +#ifdef __cplusplus +template <typename T_FN> +static inline BOOL +cicGetFN(HINSTANCE& hinstDLL, T_FN& fn, LPCTSTR pszDllName, LPCSTR pszFuncName) +{ + if (fn) + return TRUE; + if (!hinstDLL) + hinstDLL = cicLoadSystemLibrary(pszDllName, FALSE); + if (!hinstDLL) + return FALSE; + fn = reinterpret_cast<T_FN>(GetProcAddress(hinstDLL, pszFuncName)); + return !!fn; +} +#endif + +/* Is the current process on WoW64? */ +EXTERN_C +BOOL cicIsWow64(VOID); + +EXTERN_C +HRESULT +cicRealCoCreateInstance( + _In_ REFCLSID rclsid, + _In_ LPUNKNOWN pUnkOuter, + _In_ DWORD dwClsContext, + _In_ REFIID iid, + _Out_ LPVOID *ppv); + +EXTERN_C +HRESULT +cicCoCreateInstance( + _In_ REFCLSID rclsid, + _In_ LPUNKNOWN pUnkOuter, + _In_ DWORD dwClsContext, + _In_ REFIID iid, + _Out_ LPVOID *ppv); + +// ole32!CoCreateInstance +typedef HRESULT (WINAPI *FN_CoCreateInstance)( + REFCLSID rclsid, + LPUNKNOWN pUnkOuter, + DWORD dwClsContext, + REFIID iid, + LPVOID *ppv); + +EXTERN_C BOOL TFInitLib(FN_CoCreateInstance fnCoCreateInstance = NULL); +EXTERN_C VOID TFUninitLib(VOID); diff --git a/sdk/include/reactos/cicero/ciccaret.h b/sdk/lib/cicero/ciccaret.cpp similarity index 63% rename from sdk/include/reactos/cicero/ciccaret.h rename to sdk/lib/cicero/ciccaret.cpp index b6d7722d58f..ff7e7ea16f3 100644 --- a/sdk/include/reactos/cicero/ciccaret.h +++ b/sdk/lib/cicero/ciccaret.cpp @@ -5,38 +5,13 @@ * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> */ -#pragma once - -class CicCaret -{ -protected: - HWND m_hWnd; - UINT m_uCaretBlinkTimerID; - POINT m_pt; - SIZE m_size; - BOOL m_bCaretBlinking; - BOOL m_bCaretVisible; - -public: - enum { TIMER_ID = 0x4F83AF91 }; - CicCaret(); - virtual ~CicCaret(); - - void CreateCaret(HWND hWnd, SIZE size); - void DestroyCaret(); - void HideCaret(); - void InvertCaret(); - void OnTimer(); - void SetCaretPos(POINT pt); - void SetBlinking(BOOL bBlinking); -}; - -/***********************************************************************/ +#include "precomp.h" +#include "ciccaret.h" /** * @implemented */ -inline CicCaret::CicCaret() +CicCaret::CicCaret() { m_bCaretBlinking = FALSE; m_bCaretVisible = FALSE; @@ -48,7 +23,7 @@ inline CicCaret::CicCaret() /** * @implemented */ -inline CicCaret::~CicCaret() +CicCaret::~CicCaret() { HideCaret(); ::KillTimer(m_hWnd, m_uCaretBlinkTimerID); @@ -58,7 +33,7 @@ inline CicCaret::~CicCaret() /** * @implemented */ -inline void CicCaret::CreateCaret(HWND hWnd, SIZE size) +void CicCaret::CreateCaret(HWND hWnd, SIZE size) { m_hWnd = hWnd; m_size = size; @@ -69,7 +44,7 @@ inline void CicCaret::CreateCaret(HWND hWnd, SIZE size) /** * @implemented */ -inline void CicCaret::DestroyCaret() +void CicCaret::DestroyCaret() { HideCaret(); ::KillTimer(m_hWnd, m_uCaretBlinkTimerID); @@ -79,7 +54,7 @@ inline void CicCaret::DestroyCaret() /** * @implemented */ -inline void CicCaret::HideCaret() +void CicCaret::HideCaret() { if (m_bCaretVisible) { @@ -92,7 +67,7 @@ inline void CicCaret::HideCaret() /** * @implemented */ -inline void CicCaret::InvertCaret() +void CicCaret::InvertCaret() { HDC hDC = ::GetDC(m_hWnd); ::PatBlt(hDC, m_pt.x, m_pt.y, m_size.cx, m_size.cy, DSTINVERT); @@ -102,7 +77,7 @@ inline void CicCaret::InvertCaret() /** * @implemented */ -inline void CicCaret::OnTimer() +void CicCaret::OnTimer() { if (m_bCaretBlinking) { @@ -114,7 +89,7 @@ inline void CicCaret::OnTimer() /** * @implemented */ -inline void CicCaret::SetCaretPos(POINT pt) +void CicCaret::SetCaretPos(POINT pt) { BOOL bCaretVisible = m_bCaretVisible; if (bCaretVisible) @@ -129,7 +104,7 @@ inline void CicCaret::SetCaretPos(POINT pt) /** * @implemented */ -inline void CicCaret::SetBlinking(BOOL bBlinking) +void CicCaret::SetBlinking(BOOL bBlinking) { m_bCaretBlinking = bBlinking; } diff --git a/sdk/lib/cicero/ciccaret.h b/sdk/lib/cicero/ciccaret.h new file mode 100644 index 00000000000..09044ee4884 --- /dev/null +++ b/sdk/lib/cicero/ciccaret.h @@ -0,0 +1,32 @@ +/* + * PROJECT: ReactOS Cicero + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Displaying Cicero caret + * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#pragma once + +class CicCaret +{ +protected: + HWND m_hWnd; + UINT m_uCaretBlinkTimerID; + POINT m_pt; + SIZE m_size; + BOOL m_bCaretBlinking; + BOOL m_bCaretVisible; + +public: + enum { TIMER_ID = 0x4F83AF91 }; + CicCaret(); + virtual ~CicCaret(); + + void CreateCaret(HWND hWnd, SIZE size); + void DestroyCaret(); + void HideCaret(); + void InvertCaret(); + void OnTimer(); + void SetCaretPos(POINT pt); + void SetBlinking(BOOL bBlinking); +}; diff --git a/sdk/include/reactos/cicero/cicevent.h b/sdk/lib/cicero/cicevent.h similarity index 100% rename from sdk/include/reactos/cicero/cicevent.h rename to sdk/lib/cicero/cicevent.h diff --git a/sdk/include/reactos/cicero/cicfmap.h b/sdk/lib/cicero/cicfmap.cpp similarity index 61% rename from sdk/include/reactos/cicero/cicfmap.h rename to sdk/lib/cicero/cicfmap.cpp index 3c711fc1e75..703d157aa81 100644 --- a/sdk/include/reactos/cicero/cicfmap.h +++ b/sdk/lib/cicero/cicfmap.cpp @@ -5,51 +5,9 @@ * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> */ -#pragma once +#include "precomp.h" +#include "cicfmap.h" -#include "cicmutex.h" - -// class CicFileMappingStatic; -// class CicFileMapping; - -class CicFileMappingStatic -{ -protected: - LPCTSTR m_pszName; - LPVOID m_pView; - HANDLE m_hMapping; - BOOL m_bCreated; - BOOL m_bHasMutex; - CicMutex *m_pMutex; - - LPVOID _Map(); - -public: - CicFileMappingStatic() { } - ~CicFileMappingStatic() { } - - void Init(LPCTSTR pszName, CicMutex *pMutex); - - LPVOID Create(LPSECURITY_ATTRIBUTES pSA, DWORD dwMaximumSizeLow, LPBOOL pbAlreadyExists); - LPVOID Open(); - void Close(); - - BOOL Enter(); - void Leave(); - BOOL Flush(SIZE_T dwNumberOfBytesToFlush); - void Finalize(); -}; - -class CicFileMapping : public CicFileMappingStatic -{ -public: - CicFileMapping(LPCTSTR pszName, CicMutex *pMutex); - virtual ~CicFileMapping() { Finalize(); } -}; - -/******************************************************************************/ - -inline CicFileMapping::CicFileMapping(LPCTSTR pszName, CicMutex *pMutex) { m_pszName = NULL; @@ -61,7 +19,7 @@ CicFileMapping::CicFileMapping(LPCTSTR pszName, CicMutex *pMutex) Init(pszName, pMutex); } -inline void CicFileMappingStatic::Close() +void CicFileMappingStatic::Close() { if (m_pView) { @@ -78,7 +36,7 @@ inline void CicFileMappingStatic::Close() m_bCreated = FALSE; } -inline void CicFileMappingStatic::Init(LPCTSTR pszName, CicMutex *pMutex) +void CicFileMappingStatic::Init(LPCTSTR pszName, CicMutex *pMutex) { if (pMutex) m_pMutex = pMutex; @@ -88,7 +46,7 @@ inline void CicFileMappingStatic::Init(LPCTSTR pszName, CicMutex *pMutex) m_bHasMutex = (pMutex != NULL); } -inline LPVOID +LPVOID CicFileMappingStatic::Create( LPSECURITY_ATTRIBUTES pSA, DWORD dwMaximumSizeLow, @@ -112,7 +70,7 @@ CicFileMappingStatic::Create( return _Map(); } -inline LPVOID CicFileMappingStatic::Open() +LPVOID CicFileMappingStatic::Open() { if (!m_pszName) return NULL; @@ -123,7 +81,7 @@ inline LPVOID CicFileMappingStatic::Open() return _Map(); } -inline LPVOID CicFileMappingStatic::_Map() +LPVOID CicFileMappingStatic::_Map() { m_pView = ::MapViewOfFile(m_hMapping, FILE_MAP_WRITE, 0, 0, 0); if (!m_pView) @@ -134,28 +92,28 @@ inline LPVOID CicFileMappingStatic::_Map() return m_pView; } -inline BOOL CicFileMappingStatic::Enter() +BOOL CicFileMappingStatic::Enter() { if (!m_bHasMutex) return TRUE; return m_pMutex->Enter(); } -inline void CicFileMappingStatic::Leave() +void CicFileMappingStatic::Leave() { if (!m_bHasMutex) return; m_pMutex->Leave(); } -inline BOOL CicFileMappingStatic::Flush(SIZE_T dwNumberOfBytesToFlush) +BOOL CicFileMappingStatic::Flush(SIZE_T dwNumberOfBytesToFlush) { if (!m_pView) return FALSE; return ::FlushViewOfFile(m_pView, dwNumberOfBytesToFlush); } -inline void CicFileMappingStatic::Finalize() +void CicFileMappingStatic::Finalize() { if (!m_bHasMutex) return; diff --git a/sdk/lib/cicero/cicfmap.h b/sdk/lib/cicero/cicfmap.h new file mode 100644 index 00000000000..4469f838910 --- /dev/null +++ b/sdk/lib/cicero/cicfmap.h @@ -0,0 +1,48 @@ +/* + * PROJECT: ReactOS Cicero + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Cicero file mapping + * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#pragma once + +#include "cicmutex.h" + +// class CicFileMappingStatic; +// class CicFileMapping; + +class CicFileMappingStatic +{ +protected: + LPCTSTR m_pszName; + LPVOID m_pView; + HANDLE m_hMapping; + BOOL m_bCreated; + BOOL m_bHasMutex; + CicMutex *m_pMutex; + + LPVOID _Map(); + +public: + CicFileMappingStatic() { } + ~CicFileMappingStatic() { } + + void Init(LPCTSTR pszName, CicMutex *pMutex); + + LPVOID Create(LPSECURITY_ATTRIBUTES pSA, DWORD dwMaximumSizeLow, LPBOOL pbAlreadyExists); + LPVOID Open(); + void Close(); + + BOOL Enter(); + void Leave(); + BOOL Flush(SIZE_T dwNumberOfBytesToFlush); + void Finalize(); +}; + +class CicFileMapping : public CicFileMappingStatic +{ +public: + CicFileMapping(LPCTSTR pszName, CicMutex *pMutex); + virtual ~CicFileMapping() { Finalize(); } +}; diff --git a/sdk/lib/cicero/cicimc.cpp b/sdk/lib/cicero/cicimc.cpp new file mode 100644 index 00000000000..41af20cdb81 --- /dev/null +++ b/sdk/lib/cicero/cicimc.cpp @@ -0,0 +1,53 @@ +/* + * PROJECT: ReactOS Cicero + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Locking and Unlocking IMC and IMCC handles + * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#include "precomp.h" +#include <imm.h> +#include <immdev.h> +#include <imm32_undoc.h> +#include "cicimc.h" + +#define CUSTOM_CAND_INFO_SIZE 1964 + +BOOL CicIMCLock::ClearCand() +{ + HIMCC hNewCandInfo, hCandInfo = m_pIC->hCandInfo; + if (hCandInfo) + { + hNewCandInfo = ImmReSizeIMCC(hCandInfo, CUSTOM_CAND_INFO_SIZE); + if (!hNewCandInfo) + { + ImmDestroyIMCC(m_pIC->hCandInfo); + m_pIC->hCandInfo = ImmCreateIMCC(CUSTOM_CAND_INFO_SIZE); + return FALSE; + } + } + else + { + hNewCandInfo = ImmCreateIMCC(CUSTOM_CAND_INFO_SIZE); + } + + m_pIC->hCandInfo = hNewCandInfo; + if (!m_pIC->hCandInfo) + return FALSE; + + CicIMCCLock<CANDIDATEINFO> candInfo(m_pIC->hCandInfo); + if (!candInfo) + { + ImmDestroyIMCC(m_pIC->hCandInfo); + m_pIC->hCandInfo = ImmCreateIMCC(CUSTOM_CAND_INFO_SIZE); + return FALSE; + } + + candInfo.get().dwSize = CUSTOM_CAND_INFO_SIZE; + candInfo.get().dwCount = 0; + candInfo.get().dwOffset[0] = sizeof(CANDIDATEINFO); + + // FIXME: Something is trailing after CANDIDATEINFO... + + return TRUE; +} diff --git a/sdk/include/reactos/cicero/cicimc.h b/sdk/lib/cicero/cicimc.h similarity index 77% rename from sdk/include/reactos/cicero/cicimc.h rename to sdk/lib/cicero/cicimc.h index 4f0e6c73e0a..779884abfdd 100644 --- a/sdk/include/reactos/cicero/cicimc.h +++ b/sdk/lib/cicero/cicimc.h @@ -183,44 +183,3 @@ protected: return ::ImmUnlockIMC(hIMC) ? S_OK : E_FAIL; } }; - -#define CUSTOM_CAND_INFO_SIZE 1964 - -inline BOOL CicIMCLock::ClearCand() -{ - HIMCC hNewCandInfo, hCandInfo = m_pIC->hCandInfo; - if (hCandInfo) - { - hNewCandInfo = ImmReSizeIMCC(hCandInfo, CUSTOM_CAND_INFO_SIZE); - if (!hNewCandInfo) - { - ImmDestroyIMCC(m_pIC->hCandInfo); - m_pIC->hCandInfo = ImmCreateIMCC(CUSTOM_CAND_INFO_SIZE); - return FALSE; - } - } - else - { - hNewCandInfo = ImmCreateIMCC(CUSTOM_CAND_INFO_SIZE); - } - - m_pIC->hCandInfo = hNewCandInfo; - if (!m_pIC->hCandInfo) - return FALSE; - - CicIMCCLock<CANDIDATEINFO> candInfo(m_pIC->hCandInfo); - if (!candInfo) - { - ImmDestroyIMCC(m_pIC->hCandInfo); - m_pIC->hCandInfo = ImmCreateIMCC(CUSTOM_CAND_INFO_SIZE); - return FALSE; - } - - candInfo.get().dwSize = CUSTOM_CAND_INFO_SIZE; - candInfo.get().dwCount = 0; - candInfo.get().dwOffset[0] = sizeof(CANDIDATEINFO); - - // FIXME: Something is trailing after CANDIDATEINFO... - - return TRUE; -} diff --git a/sdk/include/reactos/cicero/cicmutex.h b/sdk/lib/cicero/cicmutex.h similarity index 100% rename from sdk/include/reactos/cicero/cicmutex.h rename to sdk/lib/cicero/cicmutex.h diff --git a/sdk/lib/cicero/cicreg.cpp b/sdk/lib/cicero/cicreg.cpp new file mode 100644 index 00000000000..fff4a64a6a8 --- /dev/null +++ b/sdk/lib/cicero/cicreg.cpp @@ -0,0 +1,83 @@ +/* + * PROJECT: ReactOS Cicero + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Cicero registry handling + * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#include "precomp.h" +#include <cicreg.h> + +EXTERN_C LSTATUS +_cicRegKey_Open(CicRegKey& self, HKEY hKey, LPCTSTR lpSubKey, REGSAM samDesired) +{ + HKEY hNewKey; + LSTATUS error = ::RegOpenKeyEx(hKey, lpSubKey, 0, samDesired, &hNewKey); + if (error != ERROR_SUCCESS) + return error; + + self.Close(); + self.m_hKey = hNewKey; + return error; +} + +EXTERN_C LSTATUS +_cicRegKey_Create(CicRegKey& self, HKEY hKey, LPCTSTR lpSubKey) +{ + HKEY hNewKey; + LSTATUS error = ::RegCreateKeyEx(hKey, lpSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, NULL, &hNewKey, NULL); + if (error != ERROR_SUCCESS) + return error; + + self.Close(); + self.m_hKey = hNewKey; + return error; +} + +EXTERN_C LSTATUS +_cicRegKey_EnumValue(CicRegKey& self, DWORD dwIndex, LPTSTR lpValueName, DWORD cchValueName) +{ + DWORD dwSaveLen = cchValueName; + LSTATUS error = ::RegEnumValue(self.m_hKey, dwIndex, lpValueName, &cchValueName, + NULL, NULL, NULL, NULL); + if (dwSaveLen) + lpValueName[error == ERROR_SUCCESS ? dwSaveLen - 1 : 0] = 0; + return error; +} + +EXTERN_C LSTATUS +_cicRegKey_QuerySz(CicRegKey& self, LPCTSTR pszValueName, LPTSTR pszValue, DWORD cchValueMax) +{ + DWORD cbValueMax = cchValueMax * sizeof(TCHAR); + LSTATUS error = ::RegQueryValueEx(self.m_hKey, pszValueName, 0, NULL, (LPBYTE)pszValue, &cbValueMax); + if (cchValueMax > 0) + pszValue[(error == ERROR_SUCCESS) ? (cchValueMax - 1) : 0] = UNICODE_NULL; + return error; +} + +EXTERN_C LSTATUS +_cicRegKey_RecurseDeleteKey(CicRegKey& self, LPCTSTR lpSubKey) +{ + CicRegKey regKey; + LSTATUS error = regKey.Open(self.m_hKey, lpSubKey, KEY_READ | KEY_WRITE); + if (error != ERROR_SUCCESS) + return error; + + TCHAR szName[MAX_PATH]; + DWORD cchName; + do + { + cchName = _countof(szName); + error = ::RegEnumKeyEx(regKey, 0, szName, &cchName, NULL, NULL, NULL, NULL); + if (error != ERROR_SUCCESS) + break; + + szName[_countof(szName) - 1] = UNICODE_NULL; + error = regKey.RecurseDeleteKey(szName); + } while (error == ERROR_SUCCESS); + + regKey.Close(); + + return self.DeleteSubKey(lpSubKey); +} diff --git a/sdk/lib/cicero/cicreg.h b/sdk/lib/cicero/cicreg.h new file mode 100644 index 00000000000..aaf6619fb88 --- /dev/null +++ b/sdk/lib/cicero/cicreg.h @@ -0,0 +1,116 @@ +/* + * PROJECT: ReactOS Cicero + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Cicero registry handling + * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#pragma once + +class CicRegKey +{ +public: + HKEY m_hKey; + + CicRegKey() : m_hKey(NULL) { } + ~CicRegKey() { Close(); } + + operator HKEY() { return m_hKey; } + + LSTATUS Open(HKEY hKey, LPCTSTR lpSubKey, REGSAM samDesired = KEY_READ); + LSTATUS Create(HKEY hKey, LPCTSTR lpSubKey); + void Close(); + + LSTATUS QueryDword(LPCTSTR pszValueName, LPDWORD pdwValue); + LSTATUS SetDword(LPCTSTR pszValueName, DWORD dwValue); + + LSTATUS QuerySz(LPCTSTR pszValueName, LPTSTR pszValue, DWORD cchValueMax); + LSTATUS SetSz(LPCTSTR pszValueName, LPCTSTR pszValue); + LSTATUS SetSzW(LPCWSTR pszValueName, LPCWSTR pszValue); + + LSTATUS DeleteValue(LPCTSTR pszValueName); + LSTATUS DeleteSubKey(LPCTSTR lpSubKey); + LSTATUS RecurseDeleteKey(LPCTSTR lpSubKey); + + LSTATUS EnumValue(DWORD dwIndex, LPTSTR lpValueName, DWORD cchValueName); +}; + +/***********************************************************************/ + +// FIXME: Here, directly using C++ methods causes compile errors... Why? +EXTERN_C LSTATUS _cicRegKey_Open(CicRegKey& self, HKEY hKey, LPCTSTR lpSubKey, REGSAM samDesired); +EXTERN_C LSTATUS _cicRegKey_Create(CicRegKey& self, HKEY hKey, LPCTSTR lpSubKey); +EXTERN_C LSTATUS _cicRegKey_RecurseDeleteKey(CicRegKey& self, LPCTSTR lpSubKey); + +EXTERN_C LSTATUS +_cicRegKey_EnumValue(CicRegKey& self, DWORD dwIndex, LPTSTR lpValueName, DWORD cchValueName); + +EXTERN_C LSTATUS +_cicRegKey_QuerySz(CicRegKey& self, LPCTSTR pszValueName, LPTSTR pszValue, DWORD cchValueMax); + +inline LSTATUS CicRegKey::Open(HKEY hKey, LPCTSTR lpSubKey, REGSAM samDesired) +{ + return _cicRegKey_Open(*this, hKey, lpSubKey, samDesired); +} + +inline LSTATUS CicRegKey::Create(HKEY hKey, LPCTSTR lpSubKey) +{ + return _cicRegKey_Create(*this, hKey, lpSubKey); +} + +inline LSTATUS CicRegKey::QueryDword(LPCTSTR pszValueName, LPDWORD pdwValue) +{ + DWORD cbData = sizeof(DWORD); + return ::RegQueryValueEx(m_hKey, pszValueName, 0, NULL, (LPBYTE)pdwValue, &cbData); +} + +inline LSTATUS CicRegKey::SetDword(LPCTSTR pszValueName, DWORD dwValue) +{ + return ::RegSetValueEx(m_hKey, pszValueName, 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(dwValue)); +} + +inline LSTATUS CicRegKey::SetSz(LPCTSTR pszValueName, LPCTSTR pszValue) +{ + DWORD cbValue = (lstrlen(pszValue) + 1) * sizeof(TCHAR); + return ::RegSetValueEx(m_hKey, pszValueName, 0, REG_SZ, (LPBYTE)pszValue, cbValue); +} + +inline LSTATUS CicRegKey::SetSzW(LPCWSTR pszValueName, LPCWSTR pszValue) +{ + DWORD cbValue = (lstrlenW(pszValue) + 1) * sizeof(WCHAR); + return ::RegSetValueExW(m_hKey, pszValueName, 0, REG_SZ, (LPBYTE)pszValue, cbValue); +} + +inline LSTATUS CicRegKey::QuerySz(LPCTSTR pszValueName, LPTSTR pszValue, DWORD cchValueMax) +{ + return _cicRegKey_QuerySz(*this, pszValueName, pszValue, cchValueMax); +} + +inline void CicRegKey::Close() +{ + if (!m_hKey) + return; + + ::RegCloseKey(m_hKey); + m_hKey = NULL; +} + +inline LSTATUS CicRegKey::DeleteValue(LPCTSTR pszValueName) +{ + return ::RegDeleteValue(m_hKey, pszValueName); +} + +inline LSTATUS CicRegKey::DeleteSubKey(LPCTSTR lpSubKey) +{ + return ::RegDeleteKey(m_hKey, lpSubKey); +} + +inline LSTATUS CicRegKey::EnumValue(DWORD dwIndex, LPTSTR lpValueName, DWORD cchValueName) +{ + return _cicRegKey_EnumValue(*this, dwIndex, lpValueName, cchValueName); +} + +inline LSTATUS CicRegKey::RecurseDeleteKey(LPCTSTR lpSubKey) +{ + return _cicRegKey_RecurseDeleteKey(*this, lpSubKey); +} diff --git a/sdk/include/reactos/cicero/cictf.h b/sdk/lib/cicero/cictf.h similarity index 100% rename from sdk/include/reactos/cicero/cictf.h rename to sdk/lib/cicero/cictf.h diff --git a/sdk/include/reactos/cicero/cicuif.h b/sdk/lib/cicero/cicuif.cpp similarity index 72% rename from sdk/include/reactos/cicero/cicuif.h rename to sdk/lib/cicero/cicuif.cpp index 126e22e9e74..322058e1ad3 100644 --- a/sdk/include/reactos/cicero/cicuif.h +++ b/sdk/lib/cicero/cicuif.cpp @@ -5,1155 +5,38 @@ * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> */ -#pragma once - -#include "cicarray.h" - -// This is Cicero UIF Library to support the IME UI interface. -// Cicero UIF Library implements some GUI parts for IMEs and Language Bar. -// The GUI parts of UIF Library requires special handling because: -// -// 1. To avoid interfering with IME input, the GUI part should not receive focus. -// 2. The IME popup window has WS_DISABLED style, so it cannot receive mouse messages -// directly. - -class CUIFSystemInfo; -class CUIFTheme; - class CUIFObject; - class CUIFWindow; - class CUIFToolTip; - class CUIFShadow; - class CUIFBalloonWindow; - class CUIFMenu; - class CUIFButton; - class CUIFButton2; - class CUIFToolbarMenuButton; - class CUIFToolbarButtonElement; - class CUIFBalloonButton; - class CUIFToolbarButton; - class CUIFWndFrame; - class CUIFGripper; - class CUIFMenuItem; - class CUIFMenuItemSeparator; -class CUIFObjectArray; -class CUIFColorTable; - class CUIFColorTableSys; - class CUIFColorTableOff10; -class CUIFBitmapDC; -class CUIFIcon; -class CUIFSolidBrush; -class CUIFScheme; +#include "precomp.h" +#include "cicuif.h" ///////////////////////////////////////////////////////////////////////////// - -class CUIFSystemInfo : OSVERSIONINFO -{ -public: - static CUIFSystemInfo *s_pSystemInfo; - DWORD m_cBitsPixels; - BOOL m_bHighContrast1; - BOOL m_bHighContrast2; - - CUIFSystemInfo() { } - void GetSystemMetrics(); - void Initialize(); -}; - -DECLSPEC_SELECTANY CUIFSystemInfo *CUIFSystemInfo::s_pSystemInfo = NULL; - -void cicInitUIFSys(void); -void cicDoneUIFSys(void); -void cicUpdateUIFSys(void); - -inline void cicGetWorkAreaRect(POINT pt, LPRECT prc) -{ - ::SystemParametersInfo(SPI_GETWORKAREA, 0, prc, 0); - - HMONITOR hMon = ::MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); - if (hMon) - { - MONITORINFO mi = { sizeof(mi) }; - if (::GetMonitorInfo(hMon, &mi)) - *prc = mi.rcWork; - } -} - -///////////////////////////////////////////////////////////////////////////// - -#include <uxtheme.h> -#include <vsstyle.h> - -// uxtheme.dll -using FN_OpenThemeData = decltype(&OpenThemeData); -using FN_CloseThemeData = decltype(&CloseThemeData); -using FN_DrawThemeBackground = decltype(&DrawThemeBackground); -using FN_DrawThemeParentBackground = decltype(&DrawThemeParentBackground); -using FN_DrawThemeText = decltype(&DrawThemeText); -using FN_DrawThemeIcon = decltype(&DrawThemeIcon); -using FN_GetThemeBackgroundExtent = decltype(&GetThemeBackgroundExtent); -using FN_GetThemeBackgroundContentRect = decltype(&GetThemeBackgroundContentRect); -using FN_GetThemeTextExtent = decltype(&GetThemeTextExtent); -using FN_GetThemePartSize = decltype(&GetThemePartSize); -using FN_DrawThemeEdge = decltype(&DrawThemeEdge); -using FN_GetThemeColor = decltype(&GetThemeColor); -using FN_GetThemeMargins = decltype(&GetThemeMargins); -using FN_GetThemeFont = decltype(&GetThemeFont); -using FN_GetThemeSysColor = decltype(&GetThemeSysColor); -using FN_GetThemeSysSize = decltype(&GetThemeSysSize); - -///////////////////////////////////////////////////////////////////////////// - -class CUIFTheme -{ -public: - LPCWSTR m_pszClassList; - INT m_iPartId; - INT m_iStateId; - HTHEME m_hTheme; - static HINSTANCE s_hUXTHEME; - static FN_OpenThemeData s_fnOpenThemeData; - static FN_CloseThemeData s_fnCloseThemeData; - static FN_DrawThemeBackground s_fnDrawThemeBackground; - static FN_DrawThemeParentBackground s_fnDrawThemeParentBackground; - static FN_DrawThemeText s_fnDrawThemeText; - static FN_DrawThemeIcon s_fnDrawThemeIcon; - static FN_GetThemeBackgroundExtent s_fnGetThemeBackgroundExtent; - static FN_GetThemeBackgroundContentRect s_fnGetThemeBackgroundContentRect; - static FN_GetThemeTextExtent s_fnGetThemeTextExtent; - static FN_GetThemePartSize s_fnGetThemePartSize; - static FN_DrawThemeEdge s_fnDrawThemeEdge; - static FN_GetThemeColor s_fnGetThemeColor; - static FN_GetThemeMargins s_fnGetThemeMargins; - static FN_GetThemeFont s_fnGetThemeFont; - static FN_GetThemeSysColor s_fnGetThemeSysColor; - static FN_GetThemeSysSize s_fnGetThemeSysSize; - - HRESULT InternalOpenThemeData(HWND hWnd); - HRESULT EnsureThemeData(HWND hWnd); - HRESULT CloseThemeData(); - - STDMETHOD(DrawThemeBackground)(HDC hDC, int iStateId, LPCRECT pRect, LPCRECT pClipRect); - STDMETHOD(DrawThemeParentBackground)(HWND hwnd, HDC hDC, LPRECT prc); - STDMETHOD(DrawThemeText)(HDC hDC, int iStateId, LPCWSTR pszText, int cchText, DWORD dwTextFlags, DWORD dwTextFlags2, LPCRECT pRect); - STDMETHOD(DrawThemeIcon)(HDC hDC, int iStateId, LPCRECT pRect, HIMAGELIST himl, int iImageIndex); - STDMETHOD(GetThemeBackgroundExtent)(HDC hDC, int iStateId, LPCRECT pContentRect, LPRECT pExtentRect); - STDMETHOD(GetThemeBackgroundContentRect)(HDC hDC, int iStateId, LPCRECT pBoundingRect, LPRECT pContentRect); - STDMETHOD(GetThemeTextExtent)(HDC hDC, int iStateId, LPCWSTR pszText, int cchCharCount, DWORD dwTextFlags, LPCRECT pBoundingRect, LPRECT pExtentRect); - STDMETHOD(GetThemePartSize)(HDC hDC, int iStateId, LPRECT prc, THEMESIZE eSize, SIZE *psz); - STDMETHOD(DrawThemeEdge)(HDC hDC, int iStateId, LPCRECT pDestRect, UINT uEdge, UINT uFlags, LPRECT pContentRect); - STDMETHOD(GetThemeColor)(int iStateId, int iPropId, COLORREF *pColor); - STDMETHOD(GetThemeMargins)(HDC hDC, int iStateId, int iPropId, LPRECT prc, MARGINS *pMargins); - STDMETHOD(GetThemeFont)(HDC hDC, int iStateId, int iPropId, LOGFONTW *pFont); - STDMETHOD_(COLORREF, GetThemeSysColor)(INT iColorId); - STDMETHOD_(int, GetThemeSysSize)(int iSizeId); - STDMETHOD_(void, SetActiveTheme)(LPCWSTR pszClassList, INT iPartId, INT iStateId); -}; - // static members -DECLSPEC_SELECTANY HINSTANCE CUIFTheme::s_hUXTHEME = NULL; -DECLSPEC_SELECTANY FN_OpenThemeData CUIFTheme::s_fnOpenThemeData = NULL; -DECLSPEC_SELECTANY FN_CloseThemeData CUIFTheme::s_fnCloseThemeData = NULL; -DECLSPEC_SELECTANY FN_DrawThemeBackground CUIFTheme::s_fnDrawThemeBackground = NULL; -DECLSPEC_SELECTANY FN_DrawThemeParentBackground CUIFTheme::s_fnDrawThemeParentBackground = NULL; -DECLSPEC_SELECTANY FN_DrawThemeText CUIFTheme::s_fnDrawThemeText = NULL; -DECLSPEC_SELECTANY FN_DrawThemeIcon CUIFTheme::s_fnDrawThemeIcon = NULL; -DECLSPEC_SELECTANY FN_GetThemeBackgroundExtent CUIFTheme::s_fnGetThemeBackgroundExtent = NULL; -DECLSPEC_SELECTANY FN_GetThemeBackgroundContentRect CUIFTheme::s_fnGetThemeBackgroundContentRect = NULL; -DECLSPEC_SELECTANY FN_GetThemeTextExtent CUIFTheme::s_fnGetThemeTextExtent = NULL; -DECLSPEC_SELECTANY FN_GetThemePartSize CUIFTheme::s_fnGetThemePartSize = NULL; -DECLSPEC_SELECTANY FN_DrawThemeEdge CUIFTheme::s_fnDrawThemeEdge = NULL; -DECLSPEC_SELECTANY FN_GetThemeColor CUIFTheme::s_fnGetThemeColor = NULL; -DECLSPEC_SELECTANY FN_GetThemeMargins CUIFTheme::s_fnGetThemeMargins = NULL; -DECLSPEC_SELECTANY FN_GetThemeFont CUIFTheme::s_fnGetThemeFont = NULL; -DECLSPEC_SELECTANY FN_GetThemeSysColor CUIFTheme::s_fnGetThemeSysColor = NULL; -DECLSPEC_SELECTANY FN_GetThemeSysSize CUIFTheme::s_fnGetThemeSysSize = NULL; - -///////////////////////////////////////////////////////////////////////////// - -class CUIFObjectArray : public CicArray<CUIFObject*> -{ -public: - CUIFObjectArray() { } - - BOOL Add(CUIFObject *pObject) - { - if (!pObject || Find(pObject) >= 0) - return FALSE; - - CUIFObject **ppNew = Append(1); - if (!ppNew) - return FALSE; - - *ppNew = pObject; - return TRUE; - } - - BOOL Remove(CUIFObject *pObject) - { - if (!pObject) - return FALSE; - - ssize_t iItem = Find(pObject); - if (iItem < 0) - return FALSE; - - if (size_t(iItem) + 1 < size()) - MoveMemory(&data()[iItem], &data()[iItem + 1], - (size() - (iItem + 1)) * sizeof(CUIFObject*)); - - --m_cItems; - return TRUE; - } - - CUIFObject *GetLast() const - { - if (empty()) - return NULL; - return (*this)[size() - 1]; - } -}; - -///////////////////////////////////////////////////////////////////////////// - -class CUIFObject : public CUIFTheme -{ -protected: - CUIFObject *m_pParent; - CUIFWindow *m_pWindow; - CUIFScheme *m_pScheme; - CUIFObjectArray m_ObjectArray; - DWORD m_nObjectID; - DWORD m_style; - RECT m_rc; - BOOL m_bEnable; - BOOL m_bVisible; - HFONT m_hFont; - BOOL m_bHasCustomFont; - LPWSTR m_pszToolTip; - DWORD m_dwUnknown4[2]; //FIXME: name and type - friend class CUIFWindow; - friend class CUIFToolTip; - friend class CUIFBalloonWindow; - -public: - CUIFObject(CUIFObject *pParent, DWORD nObjectID, LPCRECT prc, DWORD style); - virtual ~CUIFObject(); - - void StartCapture(); - void EndCapture(); - BOOL IsCapture(); - BOOL IsRTL(); - LRESULT NotifyCommand(WPARAM wParam, LPARAM lParam); - CUIFObject* ObjectFromPoint(POINT pt); - void SetScheme(CUIFScheme *scheme); - void StartTimer(WPARAM wParam); - void EndTimer(); - - STDMETHOD_(BOOL, Initialize)() { return TRUE; } - STDMETHOD_(void, OnPaint)(HDC hDC); - STDMETHOD_(void, OnTimer)() { } - STDMETHOD_(void, OnLButtonDown)(LONG x, LONG y) { } - STDMETHOD_(void, OnMButtonDown)(LONG x, LONG y) { } - STDMETHOD_(void, OnRButtonDown)(LONG x, LONG y) { } - STDMETHOD_(void, OnLButtonUp)(LONG x, LONG y) { } - STDMETHOD_(void, OnMButtonUp)(LONG x, LONG y) { } - STDMETHOD_(void, OnRButtonUp)(LONG x, LONG y) { } - STDMETHOD_(void, OnMouseMove)(LONG x, LONG y) { } - STDMETHOD_(void, OnMouseIn)(LONG x, LONG y) { } - STDMETHOD_(void, OnMouseOut)(LONG x, LONG y) { } - STDMETHOD_(BOOL, OnSetCursor)(UINT uMsg, LONG x, LONG y); - STDMETHOD_(void, GetRect)(LPRECT prc); - STDMETHOD_(void, SetRect)(LPCRECT prc); - STDMETHOD_(BOOL, PtInObject)(POINT pt); - STDMETHOD_(void, PaintObject)(HDC hDC, LPCRECT prc); - STDMETHOD_(void, CallOnPaint)(); - STDMETHOD_(void, Enable)(BOOL bEnable); - STDMETHOD_(void, Show)(BOOL bVisible); - STDMETHOD_(void, SetFontToThis)(HFONT hFont); - STDMETHOD_(void, SetFont)(HFONT hFont); - STDMETHOD_(void, SetStyle)(DWORD style); - STDMETHOD_(void, AddUIObj)(CUIFObject *pObject); - STDMETHOD_(void, RemoveUIObj)(CUIFObject *pObject); - STDMETHOD_(LRESULT, OnObjectNotify)(CUIFObject *pObject, WPARAM wParam, LPARAM lParam); - STDMETHOD_(void, SetToolTip)(LPCWSTR pszToolTip); - STDMETHOD_(LPCWSTR, GetToolTip)() { return m_pszToolTip; } - STDMETHOD_(LRESULT, OnShowToolTip)() { return 0; } - STDMETHOD_(void, OnHideToolTip)() { } - STDMETHOD_(void, DetachWndObj)(); - STDMETHOD_(void, ClearWndObj)(); - STDMETHOD_(BOOL, OnPaintTheme)(HDC hDC) { return FALSE; } - STDMETHOD_(void, OnPaintNoTheme)(HDC hDC) { } - STDMETHOD_(void, ClearTheme)(); -}; -///////////////////////////////////////////////////////////////////////////// - -class CUIFColorTable -{ -public: - CUIFColorTable() { } - virtual ~CUIFColorTable() { } - - STDMETHOD_(void, InitColor)() = 0; - STDMETHOD_(void, DoneColor)() { } - STDMETHOD_(void, InitBrush)() = 0; - STDMETHOD_(void, DoneBrush)() = 0; - - void Update() - { - DoneColor(); - DoneBrush(); - InitColor(); - InitBrush(); - } -}; - -class CUIFColorTableSys : public CUIFColorTable -{ -protected: - COLORREF m_rgbColors[16]; - HBRUSH m_hBrushes[16]; - -public: - CUIFColorTableSys() { } - - COLORREF GetColor(INT iColor) const { return m_rgbColors[iColor]; } - HBRUSH GetBrush(INT iColor); - - STDMETHOD_(void, InitColor)() override; - STDMETHOD_(void, InitBrush)() override; - STDMETHOD_(void, DoneBrush)() override; -}; - -class CUIFColorTableOff10 : public CUIFColorTable -{ -protected: - COLORREF m_rgbColors[32]; - HBRUSH m_hBrushes[32]; - -public: - CUIFColorTableOff10() { } - - COLORREF GetColor(INT iColor) const { return m_rgbColors[iColor]; } - HBRUSH GetBrush(INT iColor); - - STDMETHOD_(void, InitColor)() override; - STDMETHOD_(void, InitBrush)() override; - STDMETHOD_(void, DoneBrush)() override; -}; - -///////////////////////////////////////////////////////////////////////////// - -class CUIFSolidBrush -{ -public: - HBRUSH m_hBrush; - - operator HBRUSH() const { return m_hBrush; } - - CUIFSolidBrush(COLORREF rgbColor) - { - m_hBrush = ::CreateSolidBrush(rgbColor); - } - ~CUIFSolidBrush() - { - if (m_hBrush) - { - ::DeleteObject(m_hBrush); - m_hBrush = NULL; - } - } -}; - -///////////////////////////////////////////////////////////////////////////// - -class CUIFIcon -{ -public: - HICON m_hIcon; - HIMAGELIST m_hImageList; - - CUIFIcon& operator=(HICON hIcon) - { - m_hIcon = hIcon; - if (m_hImageList) - { - ImageList_Destroy(m_hImageList); - m_hImageList = NULL; - } - return *this; - } - - HIMAGELIST GetImageList(BOOL bMirror); -}; - -BOOL cicGetIconSize(HICON hIcon, LPSIZE pSize); - -///////////////////////////////////////////////////////////////////////////// - -class CUIFBitmapDC -{ -protected: - HBITMAP m_hBitmap; - HGDIOBJ m_hOldBitmap; - HGDIOBJ m_hOldObject; - HDC m_hDC; - -public: - static BOOL s_fInitBitmapDCs; - static CUIFBitmapDC *s_phdcSrc; - static CUIFBitmapDC *s_phdcMask; - static CUIFBitmapDC *s_phdcDst; - - CUIFBitmapDC(BOOL bMemory); - ~CUIFBitmapDC(); - operator HDC() const { return m_hDC; } - - void Uninit(BOOL bKeep = FALSE); - - BOOL SetBitmap(HBITMAP hBitmap); - BOOL SetBitmap(LONG cx, LONG cy, WORD cPlanes, WORD cBitCount); - BOOL SetDIB(LONG cx, LONG cy, WORD cPlanes, WORD cBitCount); - - HBITMAP DetachBitmap() - { - HBITMAP hOldBitmap = m_hBitmap; - m_hBitmap = NULL; - return hOldBitmap; - } -}; - -DECLSPEC_SELECTANY BOOL CUIFBitmapDC::s_fInitBitmapDCs = FALSE; -DECLSPEC_SELECTANY CUIFBitmapDC *CUIFBitmapDC::s_phdcSrc = NULL; -DECLSPEC_SELECTANY CUIFBitmapDC *CUIFBitmapDC::s_phdcMask = NULL; -DECLSPEC_SELECTANY CUIFBitmapDC *CUIFBitmapDC::s_phdcDst = NULL; - -void cicInitUIFUtil(void); -void cicDoneUIFUtil(void); - -HBITMAP cicMirrorBitmap(HBITMAP hBitmap, HBRUSH hbrBack); -HBRUSH cicCreateDitherBrush(VOID); -HBITMAP cicCreateDisabledBitmap(LPCRECT prc, HBITMAP hbmMask, HBRUSH hbr1, HBRUSH hbr2, - BOOL bPressed); -HBITMAP cicCreateShadowMaskBmp(LPRECT prc, HBITMAP hbm1, HBITMAP hbm2, HBRUSH hbr1, HBRUSH hbr2); -HBITMAP cicChangeBitmapColor(LPCRECT prc, HBITMAP hbm, COLORREF rgbBack, COLORREF rgbFore); -HBITMAP cicConvertBlackBKGBitmap(LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, HBRUSH hBrush); -HBITMAP cicCreateMaskBmp(LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, HBRUSH hbr, - COLORREF rgbColor, COLORREF rgbBack); -BOOL cicGetIconBitmaps(HICON hIcon, HBITMAP *hbm1, HBITMAP *hbm2, const SIZE *pSize); -void cicDrawMaskBmpOnDC(HDC hDC, LPCRECT prc, HBITMAP hbmp, HBITMAP hbmpMask); - -///////////////////////////////////////////////////////////////////////////// - -// Flags for dwDrawFlags -enum -{ - UIF_DRAW_PRESSED = 0x10, - UIF_DRAW_DISABLED = 0x20, -}; - -class CUIFScheme -{ -public: - static CUIFColorTableSys *s_pColorTableSys; - static CUIFColorTableOff10 *s_pColorTableOff10; - BOOL m_bMirroring; - - CUIFScheme() : m_bMirroring(FALSE) { } - virtual ~CUIFScheme() { } - - STDMETHOD_(DWORD, GetType)() = 0; - STDMETHOD_(COLORREF, GetColor)(INT iColor) = 0; - STDMETHOD_(HBRUSH, GetBrush)(INT iColor) = 0; - STDMETHOD_(INT, CyMenuItem)(INT cyText) = 0; - STDMETHOD_(INT, CxSizeFrame)() = 0; - STDMETHOD_(INT, CySizeFrame)() = 0; - STDMETHOD_(INT, CxWndBorder)() = 0; - STDMETHOD_(INT, CyWndBorder)() = 0; - STDMETHOD_(void, FillRect)(HDC hDC, LPCRECT prc, INT iColor); - STDMETHOD_(void, FrameRect)(HDC hDC, LPCRECT prc, INT iColor); - STDMETHOD_(void, DrawSelectionRect)(HDC hDC, LPCRECT prc, int) = 0; - STDMETHOD_(void, GetCtrlFaceOffset)(DWORD, DWORD dwDrawFlags, LPSIZE pSize) = 0; - STDMETHOD_(void, DrawCtrlBkgd)(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) = 0; - STDMETHOD_(void, DrawCtrlEdge)(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) = 0; - STDMETHOD_(void, DrawCtrlText)(HDC hDC, LPCRECT prc, LPCWSTR pszText, INT cchText, DWORD dwDrawFlags, BOOL bRight) = 0; - STDMETHOD_(void, DrawCtrlIcon)(HDC hDC, LPCRECT prc, HICON hIcon, DWORD dwDrawFlags, LPSIZE pSize) = 0; - STDMETHOD_(void, DrawCtrlBitmap)(HDC hDC, LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, DWORD dwDrawFlags) = 0; - STDMETHOD_(void, DrawMenuBitmap)(HDC hDC, LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, DWORD dwDrawFlags) = 0; - STDMETHOD_(void, DrawMenuSeparator)(HDC hDC, LPCRECT prc) = 0; - STDMETHOD_(void, DrawFrameCtrlBkgd)(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) = 0; - STDMETHOD_(void, DrawFrameCtrlEdge)(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) = 0; - STDMETHOD_(void, DrawFrameCtrlIcon)(HDC hDC, LPCRECT prc, HICON hIcon, DWORD dwDrawFlags, LPSIZE pSize) = 0; - STDMETHOD_(void, DrawFrameCtrlBitmap)(HDC hDC, LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, DWORD dwDrawFlags) = 0; - STDMETHOD_(void, DrawWndFrame)(HDC hDC, LPCRECT prc, DWORD type, DWORD unused1, DWORD unused2) = 0; - STDMETHOD_(void, DrawDragHandle)(HDC hDC, LPCRECT prc, BOOL bVertical) = 0; - STDMETHOD_(void, DrawSeparator)(HDC hDC, LPCRECT prc, BOOL bVertical) = 0; -}; - -class CUIFSchemeDef : public CUIFScheme -{ -protected: - DWORD m_dwType; - -public: - CUIFSchemeDef(DWORD dwType) : m_dwType(dwType) { } - - STDMETHOD_(DWORD, GetType)() override; - STDMETHOD_(COLORREF, GetColor)(INT iColor) override; - STDMETHOD_(HBRUSH, GetBrush)(INT iColor) override; - STDMETHOD_(INT, CyMenuItem)(INT cyText) override; - STDMETHOD_(INT, CxSizeFrame)() override; - STDMETHOD_(INT, CySizeFrame)() override; - STDMETHOD_(INT, CxWndBorder)() override { return 1; } - STDMETHOD_(INT, CyWndBorder)() override { return 1; } - STDMETHOD_(void, DrawSelectionRect)(HDC hDC, LPCRECT prc, int) override; - STDMETHOD_(void, GetCtrlFaceOffset)(DWORD dwUnknownFlags, DWORD dwDrawFlags, LPSIZE pSize) override; - STDMETHOD_(void, DrawCtrlBkgd)(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) override; - STDMETHOD_(void, DrawCtrlEdge)(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) override; - STDMETHOD_(void, DrawCtrlText)(HDC hDC, LPCRECT prc, LPCWSTR pszText, INT cchText, DWORD dwDrawFlags, BOOL bRight) override; - STDMETHOD_(void, DrawCtrlIcon)(HDC hDC, LPCRECT prc, HICON hIcon, DWORD dwDrawFlags, LPSIZE pSize) override; - STDMETHOD_(void, DrawCtrlBitmap)(HDC hDC, LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, DWORD dwDrawFlags) override; - STDMETHOD_(void, DrawMenuBitmap)(HDC hDC, LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, DWORD dwDrawFlags) override; - STDMETHOD_(void, DrawMenuSeparator)(HDC hDC, LPCRECT prc) override; - STDMETHOD_(void, DrawFrameCtrlBkgd)(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) override; - STDMETHOD_(void, DrawFrameCtrlEdge)(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) override; - STDMETHOD_(void, DrawFrameCtrlIcon)(HDC hDC, LPCRECT prc, HICON hIcon, DWORD dwDrawFlags, LPSIZE pSize) override; - STDMETHOD_(void, DrawFrameCtrlBitmap)(HDC hDC, LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, DWORD dwDrawFlags) override; - STDMETHOD_(void, DrawWndFrame)(HDC hDC, LPCRECT prc, DWORD type, DWORD unused1, DWORD unused2) override; - STDMETHOD_(void, DrawDragHandle)(HDC hDC, LPCRECT prc, BOOL bVertical) override; - STDMETHOD_(void, DrawSeparator)(HDC hDC, LPCRECT prc, BOOL bVertical) override; -}; - -DECLSPEC_SELECTANY CUIFColorTableSys *CUIFScheme::s_pColorTableSys = NULL; -DECLSPEC_SELECTANY CUIFColorTableOff10 *CUIFScheme::s_pColorTableOff10 = NULL; - -void cicInitUIFScheme(void); -void cicUpdateUIFScheme(void); -void cicDoneUIFScheme(void); -CUIFScheme *cicCreateUIFScheme(DWORD type); - -///////////////////////////////////////////////////////////////////////////// - -// m_style flags for CUIFWindow -enum -{ - UIF_WINDOW_CHILD = 0x1, - UIF_WINDOW_TOPMOST = 0x2, - UIF_WINDOW_TOOLWINDOW = 0x4, - UIF_WINDOW_DLGFRAME = 0x8, - UIF_WINDOW_TOOLTIP = 0x20, - UIF_WINDOW_SHADOW = 0x40, - UIF_WINDOW_WORKAREA = 0x80, - UIF_WINDOW_MONITOR = 0x100, - UIF_WINDOW_LAYOUTRTL = 0x200, - UIF_WINDOW_NOMOUSEMSG = 0x400, - UIF_WINDOW_USESCHEME1 = 0x10000000, - UIF_WINDOW_USESCHEME2 = 0x20000000, - UIF_WINDOW_USESCHEME3 = 0x40000000, - UIF_WINDOW_ENABLETHEMED = 0x80000000, -}; - -class CUIFWindow : public CUIFObject -{ -protected: - INT m_nLeft; - INT m_nTop; - INT m_nHeight; - INT m_nWidth; - HINSTANCE m_hInst; - HWND m_hWnd; - CUIFObject *m_pTimerObject; - CUIFObject *m_pCaptured; - CUIFObject *m_pPointed; - BOOL m_bPointing; - CUIFWindow *m_pBehindModal; - CUIFToolTip *m_pToolTip; - CUIFShadow *m_pShadow; - BOOL m_bShowShadow; - friend class CUIFObject; - friend class CUIFShadow; - friend class CUIFToolTip; - friend class CUIFButton; - friend class CUIFMenu; - -public: - enum { POINTING_TIMER_ID = 0x7982, USER_TIMER_ID = 0x5461 }; - operator HWND() const { return m_hWnd; } - CUIFWindow(HINSTANCE hInst, DWORD style); - ~CUIFWindow() override; - - static CUIFWindow* GetThis(HWND hWnd); - static void SetThis(HWND hWnd, LONG_PTR dwNewLong); - - STDMETHOD_(BOOL, Initialize)() override; - STDMETHOD_(void, Show)(BOOL bVisible) override; - STDMETHOD_(void, SetRect)(LPCRECT prc) override; - STDMETHOD_(void, PaintObject)(HDC hDC, LPCRECT prc) override; - STDMETHOD_(void, RemoveUIObj)(CUIFObject *pRemove) override; - - void SetCaptureObject(CUIFObject *pCaptured); - void SetObjectPointed(CUIFObject *pPointed, POINT pt); - void CreateScheme(); - BOOL GetWorkArea(LPCRECT prcWnd, LPRECT prcWorkArea); - void AdjustWindowPosition(); - void SetBehindModal(CUIFWindow *pBehindModal); - void SetTimerObject(CUIFObject *pTimerObject, UINT uElapse); - - static LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - - STDMETHOD_(LPCTSTR, GetClassName)() { return TEXT("CiceroUIWndFrame"); } - STDMETHOD_(LPCTSTR, GetWndTitle)() { return TEXT("CiceroUIWndFrame"); } - STDMETHOD_(DWORD, GetWndStyle)(); - STDMETHOD_(DWORD, GetWndStyleEx)(); - STDMETHOD_(HWND, CreateWnd)(HWND hwndParent); - STDMETHOD_(void, Move)(INT x, INT y, INT nWidth, INT nHeight); - STDMETHOD_(BOOL, AnimateWnd)(DWORD dwTime, DWORD dwFlags); - STDMETHOD_(void, OnObjectMoved)(CUIFObject *pObject); - STDMETHOD_(void, OnMouseOutFromWindow)(LONG x, LONG y) { } - STDMETHOD_(void, OnCreate)(HWND hWnd) { } - STDMETHOD_(void, OnDestroy)(HWND hWnd) { } - STDMETHOD_(void, OnNCDestroy)(HWND hWnd) { } - STDMETHOD_(void, OnSetFocus)(HWND hWnd) { } - STDMETHOD_(void, OnKillFocus)(HWND hWnd) { } - STDMETHOD_(void, OnNotify)(HWND hWnd, WPARAM wParam, LPARAM lParam) { } - STDMETHOD_(void, OnTimer)(WPARAM wParam) { } - STDMETHOD_(void, OnSysColorChange)() { } - STDMETHOD_(void, OnEndSession)(HWND hWnd, WPARAM wParam, LPARAM lParam) { } - STDMETHOD_(void, OnKeyDown)(HWND hWnd, WPARAM wParam, LPARAM lParam) { } - STDMETHOD_(void, OnKeyUp)(HWND, WPARAM wParam, LPARAM lParam) { } - STDMETHOD_(void, OnUser)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { } - STDMETHOD_(LRESULT, OnActivate)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) - { return 0; } - STDMETHOD_(LRESULT, OnWindowPosChanged)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) - { return 0; } - STDMETHOD_(LRESULT, OnWindowPosChanging)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) - { return 0; } - STDMETHOD_(LRESULT, OnNotifyFormat)(HWND hWnd, WPARAM wParam, LPARAM lParam) { return 0; } - STDMETHOD_(LRESULT, OnShowWindow)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) - { return 0; } - STDMETHOD_(LRESULT, OnSettingChange)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - STDMETHOD_(LRESULT, OnDisplayChange)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) - { return 0; } - STDMETHOD_(HRESULT, OnGetObject)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) - { return S_OK; } - STDMETHOD_(LRESULT, WindowProc)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - STDMETHOD_(BOOL, OnEraseBkGnd)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) - { return FALSE; } - STDMETHOD_(void, OnThemeChanged)(HWND hWnd, WPARAM wParam, LPARAM lParam); - STDMETHOD_(void, UpdateUI)(LPCRECT prc); - STDMETHOD_(void, SetCapture)(int); - STDMETHOD_(void, ModalMouseNotify)(UINT uMsg, LONG x, LONG y) { } - STDMETHOD_(void, OnAnimationStart)() { } - STDMETHOD_(void, OnAnimationEnd)(); - STDMETHOD_(void, HandleMouseMsg)(UINT uMsg, LONG x, LONG y); - STDMETHOD_(void, ClientRectToWindowRect)(LPRECT pRect); - STDMETHOD_(void, GetWindowFrameSize)(LPSIZE pSize); -}; - -///////////////////////////////////////////////////////////////////////////// - -class CUIFToolTip : public CUIFWindow -{ -protected: - CUIFWindow *m_pToolTipOwner; - CUIFObject *m_pToolTipTarget; - LPWSTR m_pszToolTipText; - BOOL m_bShowToolTip; - DWORD m_dwUnknown10; //FIXME: name and type - LONG m_nDelayTimeType2; - LONG m_nDelayTimeType3; - LONG m_nDelayTimeType1; - RECT m_rcToolTipMargin; - LONG m_cxToolTipWidth; - BOOL m_bToolTipHasBkColor; - BOOL m_bToolTipHasTextColor; - COLORREF m_rgbToolTipBkColor; - COLORREF m_rgbToolTipTextColor; - friend class CUIFObject; - friend class CTipbarWnd; - -public: - enum { TOOLTIP_TIMER_ID = 0x3216 }; - CUIFToolTip(HINSTANCE hInst, DWORD style, CUIFWindow *pToolTipOwner); - ~CUIFToolTip() override; - - LONG GetDelayTime(UINT uType); - void GetMargin(LPRECT prc); - COLORREF GetTipBkColor(); - COLORREF GetTipTextColor(); - CUIFObject* FindObject(HWND hWnd, POINT pt); - - void ShowTip(); - void HideTip(); - - void GetTipWindowSize(LPSIZE pSize); - void GetTipWindowRect(LPRECT pRect, SIZE toolTipSize, LPCRECT prc); - - void RelayEvent(LPMSG pMsg); - - STDMETHOD_(void, OnPaint)(HDC hDC) override; - STDMETHOD_(void, Enable)(BOOL bEnable) override; - STDMETHOD_(void, OnTimer)(WPARAM wParam) override; -}; - -class CUIFShadow : public CUIFWindow -{ -protected: - CUIFWindow *m_pShadowOwner; - COLORREF m_rgbShadowColor; - DWORD m_dwUnknown11[2]; - INT m_xShadowDelta; - INT m_yShadowDelta; - BOOL m_bLayerAvailable; - -public: - CUIFShadow(HINSTANCE hInst, DWORD style, CUIFWindow *pShadowOwner); - ~CUIFShadow() override; - - void InitSettings(); - void InitShadow(); - void AdjustWindowPos(); - void OnOwnerWndMoved(BOOL bDoSize); - - STDMETHOD_(BOOL, Initialize)() override; - STDMETHOD_(DWORD, GetWndStyleEx)() override; - STDMETHOD_(void, OnPaint)(HDC hDC) override; - STDMETHOD_(LRESULT, OnWindowPosChanging)(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) override; - STDMETHOD_(LRESULT, OnSettingChange)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) override; - STDMETHOD_(void, Show)(BOOL bVisible) override; -}; - -///////////////////////////////////////////////////////////////////////////// - -// m_style flags for CUIFMenu -enum -{ - UIF_MENU_USE_OFF10 = 0x10000000, -}; - -class CUIFMenu : public CUIFWindow -{ -public: - CUIFMenu *m_pVisibleSubMenu; - CUIFMenu *m_pParentMenu; - CUIFMenuItem *m_pSelectedItem; - UINT m_nSelectedID; - CicArray<CUIFMenuItem*> m_MenuItems; - HFONT m_hMenuFont; - BOOL m_bModal; - BOOL m_bHasMargin; - DWORD m_dwUnknown14; - LONG m_cxyMargin; - LONG m_cxMenuExtent; - friend class CUIFMenuItem; - -public: - CUIFMenu(HINSTANCE hInst, DWORD style, DWORD dwUnknown14); - ~CUIFMenu() override; - - void CancelMenu(); - void ClearMenuFont(); - CUIFMenuItem* GetNextItem(CUIFMenuItem *pItem); - CUIFMenuItem* GetPrevItem(CUIFMenuItem *pItem); - CUIFMenu* GetTopSubMenu(); - BOOL InsertItem(CUIFMenuItem *pItem); - BOOL InsertSeparator(); - void PostKey(BOOL bUp, WPARAM wParam, LPARAM lParam); - void SetMenuFont(); - void SetSelectedId(UINT nSelectID); - void SetSelectedItem(CUIFMenuItem *pItem); - UINT ShowModalPopup(CUIFWindow *pWindow, LPCRECT prc, BOOL bFlag); - void ShowSubPopup(CUIFMenu *pSubMenu, LPCRECT prc, BOOL bFlag); - - STDMETHOD_(void, OnKeyDown)(HWND hWnd, WPARAM wParam, LPARAM lParam) override; - STDMETHOD_(void, HandleMouseMsg)(UINT uMsg, LONG x, LONG y) override; - STDMETHOD_(void, ModalMouseNotify)(UINT uMsg, LONG x, LONG y) override; - - STDMETHOD_(void, ModalMessageLoop)(); - STDMETHOD_(BOOL, InitShow)(CUIFWindow *pWindow, LPCRECT prc, BOOL bFlag, BOOL bDoAnimation); - STDMETHOD_(BOOL, UninitShow)(); -}; - -///////////////////////////////////////////////////////////////////////////// - -class CUIFMenuItem : public CUIFObject -{ -protected: - UINT m_nMenuItemID; - LPWSTR m_pszMenuItemLeft; - UINT m_cchMenuItemLeft; - LPWSTR m_pszMenuItemRight; - UINT m_cchMenuItemRight; - UINT m_nMenuItemVKey; - UINT m_ichMenuItemPrefix; - HBITMAP m_hbmColor; - HBITMAP m_hbmMask; - BOOL m_bMenuItemChecked; - BOOL m_bMenuItemForceChecked; - BOOL m_bMenuItemGrayed; - BOOL m_bMenuItemDisabled; - CUIFMenu *m_pMenu; - CUIFMenu *m_pSubMenu; - SIZE m_MenuLeftExtent; - SIZE m_MenuRightExtent; - friend class CUIFMenu; - - void DrawArrow(HDC hDC, INT x, INT y); - void DrawBitmapProc(HDC hDC, INT xLeft, INT yTop); - void DrawCheck(HDC hDC, INT xLeft, INT yTop); - void DrawUnderline(HDC hDC, INT xText, INT yText, HBRUSH hbr); - -public: - CUIFMenuItem(CUIFMenu *pMenu, BOOL bDisabled = FALSE); - ~CUIFMenuItem() override; - - BOOL Init(UINT nMenuItemID, LPCWSTR pszText); - - BOOL IsCheck(); - void Check(BOOL bChecked) { m_bMenuItemChecked = bChecked; } - void Gray(BOOL bGrayed) { m_bMenuItemGrayed = bGrayed; } - - void SetBitmap(HBITMAP hbmColor) { m_hbmColor = hbmColor; } - void SetBitmapMask(HBITMAP hbmMask); - void SetSub(CUIFMenu *pSubMenu) { m_pSubMenu = pSubMenu; } - - void ShowSubPopup(); - - STDMETHOD_(void, OnLButtonUp)(LONG x, LONG y) override; - STDMETHOD_(void, OnMouseIn)(LONG x, LONG y) override; - STDMETHOD_(void, OnPaint)(HDC hDC) override; - STDMETHOD_(void, OnTimer)() override; - - STDMETHOD_(void, InitMenuExtent)(); - STDMETHOD_(void, OnPaintDef)(HDC hDC); - STDMETHOD_(void, OnPaintO10)(HDC hDC); - STDMETHOD_(void, OnUnknownMethod)() { } // FIXME: method name -}; - -///////////////////////////////////////////////////////////////////////////// - -class CUIFMenuItemSeparator : public CUIFMenuItem -{ -public: - CUIFMenuItemSeparator(CUIFMenu *pMenu); - - STDMETHOD_(void, InitMenuExtent)() override; - STDMETHOD_(void, OnPaintDef)(HDC hDC) override; - STDMETHOD_(void, OnPaintO10)(HDC hDC) override; -}; - -///////////////////////////////////////////////////////////////////////////// - -// m_style flags for CUIFButton -enum -{ - UIF_BUTTON_H_ALIGN_LEFT = 0, - UIF_BUTTON_H_ALIGN_CENTER = 0x1, - UIF_BUTTON_H_ALIGN_RIGHT = 0x2, - UIF_BUTTON_H_ALIGN_MASK = UIF_BUTTON_H_ALIGN_CENTER | UIF_BUTTON_H_ALIGN_RIGHT, - UIF_BUTTON_V_ALIGN_TOP = 0, - UIF_BUTTON_V_ALIGN_MIDDLE = 0x4, - UIF_BUTTON_V_ALIGN_BOTTOM = 0x8, - UIF_BUTTON_V_ALIGN_MASK = UIF_BUTTON_V_ALIGN_MIDDLE | UIF_BUTTON_V_ALIGN_BOTTOM, - UIF_BUTTON_LARGE_ICON = 0x100, - UIF_BUTTON_VERTICAL = 0x400, -}; - -class CUIFButton : public CUIFObject -{ -protected: - UINT m_uButtonStatus; - LPWSTR m_pszButtonText; - CUIFIcon m_ButtonIcon; - DWORD m_dwUnknown9; - HBITMAP m_hbmButton1; - HBITMAP m_hbmButton2; - BOOL m_bPressed; - SIZE m_IconSize; - SIZE m_TextSize; - friend class CUIFToolbarButton; - - void DrawBitmapProc(HDC hDC, LPCRECT prc, BOOL bPressed); - void DrawEdgeProc(HDC hDC, LPCRECT prc, BOOL bPressed); - void DrawIconProc(HDC hDC, LPRECT prc, BOOL bPressed); - void DrawTextProc(HDC hDC, LPCRECT prc, BOOL bPressed); - -public: - CUIFButton(CUIFObject *pParent, DWORD nObjectID, LPCRECT prc, DWORD style); - ~CUIFButton() override; - - void SetIcon(HICON hIcon); - void SetText(LPCWSTR pszText); - - void GetIconSize(HICON hIcon, LPSIZE pSize); - void GetTextSize(LPCWSTR pszText, LPSIZE pSize); - - STDMETHOD_(void, Enable)(BOOL bEnable) override; - STDMETHOD_(void, OnMouseIn)(LONG x, LONG y) override; - STDMETHOD_(void, OnMouseOut)(LONG x, LONG y) override; - STDMETHOD_(void, OnLButtonDown)(LONG x, LONG y) override; - STDMETHOD_(void, OnLButtonUp)(LONG x, LONG y) override; - STDMETHOD_(void, OnPaintNoTheme)(HDC hDC) override; - STDMETHOD_(void, SetStatus)(UINT uStatus); -}; - -///////////////////////////////////////////////////////////////////////////// - -class CUIFButton2 : public CUIFButton -{ -protected: - SIZE m_BitmapSize; - -public: - CUIFButton2(CUIFObject *pParent, DWORD nObjectID, LPCRECT prc, DWORD style); - ~CUIFButton2() override; - - DWORD MakeDrawFlag(); - STDMETHOD_(BOOL, OnPaintTheme)(HDC hDC) override; - STDMETHOD_(void, OnPaintNoTheme)(HDC hDC) override; -}; - -///////////////////////////////////////////////////////////////////////////// - -class CUIFToolbarMenuButton : public CUIFButton2 -{ -public: - CUIFToolbarButton *m_pToolbarButton; - - CUIFToolbarMenuButton(CUIFToolbarButton *pParent, DWORD nObjectID, LPCRECT prc, DWORD style); - ~CUIFToolbarMenuButton() override; - - STDMETHOD_(void, OnLButtonUp)(LONG x, LONG y) override; - STDMETHOD_(BOOL, OnSetCursor)(UINT uMsg, LONG x, LONG y) override; -}; - -///////////////////////////////////////////////////////////////////////////// - -class CUIFToolbarButtonElement : public CUIFButton2 -{ -public: - CUIFToolbarButton *m_pToolbarButton; - - CUIFToolbarButtonElement(CUIFToolbarButton *pParent, DWORD nObjectID, LPCRECT prc, DWORD style); - - STDMETHOD_(LPCWSTR, GetToolTip)() override; - STDMETHOD_(void, OnLButtonUp)(LONG x, LONG y) override; - STDMETHOD_(void, OnRButtonUp)(LONG x, LONG y) override; -}; - -///////////////////////////////////////////////////////////////////////////// - -class CUIFToolbarButton : public CUIFObject -{ -public: - CUIFToolbarButtonElement *m_pToolbarButtonElement; - CUIFToolbarMenuButton *m_pToolbarMenuButton; - DWORD m_dwToolbarButtonFlags; - LPCWSTR m_pszUnknownText; - - CUIFToolbarButton( - CUIFObject *pParent, - DWORD nObjectID, - LPCRECT prc, - DWORD style, - DWORD dwToolbarButtonFlags, - LPCWSTR pszUnknownText); - ~CUIFToolbarButton() override { } - - BOOL Init(); - HICON GetIcon(); - void SetIcon(HICON hIcon); - - STDMETHOD_(void, ClearWndObj)() override; - STDMETHOD_(void, DetachWndObj)() override; - STDMETHOD_(void, Enable)(BOOL bEnable) override; - STDMETHOD_(LPCWSTR, GetToolTip)() override; - STDMETHOD_(void, SetActiveTheme)(LPCWSTR pszClassList, INT iPartId, INT iStateId) override; - STDMETHOD_(void, SetFont)(HFONT hFont) override; - STDMETHOD_(void, SetRect)(LPCRECT prc) override; - STDMETHOD_(void, SetToolTip)(LPCWSTR pszToolTip) override; - - STDMETHOD_(void, OnUnknownMouse0)() { } - STDMETHOD_(void, OnUnknownMouse1)(LONG x, LONG y) { } - STDMETHOD_(void, OnUnknownMouse2)(LONG x, LONG y) { } -}; - -///////////////////////////////////////////////////////////////////////////// - -// m_style flags for CUIFGripper -enum -{ - UIF_GRIPPER_VERTICAL = 0x1, -}; - -class CUIFGripper : public CUIFObject -{ -protected: - POINT m_ptGripper; - -public: - CUIFGripper(CUIFObject *pParent, LPCRECT prc, DWORD style); - ~CUIFGripper() override; - - STDMETHOD_(void, OnMouseMove)(LONG x, LONG y) override; - STDMETHOD_(void, OnLButtonDown)(LONG x, LONG y) override; - STDMETHOD_(void, OnLButtonUp)(LONG x, LONG y) override; - STDMETHOD_(BOOL, OnPaintTheme)(HDC hDC) override; - STDMETHOD_(void, OnPaintNoTheme)(HDC hDC) override; - STDMETHOD_(BOOL, OnSetCursor)(UINT uMsg, LONG x, LONG y) override; - STDMETHOD_(void, SetStyle)(DWORD style) override; -}; - -///////////////////////////////////////////////////////////////////////////// - -class CUIFWndFrame : public CUIFObject -{ -protected: - DWORD m_dwHitTest; - POINT m_ptHit; - RECT m_rcWnd; - INT m_cxFrame; - INT m_cyFrame; - INT m_cxMin; - INT m_cyMin; - -public: - CUIFWndFrame(CUIFObject *pParent, LPCRECT prc, DWORD style); - - void GetFrameSize(LPSIZE pSize); - DWORD HitTest(LONG x, LONG y); - - STDMETHOD_(void, OnMouseMove)(LONG x, LONG y) override; - STDMETHOD_(void, OnLButtonDown)(LONG x, LONG y) override; - STDMETHOD_(void, OnLButtonUp)(LONG x, LONG y) override; - STDMETHOD_(BOOL, OnPaintTheme)(HDC hDC) override; - STDMETHOD_(void, OnPaintNoTheme)(HDC hDC) override; - STDMETHOD_(BOOL, OnSetCursor)(UINT uMsg, LONG x, LONG y) override; -}; - -///////////////////////////////////////////////////////////////////////////// - -class CUIFBalloonButton : public CUIFButton -{ -protected: - UINT m_nCommandID; - friend class CUIFBalloonWindow; - -public: - CUIFBalloonButton(CUIFObject *pParent, DWORD nObjectID, LPCRECT prc, DWORD style); - - STDMETHOD_(void, OnPaint)(HDC hDC) override; - void DrawTextProc(HDC hDC, LPCRECT prc, BOOL bPressed); -}; - -///////////////////////////////////////////////////////////////////////////// - -// m_style flags for CUIFBalloonWindow -enum -{ - UIF_BALLOON_WINDOW_OK = 0x10000, - UIF_BALLOON_WINDOW_YESNO = 0x20000, - UIF_BALLOON_WINDOW_TYPE_MASK = 0xF0000, -}; - -class CUIFBalloonWindow : public CUIFWindow -{ -protected: - LPWSTR m_pszBalloonText; - HRGN m_hRgn; - RECT m_rcMargin; - DWORD m_dwUnknown6; - BOOL m_bHasBkColor; - BOOL m_bHasTextColor; - COLORREF m_rgbBkColor; - COLORREF m_rgbTextColor; - POINT m_ptTarget; - RECT m_rcExclude; - POINT m_ptBalloon; - DWORD m_dwUnknown7; - UINT m_nBalloonType; - DWORD m_dwUnknown8[2]; - UINT m_cButtons; - WPARAM m_nActionID; - HWND m_hwndNotif; - UINT m_uNotifMsg; - -public: - CUIFBalloonWindow(HINSTANCE hInst, DWORD style); - ~CUIFBalloonWindow() override; - - STDMETHOD_(BOOL, Initialize)() override; - STDMETHOD_(LPCTSTR, GetClassName)() override { return TEXT("MSIME_PopupMessage"); } - STDMETHOD_(LPCTSTR, GetWndTitle)() override { return TEXT("MSIME_PopupMessage"); } - STDMETHOD_(void, OnCreate)(HWND hWnd) override; - STDMETHOD_(void, OnDestroy)(HWND hWnd) override; - STDMETHOD_(void, OnKeyDown)(HWND hWnd, WPARAM wParam, LPARAM lParam) override; - STDMETHOD_(LRESULT, OnObjectNotify)(CUIFObject *pObject, WPARAM wParam, LPARAM lParam) override; - STDMETHOD_(void, OnPaint)(HDC hDC) override; - - void AddButton(UINT nCommandId); - void AdjustPos(); - HRGN CreateRegion(LPCRECT prc); - void DoneWindowRegion(); - CUIFBalloonButton *FindButton(UINT nCommandID); - CUIFObject *FindUIObject(UINT nObjectID); - - COLORREF GetBalloonBkColor(); - COLORREF GetBalloonTextColor(); - void GetButtonSize(LPSIZE pSize); - void GetMargin(LPRECT prcMargin); - void SetExcludeRect(LPCRECT prcExclude); - void SetTargetPos(POINT ptTarget); - void SetText(LPCWSTR pszText); - - void InitWindowRegion(); - void LayoutObject(); - void PaintFrameProc(HDC hDC, LPCRECT prc); - void PaintMessageProc(HDC hDC, LPRECT prc, LPCWSTR pszText); - void SendNotification(WPARAM wParam); -}; - -///////////////////////////////////////////////////////////////////////////// - -inline void cicInitUIFLib(void) -{ - cicInitUIFSys(); - cicInitUIFScheme(); - cicInitUIFUtil(); -} - -inline void cicDoneUIFLib(void) -{ - cicDoneUIFScheme(); - cicDoneUIFSys(); - cicDoneUIFUtil(); -} - -inline void cicGetScreenRect(POINT pt, LPRECT prc) -{ - *prc = { 0, 0, ::GetSystemMetrics(SM_CXSCREEN), ::GetSystemMetrics(SM_CYSCREEN) }; - HMONITOR hMon = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); - if (hMon) - { - MONITORINFO mi = { sizeof(mi) }; - GetMonitorInfo(hMon, &mi); - *prc = mi.rcMonitor; - } -} - -inline BOOL cicIsFullScreenSize(HWND hWnd) -{ - RECT rc; - - ::GetWindowRect(hWnd, &rc); - return (rc.left <= 0) && (rc.top <= 0) && - (rc.right >= GetSystemMetrics(SM_CXFULLSCREEN)) && - (rc.bottom >= GetSystemMetrics(SM_CYFULLSCREEN)); -} +HINSTANCE CUIFTheme::s_hUXTHEME = NULL; +FN_OpenThemeData CUIFTheme::s_fnOpenThemeData = NULL; +FN_CloseThemeData CUIFTheme::s_fnCloseThemeData = NULL; +FN_DrawThemeBackground CUIFTheme::s_fnDrawThemeBackground = NULL; +FN_DrawThemeParentBackground CUIFTheme::s_fnDrawThemeParentBackground = NULL; +FN_DrawThemeText CUIFTheme::s_fnDrawThemeText = NULL; +FN_DrawThemeIcon CUIFTheme::s_fnDrawThemeIcon = NULL; +FN_GetThemeBackgroundExtent CUIFTheme::s_fnGetThemeBackgroundExtent = NULL; +FN_GetThemeBackgroundContentRect CUIFTheme::s_fnGetThemeBackgroundContentRect = NULL; +FN_GetThemeTextExtent CUIFTheme::s_fnGetThemeTextExtent = NULL; +FN_GetThemePartSize CUIFTheme::s_fnGetThemePartSize = NULL; +FN_DrawThemeEdge CUIFTheme::s_fnDrawThemeEdge = NULL; +FN_GetThemeColor CUIFTheme::s_fnGetThemeColor = NULL; +FN_GetThemeMargins CUIFTheme::s_fnGetThemeMargins = NULL; +FN_GetThemeFont CUIFTheme::s_fnGetThemeFont = NULL; +FN_GetThemeSysColor CUIFTheme::s_fnGetThemeSysColor = NULL; +FN_GetThemeSysSize CUIFTheme::s_fnGetThemeSysSize = NULL; + +CUIFSystemInfo *CUIFSystemInfo::s_pSystemInfo = NULL; + +CUIFColorTableSys *CUIFScheme::s_pColorTableSys = NULL; +CUIFColorTableOff10 *CUIFScheme::s_pColorTableOff10 = NULL; ///////////////////////////////////////////////////////////////////////////// -inline void CUIFSystemInfo::GetSystemMetrics() +void CUIFSystemInfo::GetSystemMetrics() { HDC hDC = ::GetDC(NULL); m_cBitsPixels = ::GetDeviceCaps(hDC, BITSPIXEL); @@ -1170,38 +53,17 @@ inline void CUIFSystemInfo::GetSystemMetrics() (rgbBtnText == white && rgbBtnFace == black)); } -inline void CUIFSystemInfo::Initialize() +void CUIFSystemInfo::Initialize() { dwOSVersionInfoSize = sizeof(OSVERSIONINFO); ::GetVersionEx(this); GetSystemMetrics(); } -inline void cicInitUIFSys(void) -{ - CUIFSystemInfo::s_pSystemInfo = new(cicNoThrow) CUIFSystemInfo(); - if (CUIFSystemInfo::s_pSystemInfo) - CUIFSystemInfo::s_pSystemInfo->Initialize(); -} - -inline void cicDoneUIFSys(void) -{ - if (CUIFSystemInfo::s_pSystemInfo) - { - delete CUIFSystemInfo::s_pSystemInfo; - CUIFSystemInfo::s_pSystemInfo = NULL; - } -} - -inline void cicUpdateUIFSys(void) -{ - if (CUIFSystemInfo::s_pSystemInfo) - CUIFSystemInfo::s_pSystemInfo->GetSystemMetrics(); -} - ///////////////////////////////////////////////////////////////////////////// +// CUIFTheme -inline HRESULT CUIFTheme::InternalOpenThemeData(HWND hWnd) +HRESULT CUIFTheme::InternalOpenThemeData(HWND hWnd) { if (!hWnd || !m_pszClassList) return E_FAIL; @@ -1212,14 +74,14 @@ inline HRESULT CUIFTheme::InternalOpenThemeData(HWND hWnd) return (m_hTheme ? S_OK : E_FAIL); } -inline HRESULT CUIFTheme::EnsureThemeData(HWND hWnd) +HRESULT CUIFTheme::EnsureThemeData(HWND hWnd) { if (m_hTheme) return S_OK; return InternalOpenThemeData(hWnd); } -inline HRESULT CUIFTheme::CloseThemeData() +HRESULT CUIFTheme::CloseThemeData() { if (!m_hTheme) return S_OK; @@ -1232,7 +94,7 @@ inline HRESULT CUIFTheme::CloseThemeData() return hr; } -inline STDMETHODIMP +STDMETHODIMP CUIFTheme::DrawThemeBackground(HDC hDC, int iStateId, LPCRECT pRect, LPCRECT pClipRect) { if (!cicGetFN(s_hUXTHEME, s_fnDrawThemeBackground, TEXT("uxtheme.dll"), "DrawThemeBackground")) @@ -1240,7 +102,7 @@ CUIFTheme::DrawThemeBackground(HDC hDC, int iStateId, LPCRECT pRect, LPCRECT pCl return s_fnDrawThemeBackground(m_hTheme, hDC, m_iPartId, iStateId, pRect, pClipRect); } -inline STDMETHODIMP +STDMETHODIMP CUIFTheme::DrawThemeParentBackground(HWND hwnd, HDC hDC, LPRECT prc) { if (!cicGetFN(s_hUXTHEME, s_fnDrawThemeParentBackground, TEXT("uxtheme.dll"), "DrawThemeParentBackground")) @@ -1248,7 +110,7 @@ CUIFTheme::DrawThemeParentBackground(HWND hwnd, HDC hDC, LPRECT prc) return s_fnDrawThemeParentBackground(hwnd, hDC, prc); } -inline STDMETHODIMP +STDMETHODIMP CUIFTheme::DrawThemeText(HDC hDC, int iStateId, LPCWSTR pszText, int cchText, DWORD dwTextFlags, DWORD dwTextFlags2, LPCRECT pRect) { if (!cicGetFN(s_hUXTHEME, s_fnDrawThemeText, TEXT("uxtheme.dll"), "DrawThemeText")) @@ -1256,7 +118,7 @@ CUIFTheme::DrawThemeText(HDC hDC, int iStateId, LPCWSTR pszText, int cchText, DW return s_fnDrawThemeText(m_hTheme, hDC, m_iPartId, iStateId, pszText, cchText, dwTextFlags, dwTextFlags2, pRect); } -inline STDMETHODIMP +STDMETHODIMP CUIFTheme::DrawThemeIcon(HDC hDC, int iStateId, LPCRECT pRect, HIMAGELIST himl, int iImageIndex) { if (!cicGetFN(s_hUXTHEME, s_fnDrawThemeIcon, TEXT("uxtheme.dll"), "DrawThemeIcon")) @@ -1264,7 +126,7 @@ CUIFTheme::DrawThemeIcon(HDC hDC, int iStateId, LPCRECT pRect, HIMAGELIST himl, return s_fnDrawThemeIcon(m_hTheme, hDC, m_iPartId, iStateId, pRect, himl, iImageIndex); } -inline STDMETHODIMP +STDMETHODIMP CUIFTheme::GetThemeBackgroundExtent(HDC hDC, int iStateId, LPCRECT pContentRect, LPRECT pExtentRect) { if (!cicGetFN(s_hUXTHEME, s_fnGetThemeBackgroundExtent, TEXT("uxtheme.dll"), "GetThemeBackgroundExtent")) @@ -1272,7 +134,7 @@ CUIFTheme::GetThemeBackgroundExtent(HDC hDC, int iStateId, LPCRECT pContentRect, return s_fnGetThemeBackgroundExtent(m_hTheme, hDC, m_iPartId, iStateId, pContentRect, pExtentRect); } -inline STDMETHODIMP +STDMETHODIMP CUIFTheme::GetThemeBackgroundContentRect(HDC hDC, int iStateId, LPCRECT pBoundingRect, LPRECT pContentRect) { if (!cicGetFN(s_hUXTHEME, s_fnGetThemeBackgroundContentRect, TEXT("uxtheme.dll"), "GetThemeBackgroundContentRect")) @@ -1280,7 +142,7 @@ CUIFTheme::GetThemeBackgroundContentRect(HDC hDC, int iStateId, LPCRECT pBoundin return s_fnGetThemeBackgroundContentRect(m_hTheme, hDC, m_iPartId, iStateId, pBoundingRect, pContentRect); } -inline STDMETHODIMP +STDMETHODIMP CUIFTheme::GetThemeTextExtent(HDC hDC, int iStateId, LPCWSTR pszText, int cchCharCount, DWORD dwTextFlags, LPCRECT pBoundingRect, LPRECT pExtentRect) { if (!cicGetFN(s_hUXTHEME, s_fnGetThemeTextExtent, TEXT("uxtheme.dll"), "GetThemeTextExtent")) @@ -1288,7 +150,7 @@ CUIFTheme::GetThemeTextExtent(HDC hDC, int iStateId, LPCWSTR pszText, int cchCha return s_fnGetThemeTextExtent(m_hTheme, hDC, m_iPartId, iStateId, pszText, cchCharCount, dwTextFlags, pBoundingRect, pExtentRect); } -inline STDMETHODIMP +STDMETHODIMP CUIFTheme::GetThemePartSize(HDC hDC, int iStateId, LPRECT prc, THEMESIZE eSize, SIZE *psz) { if (!cicGetFN(s_hUXTHEME, s_fnGetThemePartSize, TEXT("uxtheme.dll"), "GetThemePartSize")) @@ -1296,7 +158,7 @@ CUIFTheme::GetThemePartSize(HDC hDC, int iStateId, LPRECT prc, THEMESIZE eSize, return s_fnGetThemePartSize(m_hTheme, hDC, m_iPartId, iStateId, prc, eSize, psz); } -inline STDMETHODIMP +STDMETHODIMP CUIFTheme::DrawThemeEdge(HDC hDC, int iStateId, LPCRECT pDestRect, UINT uEdge, UINT uFlags, LPRECT pContentRect) { if (!cicGetFN(s_hUXTHEME, s_fnDrawThemeEdge, TEXT("uxtheme.dll"), "DrawThemeEdge")) @@ -1304,7 +166,7 @@ CUIFTheme::DrawThemeEdge(HDC hDC, int iStateId, LPCRECT pDestRect, UINT uEdge, U return s_fnDrawThemeEdge(m_hTheme, hDC, m_iPartId, iStateId, pDestRect, uEdge, uFlags, pContentRect); } -inline STDMETHODIMP +STDMETHODIMP CUIFTheme::GetThemeColor(int iStateId, int iPropId, COLORREF *pColor) { if (!cicGetFN(s_hUXTHEME, s_fnGetThemeColor, TEXT("uxtheme.dll"), "GetThemeColor")) @@ -1312,7 +174,7 @@ CUIFTheme::GetThemeColor(int iStateId, int iPropId, COLORREF *pColor) return s_fnGetThemeColor(m_hTheme, m_iPartId, iStateId, iPropId, pColor); } -inline STDMETHODIMP +STDMETHODIMP CUIFTheme::GetThemeMargins(HDC hDC, int iStateId, int iPropId, LPRECT prc, MARGINS *pMargins) { if (!cicGetFN(s_hUXTHEME, s_fnGetThemeMargins, TEXT("uxtheme.dll"), "GetThemeMargins")) @@ -1320,7 +182,7 @@ CUIFTheme::GetThemeMargins(HDC hDC, int iStateId, int iPropId, LPRECT prc, MARGI return s_fnGetThemeMargins(m_hTheme, hDC, m_iPartId, iStateId, iPropId, prc, pMargins); } -inline STDMETHODIMP +STDMETHODIMP CUIFTheme::GetThemeFont(HDC hDC, int iStateId, int iPropId, LOGFONTW *pFont) { if (!cicGetFN(s_hUXTHEME, s_fnGetThemeFont, TEXT("uxtheme.dll"), "GetThemeFont")) @@ -1328,7 +190,7 @@ CUIFTheme::GetThemeFont(HDC hDC, int iStateId, int iPropId, LOGFONTW *pFont) return s_fnGetThemeFont(m_hTheme, hDC, m_iPartId, iStateId, iPropId, pFont); } -inline STDMETHODIMP_(COLORREF) +STDMETHODIMP_(COLORREF) CUIFTheme::GetThemeSysColor(INT iColorId) { if (!cicGetFN(s_hUXTHEME, s_fnGetThemeSysColor, TEXT("uxtheme.dll"), "GetThemeSysColor")) @@ -1336,7 +198,7 @@ CUIFTheme::GetThemeSysColor(INT iColorId) return s_fnGetThemeSysColor(m_hTheme, iColorId); } -inline STDMETHODIMP_(int) +STDMETHODIMP_(int) CUIFTheme::GetThemeSysSize(int iSizeId) { if (!cicGetFN(s_hUXTHEME, s_fnGetThemeSysSize, TEXT("uxtheme.dll"), "GetThemeSysSize")) @@ -1344,7 +206,7 @@ CUIFTheme::GetThemeSysSize(int iSizeId) return s_fnGetThemeSysSize(m_hTheme, iSizeId); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFTheme::SetActiveTheme(LPCWSTR pszClassList, INT iPartId, INT iStateId) { m_iPartId = iPartId; @@ -1353,9 +215,9 @@ CUIFTheme::SetActiveTheme(LPCWSTR pszClassList, INT iPartId, INT iStateId) } ///////////////////////////////////////////////////////////////////////////// +// CUIFObject /// @unimplemented -inline CUIFObject::CUIFObject(CUIFObject *pParent, DWORD nObjectID, LPCRECT prc, DWORD style) { m_pszClassList = NULL; @@ -1391,7 +253,6 @@ CUIFObject::CUIFObject(CUIFObject *pParent, DWORD nObjectID, LPCRECT prc, DWORD m_dwUnknown4[1] = -1; //FIXME: name } -inline CUIFObject::~CUIFObject() { if (m_pWindow) @@ -1420,28 +281,28 @@ CUIFObject::~CUIFObject() CloseThemeData(); } -inline STDMETHODIMP_(void) CUIFObject::OnPaint(HDC hDC) +STDMETHODIMP_(void) CUIFObject::OnPaint(HDC hDC) { if (!(m_pWindow->m_style & UIF_WINDOW_ENABLETHEMED) || !OnPaintTheme(hDC)) OnPaintNoTheme(hDC); } -inline STDMETHODIMP_(BOOL) CUIFObject::OnSetCursor(UINT uMsg, LONG x, LONG y) +STDMETHODIMP_(BOOL) CUIFObject::OnSetCursor(UINT uMsg, LONG x, LONG y) { return FALSE; } -inline STDMETHODIMP_(void) CUIFObject::GetRect(LPRECT prc) +STDMETHODIMP_(void) CUIFObject::GetRect(LPRECT prc) { *prc = m_rc; } -inline STDMETHODIMP_(BOOL) CUIFObject::PtInObject(POINT pt) +STDMETHODIMP_(BOOL) CUIFObject::PtInObject(POINT pt) { return m_bVisible && ::PtInRect(&m_rc, pt); } -inline STDMETHODIMP_(void) CUIFObject::PaintObject(HDC hDC, LPCRECT prc) +STDMETHODIMP_(void) CUIFObject::PaintObject(HDC hDC, LPCRECT prc) { if (!m_bVisible) return; @@ -1460,13 +321,13 @@ inline STDMETHODIMP_(void) CUIFObject::PaintObject(HDC hDC, LPCRECT prc) } } -inline STDMETHODIMP_(void) CUIFObject::CallOnPaint() +STDMETHODIMP_(void) CUIFObject::CallOnPaint() { if (m_pWindow) m_pWindow->UpdateUI(&m_rc); } -inline STDMETHODIMP_(void) CUIFObject::Enable(BOOL bEnable) +STDMETHODIMP_(void) CUIFObject::Enable(BOOL bEnable) { if (m_bEnable == bEnable) return; @@ -1478,7 +339,7 @@ inline STDMETHODIMP_(void) CUIFObject::Enable(BOOL bEnable) CallOnPaint(); } -inline STDMETHODIMP_(void) CUIFObject::Show(BOOL bVisible) +STDMETHODIMP_(void) CUIFObject::Show(BOOL bVisible) { if (m_bVisible == bVisible) return; @@ -1491,7 +352,7 @@ inline STDMETHODIMP_(void) CUIFObject::Show(BOOL bVisible) m_pParent->CallOnPaint(); } -inline STDMETHODIMP_(void) CUIFObject::SetFontToThis(HFONT hFont) +STDMETHODIMP_(void) CUIFObject::SetFontToThis(HFONT hFont) { m_bHasCustomFont = !!hFont; if (!hFont) @@ -1499,7 +360,7 @@ inline STDMETHODIMP_(void) CUIFObject::SetFontToThis(HFONT hFont) m_hFont = hFont; } -inline STDMETHODIMP_(void) CUIFObject::SetFont(HFONT hFont) +STDMETHODIMP_(void) CUIFObject::SetFont(HFONT hFont) { SetFontToThis(hFont); @@ -1509,31 +370,31 @@ inline STDMETHODIMP_(void) CUIFObject::SetFont(HFONT hFont) CallOnPaint(); } -inline STDMETHODIMP_(void) CUIFObject::SetStyle(DWORD style) +STDMETHODIMP_(void) CUIFObject::SetStyle(DWORD style) { m_style = style; } -inline STDMETHODIMP_(void) CUIFObject::AddUIObj(CUIFObject *pObject) +STDMETHODIMP_(void) CUIFObject::AddUIObj(CUIFObject *pObject) { m_ObjectArray.Add(pObject); CallOnPaint(); } -inline STDMETHODIMP_(void) CUIFObject::RemoveUIObj(CUIFObject *pObject) +STDMETHODIMP_(void) CUIFObject::RemoveUIObj(CUIFObject *pObject) { if (m_ObjectArray.Remove(pObject)) CallOnPaint(); } -inline STDMETHODIMP_(LRESULT) CUIFObject::OnObjectNotify(CUIFObject *pObject, WPARAM wParam, LPARAM lParam) +STDMETHODIMP_(LRESULT) CUIFObject::OnObjectNotify(CUIFObject *pObject, WPARAM wParam, LPARAM lParam) { if (m_pParent) return m_pParent->OnObjectNotify(pObject, wParam, lParam); return 0; } -inline STDMETHODIMP_(void) CUIFObject::SetToolTip(LPCWSTR pszToolTip) +STDMETHODIMP_(void) CUIFObject::SetToolTip(LPCWSTR pszToolTip) { if (m_pszToolTip) { @@ -1550,38 +411,38 @@ inline STDMETHODIMP_(void) CUIFObject::SetToolTip(LPCWSTR pszToolTip) } } -inline STDMETHODIMP_(void) CUIFObject::ClearWndObj() +STDMETHODIMP_(void) CUIFObject::ClearWndObj() { m_pWindow = NULL; for (size_t iItem = 0; iItem < m_ObjectArray.size(); ++iItem) m_ObjectArray[iItem]->ClearWndObj(); } -inline STDMETHODIMP_(void) CUIFObject::ClearTheme() +STDMETHODIMP_(void) CUIFObject::ClearTheme() { CloseThemeData(); for (size_t iItem = 0; iItem < m_ObjectArray.size(); ++iItem) m_ObjectArray[iItem]->ClearTheme(); } -inline void CUIFObject::StartCapture() +void CUIFObject::StartCapture() { if (m_pWindow) m_pWindow->SetCaptureObject(this); } -inline void CUIFObject::EndCapture() +void CUIFObject::EndCapture() { if (m_pWindow) m_pWindow->SetCaptureObject(NULL); } -inline BOOL CUIFObject::IsCapture() +BOOL CUIFObject::IsCapture() { return m_pWindow && (m_pWindow->m_pCaptured == this); } -inline void CUIFObject::SetRect(LPCRECT prc) +void CUIFObject::SetRect(LPCRECT prc) { m_rc = *prc; if (m_pWindow) @@ -1589,14 +450,14 @@ inline void CUIFObject::SetRect(LPCRECT prc) CallOnPaint(); } -inline LRESULT CUIFObject::NotifyCommand(WPARAM wParam, LPARAM lParam) +LRESULT CUIFObject::NotifyCommand(WPARAM wParam, LPARAM lParam) { if (m_pParent) return m_pParent->OnObjectNotify(this, wParam, lParam); return 0; } -inline void CUIFObject::DetachWndObj() +void CUIFObject::DetachWndObj() { if (m_pWindow) { @@ -1609,14 +470,14 @@ inline void CUIFObject::DetachWndObj() } } -inline BOOL CUIFObject::IsRTL() +BOOL CUIFObject::IsRTL() { if (!m_pWindow) return FALSE; return !!(m_pWindow->m_style & UIF_WINDOW_LAYOUTRTL); } -inline CUIFObject* CUIFObject::ObjectFromPoint(POINT pt) +CUIFObject* CUIFObject::ObjectFromPoint(POINT pt) { if (!PtInObject(pt)) return NULL; @@ -1631,7 +492,7 @@ inline CUIFObject* CUIFObject::ObjectFromPoint(POINT pt) return pFound; } -inline void CUIFObject::SetScheme(CUIFScheme *scheme) +void CUIFObject::SetScheme(CUIFScheme *scheme) { m_pScheme = scheme; for (size_t i = 0; i < m_ObjectArray.size(); ++i) @@ -1640,21 +501,22 @@ inline void CUIFObject::SetScheme(CUIFScheme *scheme) } } -inline void CUIFObject::StartTimer(WPARAM wParam) +void CUIFObject::StartTimer(WPARAM wParam) { if (m_pWindow) m_pWindow->SetTimerObject(this, wParam); } -inline void CUIFObject::EndTimer() +void CUIFObject::EndTimer() { if (m_pWindow) m_pWindow->SetTimerObject(NULL, 0); } ///////////////////////////////////////////////////////////////////////////// +// CUIFColorTable... -inline STDMETHODIMP_(void) CUIFColorTableSys::InitColor() +STDMETHODIMP_(void) CUIFColorTableSys::InitColor() { m_rgbColors[0] = ::GetSysColor(COLOR_BTNFACE); m_rgbColors[1] = ::GetSysColor(COLOR_BTNSHADOW); @@ -1674,12 +536,12 @@ inline STDMETHODIMP_(void) CUIFColorTableSys::InitColor() m_rgbColors[15] = ::GetSysColor(COLOR_WINDOWTEXT); } -inline STDMETHODIMP_(void) CUIFColorTableSys::InitBrush() +STDMETHODIMP_(void) CUIFColorTableSys::InitBrush() { ZeroMemory(m_hBrushes, sizeof(m_hBrushes)); } -inline STDMETHODIMP_(void) CUIFColorTableSys::DoneBrush() +STDMETHODIMP_(void) CUIFColorTableSys::DoneBrush() { for (size_t i = 0; i < _countof(m_hBrushes); ++i) { @@ -1691,14 +553,14 @@ inline STDMETHODIMP_(void) CUIFColorTableSys::DoneBrush() } } -inline HBRUSH CUIFColorTableSys::GetBrush(INT iColor) +HBRUSH CUIFColorTableSys::GetBrush(INT iColor) { if (!m_hBrushes[iColor]) m_hBrushes[iColor] = ::CreateSolidBrush(m_rgbColors[iColor]); return m_hBrushes[iColor]; } -inline HBRUSH CUIFColorTableOff10::GetBrush(INT iColor) +HBRUSH CUIFColorTableOff10::GetBrush(INT iColor) { if (!m_hBrushes[iColor]) m_hBrushes[iColor] = ::CreateSolidBrush(m_rgbColors[iColor]); @@ -1706,7 +568,7 @@ inline HBRUSH CUIFColorTableOff10::GetBrush(INT iColor) } /// @unimplemented -inline STDMETHODIMP_(void) CUIFColorTableOff10::InitColor() +STDMETHODIMP_(void) CUIFColorTableOff10::InitColor() { m_rgbColors[0] = ::GetSysColor(COLOR_BTNFACE); m_rgbColors[1] = ::GetSysColor(COLOR_WINDOW); @@ -1742,12 +604,12 @@ inline STDMETHODIMP_(void) CUIFColorTableOff10::InitColor() m_rgbColors[31] = ::GetSysColor(COLOR_WINDOWTEXT); } -inline STDMETHODIMP_(void) CUIFColorTableOff10::InitBrush() +STDMETHODIMP_(void) CUIFColorTableOff10::InitBrush() { ZeroMemory(m_hBrushes, sizeof(m_hBrushes)); } -inline STDMETHODIMP_(void) CUIFColorTableOff10::DoneBrush() +STDMETHODIMP_(void) CUIFColorTableOff10::DoneBrush() { for (size_t i = 0; i < _countof(m_hBrushes); ++i) { @@ -1760,106 +622,70 @@ inline STDMETHODIMP_(void) CUIFColorTableOff10::DoneBrush() } ///////////////////////////////////////////////////////////////////////////// - -inline void cicInitUIFScheme(void) -{ - CUIFColorTable *pColorTable; - - pColorTable = CUIFScheme::s_pColorTableSys = new(cicNoThrow) CUIFColorTableSys(); - if (pColorTable) - { - pColorTable->InitColor(); - pColorTable->InitBrush(); - } - - pColorTable = CUIFScheme::s_pColorTableOff10 = new(cicNoThrow) CUIFColorTableOff10(); - if (pColorTable) - { - pColorTable->InitColor(); - pColorTable->InitBrush(); - } -} - -inline void cicUpdateUIFScheme(void) -{ - if (CUIFScheme::s_pColorTableSys) - CUIFScheme::s_pColorTableSys->Update(); - if (CUIFScheme::s_pColorTableOff10) - CUIFScheme::s_pColorTableOff10->Update(); -} - -inline void cicDoneUIFScheme(void) -{ - if (CUIFScheme::s_pColorTableSys) - { - delete CUIFScheme::s_pColorTableSys; - CUIFScheme::s_pColorTableSys = NULL; - } - if (CUIFScheme::s_pColorTableOff10) - { - delete CUIFScheme::s_pColorTableOff10; - CUIFScheme::s_pColorTableOff10 = NULL; - } -} +// CUIFScheme /// @unimplemented -inline CUIFScheme *cicCreateUIFScheme(DWORD type) +CUIFScheme *cicCreateUIFScheme(DWORD type) { +#if 1 + return new(cicNoThrow) CUIFSchemeDef(type); +#else switch (type) { - //case 1: return new(cicNoThrow) CUIFSchemeOff10(1); - //case 2: return new(cicNoThrow) CUIFSchemeOff10(2); - //case 3: return new(cicNoThrow) CUIFSchemeOff10(3); + case 1: return new(cicNoThrow) CUIFSchemeOff10(1); + case 2: return new(cicNoThrow) CUIFSchemeOff10(2); + case 3: return new(cicNoThrow) CUIFSchemeOff10(3); default: return new(cicNoThrow) CUIFSchemeDef(type); } +#endif } -inline STDMETHODIMP_(DWORD) CUIFSchemeDef::GetType() +STDMETHODIMP_(DWORD) CUIFSchemeDef::GetType() { return m_dwType; } -inline STDMETHODIMP_(COLORREF) CUIFSchemeDef::GetColor(INT iColor) +STDMETHODIMP_(COLORREF) CUIFSchemeDef::GetColor(INT iColor) { return s_pColorTableSys->GetColor(iColor); } -inline STDMETHODIMP_(HBRUSH) CUIFSchemeDef::GetBrush(INT iColor) +STDMETHODIMP_(HBRUSH) CUIFSchemeDef::GetBrush(INT iColor) { return s_pColorTableSys->GetBrush(iColor); } -inline STDMETHODIMP_(INT) CUIFSchemeDef::CyMenuItem(INT cyText) +STDMETHODIMP_(INT) CUIFSchemeDef::CyMenuItem(INT cyText) { return cyText + 2; } -inline STDMETHODIMP_(INT) CUIFSchemeDef::CxSizeFrame() +STDMETHODIMP_(INT) CUIFSchemeDef::CxSizeFrame() { return ::GetSystemMetrics(SM_CXSIZEFRAME); } -inline STDMETHODIMP_(INT) CUIFSchemeDef::CySizeFrame() +STDMETHODIMP_(INT) CUIFSchemeDef::CySizeFrame() { return ::GetSystemMetrics(SM_CYSIZEFRAME); } -inline STDMETHODIMP_(void) CUIFScheme::FillRect(HDC hDC, LPCRECT prc, INT iColor) +STDMETHODIMP_(void) CUIFScheme::FillRect(HDC hDC, LPCRECT prc, INT iColor) { ::FillRect(hDC, prc, GetBrush(iColor)); } -inline STDMETHODIMP_(void) CUIFScheme::FrameRect(HDC hDC, LPCRECT prc, INT iColor) +STDMETHODIMP_(void) CUIFScheme::FrameRect(HDC hDC, LPCRECT prc, INT iColor) { ::FrameRect(hDC, prc, GetBrush(iColor)); } -inline STDMETHODIMP_(void) CUIFSchemeDef::DrawSelectionRect(HDC hDC, LPCRECT prc, int) +STDMETHODIMP_(void) CUIFSchemeDef::DrawSelectionRect(HDC hDC, LPCRECT prc, int) { ::FillRect(hDC, prc, GetBrush(6)); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFSchemeDef::GetCtrlFaceOffset(DWORD dwUnknownFlags, DWORD dwDrawFlags, LPSIZE pSize) { if (!(dwDrawFlags & UIF_DRAW_PRESSED)) @@ -1899,7 +725,7 @@ CUIFSchemeDef::GetCtrlFaceOffset(DWORD dwUnknownFlags, DWORD dwDrawFlags, LPSIZE pSize->cx = pSize->cy = -1; } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFSchemeDef::DrawCtrlBkgd(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) { ::FillRect(hDC, prc, GetBrush(9)); @@ -1922,7 +748,7 @@ CUIFSchemeDef::DrawCtrlBkgd(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dw ::DeleteObject(hbrDither); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFSchemeDef::DrawCtrlEdge( HDC hDC, LPCRECT prc, @@ -1970,7 +796,7 @@ CUIFSchemeDef::DrawCtrlEdge( ::DrawEdge(hDC, &rc, uEdge, BF_RECT); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFSchemeDef::DrawCtrlText( HDC hDC, LPCRECT prc, @@ -2003,7 +829,7 @@ CUIFSchemeDef::DrawCtrlText( ::SetBkMode(hDC, OldBkMode); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFSchemeDef::DrawCtrlIcon(HDC hDC, LPCRECT prc, HICON hIcon, DWORD dwDrawFlags, LPSIZE pSize) { if (m_bMirroring) @@ -2025,7 +851,7 @@ CUIFSchemeDef::DrawCtrlIcon(HDC hDC, LPCRECT prc, HICON hIcon, DWORD dwDrawFlags } } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFSchemeDef::DrawCtrlBitmap(HDC hDC, LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, DWORD dwDrawFlags) { if (m_bMirroring) @@ -2087,13 +913,13 @@ CUIFSchemeDef::DrawCtrlBitmap(HDC hDC, LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, } } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFSchemeDef::DrawMenuBitmap(HDC hDC, LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, DWORD dwDrawFlags) { DrawCtrlBitmap(hDC, prc, hbm1, hbm2, dwDrawFlags); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFSchemeDef::DrawMenuSeparator(HDC hDC, LPCRECT prc) { RECT rc = *prc; @@ -2105,31 +931,31 @@ CUIFSchemeDef::DrawMenuSeparator(HDC hDC, LPCRECT prc) ::FillRect(hDC, &rc, (HBRUSH)UlongToHandle(COLOR_BTNHIGHLIGHT + 1)); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFSchemeDef::DrawFrameCtrlBkgd(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) { DrawCtrlBkgd(hDC, prc, dwUnknownFlags, dwDrawFlags); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFSchemeDef::DrawFrameCtrlEdge(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) { DrawCtrlEdge(hDC, prc, dwUnknownFlags, dwDrawFlags); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFSchemeDef::DrawFrameCtrlIcon(HDC hDC, LPCRECT prc, HICON hIcon, DWORD dwDrawFlags, LPSIZE pSize) { DrawCtrlIcon(hDC, prc, hIcon, dwDrawFlags, pSize); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFSchemeDef::DrawFrameCtrlBitmap(HDC hDC, LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, DWORD dwDrawFlags) { DrawCtrlBitmap(hDC, prc, hbm1, hbm2, dwDrawFlags); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFSchemeDef::DrawWndFrame(HDC hDC, LPCRECT prc, DWORD type, DWORD unused1, DWORD unused2) { RECT rc = *prc; @@ -2139,7 +965,7 @@ CUIFSchemeDef::DrawWndFrame(HDC hDC, LPCRECT prc, DWORD type, DWORD unused1, DWO FrameRect(hDC, &rc, 14); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFSchemeDef::DrawDragHandle(HDC hDC, LPCRECT prc, BOOL bVertical) { RECT rc; @@ -2150,7 +976,7 @@ CUIFSchemeDef::DrawDragHandle(HDC hDC, LPCRECT prc, BOOL bVertical) ::DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFSchemeDef::DrawSeparator(HDC hDC, LPCRECT prc, BOOL bVertical) { HPEN hLightPen = ::CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_BTNHIGHLIGHT)); @@ -2188,23 +1014,9 @@ CUIFSchemeDef::DrawSeparator(HDC hDC, LPCRECT prc, BOOL bVertical) } ///////////////////////////////////////////////////////////////////////////// +// CUIFIcon -inline BOOL cicGetIconSize(HICON hIcon, LPSIZE pSize) -{ - ICONINFO IconInfo; - if (!GetIconInfo(hIcon, &IconInfo)) - return FALSE; - - BITMAP bm; - ::GetObject(IconInfo.hbmColor, sizeof(bm), &bm); - ::DeleteObject(IconInfo.hbmColor); - ::DeleteObject(IconInfo.hbmMask); - pSize->cx = bm.bmWidth; - pSize->cy = bm.bmHeight; - return TRUE; -} - -inline HIMAGELIST CUIFIcon::GetImageList(BOOL bMirror) +HIMAGELIST CUIFIcon::GetImageList(BOOL bMirror) { if (!m_hImageList) return NULL; @@ -2229,8 +1041,9 @@ inline HIMAGELIST CUIFIcon::GetImageList(BOOL bMirror) } ///////////////////////////////////////////////////////////////////////////// +// CUIFBitmapDC -inline CUIFBitmapDC::CUIFBitmapDC(BOOL bMemory) +CUIFBitmapDC::CUIFBitmapDC(BOOL bMemory) { m_hBitmap = NULL; m_hOldBitmap = NULL; @@ -2241,13 +1054,13 @@ inline CUIFBitmapDC::CUIFBitmapDC(BOOL bMemory) m_hDC = ::CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL); } -inline CUIFBitmapDC::~CUIFBitmapDC() +CUIFBitmapDC::~CUIFBitmapDC() { Uninit(); ::DeleteDC(m_hDC); } -inline void CUIFBitmapDC::Uninit(BOOL bKeep) +void CUIFBitmapDC::Uninit(BOOL bKeep) { if (m_hOldBitmap) { @@ -2271,21 +1084,21 @@ inline void CUIFBitmapDC::Uninit(BOOL bKeep) } } -inline BOOL CUIFBitmapDC::SetBitmap(HBITMAP hBitmap) +BOOL CUIFBitmapDC::SetBitmap(HBITMAP hBitmap) { if (m_hDC) m_hOldBitmap = ::SelectObject(m_hDC, hBitmap); return TRUE; } -inline BOOL CUIFBitmapDC::SetBitmap(LONG cx, LONG cy, WORD cPlanes, WORD cBitCount) +BOOL CUIFBitmapDC::SetBitmap(LONG cx, LONG cy, WORD cPlanes, WORD cBitCount) { m_hBitmap = ::CreateBitmap(cx, cy, cPlanes, cBitCount, 0); m_hOldBitmap = ::SelectObject(m_hDC, m_hBitmap); return TRUE; } -inline BOOL CUIFBitmapDC::SetDIB(LONG cx, LONG cy, WORD cPlanes, WORD cBitCount) +BOOL CUIFBitmapDC::SetDIB(LONG cx, LONG cy, WORD cPlanes, WORD cBitCount) { BITMAPINFO bmi; ZeroMemory(&bmi, sizeof(bmi)); @@ -2300,7 +1113,7 @@ inline BOOL CUIFBitmapDC::SetDIB(LONG cx, LONG cy, WORD cPlanes, WORD cBitCount) return TRUE; } -inline void cicInitUIFUtil(void) +void cicInitUIFUtil(void) { if (!CUIFBitmapDC::s_phdcSrc) CUIFBitmapDC::s_phdcSrc = new(cicNoThrow) CUIFBitmapDC(TRUE); @@ -2315,7 +1128,7 @@ inline void cicInitUIFUtil(void) CUIFBitmapDC::s_fInitBitmapDCs = TRUE; } -inline void cicDoneUIFUtil(void) +void cicDoneUIFUtil(void) { if (CUIFBitmapDC::s_phdcSrc) { @@ -2338,7 +1151,7 @@ inline void cicDoneUIFUtil(void) CUIFBitmapDC::s_fInitBitmapDCs = FALSE; } -inline HBITMAP cicMirrorBitmap(HBITMAP hBitmap, HBRUSH hbrBack) +HBITMAP cicMirrorBitmap(HBITMAP hBitmap, HBRUSH hbrBack) { BITMAP bm; if (!CUIFBitmapDC::s_fInitBitmapDCs || !::GetObject(hBitmap, sizeof(bm), &bm)) @@ -2355,7 +1168,7 @@ inline HBITMAP cicMirrorBitmap(HBITMAP hBitmap, HBRUSH hbrBack) ::BitBlt(*CUIFBitmapDC::s_phdcMask, 0, 0, bm.bmWidth, bm.bmHeight, *CUIFBitmapDC::s_phdcSrc, 0, 0, SRCCOPY); - ::SetLayout(*CUIFBitmapDC::s_phdcMask, LAYOUT_LTR); + ::SetLayout(*CUIFBitmapDC::s_phdcMask, 0); ::BitBlt(*CUIFBitmapDC::s_phdcDst, 0, 0, bm.bmWidth, bm.bmHeight, *CUIFBitmapDC::s_phdcMask, 1, 0, SRCCOPY); @@ -2365,7 +1178,7 @@ inline HBITMAP cicMirrorBitmap(HBITMAP hBitmap, HBRUSH hbrBack) return CUIFBitmapDC::s_phdcDst->DetachBitmap(); } -inline HBRUSH cicCreateDitherBrush(VOID) +HBRUSH cicCreateDitherBrush(VOID) { BYTE bytes[16]; ZeroMemory(&bytes, sizeof(bytes)); @@ -2383,7 +1196,7 @@ inline HBRUSH cicCreateDitherBrush(VOID) return hbr; } -inline HBITMAP +HBITMAP cicCreateDisabledBitmap(LPCRECT prc, HBITMAP hbmMask, HBRUSH hbr1, HBRUSH hbr2, BOOL bPressed) { if (!CUIFBitmapDC::s_fInitBitmapDCs) @@ -2420,7 +1233,7 @@ cicCreateDisabledBitmap(LPCRECT prc, HBITMAP hbmMask, HBRUSH hbr1, HBRUSH hbr2, return CUIFBitmapDC::s_phdcDst->DetachBitmap(); } -inline HBITMAP +HBITMAP cicCreateShadowMaskBmp(LPRECT prc, HBITMAP hbm1, HBITMAP hbm2, HBRUSH hbr1, HBRUSH hbr2) { if (!CUIFBitmapDC::s_fInitBitmapDCs) @@ -2455,7 +1268,7 @@ cicCreateShadowMaskBmp(LPRECT prc, HBITMAP hbm1, HBITMAP hbm2, HBRUSH hbr1, HBRU return CUIFBitmapDC::s_phdcDst->DetachBitmap(); } -inline HBITMAP +HBITMAP cicChangeBitmapColor(LPCRECT prc, HBITMAP hbm, COLORREF rgbBack, COLORREF rgbFore) { if (!CUIFBitmapDC::s_fInitBitmapDCs) @@ -2485,7 +1298,7 @@ cicChangeBitmapColor(LPCRECT prc, HBITMAP hbm, COLORREF rgbBack, COLORREF rgbFor return CUIFBitmapDC::s_phdcDst->DetachBitmap(); } -inline HBITMAP +HBITMAP cicConvertBlackBKGBitmap(LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, HBRUSH hBrush) { if (!CUIFBitmapDC::s_fInitBitmapDCs) @@ -2525,7 +1338,7 @@ cicConvertBlackBKGBitmap(LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, HBRUSH hBrush) return CUIFBitmapDC::s_phdcDst->DetachBitmap(); } -inline HBITMAP +HBITMAP cicCreateMaskBmp(LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, HBRUSH hbr, COLORREF rgbColor, COLORREF rgbBack) { @@ -2559,10 +1372,10 @@ cicCreateMaskBmp(LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, return CUIFBitmapDC::s_phdcDst->DetachBitmap(); } -inline BOOL cicGetIconBitmaps(HICON hIcon, HBITMAP *hbm1, HBITMAP *hbm2, const SIZE *pSize) +BOOL cicGetIconBitmaps(HICON hIcon, HBITMAP *hbm1, HBITMAP *hbm2, const SIZE *pSize) { if (!CUIFBitmapDC::s_fInitBitmapDCs) - return NULL; + return FALSE; SIZE size; if (pSize) @@ -2591,7 +1404,7 @@ inline BOOL cicGetIconBitmaps(HICON hIcon, HBITMAP *hbm1, HBITMAP *hbm2, const S return TRUE; } -inline void cicDrawMaskBmpOnDC(HDC hDC, LPCRECT prc, HBITMAP hbmp, HBITMAP hbmpMask) +void cicDrawMaskBmpOnDC(HDC hDC, LPCRECT prc, HBITMAP hbmp, HBITMAP hbmpMask) { if (!CUIFBitmapDC::s_fInitBitmapDCs) return; @@ -2610,8 +1423,9 @@ inline void cicDrawMaskBmpOnDC(HDC hDC, LPCRECT prc, HBITMAP hbmp, HBITMAP hbmpM } ///////////////////////////////////////////////////////////////////////////// +// CUIFWindow -inline CUIFWindow::CUIFWindow(HINSTANCE hInst, DWORD style) +CUIFWindow::CUIFWindow(HINSTANCE hInst, DWORD style) : CUIFObject(NULL, 0, NULL, style) { m_hInst = hInst; @@ -2632,7 +1446,7 @@ inline CUIFWindow::CUIFWindow(HINSTANCE hInst, DWORD style) CUIFWindow::CreateScheme(); } -inline CUIFWindow::~CUIFWindow() +CUIFWindow::~CUIFWindow() { if (m_pToolTip) { @@ -2659,7 +1473,7 @@ inline CUIFWindow::~CUIFWindow() } } -inline STDMETHODIMP_(BOOL) +STDMETHODIMP_(BOOL) CUIFWindow::Initialize() { LPCTSTR pszClass = GetClassName(); @@ -2706,31 +1520,31 @@ CUIFWindow::Initialize() return CUIFObject::Initialize(); } -inline STDMETHODIMP_(LRESULT) +STDMETHODIMP_(LRESULT) CUIFWindow::OnSettingChange(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return ::DefWindowProc(hWnd, uMsg, wParam, lParam); } -inline void CUIFWindow::UpdateUI(LPCRECT prc) +void CUIFWindow::UpdateUI(LPCRECT prc) { if (::IsWindow(m_hWnd)) ::InvalidateRect(m_hWnd, prc, FALSE); } -inline CUIFWindow* +CUIFWindow* CUIFWindow::GetThis(HWND hWnd) { return (CUIFWindow*)GetWindowLongPtr(hWnd, GWLP_USERDATA); } -inline void +void CUIFWindow::SetThis(HWND hWnd, LONG_PTR dwNewLong) { ::SetWindowLongPtr(hWnd, GWLP_USERDATA, dwNewLong); } -inline void CUIFWindow::CreateScheme() +void CUIFWindow::CreateScheme() { if (m_pScheme) { @@ -2750,7 +1564,7 @@ inline void CUIFWindow::CreateScheme() SetScheme(m_pScheme); } -inline STDMETHODIMP_(DWORD) +STDMETHODIMP_(DWORD) CUIFWindow::GetWndStyle() { DWORD ret; @@ -2770,7 +1584,7 @@ CUIFWindow::GetWndStyle() return ret; } -inline STDMETHODIMP_(DWORD) +STDMETHODIMP_(DWORD) CUIFWindow::GetWndStyleEx() { DWORD ret = 0; @@ -2783,7 +1597,7 @@ CUIFWindow::GetWndStyleEx() return ret; } -inline STDMETHODIMP_(HWND) +STDMETHODIMP_(HWND) CUIFWindow::CreateWnd(HWND hwndParent) { HWND hWnd = CreateWindowEx(GetWndStyleEx(), GetClassName(), GetWndTitle(), GetWndStyle(), @@ -2796,7 +1610,7 @@ CUIFWindow::CreateWnd(HWND hwndParent) return hWnd; } -inline void CUIFWindow::Show(BOOL bVisible) +void CUIFWindow::Show(BOOL bVisible) { if (!IsWindow(m_hWnd)) return; @@ -2808,7 +1622,7 @@ inline void CUIFWindow::Show(BOOL bVisible) ::ShowWindow(m_hWnd, (bVisible ? SW_SHOWNOACTIVATE : 0)); } -inline STDMETHODIMP_(BOOL) +STDMETHODIMP_(BOOL) CUIFWindow::AnimateWnd(DWORD dwTime, DWORD dwFlags) { if (!::IsWindow(m_hWnd)) @@ -2823,7 +1637,7 @@ CUIFWindow::AnimateWnd(DWORD dwTime, DWORD dwFlags) return ret; } -inline void CUIFWindow::SetCaptureObject(CUIFObject *pCaptured) +void CUIFWindow::SetCaptureObject(CUIFObject *pCaptured) { if (pCaptured) { @@ -2837,7 +1651,7 @@ inline void CUIFWindow::SetCaptureObject(CUIFObject *pCaptured) } } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFWindow::SetCapture(BOOL bSet) { if (bSet) @@ -2846,7 +1660,7 @@ CUIFWindow::SetCapture(BOOL bSet) ::ReleaseCapture(); } -inline void CUIFWindow::SetObjectPointed(CUIFObject *pPointed, POINT pt) +void CUIFWindow::SetObjectPointed(CUIFObject *pPointed, POINT pt) { if (pPointed == m_pPointed) return; @@ -2874,7 +1688,7 @@ inline void CUIFWindow::SetObjectPointed(CUIFObject *pPointed, POINT pt) } } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFWindow::OnObjectMoved(CUIFObject *pObject) { if (!::IsWindow(m_hWnd)) @@ -2888,7 +1702,7 @@ CUIFWindow::OnObjectMoved(CUIFObject *pObject) SetObjectPointed(pFound, pt2); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFWindow::SetRect(LPCRECT prc) { RECT Rect = { 0, 0, 0, 0 }; @@ -2899,7 +1713,7 @@ CUIFWindow::SetRect(LPCRECT prc) CUIFObject::SetRect(&Rect); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFWindow::ClientRectToWindowRect(LPRECT lpRect) { DWORD style, exstyle; @@ -2916,7 +1730,7 @@ CUIFWindow::ClientRectToWindowRect(LPRECT lpRect) ::AdjustWindowRectEx(lpRect, style, FALSE, exstyle); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFWindow::GetWindowFrameSize(LPSIZE pSize) { RECT rc = { 0, 0, 0, 0 }; @@ -2926,20 +1740,20 @@ CUIFWindow::GetWindowFrameSize(LPSIZE pSize) pSize->cy = (rc.bottom - rc.top) / 2; } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFWindow::OnAnimationEnd() { if (m_pShadow && m_bShowShadow) m_pShadow->Show(m_bVisible); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFWindow::OnThemeChanged(HWND hWnd, WPARAM wParam, LPARAM lParam) { ClearTheme(); } -inline LRESULT +LRESULT CUIFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) @@ -3159,7 +1973,7 @@ CUIFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return 0; } -inline LRESULT CALLBACK +LRESULT CALLBACK CUIFWindow::WindowProcedure(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { CUIFWindow *This; @@ -3195,7 +2009,7 @@ CUIFWindow::WindowProcedure(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return This->WindowProc(hWnd, uMsg, wParam, lParam); } -inline BOOL +BOOL CUIFWindow::GetWorkArea(LPCRECT prcWnd, LPRECT prcWorkArea) { if (!(m_style & (UIF_WINDOW_WORKAREA | UIF_WINDOW_MONITOR))) @@ -3225,7 +2039,7 @@ CUIFWindow::GetWorkArea(LPCRECT prcWnd, LPRECT prcWorkArea) return TRUE; } -inline void +void CUIFWindow::AdjustWindowPosition() { RECT rc; @@ -3248,12 +2062,12 @@ CUIFWindow::AdjustWindowPosition() m_nTop = rcWorkArea.bottom - m_nHeight; } -inline void CUIFWindow::SetBehindModal(CUIFWindow *pBehindModal) +void CUIFWindow::SetBehindModal(CUIFWindow *pBehindModal) { m_pBehindModal = pBehindModal; } -inline void CUIFWindow::SetTimerObject(CUIFObject *pTimerObject, UINT uElapse) +void CUIFWindow::SetTimerObject(CUIFObject *pTimerObject, UINT uElapse) { if (pTimerObject) { @@ -3267,7 +2081,7 @@ inline void CUIFWindow::SetTimerObject(CUIFObject *pTimerObject, UINT uElapse) } } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFWindow::PaintObject(HDC hDC, LPCRECT prc) { BOOL bGotDC = FALSE; @@ -3305,7 +2119,7 @@ CUIFWindow::PaintObject(HDC hDC, LPCRECT prc) ::ReleaseDC(m_hWnd, hDC); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFWindow::Move(INT x, INT y, INT nWidth, INT nHeight) { m_nLeft = x; @@ -3321,7 +2135,7 @@ CUIFWindow::Move(INT x, INT y, INT nWidth, INT nHeight) } } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFWindow::RemoveUIObj(CUIFObject *pRemove) { if (pRemove == m_pCaptured) @@ -3339,7 +2153,7 @@ CUIFWindow::RemoveUIObj(CUIFObject *pRemove) CUIFObject::RemoveUIObj(pRemove); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFWindow::HandleMouseMsg(UINT uMsg, LONG x, LONG y) { POINT pt = { x, y }; @@ -3387,9 +2201,10 @@ CUIFWindow::HandleMouseMsg(UINT uMsg, LONG x, LONG y) } ///////////////////////////////////////////////////////////////////////////// +// CUIFShadow /// @unimplemented -inline CUIFShadow::CUIFShadow(HINSTANCE hInst, DWORD style, CUIFWindow *pShadowOwner) +CUIFShadow::CUIFShadow(HINSTANCE hInst, DWORD style, CUIFWindow *pShadowOwner) : CUIFWindow(hInst, (style | UIF_WINDOW_TOOLWINDOW)) { m_pShadowOwner = pShadowOwner; @@ -3400,14 +2215,14 @@ inline CUIFShadow::CUIFShadow(HINSTANCE hInst, DWORD style, CUIFWindow *pShadowO m_bLayerAvailable = FALSE; } -inline CUIFShadow::~CUIFShadow() +CUIFShadow::~CUIFShadow() { if (m_pShadowOwner) m_pShadowOwner->m_pShadow = NULL; } /// @unimplemented -inline void CUIFShadow::InitSettings() +void CUIFShadow::InitSettings() { m_bLayerAvailable = FALSE; m_rgbShadowColor = RGB(128, 128, 128); @@ -3415,7 +2230,7 @@ inline void CUIFShadow::InitSettings() } /// @unimplemented -inline void CUIFShadow::InitShadow() +void CUIFShadow::InitShadow() { if (m_bLayerAvailable) { @@ -3423,7 +2238,7 @@ inline void CUIFShadow::InitShadow() } } -inline void CUIFShadow::AdjustWindowPos() +void CUIFShadow::AdjustWindowPos() { HWND hwndOwner = *m_pShadowOwner; if (!::IsWindow(m_hWnd)) @@ -3439,7 +2254,7 @@ inline void CUIFShadow::AdjustWindowPos() SWP_NOOWNERZORDER | SWP_NOACTIVATE); } -inline void CUIFShadow::OnOwnerWndMoved(BOOL bDoSize) +void CUIFShadow::OnOwnerWndMoved(BOOL bDoSize) { if (::IsWindow(m_hWnd) && ::IsWindowVisible(m_hWnd)) { @@ -3449,14 +2264,14 @@ inline void CUIFShadow::OnOwnerWndMoved(BOOL bDoSize) } } -inline STDMETHODIMP_(BOOL) +STDMETHODIMP_(BOOL) CUIFShadow::Initialize() { InitSettings(); return CUIFWindow::Initialize(); } -inline STDMETHODIMP_(DWORD) +STDMETHODIMP_(DWORD) CUIFShadow::GetWndStyleEx() { DWORD exstyle = CUIFWindow::GetWndStyleEx(); @@ -3465,7 +2280,7 @@ CUIFShadow::GetWndStyleEx() return exstyle; } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFShadow::OnPaint(HDC hDC) { RECT rc = m_rc; @@ -3474,7 +2289,7 @@ CUIFShadow::OnPaint(HDC hDC) ::DeleteObject(hBrush); } -inline STDMETHODIMP_(LRESULT) +STDMETHODIMP_(LRESULT) CUIFShadow::OnWindowPosChanging(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { WINDOWPOS *wp = (WINDOWPOS *)lParam; @@ -3482,7 +2297,7 @@ CUIFShadow::OnWindowPosChanging(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPara return ::DefWindowProc(hWnd, Msg, wParam, lParam); } -inline STDMETHODIMP_(LRESULT) +STDMETHODIMP_(LRESULT) CUIFShadow::OnSettingChange(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { InitSettings(); @@ -3501,7 +2316,7 @@ CUIFShadow::OnSettingChange(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return ::DefWindowProc(hWnd, uMsg, wParam, lParam); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFShadow::Show(BOOL bVisible) { if (bVisible && ::IsWindow(m_hWnd) && !::IsWindowVisible(m_hWnd)) @@ -3518,8 +2333,8 @@ CUIFShadow::Show(BOOL bVisible) } ///////////////////////////////////////////////////////////////////////////// +// CUIFToolTip -inline CUIFToolTip::CUIFToolTip(HINSTANCE hInst, DWORD style, CUIFWindow *pToolTipOwner) : CUIFWindow(hInst, style) { @@ -3541,7 +2356,6 @@ CUIFToolTip::CUIFToolTip(HINSTANCE hInst, DWORD style, CUIFWindow *pToolTipOwner m_rgbToolTipTextColor = 0; } -inline CUIFToolTip::~CUIFToolTip() { if (m_pToolTipOwner) @@ -3550,7 +2364,7 @@ CUIFToolTip::~CUIFToolTip() delete[] m_pszToolTipText; } -inline LONG +LONG CUIFToolTip::GetDelayTime(UINT uType) { LONG nDelayTime; @@ -3584,13 +2398,13 @@ CUIFToolTip::GetDelayTime(UINT uType) } } -inline void CUIFToolTip::GetMargin(LPRECT prc) +void CUIFToolTip::GetMargin(LPRECT prc) { if (prc) *prc = m_rcToolTipMargin; } -inline COLORREF +COLORREF CUIFToolTip::GetTipBkColor() { if (m_bToolTipHasBkColor) @@ -3598,7 +2412,7 @@ CUIFToolTip::GetTipBkColor() return ::GetSysColor(COLOR_INFOBK); } -inline COLORREF +COLORREF CUIFToolTip::GetTipTextColor() { if (m_bToolTipHasTextColor) @@ -3606,7 +2420,7 @@ CUIFToolTip::GetTipTextColor() return ::GetSysColor(COLOR_INFOTEXT); } -inline CUIFObject* +CUIFObject* CUIFToolTip::FindObject(HWND hWnd, POINT pt) { if (hWnd == *m_pToolTipOwner) @@ -3614,7 +2428,7 @@ CUIFToolTip::FindObject(HWND hWnd, POINT pt) return NULL; } -inline void +void CUIFToolTip::ShowTip() { ::KillTimer(m_hWnd, TOOLTIP_TIMER_ID); @@ -3658,7 +2472,7 @@ CUIFToolTip::ShowTip() Show(TRUE); } -inline void +void CUIFToolTip::HideTip() { ::KillTimer(m_hWnd, TOOLTIP_TIMER_ID); @@ -3678,7 +2492,7 @@ CUIFToolTip::HideTip() } } -inline void +void CUIFToolTip::GetTipWindowSize(LPSIZE pSize) { if (!m_pszToolTipText) @@ -3716,7 +2530,7 @@ CUIFToolTip::GetTipWindowSize(LPSIZE pSize) ::ReleaseDC(m_hWnd, hDC); } -inline void +void CUIFToolTip::GetTipWindowRect(LPRECT pRect, SIZE toolTipSize, LPCRECT prc) { POINT Point; @@ -3785,7 +2599,7 @@ CUIFToolTip::GetTipWindowRect(LPRECT pRect, SIZE toolTipSize, LPCRECT prc) } } -inline void +void CUIFToolTip::RelayEvent(LPMSG pMsg) { if (!pMsg) @@ -3834,7 +2648,7 @@ CUIFToolTip::RelayEvent(LPMSG pMsg) } } -inline STDMETHODIMP_(void) CUIFToolTip::OnPaint(HDC hDC) +STDMETHODIMP_(void) CUIFToolTip::OnPaint(HDC hDC) { HGDIOBJ hFontOld = ::SelectObject(hDC, m_hFont); INT iBkModeOld = ::SetBkMode(hDC, TRANSPARENT); @@ -3869,22 +2683,22 @@ inline STDMETHODIMP_(void) CUIFToolTip::OnPaint(HDC hDC) ::SelectObject(hDC, hFontOld); } -inline STDMETHODIMP_(void) CUIFToolTip::Enable(BOOL bEnable) +STDMETHODIMP_(void) CUIFToolTip::Enable(BOOL bEnable) { if (!bEnable) HideTip(); CUIFObject::Enable(bEnable); } -inline STDMETHODIMP_(void) CUIFToolTip::OnTimer(WPARAM wParam) +STDMETHODIMP_(void) CUIFToolTip::OnTimer(WPARAM wParam) { if (wParam == TOOLTIP_TIMER_ID) ShowTip(); } ///////////////////////////////////////////////////////////////////////////// +// CUIFButton -inline CUIFButton::CUIFButton( CUIFObject *pParent, DWORD nObjectID, @@ -3901,7 +2715,7 @@ CUIFButton::CUIFButton( m_pszButtonText = NULL; } -inline CUIFButton::~CUIFButton() +CUIFButton::~CUIFButton() { if (m_pszButtonText) { @@ -3913,7 +2727,7 @@ inline CUIFButton::~CUIFButton() ImageList_Destroy(m_ButtonIcon.m_hImageList); } -inline void +void CUIFButton::DrawBitmapProc(HDC hDC, LPCRECT prc, BOOL bPressed) { INT width = m_rc.right - m_rc.left; @@ -3937,7 +2751,7 @@ CUIFButton::DrawBitmapProc(HDC hDC, LPCRECT prc, BOOL bPressed) } } -inline void +void CUIFButton::DrawEdgeProc(HDC hDC, LPCRECT prc, BOOL bPressed) { RECT rc = *prc; @@ -3947,7 +2761,7 @@ CUIFButton::DrawEdgeProc(HDC hDC, LPCRECT prc, BOOL bPressed) ::DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT); } -inline void CUIFButton::DrawIconProc(HDC hDC, LPRECT prc, BOOL bPressed) +void CUIFButton::DrawIconProc(HDC hDC, LPRECT prc, BOOL bPressed) { INT width = prc->right - prc->left; INT height = prc->bottom - prc->top; @@ -4001,7 +2815,7 @@ inline void CUIFButton::DrawIconProc(HDC hDC, LPRECT prc, BOOL bPressed) ::DeleteDC(hMemDC); } -inline void +void CUIFButton::DrawTextProc(HDC hDC, LPCRECT prc, BOOL bPressed) { if (!m_pszButtonText) @@ -4055,7 +2869,7 @@ CUIFButton::DrawTextProc(HDC hDC, LPCRECT prc, BOOL bPressed) ::SelectObject(hDC, hFontOld); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFButton::Enable(BOOL bEnable) { CUIFObject::Enable(bEnable); @@ -4067,7 +2881,7 @@ CUIFButton::Enable(BOOL bEnable) } } -inline void +void CUIFButton::GetIconSize(HICON hIcon, LPSIZE pSize) { ICONINFO IconInfo; @@ -4087,7 +2901,7 @@ CUIFButton::GetIconSize(HICON hIcon, LPSIZE pSize) } } -inline void +void CUIFButton::GetTextSize(LPCWSTR pszText, LPSIZE pSize) { HDC hDC = ::GetDC(NULL); @@ -4117,7 +2931,7 @@ CUIFButton::GetTextSize(LPCWSTR pszText, LPSIZE pSize) ::ReleaseDC(NULL, hDC); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFButton::OnLButtonDown(LONG x, LONG y) { SetStatus(1); @@ -4127,7 +2941,7 @@ CUIFButton::OnLButtonDown(LONG x, LONG y) } /// @unimplemented -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFButton::OnLButtonUp(LONG x, LONG y) { POINT pt = { x, y }; @@ -4170,7 +2984,7 @@ CUIFButton::OnLButtonUp(LONG x, LONG y) } } -inline void CUIFButton::OnMouseIn(LONG x, LONG y) +void CUIFButton::OnMouseIn(LONG x, LONG y) { if ((m_style & 0x30) == 0x20) { @@ -4188,7 +3002,7 @@ inline void CUIFButton::OnMouseIn(LONG x, LONG y) } } -inline void CUIFButton::OnMouseOut(LONG x, LONG y) +void CUIFButton::OnMouseOut(LONG x, LONG y) { if ((m_style & 0x30) == 0x20) SetStatus(0); @@ -4198,7 +3012,7 @@ inline void CUIFButton::OnMouseOut(LONG x, LONG y) SetStatus(0); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFButton::OnPaintNoTheme(HDC hDC) { ::FillRect(hDC, &m_rc, (HBRUSH)UlongToHandle(COLOR_BTNFACE + 1)); @@ -4233,7 +3047,7 @@ CUIFButton::OnPaintNoTheme(HDC hDC) DrawEdgeProc(hDC, &m_rc, FALSE); } -inline void CUIFButton::SetIcon(HICON hIcon) +void CUIFButton::SetIcon(HICON hIcon) { m_ButtonIcon = hIcon; @@ -4245,7 +3059,7 @@ inline void CUIFButton::SetIcon(HICON hIcon) CallOnPaint(); } -inline void CUIFButton::SetStatus(UINT uStatus) +void CUIFButton::SetStatus(UINT uStatus) { if (uStatus != m_uButtonStatus) { @@ -4254,7 +3068,7 @@ inline void CUIFButton::SetStatus(UINT uStatus) } } -inline void CUIFButton::SetText(LPCWSTR pszText) +void CUIFButton::SetText(LPCWSTR pszText) { if (m_pszButtonText) { @@ -4279,8 +3093,9 @@ inline void CUIFButton::SetText(LPCWSTR pszText) } ///////////////////////////////////////////////////////////////////////////// +// CUIFButton2 -inline CUIFButton2::CUIFButton2( +CUIFButton2::CUIFButton2( CUIFObject *pParent, DWORD nObjectID, LPCRECT prc, @@ -4291,12 +3106,12 @@ inline CUIFButton2::CUIFButton2( m_pszClassList = L"TOOLBAR"; } -inline CUIFButton2::~CUIFButton2() +CUIFButton2::~CUIFButton2() { CloseThemeData(); } -inline DWORD CUIFButton2::MakeDrawFlag() +DWORD CUIFButton2::MakeDrawFlag() { DWORD dwDrawFlags = 0; if (m_bPressed) @@ -4311,14 +3126,14 @@ inline DWORD CUIFButton2::MakeDrawFlag() } /// @unimplemented -inline STDMETHODIMP_(BOOL) +STDMETHODIMP_(BOOL) CUIFButton2::OnPaintTheme(HDC hDC) { //FIXME return FALSE; } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFButton2::OnPaintNoTheme(HDC hDC) { if (!m_pScheme) @@ -4341,17 +3156,13 @@ CUIFButton2::OnPaintNoTheme(HDC hDC) HGDIOBJ hFontOld = ::SelectObject(hdcMem, m_hFont); RECT rcBack = { 0, 0, width, height }; - INT cxText, cyText, cxContent, cyContent, cxyBorders, cxButton, cyButton; + INT cxText = 0, cyText = 0, cxContent = 0, cyContent = 0; + INT cxyBorders, cxButton, cyButton; if (m_pszButtonText) { cxText = m_TextSize.cx; cyText = m_TextSize.cy; } - else - { - cxText = 0; - cyText = cyText; - } if (m_ButtonIcon.m_hIcon) { @@ -4377,8 +3188,8 @@ CUIFButton2::OnPaintNoTheme(HDC hDC) { cxyBorders = ((cxText && cxContent) ? 2 : 0); - cyButton = cyContent; cxButton = cxText + cxContent + cxyBorders; + cyButton = cyContent; if (cyText > cyButton) cyButton = cyText; } @@ -4464,8 +3275,8 @@ CUIFButton2::OnPaintNoTheme(HDC hDC) } ///////////////////////////////////////////////////////////////////////////// +// CUIFGripper -inline CUIFGripper::CUIFGripper(CUIFObject *pParent, LPCRECT prc, DWORD style) : CUIFObject(pParent, 0, prc, style) { @@ -4477,11 +3288,11 @@ CUIFGripper::CUIFGripper(CUIFObject *pParent, LPCRECT prc, DWORD style) m_iPartId = RP_GRIPPER; } -inline CUIFGripper::~CUIFGripper() +CUIFGripper::~CUIFGripper() { } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFGripper::OnMouseMove(LONG x, LONG y) { if (IsCapture()) @@ -4492,7 +3303,7 @@ CUIFGripper::OnMouseMove(LONG x, LONG y) } } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFGripper::OnLButtonDown(LONG x, LONG y) { StartCapture(); @@ -4505,14 +3316,14 @@ CUIFGripper::OnLButtonDown(LONG x, LONG y) m_ptGripper.y -= rc.top; } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFGripper::OnLButtonUp(LONG x, LONG y) { if (IsCapture()) EndCapture(); } -inline STDMETHODIMP_(BOOL) +STDMETHODIMP_(BOOL) CUIFGripper::OnPaintTheme(HDC hDC) { if (FAILED(EnsureThemeData(*m_pWindow))) @@ -4535,7 +3346,7 @@ CUIFGripper::OnPaintTheme(HDC hDC) return TRUE; } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFGripper::OnPaintNoTheme(HDC hDC) { if (m_pScheme) @@ -4553,7 +3364,7 @@ CUIFGripper::OnPaintNoTheme(HDC hDC) ::DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT); } -inline STDMETHODIMP_(BOOL) +STDMETHODIMP_(BOOL) CUIFGripper::OnSetCursor(UINT uMsg, LONG x, LONG y) { HCURSOR hCursor = ::LoadCursor(NULL, IDC_SIZEALL); @@ -4561,7 +3372,7 @@ CUIFGripper::OnSetCursor(UINT uMsg, LONG x, LONG y) return TRUE; } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFGripper::SetStyle(DWORD style) { m_style = style; @@ -4572,8 +3383,8 @@ CUIFGripper::SetStyle(DWORD style) } ///////////////////////////////////////////////////////////////////////////// +// CUIFToolbarMenuButton -inline CUIFToolbarMenuButton::CUIFToolbarMenuButton( CUIFToolbarButton *pParent, DWORD nObjectID, @@ -4588,21 +3399,20 @@ CUIFToolbarMenuButton::CUIFToolbarMenuButton( SetText(L"u"); // downward triangle } -inline CUIFToolbarMenuButton::~CUIFToolbarMenuButton() { ::DeleteObject(m_hFont); SetFont(NULL); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFToolbarMenuButton::OnLButtonUp(LONG x, LONG y) { CUIFButton::OnLButtonUp(x, y); m_pToolbarButton->OnUnknownMouse2(x, y); } -inline STDMETHODIMP_(BOOL) +STDMETHODIMP_(BOOL) CUIFToolbarMenuButton::OnSetCursor(UINT uMsg, LONG x, LONG y) { m_pToolbarButton->OnSetCursor(uMsg, x, y); @@ -4610,8 +3420,8 @@ CUIFToolbarMenuButton::OnSetCursor(UINT uMsg, LONG x, LONG y) } ///////////////////////////////////////////////////////////////////////////// +// CUIFToolbarButtonElement -inline CUIFToolbarButtonElement::CUIFToolbarButtonElement( CUIFToolbarButton *pParent, DWORD nObjectID, @@ -4621,7 +3431,7 @@ CUIFToolbarButtonElement::CUIFToolbarButtonElement( m_pToolbarButton = pParent; } -inline STDMETHODIMP_(LPCWSTR) +STDMETHODIMP_(LPCWSTR) CUIFToolbarButtonElement::GetToolTip() { if (m_pToolbarButton) @@ -4629,7 +3439,7 @@ CUIFToolbarButtonElement::GetToolTip() return NULL; } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFToolbarButtonElement::OnLButtonUp(LONG x, LONG y) { CUIFButton::OnLButtonUp(x, y); @@ -4639,7 +3449,7 @@ CUIFToolbarButtonElement::OnLButtonUp(LONG x, LONG y) m_pToolbarButton->OnUnknownMouse1(x, y); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFToolbarButtonElement::OnRButtonUp(LONG x, LONG y) { if ((m_pToolbarButton->m_dwToolbarButtonFlags & 0x30000) != 0x20000) @@ -4647,8 +3457,9 @@ CUIFToolbarButtonElement::OnRButtonUp(LONG x, LONG y) } ///////////////////////////////////////////////////////////////////////////// +// CUIFToolbarButton -inline CUIFToolbarButton::CUIFToolbarButton( +CUIFToolbarButton::CUIFToolbarButton( CUIFObject *pParent, DWORD nObjectID, LPCRECT prc, @@ -4660,7 +3471,7 @@ inline CUIFToolbarButton::CUIFToolbarButton( m_pszUnknownText = pszUnknownText; } -inline BOOL CUIFToolbarButton::Init() +BOOL CUIFToolbarButton::Init() { RECT rc1, rc2; rc1 = rc2 = m_rc; @@ -4706,17 +3517,17 @@ inline BOOL CUIFToolbarButton::Init() return TRUE; } -inline HICON CUIFToolbarButton::GetIcon() +HICON CUIFToolbarButton::GetIcon() { return m_pToolbarButtonElement->m_ButtonIcon.m_hIcon; } -inline void CUIFToolbarButton::SetIcon(HICON hIcon) +void CUIFToolbarButton::SetIcon(HICON hIcon) { m_pToolbarButtonElement->SetIcon(hIcon); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFToolbarButton::ClearWndObj() { if (m_pToolbarButtonElement) @@ -4727,7 +3538,7 @@ CUIFToolbarButton::ClearWndObj() CUIFObject::ClearWndObj(); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFToolbarButton::DetachWndObj() { if (m_pToolbarButtonElement) @@ -4738,7 +3549,7 @@ CUIFToolbarButton::DetachWndObj() CUIFObject::DetachWndObj(); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFToolbarButton::Enable(BOOL bEnable) { CUIFObject::Enable(bEnable); @@ -4748,13 +3559,13 @@ CUIFToolbarButton::Enable(BOOL bEnable) m_pToolbarMenuButton->Enable(bEnable); } -inline STDMETHODIMP_(LPCWSTR) +STDMETHODIMP_(LPCWSTR) CUIFToolbarButton::GetToolTip() { return CUIFObject::GetToolTip(); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFToolbarButton::SetActiveTheme(LPCWSTR pszClassList, INT iPartId, INT iStateId) { if (m_pToolbarButtonElement) @@ -4767,13 +3578,13 @@ CUIFToolbarButton::SetActiveTheme(LPCWSTR pszClassList, INT iPartId, INT iStateI m_iStateId = iStateId; } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFToolbarButton::SetFont(HFONT hFont) { m_pToolbarButtonElement->SetFont(hFont); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFToolbarButton::SetRect(LPCRECT prc) { CUIFObject::SetRect(prc); @@ -4793,7 +3604,7 @@ CUIFToolbarButton::SetRect(LPCRECT prc) m_pToolbarMenuButton->SetRect(&rc2); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFToolbarButton::SetToolTip(LPCWSTR pszToolTip) { CUIFObject::SetToolTip(pszToolTip); @@ -4804,8 +3615,8 @@ CUIFToolbarButton::SetToolTip(LPCWSTR pszToolTip) } ///////////////////////////////////////////////////////////////////////////// +// CUIFWndFrame -inline CUIFWndFrame::CUIFWndFrame( CUIFObject *pParent, LPCRECT prc, @@ -4835,13 +3646,13 @@ CUIFWndFrame::CUIFWndFrame( m_cyMin = GetSystemMetrics(SM_CYMIN); } -inline void CUIFWndFrame::GetFrameSize(LPSIZE pSize) +void CUIFWndFrame::GetFrameSize(LPSIZE pSize) { pSize->cx = m_cxFrame; pSize->cy = m_cyFrame; } -inline DWORD CUIFWndFrame::HitTest(LONG x, LONG y) +DWORD CUIFWndFrame::HitTest(LONG x, LONG y) { DWORD dwFlags = 0; if ( m_rc.left <= x && x < m_rc.left + m_cxFrame) @@ -4855,7 +3666,7 @@ inline DWORD CUIFWndFrame::HitTest(LONG x, LONG y) return dwFlags; } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFWndFrame::OnMouseMove(LONG x, LONG y) { if (!IsCapture()) @@ -4889,7 +3700,7 @@ CUIFWndFrame::OnMouseMove(LONG x, LONG y) m_pWindow->Move(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFWndFrame::OnLButtonDown(LONG x, LONG y) { POINT Point = { x, y }; @@ -4905,14 +3716,14 @@ CUIFWndFrame::OnLButtonDown(LONG x, LONG y) StartCapture(); } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFWndFrame::OnLButtonUp(LONG x, LONG y) { if (IsCapture()) EndCapture(); } -inline STDMETHODIMP_(BOOL) +STDMETHODIMP_(BOOL) CUIFWndFrame::OnPaintTheme(HDC hDC) { if (FAILED(EnsureThemeData(*m_pWindow))) @@ -4941,7 +3752,7 @@ CUIFWndFrame::OnPaintTheme(HDC hDC) return TRUE; } -inline STDMETHODIMP_(void) +STDMETHODIMP_(void) CUIFWndFrame::OnPaintNoTheme(HDC hDC) { if (!m_pScheme) @@ -4956,7 +3767,7 @@ CUIFWndFrame::OnPaintNoTheme(HDC hDC) m_pScheme->DrawWndFrame(hDC, &m_rc, type, m_cxFrame, m_cyFrame); } -inline STDMETHODIMP_(BOOL) +STDMETHODIMP_(BOOL) CUIFWndFrame::OnSetCursor(UINT uMsg, LONG x, LONG y) { DWORD dwHitTest = m_dwHitTest; @@ -4992,8 +3803,8 @@ CUIFWndFrame::OnSetCursor(UINT uMsg, LONG x, LONG y) } ///////////////////////////////////////////////////////////////////////////// +// CUIFBalloonButton -inline CUIFBalloonButton::CUIFBalloonButton( CUIFObject *pParent, DWORD nObjectID, @@ -5003,7 +3814,7 @@ CUIFBalloonButton::CUIFBalloonButton( m_nCommandID = 0; ... 1908 lines suppressed ...
10 months, 1 week
1
0
0
0
[reactos] 01/01: [UXTHEME] Add Ukrainian (uk-UA) translation (#6502)
by Oleg Dubinskiy
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=21e139d1d105d19d5b8e0…
commit 21e139d1d105d19d5b8e00dc9a98bab12f2ab3d3 Author: Oleg Dubinskiy <oleg.dubinskij30(a)gmail.com> AuthorDate: Fri Feb 16 20:50:13 2024 +0100 Commit: GitHub <noreply(a)github.com> CommitDate: Fri Feb 16 22:50:13 2024 +0300 [UXTHEME] Add Ukrainian (uk-UA) translation (#6502) Addendum to d11582f0e. CORE-5991 --- dll/win32/uxtheme/lang/uk-UA.rc | 19 +++++++++++++++++++ dll/win32/uxtheme/uxtheme.rc | 3 +++ 2 files changed, 22 insertions(+) diff --git a/dll/win32/uxtheme/lang/uk-UA.rc b/dll/win32/uxtheme/lang/uk-UA.rc new file mode 100644 index 00000000000..f6b6ad472dd --- /dev/null +++ b/dll/win32/uxtheme/lang/uk-UA.rc @@ -0,0 +1,19 @@ +/* + * PROJECT: ReactOS uxtheme.dll + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Ukrainian resource file + * TRANSLATOR: Copyright 2024 Oleg Dubinskiy <oleg.dubinskij30(a)gmail.com> + */ + +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT + +/* Strings */ + +STRINGTABLE +BEGIN + IDS_MESSAGEBOX "Вікно повідомлення" + IDS_ACTIVEWIN "Активне вікно" + IDS_INACTIVEWIN "Неактивне вікно" + IDS_OK "ОК" + IDS_WINTEXT "Текст у вікні" +END diff --git a/dll/win32/uxtheme/uxtheme.rc b/dll/win32/uxtheme/uxtheme.rc index 69feed2ac73..041990e358c 100644 --- a/dll/win32/uxtheme/uxtheme.rc +++ b/dll/win32/uxtheme/uxtheme.rc @@ -25,3 +25,6 @@ #ifdef LANGUAGE_RU_RU #include "lang/ru-RU.rc" #endif +#ifdef LANGUAGE_UK_UA + #include "lang/uk-UA.rc" +#endif
10 months, 1 week
1
0
0
0
← Newer
1
2
3
4
5
6
...
13
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
Results per page:
10
25
50
100
200