ubit::UGraph Class Reference

class for drawing graphics in UBox view(s). More...

#include <ugraph.hpp>

List of all members.

Public Member Functions

 UGraph (UView &)
 UGraph (UMouseEvent &)
 UGraph (UPaintEvent &)
 creates a new UGraph object.
 UGraph (UHardWinImpl &)
 Impl.
UViewgetView () const
 returns the View where the graphics are being drawn.
UDispgetDisp () const
 returns the Display where the graphics are being drawn.
void flush ()
 flushes all drawing requests.
void setPaintMode ()
void setXORMode (const UColor &background_color)
bool isXORMode () const
 set/get the drawing mode.
void setColor (const UColor &)
 set the paint color.
void setBackground (const UColor &)
 sets the color of the background.
bool hasAlpha () const
 indicates if alpha blending is supported by this UGraph.
float getAlpha () const
void setAlpha (float a)
 changes alpha factor (no effect if hasAlpha() returns false).
void setFont (const UFont &)
void setFont (const UFontDesc &)
 sets the current Font.
UFontMetrics getFontMetrics (const UFont &)
UFontMetrics getFontMetrics (const UFontDesc &)
 return the corresponding Font Metrics.
float getWidth () const
void setWidth (float)
 changes line width when drawing lines, etc.
void clearRect (float x, float y, float width, float height, bool paint=false)
 clears or repaints a rectangle.
void clearView (bool paint=false)
 same as clearRect() but clears or repaint the entire view.
void copyArea (int x, int y, int width, int height, int delta_x, int delta_y, bool paint_events_when_obscured)
void draw (const UShape &)
 copies a rectangular area (X11 only, does not work with OpenGL). draws a shape.
void drawArc (float x, float y, float width, float height, float start_ang, float ext_ang)
 draws a circular or elliptical arc.
void drawIma (const UIma &, float x, float y, float scale=1.)
 draws this image with this scale.
void drawLine (float x1, float y1, float x2, float y2)
 draws a line.
void drawPolyline (float xpoints[], float ypoints[], int card)
void drawPolyline (std::vector< float > xpoints, std::vector< float > ypoints, int card)
 draws a sequence of connected lines.
void drawPolygon (float xpoints[], float ypoints[], int card)
void drawPolygon (std::vector< float > xpoints, std::vector< float > ypoints, int card)
 draws a polygon (which is automatically closed).
void drawOval (float x, float y, float width, float height)
 draws an ellipse or a circle that fits in this rectangle.
void drawRect (float x, float y, float width, float height)
 draws a rectangle.
void drawRoundRect (float x, float y, float width, float height, float arc_w, float arc_h)
 draws a round-cornered rectangle.
void drawString (const UStr &string, float x, float y)
void drawString (const char *string, int length, float x, float y)
 draw a character string.
void fillArc (float x, float y, float width, float height, float start_ang, float ext_ang)
 fills an arc of a circle (or a complete circle).
void fillOval (float x, float y, float width, float height)
 fills an ellipse or a circle that fits in this rectangle.
void fillPolygon (float xpoints[], float ypoints[], int card)
void fillPolygon (std::vector< float > xpoints, std::vector< float > ypoints, int card)
 fills a polygon (which is automatically closed).
void fillRect (float x, float y, float width, float height)
 fills the rectangle.
void fillRoundRect (float x, float y, float width, float height, float arc_w, float arc_h)
 fills a round-cornered rectangle.
void fillView ()
 fills the whole View.
int XToXwin (int x_in_view)
int YToYwin (int y_in_view)
 conve0rsion from local View coords to global Window coords.
int XwinToX (int x_in_win)
int YwintoY (int y_in_win)
 conversion from global Window coords to local View coords.
void setClip (const URegion &)
void setClip (int x, int y, int width, int height)
 set the clipping zone relatively to the origin of the VIEW.
void setWinClip (const URegion &)
void setWinClip (int x, int y, int width, int height)
 set the clipping zone relatively to the origin of the WINDOW.
void getWinClip (URegion &)
 get the clipping zone relatively to the origin of the WINDOW.
void getWinOffset (int &x, int &y)
void setWinOffset (int x, int y)
UHardWinImpl * getHardWinImpl () const
UNatGraphgetNatGraph () const
UNatDispgetNatDisp () const
UNatWingetNatWin () const
 [impl] gives acces to implementation-dependent hidden objects.
bool isUsing3d () const
void drawNatIma (const UNatIma &, float x, float y)
void drawNatPix (const UNatPix &, float x, float y)
 implementation.
void drawNatGLIma (const UNatIma &, float x, float y, float scale=1.)
 [requires OpenGL lib] implementation.


Detailed Description

class for drawing graphics in UBox view(s).


Constructor & Destructor Documentation

ubit::UGraph::UGraph ( UPaintEvent  ) 

creates a new UGraph object.

Example:

     void paintCB(UEvent& e, Data* data) {
         UGraph g(e);
         g.drawLine(...);
     }

     Data* data = ...;     // Data can be on any type
     UBox* box = ...;
     box->add(UOn::paint / ucall(data, paintCB))
 

Notes:


Member Function Documentation

void ubit::UGraph::clearRect ( float  x,
float  y,
float  width,
float  height,
bool  paint = false 
)

clears or repaints a rectangle.

fills this area with the background color if 'paint' is false. repaints the subpart of the view contained in this area is 'paint' is true (see also: UView::update())

void ubit::UGraph::draw ( const UShape &   ) 

copies a rectangular area (X11 only, does not work with OpenGL). draws a shape.

copies a rectangular area of size (width,height) at location (x,y) to a location shifted by delta_x, delta_y
Notes:

void ubit::UGraph::drawArc ( float  x,
float  y,
float  width,
float  height,
float  start_ang,
float  ext_ang 
)

draws a circular or elliptical arc.

'x,y,width,height' are the top/left position and size of the enclosing rectangle 'start_ang' is the beginning angle and 'ext_ang' the extent of the arc relative to 'start_ang'. Angles are in degrees.

void ubit::UGraph::drawOval ( float  x,
float  y,
float  width,
float  height 
)

draws an ellipse or a circle that fits in this rectangle.

'x,y,width,height' are the top/left position and size of the enclosing rectangle

void ubit::UGraph::drawRoundRect ( float  x,
float  y,
float  width,
float  height,
float  arc_w,
float  arc_h 
)

draws a round-cornered rectangle.

arc_w, arc_h are the horiz/vert diameters of the arc at the 4 corners

void ubit::UGraph::drawString ( const char *  string,
int  length,
float  x,
float  y 
)

draw a character string.

these functions use the current Font (see setFont()).

void ubit::UGraph::fillArc ( float  x,
float  y,
float  width,
float  height,
float  start_ang,
float  ext_ang 
)

fills an arc of a circle (or a complete circle).

same parameters as drawArc()

void ubit::UGraph::fillOval ( float  x,
float  y,
float  width,
float  height 
)

fills an ellipse or a circle that fits in this rectangle.

same parameters as drawOval()

void ubit::UGraph::fillPolygon ( std::vector< float >  xpoints,
std::vector< float >  ypoints,
int  card 
)

fills a polygon (which is automatically closed).

must be a convex polygon if GL is used

void ubit::UGraph::fillRect ( float  x,
float  y,
float  width,
float  height 
)

fills the rectangle.

note that this fct fills exactly 'width' and 'height' pixels. Hence, the region that is actually covered is the rectangle (x, y, x+width-1, y+height-1).

See also:
also: drawRect()

void ubit::UGraph::fillRoundRect ( float  x,
float  y,
float  width,
float  height,
float  arc_w,
float  arc_h 
)

fills a round-cornered rectangle.

See also:
fillRect() and drawRoundRect() for details.

UFontMetrics ubit::UGraph::getFontMetrics ( const UFontDesc  ) 

return the corresponding Font Metrics.

Note: the UFontDesc must not be destroyed while the returned UFontMetrics is used.

UNatWin * ubit::UGraph::getNatWin (  )  const

[impl] gives acces to implementation-dependent hidden objects.

Note: these "Native Objects" encapsulate platform-dependant data. their implementation is subject to change and to vary depending on the native platform.

bool ubit::UGraph::hasAlpha (  )  const

indicates if alpha blending is supported by this UGraph.

alpha blending is supported if the Ubit toolkit was compiled with the GL library: see UAppli::getGraphLib() and UGraph::setAlpha().

bool ubit::UGraph::isXORMode (  )  const

set/get the drawing mode.

PaintMode (the default) overwrites pixels with the foreground color. XORMode alternates the current foreground and background colors

void ubit::UGraph::setAlpha ( float  a  ) 

changes alpha factor (no effect if hasAlpha() returns false).

is alpha in range [0.,1.]
Note: Alpha blending is supported if the Ubit toolkit was compiled with the GL library: see UAppli::getGraphLib() and UGraph::hasAlpha().

void ubit::UGraph::setBackground ( const UColor  ) 

sets the color of the background.

used by setXORMode(), clearRect(), clearView()

void ubit::UGraph::setWidth ( float   ) 

changes line width when drawing lines, etc.

in X11 mode the default value is 0 this will draw 1 pixel width lines in an optimized mode


The documentation for this class was generated from the following files:
Generated on Mon Jan 29 00:20:50 2007 for Ubit by  doxygen 1.4.7