Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

UGraph Class Reference

client class for drawing graphics. More...

#include <ugraph.hpp>

Inheritance diagram for UGraph:

UWinGraph List of all members.

Public Member Functions

 UGraph (class UView *)
 UGraph (class UEvent *)
 UGraph (class UEvent &)
 creates a new UGraph for drawing in the UView given as an explicit or implicit argument

UViewgetView () const
 returns the current View where graphics are being drawn.

UDispgetDisp () const
 returns the logical Display of this View.

UAppligetAppli () const
 returns the Application context.

void setColor (const UColor *)
void setColor (const UColor &)
 sets the Foreground color

void setBgcolor (const UColor *)
void setBgcolor (const UColor &)
 sets the Background color

void setFont (const UFont *)
void setFont (const UFont &)
void setFont (const UFontDesc &)
 sets the current Font

void setCursor (const UCursor *)
void setCursor (const UCursor &)
 changes the mouse Cursor.

bool isXORMode ()
void setXORMode ()
void setPaintMode ()
void setThickness (int=0)
 these functions set the drawing mode.

int getThickness ()
 changes line thickness when drawing lines, etc

void setClip (const URegion &)
void setClip (u_pos x, u_pos y, u_dim width, u_dim height)
 set the clipping zone relatively to VIEW coordinates

void setWinClip (const URegion &)
void setWinClip (u_pos x, u_pos y, u_dim width, u_dim height)
 set the clipping zone relatively to WINDOW coordinates

void flush ()
 flushes all drawing requests (when applicable).

int grabPointer (class UCursor *=null, bool confine_to_window=false)
 starts a "physical grab" on the X server

void ungrabPointer ()
 ends a "physical grab" on the X server.

u_pos XToXwin (u_pos x_in_view)
u_pos YToYwin (u_pos y_in_view)
 conversion from local View coords to global Window coords.

u_pos XwinToX (u_pos x_in_win)
u_pos YwintoY (u_pos y_in_win)
 conversion from global Window coords to local View coords.

void clearRect (u_pos x, u_pos y, u_dim width, u_dim height, bool repaint_view=false)
 clears a rectangle

void clearView (bool repaint_view=false)
 same as clearRect() but clears the entire view.

void copyArea (u_pos x, u_pos y, u_dim width, u_dim height, u_dim delta_x, u_dim delta_y, bool generate_refresh_events_when_obscured)
void drawArc (u_pos x, u_pos y, u_dim width, u_dim height, float from_angle, float arc_angle)
 copies a rectangular area.

void drawEllipse (u_pos x, u_pos y, u_dim width, u_dim height)
 draws an ellipse or an arc of an ellipse

void drawLine (u_pos x1, u_pos y1, u_pos x2, u_pos y2)
 draws a line.

void drawPoint (u_pos x, u_pos y)
 draws a point.

void drawPolyline (u_pos xpoints[], u_pos ypoints[], u_count card)
void drawPolyline (std::vector< u_pos > xpoints, std::vector< u_pos > ypoints, u_count card)
 draws a sequence of connected lines.

void drawPolygon (u_pos xpoints[], u_pos ypoints[], u_count card)
void drawPolygon (std::vector< u_pos > xpoints, std::vector< u_pos > ypoints, u_count card)
 draws a polygon (which is automatically closed).

void drawRect (u_pos x, u_pos y, u_dim width, u_dim height)
 draws a rectangle.

void drawString (const UStr &, u_pos x, u_pos y)
void drawString (const UStr *, u_pos x, u_pos y)
void drawString (const char *, int str_length, u_pos x, u_pos y)
 draw a character string

void fillArc (u_pos x, u_pos y, u_dim width, u_dim height, float from_angle, float arc_angle)
 fills an arc of a circle (or a complete circle)

void fillPolygon (u_pos xpoints[], u_pos ypoints[], u_count card, int mode=0)
void fillPolygon (std::vector< u_pos > xpoints, std::vector< u_pos > ypoints, u_count card, int mode=0)
 fills a polygon (which is automatically closed)

void fillRect (u_pos x, u_pos y, u_dim width, u_dim height)
 fills the area.

void fillView ()
 fills the whole View.

void drawIma (const class UNatIma *, u_pos x, u_pos y)
void drawIma (const class UNatPix *, u_pos x, u_pos y)
bool getCharDefaultSize (const UFont &, int &w, int &h) const
bool getCharDefaultSize (const UFontDesc &, int &w, int &h) const
void getTextSize (const UFont &, const UStr &, u_dim &width, u_dim &height) const
void getTextSize (const UFontDesc &, const char *str, int str_len, u_dim &width, u_dim &height) const
u_dim getTextHeight (const UFont &) const
u_dim getTextHeight (const UFontDesc &) const
u_dim getTextWidth (const UFont &, const UStr &) const
u_dim getTextWidth (const UFontDesc &, const char *str, int str_len) const
 returns font metrics.

int getCharPos (const UFontDesc &, const char *str, int str_len, u_pos x) const
int getXPos (const UFontDesc &, const char *str, int str_len, int char_pos) const
 converts x pos to char pos and vice-versa.

bool getClippedText (const char *s, int len, u_pos x0, u_pos y0, int &charpos_begin, int &charpos_end, u_pos &xpos_begin, u_pos &xpos_end) const
 returns the substring that is enclosed in the current clip.

bool getSubTextSize (const UFontDesc &, const char *str, int str_len, u_dim &w, u_dim &h, u_dim available_width, int &sublen, int &change_line) const
 returns font metrics of a substring that verifies certain conditions

int getSubTextSize (const UFontDesc *, const char *str, int str_len, u_dim maxwidth, u_dim chw, u_dim *w, u_dim *h) const
 returns font metrics of a substring (obsolete version).

UNatWin * createBuffer (u_dim width, u_dim height)
 creates an off-screen pixmap.

void deleteBuffer (class UNatWin *)
 deletes an off-screen pixmap.

UNatGraphgetNatGraph () const
UWinGraphgetWinGraph () const
UNatDisp * getNatDisp () const
UNatWin * getNatWin () const
 gives acces to implementation-dependent hidden objects


Static Public Member Functions

void getImaSize (class UNatIma *, u_dim &w, u_dim &h)
void getPixSize (class UNatPix *, u_dim &w, u_dim &h)

Detailed Description

client class for drawing graphics.

!Warning: client should not use the UWinGraph class (which is reserved for the Ubit lib)


Constructor & Destructor Documentation

UGraph::UGraph class UEvent  ) 
 

creates a new UGraph for drawing in the UView given as an explicit or implicit argument

Function:

  • UGraph(UView*) allocates physical resources for drawing in this View
  • UGraph(UEvent*) allocates resources for drawing in the source View that is relative to this Event (see: UEvent::getView()) and sets the clipping area according to UEvent::redrawClip when applicable. This makes it possible to redraw just the subpart of the View that needs to be refreshed.

Typical usage:
void callback_function(UEvent& e) {
UGraph g(e);
g.drawLine(...);
}

Notes:

  • as UGraph objects allocates physical resources, they should be created in the stack (as in the previous example) in order to be released as soon as possible. Creating several UGraphs by using the 'new' primitive is not a good idea and can pose problem with certain implementations.

  • The Font and the foreground and background Colors are undefined when the UGraph is created and must be set explicitely (when needed)

  • The default drawing mode (called 'PaintMode') overwrites pixels. method setXORMode() sets the 'XORMode' that alternates the current foreground and background Colors.


Member Function Documentation

void UGraph::clearRect u_pos  x,
u_pos  y,
u_dim  width,
u_dim  height,
bool  repaint_view = false
 

clears a rectangle

Args:

  • if 'repaint_view' is true : repaints the normal content of the view in the specified region
  • otherwise: fills the area with the UGraph's background Color
  • see also: UView::updatePaint() in uview.hh for more options
  • Note: this function is not altered by the XOR mode

void UGraph::drawArc u_pos  x,
u_pos  y,
u_dim  width,
u_dim  height,
float  from_angle,
float  arc_angle
 

copies a rectangular area.

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

  • note: CopyArea can't copy obscured parts of the component but will generate refresh events for repainting the missing parts if the last argument is true

void UGraph::drawEllipse u_pos  x,
u_pos  y,
u_dim  width,
u_dim  height
 

draws an ellipse or an arc of an ellipse

Args:

  • x,y,width,height : top/left position and size of the enclosing rectangle
  • angles are in degrees

void UGraph::drawString const char *  ,
int  str_length,
u_pos  x,
u_pos  y
 

draw a character string

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

void UGraph::fillArc u_pos  x,
u_pos  y,
u_dim  width,
u_dim  height,
float  from_angle,
float  arc_angle
 

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

Args:

  • x,y,width,height : top/left position and size of the enclosing rectangle
  • angles are in degrees

void UGraph::fillPolygon std::vector< u_pos >  xpoints,
std::vector< u_pos >  ypoints,
u_count  card,
int  mode = 0
 

fills a polygon (which is automatically closed)

argument 'mode' can be set for optimisation purpose:

  • by default, mode=0 : the polygon can have an arbitrary shape
  • mode=2 assumes a Convex polygon.
  • mode=1 assumes a non Convex but non Intersecting polygon.

class UNatWin * UGraph::getNatWin  )  const
 

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.

Reimplemented in UWinGraph.

int UGraph::getSubTextSize const UFontDesc font,
const char *  s,
int  len,
u_dim  maxwidth,
u_dim  chw,
u_dim *  w,
u_dim *  h
const
 

returns font metrics of a substring (obsolete version).

????

bool UGraph::getSubTextSize const UFontDesc ,
const char *  str,
int  str_len,
u_dim &  w,
u_dim &  h,
u_dim  available_width,
int &  sublen,
int &  change_line
const
 

returns font metrics of a substring that verifies certain conditions

Notes:

  • the substring starts from the beginning of 'str' and ends at the 1st
    or 1st " " that is before 'available_width'.
  • it is equal to 'str' otherwise.
  • returns w and h that this substring occupies and its length 'sublen'
  • change_line = 1 si line must be changed because of size and 2 if a
    was found

int UGraph::getThickness  ) 
 

changes line thickness when drawing lines, etc

the default value 0 sets thickness to 1 pixel and optimizes drawing

int UGraph::grabPointer class UCursor = null,
bool  confine_to_window = false
 

starts a "physical grab" on the X server

Warning: this function may lock the X server!

void UGraph::setBgcolor const UColor  ) 
 

sets the Background color

note: the color is undefined when the UGraph is created

void UGraph::setClip u_pos  x,
u_pos  y,
u_dim  width,
u_dim  height
 

set the clipping zone relatively to VIEW coordinates

coordinates are relative to the origin of the VIEW

Reimplemented in UWinGraph.

void UGraph::setColor const UColor  ) 
 

sets the Foreground color

note: the color is undefined when the UGraph is created

void UGraph::setFont const UFontDesc  ) 
 

sets the current Font

notes:

  • the font is undefined when the UGraph is created
  • UFontDesc is an internal representation of UFont (see file ufont.hh)

void UGraph::setThickness int  = 0  ) 
 

these functions set the drawing mode.

notes:

  • PaintMode (the default) overwrites pixels with the foreground Color
  • XORMode alternates the current foreground and background Colors

void UGraph::setWinClip u_pos  x,
u_pos  y,
u_dim  width,
u_dim  height
 

set the clipping zone relatively to WINDOW coordinates

coordinates are relative to the origin of the WINDOW

Reimplemented in UWinGraph.


The documentation for this class was generated from the following files:
Generated on Fri Aug 13 12:12:14 2004 for Ubit[Eric.Lecolinet@enst.fr] by doxygen 1.3.7