CFx SDK Documentation  2022 SP0
FxQtCore.h
Go to the documentation of this file.
1 //
2 // (C) Copyright 2017-2021 by Graebert GmbH.
3 //
4 // Permission to use, copy, modify, and distribute this software in
5 // object code form for any purpose and without fee is hereby granted,
6 // provided that the above copyright notice appears in all copies and
7 // that both that copyright notice and the limited warranty and
8 // restricted rights notice below appear in all supporting
9 // documentation.
10 //
11 // GRAEBERT PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
12 // GRAEBERT SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
13 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. GRAEBERT GMBH
14 // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
15 // UNINTERRUPTED OR ERROR FREE.
16 
17 #pragma once
18 
19 #include "FxPragmaPush.h"
20 
21 // if we have no access to Qt, lets define all the things we need.
22 #if !defined(QSTRING_H) || !defined(QCHAR_H)
23 // forward declaration
24 class QString;
25 
26 #if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__))
27 # define Q_OS_DARWIN
28 # define Q_OS_BSD4
29 # ifdef __LP64__
30 # define Q_OS_DARWIN64
31 # else
32 # define Q_OS_DARWIN32
33 # endif
34 #elif !defined(SAG_COM) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
35 # define Q_OS_WIN32
36 # define Q_OS_WIN64
37 #elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
38 # if defined(WINCE) || defined(_WIN32_WCE)
39 # define Q_OS_WINCE
40 # else
41 # define Q_OS_WIN32
42 # endif
43 #elif defined(__linux__) || defined(__linux)
44 # define Q_OS_LINUX
45 #elif defined(VXWORKS) /* there is no "real" VxWorks define - this has to be set in the mkspec! */
46 # define Q_OS_VXWORKS
47 #elif defined(__MAKEDEPEND__)
48 #else
49 # error "Qt has not been ported to this OS - talk to qt-bugs@trolltech.com"
50 #endif
51 
52 #if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINCE)
53 # define Q_OS_WIN
54 #endif
55 
56 #if defined(Q_OS_WIN) && !defined(Q_CC_GNU) && !defined(Q_CC_MWERKS)
57 # define Q_INT64_C(c) c ## i64 /* signed 64 bit constant */
58 # define Q_UINT64_C(c) c ## ui64 /* unsigned 64 bit constant */
59 typedef __int64 qint64; /* 64 bit signed */
60 typedef unsigned __int64 quint64; /* 64 bit unsigned */
61 #else
62 # define Q_INT64_C(c) static_cast<long long>(c ## LL) /* signed 64 bit constant */
63 # define Q_UINT64_C(c) static_cast<unsigned long long>(c ## ULL) /* unsigned 64 bit constant */
64 typedef long long qint64; /* 64 bit signed */
65 typedef unsigned long long quint64; /* 64 bit unsigned */
66 #endif
67 
68 typedef qint64 qlonglong;
70 
71 typedef unsigned short ushort;
72 typedef unsigned char uchar;
73 typedef unsigned int uint;
74 typedef unsigned long ulong;
75 
77 {
78 public:
79  inline explicit QLatin1Char(char c) : ch(c) {}
80  inline char toLatin1() const { return ch; }
81  inline ushort unicode() const { return ushort(uchar(ch)); }
82 private:
83  char ch;
84 };
85 
86 class QChar {
87 public:
88  QChar(QLatin1Char ch) : ucs(ch.unicode()) {};
89 private:
90  ushort ucs;
91 };
92 
93 #endif // QSTRING_H || QCHAR_H
94 
95 #ifndef QRGB_H
96 #define QRGB_H
97 
98 typedef unsigned int QRgb; // RGB triplet
99 
100 inline int qRed(QRgb rgb) // get red part of RGB
101 { return ((rgb >> 16) & 0xff); }
102 
103 inline int qGreen(QRgb rgb) // get green part of RGB
104 { return ((rgb >> 8) & 0xff); }
105 
106 inline int qBlue(QRgb rgb) // get blue part of RGB
107 { return (rgb & 0xff); }
108 
109 inline int qAlpha(QRgb rgb) // get alpha part of RGBA
110 { return rgb >> 24; }
111 
112 inline int qGray(int r, int g, int b)// convert R,G,B to gray 0..255
113 { return (r*11+g*16+b*5)/32; }
114 
115 inline int qGray(QRgb rgb) // convert RGB to gray 0..255
116 { return qGray(qRed(rgb), qGreen(rgb), qBlue(rgb)); }
117 
118 inline QRgb qRgb(int r, int g, int b)// set RGB value
119 { return (0xffu << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); }
120 
121 inline QRgb qRgba(int r, int g, int b, int a)// set RGBA value
122 { return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); }
123 
124 #endif // QRGB_H
125 
126 #include "FxPragmaPop.h"
unsigned int QRgb
Definition: FxQtCore.h:98
QRgb qRgb(int r, int g, int b)
Definition: FxQtCore.h:118
int qAlpha(QRgb rgb)
Definition: FxQtCore.h:109
int qRed(QRgb rgb)
Definition: FxQtCore.h:100
unsigned char uchar
Definition: FxQtCore.h:72
QRgb qRgba(int r, int g, int b, int a)
Definition: FxQtCore.h:121
unsigned long ulong
Definition: FxQtCore.h:74
quint64 qulonglong
Definition: FxQtCore.h:69
unsigned long long quint64
Definition: FxQtCore.h:65
unsigned int uint
Definition: FxQtCore.h:73
long long qint64
Definition: FxQtCore.h:64
int qGreen(QRgb rgb)
Definition: FxQtCore.h:103
unsigned short ushort
Definition: FxQtCore.h:71
int qBlue(QRgb rgb)
Definition: FxQtCore.h:106
qint64 qlonglong
Definition: FxQtCore.h:68
int qGray(int r, int g, int b)
Definition: FxQtCore.h:112
Definition: FxQtCore.h:86
QChar(QLatin1Char ch)
Definition: FxQtCore.h:88
char toLatin1() const
Definition: FxQtCore.h:80
ushort unicode() const
Definition: FxQtCore.h:81
QLatin1Char(char c)
Definition: FxQtCore.h:79