CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
FxQtCore.h
Go to the documentation of this file.
1//
2// (C) Copyright 2017-2025 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 !defined( QT_VERSION ) && !defined( QT_CORE_LIB )
22
23// if we have no access to Qt, lets define all the things we need.
24#if !defined(QSTRING_H) || !defined(QCHAR_H)
25// forward declaration
26class QString;
27
28#if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__))
29# define Q_OS_DARWIN
30# define Q_OS_BSD4
31# ifdef __LP64__
32# define Q_OS_DARWIN64
33# else
34# define Q_OS_DARWIN32
35# endif
36#elif !defined(SAG_COM) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
37# define Q_OS_WIN32
38# define Q_OS_WIN64
39#elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
40# if defined(WINCE) || defined(_WIN32_WCE)
41# define Q_OS_WINCE
42# else
43# define Q_OS_WIN32
44# endif
45#elif defined(__linux__) || defined(__linux)
46# define Q_OS_LINUX
47#elif defined(VXWORKS) /* there is no "real" VxWorks define - this has to be set in the mkspec! */
48# define Q_OS_VXWORKS
49#elif defined(__MAKEDEPEND__)
50#else
51# error "Qt has not been ported to this OS - talk to qt-bugs@trolltech.com"
52#endif
53
54#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINCE)
55# define Q_OS_WIN
56#endif
57
58#if defined(Q_OS_WIN) && !defined(Q_CC_GNU) && !defined(Q_CC_MWERKS)
59# define Q_INT64_C(c) c ## i64 /* signed 64 bit constant */
60# define Q_UINT64_C(c) c ## ui64 /* unsigned 64 bit constant */
61typedef __int64 qint64; /* 64 bit signed */
62typedef unsigned __int64 quint64; /* 64 bit unsigned */
63#else
64# define Q_INT64_C(c) static_cast<long long>(c ## LL) /* signed 64 bit constant */
65# define Q_UINT64_C(c) static_cast<unsigned long long>(c ## ULL) /* unsigned 64 bit constant */
66typedef long long qint64; /* 64 bit signed */
67typedef unsigned long long quint64; /* 64 bit unsigned */
68#endif
69
72
73typedef unsigned short ushort;
74typedef unsigned char uchar;
75typedef unsigned int uint;
76typedef unsigned long ulong;
77
79{
80public:
81 inline explicit QLatin1Char(char c) : ch(c) {}
82 inline char toLatin1() const { return ch; }
83 inline ushort unicode() const { return ushort(uchar(ch)); }
84private:
85 char ch;
86};
87
88class QChar {
89public:
90 QChar(QLatin1Char ch) : ucs(ch.unicode()) {};
91private:
92 ushort ucs;
93};
94
95#endif // QSTRING_H || QCHAR_H
96
97#ifndef QRGB_H
98#define QRGB_H
99
100typedef unsigned int QRgb; // RGB triplet
101
102inline int qRed(QRgb rgb) // get red part of RGB
103{ return ((rgb >> 16) & 0xff); }
104
105inline int qGreen(QRgb rgb) // get green part of RGB
106{ return ((rgb >> 8) & 0xff); }
107
108inline int qBlue(QRgb rgb) // get blue part of RGB
109{ return (rgb & 0xff); }
110
111inline int qAlpha(QRgb rgb) // get alpha part of RGBA
112{ return rgb >> 24; }
113
114inline int qGray(int r, int g, int b)// convert R,G,B to gray 0..255
115{ return (r*11+g*16+b*5)/32; }
116
117inline int qGray(QRgb rgb) // convert RGB to gray 0..255
118{ return qGray(qRed(rgb), qGreen(rgb), qBlue(rgb)); }
119
120inline QRgb qRgb(int r, int g, int b)// set RGB value
121{ return (0xffu << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); }
122
123inline QRgb qRgba(int r, int g, int b, int a)// set RGBA value
124{ return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); }
125
126#endif // QRGB_H
127
128#endif //QT_CORE_LIB
129
130#include "FxPragmaPop.h"
unsigned int QRgb
Definition FxQtCore.h:100
QRgb qRgb(int r, int g, int b)
Definition FxQtCore.h:120
int qAlpha(QRgb rgb)
Definition FxQtCore.h:111
int qRed(QRgb rgb)
Definition FxQtCore.h:102
QRgb qRgba(int r, int g, int b, int a)
Definition FxQtCore.h:123
quint64 qulonglong
Definition FxQtCore.h:71
int qGreen(QRgb rgb)
Definition FxQtCore.h:105
int qBlue(QRgb rgb)
Definition FxQtCore.h:108
int qGray(int r, int g, int b)
Definition FxQtCore.h:114
long long qlonglong
unsigned char uchar
unsigned long ulong
unsigned long long quint64
unsigned int uint
long long qint64
unsigned short ushort
QChar(QLatin1Char ch)
Definition FxQtCore.h:90
char toLatin1() const
Definition FxQtCore.h:82
ushort unicode() const
Definition FxQtCore.h:83
QLatin1Char(char c)
Definition FxQtCore.h:81