![]() |
![]() |
DiaCanvas2 Reference Manual | ![]() |
---|
Once you have created a DiaCanvas it is likely that you want to display it on the screen. This is done by creating a DiaCanvasView object. The DiaCanvasView is used to interact with the object.
Once you create a DiaCanvasView, a DiaCanvasViewItem is created for every DiaCanvasItem in the DiaCanvas (notice the difference: with or without “View”). The DiaCanvasViewItem objects will render the information found while iterating the DiaShape objects. A view can be either LibArt based (with anti-aliasing) or X based. The X based implementation might work a little faster, but on a not-too-old computer you will hardly notice the difference.
In order to increase usability, the render information used by the view items will be stored. Every view item will have it's own render data of a DiaShape.
Once you have a nice DiaCanvasView on your screen it is likely that you want to interact with it. We can split the user interaction in four parts:
Actions on the item itself.
Actions on the handles of an item.
Actions involving multiple items on the canvas.
View related actions.
Actions on the item are mainly button presses, motion events and button release events. The object should not worry about being selected or not, those kinds of state changes are taken care of by the view. The object should grab the focus if it wants to receive all user actions (this is usually the case when a mouse button is pressed).
Actions on the handles are not handled by the item. A special object (DiaHandleLayer) takes care of the handles. There is one exception: when a handle is moved the handle owner (a DiaCanvasItem) is asked whether or not it is allowed to do a certain motion by calling the DiaCanvasItemClass::handle_motion() callback function.
If a handle is pressed the owner object will get the focus. The DiaHandleLayer does not know about any special action that should take place when a certain key modifier is pressed. For example DiaCanvasElement like objects will rotate when a corner handle is moved and the CONTROL key is pressed and shear when a center handle is moved. This behavior is dictated by the DiaCanvasItem rather than the DiaHandleLayer.
The only case where more than one object is involved is when multiple objects are selected and the objects are moved. It is the DiaCanvasItem that has the focus who initiates the move: by calling dia_canvas_item_move_interactive() all selected objects on the active view are moved.
View related actions consist of selecting objects and deselecting objects. If the SHIFT button is held, no objects will be deselected. Pressing the CONTROL key while selecting objects will toggle the selection.