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

Canvas Class Reference

The Canvas class provides all functionality to display and modify nodes in Grisu. More...

List of all members.

Public Slots

void scrollingSlot (int)
 Called when the user is scrolling.

void scrollLineDownSlot (void)
 Scrolls one line down.

void scrollLineUpSlot (void)
 Scrolls one line up.

void scrollLineRightSlot (void)
 Scrolls one line right.

void scrollLineLeftSlot (void)
 Scrolls one line left.

void scrollPageDownSlot (void)
 Scrolls one page down.

void scrollPageUpSlot (void)
 Scrolls one page up.

void scrollPageRightSlot (void)
 Scrolls one page right.

void scrollPageLeftSlot (void)
 Scrolls one page left.

void hideLevelPopupSlot (void)
 Hides all placeholders of hidden attributes and the type of a feature structure.

void unhideLevelPopupSlot (void)
 Shows all placeholders of hidden attributes and the type of a feature structure.

void hideNodePopupSlot (void)
 Hides a node.


Signals

void redrawSignal ()
 Emitted when the canvas needs to be redrawn.


Public Member Functions

 Canvas (Options *, MyScrollBar *, MyScrollBar *, Document *, GenericNode *rootNode, QWidget *parent=0, const char *name=0)
 Creates a new canvas that displays a structure or a tree.

 ~Canvas ()
 Destroys the canvas.

virtual void paintEvent (QPaintEvent *)
 Called when the window needs to be painted.

virtual void repaint (bool erase=true)
 Called when the window needs to be repainted.

virtual void repaint (int, int, int, int, bool erase=true)
 Called when the window needs to be painted.

void printToPrinter (QPrinter &p)
 Prints the current structure or tree.

QSize getNodeDimensions (GenericNode *nd, const NodeAddress &addrParent, int dx, int dy)
 Calculates the dimensions of a given node (by executing the drawing routines with realDraw set to false).

QSize drawGenericNode (GenericNode *nd, const NodeAddress &addrParent, int dx, int dy, unsigned short flags=0)
 Draws a node by delegating the work to be done to one of the specialized drawing routines depending on the node's type.

QSize drawHiddenNode (DisplayableNode *dnd, char *text, int dx, int dy)
 Draws a placeholder of a hidden node.

QSize drawTypeNode (TypeNode *nd, const NodeAddress &addrParent, int dx, int dy)
 Draws a type node.

QSize drawFeatvalNode (FeatvalNode *nd, const NodeAddress &addrParent, int dx, int dy)
 Draws a feature and its value.

QSize drawListNode (ListNode *nd, const NodeAddress &addrParent, int dx, int dy)
 Draws a list node.

QSize drawSetNode (SetNode *nd, const NodeAddress &addrParent, int dx, int dy)
 Draws a set node.

QSize drawStrucNode (StrucNode *nd, const NodeAddress &addrParent, int dx, int dy)
 Draws a feature structure.

QSize drawFunctionNode (FunctionNode *nd, const NodeAddress &addrParent, int dx, int dy)
 Draws a function node.

QSize drawRelationNode (RelationNode *nd, const NodeAddress &addrParent, int dx, int dy)
 Draws a relation node.

QSize drawRefNode (RefNode *nd, const NodeAddress &addrParent, int dx, int dy, unsigned short flags=0)
 Draws a tag (a number in a little box).

QSize drawAtomNode (AtomNode *nd, const NodeAddress &addrParent, int dx, int dy)
 Draws an atom node.

QSize drawTreeNode (TreeNode *nd, const NodeAddress &addrParent, int dx, int dy)
 Draws a tree node.

QSize drawTailNode (TailNode *nd, const NodeAddress &addrParent, int dx, int dy)
 Draws a tail node.

QSize drawRestNode (RestNode *nd, const NodeAddress &addrParent, int dx, int dy)
 Draws a rest node.

QSize drawDisjunctionNode (DisjunctionNode *nd, const NodeAddress &addrParent, int dx, int dy)
 Draws a DisjunctionNode.

QSize drawConjunctionNode (ConjunctionNode *nd, const NodeAddress &addrParent, int dx, int dy)
 Draws a ConjunctionNode.

void setRootNode (GenericNode *node)
 Selects a new root node.

void updateOptions (const Options &op)
 Updates the options in this canvas to match the application wide options.

void addToClick (const NodeAddress &addr, int nodetype, QRect bounds)
 Adds a click region to the list of click regions.

void hideUnhide (DisplayableNode *nd, bool redraw=true)
 Toggles the hide flag on a displayable node.

void expandCollapse (DisplayableNode *nd, bool redraw=true)
 Toggles the expanded flag on a displayable node.

void resetScrollbar ()
 Updates the scrollbars after the window has been resized or the data has changed.

QSize getMaxSize ()
 Returns the total size of the currently displayed structure or tree.

int getOffsetX ()
 Returns the current X offset.

int getOffsetY ()
 Returns the current X offset.

KlickBoxgetKlickedOn ()
 Returns the click region of the node last clicked on.

KlickBoxwhereKlicked (const QPoint &p)
 Returns the click region which contains the given point, if any.

IdTreegetDispNodes (void)
 Returns the tree of node ids.

void reset ()
 Resets the currently displayed structure or tree.

void ensureVisible (const NodeAddress *addr)
 Make sure that the given node is visible.

void markFound (const NodeAddress *addr)
 Move the found marker to a new node and scroll to that position.

DocumentgetDocument (void) const
 Returns the document displayed in this Canvas.


Protected Member Functions

void mousePressEvent (QMouseEvent *)
 Called when the user clicks with the mouse.

void mouseMoveEvent (QMouseEvent *)
 Called when the user moves the mouse.

void mouseReleaseEvent (QMouseEvent *)
 Called when the user releases a mouse button.

virtual void wheelEvent (QWheelEvent *we)
 Called when a wheel event occurs (wheel mice only).


Private Slots

void expandCollapseSlot ()
 Collapses or expands the node the user clicked on (if this operation is supported for the type of the node).


Private Member Functions

void drawFoundMark (int x, int y, int w, int h)
 Draws a rectangle around a node indicated that it was found in a search operation.

QStringList typeAndFeatsList (StrucNode *node)
 Returns a list that contains the type and all attributes of a feature structure (a StrucNode).

QStringList namesOfHiddenChildNodes (NodeAddress &addr)
 Returns a list that contains the names of all hidden child nodes.

void drawText (int, int, const char *, int width=0)
 Draws text if realDraw is set to true.

void drawLine (int, int, int, int)
 Draws a line if realDraw is set to true.

void drawRect (int, int, int, int)
 Draws a rectangle if realDraw is set to true.

void drawAndOperator (int x, int width, int yu, int yd)
 Draws an AND operator, but only if realDraw is set.

void drawOrOperator (int x, int width, int yu, int yd)
 Draws an OR operator, but only if realDraw is set.

void resetToClick (void)
 Clears the list of current click regions.

QPoint nodeOrigin (const NodeAddress *addr)
 Returns the top left coordinate of a node.


Private Attributes

Optionsoptions
 The local (window-specifc) copy of the application options.

KlickBoxklickedOn
 The node the user clicked on last.

QList< KlickBoxtoKlick
 All click regions are kept in this list to allow mapping between click regions and nodes.

QPainter * paint
 The painter object.

QSize maxSize
 The total size of a structure or a tree.

int offsetX
 The current X offset to the top left corner of the structure.

int offsetY
 The current Y offset to the top left corner of the structure.

int oldOffsetX
 The old X offset (used during dragging of a structure).

int oldOffsetY
 The old Y offset (used during dragging of a structure).

int dragX
 The current X coordinate of the mouse cursor during dragging.

int dragY
 The current Y coordinate of the mouse cursor during dragging.

bool realDraw
 Determines whether nodes should actually drawn or not.

GenericNoderootNode
 The root node of the structure or the tree.

Documentdocument
 A pointer to the document containing the node data.

MyScrollBarv_scroll
 Pointer to the vertical scrollbar.

MyScrollBarh_scroll
 Pointer to the horizontal scrollbar.

KPopupMenu * popup
 Pointer to the popup menu currently open (or NULL if there is none).

bool dragging
 true if the user is currently dragging the structure or tree with the mouse.

DisplayableNodehighlight
 Pointer to the currently highlighted node.

DisplayableNodefoundMark
 Pointer to the node that is currently marked by the finder.

IdTreedispNodes
 A search tree of node addresses.


Detailed Description

The Canvas class provides all functionality to display and modify nodes in Grisu.


Constructor & Destructor Documentation

Canvas::Canvas Options ,
MyScrollBar ,
MyScrollBar ,
Document ,
GenericNode rootNode,
QWidget *  parent = 0,
const char *  name = 0
 

Creates a new canvas that displays a structure or a tree.

Canvas::~Canvas  ) 
 

Destroys the canvas.


Member Function Documentation

void Canvas::addToClick const NodeAddress addr,
int  nodetype,
QRect  bounds
 

Adds a click region to the list of click regions.

Parameters:
addr the address of the node in this region
nodetype the type of the node
bounds the coordinates of the click region.

void Canvas::drawAndOperator int  x,
int  width,
int  yu,
int  yd
[private]
 

Draws an AND operator, but only if realDraw is set.

Parameters:
x the left X coordinate of the operator
width the total width of the operator (should be divisble by 2 to make sure the operator is symmetric)
yu the Y coordinate of the "peak" of the operator
yd the Y coordinate of the baseline of the operator.

QSize Canvas::drawAtomNode AtomNode nd,
const NodeAddress addrParent,
int  dx,
int  dy
 

Draws an atom node.

Parameters:
nd the node to be drawn
addrParent the node address of the parent node.
dx the X coordinate of the node
dy the Y coordinate of the node
Returns:
the width and height of the node.

QSize Canvas::drawConjunctionNode ConjunctionNode nd,
const NodeAddress addrParent,
int  dx,
int  dy
 

Draws a ConjunctionNode.

ConjunctionNodes represent the infix conjunction operator.

Parameters:
nd the ConjunctionNode to be drawn
addrParent the unique node address of the displayed node
dx the x coordinate of the conjunction
dy the y coordinate of the conjunction
Returns:
the size of the complete node (the extent of the operators and all operands).

QSize Canvas::drawDisjunctionNode DisjunctionNode nd,
const NodeAddress addrParent,
int  dx,
int  dy
 

Draws a DisjunctionNode.

DisjunctionNodes represent the infix disjunction operator.

Parameters:
nd the DisjunctionNode to be drawn
addrParent the unique node address of the displayed node
dx the x coordinate of the disjunction
dy the y coordinate of the disjunction
Returns:
the size of the complete node (the extent of the operators and all operands).

QSize Canvas::drawFeatvalNode FeatvalNode nd,
const NodeAddress addrParent,
int  dx,
int  dy
 

Draws a feature and its value.

Parameters:
nd the node to be drawn
addrParent the node address of the parent node.
dx the X coordinate of the node
dy the Y coordinate of the node
Returns:
the width and height of the node.

void Canvas::drawFoundMark int  x,
int  y,
int  w,
int  h
[private]
 

Draws a rectangle around a node indicated that it was found in a search operation.

Parameters:
x the X coordinate of the rectangle
y the Y coordinate of the rectangle
w the width of the rectangle
h the height of the rectangle

QSize Canvas::drawFunctionNode FunctionNode nd,
const NodeAddress addrParent,
int  dx,
int  dy
 

Draws a function node.

Parameters:
nd the node to be drawn
addrParent the node address of the parent node.
dx the X coordinate of the node
dy the Y coordinate of the node
Returns:
the width and height of the node.

QSize Canvas::drawGenericNode GenericNode nd,
const NodeAddress addrParent,
int  dx,
int  dy,
unsigned short  flags = 0
 

Draws a node by delegating the work to be done to one of the specialized drawing routines depending on the node's type.

Drawing is done recursively, top to bottom, left to right.

Parameters:
nd the node to be drawn
addrParent the node address of the parent node.
dx the X coordinate of the node
dy the Y coordinate of the node
flags additional flags (a combination of DNF_xxxx constants).
Returns:
the width and height of the node.

QSize Canvas::drawHiddenNode DisplayableNode dnd,
char *  text,
int  dx,
int  dy
 

Draws a placeholder of a hidden node.

Parameters:
dnd the displayable node to be drawn
text the text that appears as a placeholder
dx the X coordinate of the node
dy the Y coordinate of the node
Returns:
the width and height of the node.

void Canvas::drawLine int  ,
int  ,
int  ,
int 
[private]
 

Draws a line if realDraw is set to true.

QSize Canvas::drawListNode ListNode nd,
const NodeAddress addrParent,
int  dx,
int  dy
 

Draws a list node.

Parameters:
nd the node to be drawn
addrParent the node address of the parent node.
dx the X coordinate of the node
dy the Y coordinate of the node
Returns:
the width and height of the node.

void Canvas::drawOrOperator int  x,
int  width,
int  yu,
int  yd
[private]
 

Draws an OR operator, but only if realDraw is set.

Parameters:
x the left X coordinate of the operator
width the total width of the operator (should be divisble by 2 to make sure the operator is symmetric)
yu the Y coordinate of the "peak" of the operator
yd the Y coordinate of the baseline of the operator.

void Canvas::drawRect int  ,
int  ,
int  ,
int 
[private]
 

Draws a rectangle if realDraw is set to true.

QSize Canvas::drawRefNode RefNode nd,
const NodeAddress addrParent,
int  dx,
int  dy,
unsigned short  flags = 0
 

Draws a tag (a number in a little box).

Parameters:
nd the node to be drawn
addrParent the node address of the parent node.
dx the X coordinate of the node
dy the Y coordinate of the node
flags additional flags (a combination of DNF_xxxx constants).
Returns:
the width and height of the node.

QSize Canvas::drawRelationNode RelationNode nd,
const NodeAddress addrParent,
int  dx,
int  dy
 

Draws a relation node.

Parameters:
nd the node to be drawn
addrParent the node address of the parent node.
dx the X coordinate of the node
dy the Y coordinate of the node
Returns:
the width and height of the node.

QSize Canvas::drawRestNode RestNode nd,
const NodeAddress addrParent,
int  dx,
int  dy
 

Draws a rest node.

Parameters:
nd the node to be drawn
addrParent the node address of the parent node.
dx the X coordinate of the node
dy the Y coordinate of the node
Returns:
the width and height of the node.

QSize Canvas::drawSetNode SetNode nd,
const NodeAddress addrParent,
int  dx,
int  dy
 

Draws a set node.

Parameters:
nd the node to be drawn
addrParent the node address of the parent node.
dx the X coordinate of the node
dy the Y coordinate of the node
Returns:
the width and height of the node.

QSize Canvas::drawStrucNode StrucNode nd,
const NodeAddress addrParent,
int  dx,
int  dy
 

Draws a feature structure.

Parameters:
nd the node to be drawn
addrParent the node address of the parent node.
dx the X coordinate of the node
dy the Y coordinate of the node
Returns:
the width and height of the node.

QSize Canvas::drawTailNode TailNode nd,
const NodeAddress addrParent,
int  dx,
int  dy
 

Draws a tail node.

Parameters:
nd the node to be drawn
addrParent the node address of the parent node.
dx the X coordinate of the node
dy the Y coordinate of the node
Returns:
the width and height of the node.

void Canvas::drawText int  ,
int  ,
const char *  ,
int  width = 0
[private]
 

Draws text if realDraw is set to true.

QSize Canvas::drawTreeNode TreeNode nd,
const NodeAddress addrParent,
int  dx,
int  dy
 

Draws a tree node.

Parameters:
nd the node to be drawn
addrParent the node address of the parent node.
dx the X coordinate of the node
dy the Y coordinate of the node
Returns:
the width and height of the node.

QSize Canvas::drawTypeNode TypeNode nd,
const NodeAddress addrParent,
int  dx,
int  dy
 

Draws a type node.

Parameters:
nd the node to be drawn
addrParent the node address of the parent node.
dx the X coordinate of the node
dy the Y coordinate of the node
Returns:
the width and height of the node.

void Canvas::ensureVisible const NodeAddress addr  ) 
 

Make sure that the given node is visible.

Parameters:
addr the address of the node.

void Canvas::expandCollapse DisplayableNode nd,
bool  redraw = true
 

Toggles the expanded flag on a displayable node.

Parameters:
nd the displayable node
redraw indicates whether the structure should be redrawn immediately.

void Canvas::expandCollapseSlot  )  [private, slot]
 

Collapses or expands the node the user clicked on (if this operation is supported for the type of the node).

IdTree * Canvas::getDispNodes void   ) 
 

Returns the tree of node ids.

Document * Canvas::getDocument void   )  const
 

Returns the document displayed in this Canvas.

Returns:
the document.

Canvas::KlickBox * Canvas::getKlickedOn  ) 
 

Returns the click region of the node last clicked on.

QSize Canvas::getMaxSize  )  [inline]
 

Returns the total size of the currently displayed structure or tree.

QSize Canvas::getNodeDimensions GenericNode nd,
const NodeAddress addrParent,
int  dx,
int  dy
 

Calculates the dimensions of a given node (by executing the drawing routines with realDraw set to false).

Parameters:
nd the node
addrParent the node address of the parent node
dx the X coordinate of the node
dy the Y coordinate of the node.
Returns:
the width and height of the node.

int Canvas::getOffsetX  )  [inline]
 

Returns the current X offset.

int Canvas::getOffsetY  )  [inline]
 

Returns the current X offset.

void Canvas::hideLevelPopupSlot void   )  [slot]
 

Hides all placeholders of hidden attributes and the type of a feature structure.

void Canvas::hideNodePopupSlot void   )  [slot]
 

Hides a node.

void Canvas::hideUnhide DisplayableNode nd,
bool  redraw = true
 

Toggles the hide flag on a displayable node.

Parameters:
nd the displayable node
redraw indicates whether the structure should be redrawn immediately.

void Canvas::markFound const NodeAddress addr  ) 
 

Move the found marker to a new node and scroll to that position.

Parameters:
addr the address of the node to be marked as found.

void Canvas::mouseMoveEvent QMouseEvent *   )  [protected]
 

Called when the user moves the mouse.

void Canvas::mousePressEvent QMouseEvent *   )  [protected]
 

Called when the user clicks with the mouse.

void Canvas::mouseReleaseEvent QMouseEvent *   )  [protected]
 

Called when the user releases a mouse button.

QStringList Canvas::namesOfHiddenChildNodes NodeAddress addr  )  [private]
 

Returns a list that contains the names of all hidden child nodes.

Only works for nodes of type StrucNode, where all hidden attributes are returned.

Parameters:
addr the node address of the parent node.
Returns:
a list of all hidden node names. This list is empty if no hidden child nodes exist or dn contains a node with an unsupported node type.

QPoint Canvas::nodeOrigin const NodeAddress addr  )  [private]
 

Returns the top left coordinate of a node.

Parameters:
addr the address of the node.

void Canvas::paintEvent QPaintEvent *   )  [virtual]
 

Called when the window needs to be painted.

void Canvas::printToPrinter QPrinter &  p  ) 
 

Prints the current structure or tree.

void Canvas::redrawSignal  )  [signal]
 

Emitted when the canvas needs to be redrawn.

void Canvas::repaint int  ,
int  ,
int  ,
int  ,
bool  erase = true
[virtual]
 

Called when the window needs to be painted.

void Canvas::repaint bool  erase = true  )  [virtual]
 

Called when the window needs to be repainted.

void Canvas::reset  ) 
 

Resets the currently displayed structure or tree.

Everything is reset to the initial state.

void Canvas::resetScrollbar  ) 
 

Updates the scrollbars after the window has been resized or the data has changed.

void Canvas::resetToClick void   )  [private]
 

Clears the list of current click regions.

void Canvas::scrollingSlot int   )  [slot]
 

Called when the user is scrolling.

void Canvas::scrollLineDownSlot void   )  [slot]
 

Scrolls one line down.

void Canvas::scrollLineLeftSlot void   )  [slot]
 

Scrolls one line left.

void Canvas::scrollLineRightSlot void   )  [slot]
 

Scrolls one line right.

void Canvas::scrollLineUpSlot void   )  [slot]
 

Scrolls one line up.

void Canvas::scrollPageDownSlot void   )  [slot]
 

Scrolls one page down.

void Canvas::scrollPageLeftSlot void   )  [slot]
 

Scrolls one page left.

void Canvas::scrollPageRightSlot void   )  [slot]
 

Scrolls one page right.

void Canvas::scrollPageUpSlot void   )  [slot]
 

Scrolls one page up.

void Canvas::setRootNode GenericNode node  ) 
 

Selects a new root node.

Parameters:
node the node designated to be the new root node.

QStringList Canvas::typeAndFeatsList StrucNode node  )  [private]
 

Returns a list that contains the type and all attributes of a feature structure (a StrucNode).

Parameters:
node the StrucNode
Returns:
a list containing the type as its first element followed by all attributes.

void Canvas::unhideLevelPopupSlot void   )  [slot]
 

Shows all placeholders of hidden attributes and the type of a feature structure.

void Canvas::updateOptions const Options op  ) 
 

Updates the options in this canvas to match the application wide options.

This is called when the user changes a font, for example.

Parameters:
op a reference to the application wide options object.

void Canvas::wheelEvent QWheelEvent *  we  )  [protected, virtual]
 

Called when a wheel event occurs (wheel mice only).

Parameters:
we the wheel event class.

Canvas::KlickBox * Canvas::whereKlicked const QPoint &  p  ) 
 

Returns the click region which contains the given point, if any.

Parameters:
p the point
Returns:
a pointer to the click region (the node) that contains the point, or NULL of no such region exists.


Member Data Documentation

IdTree* Canvas::dispNodes [private]
 

A search tree of node addresses.

Document* Canvas::document [private]
 

A pointer to the document containing the node data.

bool Canvas::dragging [private]
 

true if the user is currently dragging the structure or tree with the mouse.

int Canvas::dragX [private]
 

The current X coordinate of the mouse cursor during dragging.

int Canvas::dragY [private]
 

The current Y coordinate of the mouse cursor during dragging.

DisplayableNode* Canvas::foundMark [private]
 

Pointer to the node that is currently marked by the finder.

MyScrollBar* Canvas::h_scroll [private]
 

Pointer to the horizontal scrollbar.

Note: The scrollbar is managed by the parent widget.

DisplayableNode* Canvas::highlight [private]
 

Pointer to the currently highlighted node.

KlickBox* Canvas::klickedOn [private]
 

The node the user clicked on last.

QSize Canvas::maxSize [private]
 

The total size of a structure or a tree.

int Canvas::offsetX [private]
 

The current X offset to the top left corner of the structure.

int Canvas::offsetY [private]
 

The current Y offset to the top left corner of the structure.

int Canvas::oldOffsetX [private]
 

The old X offset (used during dragging of a structure).

int Canvas::oldOffsetY [private]
 

The old Y offset (used during dragging of a structure).

Options* Canvas::options [private]
 

The local (window-specifc) copy of the application options.

This allows users to change some options without affecting other windows.

QPainter* Canvas::paint [private]
 

The painter object.

KPopupMenu* Canvas::popup [private]
 

Pointer to the popup menu currently open (or NULL if there is none).

bool Canvas::realDraw [private]
 

Determines whether nodes should actually drawn or not.

This way, the actual drawing routines can be used to determine the size of a node (and all its subnodes), without actually drawing the node.

GenericNode* Canvas::rootNode [private]
 

The root node of the structure or the tree.

QList<KlickBox> Canvas::toKlick [private]
 

All click regions are kept in this list to allow mapping between click regions and nodes.

MyScrollBar* Canvas::v_scroll [private]
 

Pointer to the vertical scrollbar.

Note: The scrollbar is managed by the parent widget.


Generated on Sun Apr 27 18:26:57 2003 for Grisu by doxygen1.3