 'DRAWPANELS.INC


 uses controls
 '
 ===================
 class ControlPanelA
 ===================
 float  x,y,z
 int    id
 float  xx,yy,zz
 float  dx,dy,dz
 float  sc
 int    lock
 int    t1,t2
 int    f1,f2
 string lbl
 ===================
 sliders      c[4]
 lightbuttons l[4]
 ===================

 method act(optional int n)
 indexbase 1
 if id=0
 f1=0 'cube
 f2=0 'pent
 =================================================================
 'ctrl   x    y   z     sc    shm shb tex id  lk  lbl
 -----------------------------------------------------------------
 c[1]=>-.40,-.00, .00,  0.10, f1, 00, t1, 10, 1, "slider"
 c[2]=>-.30,-.00, .00 , 0.10, f2, 00, t1, 20, 1, "slider"
 c[3]=>-.20,-.00, .00 , 0.10, f2, 00, t1, 30, 1, "slider"
 c[4]=>-.10,-.00, .00 , 0.10, f2, 00, t1, 40, 1, "slider"
 -----------------------------------------------------------------
 l[1]=>-.40, .15, .00,  0.02, f1, 00, t1, 50, 1, "light button"
 l[2]=>-.30, .15, .00 , 0.02, f2, 00, t1, 60, 1, "light button"
 l[3]=>-.20, .15, .00 , 0.02, f2, 00, t1, 70, 1, "light button"
 l[4]=>-.10, .15, .00 , 0.02, f2, 00, t1, 80, 1, "light button"
 =================================================================
 id=1+n
 int i
 for i=1 to 4 'control ids
  c[i].id+=n
  l[i].id+=n
 next 'control ids
 end if 'idf=0
 '
 glpushmatrix
 gltranslatef  x,y,z
 '
 gltranslatef -.25,.0,-.0005
 if sc then glscalef sc,sc,1.0
 if pick
  PickLabel id
 else
  QuadShadow .20,.20,.005,.5
  glcolor3f     .60,.50,.60 'fix alpha bug
  glcolor4f     .60,.50,.60,0.50 'box
 endif
 QuadTex       .20,.20,.0.01
 gltranslatef  .25,.0,-.0
 '
 'DISPLAY LABELS
 if lbl
  glpushmatrix
  gltranslatef -.43,-.13,.0005
  glcolor4f .9,.9,.4,.9
  float j=0.015
  'DISPLAY EACH SLIDER VALUE
  for i=1 to 4
   glpushmatrix
   gltranslatef j,0,0
   glscalef  .035,.035,.035
   if pick
    gltranslatef -.1,-.18,.0
    picklabel id+i
    PutBoxArea 2,1
    gltranslatef .1,.18,.0
   else 'not pick
    if picked=id+i
    --------------
     editing=1
     'EDIT BOX
     color 0.9,0.9,0.9
     'box-around
     gltranslatef -.1,-.18,.0
     glBegin GL_LINE_STRIP
     glVertex2f 0,0
     glVertex2f 2,0
     glVertex2f 2,1
     glVertex2f 0,1
     glVertex2f 0,0
     glEnd
     gltranslatef .1,.18,.0
     '
     static string ss
     ss= str(50+c[i].vy*50,0) '0..100
     input ss
     c[i].vy=(val(ss)-50) *0.02
     '
     static int cpick,cy,cx
     if cpick<>picked
      cp=le+1 'place cursor at end of string
      cy=y
      cx=x
      cpick=picked
     endif 'cpick<>picked
     '
     select lastkey
     case VK_UP
      c[i].vy+=0.01
     case VK_DOWN
      c[i].vy-=0.01
     case VK_PRIOR 'PGUP
      c[i].vy+=0.01
     case VK_NEXT 'PGDN
      c[i].vy-=0.01
     case 9 'tab
      if KeyState(VK_SHIFT)=0
       picked++
       if picked>id+4
         picked=id+4
       end if
      else 'left
       picked--
       if picked<id+1
        picked=id+1
       endif
      endif 'left
     end select 'lastkey
     '
     lastkey=0
     lastchar=0
    else 'display
     gprint str(50+c[i].vy*50,0) '0..100
     'gprint str((c[i].vy)*100 , 0) -100..100
    endif 'display
   endif
   glpopmatrix
   j+=0.1
  next 'slider
   '
   'DISPLAY MAIN PANEL LABEL
   gltranslatef 0,-.05,0
   glscalef  .04,.04,.04
   glcolor4f .9,.9,.0,.9
   gprint lbl
   glpopmatrix
  endif
  '
  '
  if bleft
   if picked=id
    if not lock
     drag(dx,dy,1.0/sc)
     x=xx+dx : y=yy+dy
    end if
   end if
  else 'not bleft
  xx=x : yy=y : zz=z 'ANCHOR
 end if
 '
 'render
 '
 int i,oi1,oi2
 for i=1 to 4
  c[i].act(1,i,oi1)
  l[i].act(1,i,oi2)
 next 'action all controls
 glpopmatrix
 '
 'show data
 '
 'glDisable GL_TEXTURE_2D
 glDisable GL_LIGHTING
 '
 glPushMatrix
 glLoadIdentity
 if pick
  PickLabel 0
 endif
 gltranslatef -.5,.35,-1.0
 float w,h
 glscalef     .05,.05,.01
 GetWordArea  "Control:",w,h
 if pick
   PutBoxArea   w,h
 else
  /*
  glColor3f    .99,.99,.00
  gprint       "Control: "
  glColor3f    .99,.99,.99
  gprint    str(picked)
  if oi1+oi2
   gprint "   "
   if oi1 then gprint str((1.0+c[oi1].vy)*50 , 0)
    if oi2 then gprint str (l[oi2].lit)
   end if
  */
 end if
 glPopMatrix
 end method 'act
 '
 method destructor()
 ===================
 'del this.label
 'sliders      c[4]
 'lightbuttons l[4]
 int i
 for i=1 to 4
  c[i].destructor
 next
 for i=1 to 4
  l[i].destructor
 next
 end method
 '
 end class

 '#recordof ControlPanelA
