2 * wbwidget.h - a widget for processing and showing whiteboard
4 * Copyright (C) 2006 Joonas Govenius
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <QGraphicsView>
29 #include <QFileDialog>
31 /*! \brief The whiteboard widget.
32 * Visualizes the whiteboard scene and provides different modes for editing and adding new elements.
33 * Local edits to existing elements are handled by the elements themselves
34 * as mouse events are passed on to them but new items are temporarily
35 * added to the scene while being drawn and only when finished, added to
41 class WbWidget
: public QGraphicsView
46 * Indicates the mode the widget is in.
48 enum Mode
{ Select
, Translate
, Rotate
, Scale
, Scroll
, Erase
, DrawPath
, DrawLine
, DrawRectangle
, DrawEllipse
, DrawCircle
, DrawPolyline
, DrawText
, DrawImage
};
50 /*! \brief Constructor
51 * Constructs a new widget with \a session and \a size with parent \a parent.
52 * \a ownJid is the Jid that should be used in item IDs created by this widget.
54 WbWidget(const QString
&session
, const QString
&ownJid
, const QSize
&size
, QWidget
*parent
=0);
55 /*! \brief Processes an incoming whiteboard element.*/
56 bool processWb(const QDomElement
&wb
);
57 /*! \brief Returns the session this widget is visualizing.*/
59 /*! \brief Returns the JID used by the user in the session.*/
60 const QString
& ownJid() const;
61 /*! \brief Returns the mode this widget is in.*/
63 /*! \brief Sets the mode which determines how to react to user interaction.*/
64 void setMode(Mode mode
);
65 /*! \brief Sets the size of the whiteboard.*/
66 void setSize(const QSize
&s
);
67 /*! \brief Sets the stroke color of new items.*/
68 void setStrokeColor(const QColor
&color
);
69 /*! \brief Sets the stroke color of new items.*/
70 void setFillColor(const QColor
&color
);
71 /*! \brief Sets the stroke width of new items.*/
72 void setStrokeWidth(int width
);
73 /*! \brief Sets whether configure edits are accepted regardless of version.
74 * Default is false. Should be set true if the session state is Negotiation::DocumentBegun.
76 void setImporting(bool);
78 /*! \brief Returns the size set by setSize().*/
79 virtual QSize
sizeHint() const;
81 /*! \brief A pointer to the WbScene.*/
85 /*! \brief Emitted when a new whiteboard element is ready to be sent.*/
86 void newWb(const QDomElement
&wb
);
87 /*! \brief Emitted when mode is changed.*/
88 void modeChanged(WbWidget::Mode
);
91 /*! \brief Clears the whiteboard.
92 * If \a sendEdits is true, the remove edits are sent.
94 void clear(const bool &sendEdits
= true);
97 /*! \brief Makes sure that area outside the whiteboard is not shown by zooming if necessary.*/
98 virtual void resizeEvent(QResizeEvent
* event
);
99 /*! \brief Passes events to items as specified by the mode.*/
100 virtual void mousePressEvent(QMouseEvent
* event
);
101 /*! \brief Passes events to items as specified by the mode.*/
102 virtual void mouseMoveEvent(QMouseEvent
* event
);
103 /*! \brief Passes events to items as specified by the mode.*/
104 virtual void mouseReleaseEvent(QMouseEvent
* event
);
107 /*! \brief The user interaction mode the widget is in.*/
109 /*! \brief The stroke color used for new items.*/
111 /*! \brief The fill color used for new items.*/
113 /*! \brief The stroke width used for new items.*/
116 /*! \brief Pointer to a new item that is being drawn.*/
118 /*! \brief Boolean used to force adding a vertex to a path being drawn.*/
120 /*! \brief Pointer to a control point to be used for the next vertex.*/
121 QPointF
* controlPoint_
;
122 /*! \brief Timer used for forcing the addition of a new vertex.*/
126 /*! \brief Slot used for forcing the addition of a new vertex.*/