;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; LUSH Lisp Universal Shell
;;;   Copyright (C) 2002 Leon Bottou, Yann Le Cun, AT&T Corp, NECI.
;;; Includes parts of TL3:
;;;   Copyright (C) 1987-1999 Leon Bottou and Neuristique.
;;; Includes selected parts of SN3.2:
;;;   Copyright (C) 1991-2001 AT&T Corp.
;;;
;;; Includes information derived from the GSL (Gnu Scientific Library)
;;;   header files which are copyrighted and distributed under the GPL
;;;   by their respective authors.
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(libload "htk/htk-config")



#? *** htk_graf

;; dummy function that adds HTK C header files in C file
(eval `(de dummy_htk_graf () ,htk-cpheader-cmd ()))

#? * (dummy_htk_graf)
#? * (initgraf)
#? * (makexgraf <wname> <x> <y> <w> <h> <bw>)
#? * (termhgraf)
#? * (hgetevent <anyevent> <action> <result>)
#? * (heventspending)
#? * (hmousepos <x> <y>)
#? * (isinrect <x> <y> <x0> <y0> <x1> <y1>)
#? * (hdrawline <x0> <y0> <x1> <y1>)
#? * (hdrawlines <points> <n>)
#? * (hfillpolygon <points> <n>)
#? * (hdrawrectangle <x0> <y0> <x1> <y1>)
#? * (hfillrectangle <x0> <y0> <x1> <y1>)
#? * (hdrawarc <x0> <y0> <x1> <y1> <stangle> <arcangle>)
#? * (hfillarc <x0> <y0> <x1> <y1> <stangle> <arcangle>)
#? * (hcopyarea <srcx> <srcy> <width> <height> <destx> <desty>)
#? * (hplotvector <x0> <y0> <x1> <y1> <v> <st> <en> <ymax> <ymin>)
#? * (hsetcolour <c>)
#? * (hsetgrey <g>)
#? * (hsetfontsize <size>)
#? * (hsetlinewidth <w>)
#? * (hsetxmode <m>)
#? * (centrex <x> <str>)
#? * (centrey <y> <str>)
#? * (htextwidth <str>)
#? * (htextheight <str>)
#? * (hdrawimage <p> <x> <y> <width> <height>)
#? * (hflush)
#? * (hspoolgraf <fname>)
#? * (hendspoolgraf)
#? * (hdumpgraf <fname>)
#? * (createhbutton <btnlst> <btnid> <x> <y> <w> <h> <str> <fg> <bg> <action>)
#? * (redrawhbutton <btn>)
#? * (redrawhbuttonlist <btnlst>)
#? * (findbutton <btnlst> <key>)
#? * (setactive <btnlst> <active>)
#? * (checkbuttonlist <btnlst> <x> <y>)
#? * (setbuttonlit <btn> <lit>)
#? * (trackbuttons <btnlist> <hev>)

;; ********************************************************


(de InitGraf (  )
    #{ InitGraf(  );  #} 
    ()
)


(de MakeXGraf (  wname  x  y  w  h  bw )
    ((-gptr- "char *") wname) 
    ((-int-) x) 
    ((-int-) y) 
    ((-int-) w) 
    ((-int-) h) 
    ((-int-) bw)  
    #{ MakeXGraf(  $wname   ,$x   ,$y   ,$w   ,$h   ,$bw  );  #} 
    ()
)


(de TermHGraf (  )
    #{ TermHGraf(  );  #} 
    ()
)


(de HGetEvent (  anyevent  action  result)
    ((-int-) anyevent) 
    ((-gptr- "void *") action)           ;; function pointer
    ((-gptr- "HEventRec *") result)
    #{ {
    HEventRec tmp;
    tmp = HGetEvent(  $anyevent   ,$action  );
    memcpy($result, &tmp, sizeof(HEventRec));
    } #}
    ()
)


(de HEventsPending (  )
    (int   #{ HEventsPending(  )  #} )
)


(de HMousePos (  x  y )
    ((-gptr- "int *") x) 
    ((-gptr- "int *") y)  
    (int   #{ HMousePos(  $x   ,$y  )  #} )
)


(de IsInRect (  x  y  x0  y0  x1  y1 )
    ((-int-) x) 
    ((-int-) y) 
    ((-int-) x0) 
    ((-int-) y0) 
    ((-int-) x1) 
    ((-int-) y1)  
    (int   #{ IsInRect(  $x   ,$y   ,$x0   ,$y0   ,$x1   ,$y1  )  #} )
)


(de HDrawLine (  x0  y0  x1  y1 )
    ((-int-) x0) 
    ((-int-) y0) 
    ((-int-) x1) 
    ((-int-) y1)  
    #{ HDrawLine(  $x0   ,$y0   ,$x1   ,$y1  );  #} 
    ()
)


(de HDrawLines (  points  n )
    ((-gptr- "HPoint *") points) 
    ((-int-) n)  
    #{ HDrawLines(  $points   ,$n  );  #} 
    ()
)


(de HFillPolygon (  points  n )
    ((-gptr- "HPoint *") points) 
    ((-int-) n)  
    #{ HFillPolygon(  $points   ,$n  );  #} 
    ()
)


(de HDrawRectangle (  x0  y0  x1  y1 )
    ((-int-) x0) 
    ((-int-) y0) 
    ((-int-) x1) 
    ((-int-) y1)  
    #{ HDrawRectangle(  $x0   ,$y0   ,$x1   ,$y1  );  #} 
    ()
)


(de HFillRectangle (  x0  y0  x1  y1 )
    ((-int-) x0) 
    ((-int-) y0) 
    ((-int-) x1) 
    ((-int-) y1)  
    #{ HFillRectangle(  $x0   ,$y0   ,$x1   ,$y1  );  #} 
    ()
)


(de HDrawArc (  x0  y0  x1  y1  stangle  arcangle )
    ((-int-) x0) 
    ((-int-) y0) 
    ((-int-) x1) 
    ((-int-) y1) 
    ((-int-) stangle) 
    ((-int-) arcangle)  
    #{ HDrawArc(  $x0   ,$y0   ,$x1   ,$y1   ,$stangle   ,$arcangle  );  #} 
    ()
)


(de HFillArc (  x0  y0  x1  y1  stangle  arcangle )
    ((-int-) x0) 
    ((-int-) y0) 
    ((-int-) x1) 
    ((-int-) y1) 
    ((-int-) stangle) 
    ((-int-) arcangle)  
    #{ HFillArc(  $x0   ,$y0   ,$x1   ,$y1   ,$stangle   ,$arcangle  );  #} 
    ()
)


(de HCopyArea (  srcx  srcy  width  height  destx  desty )
    ((-int-) srcx) 
    ((-int-) srcy) 
    ((-int-) width) 
    ((-int-) height) 
    ((-int-) destx) 
    ((-int-) desty)  
    #{ HCopyArea( $srcx   ,$srcy   ,$width   ,$height   ,$destx   ,$desty  );  #} 
    ()
)


(de HPlotVector (  x0  y0  x1  y1  v  st  en  ymax  ymin )
    ((-int-) x0) 
    ((-int-) y0) 
    ((-int-) x1) 
    ((-int-) y1) 
    ((-gptr- "float *") v) 
    ((-int-) st) 
    ((-int-) en) 
    ((-float-) ymax) 
    ((-float-) ymin)  
    #{ HPlotVector(  $x0   ,$y0   ,$x1   ,$y1   ,$v   ,$st   ,$en   ,$ymax   ,$ymin  );  #} 
    ()
)


(de HSetColour (  c )
    ((-int-) c)                       ;; HColour (enum) -> int
    #{ HSetColour(  $c  );  #} 
    ()
)


(de HSetGrey (  g )
    ((-int-) g)  
    #{ HSetGrey(  $g  );  #} 
    ()
)


(de HSetFontSize (  size )
    ((-int-) size)  
    #{ HSetFontSize(  $size  );  #} 
    ()
)


(de HSetLineWidth (  w )
    ((-int-) w)  
    #{ HSetLineWidth(  $w  );  #} 
    ()
)


(de HSetXMode (  m )
    ((-int-) m)                    ;; XferMode (enum) -> int
    #{ HSetXMode(  $m  );  #} 
    ()
)


(de CentreX (  x  str )
    ((-int-) x) 
    ((-gptr- "char *") str)  
    (int   #{ CentreX(  $x   ,$str  )  #} )
)


(de CentreY (  y  str )
    ((-int-) y) 
    ((-gptr- "char *") str)  
    (int   #{ CentreY(  $y   ,$str  )  #} )
)


(de HTextWidth (  str )
    ((-gptr- "char *") str)  
    (int   #{ HTextWidth(  $str  )  #} )
)


(de HTextHeight (  str )
    ((-gptr- "char *") str)  
    (int   #{ HTextHeight(  $str  )  #} )
)


(de HDrawImage (  p  x  y  width  height )
    ((-gptr- "unsigned char *") p) 
    ((-int-) x) 
    ((-int-) y) 
    ((-int-) width) 
    ((-int-) height)  
    #{ HDrawImage(  $p   ,$x   ,$y   ,$width   ,$height  );  #} 
    ()
)


(de HFlush (  )
    #{ HFlush(  );  #} 
    ()
)




(de HSpoolGraf (  fname )
    ((-gptr- "char *") fname)  
    #{ HSpoolGraf(  $fname  );  #} 
    ()
)


(de HEndSpoolGraf (  )
    #{ HEndSpoolGraf(  );  #} 
    ()
)


(de HDumpGraf (  fname )
    ((-gptr- "char *") fname)  
    #{ HDumpGraf(  $fname  );  #} 
    ()
)


(de CreateHButton (  btnlst  btnid  x  y  w  h  str  fg  bg  action )
    ((-gptr- "HButton *") btnlst) 
    ((-int-) btnid)              ;; ButtonId (short ) ->int 
    ((-int-) x) 
    ((-int-) y) 
    ((-int-) w) 
    ((-int-) h) 
    ((-gptr- "char *") str) 
    ((-int-) fg)                            ;; HColour ->int
    ((-int-) bg)                             ;; HColour ->int
    ((-gptr- "void *") action)                                        ;; function pointer
    (gptr #{ CreateHButton(  $btnlst   ,$btnid   ,$x   ,$y   ,$w   ,$h   ,$str   ,$fg   ,$bg   ,$action)  #} )            ;; HButton *   -> gptr
)


(de RedrawHButton (  btn )
    ((-gptr- "HButton *") btn)  
    #{ RedrawHButton(  $btn  );  #} 
    ()
)


(de RedrawHButtonList (  btnlst )
    ((-gptr- "HButton *") btnlst)  
    #{ RedrawHButtonList(  $btnlst  );  #} 
    ()
)


(de FindButton (  btnlst  key )
    ((-gptr- "HButton *") btnlst) 
    ((-int-) key)                              ;; ButtonId (short) -> int
    (gptr #{ FindButton(  $btnlst   ,$key  )  #} )            ;; HButton *   -> gptr
)


(de SetActive (  btnlst  active )
    ((-gptr- "HButton *") btnlst) 
    ((-int-) active)  
    #{ SetActive(  $btnlst   ,$active  );  #} 
    ()
)


(de CheckButtonList (  btnlst  x  y )
    ((-gptr- "HButton *") btnlst) 
    ((-int-) x) 
    ((-int-) y)  
    (gptr #{ CheckButtonList(  $btnlst   ,$x   ,$y  )  #} )            ;; HButton *   -> gptr
)


(de SetButtonLit (  btn  lit )
    ((-gptr- "HButton *") btn) 
    ((-int-) lit)  
    #{ SetButtonLit(  $btn   ,$lit  );  #} 
    ()
)


(de TrackButtons (  btnlist  hev )
    ((-gptr- "HButton *") btnlist) 
    ((-gptr- "HEventRec *") hev)           ;; struct -> pointer
    (int   #{ TrackButtons(  $btnlist   , *$hev  )  #} )              ;; ButtonId (short) -> int
)

;; ********************************************************

(dhc-make-with-libs () (list htk-libhtk)
  dummy_htk_graf
  initgraf
  makexgraf
  termhgraf
  hgetevent
  heventspending
  hmousepos
  isinrect
  hdrawline
  hdrawlines
  hfillpolygon
  hdrawrectangle
  hfillrectangle
  hdrawarc
  hfillarc
  hcopyarea
  hplotvector
  hsetcolour
  hsetgrey
  hsetfontsize
  hsetlinewidth
  hsetxmode
  centrex
  centrey
  htextwidth
  htextheight
  hdrawimage
  hflush
  hspoolgraf
  hendspoolgraf
  hdumpgraf
  createhbutton
  redrawhbutton
  redrawhbuttonlist
  findbutton
  setactive
  checkbuttonlist
  setbuttonlit
  trackbuttons
)
