#!/bin/sh # MetaCard 2.4 stack # The following is not ASCII text, # so now would be a good time to q out of more exec mc $0 "$@" altFldHeader 1 non openStack if word 1 of the systemVersion is "NT" and word 2 of the systemVersion > 5 then put queryRegistry("HKEY_CURRENT_USER\Control Panel\Colors\MenuBar") into tColor if tColor <> "" then put word 1 of tColor,word 2 of tColor,word 3 of tColor into tColor set the backgroundColor of this stack to tColor end if end if end openStack d @U ms sans serif U Verdana U Verdana W Verdana U ms sans serif U Verdana W Verdana W ms sans serif cREVGeneral scriptChecksum tl1Ipv bookmarks handlerList openStackscriptSelection char 351 to 350prevHandler mouseDowntempScript script
on openStack
if word 1 of the systemVersion is "NT" and word 2 of the systemVersion > 5 then
put queryRegistry("HKEY_CURRENT_USER\Control Panel\Colors\MenuBar") into tColor
if tColor <> "" then
put word 1 of tColor,word 2 of tColor,word 3 of tColor into tColor
set the backgroundColor of this stack to tColor
end if
end if
end openStack
P )on mouseDown put "test" end mouseDown d cREVGeneral scriptChecksum ^`h$]}L bookmarks handlerList mouseDownscriptSelection char 40 to 39prevHandler resizeStacktempScript scripton mouseDown
put "test"
end mouseDown
altFldHeader 04 # # ___ __ ____________ ___ __ _________ ___ _______ # / _ | / //_ __/ __/ / / _ \/ // / __/ _ | / _ \/ __/ _ \ # / __ |/ /__/ / / _// /__/ // / _ / _// __ |/ // / _// _/ # /_/ |_/____/_/ /_/ /____/____/_//_/___/_/ |_/____/___/_/|_| # # ------------------------------------------------------------------------------------------------------------ # Control: altFldHeader # by Chipp Walters, Altuit, inc. # # Instructions for Use: # # The altFldHeader is a group control which is linked to a field. The user can resize the stack window and the column buttons and linked field columns will resize automatically. You can also interactively place the cursor between buttons, click and drag to resize a column. Columns can be set with a minimum size which they can shrink to. # # Features: # The Field Header buttons can be enabled to do sorts etc.. # Realtime column tracking can be on or off. # Minimum Field widths can be set. # Header and Field resize with stack # Specified Fields can be set to never resize # # How to use: # # You may edit the group "altFldHeader" to add or delete buttons. # Just copy and paste one of the existing buttons. # You may also edit the altMinWidth custom property of each button # to set the minimum resize width in pixels. # # There is no maximum limit for the number of buttons. # You need to use at least 2 buttons for this control to work. # Once your finished setting and naming your buttons, press the "Init Grp" button. # You needn't set up your buttons perfectly as the InitAltFldHeader handler # will do this automatically for you. # # You may put a mouseUp handler in any of the button scripts, # but please put "pass mouseUp" in the handler so the control can manage the hiliting. # Make sure and set the altEnableBtn property to true for the button the script is in. # # You'll need to copy the image "moveColumn" to your stack (upper left). Don't rename it. # It's used as an icon resource. # # Here are the custom properties for the group "altFldHeader". # Please do not set the one marked "used internally" # # altTrackMode -used internally # altLeftButPad - the distance in pixels which the left group boundary sets from the leftmost button # altBtnIDs -used internally # altRightButPad - the distance in pixels which the right group boundary sets from the rightmost button # altLeftMargin - the distance in pixels the group sets from the left of the stack # altTargetField - the name of the associated field # altTopButPad - the distance in pixels which the top group boundary sets from the top of the buttons # altMovingNow -used internally # altRightMargin- the distance in pixels the group sets from the right of the stack # altMoveColumn -used internally # altBotButPad - the distance in pixels which the bottom group boundary sets from the bottom of the buttons # # Here are the custom properties for the buttons. Please do not set the one marked "used internally" # # altDontResize - set to true if you want the field to always have a fixed width (as set by altMinWidth) # altEnableBtn - set to true if you wish to enable the button visual animation. Make sure and put a "pass mouseUp" in your "on mouseUp" handler for this to work. Even when set to false, button handlers will execute, this property only effects the up / down animation for the button. # altMinWidth - the minumum width in pixels the column can ever shrink to. Also used by the InitAltFldHeader for setting the width of a button when the altDontResize property is set to true. # altOrder -used internally # # Notes: # # 1) It's important that the backgroundBehavior of grp "altFldHeader" be set to true so the group receives the resize command. # 2) All scripts are located inside the group "altFldHeader" # ------------------------------------------------------------------------------------------------------------ on mouseDown if the cursor is (the id of img "moveColumn") then lock cursor set the altMovingNow of me to "" put the altOrder of the target into x if mouseH() < item 1 of the loc of the target then #other button on left put line x-1 of the altBtnIDs of me into line 1 of temp put line x of the altBtnIDs of me into line 2 of temp else #other button on right put line x of the altBtnIDs of me into line 1 of temp put line x + 1 of the altBtnIDs of me into line 2 of temp end if set the altMovingNow of me to temp set the altMoveColumn of me to true else if the target contains "button" then if the altEnableBtn of the target then set the hilite of the target to true end if end if end mouseDown on mouseUp set the altMoveColumn of me to false unlock cursor if the target contains "button" then if the altEnableBtn of the target then set the hilite of the target to false end if altFinishTracking end mouseUp on mouseEnter x,y if the target contains "button" then lock cursor set the altTrackMode of me to true end if end mouseEnter on mouseLeave unlock cursor set the altTrackMode of me to false end mouseLeave on mouseRelease unlock cursor set the hilite of the target to false set the altMoveColumn of me to false altFinishTracking end mouseRelease on mouseMove x,y if the altTrackMode of me then if the target contains "button" and the altDontResize of the target is False then switch case x < (the left of the target + 5) and the altOrder of the target > 1 #other button on left # gets the btn id of the 'adjacent' button put (item 1 of line (max((the altOrder of the target - 1),1)) of the altBtnIDs of me) into tBtnID if the altDontResize of btn ID tBtnID then set the cursor to hand else set the cursor to (the id of img "moveColumn") end if break case x > (the right of the target - 5) and the altOrder of the target < the number of lines in the altBtnIDs of me #other button on right # gets the btn id of the 'adjacent' button put (item 1 of line (min((the altOrder of the target + 1),the number of lines in the altBtnIDs of me)) of the altBtnIDs of me) into tBtnID if the altDontResize of btn ID tBtnID then set the cursor to hand else set the cursor to (the id of img "moveColumn") end if break default set the cursor to hand end switch else set the cursor to hand end if end if if the altMoveColumn of me then put the altMovingNow of me into tList set the width of btn id item 1 of tList to \ min(max(x - the left of btn id item 1 of tList,item 3 of tList),(the right of btn id item 1 of line 2 of tList - the left of btn id item 1 of tList - item 3 of line 2 of tList)) put the right of btn id item 1 of line 2 of tList into tRight get the rect of btn id item 1 of line 2 of tList set the rect of btn id item 1 of line 2 of tList to \ the right of btn id item 1 of tList, \ item 2 of it, \ item 3 of it, \ item 4 of it if the altRealTimeTracking of me then altFinishTracking end if end mouseMove on resizeStack get the rect of this cd put item 3 of it into tRight put the left of me into tL set the width of me to tRight-the altRightMargin of me - the altLeftMargin of me put the width of me-the altLeftButPad of me-the altRightButPad of me into tWidth put tL + the altLeftButPad of me into tL repeat for each line L in the altBtnIDs of me set the left of btn id (item 1 of L) to tL if the altDontResize of btn id (item 1 of L) is False then set the width of btn id (item 1 of L) to max(round(tWidth * item 2 of L),the altMinWidth of btn id (item 1 of L)) end if put the right of btn id (item 1 of L) into tL end repeat set the width of btn id item 1 of last line of the altBtnIDs of grp "altFldHeader" to \ the right of grp "altFldHeader" - the altRightButPad of grp "altFldHeader" \ - the left of btn id item 1 of last line of the altBtnIDs of grp "altFldHeader" put 0 into tW set the lockLoc of fld the altTargetField of grp "altFldHeader" to true if the vscrollbar of fld the altTargetField of grp "altFldHeader" then put the scrollbarwidth of fld the altTargetField of grp "altFldHeader" into tW end if set the width of fld the altTargetField of grp "altFldHeader" to \ the width of grp "altFldHeader" + tW altFinishTracking end resizeStack on altFinishTracking #set the tabs for the associated field put the left of btn id item 1 of the altBtnIDs of me into tLeft repeat for each line L in the altBtnIDs of me put the right of btn id item 1 of L - tLeft & "," after tTabs end repeat delete last char of tTabs set the tabStops of fld the altTargetField of me to tTabs #set the new button percentages put the altBtnIDs of me into tList put (the width of me - the altLeftButPad of me - the altRightButPad of me) into tWidth put 0 into tLength repeat with x = 1 to the number of lines in tList put round(100*the width of btn id item 1 of line x of tList/tWidth)/100 into \ item 2 of line x of tList if x is not the number of lines in tList then put item 2 of line x of tList + tLength into tLength else put 1 - tLength into item 2 of line x of tList end if end repeat set the altBtnIDs of me to tList end altFinishTracking on InitAltFldHeader # should call this when 'setting up' the original group for the first time # not necessary to call this ever again # builds a sorted left to right list of all the IDs of the buttons in this group and sets the altBtnIDs property to it set the lockLoc of grp "altFldHeader" to true set the left of grp "altFldHeader" to the altLeftMargin of grp "altFldHeader" set the width of grp "altFldHeader" to \ the width of this cd - the altLeftMargin of grp "altFldHeader" - the altRightMargin of grp "altFldHeader" put (the width of grp "altFldHeader" - the altLeftButPad of grp "altFldHeader" - the altRightButPad of grp "altFldHeader") into tWidth repeat with x = 1 to the number of btns on this cd put the id of grp "altFldHeader" into tID if the long ID of btn x contains ("group ID " & tID) then put the id of btn x & "," & \ item 1 of the loc of btn x & "," & \ round(100*the width of btn x/tWidth)/100 & "," & \ the altMinWidth of btn x & "," & \ cr after tBtnIdList put the height of btn x into tHeight end if end repeat if the number of lines in tBtnIdList < 3 then answer warning "Not enough buttons in the altFldHeader Group for it to work!" exit InitAltFldHeader end if delete last char of tBtnIdList sort lines of tBtnIdList ascending numeric by item 2 of each set the height of grp "altFldHeader" to \ the altTopButPad of grp "altFldHeader" + tHeight + the altBotButPad of grp "altFldHeader" put 0 into tLength # do some clean up and make sure the total of all button width percentages = 100 # add the altOrder property to each button repeat with x = 1 to the number of lines in tBtnIdList delete item 2 of line x of tBtnIdList delete last char of line x of tBtnList set the altOrder of btn id (item 1 of line x of tBtnIdList) to x if x is not the number of lines in tBtnIdList then put item 2 of line x of tBtnIdList + tLength into tLength else put 1 - tLength into item 2 of line x of tBtnIdList end if end repeat set the altBtnIDs of grp "altFldHeader" to tBtnIdList put the left of grp "altFldHeader" into tL put tL + the altLeftButPad of grp "altFldHeader" into tL repeat for each line L in the altBtnIDs of grp "altFldHeader" set the lockloc of btn id (item 1 of L) to true set the top of btn id (item 1 of L) to the top of grp "altFldHeader" + the altTopButPad of grp "altFldHeader" set the left of btn id (item 1 of L) to tL if the altDontResize of btn id (item 1 of L) then set the width of btn id (item 1 of L) to the altMinWidth of btn id (item 1 of L) else set the width of btn id (item 1 of L) to round(tWidth * item 2 of L) end if put the right of btn id (item 1 of L) into tL end repeat # fine tuning done at the end set the width of btn id item 1 of last line of the altBtnIDs of grp "altFldHeader" to \ the right of grp "altFldHeader" - the altRightButPad of grp "altFldHeader" \ - the left of btn id item 1 of last line of the altBtnIDs of grp "altFldHeader" if not exists(fld the altTargetField of grp "altFldHeader") then answer warning "No designated fld found. Please set the altTargetField property!" exit InitAltFldHeader end if put 0 into tW if the vscrollbar of fld the altTargetField of grp "altFldHeader" then put the scrollbarwidth of fld the altTargetField of grp "altFldHeader" into tW end if set the width of fld the altTargetField of grp "altFldHeader" to \ the width of grp "altFldHeader" + tW set the lockLoc of fld the altTargetField of grp "altFldHeader" to true altFinishTracking end InitAltFldHeader <