#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 #pragma DefaultTab={3,20,4} function TestAppendSubGraph(string mainGName, wave plotThis) GetWindow $mainGName, expand variable gExpand = V_value; gExpand = gExpand == 0 ? 1 : gExpand // pixel conversion and expansion factor variable pixConv = ScreenResolution/72*gExpand GetWindow $mainGName psizeDC // define an initial size variable size = max(min((V_bottom-V_top)/4,(V_right-V_left)/5),subMinSize)/pixConv variable wL = (V_left+20)/pixConv, wT = (V_top+20)/pixConv, wR = wL+size*1.2, wB = wT+size NewPanel/HOST=$mainGName/N=floatPanel/W=(wL,wT,wR,wB) Display/HOST=#/FG=(FL,FT,FR,FB) plotThis ModifyGraph frameStyle=1 // edges are easier to see with a frame SetActiveSubwindow $mainGName SetWindow $mainGName hook(DragUpdate)=DragHookFunction end function TestRemoveHook(string gName) string subWinList = ChildWindowList(gName) int i for (i=0; i-1 && CmpStr(s.winName, gName)) // mouse events on the sub-graph GetWindow $s.winName psizeDC tempRect.top = v_top tempRect.left = v_left tempRect.right = v_right tempRect.bottom = v_bottom if (!CheckPointInRect(s.mouseLoc,tempRect)) // mouse is not in plot area GetWindow $s.winName gsizeDC; winEdge = 1 // encode sub-window mouse edge detection into winEdge winEdge = abs(s.mouseloc.h-v_left) maybe we missed a mouse-up event? SetWindow $gName userdata(dragInfo)="" dragEdge = 0 endif else break endif sName = StringFromList(1,dragInfo) StructGet/S d, GetUserData(gName, "", sName) variable deltah = s.mouseloc.h - d.mouse_init.h variable deltav = s.mouseloc.v - d.mouse_init.v tempRect = d.subwinRect tempRect.top += deltav * (dragEdge == 1 || dragEdge == 2 || dragEdge == 3) tempRect.left += deltah * (dragEdge == 1 || dragEdge == 2 || dragEdge == 4) tempRect.right += deltah * (dragEdge == 1 || dragEdge == 5 || dragEdge == 3) tempRect.bottom += deltav * (dragEdge == 1 || dragEdge == 5 || dragEdge == 4) string subWin = gName + "#" + sName if (CheckRectPosAndSize(tempRect, d.graphRect) && WinType(subWin)) MoveSubwindow/W=$subWin fnum=(tempRect.left/pixConv, tempRect.top/pixConv, tempRect.right/pixConv, tempRect.bottom/pixConv) d.subwinRect = tempRect endif d.mouse_init = s.mouseloc StructPut/S d, floatStruct SetWindow $gName userdata($sName)=floatStruct break case "resize": string subWinList = ChildWindowList(gName) if (!ItemsInList(subWinList)) break endif GetWindow $gName wsizeDC int isHostMinW = abs(v_right-v_left) <= subMinSize int isHostMinH = abs(v_bottom-v_top) <= subMinSize for (i=0; i0) tempRect.bottom = v_top - dH*(dH>0) + subH tempRect.left = v_left - dW*(dW>0) tempRect.right = v_left - dW*(dW>0) + subW MoveSubwindow/W=$(gName+"#"+sName) fnum=(tempRect.left/pixConv, tempRect.top/pixConv, tempRect.right/pixConv, tempRect.bottom/pixConv) endfor break endswitch return hookTakeOver end // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ static structure DragStruct STRUCT point mouse_init STRUCT Rect subwinRect STRUCT Rect graphRect endstructure static function CheckRectPosAndSize(STRUCT rect &in, STRUCT rect &ref) int isInside = (in.left>ref.left && in.top>ref.top && in.right= subMinSize && abs(in.bottom-in.top) >= subMinSize return isInside && isMinSize end static function CheckPointInRect(STRUCT point &pnt, STRUCT rect &ref) return ( pnt.h>ref.left && pnt.href.top && pnt.v