next up previous contents index
Next: Manager Up: Classes and Methods Previous: Item

Layer

  (subclass of 9.1.3.12 Group)

A movable overlay Group.

A layer must be added to the manager using the method "add-layer" to add it to the manager. To remove it from the manager use the function "remove-layer". If the layer depends upon an item, it may be removed or added automatically using this methods. It is also possible to add display method dependent layer using it as a each other normal item.

This example generates a layer, which contains a checkbox, a ruler and a button, which will hide and delete the layer.

LAYER *layer;
MANAGER *mgr;
BUTTON *butt;
CHECKBOX *checkbox;
RULER *ruler;
double sizex, sizey;
int my_flag;
static double my_double;


/* Get the standard Manager. If none existed it will be created.*/
mgr = (MANAGER *)GRAPE (Manager, "get-stdmgr")();

/* Create a new layer. */
layer = (LAYER *)GRAPE (Layer, "new-instance")("my third layer");

/* Set size of layer */
GRAPE (layer, "set-pref-size")(10.0, 10.0);

/* Add it to the manager. It will be drawn at the next Redraw. */
GRAPE (mgr, "add-layer")(layer);

/* Get the layer's inner size, e.g. without the border.*/
GRAPE (layer, "get-size")(&sizex, &sizey);

/* Create a dismiss button with removes the layer by sending "remove" if pressed.*/
butt = (BUTTON *) GRAPE (Button, "new-instance")("remove", layer, "dismiss");
GRAPE (butt, "set-pref-size")(sizex / 2, 1.0);

/* Button will be positioned at the very bottom of the layer. */
GRAPE (butt, "set-fill-mode")(MENU_FILL_BOTTOM);

/* Put button into layer. */
GRAPE (layer, "add-inter")(butt);

/* Create a new ruler which points to a double Variable. */
ruler = (RULER *) GRAPE (Ruler, "new-instance")
        (&my_double, "my ruler", dfDouble);

/* The ruler will fill the layer even if it is resized. */
GRAPE (ruler, "set-pref-size")(MENU_MAX_SIZE, 1.0);
GRAPE (ruler, "set-fill-mode")(MENU_FILL_TOP);
GRAPE (layer, "add-inter")(ruler);
checkbox = (CHECKBOX *) GRAPE (Checkbox, "new-instance")("my checkbox", &my_flag);
GRAPE (checkbox, "set-fill-mode")(MENU_FILL_TOP);
GRAPE (layer, "add-inter")(checkbox);

   GRAPE(layer, "fix-size")(on_off_x, ob_off_y)
LAYER *layer
int on_off_x, ob_off_y
Fix the size of layer in the given directions. This only prohibits rescaling layer with the mouse, methods are not affected. Since the size of a Layer should be the user's responsibility the use of this method is not encouraged.
   GRAPE(layer, "hide")()
LAYER *layer
Hides a layer. If the layer depends on an item, it will be removed from the items layer list. The invert method is show
   (LAYER * ) GRAPE(layer, "is-visible")()
LAYER *layer
   GRAPE(Layer, "new-instance")(name)
CLASS *Layer
char *name
Create a new layer.
   GRAPE(layer, "remove")()
LAYER *layer
Will hide a layer first and then delete it.
   GRAPE(layer, "set-fill-mode")(mode)
LAYER *layer
int mode
Overloading inherited method of class 9.1.3.15 Item. Additional a layer could have the fill-mode MENU_MOUSE_POS. Using this mode the layer will pop-up relatively to the actual mouse position, if the layer is added to the manager.
   GRAPE(layer, "set-pref-pos")(px, py)
LAYER *layer
double px, py
Overloading inherited method of class 9.1.3.15 item. This is the position of the lower left corner of the layer in absolute coordinates of the ControlDevice.
   GRAPE(layer, "show")()
LAYER *layer
Will add the layer to the manager and add it, if necessary, to the dependency list of the item, the layer depends on again. This method is the inverse method to hide.


next up previous contents index
Next: Manager Up: Classes and Methods Previous: Item

SFB 256 Universität Bonn and IAM Universität Freiburg

Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.