-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwhiteboard.h
45 lines (37 loc) · 1 KB
/
whiteboard.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
* Joshua Henderson <joshua.henderson@microchip.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef WHITEBOARD_H
#define WHITEBOARD_H
#include <QColor>
#include <QImage>
#include <QPoint>
#include <QWidget>
class WhiteBoard : public QWidget
{
Q_OBJECT
public:
explicit WhiteBoard(QWidget* parent = 0);
void setPenColor(const QColor& newColor);
public slots:
void clearImage();
protected:
void mousePressEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
void paintEvent(QPaintEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
private:
void drawLineTo(const QPoint& endPoint);
void resizeImage(QImage* image, const QSize& newSize);
bool m_drawing;
bool m_modified;
int m_penWidth;
QColor m_penColor;
QImage m_image;
QPoint m_lastPoint;
};
#endif // WHITEBOARD_H