OpSpreadOrigin Class Reference

Allows you to drag the origin to another place. More...

#include <guides.h>

Inheritance diagram for OpSpreadOrigin:

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

Public Member Functions

 OpSpreadOrigin ()
 Default constructor.
 ~OpSpreadOrigin ()
 Default destructor.
virtual void Do (OpDescriptor *pOpDesc)
 This func starts a drag that will end up setting the spread origin.
virtual void DragPointerMove (DocCoord PointerPos, ClickModifiers ClickMods, Spread *, BOOL bSolidDrag)
 Responds to a mouse move during a drag of the origin.
virtual void DragFinished (DocCoord PointerPos, ClickModifiers ClickMods, Spread *, BOOL Success, BOOL bSolidDrag)
 Responds to the drag of a guideline ending.
void RenderMyDragBlobs ()
 Renders the blobs associated with the current drag.
void RenderDragBlobs (DocRect Rect, Spread *pSpread, BOOL bSolidDrag)
 Main routine for rendering the blobs associated with the current drag. This can be called from anywhere, e.g. when the view scrolls.

Static Public Member Functions

static BOOL Init ()
 Registers an op desc for this op.
static OpState GetState (String_256 *Description, OpDescriptor *)
 Func for determining the usability of this op.

Protected Member Functions

void DoDrag (Spread *pSpread, DocCoord PointerPos)
 Starts a drag for the origin.
BOOL DoChangeOrigin (Spread *pSpread, DocCoord NewOrigin)
 Undoably set a new grid/user origin.

Private Member Functions

 CC_DECLARE_DYNCREATE (OpSpreadOrigin)

Private Attributes

SpreadpSpread
DocCoord CurrentOrigin
BOOL RenderOn

Detailed Description

Allows you to drag the origin to another place.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/95

Definition at line 439 of file guides.h.


Constructor & Destructor Documentation

OpSpreadOrigin::OpSpreadOrigin  ) 
 

Default constructor.

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

Errors: -

See also:
-

Definition at line 2841 of file guides.cpp.

02842 {
02843     RenderOn = TRUE;
02844 }

OpSpreadOrigin::~OpSpreadOrigin  ) 
 

Default destructor.

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

Errors: -

See also:
-

Definition at line 2861 of file guides.cpp.

02862 {
02863 }


Member Function Documentation

OpSpreadOrigin::CC_DECLARE_DYNCREATE OpSpreadOrigin   )  [private]
 

void OpSpreadOrigin::Do OpDescriptor pOpDesc  )  [virtual]
 

This func starts a drag that will end up setting the spread origin.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/95
Parameters:
pOpDesc = ptr op desc [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
DoAddNewGuideline(), OilRuler::OnLButtonDown()

Reimplemented from OpGridResize.

Reimplemented in OpResetSpreadOrigin.

Definition at line 2879 of file guides.cpp.

02880 {
02881     DocCoord StartPos(-5000,-5000);
02882 
02883     DoDrag(NULL,StartPos);
02884 }

BOOL OpSpreadOrigin::DoChangeOrigin Spread pSpread,
DocCoord  NewOrigin
[protected]
 

Undoably set a new grid/user origin.

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/10/95
Parameters:
pSpread = ptr to spread [INPUTS] NewOrigin = new origin for the spread
Returns:
FALSE if fails

Definition at line 3012 of file guides.cpp.

03013 {
03014     ERROR2IF(pSpread==NULL,FALSE,"OpSpreadOrigin::DoChangeOrigin() - pSpread==NULL");
03015 
03016     NodeGrid* pDefaultGrid = pSpread->FindFirstDefaultGridInSpread();
03017     ERROR2IF(pDefaultGrid==NULL,FALSE,"OpSpreadOrigin::DoChangeOrigin() - FindFirstDefaultGrid() failed");
03018 
03019     // if no change in origin, just return without inserting an op
03020     MILLIPOINT x,y;
03021     pDefaultGrid->GetOrigin(&x,&y);     // call me stupid but couldn't this return a DocCoord!
03022     if (DocCoord(x,y)==NewOrigin)
03023         return TRUE;
03024 
03025     // cunningly (NOT) OpGridResize expects the origin to be page relative!
03026     DocCoord NewPageRelativeOrigin;
03027     pSpread->SpreadCoordToPagesCoord(&NewPageRelativeOrigin,NewOrigin);
03028 
03029     // Force the origin to snap to a pixel boundary.
03030     NewPageRelativeOrigin.x = ((NewPageRelativeOrigin.x + 375) / 750) * 750;
03031     NewPageRelativeOrigin.y = ((NewPageRelativeOrigin.y + 375) / 750) * 750;
03032 
03033     // set up a complete set of grid params with new origin
03034     // (would be nice to have them all default to 'no change' and only specify the new ones but that would be far to obvious!)
03035     GridResizeInfo GridParams;
03036     GridParams.pSpread          = pSpread;
03037     GridParams.OriginX          = NewPageRelativeOrigin.x;
03038     GridParams.OriginY          = NewPageRelativeOrigin.y;
03039     GridParams.GridDivisions    = pDefaultGrid->GetDivisions();
03040     GridParams.GridSubDivisions = pDefaultGrid->GetSubdivisions();
03041     GridParams.GridUnits        = pDefaultGrid->GetUnits();
03042     GridParams.TypeOfGrid       = pDefaultGrid->GetGridType();
03043 //  GridParams.GridSpacing  // this seems to be 'MainStep' which is also determined from Divisions and Units
03044 
03045     return DoResizeGrid(&GridParams);
03046 }

void OpSpreadOrigin::DoDrag Spread pThisSpread,
DocCoord  PointerPos
[protected]
 

Starts a drag for the origin.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/95
Parameters:
pThisSpread = ptr to spread drag started in (NULL means get selected spread) [INPUTS] PointerPos = coord of point clicked
- [OUTPUTS]
Returns:
-
See also:
-

Definition at line 2901 of file guides.cpp.

02902 {
02903     pSpread = pThisSpread;
02904 
02905     if (pSpread == NULL)
02906         pSpread = Document::GetSelectedSpread();
02907 
02908     ERROR3IF(pSpread == NULL,"pSpread == NULL");
02909     if (pSpread == NULL)
02910     {
02911         End();
02912         return;
02913     }
02914 
02915     CurrentOrigin = PointerPos;
02916 
02917     RenderMyDragBlobs();
02918 
02919     // put up some status line help
02920     StatusLine* pStatusLine=GetApplication()->GetpStatusLine();
02921     if (pStatusLine!=NULL)
02922     {
02923         String_256 temp(_R(IDS_OPSPREADORIGINDRAG));
02924         pStatusLine->UpdateText(&temp,STATUSLINE_SELDESC_STATBAR);
02925     }
02926     
02927     // Tell the Dragging system that we need drags to happen
02928     StartDrag( DRAGTYPE_DEFERSCROLL );
02929 }

void OpSpreadOrigin::DragFinished DocCoord  PointerPos,
ClickModifiers  ClickMods,
Spread ,
BOOL  Success,
BOOL  bSolidDrag
[virtual]
 

Responds to the drag of a guideline ending.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/95
Parameters:
PointerPos = coord of the pointer [INPUTS] ClickMods = info on the click modifiers pSpread = ptr to spread (not used) Success = TRUE if drag ended successfully, FALSE if drag terminated (usu. by pressing Escape)
- [OUTPUTS]
Returns:
-
See also:
UndoableOperation

Reimplemented from Operation.

Definition at line 2978 of file guides.cpp.

02979 {
02980     // First Rub out the old boxes
02981     RenderMyDragBlobs();
02982 
02983     Success = (Success && !OpGuideline::IsMouseOverRuler());
02984 
02985     if (Success)
02986     {
02987         DocView::SnapCurrent(pSpread,&PointerPos);
02988         CurrentOrigin = PointerPos;
02989 
02990         Success = DoChangeOrigin(pSpread,CurrentOrigin);
02991     }
02992 
02993     if (!Success)
02994         FailAndExecute();
02995 
02996     // End the op & Drag
02997     End();
02998     EndDrag();
02999 }

void OpSpreadOrigin::DragPointerMove DocCoord  PointerPos,
ClickModifiers  ClickMods,
Spread ,
BOOL  bSolidDrag
[virtual]
 

Responds to a mouse move during a drag of the origin.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/95
Parameters:
PointerPos = coord of the pointer [INPUTS] ClickMods = info on the click modifiers pSpread = ptr to spread
- [OUTPUTS]
Returns:
-
See also:
UndoableOperation

Reimplemented from Operation.

Definition at line 2947 of file guides.cpp.

02948 {
02949     // First Rub out the old box
02950     RenderMyDragBlobs();
02951 
02952     DocView::SnapCurrent(pSpread,&PointerPos);
02953 
02954     CurrentOrigin = PointerPos;
02955 
02956     // Render the new drag box
02957     RenderMyDragBlobs();
02958 }

OpState OpSpreadOrigin::GetState String_256 Description,
OpDescriptor
[static]
 

Func for determining the usability of this op.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/95
Parameters:
Description = ptr to place description of why this op can't happen [INPUTS] pOpDesc = ptr to the Op Desc associated with this op
- [OUTPUTS]
Returns:
An OpState object
See also:
-

Reimplemented from OpGridResize.

Reimplemented in OpResetSpreadOrigin.

Definition at line 3167 of file guides.cpp.

03168 {
03169     OpState State;
03170     return State;
03171 }

BOOL OpSpreadOrigin::Init void   )  [static]
 

Registers an op desc for this op.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if op successfully declared, FALSE otherwise
See also:
-

Reimplemented from OpGridResize.

Reimplemented in OpResetSpreadOrigin.

Definition at line 3138 of file guides.cpp.

03139 {
03140     return RegisterOpDescriptor(0, 
03141                                 _R(IDS_OPSPREADORIGIN),
03142                                 CC_RUNTIME_CLASS(OpSpreadOrigin), 
03143                                 OPTOKEN_SPREADORIGIN ,
03144                                 OpSpreadOrigin::GetState,
03145                                 0,  /* help ID */
03146                                 0,  /* bubble ID */
03147                                 0   /* bitmap ID */
03148                                 );
03149 }

void OpSpreadOrigin::RenderDragBlobs DocRect  Rect,
Spread pSpread,
BOOL  bSolidDrag
[virtual]
 

Main routine for rendering the blobs associated with the current drag. This can be called from anywhere, e.g. when the view scrolls.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/95
Parameters:
Rect = region of doc being updated (NOT USED!) [INPUTS] pSpread = ptr to the spread being redrawn
- [OUTPUTS]
Returns:
-
See also:
-

Reimplemented from Operation.

Definition at line 3086 of file guides.cpp.

03087 {
03088     static DocRect RenderRect;
03089 
03090     RenderRegion* pRender = DocView::RenderOnTop( NULL, pSpread, UnclippedEOR );
03091 
03092     DocCoord Start;
03093     DocCoord End;
03094 
03095     while (pRender != NULL)
03096     {
03097         pRender->SetLineColour(COLOUR_BLACK);
03098         pRender->SetLineWidth(pRender->GetScaledPixelWidth());
03099 
03100         if (RenderOn)
03101         {
03102             View* pView = pRender->GetRenderView();
03103             if (pView != NULL)
03104             {
03105                 RenderRect = pView->GetDocViewRect(pSpread);
03106                 RenderRect = RenderRect.ToSpread(pSpread,pView);
03107             }
03108             RenderRect.Inflate(pRender->GetScaledPixelWidth());
03109         }
03110 
03111         Start = DocCoord(CurrentOrigin.x,RenderRect.lo.y);
03112         End   = DocCoord(CurrentOrigin.x,RenderRect.hi.y);
03113         pRender->DrawDashLine(Start,End);
03114 
03115         Start = DocCoord(RenderRect.lo.x,CurrentOrigin.y);
03116         End   = DocCoord(RenderRect.hi.x,CurrentOrigin.y);
03117         pRender->DrawDashLine(Start,End);
03118 
03119         // Get the Next render region
03120         pRender = DocView::GetNextOnTop(NULL);
03121     }   
03122 }

void OpSpreadOrigin::RenderMyDragBlobs  ) 
 

Renders the blobs associated with the current drag.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
RenderDragBlobs()

Definition at line 3063 of file guides.cpp.

03064 {
03065     DocRect Rect;
03066     RenderDragBlobs(Rect,pSpread, FALSE);
03067     RenderOn = !RenderOn;
03068 }


Member Data Documentation

DocCoord OpSpreadOrigin::CurrentOrigin [private]
 

Definition at line 472 of file guides.h.

Spread* OpSpreadOrigin::pSpread [private]
 

Definition at line 471 of file guides.h.

BOOL OpSpreadOrigin::RenderOn [private]
 

Definition at line 473 of file guides.h.


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