home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / doc / Xt / CH06 < prev    next >
Encoding:
Text File  |  1991-08-27  |  28.7 KB  |  1,040 lines

  1. .\" $XConsortium: CH06,v 1.7 91/08/27 10:02:24 swick Exp $
  2. .\"
  3. .\" Copyright 1985, 1986, 1987, 1988, 1991
  4. .\" Massachusetts Institute of Technology, Cambridge, Massachusetts,
  5. .\" and Digital Equipment Corporation, Maynard, Massachusetts.
  6. .\"
  7. .\" Permission to use, copy, modify and distribute this documentation for any
  8. .\" purpose and without fee is hereby granted, provided that the above copyright
  9. .\" notice appears in all copies and that both that copyright notice and this
  10. .\" permission notice appear in supporting documentation, and that the name of
  11. .\" M.I.T. or Digital not be used in in advertising or publicity pertaining
  12. .\" to distribution of the software without specific, written prior permission.
  13. .\" M.I.T and Digital makes no representations about the suitability of the
  14. .\" software described herein for any purpose.
  15. .\" It is provided ``as is'' without express or implied warranty.
  16. \&
  17. .sp 1
  18. .ce 3
  19. \s+1\fBChapter 6\fP\s-1
  20.  
  21. \s+1\fBGeometry Management\fP\s-1
  22. .sp 2
  23. .nr H1 6
  24. .nr H2 0
  25. .nr H3 0
  26. .nr H4 0
  27. .nr H5 0
  28. .LP
  29. .XS
  30. Chapter 6 \- Geometry Management 
  31. .XE
  32. .LP
  33. .IN "geometry_manager procedure"
  34. .IN "Geometry Management"
  35. .IN "Configure Window"
  36. A widget does not directly control its size and location;
  37. rather, its parent is responsible for controlling them.
  38. Although the position of children is usually left up to their parent,
  39. the widgets themselves often have the best idea of their optimal sizes
  40. and, possibly, preferred locations.
  41. .LP
  42. To resolve physical layout conflicts between sibling widgets and between
  43. a widget and its parent, the \*(xI provide the geometry management mechanism.
  44. Almost all 
  45. composite
  46. widgets have a geometry manager specified in the \fIgeometry_manager\fP field
  47. in the widget class record that is responsible for the size, position, and
  48. stacking order of the widget's children.
  49. The only exception is fixed boxes,
  50. which create their children themselves and can ensure that
  51. their children will never make a geometry request.
  52.  
  53. .NH 2
  54. Initiating Geometry Changes
  55. .LP
  56. .XS
  57. \*(SN Initiating Geometry Changes
  58. .XE
  59. Parents, children, and clients each initiate geometry changes differently.
  60. Because a parent has absolute control of its children's geometry,
  61. it changes the geometry directly by calling
  62. .PN XtMove\%Widget ,
  63. .PN XtResizeWidget ,
  64. or
  65. .PN XtConfigureWidget .
  66. A child must ask its parent for a geometry change by calling
  67. .PN XtMakeGeometryRequest
  68. or
  69. .PN XtMakeResizeRequest .
  70. An application or other client code initiates a geometry change by calling
  71. .PN XtSetValues
  72. on the appropriate geometry fields,
  73. thereby giving the widget the opportunity to modify or reject the client
  74. request before it gets propagated to the parent and the opportunity 
  75. to respond appropriately to the parent's reply.
  76. .LP
  77. When a widget that needs to change its size, position, border width, 
  78. or stacking depth asks its parent's geometry manager to make the desired 
  79. changes,
  80. the geometry manager can allow the request, disallow the request, or
  81. suggest a compromise.
  82. .LP
  83. When the geometry manager is asked to change the geometry of a child,
  84. the geometry manager may also rearrange and resize any or all
  85. of the other children that it controls.
  86. The geometry manager can move children around freely using
  87. .PN XtMoveWidget .
  88. When it resizes a child (that is, changes the width, height, or
  89. border width) other than the one making the request,
  90. it should do so by calling
  91. .PN XtResizeWidget .
  92. The requesting child may be given special treatment; see Section 6.5.
  93. It can simultaneously move and resize a child with a single call to
  94. .PN XtConfigureWidget .
  95. .LP
  96. Often, geometry managers find that they can satisfy a request only if
  97. they can reconfigure a widget that they are not in control of; in particular,
  98. the 
  99. composite 
  100. widget may want to change its own size.
  101. In this case,
  102. the geometry manager makes a request to its parent's geometry manager.
  103. Geometry requests can cascade this way to arbitrary depth.
  104. .LP
  105. Because such cascaded arbitration of widget geometry can involve extended
  106. negotiation,
  107. windows are not actually allocated to widgets at application
  108. startup until all widgets are satisfied with their geometry;
  109. see Sections 2.5 and 2.6.
  110. .NT Notes
  111. .IP 1. 5
  112. The \*(xI treatment of stacking requests is deficient in several areas.
  113. Stacking requests for unrealized widgets are granted but will have no effect.
  114. In addition, there is no way to do an
  115. .PN XtSetValues
  116. that will generate a stacking geometry request.
  117. .IP 2. 5
  118. After a successful geometry request (one that returned
  119. .PN XtGeometryYes ),
  120. a widget does not know whether its resize procedure has been called.
  121. Widgets should have resize procedures that can be called more than once
  122. without ill effects.
  123. .NE
  124.  
  125. .NH 2
  126. General Geometry Manager Requests
  127. .XS
  128. \*(SN General Geometry Manager Requests
  129. .XE
  130. .LP
  131. When making a geometry request, the child specifies an
  132. .PN XtWidgetGeometry
  133. structure.
  134. .LP
  135. .IN "XtGeometryMask"
  136. .KS
  137. .Ds 0
  138. .TA .5i 3i
  139. .ta .5i 3i
  140. typedef unsigned long XtGeometryMask;
  141.  
  142. typedef struct {
  143.     XtGeometryMask request_mode;
  144.     Position x, y;
  145.     Dimension width, height;
  146.     Dimension border_width;
  147.     Widget sibling;
  148.     int stack_mode;
  149. } XtWidgetGeometry;
  150. .De
  151. .KE
  152. .LP
  153. To make a general geometry manager request from a widget, use
  154. .PN XtMakeGeometryRequest .
  155. .IN "XtMakeGeometryRequest" "" "@DEF@"
  156. .FD 0
  157. XtGeometryResult XtMakeGeometryRequest(\fIw\fP, \fIrequest\fP, \
  158. \fIreply_return\fP)
  159. .br
  160.       Widget \fIw\fP;
  161. .br
  162.       XtWidgetGeometry *\fIrequest\fP;
  163. .br
  164.       XtWidgetGeometry *\fIreply_return\fP;
  165. .FN
  166. .IP \fIw\fP 1i
  167. Specifies the widget making the request.  \*(rI
  168. .IP \fIrequest\fP 1i
  169. Specifies the desired widget geometry (size, position, border width,
  170. and stacking order).
  171. .IP \fIreply_return\fP 1i
  172. Returns the allowed widget size, or may be NULL
  173. if the requesting widget is not interested in handling
  174. .PN XtGeometryAlmost .
  175. .LP
  176. Depending on the condition,
  177. .PN XtMakeGeometryRequest
  178. performs the following:
  179. .IP \(bu 5
  180. If the widget is unmanaged or the widget's parent is not realized,
  181. it makes the changes and returns
  182. .PN XtGeometryYes .
  183. .IP \(bu 5
  184. If the parent's class is not a subclass of
  185. .PN compositeWidgetClass 
  186. or the parent's \fIgeometry_manager\fP field is NULL,
  187. it issues an error.
  188. .IP \(bu 5
  189. If the widget's \fIbeing_destroyed\fP field is 
  190. .PN True ,
  191. it returns
  192. .PN XtGeometryNo .
  193. .IP \(bu 5
  194. If the widget \fIx\fP, \fIy\fP, \fIwidth\fP, \fIheight\fP and,
  195. \fIborder_width\fP fields are
  196. all equal to the requested values,
  197. it returns
  198. .PN XtGeometryYes ;
  199. otherwise, it calls the parent's geometry_manager procedure 
  200. with the given parameters.
  201. .IP \(bu 5
  202. If the parent's geometry manager returns
  203. .PN XtGeometryYes
  204. and if
  205. .PN XtCWQueryOnly
  206. is not set in \fIrequest->request_mode\fP
  207. and if the widget is realized,
  208. .PN XtMakeGeometryRequest
  209. calls the 
  210. .PN XConfigureWindow
  211. Xlib function to reconfigure the widget's window (set its size, location, 
  212. and stacking order as appropriate).
  213. .IP \(bu 5
  214. If the geometry manager returns
  215. .PN XtGeometryDone ,
  216. the change has been approved and actually has been done.
  217. In this case,
  218. .PN XtMakeGeometryRequest
  219. does no configuring and returns 
  220. .PN XtGeometryYes .
  221. .PN XtMakeGeometryRequest
  222. never returns
  223. .PN XtGeometryDone .
  224. .IP \(bu 5
  225. Otherwise,
  226. .PN XtMakeGeometryRequest
  227. just returns the resulting value from the parent's geometry manager.
  228. .LP
  229. Children of primitive widgets are always unmanaged; therefore,
  230. .PN XtMakeGeometryRequest
  231. always returns
  232. .PN XtGeometryYes
  233. when called by a child of a primitive widget.
  234. .LP
  235. The return codes from geometry managers are
  236. .IN "XtGeometryResult"
  237. .LP
  238. .KS
  239. .Ds 0
  240. .TA .5i 1.75i
  241. .ta .5i 1.75i
  242. typedef enum _XtGeometryResult {
  243.     XtGeometryYes,
  244.     XtGeometryNo,
  245.     XtGeometryAlmost,
  246.     XtGeometryDone
  247. } XtGeometryResult;
  248. .De
  249. .KE
  250. .LP
  251. The \fIrequest_mode\fP definitions are from
  252. .Pn < X11/X.h >.
  253. .TS
  254. lw(.5i) lw(2.5i) lw(.75i).
  255. T{
  256. #define
  257. T}    T{
  258. .PN CWX
  259. T}    T{
  260. (1<<0)
  261. T}
  262. T{
  263. #define
  264. T}    T{
  265. .PN CWY
  266. T}    T{
  267. (1<<1)
  268. T}
  269. T{
  270. #define
  271. T}    T{
  272. .PN CWWidth
  273. T}    T{
  274. (1<<2)
  275. T}
  276. T{
  277. #define
  278. T}    T{
  279. .PN CWHeight
  280. T}    T{
  281. (1<<3)
  282. T}
  283. T{
  284. #define
  285. T}    T{
  286. .PN CWBorderWidth
  287. T}    T{
  288. (1<<4)
  289. T}
  290. T{
  291. #define
  292. T}    T{
  293. .PN CWSibling
  294. T}    T{
  295. (1<<5)
  296. T}
  297. T{
  298. #define
  299. T}    T{
  300. .PN CWStackMode
  301. T}    T{
  302. (1<<6)
  303. T}
  304. .TE
  305. .LP
  306. The \*(xI also support the following value.
  307. .TS
  308. lw(.5i) lw(2.5i) lw(.75i).
  309. T{
  310. #define
  311. T}    T{
  312. .PN XtCWQueryOnly
  313. T}    T{
  314. (1<<7)
  315. T}
  316. .TE
  317. .LP
  318. .PN XtCWQueryOnly
  319. indicates that the corresponding geometry request is only a query
  320. as to what would happen if this geometry request were made
  321. and that no widgets should actually be changed.
  322. .LP
  323. .PN XtMakeGeometryRequest ,
  324. like the 
  325. .PN XConfigureWindow 
  326. Xlib function, uses \fIrequest_mode\fP to determine which fields in the
  327. .PN XtWidgetGeometry
  328. structure the caller wants to specify.
  329. .LP
  330. The \fIstack_mode\fP definitions are from
  331. .Pn < X11/X.h >:
  332. .TS
  333. lw(.5i) lw(2.5i) lw(.75i).
  334. T{
  335. #define
  336. T}    T{
  337. .PN Above
  338. T}    T{
  339. 0
  340. T}
  341. T{
  342. #define
  343. T}    T{
  344. .PN Below
  345. T}    T{
  346. 1
  347. T}
  348. T{
  349. #define
  350. T}    T{
  351. .PN TopIf
  352. T}    T{
  353. 2
  354. T}
  355. T{
  356. #define
  357. T}    T{
  358. .PN BottomIf
  359. T}    T{
  360. 3
  361. T}
  362. T{
  363. #define
  364. T}    T{
  365. .PN Opposite
  366. T}    T{
  367. 4
  368. T}
  369. .TE
  370. .LP
  371. The \*(xI also support the following value.
  372. .TS
  373. lw(.5i) lw(2.5i) lw(.75i).
  374. T{
  375. #define
  376. T}    T{
  377. .PN XtSMDontChange
  378. T}    T{
  379. 5
  380. T}
  381. .TE
  382. .LP
  383. For definition and behavior of
  384. .PN Above ,
  385. .PN Below ,
  386. .PN TopIf ,
  387. .PN BottomIf ,
  388. and
  389. .PN Opposite ,
  390. see Section 3.7 in \fI\*(xL\fP.
  391. .PN XtSMDontChange
  392. indicates that the widget wants its current stacking order preserved.
  393.  
  394. .NH 2
  395. Resize Requests
  396. .XS
  397. \*(SN Resize Requests
  398. .XE
  399. .LP
  400. To make a simple resize request from a widget, you can use
  401. .PN XtMakeResizeRequest 
  402. as an alternative to
  403. .PN XtMakeGeometryRequest .
  404. .IN "XtMakeResizeRequest" "" "@DEF@"
  405. .FD 0
  406. XtGeometryResult XtMakeResizeRequest(\fIw\fP, \fIwidth\fP, \fIheight\fP, \
  407. \fIwidth_return\fP, \fIheight_return\fP)
  408. .br
  409.       Widget \fIw\fP;
  410. .br
  411.       Dimension \fIwidth\fP, \fIheight\fP;
  412. .br
  413.       Dimension *\fIwidth_return\fP, *\fIheight_return\fP;
  414. .FN
  415. .IP \fIw\fP 1i
  416. Specifies the widget making the request.  \*(rI
  417. .IP \fIwidth\fP 1i
  418. .br
  419. .ns
  420. .IP \fIheight\fP 1i
  421. Specify the desired widget width and height.
  422. .IP \fIwidth_return\fP 1i
  423. .br
  424. .ns
  425. .IP \fIheight_return\fP 1i
  426. Return the allowed widget width and height.
  427. .LP
  428. The
  429. .PN XtMakeResizeRequest
  430. function, a simple interface to
  431. .PN XtMakeGeometryRequest ,
  432. creates an
  433. .PN XtWidgetGeometry
  434. structure and specifies that width and height should change
  435. by setting \fIrequest_mode\fP to
  436. .PN CWWidth
  437. \fB|\fP
  438. .PN CWHeight .
  439. The geometry manager is free to modify any of the other window attributes
  440. (position or stacking order) to satisfy the resize request.
  441. If the return value is
  442. .PN XtGeometryAlmost ,
  443. \fIwidth_return\fP and \fIheight_return\fP contain a compromise width and height.
  444. If these are acceptable,
  445. the widget should immediately call
  446. .PN XtMakeResizeRequest
  447. again and request that the compromise width and height be applied.
  448. If the widget is not interested in
  449. .PN XtGeometryAlmost
  450. replies, 
  451. it can pass NULL for \fIwidth_return\fP and \fIheight_return\fP.
  452.  
  453. .NH 2
  454. Potential Geometry Changes
  455. .XS
  456. \*(SN Potential Geometry Changes
  457. .XE
  458. .LP
  459. Sometimes a geometry manager cannot respond to
  460. a geometry request from a child without first making a geometry request
  461. to the widget's own parent (the original requestor's grandparent).
  462. If the request to the grandparent would allow the parent to satisfy the
  463. original request, 
  464. the geometry manager can make the intermediate geometry request 
  465. as if it were the originator.
  466. On the other hand,
  467. if the geometry manager already has determined that the original request
  468. cannot be completely satisfied (for example, if it always denies
  469. position changes),
  470. it needs to tell the grandparent to respond to the intermediate request 
  471. without actually changing the geometry
  472. because it does not know if the child will accept the compromise.
  473. To accomplish this, the geometry manager uses 
  474. .PN XtCWQueryOnly
  475. in the intermediate request.
  476. .LP
  477. When
  478. .PN XtCWQueryOnly
  479. is used, the geometry manager needs to cache
  480. enough information to exactly reconstruct the intermediate request.
  481. If the grandparent's response to the intermediate query was
  482. .PN XtGeometryAlmost ,
  483. the geometry manager needs to cache the entire
  484. reply geometry in the event the child accepts the parent's compromise.
  485. .LP
  486. If the grandparent's response was
  487. .PN XtGeometryAlmost ,
  488. it may also be necessary to cache the entire reply geometry from
  489. the grandparent when
  490. .PN XtCWQueryOnly
  491. is not used.
  492. If the geometry manager is still able to satisfy the original request,
  493. it may immediately accept the grandparent's compromise 
  494. and then act on the child's request.
  495. If the grandparent's compromise geometry is insufficient to allow 
  496. the child's request and if the geometry manager is willing to offer
  497. a different compromise to the child, 
  498. the grandparent's compromise should not be accepted until the child 
  499. has accepted the new compromise.
  500. .LP
  501. Note that a compromise geometry returned with
  502. .PN XtGeometryAlmost
  503. is guaranteed only for the next call to the same widget; 
  504. therefore, a cache of size 1 is sufficient.
  505.  
  506. .NH 2
  507. Child Geometry Management: the geometry_manager Procedure
  508. .XS
  509. \*(SN Child Geometry Management: the geometry_manager Procedure
  510. .XE
  511. .LP
  512. The geometry_manager procedure pointer in a composite widget class is of type
  513. .PN XtGeometryHandler .
  514. .IN "XtGeometryHandler" "" "@DEF@"
  515. .FD 0
  516. typedef XtGeometryResult (*XtGeometryHandler)(Widget, XtWidgetGeometry*, \
  517. XtWidgetGeometry*);
  518. .br
  519.       Widget \fIw\fP;
  520. .br
  521.       XtWidgetGeometry *\fIrequest\fP;
  522. .br
  523.       XtWidgetGeometry *\fIgeometry_return\fP;
  524. .FN
  525. .IP \fIw\fP 1.2i
  526. Passes the widget making the request.
  527. .IP \fIrequest\fP 1.2i
  528. Passes the new geometry the child desires.
  529. .IP \fIgeometry_return\fP 1.2i
  530. Passes a geometry structure in which the geometry manager may store a
  531. compromise.
  532. .LP
  533. A class can inherit its superclass's geometry manager during class
  534. initialization.
  535. .LP
  536. A bit set to zero in the request's \fIrequest_mode\fP
  537. field means that the child widget
  538. does not care about the value of the corresponding field,
  539. so the geometry manager can change this field as it wishes.
  540. A bit set to 1 means that the child wants that geometry element changed
  541. to the value in the corresponding field.
  542. .LP
  543. If the geometry manager can satisfy all changes requested 
  544. and if 
  545. .PN XtCWQueryOnly 
  546. is not specified,
  547. it updates the widget's \fIx\fP, \fIy\fP, \fIwidth\fP, \fIheight\fP,
  548. and \fIborder_width\fP fields
  549. appropriately.
  550. Then, it returns
  551. .PN XtGeometryYes ,
  552. and the values pointed to by the \fIgeometry_return\fP argument are undefined.
  553. The widget's window is moved and resized automatically by
  554. .PN XtMakeGeometryRequest .
  555. .LP
  556. Homogeneous composite widgets often find it convenient to treat the widget
  557. making the request the same as any other widget, including reconfiguring
  558. it using
  559. .PN XtConfigureWidget
  560. or
  561. .PN XtResizeWidget
  562. as part of its layout process, unless 
  563. .PN XtCWQueryOnly
  564. is specified.
  565. If it does this,
  566. it should return
  567. .PN XtGeometryDone
  568. to inform
  569. .PN XtMakeGeometryRequest
  570. that it does not need to do the configuration itself.
  571. .NT
  572. To remain
  573. compatible with layout techniques used in older widgets (before
  574. .PN XtGeometryDone
  575. was added to the \*(xI), a geometry manager should avoid using
  576. .PN XtResizeWidget
  577. or
  578. .PN XtConfigureWidget
  579. on the child making
  580. the request because the layout process of the child may be in an
  581. intermediate state in which it is not prepared to handle a call to its
  582. resize procedure.  A self-contained widget set may choose this
  583. alternative geometry management scheme, however, provided that it
  584. clearly warns widget developers of the compatibility consequences.
  585. .NE
  586. .LP
  587. Although
  588. .PN XtMakeGeometryRequest
  589. resizes the widget's window
  590. (if the geometry
  591. manager returns
  592. .PN XtGeometryYes ),
  593. it does not call the widget class's resize procedure.
  594. The requesting widget must perform whatever
  595. resizing calculations are needed explicitly.
  596. .LP
  597. If the geometry manager disallows the request,
  598. the widget cannot change its geometry.
  599. The values pointed to by \fIgeometry_return\fP are undefined,
  600. and the geometry manager returns
  601. .PN XtGeometryNo .
  602. .LP
  603. Sometimes the geometry manager cannot satisfy the request exactly
  604. but may be able to satisfy a similar request.
  605. That is,
  606. it could satisfy only a subset of the requests (for example,
  607. size but not position) or a lesser request
  608. (for example, it cannot make the child as big as the
  609. request but it can make the child bigger than its current size).
  610. In such cases,
  611. the geometry manager fills in the structure pointed to by
  612. \fIgeometry_return\fP with the actual changes
  613. it is willing to make, including an appropriate \fIrequest_mode\fP mask, and returns
  614. .PN XtGeometryAlmost .
  615. If a bit in \fIgeometry_return->request_mode\fP is zero,
  616. the geometry manager agrees not to change the corresponding value
  617. if \fIgeometry_return\fP is used immediately
  618. in a new request.
  619. If a bit is 1,
  620. the geometry manager does change that element to the corresponding
  621. value in \fIgeometry_return\fP.
  622. More bits may be set in \fIgeometry_return->request_mode\fP
  623. than in the original request if
  624. the geometry manager intends to change other fields should the
  625. child accept the compromise.
  626. .LP
  627. When
  628. .PN XtGeometryAlmost
  629. is returned,
  630. the widget must decide if the compromise suggested in \fIgeometry_return\fP
  631. is acceptable.
  632. If it is, the widget must not change its geometry directly;
  633. rather, it must make another call to
  634. .PN XtMakeGeometryRequest .
  635. .LP
  636. If the next geometry request from this child uses the
  637. \fIgeometry_return\fP values filled in by the geometry manager with an
  638. .PN XtGeometryAlmost
  639. return and if there have been no intervening geometry requests on
  640. either its parent or any of its other children,
  641. the geometry manager must grant the request, if possible.
  642. That is, if the child asks immediately with the returned geometry,
  643. it should get an answer of
  644. .PN XtGeometryYes .
  645. However,
  646. dynamic behavior in
  647. the user's window manager may affect the final outcome.
  648. .LP
  649. To return
  650. .PN XtGeometryYes ,
  651. the geometry manager frequently rearranges the position of other managed 
  652. children by calling
  653. .PN XtMoveWidget .
  654. However, a few geometry managers may sometimes change the
  655. size of other managed children by calling
  656. .PN XtResizeWidget
  657. or
  658. .PN XtConfigureWidget .
  659. If
  660. .PN XtCWQueryOnly
  661. is specified,
  662. the geometry manager must return data describing
  663. how it would react to this geometry
  664. request without actually moving or resizing any widgets.
  665. .LP
  666. Geometry managers must not assume that the \fIrequest\fP
  667. and \fIgeometry_return\fP arguments point to independent storage.
  668. The caller is permitted to use the same field for both,
  669. and the geometry manager must allocate its own temporary storage,
  670. if necessary.
  671.  
  672. .NH 2
  673. Widget Placement and Sizing
  674. .XS
  675. \*(SN Widget Placement and Sizing
  676. .XE
  677. .LP
  678. To move a sibling widget of the child making the geometry request,
  679. the parent uses
  680. .PN XtMoveWidget .
  681. .IN "XtMoveWidget" "" "@DEF@"
  682. .FD 0
  683. void XtMoveWidget(\fIw\fP, \fIx\fP, \fIy\fP)
  684. .br
  685.       Widget \fIw\fP;
  686. .br
  687.       Position \fIx\fP;
  688. .br
  689.       Position \fIy\fP;
  690. .FN
  691. .IP \fIw\fP 1i
  692. Specifies the widget.  \*(rI
  693. .IP \fIx\fP 1i
  694. .br
  695. .ns
  696. .IP \fIy\fP 1i
  697. Specify the new widget x and y coordinates.
  698. .LP
  699. The
  700. .PN XtMoveWidget
  701. function returns immediately if the specified geometry fields
  702. are the same as the old values.
  703. Otherwise,
  704. .PN XtMoveWidget
  705. writes the new \fIx\fP and \fIy\fP values into the object
  706. and, if the object is a widget and is realized, issues an Xlib
  707. .PN XMoveWindow
  708. call on the widget's window.
  709. .sp
  710. .LP
  711. To resize a sibling widget of the child making the geometry request,
  712. the parent uses
  713. .PN XtResizeWidget .
  714. .IN "XtResizeWidget" "" "@DEF@"
  715. .FD 0
  716. void XtResizeWidget(\fIw\fP, \fIwidth\fP, \fIheight\fP, \fIborder_width\fP)
  717. .br
  718.       Widget \fIw\fP;
  719. .br
  720.       Dimension \fIwidth\fP;
  721. .br
  722.       Dimension \fIheight\fP;
  723. .br
  724.       Dimension \fIborder_width\fP;
  725. .FN
  726. .IP \fIw\fP 1i
  727. Specifies the widget.  \*(rI
  728. .IP \fIwidth\fP 1i
  729. .br
  730. .ns
  731. .IP \fIheight\fP 1i
  732. .br
  733. .ns
  734. .IP \fIborder_width\fP 1i
  735. Specify the new widget size.
  736. .LP
  737. The
  738. .PN XtResizeWidget
  739. function returns immediately if the specified geometry fields
  740. are the same as the old values. 
  741. Otherwise,
  742. .PN XtResizeWidget
  743. writes the new \fIwidth\fP, \fIheight\fP, and \fIborder_width\fP values into
  744. the object and, if the object is a widget and is realized, issues an
  745. .PN XConfigureWindow
  746. call on the widget's window.
  747. .LP
  748. If the new width or height is different from the old values,
  749. .PN XtResizeWidget
  750. calls the object's resize procedure to notify it of the size change.
  751. .sp
  752. .LP
  753. To move and resize the sibling widget of the child making the geometry request,
  754. the parent uses
  755. .PN XtConfigureWidget .
  756. .IN "XtConfigureWidget" "" "@DEF@"
  757. .FD 0
  758. void XtConfigureWidget(\fIw\fP, \fIx\fP, \fIy\fP, \fIwidth\fP, \fIheight\fP, \
  759. \fIborder_width\fP)
  760. .br
  761.       Widget \fIw\fP;
  762. .br
  763.       Position \fIx\fP;
  764. .br
  765.       Position \fIy\fP;
  766. .br
  767.       Dimension \fIwidth\fP;
  768. .br
  769.       Dimension \fIheight\fP;
  770. .br
  771.       Dimension \fIborder_width\fP;
  772. .FN
  773. .IP \fIw\fP 1i
  774. Specifies the widget.  \*(rI
  775. .IP \fIx\fP 1i
  776. .br
  777. .ns
  778. .IP \fIy\fP 1i
  779. Specify the new widget x and y coordinates.
  780. .IP \fIwidth\fP 1i
  781. .br
  782. .ns
  783. .IP \fIheight\fP 1i
  784. .br
  785. .ns
  786. .IP \fIborder_width\fP 1i
  787. Specify the new widget size.
  788. .LP
  789. The
  790. .PN XtConfigureWidget
  791. function returns immediately if the specified new geometry fields
  792. are all equal to the current values.
  793. Otherwise,
  794. .PN XtConfigureWidget
  795. writes the new \fIx\fP, \fIy\fP, \fIwidth\fP, \fIheight\fP,
  796. and \fIborder_width\fP values 
  797. into the object and, if the object is a widget and is realized, makes an Xlib
  798. .PN XConfigureWindow
  799. call on the widget's window.
  800. .LP
  801. If the new width or height is different from its old value,
  802. .PN XtConfigureWidget
  803. calls the object's resize procedure to notify it of the size change;
  804. otherwise, it simply returns.
  805. .sp
  806. .LP
  807. To resize a child widget that already has the new values of its width,
  808. height, and border width, the parent uses
  809. .PN XtResizeWindow .
  810. .IN "XtResizeWindow" "" "@DEF@"
  811. .FD 0
  812. void XtResizeWindow(\fIw\fP)
  813. .br
  814.       Widget \fIw\fP;
  815. .FN
  816. .IP \fIw\fP 1i
  817. Specifies the widget.  \*(cI
  818. .LP
  819. The
  820. .PN XtResizeWindow
  821. function calls the 
  822. .PN XConfigureWindow
  823. Xlib function to make the window of the specified widget match its width,
  824. height, and border width. 
  825. This request is done unconditionally because there is no
  826. inexpensive way to tell if these
  827. values match the current values.
  828. Note that the widget's resize procedure is not called.
  829. .LP
  830. There are very few times to use
  831. .PN XtResizeWindow ;
  832. instead, the parent should use
  833. .PN XtResizeWidget .
  834.  
  835. .NH 2
  836. Preferred Geometry
  837. .XS
  838. \*(SN Preferred Geometry
  839. .XE
  840. .LP
  841. Some parents may be willing to adjust their layouts to accommodate the
  842. preferred geometries of their children.
  843. They can use
  844. .PN XtQueryGeometry
  845. to obtain the preferred geometry 
  846. and, as they see fit, can use or ignore any portion of the response.
  847. .sp
  848. .LP
  849. To query a child widget's preferred geometry, use
  850. .PN XtQueryGeometry .
  851. .IN "XtQueryGeometry" "" "@DEF@"
  852. .FD 0
  853. XtGeometryResult XtQueryGeometry(\fIw\fP, \fIintended\fP, \
  854. \fIpreferred_return\fP)
  855. .br
  856.      Widget \fIw\fP\^;
  857. .br
  858.      XtWidgetGeometry *\fIintended\fP, *\fIpreferred_return\fP\^;
  859. .FN
  860. .IP \fIw\fP 1.1i
  861. Specifies the widget.  \*(rI
  862. .IP \fIintended\fP 1.1i
  863. Specifies the new geometry the parent plans to give to the child, or
  864. NULL.
  865. .IP \fIpreferred_return\fP 1.1i
  866. Returns the child widget's preferred geometry.
  867. .LP
  868. To discover a child's preferred geometry,
  869. the child's parent stores the new
  870. geometry in the corresponding fields of
  871. the intended structure, sets the corresponding bits in \fIintended.request_mode\fP,
  872. and calls
  873. .PN XtQueryGeometry .
  874. The parent should set only those fields that are important to it so
  875. that the child can determine whether it may be able to attempt changes to
  876. other fields.
  877. .LP
  878. .PN XtQueryGeometry
  879. clears all bits in the \fIpreferred_return->request_mode\fP
  880. field and checks the
  881. \fIquery_geometry\fP field of the specified widget's class record.
  882. If \fIquery_geometry\fP is not NULL,
  883. .PN XtQueryGeometry
  884. calls the query_geometry procedure and passes as arguments the
  885. specified widget, \fIintended\fP, and \fIpreferred_return\fP structures.
  886. If the \fIintended\fP argument is NULL,
  887. .PN XtQueryGeometry
  888. replaces it with a pointer to an
  889. .PN XtWidgetGeometry
  890. structure with \fIrequest_mode\fP equal to zero before calling the
  891. query_geometry procedure.
  892. .NT
  893. If
  894. .PN XtQueryGeometry
  895. is called from within a geometry_manager
  896. procedure for the widget that issued
  897. .PN XtMakeGeometryRequest
  898. or
  899. .PN XtMakeResizeRequest ,
  900. the results
  901. are not guaranteed to be consistent with the requested changes.  The
  902. change request passed to the geometry manager takes precedence over
  903. the preferred geometry.
  904. .NE
  905. .sp
  906. .LP
  907. The query_geometry procedure pointer is of type
  908. .PN XtGeometryHandler .
  909. .IN "query_geometry procedure" "" "@DEF@"
  910. .FD 0
  911. typedef XtGeometryResult (*XtGeometryHandler)(Widget, XtWidgetGeometry*, \
  912. XtWidgetGeometry*);
  913. .br
  914.       Widget \fIw\fP;
  915. .br
  916.       XtWidgetGeometry *\fIrequest\fP;
  917. .br
  918.       XtWidgetGeometry *\fIpreferred_return\fP;
  919. .FN
  920. .IP \fIw\fP 1.2i
  921. Passes the child widget whose preferred geometry is required.
  922. .IP \fIrequest\fP 1.2i
  923. Passes the geometry changes which the parent plans to make.
  924. .IP \fIpreferred_return\fP 1.2i
  925. Passes a structure in which the child returns its preferred geometry.
  926. .LP
  927. .IN "query_geometry procedure"
  928. The query_geometry procedure is expected to examine the bits set in
  929. \fIrequest->request_mode\fP, evaluate the preferred geometry of the widget,
  930. and store the result in \fIpreferred_return\fP
  931. (setting the bits in \fIpreferred_return->request_mode\fP corresponding
  932. to those geometry fields that it cares about).
  933. If the proposed geometry change is acceptable without modification,
  934. the query_geometry procedure should return
  935. .PN XtGeometryYes .
  936. If at least one field in \fIpreferred_return\fP
  937. with a bit set in \fIpreferred_return->request_mode\fP
  938. is different
  939. from the corresponding field in \fIrequest\fP
  940. or if a bit was set in \fIpreferred_return->request_mode\fP
  941. that was not set in the request,
  942. the query_geometry procedure should return
  943. .PN XtGeometryAlmost .
  944. If the preferred geometry is identical to the current geometry,
  945. the query_geometry procedure should return
  946. .PN XtGeometryNo .
  947. .NT
  948. The query_geometry procedure may assume
  949. that no
  950. .PN XtMakeResizeRequest
  951. or
  952. .PN XtMakeGeometryRequest
  953. is in progress
  954. for the specified widget; that is, it is not required to construct
  955. a reply consistent with the requested geometry if such a request
  956. were actually outstanding.
  957. .NE
  958. .LP
  959. After calling the query_geometry procedure
  960. or if the \fIquery_geometry\fP field is NULL,
  961. .PN XtQueryGeometry
  962. examines all the unset bits in \fIpreferred_return->request_mode\fP
  963. and sets the corresponding fields in \fIpreferred_return\fP
  964. to the current values from the widget instance.
  965. If
  966. .PN CWStackMode
  967. is not set,
  968. the \fIstack_mode\fP field is set to
  969. .PN XtSMDontChange .
  970. .PN XtQueryGeometry
  971. returns the value returned by the query_geometry procedure or
  972. .PN XtGeometryYes
  973. if the \fIquery_geometry\fP field is NULL.
  974. .LP
  975. Therefore, the caller can interpret a return of
  976. .PN XtGeometryYes
  977. as not needing to evaluate the contents of the reply and, more important,
  978. not needing to modify its layout plans.
  979. A return of
  980. .PN XtGeometryAlmost
  981. means either that both the parent and the child expressed interest
  982. in at least one common field and the child's preference does not match 
  983. the parent's intentions or that the child expressed interest in a field that
  984. the parent might need to consider.
  985. A return value of
  986. .PN XtGeometryNo
  987. means that both the parent and the child expressed interest in a field and
  988. that the child suggests that the field's current value in the widget instance
  989. is its preferred value.
  990. In addition, whether or not the caller ignores the return value or the
  991. reply mask, it is guaranteed that the \fIpreferred_return\fP structure contains complete
  992. geometry information for the child.
  993. .LP
  994. Parents are expected to call
  995. .PN XtQueryGeometry
  996. in their layout routine and wherever else the information is significant
  997. after change_managed has been called.
  998. The first time it is invoked,
  999. the changed_managed procedure may assume that the child's current geometry
  1000. is its preferred geometry.
  1001. Thus, the child is still responsible for storing values
  1002. into its own geometry during its initialize procedure.
  1003.  
  1004. .NH 2
  1005. Size Change Management: the resize Procedure
  1006. .XS
  1007. \*(SN Size Change Management: the resize Procedure
  1008. .XE
  1009. .LP
  1010. A child can be resized by its parent at any time.
  1011. Widgets usually need to know when they have changed size
  1012. so that they can lay out their displayed data again to match the new size.
  1013. When a parent resizes a child, it calls
  1014. .PN XtResizeWidget ,
  1015. which updates the geometry fields in the widget,
  1016. configures the window if the widget is realized,
  1017. and calls the child's resize procedure to notify the child.
  1018. The resize procedure pointer is of type
  1019. .PN XtWidgetProc .
  1020. .IN "resize procedure" "" "@DEF@"
  1021. .LP
  1022. If a class need not recalculate anything when a widget is resized,
  1023. it can specify NULL for the \fIresize\fP field in its class record.
  1024. This is an unusual case and should occur only for widgets
  1025. with very trivial display semantics.
  1026. The resize procedure takes a widget as its only argument.
  1027. The \fIx\fP, \fIy\fP, \fIwidth\fP, \fIheight\fP,
  1028. and \fIborder_width\fP fields of the widget contain the new values.
  1029. The resize procedure should recalculate the layout of internal data
  1030. as needed.
  1031. (For example, a centered Label in a window that changes size
  1032. should recalculate the starting position of the text.)
  1033. The widget must obey resize as a command and must not treat it as a request.
  1034. A widget must not issue an
  1035. .PN XtMakeGeometryRequest
  1036. or
  1037. .PN XtMakeResizeRequest
  1038. call from its resize procedure.
  1039. .bp
  1040.