#include <gridtool.h>
Inheritance diagram for OpGridNewResize:
Public Member Functions | |
OpGridNewResize () | |
Constructor. | |
~OpGridNewResize () | |
Destructor. | |
void | DoDrag (Spread *pSpread, NodeGrid *pGrid, GridBlobType Blob, DocCoord PointClicked) |
Starts dragging from the coordinate passed in. This op either created a new grid on the page (if Blob == NoGridBlob) or resizes pGrid using the Blob provided. | |
virtual void | DragPointerMove (DocCoord PointerPos, ClickModifiers ClickMods, Spread *, BOOL bSolidDrag) |
Pure virtual function which tells the operation that the mouse has moved. | |
virtual void | DragFinished (DocCoord PointerPos, ClickModifiers ClickMods, Spread *, BOOL Success, BOOL bSolidDrag) |
Ends the drag. Either creates a new grid or resizes GridClicked depending on the state of affairs when the drag started. | |
void | RenderMyDragBlobs () |
Draws an EORed rectangle defined by AnchorPoint and DragPoint. | |
void | RenderDragBlobs (DocRect Rect, Spread *pSpread, BOOL bSolidDrag) |
Draws an EORed rectangle defined by AnchorPoint and DragPoint. | |
void | GetOpName (String_256 *OpName) |
The GetOpName fn is overridden so that we return back a description appropriate to the type of attribute that the operation applies. | |
Static Public Member Functions | |
static BOOL | Declare () |
Adds the operation to the list of all known operations. | |
static OpState | GetState (String_256 *Description, OpDescriptor *) |
Find out the state of the operation at the specific time. | |
Static Public Attributes | |
static BOOL | StartADrag = TRUE |
static BOOL | EndTheDrag = TRUE |
Private Member Functions | |
CC_DECLARE_DYNCREATE (OpGridNewResize) | |
Private Attributes | |
Spread * | SpreadClicked |
NodeGrid * | GridClicked |
GridBlobType | GridBlobClicked |
DocCoord | AnchorPoint |
DocCoord | DragPoint |
OpGridOpType | OpType |
Definition at line 263 of file gridtool.h.
|
Constructor.
Definition at line 1635 of file gridtool.cpp.
|
|
Destructor.
Definition at line 1649 of file gridtool.cpp.
|
|
|
|
Adds the operation to the list of all known operations.
Definition at line 2012 of file gridtool.cpp. 02013 { 02014 return (RegisterOpDescriptor( 02015 0, 02016 _R(IDS_GRID_TOOL), 02017 CC_RUNTIME_CLASS(OpGridNewResize), 02018 OPTOKEN_GRIDNEWRESIZE, 02019 OpGridNewResize::GetState, 02020 0, /* help ID */ 02021 _R(IDBBL_NOOP), /* bubble ID */ 02022 0 /* bitmap ID */ 02023 )); 02024 }
|
|
Starts dragging from the coordinate passed in. This op either created a new grid on the page (if Blob == NoGridBlob) or resizes pGrid using the Blob provided.
Definition at line 1671 of file gridtool.cpp. 01673 { 01674 DocView::SnapCurrent(pSpread,&PointClicked); 01675 01676 // We haven't shown a grid in the infobar yet, so set these to NULL 01677 PreOpDisplayedGrid = NULL; 01678 PostOpDisplayedGrid = NULL; 01679 01680 SpreadClicked = pSpread; 01681 GridClicked = pGrid; 01682 GridBlobClicked = Blob; 01683 01684 if (GridBlobClicked == NoGridBlob) 01685 // Creating a new grid at this point, so drag and anchor points are the same 01686 DragPoint = AnchorPoint = PointClicked; 01687 else 01688 { 01689 // Here we are resizing the given grid using the given blob point 01690 ENSURE(GridClicked != NULL,"Oops! GridClicked == NULL && GridBlobClicked != NoGridBlob"); 01691 01692 // The following works out which points should be used as drag and anchor points 01693 // It assumes that the four corner points are defined in a specific way. If the GridBlobType 01694 // definition changes, then this code will have to change 01695 GridBlobType DragBlob = (GridBlobType) ((INT32)GridBlobClicked % 4); 01696 GridBlobType AnchorBlob = (GridBlobType) (((INT32)DragBlob+2) % 4); 01697 01698 // The anchor point is always the coord of the anchor blob 01699 AnchorPoint = GridClicked->GetBlobCoord(AnchorBlob); 01700 01701 if (GridBlobClicked < LeftMiddle) 01702 // if we have clicked on a corner blob, the drag point is wherever the mouse is 01703 DragPoint = PointClicked; 01704 else 01705 { 01706 // Otherwise, the drag point has to be constrained either horizontally or vertically 01707 // depending on which mid point has been clicked 01708 DragPoint = GridClicked->GetBlobCoord(DragBlob); 01709 01710 if (((INT32)GridBlobClicked % 2) == 0) 01711 DragPoint.x = PointClicked.x; 01712 else 01713 DragPoint.y = PointClicked.y; 01714 } 01715 RenderMyDragBlobs(); 01716 } 01717 01718 // And tell the Dragging system that we need drags to happen 01719 if (OpGridNewResize::StartADrag) StartDrag( DRAGTYPE_AUTOSCROLL ); 01720 }
|
|
Ends the drag. Either creates a new grid or resizes GridClicked depending on the state of affairs when the drag started.
Reimplemented from Operation. Definition at line 1792 of file gridtool.cpp. 01794 { 01795 BOOL ok = Success; // The OK flag. If this is TRUE, it is safe to continue the operation 01796 01797 // Put the hour glass up as we have to 01798 BeginSlowJob(); 01799 01800 if (ok) DocView::SnapCurrent(pSpread,&PointerPos); // Snap the point 01801 01802 // Check for an artificially created drag. If it is artificial, then DragPointerMove 01803 // has never been called so update DragPoint to be PointerPos. 01804 if (!OpGridNewResize::EndTheDrag) DragPoint = PointerPos; 01805 01806 // First Rub out the old box 01807 RenderMyDragBlobs(); 01808 01809 // Get a ptr to a doc view 01810 DocView* pDocView = DocView::GetSelected(); // Get ptr to selected doc view 01811 if (ok) ok = (pDocView != NULL); // Check we've got a doc view 01812 01813 UINT32 IDS = 0; 01814 01815 // Has the user gone anywhere with the drag? 01816 if (ok) ok = (DragPoint != AnchorPoint); 01817 01818 NodeGrid* pNewGrid = NULL; // This will point to the new grid 01819 NodeGrid* pOldGrid = NULL; // This will point to the grid being altered (if applicable) 01820 01821 if (ok) 01822 { 01823 // BOOL FRedraw = pDocView->GetShowGridState(); // FRedraw = TRUE if we need to cause redraws after change 01824 BOOL FRedraw = TRUE; 01825 01826 DocRect ScaledBlob; // Will hold a scaled blob at coord (0,0) 01827 OSRenderRegion::GetBlobRect(pDocView->GetViewScale(), DocCoord(0,0), BT_SELECTEDLARGEST, &ScaledBlob); 01828 01829 // This lump of code makes sure that the minimum grid size created is not less than the width of a blob 01830 MILLIPOINT dx = AnchorPoint.x - DragPoint.x; 01831 MILLIPOINT dy = AnchorPoint.y - DragPoint.y; 01832 if (abs(dx) < ScaledBlob.Width()) DragPoint.x = AnchorPoint.x + (ScaledBlob.Width() *sgn(dx)); 01833 if (abs(dy) < ScaledBlob.Height()) DragPoint.y = AnchorPoint.y + (ScaledBlob.Height()*sgn(dy)); 01834 01835 01836 // Build the rectangle of the drag box at the end of the drag 01837 DocRect Rect( min(AnchorPoint.x, DragPoint.x),min(AnchorPoint.y, DragPoint.y), 01838 max(AnchorPoint.x, DragPoint.x),max(AnchorPoint.y, DragPoint.y) ); 01839 01840 01841 DocRect OldRect = DocRect(0,0,0,0); // Old rectangle coords used when resizing GridClicked 01842 01843 GridType CreateGridType; // The type of grid we need to create 01844 Node* ContextNode; // Context of the new grid's placing 01845 AttachNodeDirection AttachDir; // How the ContextNode is used to place new grid 01846 01847 if (GridBlobClicked == NoGridBlob) // No blob clicked, so we're creating a new grid 01848 { 01849 CreateGridType = NodeGrid::GetDefaultGridType(); 01850 ContextNode = SpreadClicked; 01851 AttachDir = LASTCHILD; 01852 OpType = NEW; 01853 } 01854 else // Blob clicked, so new grid is edited form of old grid 01855 { 01856 pOldGrid = GridClicked; 01857 OldRect = pOldGrid->GetBoundingRect(); 01858 GridTool::RenderAllGridBlobs(pOldGrid); 01859 01860 CreateGridType = pOldGrid->GetGridType(); 01861 ContextNode = pOldGrid; 01862 AttachDir = NEXT; 01863 OpType = RESIZE; 01864 } 01865 01866 switch (CreateGridType) // Create the new grid of the right type 01867 { 01868 case RECTANGULAR : ALLOC_WITH_FAIL(pNewGrid,(new NodeGridRect()),this); break; 01869 case ISOMETRIC : ALLOC_WITH_FAIL(pNewGrid,(new NodeGridIso()), this); break; 01870 } 01871 01872 ok = (pNewGrid != NULL); 01873 if (ok) ok = DoInsertNewNode(pNewGrid,ContextNode,AttachDir,TRUE); 01874 if (ok) ok = DoInvalidateNodeRegion(pNewGrid,TRUE); 01875 if (ok && (pOldGrid != NULL)) ok = DoInvalidateNodeRegion(pOldGrid,TRUE); 01876 if (ok && (pOldGrid != NULL)) ok = DoHideNode(pOldGrid,TRUE); 01877 01878 if (ok) 01879 { 01880 // Initialise the new grid based on whether we have an old grid or not 01881 if (pOldGrid == NULL) 01882 { 01883 pNewGrid->SetGridParams(NodeGrid::GetDefaultDivisions(),NodeGrid::GetDefaultSubdivisions(),NodeGrid::GetDefaultUnits()); 01884 // pNewGrid->SetInitialBounds(Rect); 01885 pNewGrid->SetDefault(FALSE); 01886 pNewGrid->SetDisabled(FALSE); 01887 pNewGrid->SetGridSelected(TRUE); 01888 } 01889 else 01890 { 01891 pNewGrid->SetGridParams(pOldGrid->GetDivisions(),pOldGrid->GetSubdivisions(),pOldGrid->GetUnits()); 01892 // pNewGrid->ChangeBounds(Rect); 01893 pNewGrid->SetGridSelected(pOldGrid->IsGridSelected()); 01894 } 01895 01896 NodeGrid::RecalcNumSelectedGrids(SpreadClicked); 01897 01898 // Tell the NodeGrid of the new bounds 01899 pNewGrid->SetBoundingRect(Rect); 01900 01901 // Redraw the old and new positions of the grid. 01902 // GridTool::ForceRedraw will do nothing if Rect is empty or invalid 01903 01904 if (FRedraw) 01905 { 01906 GridTool::ForceRedraw(SpreadClicked,Rect); 01907 GridTool::ForceRedraw(SpreadClicked,OldRect); 01908 } 01909 else 01910 GridTool::RenderAllGridBlobs(pNewGrid); 01911 01912 // Show the new grid's info in the info bar 01913 GridInfoBarOp* pGridInfoBarOp = GridTool::GetGridInfoBarOp(); 01914 if (pGridInfoBarOp != NULL) 01915 { 01916 PreOpDisplayedGrid = pGridInfoBarOp->GetLastGridDisplayed(); 01917 pGridInfoBarOp->EnableControls(); 01918 GridTool::DisplayGridInfo(pNewGrid); 01919 PostOpDisplayedGrid = pNewGrid; 01920 } 01921 } 01922 } 01923 01924 if (!ok) 01925 { 01926 if (pNewGrid != NULL) delete pNewGrid; 01927 if (IDS > 0) InformError(IDS,_R(IDS_OK)); 01928 FailAndExecute(); 01929 } 01930 01931 // If it's a real drag event, end the drag. 01932 if (OpGridNewResize::EndTheDrag) 01933 EndDrag(); 01934 01935 // End the op 01936 End(); 01937 }
|
|
Pure virtual function which tells the operation that the mouse has moved. virtual void Operation::DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread *pSpread, BOOL bSolidDrag)
Reimplemented from Operation. Definition at line 1740 of file gridtool.cpp. 01742 { 01743 // if (IsUserName("MarkN")) TRACE( _T("\n\nOpGridNewResize::DragPointerMove()\n")); 01744 01745 // First Rub out the old box 01746 RenderMyDragBlobs(); 01747 01748 // Update the box and draw in the new one 01749 if (pSpread != SpreadClicked) 01750 PointerPos = MakeRelativeToSpread(SpreadClicked, pSpread, PointerPos); 01751 01752 DocView::SnapCurrent(pSpread,&PointerPos); 01753 01754 if (GridBlobClicked < LeftMiddle) 01755 // If dragging a corner blob, the drag point is the same as the mouse position 01756 DragPoint = PointerPos; 01757 else 01758 { 01759 // Otherwise, constrain the drag point depending on which mid line blob was clicked 01760 if (((INT32)GridBlobClicked % 2) == 0) 01761 DragPoint.x = PointerPos.x; 01762 else 01763 DragPoint.y = PointerPos.y; 01764 } 01765 01766 // Render the new drag box 01767 RenderMyDragBlobs(); 01768 }
|
|
The GetOpName fn is overridden so that we return back a description appropriate to the type of attribute that the operation applies.
Reimplemented from Operation. Definition at line 2065 of file gridtool.cpp. 02066 { 02067 switch (OpType) 02068 { 02069 case NEW: *OpName = String_256(_R(IDS_GRID_UNDO_NEW)); break; 02070 case RESIZE: *OpName = String_256(_R(IDS_GRID_UNDO_RESIZE)); break; 02071 } 02072 }
|
|
Find out the state of the operation at the specific time.
Definition at line 2041 of file gridtool.cpp. 02042 { 02043 OpState Grid; 02044 02045 return Grid; 02046 }
|
|
Draws an EORed rectangle defined by AnchorPoint and DragPoint.
Reimplemented from Operation. Definition at line 1977 of file gridtool.cpp. 01978 { 01979 // if (IsUserName("MarkN")) TRACE( _T("OpGridNewResize::RenderDragBlobs()\n")); 01980 01981 DocRect RubberBox = DocRect( min(AnchorPoint.x,DragPoint.x),min(AnchorPoint.y,DragPoint.y), 01982 max(AnchorPoint.x,DragPoint.x),max(AnchorPoint.y,DragPoint.y) ); 01983 01984 RenderRegion* pRegion = DocView::RenderOnTop( &Rect, pSpread, UnclippedEOR ); 01985 01986 while ( pRegion != NULL ) 01987 { 01988 // Set the line colour and Draw the rect 01989 pRegion -> SetLineColour( COLOUR_XORDRAG ); 01990 01991 // Draw the rectangle 01992 pRegion -> DrawDragRect( &RubberBox ); 01993 01994 // Get the Next render region 01995 pRegion = DocView::GetNextOnTop( &Rect ); 01996 } 01997 }
|
|
Draws an EORed rectangle defined by AnchorPoint and DragPoint.
Definition at line 1953 of file gridtool.cpp. 01954 { 01955 // if (IsUserName("MarkN")) TRACE( _T("OpGridNewResize::RenderMyDragBlobs()\n")); 01956 01957 DocRect Rect = DocRect( min(AnchorPoint.x, DragPoint.x),min(AnchorPoint.y, DragPoint.y), 01958 max(AnchorPoint.x, DragPoint.x),max(AnchorPoint.y, DragPoint.y) ); 01959 01960 RenderDragBlobs(Rect,SpreadClicked, FALSE); 01961 }
|
|
Definition at line 300 of file gridtool.h. |
|
Definition at line 301 of file gridtool.h. |
|
Definition at line 293 of file gridtool.h. |
|
Definition at line 299 of file gridtool.h. |
|
Definition at line 298 of file gridtool.h. |
|
Definition at line 303 of file gridtool.h. |
|
Definition at line 297 of file gridtool.h. |
|
Definition at line 292 of file gridtool.h. |