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