OpGridResize Class Reference

#include <optsgrid.h>

Inheritance diagram for OpGridResize:

UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject OpSpreadOrigin OpResetSpreadOrigin List of all members.

Public Member Functions

 OpGridResize ()
 OpGridResize constructor (Creates an undoable operation).
 ~OpGridResize ()
 OpGridResize destructor.
void Do (OpDescriptor *)
 (Performs the page resizing operation) OpGridResize has a special overloaded Do operator which takes parameters describing what is to be done - that version of Do must be used
void DoWithParam (OpDescriptor *pOp, OpParam *pResizeParam)
 Performs the grid resize operation via DoResizeGrid().

Static Public Member Functions

static BOOL Init ()
 Creates an OpDescriptor for a Page Resize operation.
static OpState GetState (String_256 *, OpDescriptor *)
 Returns the OpState of the OpGridResize dialogue operation.

Protected Member Functions

BOOL DoResizeGrid (GridResizeInfo *pResizeInfo)
 Undoably performs the grid resize operation Forces a redraw of the parent document for the specified spread.

Private Attributes

DocRect PasteboardRect
MILLIPOINT OriginX
MILLIPOINT OriginY

Detailed Description

Definition at line 217 of file optsgrid.h.


Constructor & Destructor Documentation

OpGridResize::OpGridResize  ) 
 

OpGridResize constructor (Creates an undoable operation).

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/10/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
GridTab;

Definition at line 885 of file optsgrid.cpp.

00885                            : UndoableOperation() 
00886 {
00887 }       

OpGridResize::~OpGridResize  ) 
 

OpGridResize destructor.

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

Errors: -

See also:
-

Definition at line 904 of file optsgrid.cpp.

00905 {
00906 }


Member Function Documentation

void OpGridResize::Do OpDescriptor NotUsed  )  [virtual]
 

(Performs the page resizing operation) OpGridResize has a special overloaded Do operator which takes parameters describing what is to be done - that version of Do must be used

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/10/95
Parameters:
OpGridResize (unused) [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: Always generates an ENSURE failure because this Do doesn't.

See also:
-

Reimplemented from Operation.

Reimplemented in OpSpreadOrigin, and OpResetSpreadOrigin.

Definition at line 971 of file optsgrid.cpp.

00972 {
00973     ENSURE(FALSE, "OpGridResize does not provide a Do() function - Use DoWithParam");
00974     End();
00975 }

BOOL OpGridResize::DoResizeGrid GridResizeInfo pInfo  )  [protected]
 

Undoably performs the grid resize operation Forces a redraw of the parent document for the specified spread.

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/10/95
Parameters:
pResizeInfo - info describing how to change grid [INPUTS] note origin is page relative and specified as 2 ordinates - why!
Returns:
FALSE if fails

Definition at line 1011 of file optsgrid.cpp.

01012 {
01013     ERROR2IF(  pInfo==NULL,FALSE,"OpGridResize::DoResizeGrid() - pInfo==NULL");
01014     Spread* pSpread = pInfo->pSpread;
01015     ERROR2IF(pSpread==NULL,FALSE,"OpGridResize::DoResizeGrid() - pSpread==NULL");
01016 
01017     // If the grid is the same as last time then we want to do nothing
01018     // This apparently is signalled by the GridDivisions and GridSubDivisions being 0!
01019     if (pInfo->GridDivisions==0 || pInfo->GridSubDivisions==0)
01020         return TRUE;
01021 
01022     // find the present default grid and read it's settings for the undo action
01023     NodeGrid* pDefaultGrid = pSpread->FindFirstDefaultGridInSpread();
01024     ERROR2IF(pDefaultGrid==NULL,FALSE,"OpGridResize::DoResizeGrid() - pDefaultGrid==NULL");
01025 
01026     double     PresentGridDivisions    = pDefaultGrid->GetDivisions();
01027     UINT32       PresentGridSubDivisions = pDefaultGrid->GetSubdivisions();
01028     UnitType   PresentGridUnits        = pDefaultGrid->GetUnits();
01029     GridType   PresentGridType         = pDefaultGrid->GetGridType();
01030 
01031     DocCoord   PresentOrigin(0,0);
01032     pDefaultGrid->GetOrigin(&PresentOrigin.x, &PresentOrigin.y);
01033     BOOL ok=pSpread->SpreadCoordToPagesCoord(&PresentOrigin,PresentOrigin); // make page relative
01034     if (!ok) return FALSE;
01035 
01036     // Create an action to Undo the resizing operation
01037     ActionSetDefaultGrid *ASDG;
01038     ActionCode SetDefaultGridAction= ActionSetDefaultGrid::Init(this,
01039                                                                 &UndoActions,
01040                                                                 sizeof(ActionSetDefaultGrid),
01041                                                                 pSpread,
01042                                                                 PresentGridDivisions,
01043                                                                 PresentGridSubDivisions,
01044                                                                 PresentGridUnits,
01045                                                                 PresentGridType,
01046                                                                 PresentOrigin.x,
01047                                                                 PresentOrigin.y,
01048                                                                 (Action**)(&ASDG)
01049                                                                 );
01050     ERROR2IF(SetDefaultGridAction==AC_FAIL,FALSE,"OpGridResize::DoResizeGrid() - ActionSetDefaultGrid::Init() failed");
01051 
01052     // Check if we must change grid types, if so, replace it with the correct type
01053     if (PresentGridType!=pInfo->TypeOfGrid)
01054     {
01055         // Create a grid of the new type
01056         NodeGrid* pNewGrid = NULL;
01057         switch (pInfo->TypeOfGrid)
01058         {
01059             case RECTANGULAR : ALLOC_WITH_FAIL(pNewGrid,(new NodeGridRect()),this); break;
01060             case ISOMETRIC   : ALLOC_WITH_FAIL(pNewGrid,(new NodeGridIso()), this); break;
01061             case INVALID_GRID_TYPE: ERROR3("Use of invalid grid type"); break;
01062         }
01063         ERROR2IF(pNewGrid==NULL,FALSE,"OpGridResize::DoResizeGrid() - failed to create new grid");
01064 
01065         // The grid will cover the entire spread pasteboard area
01066         DocRect GridRect = pSpread->GetPasteboardRect(FALSE);
01067         pSpread->DocCoordToSpreadCoord(&GridRect);
01068 
01069         // Attach the new grid as the last child of the specified spread
01070         pNewGrid->AttachNode(pSpread, LASTCHILD); 
01071         pNewGrid->SetDefault(TRUE);                 // Its a default grid
01072         pNewGrid->SetBoundingRect(GridRect);
01073 
01074         // Now replace the old grid with the new one
01075         pDefaultGrid->CascadeDelete();
01076         pDefaultGrid = pNewGrid;
01077     }
01078 
01079     // the grid may have been replaced with a new one so must set up all remaining values
01080     DocCoord Origin(pInfo->OriginX, pInfo->OriginY);
01081     ok = pSpread->PagesCoordToSpreadCoord(&Origin,Origin);  // convert from page relaive to absolute
01082     if (ok) pDefaultGrid->SetOrigin(Origin.x,Origin.y);
01083     if (ok) ok = pDefaultGrid->SetGridParams(pInfo->GridDivisions, pInfo->GridSubDivisions, pInfo->GridUnits);
01084     if (!ok) return FALSE;
01085     
01086     // since grid changed sucessfully, force redraw doc and broadcast message (eg for rulers)
01087     Document* pParentDoc = (Document*)pSpread->FindOwnerDoc();
01088     ERROR2IF(pParentDoc==NULL,FALSE,"OpGridResize::DoResizeGrid() - pParentDoc==NULL");
01089     pParentDoc->ForceRedraw();
01090     BROADCAST_TO_ALL( OptionsChangingMsg(pParentDoc,OptionsChangingMsg::NEWDEFAULTGRID) );
01091 
01092     return TRUE;
01093 }

void OpGridResize::DoWithParam OpDescriptor pOp,
OpParam pResizeInfo
[virtual]
 

Performs the grid resize operation via DoResizeGrid().

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/10/95
Parameters:
pOpDesc - unused [INPUTS] pResizeInfo - points to a Page resize structure with parameters:

Reimplemented from Operation.

Definition at line 989 of file optsgrid.cpp.

00990 {
00991     if (DoResizeGrid((GridResizeInfo*)pResizeInfo)==FALSE)
00992         FailAndExecute();
00993     End();
00994 }

OpState OpGridResize::GetState String_256 pString,
OpDescriptor pOpDesc
[static]
 

Returns the OpState of the OpGridResize dialogue operation.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/10/95
See also:
GridTab;

Reimplemented in OpSpreadOrigin, and OpResetSpreadOrigin.

Definition at line 946 of file optsgrid.cpp.

00947 {
00948     OpState OpSt;
00949 
00950     return(OpSt);
00951 }

BOOL OpGridResize::Init void   )  [static]
 

Creates an OpDescriptor for a Page Resize operation.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/10/95
Returns:
FALSE if it fails (due to lack of memory)
See also:
GridTab;

Reimplemented from SimpleCCObject.

Reimplemented in OpSpreadOrigin, and OpResetSpreadOrigin.

Definition at line 919 of file optsgrid.cpp.

00920 {  
00921     return RegisterOpDescriptor(
00922         0,                              // Tool ID
00923         _R(IDS_OPSETDEFAULTGRID),           // String resource ID
00924         CC_RUNTIME_CLASS(OpGridResize), // Runtime class
00925         OPTOKEN_OPGRIDRESIZE,           // Token string
00926         OpGridResize::GetState,         // GetState function
00927         0,                              // Help ID
00928         0,                              // Bubble ID
00929         0,                              // Resource ID
00930         0                               // Control ID
00931 //  needs   'GREY_WHEN_NO_CURRENT_DOC'
00932     );
00933 }   


Member Data Documentation

MILLIPOINT OpGridResize::OriginX [private]
 

Definition at line 237 of file optsgrid.h.

MILLIPOINT OpGridResize::OriginY [private]
 

Definition at line 238 of file optsgrid.h.

DocRect OpGridResize::PasteboardRect [private]
 

Definition at line 235 of file optsgrid.h.


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