LGrafPortView is a PowerPlant class that is used as an alternative to LWindow in non-PowerPlant applications.
LGrafPortView can be useful in application frameworks and program extensions such as XCMDs.
Methods :
The methods in this class are:
Data Members:
The data members in this class are:
Operation:
When you create a GrafPortView, you should set the current port
to the Toolbox window (or other valid GrafPort) in which you want
to place the GrafPortView. Then call LGrafPortView::CreateGrafPortView() to create and initialize the GrafPortView from a PPob resource.
Source files:
See also:
Purpose:
LGrafPortView has four constructor methods. The first is the default
contructor. The second constructor is a parameter constructor
that copies inGrafPtr to mGrafPtr and then initializes the view.
The third constructor creates a LGrafPortView object from data
in the SViewInfo structure and sets the pane states. Signals if
mGrafPtr is nil.
The last constructor creates a LGrafPortView object from a stream
(usually from a PPob resource), and sets the pane states. Signals
if mGrafPtr is nil.
Access :
Prototype:
LGrafPortView();
LGrafPortView( GrafPtr inGrafPtr);
LGrafPortView( const SPaneInfo& inPaneInfo,
const SViewInfo &inViewInfo) : LView(inPaneInfo, inViewInfo); LGrafPortView(LStream *inStream):LView(inStream);Parameters:
Return:
No return value for a constructor
Purpose:
The destructor destroys the LGrafPortView object.
Access :
Prototype:
virtual ~LGrafPortView();Parameters:
Return:
No return value for a destructor
Purpose:
Checks the pane state to see if the GrafPortView is off. If so,
sets it on and activates the window. If this Window can contain
the Target, and it is not already OnDuty, restore the Target to what it was when the Window was last active.
Access :
Prototype:
void Activate();Parameters:
Return:
Purpose:
Uses Mac OS toolbox calls to set the foreground and background colors of the current port.
Access :
Prototype:
void ApplyForeAndBackColors() const;Parameters:
Return:
Remarks:
The GrafPortView or one of its SubPanes must already be focused.
Purpose:
Called when the mouse click is in the content part of a GrafPortView
object. If it is enabled, sets up the extended event record, calls
the object's Click method.
Access :
Prototype:
void ClickInContent(
const EventRecord& inMacEvent); Return:
Purpose:
Return a new GrafPortView object initialized from a PPob resource.
Access :
Prototype:
static GrafPortView* CreateGrafPortView(
ResIDT inGrafPortViewID, LCommander* inSuperCommander); Return:
Pointer to a GrafPortView object.
Remarks:
GrafPortView is put inside the current GrafPort.
Purpose:
Deactivates a GrafPortView object, and, if it was OnDuty, switches the Target to the SuperCommander.
Access :
Prototype:
virtual void Deactivate();Parameters:
Return:
Purpose:
Handle a Command for a GrafPortView by getting the target and passing the command to it.
Access :
Prototype:
void DispatchCommand(
CommandT inCommand, void* ioParam); Return:
Purpose:
Saves the port state and sends a message to the periodical handler to idle.
Access :
Prototype:
void DoIdle(
const EventRecord& inMacEvent); Return:
Purpose:
Called when the GrafPortView gets a KeyDown event. If the LCommander's sTarget data member indicates that this object is the target, process
the event.
Access :
Prototype:
void DoKeyPress(
const EventRecord& inMacEvent); Return:
Purpose:
Draw a GrafPortView using LView::Draw(). inSuperDrawRgnH specifies, in port coordinates, the portion of the View's SuperView
that needs to be drawn. Specify nil to draw the entire view.
Access :
Prototype:
void Draw(
RgnHandle inSuperDrawRgnH); Return:
Remarks:
Overrides LPane::Draw() to deal with special non-window condition
and then cycle through Subpanes. Rather than overriding this,
you should override LGrafPortView::DrawSelf(), and get called from here.
Purpose:
Draws the contents of the GrafPortView object. Currently erases the frame as well.
Access :
Prototype:
virtual void DrawSelf();Parameters:
Return:
Purpose:
Make GrafPortView the current Port.
Access :
Prototype:
Boolean EstablishPort();Parameters:
Return:
Remarks:
If you call this function directly, you should call LView::OutOfFocus(nil), since changing the current port may invalidate the Focus.
Purpose:
Return the Toolbox GrafPort associated with a LGrafPortView.
Access :
Prototype:
GrafPtr GetMacPort() const;Parameters:
Return:
Purpose:
Private initializer. Initialize the GrafPortView, assuming that
mGrafPtr is already initialized, set the pane states, and initialize all
mForeColor fields to black and all mBackColor fields to white.
Access :
Prototype:
void InitGrafPortView();Parameters:
Return:
Purpose:
Make the Mac OS Toolbox issue an update event, which will initiate a redraw of the rectangle.
Access :
Prototype:
void InvalPortRect(
const Rect *inRect); Return:
Remarks:
Use this instead of the Mac OS Toolbox routine InvalRect() (see Pane validation for more information).
Purpose:
Access :
Prototype:
virtual void InvalPortRgn(
RgnHandle inRgnH); Return:
Remarks:
Use this instead of the Mac OS Toolbox routine InvalRgn() (see Pane validation for more information).
Purpose:
Sprecify the foreground and/or background colors of a GrafPortView.
Access :
Prototype:
void SetForeAndBackColors(
const RGBColor *inForeColor, const RGBColor *inBackColor); Return:
Remarks:
Specify nil for inForeColor and/or inBackColor to leave that color trait
unchanged.
Purpose:
Redraw invalidated area of the GrafPortView.
Access :
Prototype:
void UpdatePort();Parameters:
Return:
Purpose:
Tells the Mac OS Toolbox that the selected rectangle does not need to be redrawn.
Access :
Prototype:
void ValidPortRect(
const Rect *inRect); Return:
Remarks:
Use intead of the Mac OS Toolbox routine InvalRect() (see Pane validation for more information).
Purpose:
Tells the Mac OS Toolbox that the selected region does not need to be redrawn.
Access :
Prototype:
void ValidPortRgn(
RgnHandle inRgnH); Return:
Remarks:
Use intead of the Mac OS Toolbox routine InvalRgn() (see Pane validation for more information).
Purpose:
Maintains a pointer to the current GrafPort.
Access :
Prototype:
GrafPtr mGrafPtr;
Purpose:
Maintains the current foregrounc color setting.
Access :
Prototype:
RGBColor mForeColor;
Purpose:
Maintains the current background color setting.
Access :
Prototype:
RGBColor mBackColor;