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

  1.  
  2. =head1 NAME
  3.  
  4. Tk::BrowseEntry - entry widget with popup choices.
  5.  
  6. =for pm Tixish/BrowseEntry.pm
  7.  
  8. =for category Tix Extensions
  9.  
  10. =head1 SYNOPSIS
  11.  
  12.     use Tk::BrowseEntry;
  13.  
  14.     $b = $frame->BrowseEntry(-label => "Label", -variable => \$var);
  15.     $b->insert("end", "opt1");
  16.     $b->insert("end", "opt2");
  17.     $b->insert("end", "opt3");
  18.     ...
  19.     $b->pack;
  20.  
  21. =head1 SUPER-CLASS
  22.  
  23. The C<BrowseEntry> class is derived from the C<Frame> class and
  24. inherits all the methods, options and subwidgets of its super-class.
  25. By default, options and methods are delegated to the entry subwidget.
  26.  
  27. =head1 DESCRIPTION
  28.  
  29. BrowseEntry is a poor man's ComboBox. It may be considered an
  30. enhanced version of LabEntry which provides a button to popup the
  31. choices of the possible values that the Entry may
  32. take. BrowseEntry supports all the options LabEntry supports
  33. except B<-textvariable>. This is replaced by B<-variable>. Other
  34. options that BrowseEntry supports:
  35.  
  36. =over 4
  37.  
  38. =item B<-arrowimage>
  39.  
  40. Specifies the image to be used in the arrow button beside the entry
  41. widget. The default is an downward arrow image in the file cbxarrow.xbm
  42.  
  43. =item B<-autolimitheight>
  44.  
  45. If set to a true value, then the height of the listbox will be at most
  46. the number of entries in the list. The overall maximum of
  47. C<-listheight> still applies.
  48.  
  49. =item B<-autolistwidth>
  50.  
  51. If set to a true value, then the width of the listbox will match the
  52. width of the largest entry.
  53.  
  54. =item B<-browsecmd>
  55.  
  56. Specifies a function to call when a selection is made in the
  57. popped up listbox. It is passed the widget and the text of the
  58. entry selected. This function is called after the entry variable
  59. has been assigned the value.
  60.  
  61. =item B<-browse2cmd>
  62.  
  63. Like C<-browsecmd>, but the callback is called with the listbox index
  64. instead of the selected value.
  65.  
  66. =item B<-buttontakefocus>
  67.  
  68. Set the C<-takefocus> option of the button subwidget.
  69.  
  70. =item B<-choices>
  71.  
  72. Specifies the list of choices to pop up.  This is a reference to an
  73. array of strings specifying the choices.
  74.  
  75. =item B<-colorstate>
  76.  
  77. The state of the widget is reflected by color. A non-editable entry
  78. widget will get a light gray background, while an editable entry will
  79. be almost white. [This may change]
  80.  
  81. =item B<-listcmd>
  82.  
  83. Specifies the function to call when the button next to the entry
  84. is pressed to popup the choices in the listbox. This is called before
  85. popping up the listbox, so can be used to populate the entries in
  86. the listbox.
  87.  
  88. =item B<-listheight>
  89.  
  90. Set the height of the listbox. See also C<-autolimitheight>.
  91.  
  92. =item B<-listwidth>
  93.  
  94. Specifies the width of the popup listbox.
  95.  
  96. =item B<-state>
  97.  
  98. Specifies one of three states for the widget: normal, readonly, or
  99. disabled.  If the widget is disabled then the value may not be changed
  100. and the arrow button won't activate.  If the widget is readonly, the
  101. entry may not be edited, but it may be changed by choosing a value
  102. from the popup listbox.  normal is the default.
  103.  
  104. =item B<-style>
  105.  
  106. Set the "style" of the widget. Permitted values are C<MSWin32> and
  107. C<unix>. By default C<-style> is set to the current platform. Widgets
  108. with the C<unix> style will look like a normal C<BrowseEntry> widget,
  109. whereas with the C<MSWin32> style the arrow will look close to the
  110. Windows' standard combobox widget, while moving the mouse the entries
  111. will be highlighted, and probably includes other changes.
  112.  
  113. =item B<-variable>
  114.  
  115. Specifies the variable in which the entered value is to be stored.
  116.  
  117. =back
  118.  
  119. =head1 METHODS
  120.  
  121. =over 4
  122.  
  123. =item B<insert(>I<index>, I<string>B<)>
  124.  
  125. Inserts the text of I<string> at the specified I<index>. This string
  126. then becomes available as one of the choices.
  127.  
  128. =item B<delete(>I<index1>, I<index2>B<)>
  129.  
  130. Deletes items from I<index1> to I<index2>.
  131.  
  132. =item B<get>
  133.  
  134. The get method is delegated to the choices listbox.
  135.  
  136. =back
  137.  
  138. =head1 ADVERTISED WIDGETS
  139.  
  140. The following widgets are advertised:
  141.  
  142. =over
  143.  
  144. =item entry
  145.  
  146. The entry widget.
  147.  
  148. =item arrow
  149.  
  150. The button with the arrow image.
  151.  
  152. =item choices
  153.  
  154. The toplevel widget containing the choice listbox.
  155.  
  156. =item slistbox
  157.  
  158. The scrolled listbox with the choices.
  159.  
  160. =back
  161.  
  162. =head1 SUBCLASSING
  163.  
  164. To make subclassing easier, the following methods may be overridden to
  165. use other standard widgets in composing the mega widget:
  166.  
  167. =over
  168.  
  169. =item LabEntryWidget
  170.  
  171. A widget class compatible with Tk::LabEntry used for the entry.
  172.  
  173. =item ButtonWidget
  174.  
  175. A widget class compatible with Tk::Button used for the arrow button.
  176.  
  177. =item ListboxWidget
  178.  
  179. A widget class compatible with Tk::Listbox used for the choices
  180. listbox.
  181.  
  182. =back
  183.  
  184. For example to use a C<NumEntry> widget (from the Tk-GBARR CPAN
  185. distribution) instead of the normal C<Entry> widget:
  186.  
  187.     package Tk::NumBrowseEntry;
  188.     use base qw(Tk::BrowseEntry);
  189.     use Tk::NumEntry;
  190.     Construct Tk::Widget 'NumBrowseEntry';
  191.     sub LabEntryWidget { "NumEntry" }
  192.  
  193. =head1 BUGS
  194.  
  195. BrowseEntry should really provide more of the ComboBox options.
  196.  
  197. =head1 AUTHOR
  198.  
  199. B<Rajappa Iyer> rsi@earthling.net
  200.  
  201. B<Chris Dean> ctdean@cogit.com made additions.
  202.  
  203. More additions by B<Slaven Rezic> slaven@rezic.de
  204.  
  205. This code was inspired by ComboBox.tcl in Tix4.0 by Ioi Lam and
  206. bears more than a passing resemblance to ComboBox code. This may
  207. be distributed under the same conditions as Perl.
  208.  
  209. =cut
  210.  
  211.