1Tk_MaintainGeometry(3) Tk Library Procedures Tk_MaintainGeometry(3)
2
3
4
5______________________________________________________________________________
6
8 Tk_MaintainGeometry, Tk_UnmaintainGeometry - maintain geometry of one
9 window relative to another
10
12 #include <tk.h>
13
14 Tk_MaintainGeometry(slave, master, x, y, width, height)
15
16 Tk_UnmaintainGeometry(slave, master)
17
19 Tk_Window slave (in) Window whose geometry is to be con‐
20 trolled.
21
22 Tk_Window master (in) Window relative to which slave's geome‐
23 try will be controlled.
24
25 int x (in) Desired x-coordinate of slave in master,
26 measured in pixels from the inside of
27 master's left border to the outside of
28 slave's left border.
29
30 int y (in) Desired y-coordinate of slave in master,
31 measured in pixels from the inside of
32 master's top border to the outside of
33 slave's top border.
34
35 int width (in) Desired width for slave, in pixels.
36
37 int height (in) Desired height for slave, in pixels.
38_________________________________________________________________
39
40
42 Tk_MaintainGeometry and Tk_UnmaintainGeometry make it easier for geome‐
43 try managers to deal with slaves whose masters are not their parents.
44 Three problems arise if the master for a slave is not its parent:
45
46 [1] The x- and y-position of the slave must be translated from the
47 coordinate system of the master to that of the parent before
48 positioning the slave.
49
50 [2] If the master window, or any of its ancestors up to the slave's
51 parent, is moved, then the slave must be repositioned within its
52 parent in order to maintain the correct position relative to the
53 master.
54
55 [3] If the master or one of its ancestors is mapped or unmapped,
56 then the slave must be mapped or unmapped to correspond.
57
58 None of these problems is an issue if the parent and master are the
59 same. For example, if the master or one of its ancestors is unmapped,
60 the slave is automatically removed by the screen by X.
61
62 Tk_MaintainGeometry deals with these problems for slaves whose masters
63 are not their parents, as well as handling the simpler case of slaves
64 whose masters are their parents. Tk_MaintainGeometry is typically
65 called by a window manager once it has decided where a slave should be
66 positioned relative to its master. Tk_MaintainGeometry translates the
67 coordinates to the coordinate system of slave's parent and then moves
68 and resizes the slave appropriately. Furthermore, it remembers the
69 desired position and creates event handlers to monitor the master and
70 all of its ancestors up to (but not including) the slave's parent. If
71 any of these windows is moved, mapped, or unmapped, the slave will be
72 adjusted so that it is mapped only when the master is mapped and its
73 geometry relative to the master remains as specified by x, y, width,
74 and height.
75
76 When a window manager relinquishes control over a window, or if it
77 decides that it does not want the window to appear on the screen under
78 any conditions, it calls Tk_UnmaintainGeometry. Tk_UnmaintainGeometry
79 unmaps the window and cancels any previous calls to Tk_MaintainGeometry
80 for the master-slave pair, so that the slave's geometry and mapped
81 state are no longer maintained automatically. Tk_UnmaintainGeometry
82 need not be called by a geometry manager if the slave, the master, or
83 any of the master's ancestors is destroyed: Tk will call it automati‐
84 cally.
85
86 If Tk_MaintainGeometry is called repeatedly for the same master-slave
87 pair, the information from the most recent call supersedes any older
88 information. If Tk_UnmaintainGeometry is called for a master-slave
89 pair that is is not currently managed, the call has no effect.
90
92 geometry manager, map, master, parent, position, slave, unmap
93
94
95
96Tk 4.0 Tk_MaintainGeometry(3)