Public Member Functions

mxgui::DrawingContext Class Reference
[Mxgui level 1]

#include <display.h>

List of all members.

Public Member Functions

 DrawingContext (Display &display)
void write (Point p, const char *text)
void clippedWrite (Point p, Point a, Point b, const char *text)
void clear (Color color)
void clear (Point p1, Point p2, Color color)
void beginPixel ()
void setPixel (Point p, Color color)
void line (Point a, Point b, Color color)
void scanLine (Point p, const Color *colors, unsigned short length)
void drawImage (Point p, const ImageBase &img)
void clippedDrawImage (Point p, Point a, Point b, const ImageBase &img)
void drawRectangle (Point a, Point b, Color c)
short int getHeight () const
short int getWidth () const
void setTextColor (Color fgcolor, Color bgcolor)
Color getForeground () const
Color getBackground () const
void setFont (const Font &font)
Font getFont () const
 ~DrawingContext ()

Detailed Description

A drawing context is a class that is instantiated whenever there is the need to draw something on a display. Its primary purpose is to lock a mutex allowing safe concurrent access to a display from multiple threads, but avoiding the overhead of locking a mutex for each single graphic primitive call.


Constructor & Destructor Documentation

mxgui::DrawingContext::DrawingContext ( Display display  ) 

Constructor

Parameters:
display the display on which you want to draw
mxgui::DrawingContext::~DrawingContext (  ) 

Destructor


Member Function Documentation

void mxgui::DrawingContext::beginPixel (  ) 

This member function is used on some target displays to reset the drawing window to its default value. You have to call beginPixel() once before calling setPixel(). You can then make any number of calls to setPixel() without calling beginPixel() again, as long as you don't call any other member function in this class. If you call another member function, for example line(), you have to call beginPixel() again before calling setPixel().

void mxgui::DrawingContext::clear ( Color  color  ) 

Clear the Display. The screen will be filled with the desired color

Parameters:
color fill color
void mxgui::DrawingContext::clear ( Point  p1,
Point  p2,
Color  color 
)

Clear an area of the screen

Parameters:
p1 upper left corner of area to clear
p2 lower right corner of area to clear
color fill color
void mxgui::DrawingContext::clippedDrawImage ( Point  p,
Point  a,
Point  b,
const ImageBase img 
)

Draw part of an image on the screen

Parameters:
p point of the upper left corner where the image will be drawn. Negative coordinates are allowed, as long as the clipped view has positive or zero coordinates
a Upper left corner of clipping rectangle
b Lower right corner of clipping rectangle
img Image to draw
void mxgui::DrawingContext::clippedWrite ( Point  p,
Point  a,
Point  b,
const char *  text 
)

Write part of text to the display

Parameters:
p point of the upper left corner where the text will be drawn. Negative coordinates are allowed, as long as the clipped view has positive or zero coordinates
a Upper left corner of clipping rectangle
b Lower right corner of clipping rectangle
text text to write
void mxgui::DrawingContext::drawImage ( Point  p,
const ImageBase img 
)

Draw an image on the screen

Parameters:
p point of the upper left corner where the image will be drawn
img image to draw
void mxgui::DrawingContext::drawRectangle ( Point  a,
Point  b,
Color  c 
)

Draw a rectangle (not filled) with the desired color

Parameters:
a upper left corner of the rectangle
b lower right corner of the rectangle
c color of the line
Color mxgui::DrawingContext::getBackground (  )  const
Returns:
the current background color. The foreground color is used to draw text on screen
Font mxgui::DrawingContext::getFont (  )  const
Returns:
the current font used to draw text
Color mxgui::DrawingContext::getForeground (  )  const
Returns:
the current foreground color. The foreground color is used to draw text on screen
short int mxgui::DrawingContext::getHeight (  )  const
Returns:
the display's height
short int mxgui::DrawingContext::getWidth (  )  const
Returns:
the display's width
void mxgui::DrawingContext::line ( Point  a,
Point  b,
Color  color 
)

Draw a line between point a and point b, with color c

Parameters:
a first point
b second point
color line color
void mxgui::DrawingContext::scanLine ( Point  p,
const Color colors,
unsigned short  length 
)

Draw an horizontal line on screen. Instead of line(), this member function takes an array of colors to be able to individually set pixel colors of a line.

Parameters:
p starting point of the line
colors an array of pixel colors whoase size must be b.x()-a.x()+1
length length of colors array. p.x()+length must be <= display.width()
void mxgui::DrawingContext::setFont ( const Font font  ) 

Set the font used for writing text

Parameters:
font new font
void mxgui::DrawingContext::setPixel ( Point  p,
Color  color 
)

Draw a pixel with desired color. You have to call beginPixel() once before calling setPixel()

Parameters:
p point where to draw pixel
color pixel color
void mxgui::DrawingContext::setTextColor ( Color  fgcolor,
Color  bgcolor 
)

Set colors used for writing text

Parameters:
fgcolor text color
bgcolor background color
void mxgui::DrawingContext::write ( Point  p,
const char *  text 
)

Write text to the display. If text is too long it will be truncated

Parameters:
p point where the upper left corner of the text will be printed
text,text to print.

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