Logo    
KDWinUtils
Helper library for MFC to Qt migration
Loading...
Searching...
No Matches
kpoint.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** This file is part of KDWinutils, KDAB's MFC to Qt migration tool.
4**
5** Copyright (C) 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6** All rights reserved.
7**
8** This file is intended solely for use by the migration tools and services
9** provided by Klarälvdalens Datakonsult AB.
10**
11** Any other use or distribution of this software that is not otherwise agreed
12** upon in writing and signed by an authorized representative of Klarälvdalens
13** Datakonsult AB, KDAB (USA) LLC, KDAB (Deutschland) GmbH & Co. K.G.,
14** KDAB (France) SAS, KDAB (UK), Ltd., or any future subsidiary of Klarälvdalens
15** Datakonsult AB is hereby prohibited.
16**
17** Contact info@kdab.com if any conditions stated above are unclear to you.
18**
19****************************************************************************/
20
21#pragma once
22
24
25#include <QPoint>
26
27#ifdef KDWINUTILS_WITHMFC
28#include <atltypes.h>
29#endif
30
32
33class KSize;
34
43{
44public:
45 int x = 0;
46 int y = 0;
47
49 /* implicit */ KPoint(const KSize &cs);
50 explicit KPoint(int x, int y);
51
52 // QPoint specific methods
53 /* implicit */ KPoint(const QPoint &qp);
54 KPoint &operator=(const QPoint &point);
55 QPoint toQPoint() const;
56 /* implicit */ operator QPoint() const;
57
58#ifdef KDWINUTILS_WITHMFC
59 // CPoint specific methods, available only on Windows with MFC set
60 explicit KPoint(const CPoint &cp);
61 KPoint &operator=(const CPoint &cp);
62 CPoint toCPoint() const;
63 /* implicit */ operator CPoint() const;
64#endif // KDWINUTILS_WITHMFC
65
66 // MFC API from here on
68
69 void operator+=(const KPoint &cp);
71 void operator+=(const KSize &cs);
73 void operator-=(const KPoint &cp);
75 void operator-=(const KSize &cs);
76
78 void Offset(int xOffset, int yOffset);
80 void Offset(const KPoint &other);
81};
82
85KDWINUTILS_EXPORT bool operator==(const KPoint &lhs, const KPoint &rhs) noexcept;
88KDWINUTILS_EXPORT bool operator!=(const KPoint &lhs, const KPoint &rhs) noexcept;
89
99
105KDWINUTILS_EXPORT KPoint operator-(const KSize &lhs, const KPoint &rhs);
109
The KPoint class defines a point in the plane using integer precision.
Definition kpoint.h:43
KPoint & operator=(const CPoint &cp)
KPoint operator-(const KPoint &point)
Returns the negation of a KPoint.
CPoint toCPoint() const
KPoint(const CPoint &cp)
KPoint operator+(const KPoint &lhs, const KSize &rhs)
Returns the sum of a KPoint and a KSize.
KPoint(const KSize &cs)
void operator-=(const KSize &cs)
Offsets KPoint by subtracting a KSize.
KPoint & operator=(const QPoint &point)
void Offset(const KPoint &other)
Adds values to the x and y members of the KPoint.
KPoint operator+(const KPoint &lhs, const KPoint &rhs)
Returns the sum of 2 KPoints.
bool operator==(const KPoint &lhs, const KPoint &rhs) noexcept
Checks for equality between two KPoints.
void operator+=(const KSize &cs)
Offsets KPoint by adding a KSize.
KPoint(const QPoint &qp)
KPoint operator-(const KPoint &lhs, const KSize &rhs)
Returns the difference of a KPoint and a KSize.
void operator+=(const KPoint &cp)
Offsets KPoint by adding a KPoint.
bool operator!=(const KPoint &lhs, const KPoint &rhs) noexcept
Checks for inequality between two KPoints.
QPoint toQPoint() const
void Offset(int xOffset, int yOffset)
Adds values to the x and y members of the KPoint.
KPoint(int x, int y)
void operator-=(const KPoint &cp)
Offsets KPoint by subtracting a KPoint.
The KSize class defines the size of a two-dimensional object using integer point precision.
Definition ksize.h:43
KPoint operator+(const KSize &lhs, const KPoint &rhs)
Returns the sum of a KSize and a KPoint.
#define KDWINUTILS_EXPORT
Definition kdwinutils_export.h:31
#define KDWINUTILS_BEGIN_NAMESPACE
Definition kdwinutils_global.h:27
#define KDWINUTILS_END_NAMESPACE
Definition kdwinutils_global.h:28