BFDtoolsCore


jbFunctions.ms also defines a couple (bloated) structs that allow "BFDtools" to be created and run.

A BFDtool is basically a quick way to create floaters that remember their geometry, with a few extra handy features thrown in (ie. the tools are tracked so it's impossible to create more than one instance at once).


BFDtool struct:

You create one instance of this struct per floater/tool. The accessible properties are listed below.

Available Variables:
listed in the form:
variableName (variable type, default value)
Available Functions:

Back To Top...


BFDman Struct:

There is one global instance of this struct, all properties below are always available as "BFDman.property".

Available Variables:
Available Functions:

Back To Top...


Sample Script:

------------------------------------------------------------------------------------------
-- Contents:
--		BFDtoolSample - Description of script
--		BFDtoolOtherScript - list any other macros defined in same file (if any)
--
-- Requires:
--		BFDtoolsCore.ms
--		List any required external files or functions here (if any)
--
-- History:
--		11.3.99 - Created
--		11.9.99 - Any changes should be listed here
------------------------------------------------------------------------------------------

macroScript BFDtoolSample category:"BFDtoolsDevSupport" tooltip:"BFDtool Sample Implementation" icon:#("YourIconFile",1) (

-- Version checking
if (
	-- Replace "XXX" with the version returned by jbFunctionsCurrentVersion() at the
	-- time of authorship, to lock to the version of jbFunctions you're using
	local requiredVer = XXX
	local str, failed = FALSE
	if (jbFunctionsCurrentVersion == undefined) then (
		failed = TRUE; str = "This script requires jbFunctions to run properly."
	) else if (requiredVer > jbFunctionsCurrentVersion()) then (
		failed = TRUE; str = "The installed version of jbFunctions is out of date."
	)
	if (failed) then (
		str += "\n\nYou can get the latest version at http://www.johnburnett.com/.\n\nWould you like to connect there now?"
		if (QueryBox str title:"Error") then ( try (ShellLaunch "http://www.johnburnett.com/" "") catch () )
		FALSE
	) else ( TRUE )
) then (

-- Create a *LOCAL* BFDtool with initial properties.
-- Do this at the TOP of the script.
-- In this example, most optional arguments are declared.  It's good
-- practice, but not required.  The only REQUIRED argument is the toolName.
-- It should be a short, unique, descriptive single word, that remains
-- constant across different versions of the script.
	local thisTool = BFDtool	toolName:"BFDtoolSample"	\
								author:"John Burnett"		\
								createDate:[11,3,1999]		\
								modifyDate:[11,3,1999]		\
								version:1					\
								defFloaterSize:[200,300]	\
								defFloaterPos:[50,50]

-- Define your rollouts as usual.
-- However, there is ONE addition that must be made. In the close handler of
-- your FIRST rollout (which should _always_ be present), you should put a
-- call to the tool's closeTool() function.  A convenient place for this is to
-- just make an About rollout, and _always_ add it first, and never remove it.
-- This default rollout puts up pertinent "About" information
	rollout DLGaboutRollout "About" (
		label DLGAbout01 ""
		label DLGAbout02 ""
		label DLGAbout03 ""

		on DLGaboutRollout open do (
			DLGabout01.text = thisTool.toolName
			DLGabout02.text = thisTool.author
			DLGabout03.text =	(thisTool.modifyDate.x as integer) as string + "." +
								(thisTool.modifyDate.y as integer) as string + "." +
								(thisTool.modifyDate.z as integer) as string
		)

		on DLGaboutRollout close do (
			thisTool.closeTool()
		)
	)

	rollout DLGmainRollout "Main Rollout" (
		label DLGmain "MAIN"
	)

	rollout DLGfooRollout "Foo" (
		label DLGfoo "Foo"
	)

-- Add the defined rollouts to your tool definition.  This can be done
-- one at a time, or by packing all the rollouts into an array and passing
-- the array.
-- Notice the optional "rolledUp" parameter.  This controls whether the rollups
-- are open or closed when added to the floater.  Again, this can be a single
-- value, or an array of boolean values.  If the rolledUp array isn't the same
-- size as the rollout array (like in this example), then the LAST value in
-- the rolledUp array will be used for all other rollouts in the rollout array.
-- In this example, the first rollout is rolled up, and the last two are not.
	thisTool.addRoll #(DLGaboutRollout,
				DLGmainRollout,
				DLGfooRollout) rolledUp:#(true,false)

-- Open the tool, which creates the tool's floater, etc.
-- The only oddity here is that you must pass the tool itself as a parameter
-- to the openTool() function, as shown.
	thisTool.openTool thisTool
)

Back To Top...


History:

11.1.1999 - Created (or there abouts)
4.12.2000 - If version is increased, floater geometry isn't loaded from INI

Back To Top...


Bug reports/comments/suggestions: john@johnburnett.com