OpZoomDescriptor Class Reference

Base class to the two zoom tool OpDescriptors, OpZoomComboDescriptor and OpZoomButtonDescriptor. Simplifies the parameters required by a constructor call, and provides default GetState and message handlers. More...

#include <zoomops.h>

Inheritance diagram for OpZoomDescriptor:

OpDescriptor MessageHandler ListItem CCObject SimpleCCObject OpZoomComboDescriptor OpZoomFitDrawingDescriptor OpZoomFitRectDescriptor OpZoomFitSelectedDescriptor OpZoomFitSpreadDescriptor OpZoomPrevZoomDescriptor List of all members.

Public Member Functions

 OpZoomDescriptor (const TCHAR *pcszToken, UINT32 wStatusID, UINT32 wHelpID, UINT32 wBubbleID, UINT32 resourceID=0, UINT32 controlID=0)
 Constructs the base class of the OpZoom's OpDescriptors.
virtual MsgResult Message (Msg *pMsg)
 Default message despatcher for OpZoomDescriptor derivatives. Passes button messages to HandleButtonMsg (virtual).
virtual BOOL IsAvailable ()
 Default "GetState"-like function for OpZoomDescriptor derivatives.
virtual BOOL DoZoom (OpZoom *pZoomOp)
 Is the base zoom descriptor class function for performing a zoom operation. It does this by calling (virtual) GetSpread to find the spread to zoom in on, then (virtual) GetRect to find the rectangle within the spread. The (virtual) function AdjustRect is called to modify the resultant rectangle. Derived classes can override these functions to customise the effects of particular zoom operation. Performs the zoom, after saving the current zoom settings, then updates the zoom combo box. Similar button to HandleButtonMsg but is designed to be called by the Do() operator in OpZoom and hence from keyboard short-cuts or menu operations.

Static Public Member Functions

static void FakeInvoke (TCHAR *pszToken)
 "Fakes" a button message for OpDescriptor classes derived from OpZoomDescriptor. Searches for the OpDescriptor associated with the specified token. If it finds it then casts it to an OpZoomDescriptor*, checks if the associated button isn't greyed, and if not, calls its HandleButtonMsg function. Finally it makes sure that the percentage scale factor of the selected DocView is updated in the zoom combo box.
static void FakeZoomToRect (const DocRect &rect)
 "Fakes" a button message for the ZoomRect OpDescriptor, using the specified, rectangle.

Protected Member Functions

virtual SpreadGetSpread (DocView *pDocView) const
 Gets a spread given a DocView.
virtual DocRect GetRect (Spread *pSpread)
 Gets a rectangle given a spread.
virtual void AdjustRect (DocRect *pRect) const
 In the base class version inflates the given document rectangle by 5% in each direction.
virtual MsgResult HandleButtonMsg (DialogOp *popdlgThis, CGadgetID gidThis)
 Handles a button click message, by calling (virtual) GetSpread to find the spread to zoom in on, then (virtual) GetRect to find the rectangle within the spread. The (virtual) function AdjustRect is called to modify the resultant rectangle. Derived classes can override these functions to customise the effects of particular buttons. Performs the zoom, after saving the current zoom settings, then updates the zoom combo box.

Static Protected Member Functions

static OpState GetState (String_256 *psName, OpDescriptor *popdCandidate)
 Returns the state that this zoom operation should appear in the menus or as a buttom, for example - greyed out, or ticked.

Detailed Description

Base class to the two zoom tool OpDescriptors, OpZoomComboDescriptor and OpZoomButtonDescriptor. Simplifies the parameters required by a constructor call, and provides default GetState and message handlers.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/5/93

Definition at line 415 of file zoomops.h.


Constructor & Destructor Documentation

OpZoomDescriptor::OpZoomDescriptor const TCHAR pcszToken,
UINT32  wStatusID,
UINT32  wHelpID,
UINT32  wBubbleID,
UINT32  resourceID = 0,
UINT32  controlID = 0
 

Constructs the base class of the OpZoom's OpDescriptors.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/94
Parameters:
pcszToken the "token" (OLE verb?) of the associated Operation [INPUTS] wStatusID string resource ID of status-bar text wHelpID string ID of help text/jump (?) wBubbleID string ID of bubble-help text
- [OUTPUTS]
Returns:
-

Errors: -

See also:
class OpZoomFitSpreadDescriptor; class OpZoomFitDrawingDescriptor; class OpZoomFitSelectedDescriptor; class OpZoomPrevZoomDescriptor

Definition at line 1597 of file zoomops.cpp.

01599   : OpDescriptor(0,                                 // tool ID
01600                  wStatusID,                         // string ID of text in status bar
01601                  CC_RUNTIME_CLASS(OpZoom),
01602                  (TCHAR*) pcszToken,
01603                  GetState,
01604                  wHelpID,                           // help link ID
01605                  wBubbleID,                         // bubble help string ID
01606                  resourceID,
01607                  controlID,
01608                  TRUE)                              // wants to receive messages
01609 {
01610     // Empty.
01611 }


Member Function Documentation

void OpZoomDescriptor::AdjustRect DocRect pRect  )  const [protected, virtual]
 

In the base class version inflates the given document rectangle by 5% in each direction.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/5/94
Parameters:
pRect pointer to a DocRect to adjust [INPUTS]
The adjusted DocRect. [OUTPUTS]
Returns:
-

Errors: -

See also:
OpZoomDescriptor::HandleButtonMsg; OpZoomDescriptor::GetRect

Reimplemented in OpZoomFitSpreadDescriptor, and OpZoomFitSelectedDescriptor.

Definition at line 1884 of file zoomops.cpp.

01885 {
01886     INT32 xinc = pRect->Width() / 20;           // find 5% of the width and height
01887     INT32 yinc = pRect->Height() / 20;
01888     if (xinc < 1) xinc = 1;                     // make sure we inflate by some amount
01889     if (yinc < 1) yinc = 1;
01890     pRect->lo.x -= xinc;                        // inflate the given rectangle
01891     pRect->lo.y -= yinc;
01892     pRect->hi.x += xinc;
01893     pRect->hi.y += yinc;
01894 }

BOOL OpZoomDescriptor::DoZoom OpZoom pZoomOp  )  [virtual]
 

Is the base zoom descriptor class function for performing a zoom operation. It does this by calling (virtual) GetSpread to find the spread to zoom in on, then (virtual) GetRect to find the rectangle within the spread. The (virtual) function AdjustRect is called to modify the resultant rectangle. Derived classes can override these functions to customise the effects of particular zoom operation. Performs the zoom, after saving the current zoom settings, then updates the zoom combo box. Similar button to HandleButtonMsg but is designed to be called by the Do() operator in OpZoom and hence from keyboard short-cuts or menu operations.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/9/95
Parameters:
pZoomOp pointer to the OpZoom to be used [INPUTS]
Returns:
True if operation has happened correctly

Errors: -

See also:
OpZoom::Do; OpZoomDescriptor::GetSpread; OpZoomDescriptor::GetRect; OpZoomDescriptor::AdjustRect

Reimplemented in OpZoomPrevZoomDescriptor.

Definition at line 1761 of file zoomops.cpp.

01762 {
01763     ERROR2IF(pZoomOp == 0, FALSE, "OpZoomDescriptor::DoZoom called with no operation");
01764 
01765     // Get the current view.
01766     DocView* pDocView = DocView::GetCurrent();
01767     ERROR3IF(pDocView == 0, "No current DocView in OpZoomDescriptor::HandleButtonMsg");
01768     if (pDocView == 0)
01769         return FAIL;
01770         
01771     // Find the relevant spread, if any.
01772     Spread* pSpread = GetSpread(pDocView);
01773     ERROR3IF(pSpread == 0, "No relevant spread - can't do zoom\n");
01774     if (pSpread == 0)
01775         return FAIL;
01776 
01777     // Find the relevant zoom rectangle.
01778     DocRect drBounds = GetRect(pSpread);
01779     ERROR3IF(drBounds.IsEmpty(), "Relevant rectangle is empty - can't do zoom\n");
01780 
01781     // Allow derived class to adjust the document rectangle if it so desires.
01782     AdjustRect(&drBounds);
01783 
01784     // Do the zoom, the scaling factor of which will not appear in the zoom op's table.
01785     pZoomOp->ZoomInOnRect(pSpread, drBounds);
01786 
01787     return TRUE;    
01788 }

void OpZoomDescriptor::FakeInvoke TCHAR pszToken  )  [static]
 

"Fakes" a button message for OpDescriptor classes derived from OpZoomDescriptor. Searches for the OpDescriptor associated with the specified token. If it finds it then casts it to an OpZoomDescriptor*, checks if the associated button isn't greyed, and if not, calls its HandleButtonMsg function. Finally it makes sure that the percentage scale factor of the selected DocView is updated in the zoom combo box.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/7/94
Parameters:
pszToken --- pointer to the "invoked" OpDescriptor's token [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
OpZoomComboDescriptor::OnSelectionChanged

Definition at line 1916 of file zoomops.cpp.

01917 {
01918     // Try to find the OpDescriptor.
01919     OpZoomDescriptor* pZoomOpDesc = (OpZoomDescriptor*) FindOpDescriptor(pszToken);
01920     
01921     // If that worked then call its button handler.
01922     if (pZoomOpDesc != 0 && pZoomOpDesc->IsAvailable())
01923     {
01924         pZoomOpDesc->HandleButtonMsg(0, 0);
01925     }
01926 #ifndef RALPH
01927     else
01928     {
01929         // If it didn't then refresh the zoom combo with some percentages.
01930 //      Beep();
01931         wxBell();
01932         OpZoomComboDescriptor::Update();
01933     }
01934 #endif
01935 }

void OpZoomDescriptor::FakeZoomToRect const DocRect rect  )  [static]
 

"Fakes" a button message for the ZoomRect OpDescriptor, using the specified, rectangle.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/9/96
Parameters:
pRect,pointer to a rect to zoom to [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

Definition at line 1952 of file zoomops.cpp.

01953 {
01954     // Try to find the OpDescriptor.
01955     OpZoomDescriptor* pZoomOpDesc = (OpZoomDescriptor*) FindOpDescriptor(OPTOKEN_ZOOMRECT);
01956     
01957     // If that worked then call its button handler.
01958     if (pZoomOpDesc != 0)
01959     {
01960         ((OpZoomFitRectDescriptor*) pZoomOpDesc)->SetZoomRect(rect);
01961         pZoomOpDesc->HandleButtonMsg(0, 0);
01962     }
01963 }

DocRect OpZoomDescriptor::GetRect Spread pSpread  )  [protected, virtual]
 

Gets a rectangle given a spread.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/94
Parameters:
pSpread the spread to zoom in on [INPUTS]
- [OUTPUTS]
Returns:
A rectangle within the spread to zoom in on. By default this is the "bounding rectangle" of the given spread.

Errors: -

See also:
OpZoomDescriptor::HandleButtonMsg; Spread::GetBoundingRect

Reimplemented in OpZoomFitSpreadDescriptor, OpZoomFitDrawingDescriptor, OpZoomFitSelectedDescriptor, and OpZoomFitRectDescriptor.

Definition at line 1863 of file zoomops.cpp.

01864 {
01865     return pSpread->GetBoundingRect();
01866 }

Spread * OpZoomDescriptor::GetSpread DocView pDocView  )  const [protected, virtual]
 

Gets a spread given a DocView.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/94
Parameters:
pDocView the DocView containing the spread. [INPUTS]
- [OUTPUTS]
Returns:
A pointer to the relevant spread to zoom in on. By default this is the document page, ie. the first spread in the document.

Errors: -

See also:
OpZoomDescriptor::HandleButtonMsg; View::GetDoc; Document::FindFirstSpread

Reimplemented in OpZoomFitSelectedDescriptor.

Definition at line 1841 of file zoomops.cpp.

01842 {
01843 PORTNOTE("spread", "Multi-spread warning!")
01844     return pDocView->GetDoc()->FindFirstSpread();
01845 }

OpState OpZoomDescriptor::GetState String_256 psName,
OpDescriptor pOpDesc
[static, protected]
 

Returns the state that this zoom operation should appear in the menus or as a buttom, for example - greyed out, or ticked.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/4/95
Parameters:
pDesc --- A pointer to a String. GetState fills this with the [INPUTS] appropriate details for the conditions arising eg. why "Previous Zoom" is greyed out. pOpDesc --- A pointer to the OpDescriptor whose state is being queried.
Returns:
An OpState containing the flags that show what is valid.
See also:
OpZoomDescriptor::IsAvailable

Definition at line 1631 of file zoomops.cpp.

01632 {
01633     BOOL fCanDo = ((OpZoomDescriptor*) pOpDesc)->IsAvailable();
01634 /*  TRACEUSER( "JustinF", _T("OpZoomDescriptor::GetState for %-12s (0x%lX) - %-8s at %lu ms\n"),
01635                             (LPCTSTR)   pOpDesc->Token,
01636                             (UINT32)        pOpDesc,
01637                             (LPCTSTR)   (fCanDo ? TEXT("OK") : TEXT("Greyed")),
01638                             (UINT32)        ::GetTickCount());
01639 */  return OpState(FALSE, !fCanDo);
01640 }

MsgResult OpZoomDescriptor::HandleButtonMsg DialogOp popdlgThis,
CGadgetID  gidThis
[protected, virtual]
 

Handles a button click message, by calling (virtual) GetSpread to find the spread to zoom in on, then (virtual) GetRect to find the rectangle within the spread. The (virtual) function AdjustRect is called to modify the resultant rectangle. Derived classes can override these functions to customise the effects of particular buttons. Performs the zoom, after saving the current zoom settings, then updates the zoom combo box.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/94
Parameters:
pdlgop pointer to the dialog operation ("unpacked" from a message) [INPUTS] gid the gadget ID associated with this OpDescriptor
- [OUTPUTS]
Returns:
The message result code (either EAT_MSG or OK)

Errors: -

See also:
OpZoomDescriptor::GetSpread; OpZoomDescriptor::GetRect; OpZoomDescriptor::AdjustRect

Reimplemented in OpZoomPrevZoomDescriptor.

Definition at line 1812 of file zoomops.cpp.

01813 {
01814     // Try to create an instance of the zoom operation.
01815     OpZoom* pZoomOp = new OpZoom;
01816     ERRORIF(pZoomOp == 0, _R(IDE_NOMORE_MEMORY), FAIL);
01817 
01818     // Do the zoom, the scaling factor of which will not appear in the zoom op's table.
01819     // DoZoom will End the operation
01820     BOOL ok = DoZoom(pZoomOp);
01821     if (!ok) return FAIL;
01822     return OK;
01823 }

BOOL OpZoomDescriptor::IsAvailable  )  [virtual]
 

Default "GetState"-like function for OpZoomDescriptor derivatives.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the Operation is available. By default this returns TRUE if there is a "selected" document, a spread, and a rectangle to zoom in on.

Errors: -

See also:
OpZoom::GetState; DocView::GetSelected; OpState::OpState; OpZoomDescriptor::GetSpread; OpZoomDescriptor::GetRect

Reimplemented in OpZoomPrevZoomDescriptor, and OpZoomComboDescriptor.

Definition at line 1659 of file zoomops.cpp.

01660 {
01661     // Try to get the "selected" view.
01662     DocView* pDocView = DocView::GetCurrent();
01663     if (pDocView == 0)
01664     {
01665 //      TRACEUSER( "JustinF", _T("\tNo current DocView in OpZoomDescriptor::IsAvailable\n"));
01666         return FALSE;
01667     }
01668 
01669     // Find the relevant spread, if any.
01670     Spread* pSpread = GetSpread(pDocView);
01671     if (pSpread == 0)
01672     {
01673 //      TRACEUSER( "JustinF", _T("\tNo relevant spread in OpZoomDescriptor::IsAvailable\n"));
01674         return FALSE;
01675     }
01676 
01677     DocRect ZoomRect = GetRect(pSpread);
01678     BOOL Empty = ZoomRect.IsEmpty();
01679 #ifdef _DEBUG
01680     // Is there actually no relevant rectangle within the spread to zoom on?
01681     if (Empty)
01682     {
01683 //      TRACEUSER( "JustinF", _T("\tEmpty rectangle in OpZoomDescriptor::IsAvailable\n"));
01684     }                                                                                 
01685 #endif
01686 
01687     // Find the relevant zoom rectangle, if any.
01688     return !Empty;
01689 }

MsgResult OpZoomDescriptor::Message Msg pMsg  )  [virtual]
 

Default message despatcher for OpZoomDescriptor derivatives. Passes button messages to HandleButtonMsg (virtual).

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
OpZoomDescriptor::HandleButtonMsg

Reimplemented from OpDescriptor.

Reimplemented in OpZoomComboDescriptor.

Definition at line 1707 of file zoomops.cpp.

01708 {
01709     // Check if the message is an OpDesc message.
01710     if (!MESSAGE_IS_A(pMsg, OpDescMsg)) return OK;
01711     
01712     // Cast it into the correct type etc.
01713     OpDescMsg* pOpDescMsg = (OpDescMsg*) pMsg;
01714     
01715     // Process the message . . .
01716     if (pOpDescMsg->OpDesc == this && MESSAGE_IS_A(pOpDescMsg, OpDescControlMsg))
01717     {
01718         // Cast to a control message, unpack, and despatch to the handler.
01719         OpDescControlMsg* pControlMsg = (OpDescControlMsg*) pOpDescMsg;
01720         if (pControlMsg->DlgMsg == DIM_LFT_BN_CLICKED)
01721         {
01722             if (IsAvailable())
01723                 return HandleButtonMsg(pControlMsg->pDlgOp, pOpDescMsg->SetGadgetID);
01724 #if !defined(EXCLUDE_FROM_RALPH)
01725             else
01726 //              Beep();
01727                 wxBell();
01728 #endif
01729         }
01730     }
01731 
01732     // Let the base class do its stuff on the message.
01733     return OpDescriptor::Message(pMsg);
01734 }


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:59:13 2007 for Camelot by  doxygen 1.4.4