|
Scroom 0.14-48-ga0fee447
|
#include <rulerstrategies.hh>


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 | |
| Interface & | operator= (const Interface &)=delete |
| Interface (Interface &&)=delete | |
| Interface & | operator= (Interface &&)=delete |
| virtual | ~Interface ()=default |
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.
| using RulerDrawStrategy::Ptr = std::shared_ptr<RulerDrawStrategy> |
|
pure virtual |
Draws the outline around the ruler.
| cr | Cairo context to draw to. |
| lineWidth | Width of the outline in pixels. |
Implemented in HorizontalDrawStrategy, and VerticalDrawStrategy.
|
pure virtual |
Draws the line for a ruler tick.
| cr | Cairo context to draw to. |
| linePosition | Position of the line along the ruler in pixels. |
| lineWidth | Width of the tick line in pixels. |
| lineLength | Length of the tick line in pixels. |
| width | Allocated width for the ruler in pixels. |
| height | Allocated height for the ruler in pixels. |
Implemented in HorizontalDrawStrategy, and VerticalDrawStrategy.
|
pure virtual |
Draws the label to the right of a tick line.
| cr | Cairo context to draw to. |
| label | Text to draw to right of tick line. |
| linePosition | Position of the line along the ruler in pixels. |
| labelOffset | Offset between tick line and label in pixels. |
| labelAlign | Alignment of label along tick line as a fraction of line length. |
| lineLength | Length of the tick line in pixels. |
| width | Allocated width for the ruler in pixels. |
| height | Allocated height for the ruler in pixels. |
Implemented in HorizontalDrawStrategy, and VerticalDrawStrategy.
|
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.
| width | Allocated width for the ruler in pixels. |
| height | Allocated height for the ruler in pixels. |
Implemented in HorizontalDrawStrategy, and VerticalDrawStrategy.
| int RulerDrawStrategy::getHeight | ( | ) | const |
Returns the allocated height.
Referenced by HorizontalDrawStrategy::drawOutline(), VerticalDrawStrategy::drawOutline(), HorizontalDrawStrategy::drawTickLine(), HorizontalDrawStrategy::drawTickText(), VerticalDrawStrategy::getDrawAreaSize(), and HorizontalDrawStrategy::getMajorTickLength().

|
pure virtual |
Returns the length of the major tick lines, given the ruler dimensions.
| width | Allocated width for the ruler in pixels. |
| height | Allocated height for the ruler in pixels. |
| percentage | Percentage of the /p width or /p height to be the length of the major ticks. |
Implemented in HorizontalDrawStrategy, and VerticalDrawStrategy.
| int RulerDrawStrategy::getWidth | ( | ) | const |
Returns the allocated width.
Referenced by HorizontalDrawStrategy::drawOutline(), VerticalDrawStrategy::drawOutline(), VerticalDrawStrategy::drawTickLine(), VerticalDrawStrategy::drawTickText(), HorizontalDrawStrategy::getDrawAreaSize(), and VerticalDrawStrategy::getMajorTickLength().

| void RulerDrawStrategy::setAllocatedSize | ( | int | newWidth, |
| int | height | ||
| ) |
|
private |
|
staticconstexprprotected |
|
staticconstexprprotected |
Referenced by HorizontalDrawStrategy::drawTickText(), and VerticalDrawStrategy::drawTickText().
|
private |