1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.gui.brush; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.atomic; 19 import qt.core.global; 20 import qt.core.metatype; 21 import qt.core.namespace; 22 import qt.core.objectdefs; 23 import qt.core.pair; 24 import qt.core.point; 25 import qt.core.scopedpointer; 26 import qt.core.typeinfo; 27 import qt.core.variant; 28 import qt.core.vector; 29 import qt.gui.color; 30 import qt.gui.image; 31 import qt.gui.matrix; 32 import qt.gui.pixmap; 33 import qt.gui.transform; 34 import qt.helpers; 35 36 /+ struct QBrushData; 37 class QPixmap; 38 class QGradient; 39 class QVariant; +/ 40 struct QBrushDataPointerDeleter; 41 42 @(QMetaType.Type.QBrush) @Q_MOVABLE_TYPE extern(C++, class) struct /+ Q_GUI_EXPORT +/ QBrush 43 { 44 public: 45 @disable this(); 46 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 47 ref typeof(this) rawConstructor(); 48 static typeof(this) create() 49 { 50 typeof(this) r = typeof(this).init; 51 r.rawConstructor(); 52 return r; 53 } 54 55 this(/+ Qt:: +/qt.core.namespace.BrushStyle bs); 56 this(ref const(QColor) color, /+ Qt:: +/qt.core.namespace.BrushStyle bs=/+ Qt:: +/qt.core.namespace.BrushStyle.SolidPattern); 57 this(const(QColor) color, /+ Qt:: +/qt.core.namespace.BrushStyle bs=/+ Qt:: +/qt.core.namespace.BrushStyle.SolidPattern) 58 { 59 this(color, bs); 60 } 61 this(/+ Qt:: +/qt.core.namespace.GlobalColor color, /+ Qt:: +/qt.core.namespace.BrushStyle bs=/+ Qt:: +/qt.core.namespace.BrushStyle.SolidPattern); 62 63 this(ref const(QColor) color, ref const(QPixmap) pixmap); 64 this(/+ Qt:: +/qt.core.namespace.GlobalColor color, ref const(QPixmap) pixmap); 65 this(ref const(QPixmap) pixmap); 66 this(ref const(QImage) image); 67 68 @disable this(this); 69 this(ref const(QBrush) brush); 70 71 this(ref const(QGradient) gradient); 72 73 ~this(); 74 /+ref QBrush operator =(ref const(QBrush) brush);+/ 75 /+ inline QBrush &operator=(QBrush &&other) noexcept 76 { qSwap(d, other.d); return *this; } +/ 77 /+ inline void swap(QBrush &other) noexcept 78 { qSwap(d, other.d); } +/ 79 80 /+auto opCast(T : QVariant)() const;+/ 81 82 pragma(inline, true) /+ Qt:: +/qt.core.namespace.BrushStyle style() const { return d.style; } 83 void setStyle(/+ Qt:: +/qt.core.namespace.BrushStyle); 84 85 /+ #if QT_DEPRECATED_SINCE(5, 15) +/ 86 /+ QT_DEPRECATED_X("Use transform()") +/ pragma(inline, true) ref const(QMatrix) matrix() const { return d.transform.toAffine(); } 87 /+ QT_DEPRECATED_X("Use setTransform()") +/ void setMatrix(ref const(QMatrix) mat); 88 /+ #endif +/ // QT_DEPRECATED_SINCE(5, 15) 89 90 pragma(inline, true) QTransform transform() const { return d.transform; } 91 void setTransform(ref const(QTransform) ); 92 93 QPixmap texture() const; 94 void setTexture(ref const(QPixmap) pixmap); 95 96 QImage textureImage() const; 97 void setTextureImage(ref const(QImage) image); 98 99 pragma(inline, true) ref const(QColor) color() const { return d.color; } 100 void setColor(ref const(QColor) color); 101 pragma(inline, true) void setColor(/+ Qt:: +/qt.core.namespace.GlobalColor acolor) 102 { auto tmp = QColor(acolor); setColor(tmp); } 103 104 const(QGradient)* gradient() const; 105 106 bool isOpaque() const; 107 108 /+bool operator ==(ref const(QBrush) b) const;+/ 109 /+pragma(inline, true) bool operator !=(ref const(QBrush) b) const { return !(operator==(b)); }+/ 110 111 private: 112 /+ friend class QRasterPaintEngine; +/ 113 /+ friend class QRasterPaintEnginePrivate; +/ 114 /+ friend struct QSpanData; +/ 115 /+ friend class QPainter; +/ 116 /+ friend bool Q_GUI_EXPORT qHasPixmapTexture(const QBrush& brush); +/ 117 void detach(/+ Qt:: +/qt.core.namespace.BrushStyle newStyle); 118 void init_(ref const(QColor) color, /+ Qt:: +/qt.core.namespace.BrushStyle bs); 119 QScopedPointer!(QBrushData, QBrushDataPointerDeleter) d; 120 void cleanUp(QBrushData* x); 121 122 public: 123 pragma(inline, true) bool isDetached() const { return d.ref_.loadRelaxed() == 1; } 124 alias DataPtr = QScopedPointer!(QBrushData, QBrushDataPointerDeleter); 125 pragma(inline, true) ref DataPtr data_ptr() return { return d; } 126 } 127 128 /+ Q_DECLARE_SHARED(QBrush) 129 130 /***************************************************************************** 131 QBrush stream functions 132 *****************************************************************************/ 133 134 #ifndef QT_NO_DATASTREAM 135 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QBrush &); 136 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QBrush &); 137 #endif 138 139 #ifndef QT_NO_DEBUG_STREAM 140 Q_GUI_EXPORT QDebug operator<<(QDebug, const QBrush &); 141 #endif +/ 142 143 struct QBrushData 144 { 145 QAtomicInt ref_; 146 /+ Qt:: +/qt.core.namespace.BrushStyle style; 147 QColor color; 148 QTransform transform; 149 } 150 /+ #if QT_DEPRECATED_SINCE(5, 15) 151 #endif +/ // QT_DEPRECATED_SINCE(5, 15) 152 153 154 /******************************************************************************* 155 * QGradients 156 */ 157 extern(C++, class) struct QGradientPrivate; 158 159 alias QGradientStop = QPair!(qreal, QColor); 160 alias QGradientStops = QVector!(QGradientStop); 161 162 extern(C++, class) struct /+ Q_GUI_EXPORT +/ QGradient 163 { 164 mixin(Q_GADGET); 165 public: 166 enum Type { 167 LinearGradient, 168 RadialGradient, 169 ConicalGradient, 170 NoGradient 171 } 172 /+ Q_ENUM(Type) +/ 173 174 enum Spread { 175 PadSpread, 176 ReflectSpread, 177 RepeatSpread 178 } 179 /+ Q_ENUM(Spread) +/ 180 181 enum CoordinateMode { 182 LogicalMode, 183 StretchToDeviceMode, 184 ObjectBoundingMode, 185 ObjectMode 186 } 187 /+ Q_ENUM(CoordinateMode) +/ 188 189 enum InterpolationMode { 190 ColorInterpolation, 191 ComponentInterpolation 192 } 193 194 enum Preset { 195 WarmFlame = 1, 196 NightFade = 2, 197 SpringWarmth = 3, 198 JuicyPeach = 4, 199 YoungPassion = 5, 200 LadyLips = 6, 201 SunnyMorning = 7, 202 RainyAshville = 8, 203 FrozenDreams = 9, 204 WinterNeva = 10, 205 DustyGrass = 11, 206 TemptingAzure = 12, 207 HeavyRain = 13, 208 AmyCrisp = 14, 209 MeanFruit = 15, 210 DeepBlue = 16, 211 RipeMalinka = 17, 212 CloudyKnoxville = 18, 213 MalibuBeach = 19, 214 NewLife = 20, 215 TrueSunset = 21, 216 MorpheusDen = 22, 217 RareWind = 23, 218 NearMoon = 24, 219 WildApple = 25, 220 SaintPetersburg = 26, 221 PlumPlate = 28, 222 EverlastingSky = 29, 223 HappyFisher = 30, 224 Blessing = 31, 225 SharpeyeEagle = 32, 226 LadogaBottom = 33, 227 LemonGate = 34, 228 ItmeoBranding = 35, 229 ZeusMiracle = 36, 230 OldHat = 37, 231 StarWine = 38, 232 HappyAcid = 41, 233 AwesomePine = 42, 234 NewYork = 43, 235 ShyRainbow = 44, 236 MixedHopes = 46, 237 FlyHigh = 47, 238 StrongBliss = 48, 239 FreshMilk = 49, 240 SnowAgain = 50, 241 FebruaryInk = 51, 242 KindSteel = 52, 243 SoftGrass = 53, 244 GrownEarly = 54, 245 SharpBlues = 55, 246 ShadyWater = 56, 247 DirtyBeauty = 57, 248 GreatWhale = 58, 249 TeenNotebook = 59, 250 PoliteRumors = 60, 251 SweetPeriod = 61, 252 WideMatrix = 62, 253 SoftCherish = 63, 254 RedSalvation = 64, 255 BurningSpring = 65, 256 NightParty = 66, 257 SkyGlider = 67, 258 HeavenPeach = 68, 259 PurpleDivision = 69, 260 AquaSplash = 70, 261 SpikyNaga = 72, 262 LoveKiss = 73, 263 CleanMirror = 75, 264 PremiumDark = 76, 265 ColdEvening = 77, 266 CochitiLake = 78, 267 SummerGames = 79, 268 PassionateBed = 80, 269 MountainRock = 81, 270 DesertHump = 82, 271 JungleDay = 83, 272 PhoenixStart = 84, 273 OctoberSilence = 85, 274 FarawayRiver = 86, 275 AlchemistLab = 87, 276 OverSun = 88, 277 PremiumWhite = 89, 278 MarsParty = 90, 279 EternalConstance = 91, 280 JapanBlush = 92, 281 SmilingRain = 93, 282 CloudyApple = 94, 283 BigMango = 95, 284 HealthyWater = 96, 285 AmourAmour = 97, 286 RiskyConcrete = 98, 287 StrongStick = 99, 288 ViciousStance = 100, 289 PaloAlto = 101, 290 HappyMemories = 102, 291 MidnightBloom = 103, 292 Crystalline = 104, 293 PartyBliss = 106, 294 ConfidentCloud = 107, 295 LeCocktail = 108, 296 RiverCity = 109, 297 FrozenBerry = 110, 298 ChildCare = 112, 299 FlyingLemon = 113, 300 NewRetrowave = 114, 301 HiddenJaguar = 115, 302 AboveTheSky = 116, 303 Nega = 117, 304 DenseWater = 118, 305 Seashore = 120, 306 MarbleWall = 121, 307 CheerfulCaramel = 122, 308 NightSky = 123, 309 MagicLake = 124, 310 YoungGrass = 125, 311 ColorfulPeach = 126, 312 GentleCare = 127, 313 PlumBath = 128, 314 HappyUnicorn = 129, 315 AfricanField = 131, 316 SolidStone = 132, 317 OrangeJuice = 133, 318 GlassWater = 134, 319 NorthMiracle = 136, 320 FruitBlend = 137, 321 MillenniumPine = 138, 322 HighFlight = 139, 323 MoleHall = 140, 324 SpaceShift = 142, 325 ForestInei = 143, 326 RoyalGarden = 144, 327 RichMetal = 145, 328 JuicyCake = 146, 329 SmartIndigo = 147, 330 SandStrike = 148, 331 NorseBeauty = 149, 332 AquaGuidance = 150, 333 SunVeggie = 151, 334 SeaLord = 152, 335 BlackSea = 153, 336 GrassShampoo = 154, 337 LandingAircraft = 155, 338 WitchDance = 156, 339 SleeplessNight = 157, 340 AngelCare = 158, 341 CrystalRiver = 159, 342 SoftLipstick = 160, 343 SaltMountain = 161, 344 PerfectWhite = 162, 345 FreshOasis = 163, 346 StrictNovember = 164, 347 MorningSalad = 165, 348 DeepRelief = 166, 349 SeaStrike = 167, 350 NightCall = 168, 351 SupremeSky = 169, 352 LightBlue = 170, 353 MindCrawl = 171, 354 LilyMeadow = 172, 355 SugarLollipop = 173, 356 SweetDessert = 174, 357 MagicRay = 175, 358 TeenParty = 176, 359 FrozenHeat = 177, 360 GagarinView = 178, 361 FabledSunset = 179, 362 PerfectBlue = 180, 363 364 NumPresets 365 } 366 /+ Q_ENUM(Preset) +/ 367 368 @disable this(); 369 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 370 ref typeof(this) rawConstructor(); 371 static typeof(this) create() 372 { 373 typeof(this) r = typeof(this).init; 374 r.rawConstructor(); 375 return r; 376 } 377 378 this(Preset); 379 ~this(); 380 381 Type type() const { return m_type; } 382 383 pragma(inline, true) void setSpread(Spread aspread) 384 { m_spread = aspread; } 385 Spread spread() const { return m_spread; } 386 387 void setColorAt(qreal pos, ref const(QColor) color); 388 389 void setStops(ref const(QGradientStops) stops); 390 QGradientStops stops() const; 391 392 CoordinateMode coordinateMode() const; 393 void setCoordinateMode(CoordinateMode mode); 394 395 InterpolationMode interpolationMode() const; 396 void setInterpolationMode(InterpolationMode mode); 397 398 /+bool operator ==(ref const(QGradient) gradient) const;+/ 399 /+pragma(inline, true) bool operator !=(ref const(QGradient) other) const 400 { return !operator==(other); }+/ 401 402 union QGradientData { 403 struct generated_qbrush_0 { 404 qreal x1; qreal y1; qreal x2; qreal y2; 405 }generated_qbrush_0 linear; 406 struct generated_qbrush_1 { 407 qreal cx; qreal cy; qreal fx; qreal fy; qreal cradius; 408 }generated_qbrush_1 radial; 409 struct generated_qbrush_2 { 410 qreal cx; qreal cy; qreal angle; 411 }generated_qbrush_2 conical; 412 } 413 414 private: 415 /+ friend class QLinearGradient; +/ 416 /+ friend class QRadialGradient; +/ 417 /+ friend class QConicalGradient; +/ 418 /+ friend class QBrush; +/ 419 420 Type m_type; 421 Spread m_spread; 422 QGradientStops m_stops; 423 QGradientData m_data; 424 void* dummy; // ### Qt 6: replace with actual content (CoordinateMode, InterpolationMode, ...) 425 } 426 427 extern(C++, class) struct /+ Q_GUI_EXPORT +/ QLinearGradient 428 { 429 public QGradient base0; 430 alias base0 this; 431 public: 432 @disable this(); 433 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 434 ref typeof(this) rawConstructor(); 435 static typeof(this) create() 436 { 437 typeof(this) r = typeof(this).init; 438 r.rawConstructor(); 439 return r; 440 } 441 442 this(ref const(QPointF) start, ref const(QPointF) finalStop); 443 this(qreal xStart, qreal yStart, qreal xFinalStop, qreal yFinalStop); 444 ~this(); 445 446 QPointF start() const; 447 void setStart(ref const(QPointF) start); 448 pragma(inline, true) void setStart(qreal x, qreal y) { auto tmp = QPointF(x, y); setStart(tmp); } 449 450 QPointF finalStop() const; 451 void setFinalStop(ref const(QPointF) stop); 452 pragma(inline, true) void setFinalStop(qreal x, qreal y) { auto tmp = QPointF(x, y); setFinalStop(tmp); } 453 } 454 455 456 extern(C++, class) struct /+ Q_GUI_EXPORT +/ QRadialGradient 457 { 458 public QGradient base0; 459 alias base0 this; 460 public: 461 @disable this(); 462 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 463 ref typeof(this) rawConstructor(); 464 static typeof(this) create() 465 { 466 typeof(this) r = typeof(this).init; 467 r.rawConstructor(); 468 return r; 469 } 470 471 this(ref const(QPointF) center, qreal radius, ref const(QPointF) focalPoint); 472 this(qreal cx, qreal cy, qreal radius, qreal fx, qreal fy); 473 474 this(ref const(QPointF) center, qreal radius); 475 this(qreal cx, qreal cy, qreal radius); 476 477 this(ref const(QPointF) center, qreal centerRadius, ref const(QPointF) focalPoint, qreal focalRadius); 478 this(qreal cx, qreal cy, qreal centerRadius, qreal fx, qreal fy, qreal focalRadius); 479 480 ~this(); 481 482 QPointF center() const; 483 void setCenter(ref const(QPointF) center); 484 pragma(inline, true) void setCenter(qreal x, qreal y) { auto tmp = QPointF(x, y); setCenter(tmp); } 485 486 QPointF focalPoint() const; 487 void setFocalPoint(ref const(QPointF) focalPoint); 488 pragma(inline, true) void setFocalPoint(qreal x, qreal y) { auto tmp = QPointF(x, y); setFocalPoint(tmp); } 489 490 qreal radius() const; 491 void setRadius(qreal radius); 492 493 qreal centerRadius() const; 494 void setCenterRadius(qreal radius); 495 496 qreal focalRadius() const; 497 void setFocalRadius(qreal radius); 498 } 499 500 501 extern(C++, class) struct /+ Q_GUI_EXPORT +/ QConicalGradient 502 { 503 public QGradient base0; 504 alias base0 this; 505 public: 506 @disable this(); 507 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 508 ref typeof(this) rawConstructor(); 509 static typeof(this) create() 510 { 511 typeof(this) r = typeof(this).init; 512 r.rawConstructor(); 513 return r; 514 } 515 516 this(ref const(QPointF) center, qreal startAngle); 517 this(qreal cx, qreal cy, qreal startAngle); 518 ~this(); 519 520 QPointF center() const; 521 void setCenter(ref const(QPointF) center); 522 pragma(inline, true) void setCenter(qreal x, qreal y) { auto tmp = QPointF(x, y); setCenter(tmp); } 523 524 qreal angle() const; 525 void setAngle(qreal angle); 526 } 527