[Classes] [Prev] [Next] [Methods]

CSketchPad

Methods Index

Heritage
Description
Usage
Environment
Enums
Protected Data Members
Public Methods
Constructor, Destructor, and Initializer Methods
Sketch Event Methods
Inherited Utilities

CSketchPad


Heritage

Superclass: CSubview

Subclasses: None


Description

CSketchPad is a class that allows you to designate an area on the computer screen as a sketching area. A CSketchPad object is an area inside a CView that makes it easy to "draw" other subviews. The user can drag the mouse within this area, press the mouse button, and move the mouse to drag out a certain shape-a rectangle or line. This class is useful for building drawing programs.


Usage

To drag areas inside the sketchpad, the user presses and holds down the mouse button while dragging the mouse. Upon receiving a MouseUp event, the sketchpad generates a DoCommand message. Usually you should call the GetSketchedRegion or GetSketchPoint methods upon receiving the sketchpad's DoCommand message (these methods return valid values only during DoCommand message handling).

Use the sketchpad as an enclosure for all other views in the sketchable region. You can call the SetSketchEverywhere method either to restrict sketching to the empty area of the sketchpad or to enable sketching over the views nested inside as well as over the empty area.


Environment

The border of the sketchpad is drawn with the pen, and its interior is painted with the brush. You can set the color and pattern of both the pen and the brush. Also, you can set the pen style and width.

See Also: For more information on environmental attributes, see CBrush, CPen, and CEnvironment.


Enums

SKETCHTYPE

RECTANGLE
LINE


Protected Data Members

CSketchFrame* itsSketchFrame; The wire frame to draw
BOOLEAN itIsReady; Whether there is an active wire frame
SKETCHTYPE itsSketchType; The type of sketch drawn
BOOLEAN itIsSketchEverywhere; Sketch over nested views


Public Methods

Constructor, Destructor, and Initializer Methods

CSketchPad(CSubview *theEnclosure, 
const CRect& theRegion);
CSketchPad(const CSketchPad& theSketchPad);
CSketchPad& operator=(const CSketchPad& theSketchPad);
virtual ~CSketchPad(void);
BOOLEAN ISketchPad(SKETCHTYPE theType	= RECTANGLE,
BOOLEAN isVisible = TRUE,
long theGlue = NULLSTICKY);

Sketch Event Methods

When you drag out a shape on the sketchpad, as soon as you release the mouse button, the shape disappears and a DoCommand is generated. Your application should react to the command by calling one of the three sketch event methods described here. Note that these methods can only be called as a response to a CSketchPad DoCommand. Calling them at any other time results in inaccurate return values. All of these methods return coordinates that are relative to the sketchpad.

virtual CRect GetSketchedRegion() const;
virtual CPoint GetStartPoint(void) const;
virtual CPoint GetEndPoint() const;
virtual void GetPoints(CPoint *&aPntAry, int &aNumPoints);
virtual void SetSketchType(
SKETCHTYPE theType = RECTANGLE);
virtual SKETCHTYPE GetSketchType(void) const;
virtual void SetSketchEverywhere(
BOOLEAN isSketchEverywhere);
virtual BOOLEAN IsSketchEverywhere(void);

Inherited Utilities

CSketchPad overrides two mouse methods to implement the dragging out of a shape. Mouse events are passed directly to the view at the location where the event occurs. Each of the following methods has a theButton argument that specifies which mouse button is used and can have the values 0 (left), 1 (middle), or 2 (right). By default, neither the Shift key nor the Control key is used in conjunction with the mouse button.

virtual void MouseDown(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
virtual void MouseUp(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
virtual CView* FindEventTarget(
const CPoint& theLocation) const;
virtual void Draw(const CRect& theClippingRegion);
virtual void Enable(void);
virtual void Disable(void);


[Classes] [Prev] [Next] [Methods]

support@xvt.com


Visit our online help desk for tech support

Copyright © 2009, Providence Software Solutions Inc. All rights reserved.