RulerBase Class Reference

Common base class for a ruler (X and Y derived). More...

#include <rulers.h>

Inheritance diagram for RulerBase:

HorizontalRuler VerticalRuler List of all members.

Public Member Functions

 RulerBase ()
 Constructor for RulerBase class.
virtual ~RulerBase ()
RulerPairGetpRulerPair ()
OILRulerGetpOILRuler ()
virtual MILLIPOINT GetOrd (const UserCoord &coord)=0
virtual UserCoord MakeCoord (const MILLIPOINT ord)=0
virtual BOOL IsHorizontal ()=0
BOOL Redraw (OilRect *pOilRect)
 Redraw a region of a ruler.
virtual BOOL GetStatusLineText (String_256 *pText, OilCoord PointerPos)
 Allows tools to override the ruler help text.
virtual BOOL OnRulerClick (OilCoord, ClickType, ClickModifiers)
 Convert click coordinates into DocCoords and pass them on to the current tool.
BOOL HighlightSection (MILLIPOINT ord_lo, MILLIPOINT ord_hi)
 Highlight a rectangular section of the ruler.
BOOL DrawBitmap (MILLIPOINT ord, ResourceID BitmapID)
 Draw a bitmap at a specific position in the ruler.
BOOL StartToolDrag (ClickModifiers Mods, UserCoord, String_256 *pOpToken, OpParam *pParam)
 Allows tools to start a drag operation on the ruler.

Protected Member Functions

UserCoord OilToToolCoords (OilCoord PointerPos, Spread *pSpread)
 Allows tools to override the ruler help text.

Protected Attributes

RulerPairpRulerPair
OILRulerpOILRuler

Private Member Functions

 CC_DECLARE_MEMDUMP (RulerBase)

Detailed Description

Common base class for a ruler (X and Y derived).

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/8/95

Definition at line 125 of file rulers.h.


Constructor & Destructor Documentation

RulerBase::RulerBase  ) 
 

Constructor for RulerBase class.

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/8/95

Definition at line 150 of file rulers.cpp.

00151 {
00152 }

virtual RulerBase::~RulerBase  )  [inline, virtual]
 

Definition at line 131 of file rulers.h.

00131 {} // suppress warnings


Member Function Documentation

RulerBase::CC_DECLARE_MEMDUMP RulerBase   )  [private]
 

BOOL RulerBase::DrawBitmap MILLIPOINT  ord,
ResourceID  BitmapID
 

Draw a bitmap at a specific position in the ruler.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
07/07/06
Parameters:
ord - the position on the ruler in tool user space [INPUTS] (i.e., we know about the tool's own ruler origin) BitmapID - the resource id of the bitmap
Returns:
FALSE if fails

Definition at line 307 of file rulers.cpp.

00308 {
00309     DocView*         pDocView = pRulerPair->GetpDocView();
00310     Spread*          pSpread  = pRulerPair->GetpSpread();
00311 
00312     // if no spread visible in doc view, just exit
00313     if (pSpread==NULL) return TRUE;
00314 
00315     // take the current tool ruler origin into account
00316     UserCoord Offsets(0, 0);
00317     if (Tool::GetCurrent())
00318         Tool::GetCurrent()->GetRulerOrigin(pSpread, &Offsets);
00319     ord += GetOrd(Offsets);
00320 
00321     OilCoord OilPos = MakeCoord(ord).ToSpread(pSpread).ToOil(pSpread,pDocView);
00322     return pOILRuler->DrawBitmap(OilPos, BitmapID);
00323 }

virtual MILLIPOINT RulerBase::GetOrd const UserCoord coord  )  [pure virtual]
 

Implemented in HorizontalRuler, and VerticalRuler.

OILRuler* RulerBase::GetpOILRuler  )  [inline]
 

Definition at line 134 of file rulers.h.

00134 { return pOILRuler; }

RulerPair* RulerBase::GetpRulerPair  )  [inline]
 

Definition at line 133 of file rulers.h.

00133 { return pRulerPair; }

BOOL RulerBase::GetStatusLineText String_256 pText,
OilCoord  PointerPos
[virtual]
 

Allows tools to override the ruler help text.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
25/07/06
Parameters:
PointerPos - pointer position in Oil coords [INPUTS]
Returns:
TRUE if text was set
Parameters:
Status text in pText (if return value is TRUE), else undefined [OUTPUTS]

Definition at line 437 of file rulers.cpp.

00438 {
00439     Spread *pSpread = pRulerPair->GetpSpread();
00440     UserCoord UserPos = OilToToolCoords(PointerPos, pSpread);
00441     return (Tool::GetCurrent()) ? Tool::GetCurrent()->GetRulerStatusLineText(pText, UserPos, pSpread, this) : FALSE;
00442 }

BOOL RulerBase::HighlightSection MILLIPOINT  ord_lo,
MILLIPOINT  ord_hi
 

Highlight a rectangular section of the ruler.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
07/07/06
Parameters:
ord_lo,ord_hi - low and high coordinate on the ruler in tool user [INPUTS] space (i.e., we know about the tool's own ruler origin)
Returns:
FALSE if fails

Definition at line 275 of file rulers.cpp.

00276 {
00277     DocView*         pDocView = pRulerPair->GetpDocView();
00278     Spread*          pSpread  = pRulerPair->GetpSpread();
00279 
00280     // if no spread visible in doc view, just exit
00281     if (pSpread==NULL) return TRUE;
00282 
00283     // take the current tool ruler origin into account
00284     UserCoord Offsets(0, 0);
00285     if (Tool::GetCurrent())
00286         Tool::GetCurrent()->GetRulerOrigin(pSpread, &Offsets);
00287     ord_lo += GetOrd(Offsets); ord_hi += GetOrd(Offsets);
00288 
00289     OilCoord OilPosLo = MakeCoord(ord_lo).ToSpread(pSpread).ToOil(pSpread,pDocView);
00290     OilCoord OilPosHi = MakeCoord(ord_hi).ToSpread(pSpread).ToOil(pSpread,pDocView);
00291     return pOILRuler->HighlightSection(OilPosLo, OilPosHi);
00292 }

virtual BOOL RulerBase::IsHorizontal  )  [pure virtual]
 

Implemented in HorizontalRuler, and VerticalRuler.

virtual UserCoord RulerBase::MakeCoord const MILLIPOINT  ord  )  [pure virtual]
 

Implemented in HorizontalRuler, and VerticalRuler.

UserCoord RulerBase::OilToToolCoords OilCoord  PointerPos,
Spread pSpread
[protected]
 

Allows tools to override the ruler help text.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
25/07/06
Parameters:
PointerPos - pointer position in Oil coords [INPUTS]
Returns:
TRUE if text was set
Parameters:
Status text in pText (if return value is TRUE), else undefined [OUTPUTS]

Definition at line 392 of file rulers.cpp.

00393 {
00394     DocView* pDocView = pRulerPair->GetpDocView();
00395 
00396     // First of all convert the OilRect into device coords
00397     DocCoord DocPos = PointerPos.ToDoc(pSpread, pDocView);
00398 
00399     // Convert the coord to spread coords
00400     pSpread->DocCoordToSpreadCoord(&DocPos);
00401     UserCoord UserPos = DocPos.ToUser(pSpread);
00402 
00403     // the insignificant position on the ruler (in the narrow dimension) should not be converted to
00404     // document coordinates - the result makes no sense, but we scale from OIL pixels to User coords
00405     MILLIPOINT PixelSize = pDocView->GetScaledPixelWidth().MakeLong();
00406     if (IsHorizontal())
00407         UserPos.y = MILLIPOINT(PointerPos.y * PixelSize);
00408     else
00409         UserPos.x = MILLIPOINT(PointerPos.x * PixelSize);
00410 
00411     // take the current tool ruler origin into account
00412     UserCoord Offsets(0, 0);
00413     if (Tool::GetCurrent())
00414         Tool::GetCurrent()->GetRulerOrigin(pSpread, &Offsets);
00415 
00416     // Apply the tool origin, but only in the significant direction
00417     if (IsHorizontal())
00418         UserPos.x -= Offsets.x;
00419     else
00420         UserPos.y -= Offsets.y;
00421     return UserPos;
00422 }

BOOL RulerBase::OnRulerClick OilCoord  PointerPos,
ClickType  Click,
ClickModifiers  Mods
[virtual]
 

Convert click coordinates into DocCoords and pass them on to the current tool.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/Jun/2006
Parameters:
PointerPos - Position of click from OS [INPUTS] Click - Type of click (single, double or drag) Mods - Other inputs which modify the meaning of the click

Definition at line 345 of file rulers.cpp.

00346 {
00347     ERROR3IF(pRulerPair==NULL, "pRulerPair unexpectedly NULL");
00348     ERROR3IF(pRulerPair->GetpSpread()==NULL, "pRulerPair->pSpread unexpectedly NULL");
00349     ERROR3IF(pRulerPair->GetpDocView()==NULL, "pRulerPair->pDocView unexpectedly NULL");
00350 
00351     // Ignore if system is disabled
00352     if (CCamApp::IsDisabled())
00353         return FALSE;                               // If the system is disabled, ignore
00354 
00355     // grab the focus if it's stuck in  a control somewhere
00356 //  DialogManager::DefaultKeyboardFocus();  
00357     
00358     // Find the spread in which the click happened
00359     Spread *pSpread = pRulerPair->GetpSpread();
00360 
00361     if (pSpread == NULL)
00362     {
00363         ERROR3("Could not find Ruler pair spread");
00364         return FALSE; // Exit reasonably nicely
00365     }
00366 
00367     // When the user clicks on a spread which is not the selected spread then this spread becomes
00368     // selected and the selection is cleared.
00369     // NOPE! Since this click occurred on a Ruler, not on the page, the Tool::OnRulerClick handler
00370     // must make the choice about setting the selected spread IFF it handles the click
00371 //  Document::SetSelectedViewAndSpread(pDoc, this, pSpread);
00372 
00373     UserCoord UserPos = OilToToolCoords(PointerPos, pSpread);
00374     if (Tool::GetCurrent())
00375         return Tool::GetCurrent()->OnRulerClick(UserPos, Click, Mods, pSpread, this);
00376 
00377     return FALSE;
00378 }

BOOL RulerBase::Redraw OilRect pUpdateOilRect  ) 
 

Redraw a region of a ruler.

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/8/95
Parameters:
pUpdateOilRect - only lox,hix used to determine start/end of portion [INPUTS] of the ruler to be redrawn for horizontal ruler and loy,hiy for vertical ruler
Returns:
FALSE if fails

Definition at line 167 of file rulers.cpp.

00168 {
00169     // get some useful pointers used later
00170     DocView*         pDocView = pRulerPair->GetpDocView();
00171     RulerRedrawData* pRD      = pRulerPair->GetpRedrawData();
00172     Spread*          pSpread  = pRulerPair->GetpSpread();
00173 
00174     // if no spread visible in doc view, just exit
00175     if (pSpread==NULL)
00176         return TRUE;
00177 
00178     // Convert the OilRect to a UserRect and limit to spread's paste board
00179     DocRect drect = pUpdateOilRect->ToDoc(pSpread,pDocView).ToSpread(pSpread,pDocView);
00180     UserRect UpdateRect = drect.ToUser(pSpread);
00181 
00182     // Give the current tool the chance to modify the UserCoord displayed by the ruler
00183     UserCoord Offsets(0, 0);
00184     if (Tool::GetCurrent())
00185         Tool::GetCurrent()->GetRulerOrigin(pSpread, &Offsets);
00186     // We translate the rectangle by the tool-supplied offsets. We do not call UserRect::Translate
00187     // since our rectangle is not necessarily valid due to MakeCoord used in the limit checks above
00188     UpdateRect.lo.x -= Offsets.x;
00189     UpdateRect.lo.y -= Offsets.y;
00190     UpdateRect.hi.x -= Offsets.x;
00191     UpdateRect.hi.y -= Offsets.y;
00192 
00193     MILLIPOINT LoLimit = GetOrd(pRD->PasteBoardUserRect.lo);
00194     MILLIPOINT HiLimit = GetOrd(pRD->PasteBoardUserRect.hi);
00195     if (GetOrd(UpdateRect.lo)<LoLimit) UpdateRect.lo=MakeCoord(LoLimit);
00196     if (GetOrd(UpdateRect.hi)>HiLimit) UpdateRect.hi=MakeCoord(HiLimit);
00197     if (GetOrd(UpdateRect.hi)<GetOrd(UpdateRect.lo))
00198         return TRUE;    // no region to redraw
00199 
00200     // allow the current tool to render background blobs
00201     if (Tool::GetCurrent())
00202         Tool::GetCurrent()->RenderRulerBlobs(this, UpdateRect, TRUE);
00203 
00204     // find the first and last major graticules to be rendered
00205     double Start = GetOrd(UpdateRect.lo)/pRD->GratStepSize;
00206     double End   = GetOrd(UpdateRect.hi)/pRD->GratStepSize;
00207     INT32 FirstGrat = (INT32)floor(Start)*pRD->GratStep;
00208     INT32 LastGrat  = (INT32)ceil(End)*pRD->GratStep;
00209 
00210     // plot each major graticule from the first to the last
00211     String_8 GratLabelText(_T(""));
00212     INT32 Grat=FirstGrat;
00213     while (Grat<=LastGrat)
00214     {
00215         // calc position of graticule and convert to OilCoords
00216         MILLIPOINT GratPos=(MILLIPOINT)(Grat*pRD->GratUnitSize + GetOrd(Offsets));
00217         OilCoord GratOilPos=MakeCoord(GratPos).ToSpread(pSpread).ToOil(pSpread,pDocView);
00218 
00219         // draw major graticule
00220         ERROR3IF(!NEAR_ENOUGH_INTEGER(fabs(Grat*pRD->ScaleFactor)),"RulerBase::Redraw() - Grat label should be integer!");
00221         INT32 GratLabel=MAKE_INTEGER(fabs(Grat*pRD->ScaleFactor));
00222         Convert::LongToString(GratLabel,&GratLabelText);
00223         pOILRuler->DrawMajorGraticule(GratOilPos, (LPCTSTR)GratLabelText);
00224 
00225         // draw minor grats
00226         INT32       MinorGrats   = pRD->MinorGrats;
00227         INT32       MinorGrat    = 1;
00228         MILLIPOINT MinorGratPos = 0;
00229         while (MinorGrat<MinorGrats)
00230         {
00231             INT32 Size=0;
00232             if (MinorGrat*2==MinorGrats) Size+=1;
00233             if (MinorGrats>5)
00234                 if (MinorGrat*4==MinorGrats || MinorGrat*2==MinorGrats || MinorGrat*4==MinorGrats*3) Size+=2;
00235             MinorGratPos = (MILLIPOINT)(GratPos+pRD->MinorGratStepSize*MinorGrat);
00236             GratOilPos   = MakeCoord(MinorGratPos).ToSpread(pSpread).ToOil(pSpread,pDocView);
00237             pOILRuler->DrawMinorGraticule(GratOilPos,Size);
00238             MinorGrat+=1;
00239         }
00240 
00241         // move on to next graticule
00242         Grat+=pRD->GratStep;
00243     }
00244 
00245     // allow the current tool to render foreground blobs
00246     if (Tool::GetCurrent())
00247         Tool::GetCurrent()->RenderRulerBlobs(this, UpdateRect, FALSE);
00248 
00249     // draw the mouse follower on this ruler in it's last drawn position
00250     DocCoord LastPos    = pRulerPair->GetMouseFollowerPosition();
00251     BOOL     Visibility = pRulerPair->GetMouseFollowerVisibility();
00252 
00253     if (Visibility==TRUE)
00254     {
00255         OilCoord LastOilPos = LastPos.ToOil(pSpread,pDocView);
00256         pOILRuler->PaintMouseFollower(LastOilPos, pDocView, RenderOn);
00257     
00258     }
00259 
00260     return TRUE;
00261 }

BOOL RulerBase::StartToolDrag ClickModifiers  Mods,
UserCoord  PointerPos,
String_256 pOpToken,
OpParam pParam
 

Allows tools to start a drag operation on the ruler.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
12/07/06
Parameters:
Mods - click modifiers (as passed to OnRulerClick) [INPUTS] PointerPos - pointer position (as passed to OnRulerClick) pOpToken - name of the operation to invoke for handling the drag pParam - the parameters to pass to the operation

Definition at line 459 of file rulers.cpp.

00461 {
00462     // Find the spread in which the click happened
00463     Spread *pSpread = pRulerPair->GetpSpread();
00464     DocView *pDocView = pRulerPair->GetpDocView();
00465 
00466     // take the current tool ruler origin into account
00467     UserCoord Offsets(0, 0);
00468     if (Tool::GetCurrent())
00469         Tool::GetCurrent()->GetRulerOrigin(pSpread, &Offsets);
00470     PointerPos.translate(Offsets.x, Offsets.y);
00471 
00472     OilCoord OilPos = PointerPos.ToSpread(pSpread).ToOil(pSpread,pDocView);
00473     return pOILRuler->StartToolDrag(Mods, OilPos, pOpToken, pParam);
00474 }


Member Data Documentation

OILRuler* RulerBase::pOILRuler [protected]
 

Definition at line 164 of file rulers.h.

RulerPair* RulerBase::pRulerPair [protected]
 

Definition at line 163 of file rulers.h.


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