| 13.6 The Cavity |
|
|
When the root window first appears, it seems to be a hole with nothing in
it. When viewed from pack, this hole is called the
According to the cavity paradigm, each newly packed widget goes into a cavity. The size of a cavity is not fixed it varies as the window is resized. When you pack another widget into a cavity you are placing it on one side of that cavity. The -side option, whose values are "top," "bottom," "left" and "right," is used to determine which side. The widget occupies a slice that fills the whole side of the cavity that was current when it was created. With the creation of a new slice, the new cavity is the old cavity minus this slice. Although the cavity paradigm is simple and flexible, it is confusing to use. Look at Figure 13.6a and try to do the following: Point to the cavity or cavities. Explain why the grey box on the left is not centered vertically. Explain what will happen when a user expands the window.
The cavity paradigm is not easy to master and does not encourage windows that are intellectually manageable. The slicing paradigm, on the other hand, has both these pleasant properties. Unfortunately, the slicing paradigm requires extra frames if it is to accomplish as much as the cavity paradigm. This section suggests a blending of the two that gives you the flexibility of the cavity paradigm while encouraging you to think in terms of slices. In this blended paradigm every slice goes into some cavity as described
above. The difference is that you think of cavities in terms of slicings.
Each slicing may have an Horizontal slicings are not created with just -side top (the default) but also with -side bottom. Whenever -side top is used, the newly created slice is on the top of the attached cavity of the new slicing. Whenever -side bottom is used, the newly created slice is on the bottom of the attached cavity of the new slicing. Each additional slice goes into the attached cavity of the previous version of the slicing. For vertical slicings the situation is similar. They are created with the "left" and "right" values of the -side option. Whenever -side left is used, the newly created slice is on the left of the attached cavity of the new slicing. Whenever -side right is used, the newly created slice is on the right of the attached cavity of the new slicing. Each additional slice goes into the attached cavity of the previous version of the slicing. If a vertical slice is put into the attached cavity of a horizontal slicing, the horizontal slicing becomes complete and its attached cavity is lost. If a horizontal slice is put into the attached cavity of a vertical slicing, the vertical slicing becomes complete and its attached cavity is lost.
The solution to this exercise is certainly easier to fathom than the same code as it shown in Figure 13.6a. However, a greater benefit of thinking in terms of slicings may be that you are more likely to pack your windows in ways that can be more easily described. "More easily described" implies "more easily understood."
|
Author's Home Page |
|
Order from Amazon. |