Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qcolorwell_p.h
Go to the documentation of this file.
1
// Copyright (C) 2025 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
ifndef
QCOLORWELL_P_H
6
#
define
QCOLORWELL_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtCore
/
qrect
.
h
>
20
#
include
<
QtWidgets
/
qwidget
.
h
>
21
22
QT_REQUIRE_CONFIG
(
colordialog
);
23
24
QT_BEGIN_NAMESPACE
25
26
class
QWellArray :
public
QWidget
27
{
28
Q_OBJECT
29
Q_PROPERTY(
int
selectedColumn READ selectedColumn)
30
Q_PROPERTY(
int
selectedRow READ selectedRow)
31
32
public
:
33
QWellArray(
int
rows,
int
cols, QWidget *parent =
nullptr
);
34
~QWellArray() { }
35
36
int
currentColumn()
const
{
return
curCol; }
37
int
currentRow()
const
{
return
curRow; }
38
39
int
selectedColumn()
const
{
return
selCol; }
40
int
selectedRow()
const
{
return
selRow; }
41
42
virtual
void
setCurrent(
int
row,
int
col);
43
virtual
void
setSelected(
int
row,
int
col);
44
45
QSize sizeHint()
const
override;
46
47
inline
int
cellWidth()
const
{
return
cellw; }
48
49
inline
int
cellHeight()
const
{
return
cellh; }
50
51
inline
int
rowAt(
int
y)
const
{
return
y / cellh; }
52
53
inline
int
columnAt(
int
x)
const
54
{
55
if
(isRightToLeft())
56
return
ncols - (x / cellw) - 1;
57
return
x / cellw;
58
}
59
60
inline
int
rowY(
int
row)
const
{
return
cellh * row; }
61
62
inline
int
columnX(
int
column)
const
63
{
64
if
(isRightToLeft())
65
return
cellw * (ncols - column - 1);
66
return
cellw * column;
67
}
68
69
inline
int
numRows()
const
{
return
nrows; }
70
71
inline
int
numCols()
const
{
return
ncols; }
72
73
inline
int
index(
int
row,
int
col) {
return
col * nrows + row; }
74
75
inline
QRect cellRect()
const
{
return
QRect(0, 0, cellw, cellh); }
76
77
inline
QSize gridSize()
const
{
return
QSize(ncols * cellw, nrows * cellh); }
78
79
QRect cellGeometry(
int
row,
int
column)
80
{
81
QRect r;
82
if
(row >= 0 && row < nrows && column >= 0 && column < ncols)
83
r.setRect(columnX(column), rowY(row), cellw, cellh);
84
return
r;
85
}
86
87
inline
void
updateCell(
int
row,
int
column) { update(cellGeometry(row, column)); }
88
89
signals:
90
void
selected(
int
row,
int
col);
91
void
currentChanged(
int
row,
int
col);
92
void
colorChanged(
int
index, QRgb color);
93
94
protected
:
95
virtual
void
paintCell(QPainter *,
int
row,
int
col,
const
QRect &);
96
virtual
void
paintCellContents(QPainter *,
int
row,
int
col,
const
QRect &);
97
98
void
mousePressEvent(QMouseEvent *) override;
99
void
mouseReleaseEvent(QMouseEvent *) override;
100
void
keyPressEvent(QKeyEvent *) override;
101
void
focusInEvent(QFocusEvent *) override;
102
void
focusOutEvent(QFocusEvent *) override;
103
void
paintEvent(QPaintEvent *) override;
104
105
void
sendAccessibleChildFocusEvent();
106
107
private
:
108
Q_DISABLE_COPY(QWellArray)
109
110
int
nrows;
111
int
ncols;
112
int
cellw;
113
int
cellh;
114
int
curRow;
115
int
curCol;
116
int
selRow;
117
int
selCol;
118
};
119
120
class
QColorWell
:
public
QWellArray
121
{
122
Q_OBJECT
123
public
:
124
QColorWell
(
QWidget
*
parent
,
int
r
,
int
c
,
const
QRgb
*
vals
)
125
:
QWellArray
(
r
,
c
,
parent
),
values
(
vals
),
mousePressed
(
false
),
oldCurrent
(-1, -1)
126
{
127
setSizePolicy
(
QSizePolicy
(
QSizePolicy
::
Minimum
,
QSizePolicy
::
Minimum
));
128
}
129
130
const
QRgb
*
rgbValues
() {
return
values
; }
131
132
protected
:
133
void
paintCellContents
(
QPainter
*,
int
row
,
int
col
,
const
QRect
&)
override
;
134
void
mousePressEvent
(QMouseEvent *e)
override
;
135
void
mouseMoveEvent
(QMouseEvent *e)
override
;
136
void
mouseReleaseEvent
(QMouseEvent *e)
override
;
137
#
if
QT_CONFIG
(
draganddrop
)
138
void
dragEnterEvent
(
QDragEnterEvent
*
e
)
override
;
139
void
dragLeaveEvent
(
QDragLeaveEvent
*
e
)
override
;
140
void
dragMoveEvent
(
QDragMoveEvent
*
e
)
override
;
141
void
dropEvent
(
QDropEvent
*
e
)
override
;
142
#
endif
143
144
private
:
145
const
QRgb *values;
146
bool
mousePressed;
147
QPoint pressPos;
148
QPoint oldCurrent;
149
};
150
151
QT_END_NAMESPACE
152
153
#
endif
// QCOLORWELL_P_H
QColorWell
Definition
qcolorwell_p.h:121
QColorWell::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
Definition
qcolordialog.cpp:506
QColorWell::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse release even...
Definition
qcolordialog.cpp:571
QColorWell::mousePressEvent
void mousePressEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
Definition
qcolordialog.cpp:498
QT_REQUIRE_CONFIG
QT_REQUIRE_CONFIG(colordialog)
qtbase
src
widgets
dialogs
qcolorwell_p.h
Generated on
for Qt by
1.18.0