This repository has been archived by the owner on Sep 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmy_rectdialog.h
114 lines (95 loc) · 3.39 KB
/
my_rectdialog.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/****************************************/
// COMP2012 2015S PA2 -- Paint
// File: my_rectdialog.h
// Author: Hong Joon Choi
// Description: the header file
// -- MyRectDialog class definition
// customizing the QDialog class for the Rectangle tool
/****************************************/
#include <qmainwindow.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qapplication.h>
#include <qpushbutton.h>
#include <qpen.h>
#include <qslider.h>
#include <qdialog.h>
#include <qlabel.h>
#include <qbuttongroup.h>
#include <qradiobutton.h>
#include <qcolor.h>
#include <qpaintdevice.h>
#ifndef _MY_RECT_DIALOG_H
#define _MY_RECT_DIALOG_H
// MyLineDialog: custormized QDialog
// The QDialog class provides a dialog window for communications with user
class MyRectDialog: public QDialog {
// All classes that contain signals or slots
// must mention Q_OBJECT in their declaration.
Q_OBJECT
public:
/** constructor and destructor */
MyRectDialog(QWidget* parent = 0, const char* name = 0);
~MyRectDialog();
/** for storing the color, pen and brush settings */
QColor bgColor; // stores bgColor.
QColor fgColor; // stores fgColor.
QPen pen; // stores pen settings
QBrush brush; // stores brush settings
/**
* @brief Sets color of the shape to be drawn, according to fill color settings. Simply setting fg or bg color DO NOT affect the shape color
* @param none
* @retval none
* @example : bgColor=windowColor; setColor();
*/
void setColor();
/**
* @brief Draws shape onto the target PaintDevice according to the dialog settings.
* @param target: target paintDevice
* @param clip: Rectangle area of where the drawing is allowed.
* @param shape: Sets position and size of the shape in rectangle format.
* @retval none
* @example : drawShapeWithSettings(image, clip, rectangle);
*/
void drawShapeWithSettings(const QPaintDevice* target, const QRect& clip, const QRect& shape);
/** user defined slots */
public slots:
void OnSetBoundaryWidth(int w);
void OnSetDrawType(int type);
void OnSetBoundaryStyle(int type);
void OnSetFillStyle(int type);
void OnSetFillColor(int type);
void OnSetBounaryJoinStyle(int type);
private:
// Slider pointer
QSlider* boundaryWidthSlider;
// Slider labels
QLabel* sliderLabel;
QLabel* boundaryWidthLabel;
// draw type radio buttons group
QButtonGroup* drawTypeBgroup;
// array of draw type radio buttons
QRadioButton** rb_drawTypes;
// fill style radio buttons group
QButtonGroup* fillStyleBgroup;
// array of fill style radio buttons
QRadioButton** rb_fillStyles;
// boundary style radio buttons group
QButtonGroup* boundaryStyleBgroup;
// array of boundary style radio buttons
QRadioButton** rb_boundaryStyles;
// fill color radio buttons group
QButtonGroup* fillColorBgroup;
// array of fill color radio buttons
QRadioButton** rb_fillColors;
// boundary join style radio buttons group
QButtonGroup* boundaryJoinStyleBGroup;
// array of boundary join style radio buttons
QRadioButton** rb_boundaryJoinStyles;
// painter for drawing rectangles
QPainter* paint;
// dialog settings
bool foregroundColor;
int drawType;
};
#endif