GridTool Class Reference

A Tool for creating and editing grids. More...

#include <gridtool.h>

Inheritance diagram for GridTool:

Tool_v1 List of all members.

Public Member Functions

 GridTool ()
 Constructor - does nothing. Other initialisation is done in GridTool::Init which is called by the Tool Manager.
 ~GridTool ()
 Destructor (Virtual). Does nothing.
BOOL Init ()
 Used to check if the Tool was properly constructed.
void Describe (void *InfoPtr)
 Allows the tool manager to extract information about the tool.
UINT32 GetID ()
void SelectChange (BOOL isSelected)
 Creates/destroys/pushes/pops the rectangle tool's cursor.
void OnClick (DocCoord, ClickType, ClickModifiers, Spread *)
 To handle a Mouse Click event for the Grid Tool. It handles grid creation, selection and translation.
void OnMouseMove (DocCoord PointerPos, Spread *pSpread, ClickModifiers mods)
 To handle a Mouse Move event for the Grid Tool. It changes the cursor dependant on were it is in relation to grids in the spread The status bar is filled with a relevent piece of text.
void RenderToolBlobs (Spread *pSpread, DocRect *pDocRect)
 Handles the RenderToolBlobs method. Renders the tool's blobs into the current doc view.

Static Public Member Functions

static void RenderAllGridBlobs (NodeGrid *pGrid)
 Renders the full compliment of blobs for the given grid. This means bounding rect AND select blobs are rendered. The routine works out what spread it belongs to and tries to render the blobs in the current doc view.
static void ChangeSelectedGrids ()
static void ForceRedraw (Spread *pSpread, DocRect Rect)
 To handle a CurrentDocViewChange event for the Grid Tool. To handle a SelectedDocViewChange event for the Grid Tool. Forces a blob-inclusive redraw on the rect given in Spread. If the Rect is empty or invalid, no redraw is forced The redraw happens in the current view (if there is one).
static void ForceRedraw (NodeGrid *pGrid)
 Forces a blob-inclusive redraw on the the given grid. If the Rect is empty or invalid, no redraw is forced The redraw happens in the current view (if there is one).
static void MakeDefaultGrid (Spread *pSpread)
static void ToggleDefaultGrid ()
 Creates a grid covering the whole spread. The grid is defined using the default parameters.
static void DisplayStatusBarHelp (UINT32 StatusID)
 Displays the given status help string in the status bar.
static void DisplayGridInfo (NodeGrid *pGrid)
 Displays the given grid's info in the infobar.
static SpreadGetSpreadClicked ()
static GridInfoBarOpGetGridInfoBarOp ()
static DocumentGetDoc ()
static void SetDoc (Document *pThisDoc)
 Updates the grid tool's idea of what is the relevant doc. If the doc is different to the last one we had, then make sure the default units are correct for this doc, and init the controls in the info bar to take into account the new doc.

Static Public Attributes

static GridType DefaultGridType

Private Member Functions

 CC_DECLARE_MEMDUMP (GridTool)
BOOL CreateCursors ()
 Creates all the grid tool cursors.
void RenderAllGridBlobs ()
 Update the GridTool's controls on the info bar. Handles UI events from the Zoom Tool's gadgets on the info bar. Shows the grid blobs of all the grids in the current view.
BOOL WhichGridClicked (Spread *pSpread, const DocCoord &PointerPos, NodeGrid **ppGrid)
 Scans the grids in the spread to see which one was clicked in (if any) Disabled grids are ignored.
BOOL WhichGridBlobClicked (Spread *pSpread, const DocCoord &PointerPos, NodeGrid **ppGrid, GridBlobType *pGridBlob)
 Scans the grids in the spread to see which grid select blob was clicked (if any).

Static Private Member Functions

static void ChangeGrid (NodeGrid *pGrid)
static void RenderGridBlobsInSpread (DocView *pDocView, Spread *pSpread, DocRect *pDocRect)
 EORs the blobs of all the grids in the given spread viewed through the given doc view.
static void RenderGridBlobs (RenderRegion *pRender, NodeGrid *pGrid)
 Renders the blobs (i.e. the bounding rect) of the given grid.
static void RenderGridSelectBlobs (RenderRegion *pRender, NodeGrid *pGrid)
 Shows the selection blobs of the given grid in the given render region.
static void RenderGridBlobs (NodeGrid *pGrid)
 EORs the bounding rectangle blob of the given grid. The routine works out what spread it belongs to and tries to render the blobs in the current doc view.
static void RenderGridSelectBlobs (NodeGrid *pGrid)
 Shows the selection blobs of the given grid. The routine works out what spread it belongs to and tries to render the blobs in the current doc view.
static void ClearSelection (Spread *pSpread)
 Scans the grids in the spread and clears the selection bit. If the selection bit of a grid is set from TRUE to FALSE, the selection blobs of that grid are also updated.
static BOOL GetGridBlobRenderVars (NodeGrid *pGrid, DocView **ppDocView, Spread **ppSpread, DocRect *pDocRect)
 Gets the vars required to render the blobs of a grid.
static void FindCurrentSpread ()
 Tries to find a spread that can be considered the current spread in relation to the grid tool.
static BOOL HasSpreadSelGrids (Spread *pSpread)
 Tells you the 'selected grids' state of the given spread.

Private Attributes

CursorpcNormalGridCursor
CursorpcOverGridCursor
CursorpcOverBlobCursorUD
CursorpcOverBlobCursorLR
CursorpcOverBlobCursorTL
CursorpcOverBlobCursorTR
CursorpcCurrentCursor
INT32 CurrentCursorID

Static Private Attributes

static SpreadSpreadClicked = NULL
static DocCoord PointClicked
static NodeGridGridClicked = NULL
static GridBlobType GridBlobClicked = NoGridBlob
static NodeGridLastGridClicked = NULL
static UINT32 LastStatusID = 0
static GridInfoBarOppGridInfoBarOp = NULL
static DocumentpDocument = NULL
static char * FamilyName = "Grid Tools"
static char * ToolName = "Grid Tool"
static char * Purpose = "Grid manipulation"
static char * Author = "Mark Neves"

Detailed Description

A Tool for creating and editing grids.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/2/94

Definition at line 127 of file gridtool.h.


Constructor & Destructor Documentation

GridTool::GridTool  ) 
 

Constructor - does nothing. Other initialisation is done in GridTool::Init which is called by the Tool Manager.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/2/94
See also:
GridTool::Init

Definition at line 202 of file gridtool.cpp.

00203 {
00204     pcCurrentCursor = NULL;
00205 }

GridTool::~GridTool  ) 
 

Destructor (Virtual). Does nothing.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/2/94

Definition at line 217 of file gridtool.cpp.

00218 {
00219     // Dummy destructor
00220 
00221 //  if (IsUserName("MarkN")) TRACE( _T("~GridTool()\n"));
00222 
00223 }


Member Function Documentation

GridTool::CC_DECLARE_MEMDUMP GridTool   )  [private]
 

static void GridTool::ChangeGrid NodeGrid pGrid  )  [static, private]
 

static void GridTool::ChangeSelectedGrids  )  [static]
 

void GridTool::ClearSelection Spread pSpread  )  [static, private]
 

Scans the grids in the spread and clears the selection bit. If the selection bit of a grid is set from TRUE to FALSE, the selection blobs of that grid are also updated.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/2/94
Parameters:
pSpread = ptr to a spread (can cope with pSpread == NULL) [INPUTS]
Returns:
-
See also:

Definition at line 1184 of file gridtool.cpp.

01185 {
01186     // A NULL spread is a possibility
01187     if (pSpread == NULL) return;
01188 
01189     Node* pNode = pSpread->FindLastChild();
01190     while (pNode != NULL)
01191     {
01192         if (pNode->IsKindOf(CC_RUNTIME_CLASS(NodeGrid)))
01193         {
01194             NodeGrid* pGrid = (NodeGrid*)pNode;
01195             
01196             if (pGrid->IsGridSelected())
01197             {
01198                 RenderGridSelectBlobs(pGrid);
01199                 pGrid->SetGridSelected(FALSE);
01200             }
01201         }
01202         pNode = pNode->FindPrevious();
01203     }
01204 }

BOOL GridTool::CreateCursors  )  [private]
 

Creates all the grid tool cursors.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/5/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if all the grid tool cursors have been successfully created
See also:
-

Definition at line 476 of file gridtool.cpp.

00477 {
00478     // This tool has just been selected.  Create the cursors.
00479     pcNormalGridCursor  = new Cursor(this, _R(IDC_GRIDTOOLCURSOR));
00480     pcOverGridCursor    = new Cursor(this, _R(IDC_MOVEBEZIERCURSOR));
00481     pcOverBlobCursorUD  = new Cursor(_R(IDC_SIZENS));
00482     pcOverBlobCursorLR  = new Cursor(_R(IDC_SIZEWE));
00483     pcOverBlobCursorTL  = new Cursor(_R(IDC_SIZENWSE));
00484     pcOverBlobCursorTR  = new Cursor(_R(IDC_SIZENESW));
00485 
00486     if ( pcNormalGridCursor==NULL       ||  !pcNormalGridCursor->IsValid()  ||
00487          pcOverGridCursor==NULL         ||  !pcOverGridCursor->IsValid()    ||
00488          pcOverBlobCursorUD==NULL       ||  !pcOverBlobCursorUD->IsValid()  ||
00489          pcOverBlobCursorLR==NULL       ||  !pcOverBlobCursorLR->IsValid()  ||
00490          pcOverBlobCursorTL==NULL       ||  !pcOverBlobCursorTL->IsValid()  ||
00491          pcOverBlobCursorTR==NULL       ||  !pcOverBlobCursorTR->IsValid())
00492     {
00493         if (IsUserName("MarkN")) TRACE( _T("Couldn't create grid tool cursors!\n"));
00494 
00495         if (pcNormalGridCursor != NULL) delete pcNormalGridCursor;
00496         if (pcOverGridCursor   != NULL) delete pcOverGridCursor;
00497         if (pcOverBlobCursorUD != NULL) delete pcOverBlobCursorUD;
00498         if (pcOverBlobCursorLR != NULL) delete pcOverBlobCursorLR;
00499         if (pcOverBlobCursorTL != NULL) delete pcOverBlobCursorTL;
00500         if (pcOverBlobCursorTR != NULL) delete pcOverBlobCursorTR;
00501         return FALSE;
00502     }
00503     else
00504         return TRUE;
00505 }

void GridTool::Describe void *  InfoPtr  )  [virtual]
 

Allows the tool manager to extract information about the tool.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/2/94
Parameters:
InfoPtr - A pointer to a tool info block. It is passed cast to void* as [INPUTS] the version of the tool is unknown at this point. Later versions of the Tool class may have more items in this block, that this tool will not use
InfoPtr - The structure pointed to by InfoPtr will have had all the info [OUTPUTS] that this version of the Tool knows about

Reimplemented from Tool_v1.

Definition at line 298 of file gridtool.cpp.

00299 {
00300     // Cast structure into the latest one we understand.
00301     ToolInfo_v1 *Info = (ToolInfo_v1 *) InfoPtr;
00302 
00303     Info -> InfoVersion = 1;
00304     
00305     Info -> InterfaceVersion = GetToolInterfaceVersion();  // You should always have this line.
00306         
00307     // These are all arbitrary at present.
00308     Info -> Version = 1;
00309     Info -> ID      = GetID();
00310     Info -> TextID  = _R(IDS_GRID_TOOL);
00311 
00312     Info -> Family  = FamilyName;
00313     Info -> Name    = ToolName;
00314     Info -> Purpose = Purpose;
00315     Info -> Author  = Author;
00316 
00317     Info -> InfoBarDialog = _R(IDD_GRIDTOOL);
00318     Info -> BubbleID = _R(IDBBL_GRID_TOOLBOX);
00319 }

void GridTool::DisplayGridInfo NodeGrid pGrid  )  [static]
 

Displays the given grid's info in the infobar.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/5/94
Parameters:
pGrid = ptr to grid to display in [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
-

Definition at line 1532 of file gridtool.cpp.

01533 {
01534     pGridInfoBarOp->DisplayGridInfo(pGrid);
01535 }

void GridTool::DisplayStatusBarHelp UINT32  StatusID  )  [static]
 

Displays the given status help string in the status bar.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/5/94
Parameters:
StatusID = ID of status help string [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
-

Definition at line 1506 of file gridtool.cpp.

01507 {
01508 //  if (LastStatusID != StatusID)
01509 //  {
01510         String_256 StatusMsg("");
01511         StatusMsg.Load(StatusID);
01512         GetApplication()->UpdateStatusBarText(&StatusMsg);
01513         LastStatusID = StatusID;
01514 //  }
01515 }

void GridTool::FindCurrentSpread  )  [static, private]
 

Tries to find a spread that can be considered the current spread in relation to the grid tool.

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

Definition at line 522 of file gridtool.cpp.

00523 {
00524     Spread* pSpreadWithSelGrids   = NULL;
00525     Spread* pSpreadWithSelObjects = NULL;
00526 
00527     if (GridTool::GetDoc() != NULL)     // if there's a current doc, rock and roll
00528     {
00529         // Now we need to scan all spreads throughout this doc view's doc.
00530 
00531         Chapter* pChapter = Node::FindFirstChapter(GridTool::GetDoc());
00532         while (pChapter != NULL && pSpreadWithSelGrids == NULL)
00533         {
00534             // For each chapter in the doc...
00535             Node* pNode = pChapter->FindFirstChild();
00536             while (pNode != NULL && pSpreadWithSelGrids == NULL)
00537             {
00538                 // If the child node of the chapter is a spread...
00539                 if (pNode->IsKindOf(CC_RUNTIME_CLASS(Spread)))
00540                 {
00541                     Spread* pSpread = (Spread*)pNode;
00542                     if (HasSpreadSelGrids(pSpread))
00543                         pSpreadWithSelGrids = pSpread;
00544                 }
00545                 pNode = pNode->FindNext();
00546             }
00547             pChapter = pChapter->FindNextChapter();
00548         }
00549 
00550         if (pSpreadWithSelGrids == NULL)
00551         {
00552             // Obtain the current selections
00553             Range Sel(*(GetApplication()->FindSelection()));
00554     
00555             // Find the first selected object.
00556             Node* FirstSelected = Sel.FindFirst();
00557 
00558             // If there isn't one, then there is no spread with sel objects
00559             // Otherwise get the selected object's parent spread
00560             if (FirstSelected != NULL)
00561                 pSpreadWithSelObjects = (Spread*)FirstSelected->FindParent(CC_RUNTIME_CLASS(Spread));
00562         }
00563     }
00564 
00565     if (pSpreadWithSelGrids != NULL)
00566         SpreadClicked = pSpreadWithSelGrids;
00567     else
00568         SpreadClicked = pSpreadWithSelObjects;
00569 }    

void GridTool::ForceRedraw NodeGrid pGrid  )  [static]
 

Forces a blob-inclusive redraw on the the given grid. If the Rect is empty or invalid, no redraw is forced The redraw happens in the current view (if there is one).

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/3/94
Parameters:
pGrid = ptr to grid to force a redraw on [INPUTS]

Definition at line 1056 of file gridtool.cpp.

01057 {
01058     ForceRedraw(pGrid->FindParentSpread(),pGrid->GetBlobBoundingRect());
01059 }

void GridTool::ForceRedraw Spread pSpread,
DocRect  Rect
[static]
 

To handle a CurrentDocViewChange event for the Grid Tool. To handle a SelectedDocViewChange event for the Grid Tool. Forces a blob-inclusive redraw on the rect given in Spread. If the Rect is empty or invalid, no redraw is forced The redraw happens in the current view (if there is one).

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/3/94
Parameters:
pPSpread = ptr to a spread, dude! [INPUTS] Rect - The region that needs the blobs to be drawn

Definition at line 1009 of file gridtool.cpp.

01010 {
01011     // Is it a wank spread? Then stick it where the sun don't shine!
01012     if (pSpread == NULL) return;
01013 
01014     // No selected view? Then no dice!
01015     DocView* pDocView = DocView::GetSelected();
01016     if (pDocView == NULL) return;
01017 
01018     // Bad rect?
01019     if (Rect.IsEmpty() || !Rect.IsValid()) return;
01020 
01021     DocRect BlobSize;   // Will old the size of a scaled blob
01022 
01023     // Add the size of a blob to the top corner of the bounding rectangle
01024     OSRenderRegion::GetBlobRect(pDocView->GetViewScale(), Rect.HighCorner(), 
01025                                 BT_SELECTEDLARGEST, &BlobSize);
01026     Rect.IncludePoint( BlobSize.HighCorner() );
01027 
01028     // add the size of a blob to the bottom corner of the bounding rectangle
01029     OSRenderRegion::GetBlobRect(pDocView->GetViewScale(), Rect.LowCorner(), 
01030                                 BT_SELECTEDLARGEST, &BlobSize);
01031     Rect.IncludePoint( BlobSize.LowCorner() );
01032 
01033 
01034     // Uncomment the next two lines for total spread area redraw
01035     //Rect = pSpread->GetPasteboardRect();
01036     //pSpread->DocCoordToSpreadCoord(&Rect);
01037 
01038 
01039     // redraw it 
01040     pDocView->ForceRedraw(pSpread,Rect);
01041 }

static Document* GridTool::GetDoc  )  [inline, static]
 

Definition at line 161 of file gridtool.h.

00161 { return GridTool::pDocument; }

BOOL GridTool::GetGridBlobRenderVars NodeGrid pGrid,
DocView **  ppDocView,
Spread **  ppSpread,
DocRect pDocRect
[static, private]
 

Gets the vars required to render the blobs of a grid.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/2/94
Parameters:
pGrid = ptr to grid in question [INPUTS] ppDocView = ptr to ptr to a DocView ppSpread = ptr to ptr to a spread pDocRect = ptr to the spread's bounding box
Puts a ptr to the current doc view into *ppDocView [OUTPUTS] Puts the ptr to the parent spread of the grid into *ppSpread Puts bounding DocRect of spread into *pDocRect
Returns:
TRUE - The vars are good, so go and render FALSE - Something was not found, so outputs are invalid
See also:

Definition at line 914 of file gridtool.cpp.

00915 {
00916     // Get current doc view.  If there isn't one, fail
00917     *ppDocView = DocView::GetCurrent();
00918     if (*ppDocView == NULL) return (FALSE);
00919     
00920     // Get parent spread. If there isn't one, fail
00921     *ppSpread = pGrid->FindParentSpread();
00922     if (*ppSpread == NULL) return (FALSE);
00923 
00924     // Get spread bounds and translate to spread coords
00925     *pDocRect = (*ppSpread)->GetPasteboardRect();
00926     (*ppSpread)->DocCoordToSpreadCoord(pDocRect);
00927     
00928     return (TRUE);
00929 }

static GridInfoBarOp* GridTool::GetGridInfoBarOp  )  [inline, static]
 

Definition at line 157 of file gridtool.h.

00157 {return pGridInfoBarOp; }

UINT32 GridTool::GetID  )  [virtual]
 

Reimplemented from Tool_v1.

Definition at line 321 of file gridtool.cpp.

00322 {
00323     return TOOLID_GRID;
00324 }

static Spread* GridTool::GetSpreadClicked  )  [inline, static]
 

Definition at line 156 of file gridtool.h.

00156 {return SpreadClicked; }

BOOL GridTool::HasSpreadSelGrids Spread pSpread  )  [static, private]
 

Tells you the 'selected grids' state of the given spread.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/5/94
Parameters:
pSpread = spread to look at [INPUTS]
Returns:
TRUE if spread contains at least one selected grid
See also:
-

Definition at line 586 of file gridtool.cpp.

00587 {
00588     // scan the children of the spread for grids
00589     Node* pNode = pSpread->FindFirstChild();
00590     while (pNode != NULL)
00591     {
00592         if (pNode->IsKindOf(CC_RUNTIME_CLASS(NodeGrid)))
00593         {
00594             // we now have a ptr to a grid, so render those blobs
00595             NodeGrid* pGrid = (NodeGrid*)pNode;
00596             if (!pGrid->IsDisabled() && pGrid->IsGridSelected())
00597                 return TRUE;
00598         }
00599         pNode = pNode->FindNext();
00600     }
00601     return FALSE;
00602 }

BOOL GridTool::Init void   )  [virtual]
 

Used to check if the Tool was properly constructed.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/2/94
Returns:
FALSE if it does not want to be created, TRUE otherwise
See also:
GridTool::GridTool

Reimplemented from Tool_v1.

Definition at line 239 of file gridtool.cpp.

00240 {
00241 //  if (IsUserName("MarkN")) TRACE( _T("\nGridTool::Init called\n"));
00242 //  if (IsUserName("MarkN")) TRACE( _T("Creating grid tool info bar\n"));
00243 
00244     // Declare ops and only succeed if all declarations succeed
00245     BOOL ok = ( OpGridNewResize::Declare() && 
00246                 OpGridSelection::Declare() && 
00247                 OpGridChange::Declare());
00248 
00249 
00250     // This section reads in the infobar definition and creates an instance of
00251     // GridInfoBarOp.  Also pGridInfoBarOp, the ptr to my infobar, as set up
00252     // after the infobar is successfully read and created.
00253     if (ok)
00254     {
00255         CCResTextFile       file;               // Resource File
00256         GridInfoBarOpCreate BarCreate;          // Object that creates GridInfoBarOp objects
00257 
00258                 ok = file.open(_R(IDM_GRID_BAR), _R(IDT_INFO_BAR_RES));     // Open resource
00259         if (ok) ok = DialogBarOp::ReadBarsFromFile(file,BarCreate); // Read and create info bar
00260         if (ok) file.close();                                       // Close resource
00261 
00262         ENSURE(ok,"Unable to load gridbar.ini from resource\n"); 
00263 
00264         if (ok)
00265         {
00266             // Info bar now exists.  Now get a pointer to it
00267             String_32 str = String_32(_R(IDS_GRIDTOOL_INFOBARNAME));
00268             DialogBarOp* pDialogBarOp = DialogBarOp::FindDialogBarOp(str);
00269 
00270                     ok = (pDialogBarOp != NULL);
00271             if (ok) ok = pDialogBarOp->IsKindOf(CC_RUNTIME_CLASS(GridInfoBarOp));
00272             if (ok) pGridInfoBarOp = (GridInfoBarOp*)pDialogBarOp;
00273 
00274             ENSURE(ok,"Couldn't find grid tool info bar");
00275         }
00276     }
00277 
00278     return (ok);
00279 }

static void GridTool::MakeDefaultGrid Spread pSpread  )  [static]
 

void GridTool::OnClick DocCoord  PointerPos,
ClickType  Click,
ClickModifiers  ClickMods,
Spread pSpread
[virtual]
 

To handle a Mouse Click event for the Grid Tool. It handles grid creation, selection and translation.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/2/94
Parameters:
PointerPos - The DocCoord of the point where the mouse button was clicked [INPUTS] Click - Describes the type of click that was detected. ClickMods - Indicates which buttons caused the click and which modifers were pressed at the same time pSpread - The spread in which the click happened
Returns:
-
See also:
Tool::MouseClick; ClickType; ClickModifiers

Reimplemented from Tool_v1.

Definition at line 1225 of file gridtool.cpp.

01227 {
01228     if (ClickMods.Menu) return;                         // Don't do anything if the user clicked the Menu button
01229 
01230     ENSURE(pSpread != NULL,"GridTool::OnClick pSpread == NULL!!!!!");
01231 
01232     // Make sure this click is one that we want
01233     if ( Click == CLICKTYPE_SINGLE || Click == CLICKTYPE_DOUBLE)
01234     {
01235         // If click appears on a different spread than the last click, clear
01236         // the selection from the previous spread
01237         if (SpreadClicked != pSpread)   ClearSelection(SpreadClicked);
01238 
01239         if (SpreadClicked == NULL && pSpread != NULL)
01240             pGridInfoBarOp->EnableGadget(_R(IDC_MAKEGRID),TRUE);
01241 
01242         // make a note of the click pos and spread
01243         PointClicked  = PointerPos;
01244         SpreadClicked = pSpread;
01245 
01246         // Get the grid and blob clicked on...
01247         // The following two functions work out which grid was clicked on, and if a grid
01248         // was clicked on, which blob (if any) was clicked
01249         // NOTE : The result of these function calls are stored in GridClicked & GridBlobClicked
01250 
01251         if (!WhichGridBlobClicked(SpreadClicked,PointClicked,&GridClicked,&GridBlobClicked))
01252             WhichGridClicked(SpreadClicked,PointClicked,&GridClicked);
01253 
01254 
01255         // The following decides how the click will be processed
01256 
01257         if (GridClicked != NULL)
01258         {
01259             // Display grid info in the info bar
01260             ENSURE(pGridInfoBarOp != NULL,"GridTool::OnClick - pGridInfoBarOp == NULL!");
01261             pGridInfoBarOp->DisplayGridInfo(GridClicked);
01262     
01263             if (!GridClicked->IsDefault())
01264             {
01265                 if (GridBlobClicked == NoGridBlob)
01266                 {
01267                     if (GridClicked->IsGridSelected() && !ClickMods.Adjust)
01268                     {
01269                         // A left click on a selected grid starts a drag on the selection
01270                     }
01271                     else
01272                     {
01273                         // if clicked with right mouse button, toggle grid's select state
01274                         if (ClickMods.Adjust)
01275                             GridClicked->SetGridSelected(!GridClicked->IsGridSelected());
01276                         else
01277                         {
01278                             // Otherwise clear selection, then set clicked grid to be selected
01279                             ClearSelection(SpreadClicked);
01280                             GridClicked->SetGridSelected(TRUE);
01281                         }
01282     
01283                         // Render the grid select blobs to reflect the change in its select state
01284                         RenderGridSelectBlobs(GridClicked);
01285                         NodeGrid::RecalcNumSelectedGrids(SpreadClicked);
01286                         DialogBarOp::SetSystemStateChanged();
01287                     }
01288                 }
01289             }
01290             else
01291             {
01292                 ClearSelection(SpreadClicked);
01293                 GridClicked->SetGridSelected(TRUE);
01294                 GridBlobClicked = NoGridBlob;
01295                 GridClicked     = NULL;
01296                 NodeGrid::RecalcNumSelectedGrids(SpreadClicked);
01297                 DialogBarOp::SetSystemStateChanged();
01298             }
01299         }
01300         else
01301         {
01302             // if no grid clicked on, clear the selection
01303             ClearSelection(SpreadClicked);
01304             NodeGrid::RecalcNumSelectedGrids(SpreadClicked);
01305             DialogBarOp::SetSystemStateChanged();
01306         }
01307 
01308         // Make sure pointer shape and status bar text are correct
01309         OnMouseMove(PointerPos, pSpread, ClickMods);
01310 
01311         // Make sure the controls are shaded correctly
01312         pGridInfoBarOp->EnableControls();
01313     }
01314 
01315     if ( Click == CLICKTYPE_DRAG )
01316     {
01317         if ((GridClicked != NULL) && (GridBlobClicked == NoGridBlob))
01318         {
01319             // Is it a drag on a selected grid using the left mouse button?
01320             if (GridClicked->IsGridSelected() && !ClickMods.Adjust)
01321             {
01322                 // Drag the selection around
01323                 OpGridSelection* pOpGridSelection = new OpGridSelection;
01324                 if (pOpGridSelection != NULL)
01325                 {
01326                     // Start the drag operation and pass in the Anchor Point to the push operation
01327                     pOpGridSelection->DoDrag(SpreadClicked,PointClicked,GridClicked);
01328                 }
01329             }
01330         }
01331         else
01332         {
01333             // Create/Resize a grid
01334             OpGridNewResize* pOpGridNewResize = new OpGridNewResize;
01335             if (pOpGridNewResize != NULL)
01336             {
01337                 if (GridBlobClicked == NoGridBlob)      // if no blob clicked, we're creating a new grid
01338                     ClearSelection(SpreadClicked);      // so clear selection
01339 
01340                 // Start the drag operation
01341                 OpGridNewResize::StartADrag = TRUE;
01342                 OpGridNewResize::EndTheDrag = TRUE;
01343                 pOpGridNewResize->DoDrag(SpreadClicked,GridClicked,GridBlobClicked,PointClicked);
01344             }
01345         }
01346     }
01347 }

void GridTool::OnMouseMove DocCoord  PointerPos,
Spread pSpread,
ClickModifiers  mods
[virtual]
 

To handle a Mouse Move event for the Grid Tool. It changes the cursor dependant on were it is in relation to grids in the spread The status bar is filled with a relevent piece of text.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
Parameters:
PointerPos - The DocCoord of the point where the mouse has moved to [INPUTS] pSpread - The spread in which the move occurred mods - which buttons/keys are down
Returns:
TRUE if it handled the Click, FALSE otherwise
See also:
Tool::MouseClick; ClickType; ClickModifiers

Reimplemented from Tool_v1.

Definition at line 1366 of file gridtool.cpp.

01367 {
01368 //  if (IsUserName("MarkN")) TRACE( _T("GridTool::OnMouseMove\n"));
01369 
01370     NodeGrid*       pGrid;
01371     GridBlobType    GridBlob;
01372     Cursor*         pCursor=NULL;
01373     UINT32          StatusID = _R(IDS_NOGRID);
01374 
01375     // Is pointer over a grid blob?
01376     if (WhichGridBlobClicked(pSpread,PointerPos,&pGrid,&GridBlob))
01377     {
01378         switch (GridBlob)
01379         {
01380             case BottomLeft     :   pCursor  = pcOverBlobCursorTR;
01381                                     StatusID = _R(IDS_BOTTOMLEFTHANDLE);
01382                                     break;
01383             case TopRight       :   pCursor  = pcOverBlobCursorTR;
01384                                     StatusID = _R(IDS_TOPRIGHTHANDLE);
01385                                     break;
01386             case TopLeft        :   pCursor  = pcOverBlobCursorTL;
01387                                     StatusID = _R(IDS_TOPLEFTHANDLE);
01388                                     break;
01389             case BottomRight    :   pCursor  = pcOverBlobCursorTL;
01390                                     StatusID = _R(IDS_BOTTOMRIGHTHANDLE);
01391                                     break;
01392             case LeftMiddle     :   pCursor  = pcOverBlobCursorLR;
01393                                     StatusID = _R(IDS_LEFTHANDLE);
01394                                     break;
01395             case RightMiddle    :   pCursor  = pcOverBlobCursorLR;
01396                                     StatusID = _R(IDS_RIGHTHANDLE);
01397                                     break;
01398             case TopMiddle      :   pCursor  = pcOverBlobCursorUD;
01399                                     StatusID = _R(IDS_TOPHANDLE);
01400                                     break;
01401             case BottomMiddle   :   pCursor  = pcOverBlobCursorUD;
01402                                     StatusID = _R(IDS_BOTTOMHANDLE);
01403                                     break;
01404         }
01405     }
01406     else
01407     {
01408         // If not, see if it is over a grid
01409         if (WhichGridClicked(pSpread,PointerPos,&pGrid))
01410         {
01411             if (pGrid->IsDefault())
01412             {
01413                 pCursor = pcNormalGridCursor;
01414                 if (pGrid->IsGridSelected())
01415                     StatusID = _R(IDS_SELDEFAULT);
01416                 else
01417                     StatusID = _R(IDS_UNSELDEFAULT);
01418             }
01419             else
01420             {
01421                 pCursor = pcOverGridCursor;
01422                 if (pGrid->IsGridSelected())
01423                     StatusID = _R(IDS_SELGRID);
01424                 else
01425                     StatusID = _R(IDS_UNSELGRID);
01426             }
01427         }
01428         else
01429         {
01430             pCursor = pcNormalGridCursor;
01431             StatusID = _R(IDS_NOGRID);
01432         }
01433     }
01434 
01435     if (pCursor != pcCurrentCursor)
01436     {
01437         // We're using the wrong shape!! 
01438         pcCurrentCursor = pCursor;
01439         CursorStack::GSetTop(pcCurrentCursor, CurrentCursorID);
01440     }
01441 
01442     GridTool::DisplayStatusBarHelp(StatusID);
01443 }

void GridTool::RenderAllGridBlobs  )  [private]
 

Update the GridTool's controls on the info bar. Handles UI events from the Zoom Tool's gadgets on the info bar. Shows the grid blobs of all the grids in the current view.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/2/94
Parameters:
- [INPUTS]
Returns:
-
See also:

Definition at line 659 of file gridtool.cpp.

00660 {
00661     DocView* pDocView = DocView::GetCurrent();          // Get ptr to current doc view
00662     if (pDocView == NULL) return;                       // If no current doc, return
00663     if (pDocView->GetDoc() == NULL) return;             // If no doc attached to current view, return
00664     Document* pDoc = pDocView->GetDoc();                // get ptr to the doc
00665     pDoc->SetCurrent();                                 // Make sure this doc becomes the current doc
00666 
00667 
00668     // Now we need to scan all spreads throughout the current doc view's doc.
00669 
00670     Chapter* pChapter = Node::FindFirstChapter(pDoc);
00671     while (pChapter != NULL)
00672     {
00673         // For each chapter in the doc...
00674         Node* pNode = pChapter->FindFirstChild();
00675         while (pNode != NULL)
00676         {
00677             // If the child node of the chapter is a spread...
00678             if (pNode->IsKindOf(CC_RUNTIME_CLASS(Spread)))
00679             {
00680                 Spread* pSpread = (Spread*)pNode;
00681 
00682                 DocRect BB = pSpread->GetPasteboardRect();
00683                 pSpread->DocCoordToSpreadCoord(&BB);
00684 
00685                 // BB is now the bounding rect of the spread
00686                 // Now render all grids within this spread
00687                 RenderGridBlobsInSpread(pDocView,pSpread,&BB);
00688             }
00689             pNode = pNode->FindNext();
00690         }
00691         pChapter = pChapter->FindNextChapter();
00692     }
00693 }    

void GridTool::RenderAllGridBlobs NodeGrid pGrid  )  [static]
 

Renders the full compliment of blobs for the given grid. This means bounding rect AND select blobs are rendered. The routine works out what spread it belongs to and tries to render the blobs in the current doc view.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/2/94
Parameters:
pGrid = ptr to a grid [INPUTS]
Returns:
-
See also:

Definition at line 882 of file gridtool.cpp.

00883 {
00884     RenderGridBlobs(pGrid);
00885     RenderGridSelectBlobs(pGrid);
00886 }

void GridTool::RenderGridBlobs NodeGrid pGrid  )  [static, private]
 

EORs the bounding rectangle blob of the given grid. The routine works out what spread it belongs to and tries to render the blobs in the current doc view.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/2/94
Parameters:
pGrid = ptr to a grid [INPUTS]
Returns:
-
See also:

Definition at line 780 of file gridtool.cpp.

00781 {
00782     DocView* pDocView;
00783     Spread* pSpread;
00784     DocRect Rect;
00785     
00786     // Get the current doc view, the parent spread of the grid, and the spread bounds
00787     if (!GetGridBlobRenderVars(pGrid,&pDocView,&pSpread,&Rect)) return;
00788 
00789 //  DocRect BB = pGrid->GetBoundingRect();   // get local copy of grid bounds
00790 
00791     // Start a 'render on top' loop so we can EOR our select blobs on
00792     RenderRegion* pRender = pDocView->RenderOnTop(&Rect,pSpread,UnclippedEOR);
00793 
00794     // Render grid EOR select blobs for each render region
00795     while (pRender != NULL)
00796     {
00797         RenderGridBlobs(pRender,pGrid);
00798         pRender = pDocView->GetNextOnTop(&Rect);
00799     }
00800 }

void GridTool::RenderGridBlobs RenderRegion pRender,
NodeGrid pGrid
[static, private]
 

Renders the blobs (i.e. the bounding rect) of the given grid.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/2/94
Parameters:
pRender = ptr to a render region [INPUTS] pGrid = ptr to the grid node
Returns:
-
See also:

Definition at line 753 of file gridtool.cpp.

00754 {
00755     if (!pGrid->IsDefault())
00756     {
00757         DocRect Rect = pGrid->GetBoundingRect();
00758 
00759         pRender->SetLineColour(COLOUR_GRID);
00760         pRender->SetFillColour(COLOUR_TRANS);
00761         pRender->DrawRect(&Rect);
00762     }
00763 }

void GridTool::RenderGridBlobsInSpread DocView pDocView,
Spread pSpread,
DocRect pDocRect
[static, private]
 

EORs the blobs of all the grids in the given spread viewed through the given doc view.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/2/94
Parameters:
pDocView = ptr to the doc view to render grid blobs in [INPUTS] pSpread = spread containing grids to be rendered pDocRect = bounding rect of spread defining which area of the spread view needs updating
Returns:
-
See also:

Definition at line 710 of file gridtool.cpp.

00711 {
00712 
00713     // Get a render region on the spread.  We need to render EORd stuff on top of the current view
00714     RenderRegion* pRender = pDocView->RenderOnTop(pDocRect,pSpread,UnclippedEOR);
00715 
00716     while (pRender != NULL)
00717     {
00718         // scan the children of the spread for grids
00719         Node* pNode = pSpread->FindFirstChild();
00720         while (pNode != NULL)
00721         {
00722             if (pNode->IsKindOf(CC_RUNTIME_CLASS(NodeGrid)))
00723             {
00724                 // we now have a ptr to a grid, so render those blobs
00725                 NodeGrid* pGrid = (NodeGrid*)pNode;
00726                 RenderGridBlobs(pRender,pGrid);
00727                 // if the grid is selected, show this by rendering the select blobs
00728                 if (pGrid->IsGridSelected() && !pGrid->IsDefault())
00729                     RenderGridSelectBlobs(pRender,pGrid);
00730             }
00731             pNode = pNode->FindNext();
00732         }
00733 
00734         // get the next render region
00735         pRender = pDocView->GetNextOnTop(pDocRect);
00736     }
00737 }

void GridTool::RenderGridSelectBlobs NodeGrid pGrid  )  [static, private]
 

Shows the selection blobs of the given grid. The routine works out what spread it belongs to and tries to render the blobs in the current doc view.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/2/94
Parameters:
pGrid = ptr to a grid [INPUTS]
Returns:
-
See also:

Definition at line 844 of file gridtool.cpp.

00845 {
00846     DocView* pDocView;
00847     Spread* pSpread;
00848     DocRect Rect;
00849     
00850     // Get the current doc view, the parent spread of the grid, and the spread bounds
00851     if (!GetGridBlobRenderVars(pGrid,&pDocView,&pSpread,&Rect)) return;
00852 
00853 //  DocRect BB = pGrid->GetBoundingRect();   // get local copy of grid bounds
00854 
00855     // Start a 'render on top' loop so we can EOR our select blobs on
00856     RenderRegion* pRender = pDocView->RenderOnTop(&Rect,pSpread,UnclippedEOR);
00857 
00858     // Render grid EOR select blobs for each render region
00859     while (pRender != NULL)
00860     {
00861         RenderGridSelectBlobs(pRender,pGrid);
00862         pRender = pDocView->GetNextOnTop(&Rect);
00863     }
00864 }

void GridTool::RenderGridSelectBlobs RenderRegion pRender,
NodeGrid pGrid
[static, private]
 

Shows the selection blobs of the given grid in the given render region.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/2/94
Parameters:
pRender = ptr to a render region [INPUTS] pGrid = ptr to a grid node
Returns:
-
See also:

Definition at line 816 of file gridtool.cpp.

00817 {
00818     if (!pGrid->IsDefault())
00819     {
00820         // Make sure the line and fill colours are correct
00821         pRender->SetLineColour(COLOUR_NONE);
00822         pRender->SetFillColour(COLOUR_UNSELECTEDBLOB);
00823 
00824         for(INT32 i = BottomLeft;i < NumGridBlobTypes;i++)
00825             pRender->DrawBlob(pGrid->GetBlobCoord((GridBlobType)i),BT_UNSELECTED);
00826     }
00827 }

void GridTool::RenderToolBlobs Spread pSpread,
DocRect pDocRect
[virtual]
 

Handles the RenderToolBlobs method. Renders the tool's blobs into the current doc view.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/2/94
Parameters:
pSpread = ptr to a spread [INPUTS] pDocRect = ptr to DocRect of spread to render in
Returns:
-
See also:

Reimplemented from Tool_v1.

Definition at line 949 of file gridtool.cpp.

00950 {
00951 //  if (IsUserName("MarkN")) TRACE( _T("GridTool::RenderToolBlobs\n"));
00952 
00953     // Render into the selected doc view
00954     DocView* pDocView = DocView::GetSelected();
00955     if (pDocView != NULL)
00956         RenderGridBlobsInSpread(pDocView,pSpread,pDocRect);
00957 }

void GridTool::SelectChange BOOL  isSelected  )  [virtual]
 

Creates/destroys/pushes/pops the rectangle tool's cursor.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/2/94
Parameters:
isSelected - TRUE = tool has been selected [INPUTS]
  • FALSE = tool has been deselected
- [OUTPUTS]
Returns:
-

Errors: Debug warning if creating the cursor fails.

See also:
-

Reimplemented from Tool_v1.

Definition at line 347 of file gridtool.cpp.

00348 {
00349     if (isSelected)
00350     {
00351         // Make sure my idea of the current document is correct
00352         GridTool::SetDoc(Document::GetCurrent());
00353 
00354         if (!CreateCursors()) return;
00355 
00356         CurrentCursorID = CursorStack::GPush(pcNormalGridCursor, FALSE);        // Push cursor but don't display now
00357         pcCurrentCursor = pcNormalGridCursor;
00358 
00359         // Make all grids visible
00360         if (DocView::GetSelected() != NULL)
00361         {
00362             if (!DocView::GetSelected()->GetShowGridState())
00363                 NodeGrid::ForceRedrawAllGrids();    // Redraw all grids
00364             else
00365                 RenderAllGridBlobs();               // Just EOR their blobs on
00366         }
00367 
00368         GridTool::FindCurrentSpread();
00369         //CurrentTool = TRUE;
00370 
00371         // Create and display the tool's info bar
00372         pGridInfoBarOp->Create();
00373 
00374 
00375         OpDescriptor* pOpDesc;
00376 
00377         // Find the pre-registered OpDescs that we're interested in and
00378         // alias them with an alternative op and GetState
00379         pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_DELETE);
00380         if (pOpDesc != NULL) pOpDesc->AliasOperation(CC_RUNTIME_CLASS(OpGridDelete),OpGridDelete::GetState);
00381 
00382         pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_CUT);
00383         if (pOpDesc != NULL) pOpDesc->AliasOperation(CC_RUNTIME_CLASS(OpGridCut),NoClipboardOpGetState);
00384 
00385         pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_COPY);
00386         if (pOpDesc != NULL) pOpDesc->AliasOperation(CC_RUNTIME_CLASS(OpGridCopy),NoClipboardOpGetState);
00387 
00388         pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_PASTE);
00389         if (pOpDesc != NULL) pOpDesc->AliasOperation(CC_RUNTIME_CLASS(OpGridPaste),NoClipboardOpGetState);
00390 
00391         pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_DUPLICATE);
00392         if (pOpDesc != NULL) pOpDesc->AliasOperation(CC_RUNTIME_CLASS(OpGridDuplicate),OpGridDuplicate::GetState);
00393     }
00394     else
00395     {
00396         // Deselection - destroy the tool's cursors, if they exist.
00397         if (pcCurrentCursor != NULL)
00398         {
00399             CursorStack::GPop(CurrentCursorID);
00400             delete pcNormalGridCursor;
00401             delete pcOverGridCursor;
00402             delete pcOverBlobCursorUD;
00403             delete pcOverBlobCursorLR;
00404             delete pcOverBlobCursorTL;
00405             delete pcOverBlobCursorTR;
00406             pcCurrentCursor = NULL;
00407             CurrentCursorID = 0;
00408         }
00409         // EOR off all grid blobs before exiting
00410         if (DocView::GetSelected() != NULL)
00411         {
00412             if (!DocView::GetSelected()->GetShowGridState())
00413                 NodeGrid::ForceRedrawAllGrids();
00414             else
00415                 RenderAllGridBlobs();
00416         }
00417 
00418         // Remove the info bar from view by deleting the actual underlying window
00419         pGridInfoBarOp->Delete();
00420         //CurrentTool = FALSE;
00421         SpreadClicked = NULL;
00422     }
00423 }

void GridTool::SetDoc Document pThisDoc  )  [static]
 

Updates the grid tool's idea of what is the relevant doc. If the doc is different to the last one we had, then make sure the default units are correct for this doc, and init the controls in the info bar to take into account the new doc.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/7/94
Parameters:
pThisDoc = ptr to a document. This should be the current doc. [INPUTS]
- [OUTPUTS]
Returns:
-
This function relies on being called properly when the current doc changes. This is done via the grid tool infobar message handler
See also:
-

Definition at line 445 of file gridtool.cpp.

00446 {
00447     if (GridTool::pDocument != pThisDoc)
00448     {
00449         GridTool::pDocument = pThisDoc;
00450         if (GridTool::pDocument != NULL)
00451             NodeGrid::SetDefaultUnits(GridTool::pDocument->GetDocUnitList()->GetPageUnits());
00452         else
00453             NodeGrid::SetDefaultUnits(NOTYPE);
00454 
00455         GridTool::FindCurrentSpread();
00456         pGridInfoBarOp->InitControls();
00457         pGridInfoBarOp->DisplayDefaultGridInfo();
00458     }
00459 }

void GridTool::ToggleDefaultGrid  )  [static]
 

Creates a grid covering the whole spread. The grid is defined using the default parameters.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/5/94
Parameters:
pSpread = spread in which to make the Default grid [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
-

Definition at line 1460 of file gridtool.cpp.

01461 {
01462     if (SpreadClicked == NULL) return;
01463 
01464     // scan the children of the current spread for grids
01465     Node* pNode = SpreadClicked->FindFirstChild();
01466     while (pNode != NULL)
01467     {
01468         if (pNode->IsKindOf(CC_RUNTIME_CLASS(NodeGrid)))
01469         {
01470             // we now have a ptr to a grid, so render those blobs
01471             NodeGrid* pGrid = (NodeGrid*)pNode;
01472             if (pGrid->IsDefault())
01473             {
01474                 if (pGrid->IsDisabled())
01475                 {
01476                     pGrid->SetDisabled(FALSE);
01477                     ForceRedraw(pGrid);
01478                     ClearSelection(SpreadClicked);
01479                     pGrid->SetGridSelected(TRUE);
01480                 }
01481                 else
01482                 {
01483                     ForceRedraw(pGrid);
01484                     pGrid->SetDisabled(TRUE);
01485                 }
01486             }
01487         }
01488         pNode = pNode->FindNext();
01489     }
01490 }

BOOL GridTool::WhichGridBlobClicked Spread pSpread,
const DocCoord PointerPos,
NodeGrid **  ppGrid,
GridBlobType pGridBlob
[private]
 

Scans the grids in the spread to see which grid select blob was clicked (if any).

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/2/94
Parameters:
pSpread = ptr to a spread [INPUTS] PointerPos = pointer pos in spread coords
*ppGrid - see 'Returns' [OUTPUTS] pGridBlob - see 'Returns'
Returns:
TRUE - *ppGrid = ptr to the NodeGrid which contains the point pGridBlob = the grid blob that was clicked FALSE - *ppGrid = NULL pGridBlob = NoGridBlob
See also:

Definition at line 1125 of file gridtool.cpp.

01127 {
01128     // Init reference vars
01129     *ppGrid     = NULL;
01130     *pGridBlob = NoGridBlob;
01131 
01132     DocView *pDocView = DocView::GetCurrent();
01133     if (pDocView==NULL) return FALSE;
01134 
01135     // Start from the last node in the spread, so top grid is checked before the one behind it, etc
01136     Node* pNode = pSpread->FindLastChild();
01137     while ((pNode != NULL) && (*ppGrid == NULL))
01138     {
01139         if (pNode->IsKindOf(CC_RUNTIME_CLASS(NodeGrid)))
01140         {
01141             NodeGrid* pGrid = (NodeGrid*)pNode;
01142             
01143             if (pGrid->IsGridSelected() && !pGrid->IsDisabled())
01144             {
01145                 DocRect CornerBlob;
01146                 DocCoord BlobCoord;
01147 
01148                 for (INT32 i=BottomLeft;(i<NumGridBlobTypes) && (*ppGrid == NULL);i++)
01149                 {
01150                     BlobCoord = pGrid->GetBlobCoord((GridBlobType)i);
01151                     OSRenderRegion::GetBlobRect(pDocView->GetViewScale(),BlobCoord,BT_SELECTEDLARGEST,&CornerBlob);
01152 
01153                     // Check for collision with the control points
01154                     if (CornerBlob.ContainsCoord(PointerPos))
01155                     {
01156                         *ppGrid = pGrid;
01157                         *pGridBlob = (GridBlobType)i;
01158                     }
01159                 }
01160             }
01161         }
01162         // Scan back along the sibling list
01163         pNode = pNode->FindPrevious();
01164     }
01165     // Return whether a grid was found or not
01166     return (*ppGrid != NULL);
01167 }

BOOL GridTool::WhichGridClicked Spread pSpread,
const DocCoord PointerPos,
NodeGrid **  ppGrid
[private]
 

Scans the grids in the spread to see which one was clicked in (if any) Disabled grids are ignored.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/2/94
Parameters:
pSpread = ptr to a spread [INPUTS] PointerPos = pointer pos in spread coords
*ppGrid - see 'Returns' [OUTPUTS]
Returns:
TRUE - *ppGrid = ptr to the NodeGrid which contains the point FALSE - *ppGrid = NULL
See also:

Definition at line 1079 of file gridtool.cpp.

01080 {
01081     // Init reference vars
01082     *ppGrid = NULL;
01083 
01084     // Start from the last node in the spread, so top grid is checked before the one behind it, etc
01085     Node* pNode = pSpread->FindLastChild();
01086     while ((pNode != NULL) && (*ppGrid == NULL))
01087     {
01088         if (pNode->IsKindOf(CC_RUNTIME_CLASS(NodeGrid)))
01089         {
01090             NodeGrid* pGrid = (NodeGrid*)pNode;
01091             
01092             if (!pGrid->IsDisabled())
01093             {
01094                 if (pGrid->GetBoundingRect().ContainsCoord(PointerPos))
01095                     *ppGrid = pGrid;
01096             }
01097         }
01098         // Scan back along the sibling list
01099         pNode = pNode->FindPrevious();
01100     }
01101     // Return whether a grid was found or not
01102     return (*ppGrid != NULL);
01103 }


Member Data Documentation

char * GridTool::Author = "Mark Neves" [static, private]
 

Definition at line 206 of file gridtool.h.

INT32 GridTool::CurrentCursorID [private]
 

Definition at line 201 of file gridtool.h.

GridType GridTool::DefaultGridType [static]
 

Definition at line 145 of file gridtool.h.

char * GridTool::FamilyName = "Grid Tools" [static, private]
 

Definition at line 203 of file gridtool.h.

GridBlobType GridTool::GridBlobClicked = NoGridBlob [static, private]
 

Definition at line 187 of file gridtool.h.

NodeGrid * GridTool::GridClicked = NULL [static, private]
 

Definition at line 186 of file gridtool.h.

NodeGrid * GridTool::LastGridClicked = NULL [static, private]
 

Definition at line 188 of file gridtool.h.

UINT32 GridTool::LastStatusID = 0 [static, private]
 

Definition at line 190 of file gridtool.h.

Cursor* GridTool::pcCurrentCursor [private]
 

Definition at line 200 of file gridtool.h.

Cursor* GridTool::pcNormalGridCursor [private]
 

Definition at line 194 of file gridtool.h.

Cursor* GridTool::pcOverBlobCursorLR [private]
 

Definition at line 197 of file gridtool.h.

Cursor* GridTool::pcOverBlobCursorTL [private]
 

Definition at line 198 of file gridtool.h.

Cursor* GridTool::pcOverBlobCursorTR [private]
 

Definition at line 199 of file gridtool.h.

Cursor* GridTool::pcOverBlobCursorUD [private]
 

Definition at line 196 of file gridtool.h.

Cursor* GridTool::pcOverGridCursor [private]
 

Definition at line 195 of file gridtool.h.

Document * GridTool::pDocument = NULL [static, private]
 

Definition at line 192 of file gridtool.h.

GridInfoBarOp * GridTool::pGridInfoBarOp = NULL [static, private]
 

Definition at line 191 of file gridtool.h.

DocCoord GridTool::PointClicked [static, private]
 

Definition at line 185 of file gridtool.h.

char * GridTool::Purpose = "Grid manipulation" [static, private]
 

Definition at line 205 of file gridtool.h.

Spread * GridTool::SpreadClicked = NULL [static, private]
 

Definition at line 184 of file gridtool.h.

char * GridTool::ToolName = "Grid Tool" [static, private]
 

Definition at line 204 of file gridtool.h.


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