subr viewmapwidget, fm, win
 sw = string(win)
 ;setup 5 parameter widgets for the 5 types of scaling plus one for external plus
 ;TRACE options
 xq = intarr(7)
 ;and 22 text widgets contained within them
 wtext = intarr(22)
 j = 0
 ;the first 4 are very similar
 for i=0,3 do {
  board = xmboard(fm, 190, 54)
  if i eq 1 then ix = 62 else ix = 0
  for k=0,2 do {
  iq = xmtextfield(board,'',10,scomm,$f3,'white')
  xmposition,iq, ix, 4, 61, 30
  wtext(j) = iq  j = j + 1  ix = ix + 62
  if i eq 1 then break	;do just one for the auto min/max case
  }
  ncase i
   { xmposition, xmlabel(board,'min',$f4), 13, 35
     xmposition, xmlabel(board,'max',$f4), 75, 35
     xmposition, xmlabel(board,'gamma',$f4), 135, 35  }
   { xmposition, xmlabel(board,'gamma',$f4), 70, 35  }
   { xmposition, xmlabel(board,'hbot',$f4), 13, 35
     xmposition, xmlabel(board,'htop',$f4), 75, 35
     xmposition, xmlabel(board,'gamma',$f4), 135, 35  }
   { xmposition, xmlabel(board,'min',$f4), 13, 35
     xmposition, xmlabel(board,'max',$f4), 75, 35  }
   endcase  
  xq(i) = board
  }
 ;the 5th one has more parameters
  board = xmboard(fm, 190, 120)
  xq(4) = board
  ix = 0
  for k=0,2 do {
  iq = xmtextfield(board,'',10,scomm,$f3,'white')
  xmposition,iq, ix, 4, 61, 30
  wtext(j) = iq  j = j + 1  ix = ix + 62
  }
  ix = 15
  for k=0,1 do {
  iq = xmtextfield(board,'',10,scomm,$f3,'white')
  xmposition,iq, ix, 58, 61, 30
  wtext(j) = iq  j = j + 1  ix = ix + 85
  }
  ;and special labels
  xmposition, xmlabel(board,'min',$f4), 13, 35
  xmposition, xmlabel(board,'kink',$f4), 75, 35
  xmposition, xmlabel(board,'max',$f4), 140, 35
  xmposition, xmlabel(board,'gamma',$f4), 23, 88
  xmposition, xmlabel(board,'% range\nabove kink',$f4), 95, 88

  ;a 6th one for arc tan, this was added after the TRACE options and has out of
  ;sequence members for wtext, 20-21
  board = xmboard(fm, 190, 54)
  xq(5) = board
  ix = 20
  j = 20
  for k=0,1 do {
    iq = xmtextfield(board,'',10,scomm,$f3,'white')
    xmposition,iq, ix, 4, 61, 30
    wtext(j) = iq       j = j + 1  ix = ix + 100
  }
  xmposition, xmlabel(board,'min',$f4), 30, 35
  xmposition, xmlabel(board,'50% ref',$f4), 120, 35

  ;and one for externally scaled views, has no wtext
  board = xmboard(fm, 190, 54)
  xmposition,xmlabel(board,'scaling for this view is\nmanaged elsewhere',$f4),30,10
  xq(6) = board

 ;manage just one of them at a time
 dm = $view_scaletype(win)
 for i = 0, 6 do {
   if i eq dm then xtmanage, xq(i) else  xtunmanage, xq(i)
   xmattach, xq(i), 0, 1,1,1,1
 }
 equate, eval('$imagemaptypeswidget'+sw), xq

 s1 = 'fixed range'
 s2 = 'auto min/max'
 s3 = 'histogram trim'
 s4 = 'log'
 s5 = 'fixed->log'
 s6 = 'arc tan'
 xq = xmoptionmenu(viq, 'ftsc_mode_cb,'+sw, $f4, '','mode',s1, s2, s3, s4,s5,s6,dm)

 ;add a label for the current scaling at the bottom (reserve lq)
 lq = xmlabel(viq,'current scaling range', $f4)
 ;;sq2 =fstring('%g',$view_scale_range(0,win)) -
 ;;  + ' to ' + fstring('%g',$view_scale_range(1,win))
 sq2 = sprintf('%g to %g', $view_scale_range(0,win), $view_scale_range(1,win))
 $view_label(0,win) = xmlabel(viq,sq2, $f1,'',1)
 xmposition, $view_label(0,win), 0,0, 230, 30
 ;2/25/2008 - add a sep to clear the Apple widget handle at the bottom
 sep3 = xmseparator(viq, 0, 5, 0)
 xmsize, sep3, 0, 10
 sep1 = xmseparator(viq, 0, 2, 5)
 sep2 = xmseparator(viq, 0, 2, 5)
 xmsize, sep1, 0, 2
 xmsize, sep2, 0, 2
 endsubr
