Column Width in Pixels

Wayne Brissette waynefb at earthlink.net
Thu May 1 13:42:01 PDT 2003


Here are two AppleScripts that I wrote that may be useful to some of you.


Script Name: Set Column Width
About this script: While I like being able to drag around the widths for
columns, there are times that I need to set column widths to a specific
pixel width. So, I wrote this script.


-- Begin AppleScript

set MyWidths to {}
set LoopString to "Set Column "
set LoopString2 to " to what width (in pixels)?"


tell application "OmniOutliner"
	set DocColumns to columns of front document
	
	set numLoops to ((count of DocColumns) - 1)
 (* If you want to set the first column <the checkbox> remove the 
    minus 1 from the statement above *)
 	
	repeat with i from 1 to numLoops
		set tmpString to LoopString & i & LoopString2 as string
		display dialog tmpString default answer ""
		set tmpwidth to (text returned of result) as integer
		set MyWidths to MyWidths & tmpwidth as list
	end repeat
	
 (* 
    If you want to set the first column <the checkbox> change the 
    statement below.
    OLD STATEMENT: with i from 2 to 
    NEW STATEMENT: with i from 1 to 
 *)

	repeat with i from 2 to (count of DocColumns)
		set tmpcol to item i of DocColumns
		set width of tmpcol to (item (i - 1)) of MyWidths
	end repeat
	
end tell

-- End AppleScript

Script Name: Display Column Widths
About this script: I find it very handy to know what my total width of a
columns is (I don't count the first column usually), so I wrote this
script to let me know the width of each column and total width of all
columns (minus the first column). 

-- Begin AppleScript

set TMP to {}
set tmpcount to 0
set ColWidths to ""

tell application "OmniOutliner"
	set DocColumns to columns of front document
	set numLoops to (count of DocColumns)

(*
   If you want to include the first column change the 2 to a 1 in the
statement below.
*)

	repeat with i from 2 to numLoops
		set tmpcol to item i of DocColumns
		set tmpcol to width of tmpcol as integer

(*
  if you want to include the first column, remove the -1 from the i
variable below.
*)

		set ColWidths to ColWidths & "Col " & (i - 1) & " is " & tmpcol & "
pixels." & return as text
		set TMP to TMP & tmpcol
		set tmpcount to tmpcount + tmpcol
	end repeat
	display dialog ColWidths & return & "Total Width is " & tmpcount & " pixels."
end tell

-- End Applescript


Wayne

-- 
"Success usually comes to those who are too busy to be looking for it" 
- Henry David Thoreau

Live DAT & Music Page: http://homepage.mac.com/wayneb/
Wayne's Music Calendar: http://ical.mac.com/wayneb/Music
PowerMail AppleScript Archives: http://homepage.mac.com/wayneb/powermail.html

Music Currently playing:




More information about the OmniOutliner-Users mailing list