home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _5038fa87bbb3b3b86ad8596bebfdc87c < prev    next >
Text File  |  2004-06-01  |  10KB  |  283 lines

  1.  
  2. =head1 NAME
  3.  
  4. Tk::Balloon - pop up help balloons.
  5.  
  6. =for pm Tixish/Balloon.pm
  7.  
  8. =for category Tix Extensions
  9.  
  10. =head1 SYNOPSIS
  11.  
  12.     use Tk::Balloon;
  13.     ...
  14.     $b = $top->Balloon(-statusbar => $status_bar_widget);
  15.  
  16.     # Normal Balloon:
  17.     $b->attach($widget,
  18.            -balloonmsg => "Balloon help message",
  19.            -statusmsg => "Status bar message");
  20.  
  21.     # Balloon attached to entries in a menu widget:
  22.     $b->attach($menu, -state => 'status',
  23.               -msg => ['first menu entry',
  24.                    'second menu entry',
  25.                    ...
  26.                   ],
  27.           );
  28.  
  29.     # Balloon attached to individual items in a canvas widget:
  30.     $b->attach($canvas, -balloonposition => 'mouse',
  31.             -msg => {'item1' => 'msg1',
  32.                  'tag2'  => 'msg2',
  33.                   ...
  34.                 },
  35.           );
  36.  
  37.     # Balloon attached to items in a listbox widget:
  38.     $b->attach($listbox, -balloonposition => 'mouse',
  39.              -msg => ['first listbox element',
  40.                   '2nd listbox element',
  41.                   ...
  42.                  ],
  43.           );
  44.  
  45. =head1 DESCRIPTION
  46.  
  47. B<Balloon> provides the framework to create and attach help
  48. balloons to various widgets so that when the mouse pauses over the
  49. widget for more than a specified amount of time, a help balloon is
  50. popped up.
  51.  
  52. =head2 Balloons and Menus or Listboxes
  53.  
  54. If the balloon is attached to a B<Menu> or B<Listbox> widget and the
  55. message arguments are array references, then each element in the array
  56. will be the message corresponding to a menu entry or listbox element.
  57. The balloon message will then be shown for the entry which the mouse
  58. pauses over. Otherwise it is assumed that the balloon is to be
  59. attached to the B<Menu> or B<Listbox> as a whole. You can have
  60. separate status and balloon messages just like normal balloons.
  61.  
  62. =head2 Balloons and Canvases
  63.  
  64. If the balloon is attached to a B<Canvas> widget and the message
  65. arguments are hash references, then each hash key should correspond to
  66. a canvas item ID or tag and the associated value will correspond to the
  67. message for that canvas item. The balloon message will then be shown for
  68. the current item (the one at the position of the mouse). Otherwise it is
  69. assumed that the balloon is to be attached to the B<Canvas> as a whole.
  70. You can have separate status and balloon messages just like normal
  71. balloons.
  72.  
  73. =head2 Balloon Position
  74.  
  75. By default, the balloon pops up at the lower right side of the client.
  76. If it would extend outside the lower screen border, its positioned at the
  77. upper right side. If it would extend outside the right screen border
  78. it's shown on the lower left side of the client. If it would extend
  79. outside both the lower and the right screen border, it's positioned
  80. at the upper left side of the client. Thus, the little arrow always
  81. points to the attached client.
  82.  
  83. =head1 OPTIONS
  84.  
  85. B<Balloon> accepts all of the options that the B<Frame> widget
  86. accepts. In addition, the following options are also recognized.
  87.  
  88. =over 4
  89.  
  90. =item B<-initwait>
  91.  
  92. Specifies the amount of time to wait without activity before
  93. popping up a help balloon. Specified in milliseconds. Defaults to
  94. 350 milliseconds. This applies to both the popped up balloon and
  95. the status bar message.
  96.  
  97. =item B<-state>
  98.  
  99. Can be one of B<'balloon'>, B<'status'>, B<'both'> or B<'none'>
  100. indicating that the help balloon, status bar help, both or none
  101. respectively should be activated when the mouse pauses over the
  102. client widget. Default is B<'both'>.
  103.  
  104. =item B<-statusbar>
  105.  
  106. Specifies the widget used to display the status message. This
  107. widget should accept the B<-text> option and is typically a
  108. B<Label>. If the widget accepts the B<-textvariable> option and
  109. that option is defined then it is used instead of the B<-text>
  110. option.
  111.  
  112. =item B<-balloonposition>
  113.  
  114. Can be one of B<'widget'> or B<'mouse'>. It controls where the balloon
  115. will popup. B<'widget'> makes the balloon appear at the lower right
  116. corner of the widget it is attached to (default), and B<'mouse'> makes
  117. the balloon appear below and to the right of the current mouse position.
  118.  
  119. =item B<-postcommand>
  120.  
  121. This option takes a B<CODE> reference which will be executed before the
  122. balloon and statusbar messages are displayed and should return a true
  123. or false value to indicate whether you want the balloon to be displayed
  124. or not. This also lets you control where the balloon is positioned by
  125. returning a true value that looks like I<X,Y> (matches this regular
  126. expression: C</^(\d+),(\d+)$/>). If the postcommand returns a value that
  127. matches that re then those coordinates will be used as the position to
  128. post the balloon. I<Warning:> this subroutine should return quickly or
  129. the balloon response will appear slow.
  130.  
  131. =item B<-cancelcommand>
  132.  
  133. This option takes a B<CODE> reference which will be executed before the
  134. balloon and statusbar messages are canceled and should return a true
  135. or false value to indicate whether you want the balloon to be canceled
  136. or not. I<Warning:> this subroutine should return quickly or the balloon
  137. response will appear slow.
  138.  
  139. =item B<-motioncommand>
  140.  
  141. This option takes a B<CODE> reference which will be executed for any
  142. motion event and should return a true or false value to indicate
  143. whether the currently displayed balloon should be canceled (deactivated).
  144. If it returns true then the balloon will definitely be canceled, if it
  145. returns false then it may still be canceled depending the internal rules.
  146. I<Note:> a new balloon may be posted after the B<-initwait> time
  147. interval, use the B<-postcommand> option to control that behavior.
  148. I<Warning:> the subroutine should be extremely fast or the balloon
  149. response will appear slow and consume a lot of CPU time (it is executed
  150. every time the mouse moves over the widgets the balloon is attached to).
  151.  
  152. =item B<-numscreens>
  153.  
  154. This option accepts an integer 1 or greater. This option should be used
  155. to avoid disjointed balloons across multiple screens in single logical
  156. sceen (SLS) mode. This only currently works in the horizontal direction.
  157. Example: If you are running dual screens in SLS mode then you would set
  158. this value to 2. Default value is 1.
  159.  
  160. =back
  161.  
  162. =head1 METHODS
  163.  
  164. The B<Balloon> widget supports only three non-standard methods:
  165.  
  166. =head2 B<attach(>I<widget>, I<options>B<)>
  167.  
  168. Attaches the widget indicated by I<widget> to the help system. The
  169. allowed options are:
  170.  
  171. =over 4
  172.  
  173. =item B<-statusmsg>
  174.  
  175. The argument is the message to be shown on the status bar when the
  176. mouse pauses over this client. If this is not specified, but
  177. B<-msg> is specified then the message displayed on the status bar
  178. is the same as the argument for B<-msg>. If you give it a scalar
  179. reference then it is dereferenced before being displayed. Useful
  180. if the postcommand is used to change the message.
  181.  
  182. =item B<-balloonmsg>
  183.  
  184. The argument is the message to be displayed in the balloon that
  185. will be popped up when the mouse pauses over this client. As with
  186. B<-statusmsg> if this is not specified, then it takes its value
  187. from the B<-msg> specification if any. If neither B<-balloonmsg>
  188. nor B<-msg> are specified, or they are the empty string then
  189. no balloon is popped up instead of an empty balloon. If you
  190. give it a scalar reference then it is dereferenced before being
  191. displayed. Useful if the postcommand is used to change the message.
  192.  
  193. =item B<-msg>
  194.  
  195. The catch-all for B<-statusmsg> and B<-balloonmsg>. This is a
  196. convenient way of specifying the same message to be displayed in
  197. both the balloon and the status bar for the client.
  198.  
  199. =item B<-initwait>
  200.  
  201. =item B<-state>
  202.  
  203. =item B<-statusbar>
  204.  
  205. =item B<-balloonposition>
  206.  
  207. =item B<-postcommand>
  208.  
  209. =item B<-cancelcommand>
  210.  
  211. =item B<-motioncommand>
  212.  
  213. These options allow you to override the balloon's default value for
  214. those option for some of the widgets it is attached to. It accepts the
  215. same values as above and will default to the B<Balloon>'s value.
  216.  
  217. =back
  218.  
  219. =head2 B<detach(>I<widget>B<)>
  220.  
  221. Detaches the specified I<widget> from the help system.
  222.  
  223. =head2 B<destroy>
  224.  
  225. Destroys the specified balloon.
  226.  
  227. =head1 ADVERTISED SUBWIDGETS
  228.  
  229. The balloon label is advertised as C<message>.
  230.  
  231. =head1 EXAMPLES
  232.  
  233. See the balloon demo included with the widget demo script that came with
  234. the distribution for examples on various ways to use balloons.
  235.  
  236. =head1 NOTES
  237.  
  238. Because of the overhead associated with each balloon you create (from
  239. tracking the mouse movement to know when to activate and deactivate
  240. them) you will see the best performance (low CPU consumption) if you
  241. create as few balloons as possible and attach them to as many widgets
  242. as you can.  In other words, don't create a balloon for each widget
  243. you want to attach one to.
  244.  
  245. =head1 CAVEATS
  246.  
  247. Pressing any button will deactivate (cancel) the current balloon,
  248. if one exists. You can usually make the balloon reappear by moving
  249. the mouse a little. Creative use of the 3 command options can help
  250. you out also. If the mouse is over the balloon when a menu is unposted
  251. then the balloon will remain until you move off of it.
  252.  
  253. =head1 BUGS
  254.  
  255. If using balloons attached to listbox entries or canvas items in a
  256. scrolled widget, then the subwidget have to be used:
  257.  
  258.     $balloon->attach($w->Subwidget("scrolled"), -msg => ...);
  259.  
  260. =head1 AUTHORS
  261.  
  262. B<Rajappa Iyer> rsi@earthling.net did the original coding.
  263.  
  264. B<Jason A. Smith> <smithj4@rpi.edu> added support for menus and made some
  265. other enhancements.
  266.  
  267. B<Slaven Rezic> <eserte@cs.tu-berlin.de> added support for canvas items.
  268.  
  269. B<Gerhard Petrowitsch> <gerhard@petrowitsch.de> added intelligent positioning
  270.  
  271. B<Jack Dunnigan> <dunniganj@cpan.org> Made positioning I<more> intelligent and
  272. added support for multiple monitors under single logical screen.
  273.  
  274. =head1 HISTORY
  275.  
  276. The code and documentation was derived from Balloon.tcl from the
  277. Tix4.0 distribution by Ioi Lam and modified by the above mentioned
  278. authors. This code may be redistributed under the same terms as Perl.
  279.  
  280. =cut
  281.  
  282.  
  283.