| 1 | { Common types for BGRA Controls package
|
|---|
| 2 |
|
|---|
| 3 | Copyright (C) 2011 Krzysztof Dibowski dibowski at interia.pl
|
|---|
| 4 |
|
|---|
| 5 | This library is free software; you can redistribute it and/or modify it
|
|---|
| 6 | under the terms of the GNU Library General Public License as published by
|
|---|
| 7 | the Free Software Foundation; either version 2 of the License, or (at your
|
|---|
| 8 | option) any later version with the following modification:
|
|---|
| 9 |
|
|---|
| 10 | As a special exception, the copyright holders of this library give you
|
|---|
| 11 | permission to link this library with independent modules to produce an
|
|---|
| 12 | executable, regardless of the license terms of these independent modules,and
|
|---|
| 13 | to copy and distribute the resulting executable under terms of your choice,
|
|---|
| 14 | provided that you also meet, for each linked independent module, the terms
|
|---|
| 15 | and conditions of the license of that module. An independent module is a
|
|---|
| 16 | module which is not derived from or based on this library. If you modify
|
|---|
| 17 | this library, you may extend this exception to your version of the library,
|
|---|
| 18 | but you are not obligated to do so. If you do not wish to do so, delete this
|
|---|
| 19 | exception statement from your version.
|
|---|
| 20 |
|
|---|
| 21 | This program is distributed in the hope that it will be useful, but WITHOUT
|
|---|
| 22 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|---|
| 23 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
|
|---|
| 24 | for more details.
|
|---|
| 25 |
|
|---|
| 26 | You should have received a copy of the GNU Library General Public License
|
|---|
| 27 | along with this library; if not, write to the Free Software Foundation,
|
|---|
| 28 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|---|
| 29 | }
|
|---|
| 30 | unit BCTypes;
|
|---|
| 31 |
|
|---|
| 32 | {$mode objfpc}{$H+}
|
|---|
| 33 |
|
|---|
| 34 | interface
|
|---|
| 35 |
|
|---|
| 36 | uses
|
|---|
| 37 | Classes, Controls, BGRABitmap, BGRABitmapTypes, Graphics, BCBasectrls;
|
|---|
| 38 |
|
|---|
| 39 | type
|
|---|
| 40 | TBCMouseState = (msNone, msHover, msClicked);
|
|---|
| 41 | TBCAlignment = (bcaLeftTop, bcaLeftCenter, bcaLeftBottom,
|
|---|
| 42 | bcaCenterTop, bcaCenter, bcaCenterBottom, bcaRightTop, bcaRightCenter,
|
|---|
| 43 | bcaRightBottom);
|
|---|
| 44 | TBCBackgroundStyle = (bbsClear, bbsColor, bbsGradient);
|
|---|
| 45 | TBCBorderStyle = (bboNone, bboSolid);
|
|---|
| 46 | TBCArrowDirection = (badLeft, badRight, badUp, badDown);
|
|---|
| 47 | TBGRATextAlign = (btaLeft, btaCenter, btaRight); // deprecated
|
|---|
| 48 | TBGRATextVAlign = (btvaTop, btvaCenter, btvaBottom); // deprecated
|
|---|
| 49 | TBGRARedrawEvent = procedure(Sender: TObject; Bitmap: TBGRABitmap) of object;
|
|---|
| 50 |
|
|---|
| 51 | type
|
|---|
| 52 | { TBCGradient }
|
|---|
| 53 |
|
|---|
| 54 | TBCGradient = class(TBCProperty)
|
|---|
| 55 | private
|
|---|
| 56 | FColorCorrection: boolean;
|
|---|
| 57 | FDrawMode: TDrawMode;
|
|---|
| 58 | FGradientType: TGradientType;
|
|---|
| 59 | FEndColor: TColor;
|
|---|
| 60 | FEndColorOpacity: byte;
|
|---|
| 61 | FPoint1XPercent: single;
|
|---|
| 62 | FPoint1YPercent: single;
|
|---|
| 63 | FPoint2XPercent: single;
|
|---|
| 64 | FPoint2YPercent: single;
|
|---|
| 65 | FSinus: boolean;
|
|---|
| 66 | FStartColor: TColor;
|
|---|
| 67 | FStartColorOpacity: byte;
|
|---|
| 68 | procedure SetColorCorrection(const AValue: boolean);
|
|---|
| 69 | procedure SetDrawMode(const AValue: TDrawMode);
|
|---|
| 70 | procedure SetEndColor(const AValue: TColor);
|
|---|
| 71 | procedure SetEndColorOpacity(const AValue: byte);
|
|---|
| 72 | procedure SetGradientType(const AValue: TGradientType);
|
|---|
| 73 | procedure SetPoint1XPercent(const AValue: single);
|
|---|
| 74 | procedure SetPoint1YPercent(const AValue: single);
|
|---|
| 75 | procedure SetPoint2XPercent(const AValue: single);
|
|---|
| 76 | procedure SetPoint2YPercent(const AValue: single);
|
|---|
| 77 | procedure SetSinus(const AValue: boolean);
|
|---|
| 78 | procedure SetStartColor(const AValue: TColor);
|
|---|
| 79 | procedure SetStartColorOpacity(const AValue: byte);
|
|---|
| 80 | public
|
|---|
| 81 | constructor Create(AControl: TControl); override;
|
|---|
| 82 |
|
|---|
| 83 | procedure Assign(Source: TPersistent); override;
|
|---|
| 84 | published
|
|---|
| 85 | property StartColor: TColor Read FStartColor Write SetStartColor;
|
|---|
| 86 | property StartColorOpacity: byte Read FStartColorOpacity
|
|---|
| 87 | Write SetStartColorOpacity;
|
|---|
| 88 | property DrawMode: TDrawMode Read FDrawMode Write SetDrawMode;
|
|---|
| 89 | property EndColor: TColor Read FEndColor Write SetEndColor;
|
|---|
| 90 | property EndColorOpacity: byte Read FEndColorOpacity
|
|---|
| 91 | Write SetEndColorOpacity;
|
|---|
| 92 | property ColorCorrection: boolean Read FColorCorrection
|
|---|
| 93 | Write SetColorCorrection;
|
|---|
| 94 | property GradientType: TGradientType Read FGradientType
|
|---|
| 95 | Write SetGradientType;
|
|---|
| 96 | property Point1XPercent: single Read FPoint1XPercent Write SetPoint1XPercent;
|
|---|
| 97 | property Point1YPercent: single Read FPoint1YPercent Write SetPoint1YPercent;
|
|---|
| 98 | property Point2XPercent: single Read FPoint2XPercent Write SetPoint2XPercent;
|
|---|
| 99 | property Point2YPercent: single Read FPoint2YPercent Write SetPoint2YPercent;
|
|---|
| 100 | property Sinus: boolean Read FSinus Write SetSinus;
|
|---|
| 101 | end;
|
|---|
| 102 |
|
|---|
| 103 | { TBCFont }
|
|---|
| 104 |
|
|---|
| 105 | TBCFont = class(TBCProperty)
|
|---|
| 106 | private
|
|---|
| 107 | FColor: TColor;
|
|---|
| 108 | FEndEllipsis: Boolean;
|
|---|
| 109 | FFontQuality: TBGRAFontQuality;
|
|---|
| 110 | FHeight: Integer;
|
|---|
| 111 | FName: String;
|
|---|
| 112 | FShadow: Boolean;
|
|---|
| 113 | FShadowColor: TColor;
|
|---|
| 114 | FShadowColorOpacity: Byte;
|
|---|
| 115 | FShadowOffsetX: ShortInt;
|
|---|
| 116 | FShadowOffsetY: ShortInt;
|
|---|
| 117 | FShadowRadius: Byte;
|
|---|
| 118 | FSingleLine: Boolean;
|
|---|
| 119 | FStyle: TFontStyles;
|
|---|
| 120 | FTextAlignment: TBCAlignment;
|
|---|
| 121 | FWordBreak: Boolean;
|
|---|
| 122 | function IsNamStored: Boolean;
|
|---|
| 123 | procedure SetColor(AValue: TColor);
|
|---|
| 124 | procedure SetEndEllipsis(AValue: Boolean);
|
|---|
| 125 | procedure SetFontQuality(AValue: TBGRAFontQuality);
|
|---|
| 126 | procedure SetHeight(AValue: Integer);
|
|---|
| 127 | procedure SetName(AValue: String);
|
|---|
| 128 | procedure SetShadow(AValue: Boolean);
|
|---|
| 129 | procedure SetShadowColor(AValue: TColor);
|
|---|
| 130 | procedure SetShadowColorOpacity(AValue: Byte);
|
|---|
| 131 | procedure SetShadowOffsetX(AValue: ShortInt);
|
|---|
| 132 | procedure SetShadowOffsetY(AValue: ShortInt);
|
|---|
| 133 | procedure SetShadowRadius(AValue: Byte);
|
|---|
| 134 | procedure SetSingleLine(AValue: Boolean);
|
|---|
| 135 | procedure SetStyle(AValue: TFontStyles);
|
|---|
| 136 | procedure SetTextAlignment(AValue: TBCAlignment);
|
|---|
| 137 | procedure SetWordBreak(AValue: Boolean);
|
|---|
| 138 | public
|
|---|
| 139 | constructor Create(AControl: TControl); override;
|
|---|
| 140 | procedure Assign(Source: TPersistent); override;
|
|---|
| 141 | published
|
|---|
| 142 | property Color: TColor read FColor write SetColor;
|
|---|
| 143 | property EndEllipsis: Boolean read FEndEllipsis write SetEndEllipsis;
|
|---|
| 144 | property FontQuality: TBGRAFontQuality
|
|---|
| 145 | read FFontQuality write SetFontQuality;
|
|---|
| 146 | property Height: Integer read FHeight write SetHeight;
|
|---|
| 147 | property Name: String read FName write SetName stored IsNamStored;
|
|---|
| 148 | property SingleLine: Boolean read FSingleLine write SetSingleLine;
|
|---|
| 149 | property Shadow: Boolean read FShadow write SetShadow;
|
|---|
| 150 | property ShadowColor: TColor
|
|---|
| 151 | read FShadowColor write SetShadowColor;
|
|---|
| 152 | property ShadowColorOpacity: Byte read FShadowColorOpacity write SetShadowColorOpacity;
|
|---|
| 153 | property ShadowRadius: Byte
|
|---|
| 154 | read FShadowRadius write SetShadowRadius;
|
|---|
| 155 | property ShadowOffsetX: ShortInt
|
|---|
| 156 | read FShadowOffsetX write SetShadowOffsetX;
|
|---|
| 157 | property ShadowOffsetY: ShortInt
|
|---|
| 158 | read FShadowOffsetY write SetShadowOffsetY;
|
|---|
| 159 | property Style: TFontStyles read FStyle write SetStyle;
|
|---|
| 160 | property TextAlignment: TBCAlignment
|
|---|
| 161 | read FTextAlignment write SetTextAlignment;
|
|---|
| 162 | property WordBreak: Boolean read FWordBreak write SetWordBreak;
|
|---|
| 163 | end;
|
|---|
| 164 |
|
|---|
| 165 | { TBCBackground }
|
|---|
| 166 |
|
|---|
| 167 | TBCBackground = class(TBCProperty)
|
|---|
| 168 | private
|
|---|
| 169 | FColor: TColor;
|
|---|
| 170 | FColorOpacity: byte;
|
|---|
| 171 | FGradient1: TBCGradient;
|
|---|
| 172 | FGradient1EndPercent: single;
|
|---|
| 173 | FGradient2: TBCGradient;
|
|---|
| 174 | FStyle: TBCBackgroundStyle;
|
|---|
| 175 | procedure OnChangeChildProperty(Sender: TObject; AData: PtrInt);
|
|---|
| 176 | procedure SetColor(AValue: TColor);
|
|---|
| 177 | procedure SetColorOpacity(AValue: byte);
|
|---|
| 178 | procedure SetGradient1(AValue: TBCGradient);
|
|---|
| 179 | procedure SetGradient1EndPercent(AValue: single);
|
|---|
| 180 | procedure SetGradient2(AValue: TBCGradient);
|
|---|
| 181 | procedure SetStyle(AValue: TBCBackgroundStyle);
|
|---|
| 182 | public
|
|---|
| 183 | constructor Create(AControl: TControl); override;
|
|---|
| 184 | destructor Destroy; override;
|
|---|
| 185 |
|
|---|
| 186 | procedure Assign(Source: TPersistent); override;
|
|---|
| 187 | published
|
|---|
| 188 | property Color: TColor read FColor write SetColor;
|
|---|
| 189 | property ColorOpacity: byte read FColorOpacity write SetColorOpacity;
|
|---|
| 190 | property Gradient1: TBCGradient read FGradient1 write SetGradient1;
|
|---|
| 191 | property Gradient2: TBCGradient read FGradient2 write SetGradient2;
|
|---|
| 192 | property Gradient1EndPercent: single read FGradient1EndPercent
|
|---|
| 193 | write SetGradient1EndPercent;
|
|---|
| 194 | property Style: TBCBackgroundStyle read FStyle write SetStyle;
|
|---|
| 195 | end;
|
|---|
| 196 |
|
|---|
| 197 | { TBCBorder }
|
|---|
| 198 |
|
|---|
| 199 | TBCBorder = class(TBCProperty)
|
|---|
| 200 | private
|
|---|
| 201 | FColor: TColor;
|
|---|
| 202 | FColorOpacity: byte;
|
|---|
| 203 | FLightColor: TColor;
|
|---|
| 204 | FLightOpacity: byte;
|
|---|
| 205 | FLightWidth: integer;
|
|---|
| 206 | FStyle: TBCBorderStyle;
|
|---|
| 207 | FWidth: Integer;
|
|---|
| 208 | procedure SetColor(AValue: TColor);
|
|---|
| 209 | procedure SetColorOpacity(AValue: byte);
|
|---|
| 210 | procedure SetLightColor(AValue: TColor);
|
|---|
| 211 | procedure SetLightOpacity(AValue: byte);
|
|---|
| 212 | procedure SetLightWidth(AValue: integer);
|
|---|
| 213 | procedure SetStyle(AValue: TBCBorderStyle);
|
|---|
| 214 | procedure SetWidth(AValue: Integer);
|
|---|
| 215 | public
|
|---|
| 216 | constructor Create(AControl: TControl); override;
|
|---|
| 217 | procedure Assign(Source: TPersistent); override;
|
|---|
| 218 | published
|
|---|
| 219 | property Color: TColor read FColor write SetColor;
|
|---|
| 220 | property ColorOpacity: byte read FColorOpacity
|
|---|
| 221 | write SetColorOpacity;
|
|---|
| 222 | property LightColor: TColor read FLightColor write SetLightColor;
|
|---|
| 223 | property LightOpacity: byte read FLightOpacity write SetLightOpacity;
|
|---|
| 224 | property LightWidth: integer read FLightWidth write SetLightWidth;
|
|---|
| 225 | property Style: TBCBorderStyle read FStyle write SetStyle;
|
|---|
| 226 | property Width: Integer read FWidth write SetWidth;
|
|---|
| 227 | end;
|
|---|
| 228 |
|
|---|
| 229 | { TBCRounding }
|
|---|
| 230 |
|
|---|
| 231 | TBCRounding = class(TBCProperty)
|
|---|
| 232 | private
|
|---|
| 233 | FRoundOptions: TRoundRectangleOptions;
|
|---|
| 234 | FRoundX: Byte;
|
|---|
| 235 | FRoundY: Byte;
|
|---|
| 236 | procedure SetRoundOptions(AValue: TRoundRectangleOptions);
|
|---|
| 237 | procedure SetRoundX(AValue: Byte);
|
|---|
| 238 | procedure SetRoundY(AValue: Byte);
|
|---|
| 239 | public
|
|---|
| 240 | constructor Create(AControl: TControl); override;
|
|---|
| 241 | procedure Assign(Source: TPersistent); override;
|
|---|
| 242 | published
|
|---|
| 243 | property RoundX: Byte read FRoundX write SetRoundX;
|
|---|
| 244 | property RoundY: Byte read FRoundY write SetRoundY;
|
|---|
| 245 | property RoundOptions: TRoundRectangleOptions
|
|---|
| 246 | read FRoundOptions write SetRoundOptions;
|
|---|
| 247 | end;
|
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 | {const
|
|---|
| 251 | DEF_START_COL = $00EFE6D2;
|
|---|
| 252 | DEF_END_COL = $00C87511;
|
|---|
| 253 | DEF_BORD_COL = $00AB713B;
|
|---|
| 254 | DEF_BORD_COL_HOVER = $00D7B697;
|
|---|
| 255 | DEF_FONT_COLOR = $0072412A; }
|
|---|
| 256 |
|
|---|
| 257 | implementation
|
|---|
| 258 |
|
|---|
| 259 | { TBCRounding }
|
|---|
| 260 |
|
|---|
| 261 | procedure TBCRounding.SetRoundOptions(AValue: TRoundRectangleOptions);
|
|---|
| 262 | begin
|
|---|
| 263 | if FRoundOptions = AValue then Exit;
|
|---|
| 264 | FRoundOptions := AValue;
|
|---|
| 265 |
|
|---|
| 266 | Change;
|
|---|
| 267 | end;
|
|---|
| 268 |
|
|---|
| 269 | procedure TBCRounding.SetRoundX(AValue: Byte);
|
|---|
| 270 | begin
|
|---|
| 271 | if FRoundX = AValue then Exit;
|
|---|
| 272 | FRoundX := AValue;
|
|---|
| 273 |
|
|---|
| 274 | Change;
|
|---|
| 275 | end;
|
|---|
| 276 |
|
|---|
| 277 | procedure TBCRounding.SetRoundY(AValue: Byte);
|
|---|
| 278 | begin
|
|---|
| 279 | if FRoundY = AValue then Exit;
|
|---|
| 280 | FRoundY := AValue;
|
|---|
| 281 |
|
|---|
| 282 | Change;
|
|---|
| 283 | end;
|
|---|
| 284 |
|
|---|
| 285 | constructor TBCRounding.Create(AControl: TControl);
|
|---|
| 286 | begin
|
|---|
| 287 | inherited Create(AControl);
|
|---|
| 288 |
|
|---|
| 289 | FRoundX := 1;
|
|---|
| 290 | FRoundY := 1;
|
|---|
| 291 | FRoundOptions := [];
|
|---|
| 292 | end;
|
|---|
| 293 |
|
|---|
| 294 | procedure TBCRounding.Assign(Source: TPersistent);
|
|---|
| 295 | begin
|
|---|
| 296 | if Source is TBCRounding then
|
|---|
| 297 | begin
|
|---|
| 298 | FRoundX := TBCRounding(Source).FRoundX;
|
|---|
| 299 | FRoundY := TBCRounding(Source).FRoundY;
|
|---|
| 300 | FRoundOptions := TBCRounding(Source).FRoundOptions;
|
|---|
| 301 | end
|
|---|
| 302 | else
|
|---|
| 303 | inherited Assign(Source);
|
|---|
| 304 | end;
|
|---|
| 305 |
|
|---|
| 306 | { TBCGradient }
|
|---|
| 307 |
|
|---|
| 308 | procedure TBCGradient.SetColorCorrection(const AValue: boolean);
|
|---|
| 309 | begin
|
|---|
| 310 | if FColorCorrection = AValue then
|
|---|
| 311 | exit;
|
|---|
| 312 | FColorCorrection := AValue;
|
|---|
| 313 |
|
|---|
| 314 | Change;
|
|---|
| 315 | end;
|
|---|
| 316 |
|
|---|
| 317 | procedure TBCGradient.SetDrawMode(const AValue: TDrawMode);
|
|---|
| 318 | begin
|
|---|
| 319 | if FDrawMode = AValue then
|
|---|
| 320 | exit;
|
|---|
| 321 | FDrawMode := AValue;
|
|---|
| 322 |
|
|---|
| 323 | Change;
|
|---|
| 324 | end;
|
|---|
| 325 |
|
|---|
| 326 | procedure TBCGradient.SetEndColor(const AValue: TColor);
|
|---|
| 327 | begin
|
|---|
| 328 | if FEndColor = AValue then
|
|---|
| 329 | exit;
|
|---|
| 330 | FEndColor := AValue;
|
|---|
| 331 |
|
|---|
| 332 | Change;
|
|---|
| 333 | end;
|
|---|
| 334 |
|
|---|
| 335 | procedure TBCGradient.SetEndColorOpacity(const AValue: byte);
|
|---|
| 336 | begin
|
|---|
| 337 | if FEndColorOpacity = AValue then
|
|---|
| 338 | exit;
|
|---|
| 339 | FEndColorOpacity := AValue;
|
|---|
| 340 |
|
|---|
| 341 | Change;
|
|---|
| 342 | end;
|
|---|
| 343 |
|
|---|
| 344 | procedure TBCGradient.SetGradientType(const AValue: TGradientType);
|
|---|
| 345 | begin
|
|---|
| 346 | if FGradientType = AValue then
|
|---|
| 347 | exit;
|
|---|
| 348 | FGradientType := AValue;
|
|---|
| 349 |
|
|---|
| 350 | Change;
|
|---|
| 351 | end;
|
|---|
| 352 |
|
|---|
| 353 | procedure TBCGradient.SetPoint1XPercent(const AValue: single);
|
|---|
| 354 | begin
|
|---|
| 355 | if FPoint1XPercent = AValue then
|
|---|
| 356 | exit;
|
|---|
| 357 | FPoint1XPercent := AValue;
|
|---|
| 358 |
|
|---|
| 359 | Change;
|
|---|
| 360 | end;
|
|---|
| 361 |
|
|---|
| 362 | procedure TBCGradient.SetPoint1YPercent(const AValue: single);
|
|---|
| 363 | begin
|
|---|
| 364 | if FPoint1YPercent = AValue then
|
|---|
| 365 | exit;
|
|---|
| 366 | FPoint1YPercent := AValue;
|
|---|
| 367 |
|
|---|
| 368 | Change;
|
|---|
| 369 | end;
|
|---|
| 370 |
|
|---|
| 371 | procedure TBCGradient.SetPoint2XPercent(const AValue: single);
|
|---|
| 372 | begin
|
|---|
| 373 | if FPoint2XPercent = AValue then
|
|---|
| 374 | exit;
|
|---|
| 375 | FPoint2XPercent := AValue;
|
|---|
| 376 |
|
|---|
| 377 | Change;
|
|---|
| 378 | end;
|
|---|
| 379 |
|
|---|
| 380 | procedure TBCGradient.SetPoint2YPercent(const AValue: single);
|
|---|
| 381 | begin
|
|---|
| 382 | if FPoint2YPercent = AValue then
|
|---|
| 383 | exit;
|
|---|
| 384 | FPoint2YPercent := AValue;
|
|---|
| 385 |
|
|---|
| 386 | Change;
|
|---|
| 387 | end;
|
|---|
| 388 |
|
|---|
| 389 | procedure TBCGradient.SetSinus(const AValue: boolean);
|
|---|
| 390 | begin
|
|---|
| 391 | if FSinus = AValue then
|
|---|
| 392 | exit;
|
|---|
| 393 | FSinus := AValue;
|
|---|
| 394 |
|
|---|
| 395 | Change;
|
|---|
| 396 | end;
|
|---|
| 397 |
|
|---|
| 398 | procedure TBCGradient.SetStartColor(const AValue: TColor);
|
|---|
| 399 | begin
|
|---|
| 400 | if FStartColor = AValue then
|
|---|
| 401 | exit;
|
|---|
| 402 | FStartColor := AValue;
|
|---|
| 403 |
|
|---|
| 404 | Change;
|
|---|
| 405 | end;
|
|---|
| 406 |
|
|---|
| 407 | procedure TBCGradient.SetStartColorOpacity(const AValue: byte);
|
|---|
| 408 | begin
|
|---|
| 409 | if FStartColorOpacity = AValue then
|
|---|
| 410 | exit;
|
|---|
| 411 | FStartColorOpacity := AValue;
|
|---|
| 412 |
|
|---|
| 413 | Change;
|
|---|
| 414 | end;
|
|---|
| 415 |
|
|---|
| 416 | constructor TBCGradient.Create(AControl: TControl);
|
|---|
| 417 | begin
|
|---|
| 418 | FStartColor := clWhite;
|
|---|
| 419 | FStartColorOpacity := 255;
|
|---|
| 420 | FDrawMode := dmSet;
|
|---|
| 421 | FEndColor := clBlack;
|
|---|
| 422 | FEndColorOpacity := 255;
|
|---|
| 423 | FGradientType := gtLinear;
|
|---|
| 424 | FColorCorrection := True;
|
|---|
| 425 | FSinus := False;
|
|---|
| 426 |
|
|---|
| 427 | FPoint1XPercent := 0;
|
|---|
| 428 | FPoint1YPercent := 0;
|
|---|
| 429 | FPoint2XPercent := 0;
|
|---|
| 430 | FPoint2YPercent := 100;
|
|---|
| 431 |
|
|---|
| 432 | inherited Create(AControl);
|
|---|
| 433 | end;
|
|---|
| 434 |
|
|---|
| 435 | procedure TBCGradient.Assign(Source: TPersistent);
|
|---|
| 436 | begin
|
|---|
| 437 | if Source is TBCGradient then
|
|---|
| 438 | begin
|
|---|
| 439 | FStartColor := TBCGradient(Source).FStartColor;
|
|---|
| 440 | FStartColorOpacity := TBCGradient(Source).FStartColorOpacity;
|
|---|
| 441 | FDrawMode := TBCGradient(Source).FDrawMode;
|
|---|
| 442 | FEndColor := TBCGradient(Source).FEndColor;
|
|---|
| 443 | FEndColorOpacity := TBCGradient(Source).FEndColorOpacity;
|
|---|
| 444 | FColorCorrection := TBCGradient(Source).FColorCorrection;
|
|---|
| 445 | FGradientType := TBCGradient(Source).FGradientType;
|
|---|
| 446 | FPoint1XPercent := TBCGradient(Source).FPoint1XPercent;
|
|---|
| 447 | FPoint1YPercent := TBCGradient(Source).FPoint1YPercent;
|
|---|
| 448 | FPoint2XPercent := TBCGradient(Source).FPoint2XPercent;
|
|---|
| 449 | FPoint2YPercent := TBCGradient(Source).FPoint2YPercent;
|
|---|
| 450 | FSinus := TBCGradient(Source).FSinus;
|
|---|
| 451 |
|
|---|
| 452 | Change;
|
|---|
| 453 | end
|
|---|
| 454 | else
|
|---|
| 455 | inherited Assign(Source);
|
|---|
| 456 | end;
|
|---|
| 457 |
|
|---|
| 458 | { TBCFont }
|
|---|
| 459 |
|
|---|
| 460 | function TBCFont.IsNamStored: Boolean;
|
|---|
| 461 | begin
|
|---|
| 462 | Result := DefFontData.Name <> Name;
|
|---|
| 463 | end;
|
|---|
| 464 |
|
|---|
| 465 | procedure TBCFont.SetColor(AValue: TColor);
|
|---|
| 466 | begin
|
|---|
| 467 | if FColor = AValue then Exit;
|
|---|
| 468 | FColor := AValue;
|
|---|
| 469 |
|
|---|
| 470 | Change;
|
|---|
| 471 | end;
|
|---|
| 472 |
|
|---|
| 473 | procedure TBCFont.SetEndEllipsis(AValue: Boolean);
|
|---|
| 474 | begin
|
|---|
| 475 | if FEndEllipsis = AValue then Exit;
|
|---|
| 476 | FEndEllipsis := AValue;
|
|---|
| 477 |
|
|---|
| 478 | Change;
|
|---|
| 479 | end;
|
|---|
| 480 |
|
|---|
| 481 | procedure TBCFont.SetFontQuality(AValue: TBGRAFontQuality);
|
|---|
| 482 | begin
|
|---|
| 483 | if FFontQuality = AValue then Exit;
|
|---|
| 484 | FFontQuality := AValue;
|
|---|
| 485 |
|
|---|
| 486 | Change;
|
|---|
| 487 | end;
|
|---|
| 488 |
|
|---|
| 489 | procedure TBCFont.SetHeight(AValue: Integer);
|
|---|
| 490 | begin
|
|---|
| 491 | if FHeight = AValue then Exit;
|
|---|
| 492 | FHeight := AValue;
|
|---|
| 493 |
|
|---|
| 494 | Change;
|
|---|
| 495 | end;
|
|---|
| 496 |
|
|---|
| 497 | procedure TBCFont.SetName(AValue: String);
|
|---|
| 498 | begin
|
|---|
| 499 | if FName = AValue then Exit;
|
|---|
| 500 | FName := AValue;
|
|---|
| 501 | if FName='' then
|
|---|
| 502 | FName := 'default';
|
|---|
| 503 | Change;
|
|---|
| 504 | end;
|
|---|
| 505 |
|
|---|
| 506 | procedure TBCFont.SetShadow(AValue: Boolean);
|
|---|
| 507 | begin
|
|---|
| 508 | if FShadow = AValue then Exit;
|
|---|
| 509 | FShadow := AValue;
|
|---|
| 510 |
|
|---|
| 511 | Change;
|
|---|
| 512 | end;
|
|---|
| 513 |
|
|---|
| 514 | procedure TBCFont.SetShadowColor(AValue: TColor);
|
|---|
| 515 | begin
|
|---|
| 516 | if FShadowColor = AValue then Exit;
|
|---|
| 517 | FShadowColor := AValue;
|
|---|
| 518 |
|
|---|
| 519 | Change;
|
|---|
| 520 | end;
|
|---|
| 521 |
|
|---|
| 522 | procedure TBCFont.SetShadowColorOpacity(AValue: Byte);
|
|---|
| 523 | begin
|
|---|
| 524 | if FShadowColorOpacity = AValue then Exit;
|
|---|
| 525 | FShadowColorOpacity := AValue;
|
|---|
| 526 |
|
|---|
| 527 | Change;
|
|---|
| 528 | end;
|
|---|
| 529 |
|
|---|
| 530 | procedure TBCFont.SetShadowOffsetX(AValue: ShortInt);
|
|---|
| 531 | begin
|
|---|
| 532 | if FShadowOffsetX = AValue then Exit;
|
|---|
| 533 | FShadowOffsetX := AValue;
|
|---|
| 534 |
|
|---|
| 535 | Change;
|
|---|
| 536 | end;
|
|---|
| 537 |
|
|---|
| 538 | procedure TBCFont.SetShadowOffsetY(AValue: ShortInt);
|
|---|
| 539 | begin
|
|---|
| 540 | if FShadowOffsetY = AValue then Exit;
|
|---|
| 541 | FShadowOffsetY := AValue;
|
|---|
| 542 |
|
|---|
| 543 | Change;
|
|---|
| 544 | end;
|
|---|
| 545 |
|
|---|
| 546 | procedure TBCFont.SetShadowRadius(AValue: Byte);
|
|---|
| 547 | begin
|
|---|
| 548 | if FShadowRadius = AValue then Exit;
|
|---|
| 549 | FShadowRadius := AValue;
|
|---|
| 550 |
|
|---|
| 551 | Change;
|
|---|
| 552 | end;
|
|---|
| 553 |
|
|---|
| 554 | procedure TBCFont.SetSingleLine(AValue: Boolean);
|
|---|
| 555 | begin
|
|---|
| 556 | if FSingleLine = AValue then Exit;
|
|---|
| 557 | FSingleLine := AValue;
|
|---|
| 558 |
|
|---|
| 559 | if FSingleLine then
|
|---|
| 560 | FWordBreak := False;
|
|---|
| 561 |
|
|---|
| 562 | Change;
|
|---|
| 563 | end;
|
|---|
| 564 |
|
|---|
| 565 | procedure TBCFont.SetStyle(AValue: TFontStyles);
|
|---|
| 566 | begin
|
|---|
| 567 | if FStyle = AValue then Exit;
|
|---|
| 568 | FStyle := AValue;
|
|---|
| 569 |
|
|---|
| 570 | Change;
|
|---|
| 571 | end;
|
|---|
| 572 |
|
|---|
| 573 | procedure TBCFont.SetTextAlignment(AValue: TBCAlignment);
|
|---|
| 574 | begin
|
|---|
| 575 | if FTextAlignment = AValue then Exit;
|
|---|
| 576 | FTextAlignment := AValue;
|
|---|
| 577 |
|
|---|
| 578 | Change;
|
|---|
| 579 | end;
|
|---|
| 580 |
|
|---|
| 581 | procedure TBCFont.SetWordBreak(AValue: Boolean);
|
|---|
| 582 | begin
|
|---|
| 583 | if FWordBreak = AValue then Exit;
|
|---|
| 584 | FWordBreak := AValue;
|
|---|
| 585 |
|
|---|
| 586 | if FWordBreak then
|
|---|
| 587 | FSingleLine := False;
|
|---|
| 588 |
|
|---|
| 589 | Change;
|
|---|
| 590 | end;
|
|---|
| 591 |
|
|---|
| 592 | constructor TBCFont.Create(AControl: TControl);
|
|---|
| 593 | begin
|
|---|
| 594 | inherited Create(AControl);
|
|---|
| 595 |
|
|---|
| 596 | // That is temporary. BGRABitmap draw some yellow background when fqSystemClearType.
|
|---|
| 597 | // This problem is reported
|
|---|
| 598 | {$IFDEF LCLGTK2}
|
|---|
| 599 | FFontQuality := fqFineAntialiasing;
|
|---|
| 600 | {$ELSE}
|
|---|
| 601 | FFontQuality := fqSystemClearType;
|
|---|
| 602 | {$ENDIF}
|
|---|
| 603 | FShadow := False;
|
|---|
| 604 | FShadowColor := clBlack;
|
|---|
| 605 | FShadowColorOpacity := 255;
|
|---|
| 606 | FShadowRadius := 5;
|
|---|
| 607 | FShadowOffsetX := 5;
|
|---|
| 608 | FShadowOffsetY := 5;
|
|---|
| 609 | FHeight := 0;
|
|---|
| 610 | FTextAlignment := bcaCenter;
|
|---|
| 611 | FStyle := [];
|
|---|
| 612 | FName := DefFontData.Name;
|
|---|
| 613 | FColor := clDefault;
|
|---|
| 614 | FWordBreak := False;
|
|---|
| 615 | FSingleLine := True;
|
|---|
| 616 | FEndEllipsis := False;
|
|---|
| 617 | end;
|
|---|
| 618 |
|
|---|
| 619 | procedure TBCFont.Assign(Source: TPersistent);
|
|---|
| 620 | begin
|
|---|
| 621 | if Source is TBCFont then
|
|---|
| 622 | begin
|
|---|
| 623 | FColor := TBCFont(Source).FColor;
|
|---|
| 624 | FEndEllipsis := TBCFont(Source).FEndEllipsis;
|
|---|
| 625 | FFontQuality := TBCFont(Source).FFontQuality;
|
|---|
| 626 | FHeight := TBCFont(Source).FHeight;
|
|---|
| 627 | FName := TBCFont(Source).FName;
|
|---|
| 628 | FSingleLine := TBCFont(Source).FSingleLine;
|
|---|
| 629 | FShadow := TBCFont(Source).FShadow;
|
|---|
| 630 | FShadowColor := TBCFont(Source).FShadowColor;
|
|---|
| 631 | FShadowColorOpacity := TBCFont(Source).FShadowColorOpacity;
|
|---|
| 632 | FShadowRadius := TBCFont(Source).FShadowRadius;
|
|---|
| 633 | FShadowOffsetX := TBCFont(Source).FShadowOffsetX;
|
|---|
| 634 | FShadowOffsetY := TBCFont(Source).FShadowOffsetY;
|
|---|
| 635 | FStyle := TBCFont(Source).FStyle;
|
|---|
| 636 | FTextAlignment := TBCFont(Source).FTextAlignment;
|
|---|
| 637 | FWordBreak := TBCFont(Source).FWordBreak;
|
|---|
| 638 |
|
|---|
| 639 | Change;
|
|---|
| 640 | end
|
|---|
| 641 | else
|
|---|
| 642 | inherited Assign(Source);
|
|---|
| 643 | end;
|
|---|
| 644 |
|
|---|
| 645 | { TBCBackground }
|
|---|
| 646 |
|
|---|
| 647 | procedure TBCBackground.SetStyle(AValue: TBCBackgroundStyle);
|
|---|
| 648 | begin
|
|---|
| 649 | if FStyle = AValue then Exit;
|
|---|
| 650 | FStyle := AValue;
|
|---|
| 651 |
|
|---|
| 652 | Change;
|
|---|
| 653 | end;
|
|---|
| 654 |
|
|---|
| 655 | constructor TBCBackground.Create(AControl: TControl);
|
|---|
| 656 | begin
|
|---|
| 657 | FStyle := bbsColor;
|
|---|
| 658 | FColorOpacity := 255;
|
|---|
| 659 | FGradient1 := TBCGradient.Create(AControl);
|
|---|
| 660 | FGradient2 := TBCGradient.Create(AControl);
|
|---|
| 661 | FGradient1EndPercent := 35;
|
|---|
| 662 |
|
|---|
| 663 | FGradient1.OnChange := @OnChangeChildProperty;
|
|---|
| 664 | FGradient2.OnChange := @OnChangeChildProperty;
|
|---|
| 665 | inherited Create(AControl);
|
|---|
| 666 | end;
|
|---|
| 667 |
|
|---|
| 668 | destructor TBCBackground.Destroy;
|
|---|
| 669 | begin
|
|---|
| 670 | FGradient1.Free;
|
|---|
| 671 | FGradient2.Free;
|
|---|
| 672 | inherited Destroy;
|
|---|
| 673 | end;
|
|---|
| 674 |
|
|---|
| 675 | procedure TBCBackground.Assign(Source: TPersistent);
|
|---|
| 676 | begin
|
|---|
| 677 | if Source is TBCBackground then
|
|---|
| 678 | begin
|
|---|
| 679 | FColor := TBCBackground(Source).FColor;
|
|---|
| 680 | FColorOpacity := TBCBackground(Source).FColorOpacity;
|
|---|
| 681 | FGradient1EndPercent := TBCBackground(Source).FGradient1EndPercent;
|
|---|
| 682 | FStyle := TBCBackground(Source).FStyle;
|
|---|
| 683 | FGradient1.Assign(TBCBackground(Source).FGradient1);
|
|---|
| 684 | FGradient2.Assign(TBCBackground(Source).FGradient2);
|
|---|
| 685 | end
|
|---|
| 686 | else
|
|---|
| 687 | inherited Assign(Source);
|
|---|
| 688 | end;
|
|---|
| 689 |
|
|---|
| 690 | procedure TBCBackground.SetGradient1(AValue: TBCGradient);
|
|---|
| 691 | begin
|
|---|
| 692 | if FGradient1 = AValue then Exit;
|
|---|
| 693 | FGradient1 := AValue;
|
|---|
| 694 |
|
|---|
| 695 | Change;
|
|---|
| 696 | end;
|
|---|
| 697 |
|
|---|
| 698 | procedure TBCBackground.OnChangeChildProperty(Sender: TObject; AData: PtrInt);
|
|---|
| 699 | begin
|
|---|
| 700 | Change(AData);
|
|---|
| 701 | end;
|
|---|
| 702 |
|
|---|
| 703 | procedure TBCBackground.SetColor(AValue: TColor);
|
|---|
| 704 | begin
|
|---|
| 705 | if FColor = AValue then Exit;
|
|---|
| 706 | FColor := AValue;
|
|---|
| 707 |
|
|---|
| 708 | Change;
|
|---|
| 709 | end;
|
|---|
| 710 |
|
|---|
| 711 | procedure TBCBackground.SetColorOpacity(AValue: byte);
|
|---|
| 712 | begin
|
|---|
| 713 | if FColorOpacity = AValue then Exit;
|
|---|
| 714 | FColorOpacity := AValue;
|
|---|
| 715 |
|
|---|
| 716 | Change;
|
|---|
| 717 | end;
|
|---|
| 718 |
|
|---|
| 719 | procedure TBCBackground.SetGradient1EndPercent(AValue: single);
|
|---|
| 720 | begin
|
|---|
| 721 | if FGradient1EndPercent = AValue then Exit;
|
|---|
| 722 | FGradient1EndPercent := AValue;
|
|---|
| 723 |
|
|---|
| 724 | Change;
|
|---|
| 725 | end;
|
|---|
| 726 |
|
|---|
| 727 | procedure TBCBackground.SetGradient2(AValue: TBCGradient);
|
|---|
| 728 | begin
|
|---|
| 729 | if FGradient2 = AValue then Exit;
|
|---|
| 730 | FGradient2 := AValue;
|
|---|
| 731 |
|
|---|
| 732 | Change;
|
|---|
| 733 | end;
|
|---|
| 734 |
|
|---|
| 735 | { TBCBorder }
|
|---|
| 736 |
|
|---|
| 737 | procedure TBCBorder.SetLightColor(AValue: TColor);
|
|---|
| 738 | begin
|
|---|
| 739 | if FLightColor = AValue then Exit;
|
|---|
| 740 | FLightColor := AValue;
|
|---|
| 741 |
|
|---|
| 742 | Change;
|
|---|
| 743 | end;
|
|---|
| 744 |
|
|---|
| 745 | procedure TBCBorder.SetColor(AValue: TColor);
|
|---|
| 746 | begin
|
|---|
| 747 | if FColor = AValue then Exit;
|
|---|
| 748 | FColor := AValue;
|
|---|
| 749 |
|
|---|
| 750 | Change;
|
|---|
| 751 | end;
|
|---|
| 752 |
|
|---|
| 753 | procedure TBCBorder.SetColorOpacity(AValue: byte);
|
|---|
| 754 | begin
|
|---|
| 755 | if FColorOpacity = AValue then Exit;
|
|---|
| 756 | FColorOpacity := AValue;
|
|---|
| 757 |
|
|---|
| 758 | Change;
|
|---|
| 759 | end;
|
|---|
| 760 |
|
|---|
| 761 | procedure TBCBorder.SetLightOpacity(AValue: byte);
|
|---|
| 762 | begin
|
|---|
| 763 | if FLightOpacity = AValue then Exit;
|
|---|
| 764 | FLightOpacity := AValue;
|
|---|
| 765 |
|
|---|
| 766 | Change;
|
|---|
| 767 | end;
|
|---|
| 768 |
|
|---|
| 769 | procedure TBCBorder.SetLightWidth(AValue: integer);
|
|---|
| 770 | begin
|
|---|
| 771 | if FLightWidth = AValue then Exit;
|
|---|
| 772 | FLightWidth := AValue;
|
|---|
| 773 |
|
|---|
| 774 | Change;
|
|---|
| 775 | end;
|
|---|
| 776 |
|
|---|
| 777 | procedure TBCBorder.SetStyle(AValue: TBCBorderStyle);
|
|---|
| 778 | begin
|
|---|
| 779 | if FStyle = AValue then Exit;
|
|---|
| 780 | FStyle := AValue;
|
|---|
| 781 |
|
|---|
| 782 | Change;
|
|---|
| 783 | end;
|
|---|
| 784 |
|
|---|
| 785 | procedure TBCBorder.SetWidth(AValue: Integer);
|
|---|
| 786 | begin
|
|---|
| 787 | if FWidth = AValue then Exit;
|
|---|
| 788 | FWidth := AValue;
|
|---|
| 789 |
|
|---|
| 790 | Change;
|
|---|
| 791 | end;
|
|---|
| 792 |
|
|---|
| 793 | constructor TBCBorder.Create(AControl: TControl);
|
|---|
| 794 | begin
|
|---|
| 795 | FColor := clBlack;
|
|---|
| 796 | FColorOpacity := 255;
|
|---|
| 797 | FLightWidth := 0;
|
|---|
| 798 | FLightOpacity := 255;
|
|---|
| 799 | FLightColor := clWhite;
|
|---|
| 800 | FStyle := bboSolid;
|
|---|
| 801 | FWidth := 1;
|
|---|
| 802 | inherited Create(AControl);
|
|---|
| 803 | end;
|
|---|
| 804 |
|
|---|
| 805 | procedure TBCBorder.Assign(Source: TPersistent);
|
|---|
| 806 | begin
|
|---|
| 807 | if Source is TBCBorder then
|
|---|
| 808 | begin
|
|---|
| 809 | FColor := TBCBorder(Source).FColor;
|
|---|
| 810 | FColorOpacity := TBCBorder(Source).FColorOpacity;
|
|---|
| 811 | FLightColor := TBCBorder(Source).FLightColor;
|
|---|
| 812 | FLightOpacity := TBCBorder(Source).FLightOpacity;
|
|---|
| 813 | FLightWidth := TBCBorder(Source).FLightWidth;
|
|---|
| 814 | FStyle := TBCBorder(Source).FStyle;
|
|---|
| 815 | FWidth := TBCBorder(Source).FWidth;
|
|---|
| 816 | end
|
|---|
| 817 | else
|
|---|
| 818 | inherited Assign(Source);
|
|---|
| 819 | end;
|
|---|
| 820 |
|
|---|
| 821 | end.
|
|---|