Skip to content

Commit a57ce19

Browse files
committed
Added menu alignment handling
1 parent 0fdad23 commit a57ce19

File tree

1 file changed

+49
-46
lines changed

1 file changed

+49
-46
lines changed

miniwindow.cpp

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3579,6 +3579,7 @@ CMenu* GrabAMenu (void)
35793579
CString CMiniWindow::Menu(long Left, long Top, LPCTSTR Items, CMUSHView* pView)
35803580
{
35813581
CString strResult;
3582+
int align = TPM_LEFTALIGN | TPM_TOPALIGN; // these are actually both zero
35823583

35833584
// can't menu if not visible
35843585
if (!m_bShow || m_bTemporarilyHide)
@@ -3606,60 +3607,62 @@ CString strResult;
36063607
p++;
36073608
}
36083609

3609-
vector<string> v;
3610-
3611-
StringToVector (p, v, "|");
3612-
3613-
int iCount = v.size ();
3614-
3615-
// must have at least one item
3616-
if (iCount < 1)
3617-
return strResult;
3610+
// alignment
36183611

3619-
#if 0 // AARRRRRRRRGGGGGGGGGGGHHHHHHHHHHHHHHH!!!!!!!!!!!!!!!!!!!
3620-
3621-
// if we are doing this in response to a mouse-down, we have to cancel the
3622-
// mouse-down event now, or things get confused
3623-
3624-
if (!pView->m_sPreviousMiniWindow.empty ())
3612+
if (*p == '~' && strlen (p) > 3)
36253613
{
3626-
CMUSHclientDoc* pDoc = pView->GetDocument();
3627-
3628-
MiniWindowMapIterator it = pDoc->m_MiniWindows.find (pView->m_sPreviousMiniWindow);
3629-
3630-
if (it != pDoc->m_MiniWindows.end ())
3614+
p++; // skip the '~'
3615+
// horizontal alignment
3616+
switch (*p++)
36313617
{
3618+
case 'c':
3619+
case 'C':
3620+
align |= TPM_CENTERALIGN;
3621+
break;
3622+
case 'l':
3623+
case 'L':
3624+
align |= TPM_LEFTALIGN;
3625+
break;
3626+
case 'r':
3627+
case 'R':
3628+
align |= TPM_RIGHTALIGN;
3629+
break;
3630+
default:
3631+
// ignore
3632+
break;
3633+
} // end of switch
36323634

3633-
CMiniWindow * old_mw = it->second;
3634-
3635-
// cancel previous move-down hotspot
3636-
if (!old_mw->m_sMouseDownHotspot.empty ()) // HotspotId was used
3637-
{
3638-
// lookup that HotspotId
3639-
HotspotMapIterator it = old_mw->m_Hotspots.find (old_mw->m_sMouseDownHotspot);
3640-
3641-
// call CancelMouseDown for that hotspot, if it exists
3642-
if (it != old_mw->m_Hotspots.end ())
3643-
{
3644-
m_last_mouseup = m_last_mousemove;
3645-
pView->Send_Mouse_Event_To_Plugin (old_mw->m_sCallbackPlugin,
3646-
it->second->m_sCancelMouseDown,
3647-
old_mw->m_sMouseDownHotspot);
3648-
}
3649-
old_mw->m_sMouseDownHotspot.erase (); // no mouse-down right now
3650-
} // we had previous hotspot
3651-
3652-
} // previous window still exists
3635+
// vertical alignment
3636+
switch (*p++)
3637+
{
3638+
case 'c':
3639+
case 'C':
3640+
align |= TPM_VCENTERALIGN;
3641+
break;
3642+
case 'b':
3643+
case 'B':
3644+
align |= TPM_BOTTOMALIGN;
3645+
break;
3646+
case 't':
3647+
case 'T':
3648+
align |= TPM_TOPALIGN;
3649+
break;
3650+
default:
3651+
// ignore
3652+
break;
3653+
} // end of switch
36533654

3654-
pView->m_sPreviousMiniWindow.erase (); // no longer have a previous window
3655-
ReleaseCapture(); // Release the mouse capture established at
3656-
// the beginning of the mouse click.
3655+
} // end of alignment code
36573656

3658-
} // released mouse in different window
3657+
vector<string> v;
36593658

3660-
#endif // AARRRRRRRRGGGGGGGGGGGHHHHHHHHHHHHHHH!!!!!!!!!!!!!!!!!!!
3659+
StringToVector (p, v, "|");
36613660

3661+
int iCount = v.size ();
36623662

3663+
// must have at least one item
3664+
if (iCount < 1)
3665+
return strResult;
36633666

36643667
CPoint menupoint (Left, Top);
36653668

@@ -3734,7 +3737,7 @@ CPoint menupoint (Left, Top);
37343737
// without this line the auto-enable always set "no items" to active
37353738
Frame.m_bAutoMenuEnable = FALSE;
37363739

3737-
int iResult = vPopup.front ()->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD,
3740+
int iResult = vPopup.front ()->TrackPopupMenu(align | TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD,
37383741
menupoint.x,
37393742
menupoint.y,
37403743
pWndPopupOwner);

0 commit comments

Comments
 (0)