Window Controller

Where it all happens and why

You already saw that the Size and Alignment tables contain only data. All the calculations happen in the System table, in the Window Controller field. If you open it, you'll see a huge auto-enter calculation that reads preferences, default or saved settings, passed parameters, then calculates intermediate values, such as available desktop size, and finally yields settings for top, left, width, height, zoom level and status toolbar state and stacks them together. Other global fields simply copy these values from the controller.

Window Controller does all the math in a large auto-enter formula of a global field in the System table.
Window Controller auto-enter formula.

This is somewhat unusual, but necessary and practical behavior. Consider a situation when the user, say, clicks a button in a portal and you need to go to a related record in a new window. The table you're on and the portal are completely unrelated to the System table and tables that store window sizes, alignments and settings. You can set globals in System, but these globals are mere links to related records; to use the related data you need to somehow do all the calculations from the context of the System table. But you cannot just switch there to do this, because you have a portal row selected and will lose it if you do.

You can fetch all the related settings into global fields, but there's too much of them, there's three tables after all, and once the math is done, all these data are no longer necessary. You can also remember the portal context and then restore it somehow, but this is extra work. So it pays to go an extra mile and find the way to run the calculation from System without actually switching to it and without loading all the data into temporary fields. With these considerations a global field with an auto-enter formula seems to be quite a practical option.

It's a bit difficult to debug such a formula, but not that difficult; you can do most of the work in the Data Viewer.

What does Window Controller take into account

Window Controller knows and tries to handle the following:

Why view is special

To properly calculate dimensions the Controller needs to know the view state of the target window (i.e. Form, List, or Table; the two latter have a 3-pixel area on the left). But unlike the status toolbar or zoom level, view state is not a thing users will change on their own, so Window Controller doesn't attempt to save view state nor does it copy the state from current window. It either uses the default state or an explicit parameter; if neither is present, it assumes the view is Form.

blog comments powered by Disqus