https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f170276fd263b4c69740042beda9fa534abd45f4

commit f170276fd263b4c69740042beda9fa534abd45f4
Author:     Katayama Hirofumi MZ <katayama.hirofumi...@gmail.com>
AuthorDate: Wed Jan 24 14:41:04 2024 +0900
Commit:     GitHub <nore...@github.com>
CommitDate: Wed Jan 24 14:41:04 2024 +0900

    [SDK] cicuif.h: Fix CUIFMenu::InitShow (#6402)
    
    Supporting Language Bar...
    JIRA issue: CORE-19363
    Implement CUIFMenu::InitShow method.
---
 sdk/include/reactos/cicero/cicuif.h | 149 +++++++++++++++++++++++++++++++++++-
 1 file changed, 147 insertions(+), 2 deletions(-)

diff --git a/sdk/include/reactos/cicero/cicuif.h 
b/sdk/include/reactos/cicero/cicuif.h
index 257df7162d8..ba366c6f674 100644
--- a/sdk/include/reactos/cicero/cicuif.h
+++ b/sdk/include/reactos/cicero/cicuif.h
@@ -5579,11 +5579,156 @@ inline void CUIFMenu::HandleMouseMsg(UINT uMsg, LONG 
x, LONG y)
     CUIFWindow::HandleMouseMsg(uMsg, x, y);
 }
 
-/// @unimplemented
 inline STDMETHODIMP_(BOOL)
 CUIFMenu::InitShow(CUIFWindow *pWindow, LPCRECT prc, BOOL bFlag, BOOL 
bDoAnimation)
 {
-    //FIXME
+    HWND hWnd = NULL;
+    if (pWindow)
+        hWnd = *pWindow;
+
+    CreateWnd(hWnd);
+
+    m_bHasMargin = FALSE;
+
+    for (size_t iItem = 0; iItem < m_MenuItems.size(); ++iItem)
+    {
+        if (m_MenuItems[iItem])
+            m_MenuItems[iItem]->InitMenuExtent();
+    }
+
+    INT cxMax = 0;
+
+    m_cxMenuExtent = 0;
+    for (size_t iItem = 0; iItem < m_MenuItems.size(); ++iItem)
+    {
+        CUIFMenuItem *pItem = m_MenuItems[iItem];
+        if (!pItem)
+            continue;
+
+        INT cxItem = m_cxyMargin + pItem->m_MenuLeftExtent.cx;
+        if (cxMax < cxItem)
+            cxMax = cxItem;
+        m_cxMenuExtent = max(m_cxMenuExtent, pItem->m_MenuRightExtent.cx);
+        if (!m_bHasMargin && pItem->m_hbmColor && pItem->IsCheck())
+            m_bHasMargin = TRUE;
+    }
+
+    RECT rcItem = { 0, 0, 0, 0 };
+    for (size_t iItem = 0; iItem < m_MenuItems.size(); ++iItem)
+    {
+        CUIFMenuItem *pItem = m_MenuItems[iItem];
+        if (!pItem)
+            continue;
+
+        INT cyItem = pItem->m_MenuLeftExtent.cy;
+        rcItem.right = rcItem.left + cxMax + m_cxMenuExtent;
+        rcItem.bottom = rcItem.top + cyItem;
+        pItem->SetRect(&rcItem);
+        rcItem.top += cyItem;
+        AddUIObj(pItem);
+    }
+
+    rcItem.top = 0;
+    DWORD style = ::GetWindowLongPtr(hWnd, GWL_STYLE);
+    cxMax = rcItem.right;
+    INT cyMax = rcItem.bottom;
+    if (style & WS_DLGFRAME)
+    {
+        cxMax = rcItem.right + 2 * ::GetSystemMetrics(SM_CXDLGFRAME);
+        cyMax += 2 * ::GetSystemMetrics(SM_CYDLGFRAME);
+    }
+    else if (style & WS_BORDER)
+    {
+        cxMax = rcItem.right + 2 * ::GetSystemMetrics(SM_CXBORDER);
+        cyMax += 2 * ::GetSystemMetrics(SM_CYBORDER);
+    }
+
+    RECT rc = { 0, 0, ::GetSystemMetrics(SM_CXSCREEN), 
::GetSystemMetrics(SM_CYSCREEN) };
+
+    RECT rc3 = *prc;
+    HMONITOR hMon = ::MonitorFromRect(&rc3, MONITOR_DEFAULTTONEAREST);
+    if (hMon)
+    {
+        MONITORINFO mi = { sizeof(mi) };
+        if (::GetMonitorInfo(hMon, &mi))
+            rc = mi.rcMonitor;
+    }
+
+    if (m_style & 0x200)
+        rcItem.left -= cxMax;
+
+    INT x, y;
+    DWORD dwFlags2 = 0;
+
+    if (bFlag)
+    {
+        INT bottom = prc->bottom;
+        x = rcItem.left + prc->left;
+        if (rcItem.top + bottom + cyMax > rc.bottom)
+        {
+            bottom = prc->top - cyMax;
+            dwFlags2 = 8;
+        }
+        else
+        {
+            dwFlags2 = 4;
+        }
+
+        y = rcItem.top + bottom;
+
+        if (rcItem.left + cxMax + prc->right > rc.right)
+            x = rc.right - cxMax;
+    }
+    else
+    {
+        y = rcItem.top + prc->top;
+        if (rcItem.left + prc->right + cxMax > rc.right)
+        {
+            x = rcItem.left + prc->left - cxMax;
+            dwFlags2 = 2;
+        }
+        else
+        {
+            x = rcItem.left + prc->right;
+            dwFlags2 = 1;
+        }
+        if (rcItem.top + cyMax + prc->bottom > rc.bottom)
+            y = rc.bottom - cyMax;
+    }
+
+    if (x > rc.right - cxMax)
+        x = rc.right - cxMax;
+    if (x < rc.left)
+        x = rc.left;
+    if (y > rc.bottom - cyMax)
+        y = rc.bottom - cyMax;
+    if (y < rc.top)
+        y = rc.top;
+
+    Move(x, y, cxMax, -1);
+
+    SetRect(NULL);
+
+    BOOL bAnimation = FALSE;
+    if (bDoAnimation &&
+        ::SystemParametersInfo(SPI_GETMENUANIMATION, 0, &bAnimation, 0) && 
bAnimation)
+    {
+        BOOL bMenuFade = FALSE;
+        if (!::SystemParametersInfoA(SPI_GETMENUFADE, 0, &bMenuFade, 0))
+            bMenuFade = FALSE;
+
+        DWORD dwFlags = (bMenuFade ? 0x80000 : dwFlags2) | 0x40000;
+        if (!AnimateWnd(200, dwFlags))
+            Show(TRUE);
+    }
+    else
+    {
+        Show(TRUE);
+    }
+
+    if (m_pVisibleSubMenu)
+        m_pVisibleSubMenu->m_pParentMenu = this;
+
     return TRUE;
 }
 

Reply via email to