#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 // Use modern global access method and strict wave access. #pragma IndependentModule=ScrollWheelToMagnify static Function IgorStartOrNewHook(igorApplicationNameStr) String igorApplicationNameStr // not used InstallSTMHookOnAllGraphs() // print "InstallSTM_IgorStartOrNewHook ran" End static Function AfterWindowCreatedHook(windowNameStr, winType) String windowNameStr Variable winType // Only install the hook on graphs if (winType == 1) SetWindow $(windowNameStr) hook(ScrollToMagnify) = ScrollToMagnifyHook endif // print "InstallSTM_AfterWinCreatedHook ran on window " + windowNameStr End static Function AfterFileOpenHook(refNum, fileNameStr, pathNameStr, fileTypeStr, fileCreatorStr, fileKind ) Variable refNum // Will be -1 for experiments and XOPs String fileNameStr String pathNameStr String fileTypeStr String fileCreatorStr Variable fileKind if (refNum == -1) // Experiments and XOPs will have refNum set to -1 if (fileKind != 3) // XOPs are fileKind 3 InstallSTMHookOnAllGraphs() // print "AfterFileOpenHook ran" endif endif return 0 // Let Igor do the default thing with this file. End Function InstallSTMHookOnAllGraphs() Variable n String thisWinName do thisWinName = WinName(n, 1) if (strlen(thisWinName) <= 0) // No more windows. break endif GetWindow $(thisWinName) hook(ScrollToMagnify) if (strlen(S_Value) <= 0) // This window needs to have the hook installed SetWindow $(thisWinName) hook(ScrollToMagnify) = ScrollToMagnifyHook endif n++ while(1) // print "InstallSTMHookOnAllGraphs ran" End // Increases/decreases expansion of a graph window on // Ctrl/Cmd + vertical scroll wheel events. Function ScrollToMagnifyHook(s) STRUCT WMWinHookStruct &s Switch (s.eventCode) case 22: // mouse wheel // Require that Ctrl (Window) or Cmd (Mac) be held down. if (s.eventMod & 8) if (s.wheelDy != 0) ChangeWindowExpansion(s.winName, (s.wheelDy > 0) ? 1 : 0) endif endif break EndSwitch return 0 // Don't consider the event handled. End // Changes the expansion of windowName, if windowName is a graph. // If increaseExpansion is true, the expansion factor will be // increased. Otherwise it will be decreased. // If the window is already as maximal or minimal expansion, // it will not be changed. Function ChangeWindowExpansion(windowName, increaseExpansion) String windowName Variable increaseExpansion Variable windowType = WinType(windowName) Switch (windowType) case 1: // Graph GetWindow $(windowName), expand Variable expansion = V_Value if (expansion == 0) // Means default expansion expansion = 1 endif if (increaseExpansion) expansion += 0.125 else expansion -= 0.125 endif if (expansion <= 0.125 || expansion >= 8) // New expansion factor is outside of allowed // range, so do nothing else ModifyGraph expand=expansion endif break // Other window types could be handled here, if desired. EndSwitch End