Scroom 0.14-49-gb7ae7a6d
Loading...
Searching...
No Matches
RulerDrawStrategy Class Referenceabstract

#include <rulerstrategies.hh>

Inheritance diagram for RulerDrawStrategy:
Inheritance graph
Collaboration diagram for RulerDrawStrategy:
Collaboration graph

Public Types

using Ptr = std::shared_ptr< RulerDrawStrategy >
 

Public Member Functions

virtual double getMajorTickLength (double percentage)=0
 
virtual double getDrawAreaSize ()=0
 
virtual void drawOutline (cairo_t *cr, double lineWidth)=0
 
virtual void drawTickLine (cairo_t *cr, double linePosition, double lineWidth, double lineLength)=0
 
virtual void drawTickText (cairo_t *cr, const std::string &label, double linePosition, double labelOffset, double labelAlign, double lineLength)=0
 
void setAllocatedSize (int newWidth, int height)
 
int getWidth () const
 
int getHeight () const
 

Static Protected Attributes

static constexpr double LINE_COORD_OFFSET {0.5}
 
static constexpr double TEXT_ANCHOR {0.5}
 

Private Attributes

int width {}
 
int height {}
 

Additional Inherited Members

- Private Member Functions inherited from Interface
 Interface ()=default
 
 Interface (const Interface &)=delete
 
Interfaceoperator= (const Interface &)=delete
 
 Interface (Interface &&)=delete
 
Interfaceoperator= (Interface &&)=delete
 
virtual ~Interface ()=default
 

Detailed Description

The Ruler class employs the Strategy pattern to draw the horizontal and vertical ruler. Implementations of this class contain the code to draw the parts of the ruler that need to be oriented differently.

Member Typedef Documentation

◆ Ptr

using RulerDrawStrategy::Ptr = std::shared_ptr<RulerDrawStrategy>

Member Function Documentation

◆ drawOutline()

virtual void RulerDrawStrategy::drawOutline ( cairo_t *  cr,
double  lineWidth 
)
pure virtual

Draws the outline around the ruler.

Parameters
crCairo context to draw to.
lineWidthWidth of the outline in pixels.

Implemented in HorizontalDrawStrategy, and VerticalDrawStrategy.

◆ drawTickLine()

virtual void RulerDrawStrategy::drawTickLine ( cairo_t *  cr,
double  linePosition,
double  lineWidth,
double  lineLength 
)
pure virtual

Draws the line for a ruler tick.

Parameters
crCairo context to draw to.
linePositionPosition of the line along the ruler in pixels.
lineWidthWidth of the tick line in pixels.
lineLengthLength of the tick line in pixels.
widthAllocated width for the ruler in pixels.
heightAllocated height for the ruler in pixels.

Implemented in HorizontalDrawStrategy, and VerticalDrawStrategy.

◆ drawTickText()

virtual void RulerDrawStrategy::drawTickText ( cairo_t *  cr,
const std::string &  label,
double  linePosition,
double  labelOffset,
double  labelAlign,
double  lineLength 
)
pure virtual

Draws the label to the right of a tick line.

Parameters
crCairo context to draw to.
labelText to draw to right of tick line.
linePositionPosition of the line along the ruler in pixels.
labelOffsetOffset between tick line and label in pixels.
labelAlignAlignment of label along tick line as a fraction of line length.
lineLengthLength of the tick line in pixels.
widthAllocated width for the ruler in pixels.
heightAllocated height for the ruler in pixels.

Implemented in HorizontalDrawStrategy, and VerticalDrawStrategy.

◆ getDrawAreaSize()

virtual double RulerDrawStrategy::getDrawAreaSize ( )
pure virtual

Returns the length in pixels along the ruler. For a horizontal ruler, this is its width. For a vertical ruler, this is its height.

Parameters
widthAllocated width for the ruler in pixels.
heightAllocated height for the ruler in pixels.
Returns
The length in pixels along the ruler in pixels.

Implemented in HorizontalDrawStrategy, and VerticalDrawStrategy.

◆ getHeight()

int RulerDrawStrategy::getHeight ( ) const

Returns the allocated height.

Returns
The allocated height.
14{ return height; }
int height
Definition rulerstrategies.hh:104

Referenced by HorizontalDrawStrategy::drawOutline(), VerticalDrawStrategy::drawOutline(), HorizontalDrawStrategy::drawTickLine(), HorizontalDrawStrategy::drawTickText(), VerticalDrawStrategy::getDrawAreaSize(), and HorizontalDrawStrategy::getMajorTickLength().

Here is the caller graph for this function:

◆ getMajorTickLength()

virtual double RulerDrawStrategy::getMajorTickLength ( double  percentage)
pure virtual

Returns the length of the major tick lines, given the ruler dimensions.

Parameters
widthAllocated width for the ruler in pixels.
heightAllocated height for the ruler in pixels.
percentagePercentage of the /p width or /p height to be the length of the major ticks.
Returns
The length of the major tick lines in pixels.

Implemented in HorizontalDrawStrategy, and VerticalDrawStrategy.

◆ getWidth()

int RulerDrawStrategy::getWidth ( ) const

Returns the allocated width.

Returns
The allocated width.
12{ return width; }
int width
Definition rulerstrategies.hh:102

Referenced by HorizontalDrawStrategy::drawOutline(), VerticalDrawStrategy::drawOutline(), VerticalDrawStrategy::drawTickLine(), VerticalDrawStrategy::drawTickText(), HorizontalDrawStrategy::getDrawAreaSize(), and VerticalDrawStrategy::getMajorTickLength().

Here is the caller graph for this function:

◆ setAllocatedSize()

void RulerDrawStrategy::setAllocatedSize ( int  newWidth,
int  height 
)

Sets the allocated newWidth and height for the ruler.

Parameters
newWidthAllocated newWidth for the ruler in pixels.
heightAllocated height for the ruler in pixels.
7{
8 this->width = newWidth;
9 this->height = newHeight;
10}

Member Data Documentation

◆ height

int RulerDrawStrategy::height {}
private

Allocated height for the ruler in pixels.

104{};

Referenced by getHeight(), and setAllocatedSize().

◆ LINE_COORD_OFFSET

constexpr double RulerDrawStrategy::LINE_COORD_OFFSET {0.5}
staticconstexprprotected

◆ TEXT_ANCHOR

constexpr double RulerDrawStrategy::TEXT_ANCHOR {0.5}
staticconstexprprotected

◆ width

int RulerDrawStrategy::width {}
private

Allocated width for the ruler in pixels.

102{};

Referenced by getWidth(), and setAllocatedSize().


The documentation for this class was generated from the following files: