JX Application Framework
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | List of all members
JPainter Class Referenceabstract

#include <JPainter.h>

Inheritance diagram for JPainter:
[legend]

Public Types

enum struct  HAlign {
  kLeft ,
  kCenter ,
  kRight
}
 
enum struct  VAlign {
  kTop ,
  kCenter ,
  kBottom
}
 

Public Member Functions

 JPainter (JFontManager *fontManager, const JRect &defaultClipRect)
 
virtual ~JPainter ()
 
JFontManagerGetFontManager () const
 
virtual void Reset ()
 
void Reset (const JRect &defClipRect)
 
virtual void ResetAllButClipping ()
 
const JRectGetClipRect () const
 
virtual JRect SetClipRect (const JRect &r)
 
void ResetClipRect ()
 
const JRectGetDefaultClipRect () const
 
void SetDefaultClipRect (const JRect &r)
 
const JPointGetOrigin () const
 
void SetOrigin (const JCoordinate x, const JCoordinate y)
 
void SetOrigin (const JPoint &pt)
 
void ShiftOrigin (const JCoordinate dx, const JCoordinate dy)
 
void ShiftOrigin (const JPoint &delta)
 
const JPointGetPenLocation () const
 
void SetPenLocation (const JCoordinate x, const JCoordinate y)
 
void SetPenLocation (const JPoint &pt)
 
void ShiftPenLocation (const JCoordinate dx, const JCoordinate dy)
 
void ShiftPenLocation (const JPoint &delta)
 
JColorID GetPenColor () const
 
void SetPenColor (const JColorID color)
 
JSize GetLineWidth () const
 
void SetLineWidth (const JSize width)
 
bool LinesAreDashed () const
 
void DrawDashedLines (const bool on)
 
bool GetDashList (const JArray< JSize > **dashList, JSize *dashOffset) const
 
virtual void SetDashList (const JArray< JSize > &dashList, const JSize dashOffset=0)
 
bool IsFilling () const
 
void SetFilling (const bool on)
 
const JFontGetFont () const
 
void SetFontName (const JString &name)
 
void SetFontSize (const JSize size)
 
void SetFontStyle (const JFontStyle &style)
 
void SetFont (const JFont &f)
 
JSize GetLineHeight (JCoordinate *ascent, JCoordinate *descent) const
 
JSize GetLineHeight () const
 
JSize GetStringWidth (const JString &str) const
 
void String (const JCoordinate left, const JCoordinate top, const JString &str, const JCoordinate width=0, const HAlign hAlign=HAlign::kLeft, const JCoordinate height=0, const VAlign vAlign=VAlign::kTop)
 
void String (const JPoint &topLeft, const JString &str, const JCoordinate width=0, const HAlign hAlign=HAlign::kLeft, const JCoordinate height=0, const VAlign vAlign=VAlign::kTop)
 
void String (const JRect &rect, const JString &str, const HAlign hAlign=HAlign::kLeft, const VAlign vAlign=VAlign::kTop)
 
virtual void String (const JFloat angle, const JCoordinate left, const JCoordinate top, const JString &str, const JCoordinate width=0, const HAlign hAlign=HAlign::kLeft, const JCoordinate height=0, const VAlign vAlign=VAlign::kTop)=0
 
void String (const JFloat angle, const JPoint &topLeft, const JString &str, const JCoordinate width=0, const HAlign hAlign=HAlign::kLeft, const JCoordinate height=0, const VAlign vAlign=VAlign::kTop)
 
void String (const JFloat angle, const JRect &rect, const JString &str, const HAlign hAlign=HAlign::kLeft, const VAlign vAlign=VAlign::kTop)
 
virtual void StringNoSubstitutions (const JCoordinate left, const JCoordinate top, const JString &str)=0
 
virtual void Point (const JCoordinate x, const JCoordinate y)=0
 
void Point (const JPoint &pt)
 
virtual void Line (const JCoordinate x1, const JCoordinate y1, const JCoordinate x2, const JCoordinate y2)=0
 
void Line (const JPoint &pt1, const JPoint &pt2)
 
void LineTo (const JCoordinate x, const JCoordinate y)
 
void LineTo (const JPoint &pt)
 
void DeltaLine (const JCoordinate dx, const JCoordinate dy)
 
void DeltaLine (const JPoint &delta)
 
virtual void Rect (const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h)=0
 
void Rect (const JPoint &upperLeft, const JCoordinate w, const JCoordinate h)
 
void Rect (const JRect &bounds)
 
void RectInside (const JRect &bounds)
 
virtual void Ellipse (const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h)=0
 
void Ellipse (const JPoint &upperLeft, const JCoordinate w, const JCoordinate h)
 
void Ellipse (const JRect &bounds)
 
virtual void Arc (const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h, const JFloat startAngle, const JFloat deltaAngle)=0
 
void Arc (const JPoint &upperLeft, const JCoordinate w, const JCoordinate h, const JFloat startAngle, const JFloat deltaAngle)
 
void Arc (const JRect &bounds, const JFloat startAngle, const JFloat deltaAngle)
 
virtual void Polygon (const JCoordinate left, const JCoordinate top, const JPolygon &poly)=0
 
void Polygon (const JPoint &upperLeft, const JPolygon &poly)
 
void Polygon (const JPolygon &poly)
 
void Image (const JImage &image, const JRect &srcRect, const JCoordinate left, const JCoordinate top)
 
void Image (const JImage &image, const JRect &srcRect, const JPoint &topLeft)
 
virtual void Image (const JImage &image, const JRect &srcRect, const JRect &destRect)=0
 

Protected Member Functions

JSize AlignString (JCoordinate *left, JCoordinate *top, const JString &str, const JCoordinate width, const HAlign hAlign, const JCoordinate height, const VAlign vAlign) const
 

Detailed Description

This class abstracts the functions required to draw to the screen and
to a printer.  Derived classes must implement the following functions:

SetClipRect
    Set the rectangle that drawing will be clipped to.

String
    The first version draws text horizontally inside the specified
    rectangle with the specified horizontal and vertical alignment.
    The second version draws rotated text.  This routine is only
    required to handle rotations of 0, 90, 180, and 270 degrees.

Point
    Draw a point.

Line
    Draw a line between the two specified points.  Call SetPenLocation()
    with the ending point.

Rect
    Draw the specified rectangle.  If IsFilled() returns true,
    fill the rectangle.

Ellipse
    Draw an ellipse inside the specified rectangle.  If IsFilled()
    returns true, fill the ellipse.

Arc
    Draw the specified arc inside the specified rectangle.  startAngle
    follows the usual convention of zero degrees on the positive x-axis and
    increases counterclockwise.  deltaAngle tells how much of the arc
    to draw (in degrees) and is positive in the counterclockwise direction.
    If IsFilled() returns true, fill the ellipse as a pie slice.

Polygon
    Draw the specified polygon, including the closing line from the
    last vertex to the first vertex.  top and left specify the offset of
    the vertices relative to the current origin.  If IsFilled() returns true,
    fill the polygon.

Image
    Draw the portion of the image specified by srcRect into the
    given destRect.

Member Enumeration Documentation

◆ HAlign

enum struct JPainter::HAlign
strong
Enumerator
kLeft 
kCenter 
kRight 

◆ VAlign

enum struct JPainter::VAlign
strong
Enumerator
kTop 
kCenter 
kBottom 

Constructor & Destructor Documentation

◆ JPainter()

JPainter::JPainter ( JFontManager fontManager,
const JRect defaultClipRect 
)

◆ ~JPainter()

JPainter::~JPainter ( )
virtual

Member Function Documentation

◆ AlignString()

JSize JPainter::AlignString ( JCoordinate left,
JCoordinate top,
const JString str,
const JCoordinate  width,
const HAlign  hAlign,
const JCoordinate  height,
const VAlign  vAlign 
) const
protected

Adjust the given coordinates as appropriate for the given alignment. Returns the width of the string, if it was computed.

◆ Arc() [1/3]

virtual void JPainter::Arc ( const JCoordinate  x,
const JCoordinate  y,
const JCoordinate  w,
const JCoordinate  h,
const JFloat  startAngle,
const JFloat  deltaAngle 
)
pure virtual

◆ Arc() [2/3]

void JPainter::Arc ( const JPoint upperLeft,
const JCoordinate  w,
const JCoordinate  h,
const JFloat  startAngle,
const JFloat  deltaAngle 
)
inline

◆ Arc() [3/3]

void JPainter::Arc ( const JRect bounds,
const JFloat  startAngle,
const JFloat  deltaAngle 
)
inline

◆ DeltaLine() [1/2]

void JPainter::DeltaLine ( const JCoordinate  dx,
const JCoordinate  dy 
)
inline

◆ DeltaLine() [2/2]

void JPainter::DeltaLine ( const JPoint delta)
inline

◆ DrawDashedLines()

void JPainter::DrawDashedLines ( const bool  on)
inline

◆ Ellipse() [1/3]

virtual void JPainter::Ellipse ( const JCoordinate  x,
const JCoordinate  y,
const JCoordinate  w,
const JCoordinate  h 
)
pure virtual

◆ Ellipse() [2/3]

void JPainter::Ellipse ( const JPoint upperLeft,
const JCoordinate  w,
const JCoordinate  h 
)
inline

◆ Ellipse() [3/3]

void JPainter::Ellipse ( const JRect bounds)
inline

◆ GetClipRect()

const JRect & JPainter::GetClipRect ( ) const
inline

◆ GetDashList()

bool JPainter::GetDashList ( const JArray< JSize > **  dashList,
JSize dashOffset 
) const
inline

◆ GetDefaultClipRect()

const JRect & JPainter::GetDefaultClipRect ( ) const
inline

◆ GetFont()

const JFont & JPainter::GetFont ( ) const
inline

◆ GetFontManager()

JFontManager * JPainter::GetFontManager ( ) const
inline

◆ GetLineHeight() [1/2]

JSize JPainter::GetLineHeight ( ) const

◆ GetLineHeight() [2/2]

JSize JPainter::GetLineHeight ( JCoordinate ascent,
JCoordinate descent 
) const

◆ GetLineWidth()

JSize JPainter::GetLineWidth ( ) const
inline

◆ GetOrigin()

const JPoint & JPainter::GetOrigin ( ) const
inline

◆ GetPenColor()

JColorID JPainter::GetPenColor ( ) const
inline

◆ GetPenLocation()

const JPoint & JPainter::GetPenLocation ( ) const
inline

◆ GetStringWidth()

JSize JPainter::GetStringWidth ( const JString str) const

◆ Image() [1/3]

void JPainter::Image ( const JImage image,
const JRect srcRect,
const JCoordinate  left,
const JCoordinate  top 
)
inline

◆ Image() [2/3]

void JPainter::Image ( const JImage image,
const JRect srcRect,
const JPoint topLeft 
)
inline

◆ Image() [3/3]

virtual void JPainter::Image ( const JImage image,
const JRect srcRect,
const JRect destRect 
)
pure virtual

◆ IsFilling()

bool JPainter::IsFilling ( ) const
inline

◆ Line() [1/2]

virtual void JPainter::Line ( const JCoordinate  x1,
const JCoordinate  y1,
const JCoordinate  x2,
const JCoordinate  y2 
)
pure virtual

◆ Line() [2/2]

void JPainter::Line ( const JPoint pt1,
const JPoint pt2 
)
inline

◆ LinesAreDashed()

bool JPainter::LinesAreDashed ( ) const
inline

◆ LineTo() [1/2]

void JPainter::LineTo ( const JCoordinate  x,
const JCoordinate  y 
)
inline

◆ LineTo() [2/2]

void JPainter::LineTo ( const JPoint pt)
inline

◆ Point() [1/2]

virtual void JPainter::Point ( const JCoordinate  x,
const JCoordinate  y 
)
pure virtual

◆ Point() [2/2]

void JPainter::Point ( const JPoint pt)
inline

◆ Polygon() [1/3]

virtual void JPainter::Polygon ( const JCoordinate  left,
const JCoordinate  top,
const JPolygon poly 
)
pure virtual

◆ Polygon() [2/3]

void JPainter::Polygon ( const JPoint upperLeft,
const JPolygon poly 
)
inline

◆ Polygon() [3/3]

void JPainter::Polygon ( const JPolygon poly)
inline

◆ Rect() [1/3]

virtual void JPainter::Rect ( const JCoordinate  x,
const JCoordinate  y,
const JCoordinate  w,
const JCoordinate  h 
)
pure virtual

◆ Rect() [2/3]

void JPainter::Rect ( const JPoint upperLeft,
const JCoordinate  w,
const JCoordinate  h 
)
inline

◆ Rect() [3/3]

void JPainter::Rect ( const JRect bounds)
inline

◆ RectInside()

void JPainter::RectInside ( const JRect bounds)

Draws a rectangle inside the given frame, instead of centered on it.

◆ Reset() [1/2]

void JPainter::Reset ( )
virtual

Reset parameters that may have been changed and that we have reasonable defaults for.

The second version accepts a default clip rect.

Reimplemented in JXWindowPainter, and JXWindowPainter.

◆ Reset() [2/2]

void JPainter::Reset ( const JRect defClipRect)

◆ ResetAllButClipping()

void JPainter::ResetAllButClipping ( )
virtual

◆ ResetClipRect()

void JPainter::ResetClipRect ( )

◆ SetClipRect()

JRect JPainter::SetClipRect ( const JRect r)
virtual

Reimplemented in JEPSPrinter, JPSPrinter, and JXWindowPainter.

◆ SetDashList()

void JPainter::SetDashList ( const JArray< JSize > &  dashList,
const JSize  dashOffset = 0 
)
virtual

Reimplemented in JEPSPrinter, JPSPrinter, and JXWindowPainter.

◆ SetDefaultClipRect()

void JPainter::SetDefaultClipRect ( const JRect r)

◆ SetFilling()

void JPainter::SetFilling ( const bool  on)
inline

◆ SetFont()

void JPainter::SetFont ( const JFont f)
inline

◆ SetFontName()

void JPainter::SetFontName ( const JString name)
inline

◆ SetFontSize()

void JPainter::SetFontSize ( const JSize  size)
inline

◆ SetFontStyle()

void JPainter::SetFontStyle ( const JFontStyle style)
inline

◆ SetLineWidth()

void JPainter::SetLineWidth ( const JSize  width)

◆ SetOrigin() [1/2]

void JPainter::SetOrigin ( const JCoordinate  x,
const JCoordinate  y 
)
inline

◆ SetOrigin() [2/2]

void JPainter::SetOrigin ( const JPoint pt)
inline

◆ SetPenColor()

void JPainter::SetPenColor ( const JColorID  color)
inline

◆ SetPenLocation() [1/2]

void JPainter::SetPenLocation ( const JCoordinate  x,
const JCoordinate  y 
)
inline

◆ SetPenLocation() [2/2]

void JPainter::SetPenLocation ( const JPoint pt)
inline

◆ ShiftOrigin() [1/2]

void JPainter::ShiftOrigin ( const JCoordinate  dx,
const JCoordinate  dy 
)
inline

◆ ShiftOrigin() [2/2]

void JPainter::ShiftOrigin ( const JPoint delta)
inline

◆ ShiftPenLocation() [1/2]

void JPainter::ShiftPenLocation ( const JCoordinate  dx,
const JCoordinate  dy 
)
inline

◆ ShiftPenLocation() [2/2]

void JPainter::ShiftPenLocation ( const JPoint delta)
inline

◆ String() [1/6]

void JPainter::String ( const JCoordinate  left,
const JCoordinate  top,
const JString str,
const JCoordinate  width = 0,
const HAlign  hAlign = HAlign::kLeft,
const JCoordinate  height = 0,
const VAlign  vAlign = VAlign::kTop 
)

◆ String() [2/6]

virtual void JPainter::String ( const JFloat  angle,
const JCoordinate  left,
const JCoordinate  top,
const JString str,
const JCoordinate  width = 0,
const HAlign  hAlign = HAlign::kLeft,
const JCoordinate  height = 0,
const VAlign  vAlign = VAlign::kTop 
)
pure virtual

◆ String() [3/6]

void JPainter::String ( const JFloat  angle,
const JPoint topLeft,
const JString str,
const JCoordinate  width = 0,
const HAlign  hAlign = HAlign::kLeft,
const JCoordinate  height = 0,
const VAlign  vAlign = VAlign::kTop 
)
inline

◆ String() [4/6]

void JPainter::String ( const JFloat  angle,
const JRect rect,
const JString str,
const HAlign  hAlign = HAlign::kLeft,
const VAlign  vAlign = VAlign::kTop 
)

◆ String() [5/6]

void JPainter::String ( const JPoint topLeft,
const JString str,
const JCoordinate  width = 0,
const HAlign  hAlign = HAlign::kLeft,
const JCoordinate  height = 0,
const VAlign  vAlign = VAlign::kTop 
)
inline

◆ String() [6/6]

void JPainter::String ( const JRect rect,
const JString str,
const HAlign  hAlign = HAlign::kLeft,
const VAlign  vAlign = VAlign::kTop 
)
inline

◆ StringNoSubstitutions()

virtual void JPainter::StringNoSubstitutions ( const JCoordinate  left,
const JCoordinate  top,
const JString str 
)
pure virtual

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