Skip to content

Commit

Permalink
Added GetInfo (294), changed way scroll wheel works
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Jun 23, 2010
1 parent cb3a144 commit 673a568
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 14 deletions.
29 changes: 15 additions & 14 deletions mushview.cpp
Expand Up @@ -4890,13 +4890,6 @@ CRect rect;
unsigned int iScrollLines;


/*
* Don't handle zoom and datazoom.
*/

if (nFlags & MK_CONTROL || nFlags & MK_SHIFT)
return CView::OnMouseWheel(nFlags, zDelta, pt);

SystemParametersInfo (SPI_GETWHEELSCROLLLINES, 0, &iScrollLines, 0);

if (iScrollLines == 0)
Expand All @@ -4913,9 +4906,16 @@ unsigned int iScrollLines;

// if over miniwindow, don't keep going

if (Mouse_Wheel_MiniWindow (pDoc, point, zDelta < 0 ? -1 : 1))
if (Mouse_Wheel_MiniWindow (pDoc, point, zDelta < 0 ? 0x100 : 0))
return 1;

/*
* Don't handle zoom and datazoom.
*/

if (nFlags & MK_CONTROL || nFlags & MK_SHIFT)
return CView::OnMouseWheel(nFlags, zDelta, pt);

if (iScrollLines == WHEEL_PAGESCROLL)
{
if (zDelta < 0) // page down
Expand Down Expand Up @@ -6238,12 +6238,13 @@ void CMUSHView::Send_Mouse_Event_To_Plugin (DISPID iDispatchID,
CMUSHclientDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

// also Flags might be:
// also Flags might be (from caller):

// 0x10 - LH mouse
// 0x20 - RH mouse
// 0x40 - double-click
// 0x80 - mouse-over not first time
// 0x10 - LH mouse
// 0x20 - RH mouse
// 0x40 - double-click
// 0x80 - mouse-over not first time
// 0x100 - scroll wheel backwards

if (!dont_modify_flags)
{
Expand Down Expand Up @@ -7244,7 +7245,7 @@ bool CMUSHView::Mouse_Wheel_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long
mw->m_sCallbackPlugin,
pHotspot->m_sScrollwheelCallback,
sHotspotId,
delta, true);
delta);

return true; // we are over mini-window - don't scroll underlying text

Expand Down
8 changes: 8 additions & 0 deletions scripting/lua_methods.cpp
Expand Up @@ -7084,6 +7084,14 @@ static flags_pair miniwindow_flags [] =
{ "drag_got_control", 0x02 },
{ "drag_got_alt", 0x04 },

// mouse wheel handler callback flags

{ "wheel_got_shift", 0x01 },
{ "wheel_got_control", 0x02 },
{ "wheel_got_alt", 0x04 },
{ "wheel_scroll_back", 0x100 },


{ NULL, 0 }
};

Expand Down
47 changes: 47 additions & 0 deletions scripting/methods.cpp
Expand Up @@ -4242,6 +4242,7 @@ tInfoTypeMapping InfoTypes [] =
{ 291, "Actual text rectangle - top" },
{ 292, "Actual text rectangle - right" },
{ 293, "Actual text rectangle - bottom" },
{ 294, "State of keyboard modifiers" },


// (dates - calculated at runtime)
Expand Down Expand Up @@ -4910,6 +4911,52 @@ VARIANT CMUSHclientDoc::GetInfo(long InfoType)
}
break;

case 294:
{
long result = 0;
if (GetKeyState (VK_SHIFT) & 0x8000)
result |= 0x01;
if (GetKeyState (VK_CONTROL) & 0x8000)
result |= 0x02;
if (GetKeyState (VK_MENU) & 0x8000)
result |= 0x04;
if (GetKeyState (VK_LSHIFT) & 0x8000)
result |= 0x08;
if (GetKeyState (VK_RSHIFT) & 0x8000)
result |= 0x10;
if (GetKeyState (VK_LCONTROL) & 0x8000)
result |= 0x20;
if (GetKeyState (VK_RCONTROL) & 0x8000)
result |= 0x40;
if (GetKeyState (VK_LMENU) & 0x8000)
result |= 0x80;
if (GetKeyState (VK_RMENU) & 0x8000)
result |= 0x100;
if (GetKeyState (VK_CAPITAL) & 0x8000)
result |= 0x200;
if (GetKeyState (VK_NUMLOCK) & 0x8000)
result |= 0x400;
if (GetKeyState (VK_SCROLL) & 0x8000)
result |= 0x800;
// 0x1000 unused for symmetry
if (GetKeyState (VK_CAPITAL) & 0x0001)
result |= 0x2000;
if (GetKeyState (VK_NUMLOCK) & 0x0001)
result |= 0x4000;
if (GetKeyState (VK_SCROLL) & 0x0001)
result |= 0x8000;

if (GetKeyState (VK_LBUTTON) & 0x8000)
result |= 0x10000;
if (GetKeyState (VK_RBUTTON) & 0x8000)
result |= 0x20000;
if (GetKeyState (VK_MBUTTON) & 0x8000)
result |= 0x40000;

SetUpVariantLong (vaResult, result);
}
break; // state of virtual keys

case 301:
if (m_tConnectTime.GetTime ()) // only if non-zero, otherwise return empty
SetUpVariantDate (vaResult, COleDateTime (m_tConnectTime.GetTime ()));
Expand Down

0 comments on commit 673a568

Please sign in to comment.