Creating the tool

Much of the source for the TCanavsPolygonCreationTool is either "boilerplate" (which requires little change) or is inherited from the cursor tools framework. You modify the following relevant functions for your tool:

GetPaletteText

As with all cursor tools, override the GetPaletteText function to provide the text associated with this particular tool. Change the text to the name of your tool.

      void
      TCanvasPolygonCreationTool::GetPaletteText (TText& theText) const
      {
          theText.Replace (TStandardText("Polygon"));
      }

TCanvasPolygonCreation Tool

Similarly, as with all cursor tools, override the CreatePaletteGraphic function to provide an
MGraphic associated with this particular tool. You could use this graphic in a tool palette. Although not required, you could provide a graphic for your tool here.

      MGraphic*
      TCanvasPolygonCreationTool::CreatePaletteGraphic () const
      {
          return NIL;
      }

CreateCursorGraphic

As with the CreatePaletteGraphic function, override the CreateCursorGraphic function to provide an
MGraphic associated with this particular tool. GrafEdit applications use this graphic to change the look of the cursor when it is over an area where you can use the tool. Although not required, having a unique graphic for each tool helps users realize what the current tool is.

      // Copyright (C) 1995 Taligent, Inc. All rights reserved.
      MGraphic*
      TCanvasPolygonCreationTool::CreateCursorGraphic () const
      {
          TGPolygon crossHair (12);
      
          crossHair.SetPoint (0,TGPoint(-1,7));
          crossHair.SetPoint (1,TGPoint(1,7));
          crossHair.SetPoint (2,TGPoint(1,1));
          crossHair.SetPoint (3,TGPoint(7,1));
          crossHair.SetPoint (4,TGPoint(7,-1));
          crossHair.SetPoint (5,TGPoint(1,-1));
          crossHair.SetPoint (6,TGPoint(1,-7));
          crossHair.SetPoint (7,TGPoint(-1,-7));
          crossHair.SetPoint (8,TGPoint(-1,-1));
          crossHair.SetPoint (9,TGPoint(-7,-1));
          crossHair.SetPoint (10,TGPoint(-7,1));
          crossHair.SetPoint (11,TGPoint(-1,1));
          
          TRGBColor black(0,0,0),white(1,1,1);
          TGrafBundle* bundle = new TGrafBundle(new TColorPaint(black),new TColorPaint(white));
              
          return new TPolygon (crossHair, bundle);
      }

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker