Chapter Contents |
Previous |
Next |
SAS/AF Software: Class Dictionary |
These are the basic application development steps for creating a simple work area:
Drag and Drop and the Work Area |
Drag-and-drop functionality, which has been added to the Widget class as a whole, is particularly useful for the Work Area class. Drag and drop allows you to define additional functionality for objects so that you can use a mouse to pick up an object from your work area and drag it over to another object on your work area and have an action occur when you drop it. For example, your work area might contain an item called View that runs the FSVIEW command when you drag a dataset (also a work area item) and drop it on that item.
The Work Area class automatically sets each item to be a drag site of type _afWORKAREA. The _afWORKAREA representation is an SCL list that contains the result of the _getProperties method (see the Widget class) and includes all instance variables and the region definition. It provides the work area with enough information to re-create the object if it is copied or moved to a different window. As a result, you can move or copy a work area item to a different work area in either the same frame or a different frame. In this case, the object is destroyed and re-created.
You can also move or copy a work area item within the same work area. This action uses a different work area representation named _afWORKAREA plus a unique numeric suffix. This representation allows the workarea to simply move the item instead of destroying and re-creating it.
For more information on drag and drop, see SAS/AF online help.
Example: Defining Drag and Drop by Subclassing |
For an example that defines drag sites and drop sites using per-instance methods (instead of subclassing) see SAS/AF online help.
A desk is defined, generally, as a place to do work. Part of your desk may include file drawers, note pads, calculators, ledgers, etc. The arrangement and contents of the things on your desk are decided by you and not by anyone else. The Work Area Class provides an area where you can place any function you can think of, from commands to applications, from calendars to datasets.
... Or, you may have placed a Graphics Object to plot how the stock market is doing. You may have several stocks that you want to plot. You could drag the stock over the Graphic object and drop it to plot that stock. Also, just like the top of your desk, if you leave the frame containing the work area object and come back to it later, it will be in the same state as when you left it.
button: /* Create the main list and a */ /* sublist */ l = makelist(); /* Create a sublist for class */ /* information */ l1 = makelist(); /* Fill the sublist with the class */ /* of the item*/ rc = setnitemc(l1, "GTEXT.GTEXT", "_classname"); /* Add the class sublist to the main */ /* list */ rc = insertl(l, l1, 1); /* Create a sublist for position */ /* information */ r = makelist(); /* Add the region sublist to the */ /* main list */ rc = setniteml(l1, r, "_region"); /* Specify the coordinates for the */ /* upper left corner of the item */ rc = setnitemd(r, 1, "ULX"); rc = setnitemd(r, 1, "ULY"); /* Does this do anything other */ /* than print list contents?? */ putlist(l); /* Add the button to the work area */ /* WORK1 */ call notify("work1", "_newItem", l); /* Delete the list */ dellist(l); return;
Example: Adding Highlighting to a Work Area |
The following example shows how to add highlighting to a work area. Two methods are overridden in this example. The first is the _selectItem method. It is used to highlight the selected item and unhighlight any previously selected items. The second method is the _select method. This method is used to unhighlight any previously selected items.
length _self_ 8; /* _selectItem method. Turns on */ /* outlines of all selected items */ /* Turns off outlines of previous */ /* selection */ selitem: method ids 8 action $ 8; l = makelist(); /* Get the list of currently */ /* selected items and turn off their */ /* current selection colors */ call send(_SELF_, "_getSelections", l); do i=1 to listlen(l); l1 = getiteml(l, i); call send(l1, "_setSelection", "OFF", "BLACK"); end; /* Let the sworkarea know about the */ /* selected items */ call super(_SELF_, "_selectItem", ids, action); /* Get the list of currently selected */ /* items and turn on their */ /* current selection colors */ call send(_SELF_, "_getSelections", l); do i=1 to listlen(l); l1 = getiteml(l, i); call send(l1, "_setSelection", "ON", "WHITE"); end; rc = dellist(l); if (rc ^= 0) then do; put "Error removing temporary list during _selectItem"; _msg="Error removing temporary list during _selectItem"; end; endmethod; /* Select method to turn off outlines */ select: method; l = makelist(); /* Send the select item method and */ /* only have this item selected */ call send(_self_, "_selectItem", l, "REPLACE"); rc = dellist(l); if (rc ^= 0) then do; put "Error removing temporary list during _select"; _msg="Error removing temporary list during _select"; end; endmethod;
Work Area Run-time Menus |
The user creates and modifies work area items at run time by selecting items from pop-up menus.
Note: Objects placed on
the work area in the Build environment are not work area items. As a result, run-time menus do not affect them, and you cannot perform actions such as growing, resizing, editing, deleting, or
scrolling.
The pop-up menu in the work area region displays these choices:
Add Item
Modify Resource
Turn Growing On/Off
Add Item
and
Copy
are grayed. This selection runs the _growMode method.Auto Arrange
Adjust Arrangement
Disallow dragging
Allow dragging
Disallow dragging
is selected, the mouse button provides an alternate function (usually marking or pasting).You can use the _popup method to add or delete items in
this menu.
If you pop-up on a newly created item in the work area, the menu displays these choices:
Attributes
Region Attributes
Remove
Copy
Move
Additional choices may be available depending on the class of the item. You can use the _childPopup method to add or delete items in this menu.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.