Home |
Obtaining a Pointer to PegPresentationManager Determining the Position of an Object Overriding the Message() Method Viewports |
ViewportsViewports are used to improve drawing efficiency and to allow background drawing operations to occur without overwriting foreground graphics. Viewports are rectangular areas of the screen owned by the object visible in that rectangle. Each viewport has only one owner, while one object may own several viewports. RTPEG-32 maintains the screen viewports, and you do not ordinarily have to concern yourself with how they work. There is one exception, however, that you may need to be aware of. Normally, only PegWindow derived objects have viewport status. That means that other smaller objects like PegButton and PegIcon do not own viewports, and simply inherit the viewport(s) of their parent window. The viewport management algorithm employed does not allow breaks in the viewport tree. That is, an object that owns viewports (i.e. a PegWindow derived object) should only be added to another object that owns viewports. This does not mean that you cannot add PegWindow derived objects to objects that are not derived from PegWindow, because you can. However, when you do this you should set the PSF_VIEWPORT status flag of the parent object, to make it a viewport owner. An example should clarify this concept. Suppose you want to create a simple object container class. This container class will simply serve as a parent for a group of lists, windows, and other controls. This is a common thing to do, as it allows you to add and remove the entire group of objects at any time simply by adding or removing the container. Since the container class does not need to actually draw anything, you decide to derive it from PegThing, the most basic class. Since at least some of the children of the PegThing container are PegWindow derived objects, you will need to make the PegThing container class a viewport owner. If you don't do this, the PegWindow derived children of the container class won't show up on the screen. You can make the PegThing container class a viewport owner simply by adding the PSF_VIEWPORT system status in the container class constructor: AddStatus(PSF_VIEWPORT); Now your container class will work correctly, and both PegWindow derived children and simple children will be displayed when the parent container class is displayed.
|