#include <rulers.h>
Inheritance diagram for RulerBase:
Public Member Functions | |
RulerBase () | |
Constructor for RulerBase class. | |
virtual | ~RulerBase () |
RulerPair * | GetpRulerPair () |
OILRuler * | GetpOILRuler () |
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 | |
RulerPair * | pRulerPair |
OILRuler * | pOILRuler |
Private Member Functions | |
CC_DECLARE_MEMDUMP (RulerBase) |
Definition at line 125 of file rulers.h.
|
Constructor for RulerBase class.
Definition at line 150 of file rulers.cpp.
|
|
Definition at line 131 of file rulers.h.
|
|
|
|
Draw a bitmap at a specific position in the ruler.
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 }
|
|
Implemented in HorizontalRuler, and VerticalRuler. |
|
Definition at line 134 of file rulers.h. 00134 { return pOILRuler; }
|
|
Definition at line 133 of file rulers.h. 00133 { return pRulerPair; }
|
|
Allows tools to override the ruler help text.
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 }
|
|
Highlight a rectangular section of the ruler.
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 }
|
|
Implemented in HorizontalRuler, and VerticalRuler. |
|
Implemented in HorizontalRuler, and VerticalRuler. |
|
Allows tools to override the ruler help text.
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 }
|
|
Convert click coordinates into DocCoords and pass them on to the current tool.
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 }
|
|
Redraw a region of a ruler.
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 }
|
|
Allows tools to start a drag operation on the ruler.
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 }
|
|
|
|
|