Mercurial > hg > xemacs-beta
comparison man/widget.texi @ 434:9d177e8d4150 r21-2-25
Import from CVS: tag r21-2-25
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:30:53 +0200 |
parents | 3ecd8885ac67 |
children | 8de8e3f6228a |
comparison
equal
deleted
inserted
replaced
433:892ca416f0fb | 434:9d177e8d4150 |
---|---|
460 String to suffix buttons. | 460 String to suffix buttons. |
461 @end defopt | 461 @end defopt |
462 | 462 |
463 @item %@{ | 463 @item %@{ |
464 @itemx %@} | 464 @itemx %@} |
465 The text inside will be displayed with the face specified by | 465 The text inside will be displayed in the face specified by |
466 @code{:sample-face}. | 466 @code{:sample-face}. |
467 | 467 |
468 @item %v | 468 @item %v |
469 This will be replaces with the buffer representation of the widgets | 469 This will be replaced with the buffer representation of the widget's |
470 value. What this is depends on the widget type. | 470 value. What this is depends on the widget type. |
471 | 471 |
472 @item %d | 472 @item %d |
473 Insert the string specified by @code{:doc} here. | 473 Insert the string specified by @code{:doc} here. |
474 | 474 |
558 Should be a function called with two arguments, the widget and a value, | 558 Should be a function called with two arguments, the widget and a value, |
559 and returning non-nil if the widget can represent the specified value. | 559 and returning non-nil if the widget can represent the specified value. |
560 | 560 |
561 @item :validate | 561 @item :validate |
562 A function which takes a widget as an argument, and return nil if the | 562 A function which takes a widget as an argument, and return nil if the |
563 widgets current value is valid for the widget. Otherwise, it should | 563 widget's current value is valid for the widget. Otherwise it should |
564 return the widget containing the invalid data, and set that widgets | 564 return the widget containing the invalid data, and set that widget's |
565 @code{:error} property to a string explaining the error. | 565 @code{:error} property to a string explaining the error. |
566 | 566 |
567 The following predefined function can be used: | 567 The following predefined function can be used: |
568 | 568 |
569 @defun widget-children-validate widget | 569 @defun widget-children-validate widget |
762 | 762 |
763 @example | 763 @example |
764 TYPE ::= (menu-choice [KEYWORD ARGUMENT]... TYPE ... ) | 764 TYPE ::= (menu-choice [KEYWORD ARGUMENT]... TYPE ... ) |
765 @end example | 765 @end example |
766 | 766 |
767 The @var{type} arguments represents each possible choice. The widgets | 767 The @var{type} argument represents each possible choice. The widget's |
768 value of will be the value of the chosen @var{type} argument. This | 768 value will be that of the chosen @var{type} argument. This widget will |
769 widget will match any value that matches at least one of the specified | 769 match any value matching at least one of the specified @var{type} |
770 @var{type} arguments. | 770 arguments. |
771 | 771 |
772 @table @code | 772 @table @code |
773 @item :void | 773 @item :void |
774 Widget type used as a fallback when the value does not match any of the | 774 Widget type used as a fallback when the value does not match any of the |
775 specified @var{type} arguments. | 775 specified @var{type} arguments. |
797 | 797 |
798 @example | 798 @example |
799 TYPE ::= (radio-button-choice [KEYWORD ARGUMENT]... TYPE ... ) | 799 TYPE ::= (radio-button-choice [KEYWORD ARGUMENT]... TYPE ... ) |
800 @end example | 800 @end example |
801 | 801 |
802 The @var{type} arguments represents each possible choice. The widgets | 802 The @var{type} argument represents each possible choice. The widget's |
803 value of will be the value of the chosen @var{type} argument. This | 803 value will be that of the chosen @var{type} argument. This widget will |
804 widget will match any value that matches at least one of the specified | 804 match any value matching at least one of the specified @var{type} |
805 @var{type} arguments. | 805 arguments. |
806 | 806 |
807 The following extra properties are recognized. | 807 The following extra properties are recognized. |
808 | 808 |
809 @table @code | 809 @table @code |
810 @item :entry-format | 810 @item :entry-format |
887 | 887 |
888 @example | 888 @example |
889 TYPE ::= (toggle [KEYWORD ARGUMENT]...) | 889 TYPE ::= (toggle [KEYWORD ARGUMENT]...) |
890 @end example | 890 @end example |
891 | 891 |
892 The widget has two possible states, `on' and `off', which corresponds to | 892 The widget has two possible states, `on' and `off', which correspond to |
893 a @code{t} or @code{nil} value. | 893 a @code{t} or @code{nil} value respectively. |
894 | 894 |
895 The following extra properties are recognized. | 895 The following extra properties are recognized. |
896 | 896 |
897 @table @code | 897 @table @code |
898 @item :on | 898 @item :on |
928 | 928 |
929 @example | 929 @example |
930 TYPE ::= (checklist [KEYWORD ARGUMENT]... TYPE ... ) | 930 TYPE ::= (checklist [KEYWORD ARGUMENT]... TYPE ... ) |
931 @end example | 931 @end example |
932 | 932 |
933 The @var{type} arguments represents each checklist item. The widgets | 933 The @var{type} arguments represents each checklist item. The widget's |
934 value of will be a list containing the value of each ticked @var{type} | 934 value will be a list containing the values of all ticked @var{type} |
935 argument. The checklist widget will match a list whose elements all | 935 arguments. The checklist widget will match a list whose elements all |
936 matches at least one of the specified @var{type} arguments. | 936 match at least one of the specified @var{type} arguments. |
937 | 937 |
938 The following extra properties are recognized. | 938 The following extra properties are recognized. |
939 | 939 |
940 @table @code | 940 @table @code |
941 @item :entry-format | 941 @item :entry-format |
949 @item %% | 949 @item %% |
950 Insert a literal @samp{%}. | 950 Insert a literal @samp{%}. |
951 @end table | 951 @end table |
952 | 952 |
953 @item :greedy | 953 @item :greedy |
954 Usually, a checklist will only match if the items are in the exact | 954 Usually a checklist will only match if the items are in the exact |
955 sequence given in the specification. By setting @code{:greedy} to | 955 sequence given in the specification. By setting @code{:greedy} to |
956 non-nil, it will allow the items to come in any sequence. However, if | 956 non-nil, it will allow the items to appear in any sequence. However, if |
957 you extract the value they will be in the sequence given in the | 957 you extract the values they will be in the sequence given in the |
958 checklist. I.e. the original sequence is forgotten. | 958 checklist. I.e. the original sequence is forgotten. |
959 | 959 |
960 @item button-args | 960 @item button-args |
961 A list of keywords to pass to the checkboxes. Useful for setting | 961 A list of keywords to pass to the checkboxes. Useful for setting |
962 e.g. the @samp{:help-echo} for each checkbox. | 962 e.g. the @samp{:help-echo} for each checkbox. |
963 | 963 |
1234 | 1234 |
1235 The value of a widget of this type will either have the form | 1235 The value of a widget of this type will either have the form |
1236 @samp{(file t)} or @code{(file string string)}. | 1236 @samp{(file t)} or @code{(file string string)}. |
1237 | 1237 |
1238 This concept of inline is probably hard to understand. It was certainly | 1238 This concept of inline is probably hard to understand. It was certainly |
1239 hard to implement so instead of confuse you more by trying to explain it | 1239 hard to implement so instead of confusing you more by trying to explain |
1240 here, I'll just suggest you meditate over it for a while. | 1240 it here, I'll just suggest you meditate over it for a while. |
1241 | 1241 |
1242 @deffn Widget choice | 1242 @deffn Widget choice |
1243 Allows you to edit a sexp which may have one of fixed set of types. It | 1243 Allows you to edit a sexp which may have one of a fixed set of types. |
1244 is currently implemented with the @code{choice-menu} basic widget, and | 1244 It is currently implemented with the @code{choice-menu} basic widget, |
1245 has a similar syntax. | 1245 and has a similar syntax. |
1246 @end deffn | 1246 @end deffn |
1247 | 1247 |
1248 @deffn Widget set | 1248 @deffn Widget set |
1249 Allows you to specify a type which must be a list whose elements all | 1249 Allows you to specify a type which must be a list whose elements all |
1250 belong to given set. The elements of the list is not significant. This | 1250 belong to given set. The elements of the list is not significant. This |
1324 | 1324 |
1325 ;; Make @var{widget} active. | 1325 ;; Make @var{widget} active. |
1326 (widget-apply @var{widget} :activate) | 1326 (widget-apply @var{widget} :activate) |
1327 @end lisp | 1327 @end lisp |
1328 | 1328 |
1329 A widget is inactive if itself, or any of its ancestors (found by | 1329 A widget is inactive if itself or any of its ancestors (found by |
1330 following the @code{:parent} link) have been deactivated. To make sure | 1330 following the @code{:parent} link) have been deactivated. To make sure |
1331 a widget is really active, you must therefore activate both itself, and | 1331 a widget is really active, you must therefore activate both itself and |
1332 all its ancestors. | 1332 all its ancestors. |
1333 | 1333 |
1334 @lisp | 1334 @lisp |
1335 (while widget | 1335 (while widget |
1336 (widget-apply widget :activate) | 1336 (widget-apply widget :activate) |
1337 (setq widget (widget-get widget :parent))) | 1337 (setq widget (widget-get widget :parent))) |
1338 @end lisp | 1338 @end lisp |
1339 | 1339 |
1340 You can check if a widget has been made inactive by examining the value | 1340 You can check if a widget has been made inactive by examining the value |
1341 of @code{:inactive} keyword. If this is non-nil, the widget itself has | 1341 of the @code{:inactive} keyword. If this is non-nil, the widget itself |
1342 been deactivated. This is different from using the @code{:active} | 1342 has been deactivated. This is different from using the @code{:active} |
1343 keyword, in that the later tell you if the widget @strong{or} any of its | 1343 keyword, in that the latter tells you if the widget @strong{or} any of |
1344 ancestors have been deactivated. Do not attempt to set the | 1344 its ancestors have been deactivated. Do not attempt to set the |
1345 @code{:inactive} keyword directly. Use the @code{:activate} | 1345 @code{:inactive} keyword directly. Use the @code{:activate} |
1346 @code{:deactivated} keywords instead. | 1346 @code{:deactivate} keywords instead. |
1347 | 1347 |
1348 | 1348 |
1349 @node Defining New Widgets, Widget Browser, Widget Properties, Top | 1349 @node Defining New Widgets, Widget Browser, Widget Properties, Top |
1350 @comment node-name, next, previous, up | 1350 @comment node-name, next, previous, up |
1351 @section Defining New Widgets | 1351 @section Defining New Widgets |
1352 | 1352 |
1353 You can define specialized widgets with @code{define-widget}. It allows | 1353 You can define specialized widgets with @code{define-widget}. It allows |
1354 you to create a shorthand for more complex widgets, including specifying | 1354 you to create a shorthand for more complex widgets. This includes |
1355 component widgets and default new default values for the keyword | 1355 specifying component widgets and new default values for the keyword |
1356 arguments. | 1356 arguments. |
1357 | 1357 |
1358 @defun widget-define name class doc &rest args | 1358 @defun widget-define name class doc &rest args |
1359 Define a new widget type named @var{name} from @code{class}. | 1359 Define a new widget type named @var{name} from @code{class}. |
1360 | 1360 |
1361 @var{name} and class should both be symbols, @code{class} should be one | 1361 @var{name} and class should both be symbols, @code{class} should be one |
1362 of the existing widget types. | 1362 of the existing widget types. |
1363 | 1363 |
1364 The third argument @var{DOC} is a documentation string for the widget. | 1364 The third argument @var{DOC} is a documentation string for the widget. |
1365 | 1365 |
1366 After the new widget has been defined, the following two calls will | 1366 After the new widget has been defined the following two calls will |
1367 create identical widgets: | 1367 create identical widgets: |
1368 | 1368 |
1369 @itemize @bullet | 1369 @itemize @bullet |
1370 @item | 1370 @item |
1371 @lisp | 1371 @lisp |
1378 @end lisp | 1378 @end lisp |
1379 @end itemize | 1379 @end itemize |
1380 | 1380 |
1381 @end defun | 1381 @end defun |
1382 | 1382 |
1383 Using @code{widget-define} does just store the definition of the widget | 1383 Using @code{widget-define} just stores the definition of the widget type |
1384 type in the @code{widget-type} property of @var{name}, which is what | 1384 in the @code{widget-type} property of @var{name}, which is what |
1385 @code{widget-create} uses. | 1385 @code{widget-create} uses. |
1386 | 1386 |
1387 If you just want to specify defaults for keywords with no complex | 1387 If you just want to specify defaults for keywords with no complex |
1388 conversions, you can use @code{identity} as your conversion function. | 1388 conversions, you can use @code{identity} as your conversion function. |
1389 | 1389 |
1392 @table @code | 1392 @table @code |
1393 @item :convert-widget | 1393 @item :convert-widget |
1394 Function to convert a widget type before creating a widget of that | 1394 Function to convert a widget type before creating a widget of that |
1395 type. It takes a widget type as an argument, and returns the converted | 1395 type. It takes a widget type as an argument, and returns the converted |
1396 widget type. When a widget is created, this function is called for the | 1396 widget type. When a widget is created, this function is called for the |
1397 widget type and all the widgets parent types, most derived first. | 1397 widget type and all the widget's parent types, most derived first. |
1398 | 1398 |
1399 The following predefined functions can be used here: | 1399 The following predefined functions can be used here: |
1400 | 1400 |
1401 @defun widget-types-convert-widget widget | 1401 @defun widget-types-convert-widget widget |
1402 Convert @code{:args} as widget types in @var{widget}. | 1402 Convert @code{:args} as widget types in @var{widget}. |
1406 Initialize @code{:value} from @code{:args} in @var{widget}. | 1406 Initialize @code{:value} from @code{:args} in @var{widget}. |
1407 @end defun | 1407 @end defun |
1408 | 1408 |
1409 @item :value-to-internal | 1409 @item :value-to-internal |
1410 Function to convert the value to the internal format. The function | 1410 Function to convert the value to the internal format. The function |
1411 takes two arguments, a widget and an external value, and returns the | 1411 takes two arguments, a widget and an external value. It returns the |
1412 internal value. The function is called on the present @code{:value} | 1412 internal value. The function is called on the present @code{:value} |
1413 when the widget is created, and on any value set later with | 1413 when the widget is created, and on any value set later with |
1414 @code{widget-value-set}. | 1414 @code{widget-value-set}. |
1415 | 1415 |
1416 @item :value-to-external | 1416 @item :value-to-external |
1420 when the widget is created, and on any value set later with | 1420 when the widget is created, and on any value set later with |
1421 @code{widget-value-set}. | 1421 @code{widget-value-set}. |
1422 | 1422 |
1423 @item :create | 1423 @item :create |
1424 Function to create a widget from scratch. The function takes one | 1424 Function to create a widget from scratch. The function takes one |
1425 argument, a widget type, and create a widget of that type, insert it in | 1425 argument, a widget type, and creates a widget of that type, inserts it |
1426 the buffer, and return a widget object. | 1426 in the buffer, and returns a widget object. |
1427 | 1427 |
1428 @item :delete | 1428 @item :delete |
1429 Function to delete a widget. The function takes one argument, a widget, | 1429 Function to delete a widget. The function takes one argument, a widget, |
1430 and should remove all traces of the widget from the buffer. | 1430 and should remove all traces of the widget from the buffer. |
1431 | 1431 |
1432 @item :value-create | 1432 @item :value-create |
1433 Function to expand the @samp{%v} escape in the format string. It will | 1433 Function to expand the @samp{%v} escape in the format string. It will |
1434 be called with the widget as its argument. Should | 1434 be called with the widget as its argument and should insert a |
1435 insert a representation of the widgets value in the buffer. | 1435 representation of the widget's value in the buffer. |
1436 | 1436 |
1437 @item :value-delete | 1437 @item :value-delete |
1438 Should remove the representation of the widgets value from the buffer. | 1438 Should remove the representation of the widget's value from the buffer. |
1439 It will be called with the widget as its argument. It doesn't have to | 1439 It will be called with the widget as its argument. It doesn't have to |
1440 remove the text, but it should release markers and delete nested widgets | 1440 remove the text, but it should release markers and delete nested widgets |
1441 if such has been used. | 1441 if such have been used. |
1442 | 1442 |
1443 The following predefined function can be used here: | 1443 The following predefined function can be used here: |
1444 | 1444 |
1445 @defun widget-children-value-delete widget | 1445 @defun widget-children-value-delete widget |
1446 Delete all @code{:children} and @code{:buttons} in @var{widget}. | 1446 Delete all @code{:children} and @code{:buttons} in @var{widget}. |
1460 Function to handle unknown @samp{%} escapes in the format string. It | 1460 Function to handle unknown @samp{%} escapes in the format string. It |
1461 will be called with the widget and the escape character as arguments. | 1461 will be called with the widget and the escape character as arguments. |
1462 You can set this to allow your widget to handle non-standard escapes. | 1462 You can set this to allow your widget to handle non-standard escapes. |
1463 | 1463 |
1464 You should end up calling @code{widget-default-format-handler} to handle | 1464 You should end up calling @code{widget-default-format-handler} to handle |
1465 unknown escape sequences, which will handle the @samp{%h} and any future | 1465 unknown escape sequences. It will handle the @samp{%h} and any future |
1466 escape sequences, as well as give an error for unknown escapes. | 1466 escape sequences as well as give an error for unknown escapes. |
1467 | 1467 |
1468 @item :action | 1468 @item :action |
1469 Function to handle user initiated events. By default, @code{:notify} | 1469 Function to handle user initiated events. By default, @code{:notify} |
1470 the parent. | 1470 the parent. |
1471 | 1471 |
1479 @item :prompt-value | 1479 @item :prompt-value |
1480 Function to prompt for a value in the minibuffer. The function should | 1480 Function to prompt for a value in the minibuffer. The function should |
1481 take four arguments, @var{widget}, @var{prompt}, @var{value}, and | 1481 take four arguments, @var{widget}, @var{prompt}, @var{value}, and |
1482 @var{unbound} and should return a value for widget entered by the user. | 1482 @var{unbound} and should return a value for widget entered by the user. |
1483 @var{prompt} is the prompt to use. @var{value} is the default value to | 1483 @var{prompt} is the prompt to use. @var{value} is the default value to |
1484 use, unless @var{unbound} is non-nil in which case there are no default | 1484 use, unless @var{unbound} is non-nil. In this case there is no default |
1485 value. The function should read the value using the method most natural | 1485 value. The function should read the value using the method most natural |
1486 for this widget, and does not have to check that it matches. | 1486 for this widget and does not have to check whether it matches. |
1487 @end table | 1487 @end table |
1488 | 1488 |
1489 If you want to define a new widget from scratch, use the @code{default} | 1489 If you want to define a new widget from scratch, use the @code{default} |
1490 widget as its base. | 1490 widget as its base. |
1491 | 1491 |