Alternating Lines in a listbox

Jim Lambert jiml at netrin.com
Wed Nov 29 17:30:46 CST 2006


*****
Scott Kane wrote:

I know this is a periodic topic in the RR list, but as I've been a way for a
while (and the Rev based list searching tools are failing to return results
on queries) I thought I'd ask if any solutions have been found to the
alternating lines in a list box issue (the old "make it look like ITunes"
dilemma).
*****

Try this.
Jim Lambert

on alternateLines cFld, Ln1color, Ln2color

  -- This script will give the lines of a field alternating colors.
  -- Requires Rev verson => 2.7
  -- May not work on Win 98

  -- syntax:  alternateLines field reference, [first line color, second line
color]
  -- example: alternateLines "myField", "light pink", "#708099"
  -- If color parameters are omitted color pickers will appear.
  -- Fields must have a fixed line height.

  if there is not a fld cFld then
    beep
    answer error "Field" && cFld && "does not exist!"
    exit alternateLines
  end if
  if the fixedLineHeight of fld cFld <> true then
    beep
    answer warning "Field" && cFld && "does not have a fixed lineheight,
which is required." & return & "Set the fixedlineheight to true?" with
"Cancel" or "OK"
    if it = "Cancel" then exit alternateLines
    set the fixedLineHeight of fld cFld to true
  end if

  if Ln1color = "" then
    answer color --THE COLOR OF THE FIRST LINE
    if the result is cancel then exit alternateLines
    put it into Ln1color
  end if
  if Ln2color = "" then
    answer color --THE COLOR OF THE SECOND LINE
    if the result is cancel then exit alternateLines
    put it into Ln2color
  end if
  if Ln1color is not a color or Ln2color is not a color then
    beep
    answer error "Can't understand the color data. Make sure colors are in
the correct format!"
    exit alternateLines
  end if
  lock screen
  set the topmargin of fld cFld to 4
  if there is not a grc "Ln1" then create grc "Ln1"
  if there is not a grc "Ln2" then create grc "Ln2"
  set the opaque of grc "Ln2" to true
  set the opaque of grc "Ln1" to true
  set the linesize of grc "Ln2" to 0
  set the linesize of grc "Ln1" to 0
  set the backcolor of grc "Ln2" to Ln2color
  set the backcolor of grc "Ln1" to Ln1color
  set the width of grc "Ln1" to the  effective textheight of fld cFld
  set the width of grc "Ln2" to the  effective textheight of fld cFld
  set the height of  grc "Ln1" to  2* (the  effective textheight of fld
cFld)
  set the height of  grc "Ln2" to  (the  effective textheight of fld cFld)
  set the bottomleft of  grc "Ln2" to the bottomleft of  grc "Ln1"
  import snapshot from rectangle (rect of grc "Ln1") of this card
  put the id of the last image into imgID
  set the backgroundpattern of fld cFld to imgID
  delete img id imgID
  delete grc "Ln1"
  delete grc "Ln2"
  unlock screen with wipe down
 -- copyright 2006 Jim Lambert
 -- You're free to use this anywhere as long as the credit line remains.
end alternateLines





More information about the use-livecode mailing list