Layout

VERSION 12 Published

Created on:Sep 28, 2007 5:11 PM by admin - Last Modified:  Oct 23, 2007 3:33 PM by admin

1. How do I find the actual height and width of a graphical object?

When you specify the size of a graphical object using height= or width=, you are merely stating a preference. The Curl layout system will attempt to give every object its preferred size, but if that is not possible it will make adjustments accordingly. The simplest way to get the actual size of a Graphic object g is to use get-bounds:
{let b:GRect = {g.layout.get-bounds}

This causes a layout negotiation to occur (if needed) and returns the bounding rectangle for g. You can use operations like b.width and b.height to get height and width of g.

Note that the graphic hierarchy is automatically laid out and then painted on the screen when your applet is first loaded. If you resize the window, both layout and repaint will be repeated. If you cover and uncover the window, only the repaint process will be repeated.

If you're writing a subclass of Graphic and you want to do something each time the size of a graphic is updated, you can override the set-size method. The Layout process ends with a bottom-up treewalk where each Graphic is assigned its actual size by calling the set-size method on the object. The set-size method is passed a rectangle (GRect) that represents the bounding box of your object. You can do any processing that requires the exact size at that time.

2. What kinds of containers does the Curl language have?

These are the most commonly used containers provided by the Curl language:

Frame:
Simple container for exactly one child. Often used as a placeholder because by default it shrinks to fit whatever is placed inside of it.

HBox, VBox:
These can contain any number of children. The children are arranged side by side by an HBox and one above the other in a VBox.

Canvas:
A Canvas can contain any number of children. Each child must be placed at a specific (x, y) location. You must take care to set the size of the Canvas and place the children so they are fully visible. Items inside a Canvas can overlap.

ScrollBox:
A ScrollBox gives whatever is placed inside of it as much space as it needs. If this is larger than the ScrollBox, scrollbars are provided.

TextFlowBox:
This is the container for formatted text. Graphical objects can also be added to a TextFlowBox.

Grid:
Any number of graphical objects can be contained in a Grid. Vertical and horizontal fiducials are used to align the edges of objects.

Table:
A Table consists of rows and columns, much like an HTML table.

View:
A View is a standalone window. It contains one child. If the view contains a document, the child might be a ScrollBox containing a TextFlow Box. If the View is used as a dialog, it might contain a collection of boxes and controls.

3. What is a Fill?

A Fill is a highly stretchy graphical object typically used to fill in the space between other graphical objects to help achieve a desired layout.
Average User Rating
(0 ratings)




There are no comments on this document