comparison man/lispref/glyphs.texi @ 2028:2ba4f06a264d

[xemacs-hg @ 2004-04-19 08:02:27 by stephent] texi doc improvements <87zn98wg4q.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Mon, 19 Apr 2004 08:02:38 +0000
parents c6facab13185
children 4657b5a54253
comparison
equal deleted inserted replaced
2027:71477bc21fe8 2028:2ba4f06a264d
32 * Glyph Functions:: Functions for working with glyphs. 32 * Glyph Functions:: Functions for working with glyphs.
33 * Images:: Graphical images displayed in a frame. 33 * Images:: Graphical images displayed in a frame.
34 * Glyph Types:: Each glyph has a particular type. 34 * Glyph Types:: Each glyph has a particular type.
35 * Mouse Pointer:: Controlling the mouse pointer. 35 * Mouse Pointer:: Controlling the mouse pointer.
36 * Redisplay Glyphs:: Glyphs controlling various redisplay functions. 36 * Redisplay Glyphs:: Glyphs controlling various redisplay functions.
37 * Native GUI Widgets:: Complex active images treated as a single glyph.
37 * Subwindows:: Inserting an externally-controlled subwindow 38 * Subwindows:: Inserting an externally-controlled subwindow
38 into a buffer. 39 into a buffer.
39 * Glyph Examples:: Examples of how to work with glyphs. 40 * Glyph Examples:: Examples of how to work with glyphs.
40 @end menu 41 @end menu
41 42
345 In general, it is OK to pass an instance object (e.g. as returned by 346 In general, it is OK to pass an instance object (e.g. as returned by
346 @code{glyph-property-instance}) as an instantiator in place of an actual 347 @code{glyph-property-instance}) as an instantiator in place of an actual
347 instantiator. In such a case, the instantiator used to create that 348 instantiator. In such a case, the instantiator used to create that
348 instance object will be used (for example, if you set a font-instance 349 instance object will be used (for example, if you set a font-instance
349 object as the value of the @code{font} property, then the font name used 350 object as the value of the @code{font} property, then the font name used
350 to create that object will be used instead). If some cases, however, 351 to create that object will be used instead). In some cases, however,
351 doing this conversion does not make sense, and this will be noted in the 352 doing this conversion does not make sense, and this will be noted in the
352 documentation for particular types of instance objects. 353 documentation for particular types of instance objects.
353 354
354 If @var{property} is not a built-in property, then this function will 355 If @var{property} is not a built-in property, then this function will
355 simply set its value if @var{locale} is @code{nil}. However, if 356 simply set its value if @var{locale} is @code{nil}. However, if
1202 This function returns the background color of @var{image-instance}, if 1203 This function returns the background color of @var{image-instance}, if
1203 applicable. This will be a color instance or @code{nil}. (It will only 1204 applicable. This will be a color instance or @code{nil}. (It will only
1204 be non-@code{nil} for colorized mono pixmaps and for pointers.) 1205 be non-@code{nil} for colorized mono pixmaps and for pointers.)
1205 @end defun 1206 @end defun
1206 1207
1207
1208 @node Glyph Types 1208 @node Glyph Types
1209 @section Glyph Types 1209 @section Glyph Types
1210 1210
1211 Each glyph has a particular type, which controls how the glyph's image 1211 Each glyph has a particular type, which controls how the glyph's image
1212 is generated. Each glyph type has a corresponding list of allowable 1212 is generated. Each glyph type has a corresponding list of allowable
1371 @end defvr 1371 @end defvr
1372 1372
1373 @defvr Glyph control-arrow-glyph 1373 @defvr Glyph control-arrow-glyph
1374 This variable specifies what to use as an arrow for control characters. 1374 This variable specifies what to use as an arrow for control characters.
1375 @end defvr 1375 @end defvr
1376
1377 @node Native GUI Widgets
1378 @section Native GUI Widgets
1379 @cindex native widget
1380
1381 A ``native widget'' is a primitive GUI object defined either by the host
1382 GUI platform or an external toolkit, and accessed from Lisp as a
1383 ``glyph.''
1384
1385 @menu
1386 * Introduction to Widgets:: Native widgets provide tight integration of
1387 GUI features with the platform GUI.
1388 * Lisp API to Native Widgets:: Native widgets are glyphs.
1389 * Layouts:: Specifying composite widgets from Lisp.
1390 * Primitive Widgets:: Catalogue of available native widgets.
1391 @end menu
1392
1393 @node Introduction to Widgets
1394 @subsection Introduction to Native Widgets and Subwindow Glyphs
1395
1396 Traditionally Emacsen have hidden the GUI apparatus from the Lisp
1397 programmer, but in XEmacs 21.4 the ability to embed autonomous GUI
1398 objects, called @dfn{native widgets}, in text was added to Lisp. They
1399 are handled as @emph{glyphs}. Unlike traditional XEmacs
1400 glyphs such images and strings, native widgets are opaque to XEmacs, and
1401 must be able to redraw themselves because they are implemented as
1402 subwindows, not as graphics drawn by XEmacs into the text window.
1403
1404 Primitive widgets are coded in C using the underlying GUI toolkit, and
1405 thus are beyond the scope of the @emph{XEmacs Lisp Reference Manual}.
1406 However, composite widgets can be created in Lisp using ``layouts,''
1407 which are horizontal or vertical arrays of subwidgets. For example, the
1408 search dialog is formatted using layouts.
1409
1410 @node Lisp API to Native Widgets
1411 @subsection Lisp API to Native Widgets
1412
1413 Native widgets are manipulated as @emph{glyphs} (@pxref{Glyphs}). Thus
1414 they are created using @code{make-glyph}, with a format of one of the
1415 widget types and a @code{:data} property specific to the widget being
1416 instanced.
1417
1418 However, there is a technical difference between widgets and other kinds
1419 of glyphs that is theoretically important, which is that because widgets
1420 are active (that is, they can respond to user input events themselves),
1421 it is possible for the user to become aware that two appearances of the
1422 ``same'' glyph are actually separate instances. For example, if a user
1423 changes an image glyph from red to blue, and the buffer containing the
1424 glyph appears in more than one window, the user will perceive all the
1425 appearances to change from red to blue simultaneously. However, suppose
1426 the glyph is a button glyph (@emph{e.g.}, as used in the Customize
1427 buffer for the Set, Save, and Done buttons). Then if the Customize
1428 buffer appears in several windows at the same time, and the user clicks
1429 on the button, she will only perceive the button to be depressed in the
1430 window where she clicked the button.
1431
1432 It seems from this example that it is unlikely to be a problem in
1433 practice. When the user is faced with an active widget, it seems likely
1434 that attention will focus on the widget being manipulated, and having
1435 other instances of the widget respond simultaneously might be more
1436 disconcerting than the actual case.
1437
1438 @node Layouts
1439 @subsection Layouts
1440
1441 An XEmacs @dfn{layout} is a one-dimensional array of glyphs. It is a
1442 widget for controlling the positioning of children underneath it.
1443 Through the use of nested layouts, a widget hierarchy can be created
1444 which can have the appearance of any standard dialog box or similar
1445 arrangement; all of this is counted as one "glyph" and could appear in
1446 many of the places that expect a single glyph.
1447
1448 (There are also @dfn{native layouts}, but I don't know what these are or
1449 how they are used.)
1450
1451 A layout descriptor is an image instantiator, @emph{i.e.}, a vector of
1452 the form @samp{[FORMAT KEY-1 VALUE-1 KEY-2 VALUE-2 ...]} with format
1453 @code{layout}, and properties
1454
1455 @c #### need defaults for these
1456 @table @code
1457 @item :orientation
1458 Specifies the orientation of the contained array of glyphs. The value
1459 must be one of the symbols @code{horizontal} or @code{vertical}.
1460
1461 @item :horizontally-justify
1462 Specifies the horizontal justification of the items in the array. The
1463 value must be one of the symbols @code{:right}, @code{:center}, or
1464 @code{:left}.
1465
1466 @item :vertically-justify
1467 Specifies the vertical justification of the items in the array. The
1468 value must be one of the symbols @code{:center}, @code{:center}, or
1469 @code{:bottom}.
1470
1471 @item :justify
1472 Specifies justification. #### not understood.
1473
1474 @item :border
1475 A glyph to place in the border. The value must be an image
1476 instantiator.
1477
1478 @item :items
1479 The glyphs controlled by the layout. The value must be a list of image
1480 instantiators.
1481 @end table
1482
1483 Here is the specification of the search dialog widget created by
1484 @code{make-search-dialog} in the @file{dialog-items} library, which
1485 makes use of recursive layouts.
1486
1487 @example
1488 (make-glyph
1489 `[layout
1490 :orientation horizontal
1491 :vertically-justify top
1492 :horizontally-justify center
1493 :border [string :data "Search"]
1494 :items
1495 ([layout :orientation vertical
1496 :justify top ; implies left also
1497 :items
1498 ([string :data "Search for:"]
1499 [button :descriptor "Match Case"
1500 :style toggle
1501 :selected (not case-fold-search)
1502 :callback (setq case-fold-search
1503 (not case-fold-search))]
1504 [button :descriptor "Regular Expression"
1505 :style toggle
1506 :selected search-dialog-regexp
1507 :callback (setq search-dialog-regexp
1508 (not search-dialog-regexp))]
1509 [button :descriptor "Forwards"
1510 :style radio
1511 :selected search-dialog-direction
1512 :callback (setq search-dialog-direction t)]
1513 [button :descriptor "Backwards"
1514 :style radio
1515 :selected (not search-dialog-direction)
1516 :callback (setq search-dialog-direction nil)]
1517 )]
1518 [layout :orientation vertical
1519 :vertically-justify top
1520 :horizontally-justify right
1521 :items
1522 ([edit-field :width 15 :descriptor "" :active t
1523 :initial-focus t]
1524 [button :width 10 :descriptor "Find Next"
1525 :callback-ex
1526 (lambda (image-instance event)
1527 (search-dialog-callback ,parent
1528 image-instance
1529 event))]
1530 [button :width 10 :descriptor "Cancel"
1531 :callback-ex
1532 (lambda (image-instance event)
1533 (isearch-dehighlight)
1534 (delete-frame
1535 (event-channel event)))])])])
1536 @end example
1537
1538 @node Primitive Widgets
1539 @subsection Primitive Widgets
1540
1541 @c #### the following table should be replaced with a menu of nodes
1542 @table @code
1543 @item button
1544 A button widget; either a push button, radio button or toggle
1545 button.
1546
1547 @item combo-box
1548 A drop list of selectable items in a widget, for editing text.
1549
1550 @item edit-field
1551 A text editing widget.
1552
1553 @item label
1554 A static, text-only, widget; for displaying text.
1555
1556 @item progress-gauge
1557 A sliding widget, for showing progress.
1558
1559 @item tab-control
1560 A tab widget; a series of user selectable tabs.
1561
1562 @item tree-view
1563 A folding widget.
1564
1565 @item scrollbar
1566 A scrollbar widget. (#### Probably not the same as the scrollbar
1567 controlling an Emacs window.)
1568 @end table
1569
1376 1570
1377 @node Subwindows 1571 @node Subwindows
1378 @section Subwindows 1572 @section Subwindows
1379 1573
1380 Subwindows are not currently implemented. 1574 Subwindows are not currently implemented.