home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / unix-faq / shell / hush-faq < prev    next >
Encoding:
Internet Message Format  |  1997-06-04  |  26.1 KB

  1. Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!newsxfer3.itd.umich.edu!news-peer.sprintlink.net!news-pull.sprintlink.net!news-in-east.sprintlink.net!news.sprintlink.net!Sprint!194.159.255.23!disgorge.news.demon.net!demon!dispatch.news.demon.net!demon!fido.news.demon.net!demon!sun4nl!sun4nl!star.cs.vu.nl!jrvosse
  2. From: jrvosse@cs.vu.nl (JR van Ossenbruggen)
  3. Newsgroups: comp.lang.tcl,comp.lang.c++,comp.answers,news.answers
  4. Subject: hush (hyper utility shell) FAQ
  5. Followup-To: poster
  6. Date: 3 Jun 1997 09:41:26 GMT
  7. Organization: Fac. Wiskunde & Informatica, VU, Amsterdam
  8. Approved: news-answers-request@MIT.EDU
  9. Message-ID: <5n0os6$m36@star.cs.vu.nl>
  10. Reply-To: hush@cs.vu.nl
  11. NNTP-Posting-Host: mirror.cs.vu.nl
  12. Summary: hush -- a hyper utility shell and  C++ API for Tcl/Tk
  13. X-Newsreader: TIN [version 1.2 PL2]
  14. Lines: 673
  15. Xref: senator-bedfellow.mit.edu comp.lang.tcl:67539 comp.lang.c++:264503 comp.answers:26341 news.answers:104068
  16.  
  17. Archive-name: unix-faq/shell/hush-faq
  18. Submitted-by: Jacco van Ossenbruggen <jrvosse@cs.vu.nl>
  19. Version: 1.0a6
  20. Last-modified: Fri May 30 10:04:16 MET DST 1997
  21. URL: http://www.cs.vu.nl/~hush/FAQ/
  22.  
  23. This article contains answers to Frequently Asked Questions about hush
  24. (an object-oriented hyper utility shell -- see the answer to question
  25. 1.1 for a short overview).  Please send any comments or suggestions to
  26. <hush@cs.vu.nl>.
  27.  
  28. Address information:
  29.  
  30. hush is developed by:
  31.     Anton Eliens
  32.     Email: <eliens@cs.vu.nl>
  33.  
  34. FAQ maintained by:
  35.     Jacco van Ossenbruggen 
  36.     Email: <jrvosse@cs.vu.nl>
  37.  
  38. Postal Address:
  39.     Vrije Universiteit 
  40.     Fac. of Mathematics and Computer Sciences 
  41.     De Boelelaan 1081a 
  42.     1081 HV Amsterdam
  43.     The Netherlands 
  44.  
  45. This article is provided as is without any express or implied
  46. warranties.  While every effort has been taken to ensure the accuracy
  47. of the information contained in this article, the contributors assume
  48. no responsibility for errors or omissions, or for damages resulting
  49. from the use of the information contained herein.
  50.  
  51. The latest version of this FAQ is available from
  52. <URL:http://www.cs.vu.nl/~hush/FAQ/>.  
  53.  
  54. This FAQ is divided in the following chapters:
  55.  
  56.  1. General information and availability
  57.  2. Building hush
  58.  3. hush extensions  
  59.  4. Script programming in hush
  60.  5. C++ Programming in hush
  61.  6. Compiling and Running hush applications
  62.  
  63. To find the start of a particular chapter, search for the chapter
  64. number followed by a dot and a space at the beginning of a line
  65. (e.g. to find chapter 4 in vi, type /^4\. /).
  66.  
  67. Here's an overview of the questions per chapter:
  68.  
  69.  1. General information and availability
  70.   1.1. Q. What is hush?
  71.   1.2. Q. Why is it called hush?
  72.   1.3. Q. How do I obtain a copy of the hush source?
  73.   1.4. Q. How do I get documentation on hush?
  74.   1.5. Q. Are there other ftp sites that mirror the hush distribution?
  75.   1.6. Q. Is there a newsgroup or mailing list devoted to hush?
  76.   1.7. Q. Is there a WWW page devoted to hush?
  77.   1.8. Q. Is the hush documentation available on the WWW?
  78.   1.9. Q. Is there a book on hush, or will there be one out soon?
  79.   1.10. Q. Are there any published articles about hush that I can quote?
  80.   1.11. Q. Has hush been used outside your own institute?
  81.  
  82.  2. Building hush
  83.   2.1. Q. On what platforms has hush successfully been installed?
  84.   2.2. Q. What compiler do I need to compile hush?
  85.   2.3. Q. Which version of Tcl/Tk do I need?
  86.   2.4. Q. What are resource.mk, install.mk, lib.mk etc?
  87.   2.5. Q. Why do I get those Xpm related errors during linking?
  88.   2.6. Q. Can I link BSD-ish software (like ucblib) with hush on my
  89.        non-BSD platform?
  90.  
  91.  3. hush extensions  
  92.   3.1. Q. Can I use hush in combination with any extensions to Tcl/Tk?
  93.   3.2. Q. Are there any other extensions to hush?
  94.   3.3. Q. What is the video-widget?
  95.   3.4. Q. What is the web-widget?
  96.   3.5. Q. What is hymne?
  97.   3.6. Q. What is sim?
  98.  
  99.  4. Script programming in hush
  100.   4.1. Q. What is Tcl/Tk?
  101.   4.2. Q. Can I use interpreted programs (scripts) with hush?
  102.   4.3. Q. How do make my scripts independent of the location of the
  103.        interpreter?
  104.   4.4. Q. How do I open a new window?
  105.   4.5. Q. How do I convert screen coordinates to canvas coordinates?
  106.   4.6. Q. Why do my "ButtonRelease" bindings not work?
  107.   4.7. Q. Why does the Tcl "glob" function returns corrupted filenames?
  108.   4.8. Q. How do I apply (GIF) images in my hush scripts?
  109.   4.9. Q. How can I load images once and use them many times?
  110.   4.10. Q. How do I apply transparent GIF images in my hush scripts?
  111.  
  112.  5. C++ Programming in hush
  113.   5.1. Q. What does a typical hush main program look like?
  114.   5.2. Q. Why do I need handlers?
  115.   5.3. Q. What about garbage collection?
  116.   5.4. Q. I created a new toplevel window. How do I confine all keyboard
  117.        and mouse events to this new window?
  118.   5.5. Q. How do I apply (GIF) images in C++ code?
  119.   5.6. Q. How can I load images once and use them many times?
  120.   5.7. Q. I have bound a handler to a button widget. Why is the
  121.        handler::operator()() still called if the button is pressed,
  122.        __even__ after disabling the button?
  123.   5.8. Q. I have just inserted some text in my text widget. How do I
  124.        make it scroll to the place the text is inserted so the new text
  125.        becomes visable?
  126.   5.9. Q. What is that dashed line at the top of my menus, and
  127.        how do I make it disappear?
  128.   5.10. Q. How do I convert X-keycodes to ASCII without using Xlib directly. 
  129.   5.11. Q. How do I wait for (socket) IO without blocking the X main loop?
  130.  
  131.  6. Compiling and Running hush applications
  132.   6.1. Q. Why does the compiler complain about declaring/creating a 
  133.        button object?
  134.   6.2. Q. Why does g++ complain about the use of widget::handler(...) ?
  135.  
  136. To find a particular question, search for the question number followed
  137. by a dot, a space, and a Q at the beginning of a line (e.g. to find
  138. question 4.2 in vi, type /^4\.2\. Q/).
  139.  
  140.  
  141. 1. General information and availability
  142. =======================================
  143.  
  144. 1.1. Q. What is hush?
  145.  
  146. A.  The standard interpreter associated with the hush library is a
  147. shell, called hush, including a number of the available extensions of
  148. Tcl/Tk and widgets developed by ourselves (such as a www and a video
  149. widget). The hush library offers a C++ interface to the Tcl/Tk toolkit
  150. and its extensions.  It allows the programmer to employ the
  151. functionality of Tcl/Tk in a C++ program.  Moreover, a program created
  152. with hush is itself an interpreter extending the hush interpreter (and
  153. wish).
  154.  
  155. The hush library is explicitly intended to support the needs of both
  156. novice and experienced window programmers. Its C++ class interface
  157. should suffice for most applications, yet it allows for employing Tcl
  158. script code when more is demanded. The contribution of hush with
  159. respect to the Tcl/Tk toolkit is essentially that it provides a
  160. type-secure solution for connecting Tcl and C++ code. As an additional
  161. advantage, the hush library allows the programmer to employ
  162. inheritance for the development of possibly compound widgets. In
  163. particular, it provides the means to define composite widgets that
  164. behave as the standard Tk widgets.
  165.  
  166. hush has been developed by Anton Eliens, with contributions from Dirk
  167. Bolier, Matthijs van Doorn, Jacco van Ossenbruggen, 
  168. Bastiaan Schonhage, Cees Visser and Martijn van Welie.
  169.  
  170. 1.2. Q. Why is it called hush?
  171.  
  172. A. Hush stands for Hyper Utility SHell.  In the future, hush should
  173. offer a full-fledged component-based, multi-paradigm object-oriented
  174. hypermedia programming environment. hush!
  175.  
  176. 1.3. Q. How do I obtain a copy of the hush source?
  177.  
  178. A. The latest complete hush source distribution is always available by
  179. anonymous ftp, e.g.
  180. <URL:ftp://ftp.cs.vu.nl/pub/hush/hush-2.0.tar.Z>. It is a
  181. compressed tar file containing the complete C++/Tcl source,
  182. documentation, example programs, and several useful pieces of freely
  183. distributable software.  The distribution in this directory is still
  184. experimental.  It may be freely used for education and research only.
  185. A newer beta relaease is at 
  186. <URL:ftp://ftp.cs.vu.nl/pub/hush/hush-3.0b1.4.tar.gz> which needs
  187. Tcl/Tk 8.0a2.
  188.  
  189. Binaries for Solaris 2.5 are at 
  190. <URL:ftp://ftp.cs.vu.nl/pub/eliens/hush/hush-solaris-3.0b1.3.tar.gz>.
  191.  
  192. 1.4. Q. How do I get documentation on hush?
  193.  
  194. A. The documentation is part of the source distribution.  The latest
  195. version of the manuals are available on the WWW at
  196. <URL:http://www.cs.vu.nl/~hush/manuals>.
  197.  
  198. 1.5. Q. Are there other ftp sites that mirror the hush distribution?
  199.  
  200. A. Not yet.
  201.  
  202. 1.6. Q. Is there a newsgroup or mailing list devoted to hush?
  203.  
  204. A. Not yet.
  205.  
  206. 1.7. Q. Is there a WWW page devoted to hush?
  207.  
  208. A. Yes, <URL:http://www.cs.vu.nl/~hush/> is the official hush home
  209. page.
  210.  
  211. 1.8. Q. Is the hush documentation available on the WWW?
  212.  
  213. A. Yes, see <URL:http://www.cs.vu.nl/~hush/> (hush' home page).  It
  214. contains pointers to hypertext versions of the whole documentation set
  215. (as hypertext, not just PostScript).  The latest version of the
  216. manuals are available on the WWW at
  217. <URL:http://www.cs.vu.nl/~hush/manuals/>.
  218.  
  219. 1.9. Q. Is there a book on hush, or will there be one out soon?
  220.  
  221. A. Not really. However, chapter 12 of the following book
  222. is largely devoted to hush:
  223.  
  224.      Principles of Object-Oriented Software Development 
  225.      A. Eliens
  226.      Addison-Wesley (ISBN 0-201-62444-3) 
  227.      1995
  228.  
  229. 1.10. Q. Are there any published articles about hush that I can quote?
  230.  
  231. A. So far the only refereed and published article that describes hush
  232. in detail is:
  233.  
  234.      Hush: A C++ API for Tcl/Tk
  235.      A. Eliens 
  236.      The X Resource, Nr 14 (pages 111-155) 
  237.      April 1995
  238.  
  239. The discrete event simulation library is described in:
  240.  
  241.      Sim --- a C++ library for discrete event simulation
  242.            D. Bolier and A. Eliens
  243.            Vrije Universiteit, Amsterdam , Techreport IR-367,
  244.      November 1994
  245.      <URL:http://www.cs.vu.nl/~eliens/sim/>
  246.  
  247. The web-widget is described in:
  248.  
  249.      Integrating Applications and the World Wide Web
  250.      M.A.B. van Doorn and A. Eliens
  251.      In: Computer Networks and ISDN Systems 
  252.      Proceedings of the Third International World-Wide Web Conference 
  253.      April 10-14 1995, Darmstadt, Germany (pages 1105-1110)
  254.      <URL:http://www.cs.vu.nl/~dejavu/papers/Darmstadt95/>
  255.  
  256. The hymne library is described in:
  257.      Music in Time-based Hypermedia
  258.      J.R. van Ossenbruggen and A. Eliens
  259.      In: ECHT'94 
  260.      The European Conference on Hypermedia Technology (pages 224-270) 
  261.      September 1994
  262.      <URL:http://www.cs.vu.nl/~jrvosse/Papers/echt94/html/>
  263.  
  264.  
  265. 1.11. Q. Has hush been used outside your own institute?
  266.  
  267. A. Yes. Several people outside our university use hush.  You can read
  268. some comments of hush users at
  269. <URL:http://www.cs.vu.nl/~eliens/hush/comments-hush.html>
  270.  
  271.  
  272. 2. Building hush
  273. ================
  274.  
  275. 2.1. Q. On what platforms has hush successfully been installed?
  276.  
  277. A. hush runs on Solaris 2.X, SunOS 4.X and Linux.  On other platforms,
  278. hush has not been tested yet.  We are interested if you run hush on
  279. another platform.
  280.  
  281. It should be possible to port hush to any platform running Tcl/Tk.  At
  282. the moment, an experimental port to Windows 3.11 / Windows 95 /
  283. Windows-NT of hush is available.  See 
  284. the latest beta release of hush 3.0 for more information.
  285.  
  286. 2.2. Q. What compiler do I need to compile hush?
  287.  
  288. A. At the moment, hush compiles with GNU g++ (version > 2.5.8) and
  289. Sun's C++ compiler CC (version > SC3.0.1 02 Mar 1995).  We are
  290. interested if you have successfully built hush with other C++
  291. compilers.
  292.  
  293. 2.3. Q. Which version of Tcl/Tk do I need?
  294.  
  295. A. The standard distribution contains a copy of Tcl7.4 and Tk4.0.
  296. Hush 3.0 will be based on Tcl/Tk 8.0.
  297.  
  298. 2.4. Q. What are resource.mk, install.mk, lib.mk etc?
  299.  
  300. A. These files are included by the Makefiles.  We are trying to find a
  301. way to be able to change the resources without updating all the
  302. Makefiles in the source directory tree.  This may improve in the
  303. future. Suggestions welcome.
  304.  
  305. The main problem is the huge amount of third party software used by
  306. the hush package. While compiling hush (or a hush application), one
  307. need the specify the directories where the various include files are
  308. located, the directories of all the libraries, which libraries should
  309. be linked etc, etc.  This is not trivial at all...
  310.  
  311. 2.5. Q. Why do I get those Xpm related errors during linking?
  312.  
  313. A. This will not happen with the new versions of hush (>= 1.7) hush
  314. 1.5 used the pixmap extension to Tk.  So you have to link the Xpm
  315. library to, otherwise you will get not defined messages of:
  316.  
  317.         _XpmCreateDataFromPixmap 
  318.         _XpmWriteFileFromPixmap 
  319.         _XpmCreatePixmapFromData 
  320.         _XpmReadFileToPixmap 
  321.         _XpmFreeAttributes 
  322.  
  323. Newer versions of hush use the build-in image support of Tk and the
  324. Xpm library is no longer supported.  See question 4.7 and question 5.4
  325.  
  326. 2.6. Q. Can I link BSD-ish software (like ucblib) with hush on my
  327. non-BSD platform?
  328.  
  329. A. Yes. However, we have experienced some troubles. In particular, the
  330. Tcl "glob" command returns corrupted filenames. Seems that the
  331. implementation uses a function (fstat?) defined by both the C library
  332. and the BSD library, and picks the wrong one (BSD). We solved the
  333. problem by explicit linking of the C lib __before__ the BSD libs.
  334.  
  335. E.g. on Solaris we define:
  336.         SYSTEMLIBS = -R/usr/openwin/lib -L/usr/openwin/lib \
  337.                 -lX11 -lm -lc -lucb
  338.  
  339. 3. hush extensions  
  340. ===================
  341.  
  342. 3.1. Q. Can I use hush in combination with any extensions to Tcl/Tk?
  343.  
  344. A. Yes. We use hush in combination with the following packages:
  345. 3ditems, TkSteal-3.3, blt-1.7, expect-4.5, graph-1.0, itcl-1.3,
  346. minterp, photo-2.3, tcl-dp2.0 and tree-3.3.
  347.  
  348. 3.2. Q. Are there any other extensions to hush?
  349.  
  350. A. Yes. You may use the video-widget, the web widget, the hymne
  351. library and the sim library.
  352.  
  353. 3.3. Q. What is the video-widget?
  354.  
  355. A. With the video widget, you can display video files in your hush
  356. application's interface. At the moment, only (black and white) MPEG is
  357. supported, but a new video widget will be out this summer.  The new
  358. widget will support full color MPEG, QuickTime and many more other
  359. formats as well.
  360.  
  361. 3.4. Q. What is the web-widget?
  362.  
  363. A. The hush web-widget provides for a two-way integration of the World
  364. Wide Web with your application. First, the widget behaves as a
  365. graphical WWW browser. Secondly, it allows HTML-pages to contain
  366. embedded Tcl-commands, enabling highly interactive and dynamic
  367. WWW-pages. For instance, you may use an embedded video widget to have
  368. in-line video player in your HTML pages.  See also
  369. <URL:http://www.cs.vu.nl/~dejavu/papers/Darmstadt95/>.
  370.  
  371. Currently, a new SGML version of the web widget is being developed.
  372. It is based on James Clark's SGML parser SP.
  373.  
  374. 3.5. Q. What is hymne?
  375.  
  376. A. Hymne provides a flexible C++ class interface to Csound.  The hymne
  377. class library offers a C++ API to Csound.  Csound is a Software Sound
  378. Synthesis (SWSS) package.
  379.  
  380. SWSS involves the generation of digital audio samples.  Csound runs
  381. real-time on a SPARC, so applications can use music without having to
  382. use (large) pre-recorded samples.
  383.  
  384. One can synthesize music from Tcl scripts by using a hush interpreter
  385. with the hymne extension.  See also
  386. <URL:http://www.cs.vu.nl/~jrvosse/papers/echt94/html/>.
  387.  
  388. Currently, we are developing a MIDI-based sound C/S package for hush.
  389.  
  390. 3.6. Q. What is sim?
  391.  
  392. A. Sim is a C++ library for discrete event simulation. The sim library
  393. supports both an event and process-oriented approach to developing
  394. simulations. Events as well as entities (which may be considered as
  395. objects in the simulation combining several related events and having
  396. an additional phase signifying episodes in its life-time) are provided
  397. as abstract classes that must be refined by the application programmer
  398. to define the actual events and entities participating in the
  399. simulation. The sim library is integrated with the hush library, thus
  400. offering powerful graphic and animation facilities. However, the sim
  401. library may also be used independently, on both Unix and MS-DOS
  402. platforms.
  403.  
  404. The notion of 'event' in the discrete event simulation library and the
  405. window environment event are fully integrated in hush.
  406.  
  407. See also <URL:http://www.cs.vu.nl/~eliens/sim/sim.html>
  408.  
  409.  
  410. 4. Script programming in hush
  411. ===============================
  412.  
  413. 4.1. Q. What is Tcl/Tk?
  414.  
  415. A. The hush kernel provides a flexible C++ interface to Tcl/Tk.  Tcl
  416. is a cshell-like (interpreted) script language that may be embedded in
  417. C or C++. Tk is a window and graphics toolkit based on X11, partly
  418. implemented in Tcl and partly in C. Tk offers numerous widgets,
  419. including a powerful canvas and text widget.  Moreover, the Tcl
  420. scripting language allows the user to rapidly prototype rather complex
  421. graphical user interfaces by writing Tcl scripts. These scripts may be
  422. executed by using wish, the windowing shell interpreter that comes
  423. with Tk. Despite being based on Tcl, the performance of Tk (and wish)
  424. is comparable with (and in some respects even better than) C or C++
  425. based toolkits. The Tcl/Tk toolkit has become very popular in a rather
  426. short period of time.
  427.  
  428. For more information, see
  429. <URL:http://www.x.co.uk/of_interest/tcl/Tcl.html> or check out the Tcl
  430. FAQ at <URL:http://route.psg.com/tcl.html> or <URL:news:news.answers>.
  431. See
  432. <URL:ftp://ftp.slac.stanford.edu/software/TkMail/tkref-4.0.1.tar.gz>
  433. for a Quick Reference Card package, or a PostScript version at
  434. <URL:http://www.cs.vu.nl/~hush/documents/refguide.ps>.  Manpages are
  435. also available from
  436. <URL:http://www.elf.org/tcltk-man-html/contents.html>.
  437.  
  438. 4.2. Q. Can I use interpreted programs (scripts) with hush?
  439.  
  440. A. Yes. Every hush application is a (extended) version of the Tcl/Tk
  441. windowing shell (wish) by default. As a result, you can use such
  442. applications as a interpreter for your Tcl/Tk scripts.  Additionally,
  443. you can use the kit::source(filename) member to evaluate Tcl/Tk
  444. scripts in your C++ program.  In these scripts, you can use plain
  445. Tcl/Tk and all extra commands you defined in your hush application.
  446.  
  447. In the future, hush might support Python
  448. (<URL:http://www.python.org/>) and Scheme scripts as well.
  449.  
  450. 4.3. Q. How do make my scripts independent of the location of the
  451. interpreter?
  452.  
  453. A. Use Unix' env(1) to call the first matching interpreter in your
  454. PATH.  E.g:
  455.         #!/bin/env hush
  456.         puts "Hello world"
  457.  
  458. instead of:
  459.         #!/some/local/and/often/changing/path/hush
  460.         puts "Hello world"
  461.  
  462.  
  463. 4.4. Q. How do I open a new window?
  464.  
  465. A. Use the toplevel widget.
  466.  
  467. 4.5. Q. How do I convert screen coordinates to canvas coordinates?
  468.  
  469. A. As long as your canvas does not have scrollbars, you will probably
  470. have no problem. As soon as you have adjusted the view of the canvas
  471. using x- or yview (usually via scrollbars), you will notice that the
  472. canvas coordinates differ from screen coordinates as returned by
  473. window events.
  474.  
  475. Use the canvasx and canvasy commands to solve the problem.  They map
  476. from screen coordinates to canvas coordinates.  In a Tcl procedure
  477. bound to a mouse event, you can use something like:
  478.  
  479.          set posX [.c canvasx %x]
  480.          set posY [.c canvasy %y]
  481.  
  482. (thanks to Christopher Herringshaw <xxviper@umich.edu>)
  483.  
  484. The hush canvas widget class features automatic conversion from window
  485. coordinates to canvas coordinates. As a consequence, drawing a point
  486. on (10,20) on a canvas which has been scrolled over a vector
  487. (100,200), results in drawing a point on (10+100, 20+200).
  488.  
  489. However, since some users prefer to do this calculation themselves
  490. (using canvasx() and canvasy()), the latest hush version will have a
  491. canvas widget which provides an extra member function to switch this
  492. feature on and off.
  493.  
  494.   enum { window_coords, canvas_coords }; // window_coords is default
  495.   void coordsystem(int);
  496.   int coordsystem() const;
  497.  
  498. If you set coordsystem(canvas::window_coords), which is the default,
  499. the canvas expects window coordinates, which will be transformed to
  500. canvas coordinates automatically.
  501.  
  502. However, if you set coordsystem(canvas::canvas_coords), the canvas
  503. widget expects canvas coordinates and will do no further calculations.
  504.  
  505. 4.6. Q. Why do my "ButtonRelease" bindings not work?
  506.  
  507. A. This may be a bug in old Tcl/Tk versions.  Workaround: use explicit
  508. button numbers.
  509.  
  510. See <URL:http://www.cs.vu.nl/~hush/FAQ/examples/buttonrelease> for a
  511. Tcl example.
  512.  
  513. 4.7. Q. Why does the Tcl "glob" function returns corrupted filenames?
  514.  
  515. A. You are probably using BSD libraries (like ucb) as well.  See
  516. question 2.6.  Thanks to Sebastiaan A. Megens for reporting this bug.
  517.  
  518. 4.8. Q. How do I apply (GIF) images in my hush scripts?
  519.  
  520. A. Use the standard Tk image script command. See man image(n).  See
  521. <URL:http://www.cs.vu.nl/~hush/FAQ/examples/image-tcl> for a Tcl
  522. example.
  523.  
  524. 4.9. Q. How can I load images once and use them many times?
  525.  
  526. A. Use the standard Tk image script command. See man image(n).  See
  527. <URL:http://www.cs.vu.nl/~hush/FAQ/examples/image2-tcl> for a Tcl
  528. example.
  529.  
  530. 4.10. Q. How do I apply transparent GIF images in my hush scripts?
  531.  
  532. A. You don't :-( 
  533. hush does not support transparency because Tk doesn't
  534. (yet).
  535.  
  536. But ... you can change the transparent color of a GIF by setting the
  537. magic Tcl variable TRANSPARENT_GIF_COLOR.
  538.  
  539. E.g:
  540.         set TRANSPARENT_GIF_COLOR [.w cget -background]
  541.  
  542. 5. C++ Programming in hush
  543. ==========================
  544.  
  545. 5.1. Q. What does a typical hush main program look like?
  546.  
  547. A. Typically, one defines a class, usually called "application",
  548. derived from the session class.  One may override its "prelude" member
  549. function to provide for user-defined initializations. For instance,
  550. this is the place to initialize all extensions packages. The "main"
  551. member function can be used to set up the interface.
  552.  
  553. Like most window toolkits, the main loop of the application is hidden
  554. in the library code, which is doing all the window-event dispatching.
  555. User-defined code is usually activated by the use of
  556. call-back-functions, or in the case of hush: by installing handlers.
  557.  
  558. See <URL:http://www.cs.vu.nl/~hush/FAQ/examples/template.cc> 
  559. for a template C++ main program.
  560.  
  561. 5.2. Q. Why do I need handlers?
  562.  
  563. A. In general, a user defined function activated by the call-back
  564. mechanism needs user-defined parameters. The type of those parameters
  565. is not known by the dispatching code doing the call-back.  In other
  566. toolkits, this data usually is a parameter of type void* and needs to
  567. be casted by the application programmer to a pointer of the right
  568. type.
  569.  
  570. The hush handler class solves this problem, and provides a type secure
  571. way to bind C++ code to events.  By deriving a subclass from handler,
  572. a application programmer may activate it's own code by overiding the
  573. operator()() function.  Any data can be stored (locally) within the
  574. data members of the object.  No type casts are needed.
  575.  
  576. 5.3. Q. What about garbage collection?
  577.  
  578. A. See <URL:http://www.cs.vu.nl/~hush/tutorials/garbage/>.
  579.  
  580. 5.4. Q. I created a new toplevel window. How do I confine all keyboard
  581. and mouse events to this new window?
  582.  
  583. A.  You can confine window events to any (mapped) widget subtree by
  584. using the widget::grab() member function. E.g:
  585.  
  586.         toplevel *t = new toplevel(".top");
  587.         tk->update();        // make sure window is mapped
  588.         t->grab();        // Local grab
  589.         t->grab("-global");    // Global grab - dangerous!
  590.         t->grab("release");    // Release grab
  591.  
  592. See the man-page of the Tcl/Tk grab command for more details
  593. (<URL:http://www.cs.vu.nl/~hush/manuals/mann/grab.html>).
  594.  
  595. 5.5. Q. How do I apply (GIF) images in C++ code?
  596.  
  597. A. Most widgets have an image() member. See
  598. <URL:http://www.cs.vu.nl/~hush/FAQ/examples/image.cc>
  599. for a C++ main program.
  600.  
  601. 5.6. Q. How can I load images once and use them many times?
  602.  
  603. A. Most widgets have an image() member. See
  604. <URL:http://www.cs.vu.nl/~hush/FAQ/examples/image2.cc>
  605. for a C++ example.
  606.  
  607. 5.7. Q. I have bound a handler to a button widget. Why is the
  608. handler::operator()() still called if the button is pressed,
  609. __even__ after disabling the button?
  610.  
  611. A. You probably bound the handler by using something like:
  612.  
  613.         abutton->bind("<ButtonPress>", ahandler, "some-argument");
  614.  
  615. which activates a general binding for widgets, and circumvents the
  616. special binding for buttons. Leave out the "ButtonPress" argument to fix
  617. this problem:
  618.  
  619.         abutton->bind(ahandler, "some-argument");
  620.  
  621. 5.8. Q. I have just inserted some text in my text widget. How do I
  622. make it scroll to the place the text is inserted so the new text
  623. becomes visable?
  624.  
  625. A. Use the "see" command of the text widget in combination with the
  626. index of the first character of the newly inserted text.  The
  627. insertion cursor is called "insert", so you have to use the index
  628. "insert linestart". See text(n) for details.  Since the hush class
  629. interface to text does not provide a see() member (yet), use:
  630.  
  631.         text *t
  632.         ...
  633.         t->eval("see {insert linestart}");
  634.         tk->update();    // to be sure ...
  635.  
  636. 5.9. Q. What is that dashed line at the top of my menus, and
  637. how do I make it disappear?
  638.  
  639. A. The dashed line is a so-called "tear-off" entry, which
  640. makes a tear-off copy of the menu if it is invoked.
  641. You can prevent this by creating/configuring your menus with a
  642. "-tearoff false" option.
  643.     
  644.  
  645. 5.10. Q. How do I convert X-keycodes to ASCII without using Xlib directly. 
  646.  
  647. A. See the Tk bind(n) manual and example at
  648. <URL:http://www.cs.vu.nl/~hush/FAQ/examples/key.cc>
  649.  
  650.  
  651. 5.11. Q. How do I wait for (socket) IO without blocking the X main loop?
  652.  
  653. A. You can use the kit->bind(int fd, handler*, int mask=readable) to
  654. bind a handler to a file descriptor. Its operator()() will be called by
  655. the system if there arrives readable data on fd. You can use alternative
  656. masks for other IO events.
  657.  
  658. 6. Compiling and Running hush applications
  659. =========================================== 
  660.  
  661. In general: The color management of earlier Tcl/Tk versions are be the
  662. cause of many errors and core dumps.  Killing color-intensive
  663. applications (such as Netscape!) may be worth the trouble ...
  664.  
  665. 6.1. Q. Why does the compiler complain about declaring/creating a 
  666. button object?
  667.  
  668. A. This only happens if the declaration/creation occurs within the
  669. scope of a class derived from event.  The button(...) member of event
  670. hides the button class.  Note that the session class used to be
  671. derived from event, and the problem above often occured in a member of
  672. a class derived from session in older versions of hush (< 2.0).
  673.  
  674. Solution: use global scoping (::), e.g. something like
  675.      ::button* b = new ::button(".b");
  676.  
  677. 6.2. Q. Why does g++ complain about the use of widget::handler(...) ?
  678.  
  679. A. We think (?) this is a bug in the GNU compiler (at least version
  680. 2.7.0 and earlier).  Widget's member function "handler" hides the
  681. constructor of its base class, called "handler" as well...
  682.  
  683. Solution: Use handler::bind(...) instead to work around this bug.
  684. Note: In the newer versions of hush, widget::handler(...) is no longer
  685. available.
  686. -- 
  687. Jacco van Ossenbruggen             Faculty of Mathematics and Computer Science
  688. mailto:jrvosse@cs.vu.nl            Vrije Universiteit, de Boelelaan 1081a
  689. http://www.cs.vu.nl/~jrvosse/      1081 HV Amsterdam (fax: +31 20 44 47653)
  690.