1 // SPDX-License-Identifier: GPL-3.0-only
2 unit UConfig;
3
4 {$mode objfpc}{$H+}
5
6 interface
7
8 uses
9 Classes, SysUtils, IniFiles, BGRABitmapTypes, Graphics, LCLType, uscripting,
10 Forms, LCVectorRectShapes;
11
12 type
13 TLazPaintConfig = class;
14
15 IConfigProvider = interface
GetConfignull16 function GetConfig: TLazPaintConfig;
17 end;
18
19 TDarkThemePreference = (dtpAuto, dtpDark, dtpLight);
20
21 { TLazPaintConfig }
22
23 TLazPaintConfig = class
24 private
25 iniOptions: TIniFile;
26 recentFiles, recentDirs: TStringList;
27 tempFont: TFont;
28 colorizePresets: TList;
29 FVersion: string;
30 FDarkTheme,FDarkThemeEvaluated: boolean;
31 FDarkThemePreference: TDarkThemePreference;
32 FDarkThemePreferenceEvaluated: boolean;
33 FWorkspaceColor: TColor;
34 FWorkspaceColorEvaluated: boolean;
GetBrushCountnull35 function GetBrushCount: integer;
GetBrushInfonull36 function GetBrushInfo(Index: integer): string;
GetColorizePresetnull37 function GetColorizePreset(Index: Integer): TVariableSet;
GetColorizePresetCountnull38 function GetColorizePresetCount: integer;
GetRecentDirectoriesCountnull39 function GetRecentDirectoriesCount: integer;
GetRecentDirectorynull40 function GetRecentDirectory(Index: Integer): string;
GetRecentFilenull41 function GetRecentFile(Index: Integer): string;
GetRecentFilesCountnull42 function GetRecentFilesCount: integer;
43
44 public
45 Languages: TStringList;
46 constructor Create(ini: TIniFile; AVersion: string);
47 destructor Destroy; override;
48
49 procedure InitRecentFiles;
50 procedure AddRecentFile(filename: string);
51 procedure AddRecentDirectory(dirname: string);
52 procedure FinalizeRecentFiles;
DefaultRememberStartupTargetDirectorynull53 function DefaultRememberStartupTargetDirectory: boolean;
54 procedure SetRememberStartupTargetDirectory(AValue: boolean);
DefaultRememberStartupExportDirectorynull55 function DefaultRememberStartupExportDirectory: boolean;
56 procedure SetRememberStartupExportDirectory(AValue: boolean);
DefaultRememberStartupSourceDirectorynull57 function DefaultRememberStartupSourceDirectory: boolean;
58 procedure SetRememberStartupSourceDirectory(AValue: boolean);
DefaultStartupSourceDirectorynull59 function DefaultStartupSourceDirectory: string;
60 procedure SetStartupSourceDirectory(AValue: string);
DefaultStartupTargetDirectorynull61 function DefaultStartupTargetDirectory: string;
62 procedure SetStartupTargetDirectory(AValue: string);
DefaultStartupExportDirectorynull63 function DefaultStartupExportDirectory: string;
64 procedure SetStartupExportDirectory(AValue: string);
DefaultRememberSaveFormatnull65 function DefaultRememberSaveFormat: boolean;
66 procedure SetRememberSaveFormat(AValue: boolean);
DefaultSaveExtensionsnull67 function DefaultSaveExtensions: string;
68 procedure SetSaveExtensions(AValue: string);
69
70 procedure SetBrushes(ABrushes: TStringList);
DefaultJpegQualitynull71 function DefaultJpegQuality: integer;
72 procedure SetDefaultJpegQuality(value: integer);
DefaultWebPLosslessnull73 function DefaultWebPLossless: boolean;
74 procedure SetDefaultWebPLossless(value: boolean);
DefaultSaveOptionDialogMaximizednull75 function DefaultSaveOptionDialogMaximized: boolean;
76 procedure SetDefaultSaveOptionDialogMaximized(value: boolean);
77
78 procedure InitColorizePresets;
AddColorizePresetnull79 function AddColorizePreset(AName: string; AHue, ASaturation: double; ACorrection: Boolean): integer;
AddColorizePresetnull80 function AddColorizePreset(AParams: TVariableSet): integer;
81 procedure RemoveColorizePreset(AIndex: integer);
IndexOfColorizePresetnull82 function IndexOfColorizePreset(AName: string): integer;
83 procedure FinalizeColorizePresets;
84
DefaultLangagenull85 function DefaultLangage: string;
ClassGetDefaultLangagenull86 class function ClassGetDefaultLangage(AIni: TIniFile): string; static;
87 procedure SetDefaultLangage(value: string);
88
GetLastUpdateChecknull89 function GetLastUpdateCheck: TDateTime;
90 procedure SetLastUpdateCheck(value: TDateTime);
91
LatestVersionnull92 function LatestVersion: string;
93 procedure SetLatestVersion(value: string);
94 procedure GetUpdatedLanguages(AList: TStringList);
95 procedure SetUpdatedLanguages(AList: TStringList);
96 class procedure ClassGetUpdatedLanguages(AList: TStringList; AIni: TIniFile; AVersion: string); static;
97 class procedure ClassSetUpdatedLanguages(AList: TStringList; AIni: TIniFile; AVersion: string); static;
98 procedure AddUpdatedLanguage(ALang: string);
99
Default3dObjectDirectorynull100 function Default3dObjectDirectory: string;
101 procedure SetDefault3dObjectDirectory(value: string);
DefaultTextureDirectorynull102 function DefaultTextureDirectory: string;
103 procedure SetDefaultTextureDirectory(value: string);
DefaultBrushDirectorynull104 function DefaultBrushDirectory: string;
105 procedure SetDefaultBrushDirectory(value: string);
DefaultPaletteDirectorynull106 function DefaultPaletteDirectory: string;
107 procedure SetDefaultPaletteDirectory(value: string);
DefaultScriptDirectorynull108 function DefaultScriptDirectory: string;
109 procedure SetDefaultScriptDirectory(value: string);
110
DefaultIconSizenull111 function DefaultIconSize(defaultValue: integer): integer;
112 procedure SetDefaultIconSize(value: integer);
GetDarkThemenull113 function GetDarkTheme: boolean;
114 procedure SetDarkTheme(AValue: boolean);
GetDarkThemePreferencenull115 function GetDarkThemePreference: TDarkThemePreference;
116 procedure SetDarkThemePreference(AValue: TDarkThemePreference);
117
118 //new image config
DefaultImageWidthnull119 function DefaultImageWidth: integer;
DefaultImageHeightnull120 function DefaultImageHeight: integer;
DefaultImageBackgroundColornull121 function DefaultImageBackgroundColor: TBGRAPixel;
122 procedure SetDefaultImageWidth(value: integer);
123 procedure SetDefaultImageHeight(value: integer);
124 procedure SetDefaultImageBackgroundColor(value: TBGRAPixel);
125
DefaultIconImageWidthnull126 function DefaultIconImageWidth: integer;
DefaultIconImageHeightnull127 function DefaultIconImageHeight: integer;
DefaultIconImageBitDepthnull128 function DefaultIconImageBitDepth: integer;
DefaultIconImageBackgroundColornull129 function DefaultIconImageBackgroundColor: TBGRAPixel;
130 procedure SetDefaultIconImageWidth(value: integer);
131 procedure SetDefaultIconImageHeight(value: integer);
132 procedure SetDefaultIconImageBitDepth(value: integer);
133 procedure SetDefaultIconImageBackgroundColor(value: TBGRAPixel);
134
135
136 //resample config
DefaultResampleKeepAspectRationull137 function DefaultResampleKeepAspectRatio: boolean;
DefaultResampleQualitynull138 function DefaultResampleQuality: integer;
139 procedure SetDefaultResampleKeepAspectRatio(value: boolean);
140 procedure SetDefaultResampleQuality(value: integer);
141
142 //window
DefaultScreenSizenull143 function DefaultScreenSize: TRect;
DefaultDockLayersAndColorsnull144 function DefaultDockLayersAndColors: boolean;
145 procedure SetDefaultDockLayersAndColors(value: boolean);
DefaultDockLayersAndColorsWidthnull146 function DefaultDockLayersAndColorsWidth: integer;
147 procedure SetDefaultDockLayersAndColorsWidth(AValue: integer);
ScreenSizeChangednull148 function ScreenSizeChanged: boolean;
149 procedure SetDefaultScreenSize(value: TRect);
DefaultMainWindowMaximizednull150 function DefaultMainWindowMaximized: boolean;
151 procedure SetDefaultMainWindowMaximized(value: boolean);
DefaultMainWindowPositionnull152 function DefaultMainWindowPosition: TRect;
153 procedure SetDefaultMainWindowPosition(value: TRect);
DefaultColorWindowPositionnull154 function DefaultColorWindowPosition: TRect;
155 procedure SetDefaultColorWindowPosition(value: TRect);
DefaultLayerWindowPositionnull156 function DefaultLayerWindowPosition: TRect;
157 procedure SetDefaultLayerWindowPosition(value: TRect);
DefaultLayerStackZoomnull158 function DefaultLayerStackZoom: single;
159 procedure SetDefaultLayerStackZoom(value: single);
DefaultToolboxWindowPositionnull160 function DefaultToolboxWindowPosition: TRect;
161 procedure SetDefaultToolboxWindowPosition(value: TRect);
DefaultToolboxDockingnull162 function DefaultToolboxDocking: string;
163 procedure SetDefaultToolboxDocking(value: string);
DefaultImageListPositionnull164 function DefaultImageListPosition: TRect;
165 procedure SetDefaultImagelistWindowPosition(value: TRect);
DefaultBrowseWindowMaximizednull166 function DefaultBrowseWindowMaximized: boolean;
167 procedure SetDefaultBrowseWindowMaximized(value: boolean);
DefaultBrowseWindowPositionnull168 function DefaultBrowseWindowPosition: TRect;
169 procedure SetDefaultBrowseWindowPosition(value: TRect);
DefaultPreviewDialogMaximizednull170 function DefaultPreviewDialogMaximized: boolean;
171 procedure SetDefaultPreviewDialogMaximized(value: boolean);
DefaultPreviewDialogPositionnull172 function DefaultPreviewDialogPosition: TRect;
173 procedure SetDefaultPreviewDialogPosition(value: TRect);
174
DefaultPaletteToolbarVisiblenull175 function DefaultPaletteToolbarVisible: boolean;
176 procedure SetDefaultPaletteToolbarVisible(value: boolean);
DefaultColorWindowVisiblenull177 function DefaultColorWindowVisible: boolean;
178 procedure SetDefaultColorWindowVisible(value: boolean);
DefaultLayerWindowVisiblenull179 function DefaultLayerWindowVisible: boolean;
180 procedure SetDefaultLayerWindowVisible(value: boolean);
DefaultToolboxWindowVisiblenull181 function DefaultToolboxWindowVisible: boolean;
182 procedure SetDefaultToolboxWindowVisible(value: boolean);
DefaultImagelistWindowVisiblenull183 function DefaultImagelistWindowVisible: boolean;
184 procedure SetDefaultImagelistWindowVisible(value: boolean);
DefaultGridVisiblenull185 function DefaultGridVisible: boolean;
186 procedure SetDefaultGridVisible(value: boolean);
DefaultZoomToolbarVisiblenull187 function DefaultZoomToolbarVisible: boolean;
188 procedure SetDefaultZoomToolbarVisible(value: boolean);
DefaultFileToolbarVisiblenull189 function DefaultFileToolbarVisible: boolean;
190 procedure SetDefaultFileToolbarVisible(value: boolean);
DefaultUndoRedoToolbarVisiblenull191 function DefaultUndoRedoToolbarVisible: boolean;
192 procedure SetDefaultUndoRedoToolbarVisible(value: boolean);
DefaultCopyPasteToolbarVisiblenull193 function DefaultCopyPasteToolbarVisible: boolean;
194 procedure SetDefaultCopyPasteToolbarVisible(value: boolean);
DefaultCoordinatesToolbarVisiblenull195 function DefaultCoordinatesToolbarVisible: boolean;
196 procedure SetDefaultCoordinatesToolbarVisible(value: boolean);
197
GetStatusBarVisiblenull198 function GetStatusBarVisible: boolean;
199 procedure SetStatusBarVisible(value: boolean);
GetWorkspaceColornull200 function GetWorkspaceColor: TColor;
201 procedure SetWorkspaceColor(value: TColor);
DefaultUseImageBrowsernull202 function DefaultUseImageBrowser: boolean;
203 procedure SetDefaultUseImageBrowser(value: boolean);
204
205 //tools
DefaultToolForeColornull206 function DefaultToolForeColor: TBGRAPixel;
DefaultToolBackColornull207 function DefaultToolBackColor: TBGRAPixel;
DefaultToolOutlineColornull208 function DefaultToolOutlineColor: TBGRAPixel;
209 procedure SetDefaultToolForeColor(value: TBGRAPixel);
210 procedure SetDefaultToolBackColor(value: TBGRAPixel);
211 procedure SetDefaultToolOutlineColor(value: TBGRAPixel);
DefaultToolForeGradientnull212 function DefaultToolForeGradient: string;
DefaultToolBackGradientnull213 function DefaultToolBackGradient: string;
DefaultToolOutlineGradientnull214 function DefaultToolOutlineGradient: string;
215 procedure SetDefaultToolForeGradient(value: string);
216 procedure SetDefaultToolBackGradient(value: string);
217 procedure SetDefaultToolOutlineGradient(value: string);
DefaultToolPenWidthnull218 function DefaultToolPenWidth: single;
219 procedure SetDefaultToolPenWidth(value: single);
DefaultToolEraserWidthnull220 function DefaultToolEraserWidth: single;
221 procedure SetDefaultToolEraserWidth(value: single);
DefaultToolOptionDrawShapenull222 function DefaultToolOptionDrawShape: boolean;
223 procedure SetDefaultToolOptionDrawShape(value: boolean);
DefaultToolOptionFillShapenull224 function DefaultToolOptionFillShape: boolean;
225 procedure SetDefaultToolOptionFillShape(value: boolean);
DefaultToolOptionCloseShapenull226 function DefaultToolOptionCloseShape: boolean;
227 procedure SetDefaultToolOptionCloseShape(value: boolean);
DefaultToolTolerancenull228 function DefaultToolTolerance: integer;
229 procedure SetDefaultToolTolerance(value: integer);
DefaultToolTextOutlinenull230 function DefaultToolTextOutline: boolean;
231 procedure SetDefaultToolTextOutline(value: boolean);
DefaultToolTextOutlineWidthnull232 function DefaultToolTextOutlineWidth: single;
233 procedure SetDefaultToolTextOutlineWidth(value: single);
DefaultToolTextShadownull234 function DefaultToolTextShadow: boolean;
235 procedure SetDefaultToolTextShadow(value: boolean);
DefaultToolTextFontnull236 function DefaultToolTextFont: TFont;
237 procedure SetDefaultToolTextFont(AName: string; ASize: single; AStyle: TFontStyles);
DefaultToolTextBlurnull238 function DefaultToolTextBlur: single;
239 procedure SetDefaultToolTextBlur(value: single);
DefaultToolTextShadowOffsetXnull240 function DefaultToolTextShadowOffsetX: integer;
241 procedure SetDefaultToolTextShadowOffsetX(value: integer);
DefaultToolTextShadowOffsetYnull242 function DefaultToolTextShadowOffsetY: integer;
243 procedure SetDefaultToolTextShadowOffsetY(value: integer);
244 procedure SetDefaultToolTextShadowOffset(value: TPoint);
DefaultToolTextShadowOffsetnull245 function DefaultToolTextShadowOffset: TPoint;
DefaultToolTextPhongnull246 function DefaultToolTextPhong: boolean;
247 procedure SetDefaultToolTextPhong(value: boolean);
248
ToolPopupMessageShownCountnull249 function ToolPopupMessageShownCount(index: integer): integer;
250 procedure SetToolPopupMessageShownCount(index: integer; AValue: integer);
251
DefaultToolLightPositionXnull252 function DefaultToolLightPositionX: single;
253 procedure SetDefaultToolLightPositionX(value: single);
DefaultToolLightPositionYnull254 function DefaultToolLightPositionY: single;
255 procedure SetDefaultToolLightPositionY(value: single);
256 procedure SetDefaultToolLightPosition(const value: TPointF);
DefaultToolLightPositionnull257 function DefaultToolLightPosition: TPointF;
DefaultToolLightAltitudenull258 function DefaultToolLightAltitude: integer;
259 procedure SetDefaultToolLightAltitude(value: integer);
DefaultToolShapeAltitudenull260 function DefaultToolShapeAltitude: integer;
261 procedure SetDefaultToolShapeAltitude(value: integer);
DefaultToolShapeBorderSizenull262 function DefaultToolShapeBorderSize: integer;
263 procedure SetDefaultToolShapeBorderSize(value: integer);
DefaultToolShapeTypenull264 function DefaultToolShapeType: TPhongShapeKind;
265 procedure SetDefaultToolShapeType(value: TPhongShapeKind);
266
DefaultRetrieveSelectionAnswernull267 function DefaultRetrieveSelectionAnswer: TModalResult;
268 procedure SetDefaultRetrieveSelectionAnswer(value: TModalResult);
DefaultTransformSelectionAnswernull269 function DefaultTransformSelectionAnswer: TModalResult;
270 procedure SetDefaultTransformSelectionAnswer(value: TModalResult);
271
272 //radial blur config
DefaultBlurRadiusnull273 function DefaultBlurRadius: single;
274 procedure SetDefaultBlurRadius(value: single);
DefaultPixelateSizenull275 function DefaultPixelateSize: integer;
276 procedure SetDefaultPixelateSize(value: integer);
DefaultPixelateQualitynull277 function DefaultPixelateQuality: string;
278 procedure SetDefaultPixelateQuality(value: string);
DefaultSharpenAmountnull279 function DefaultSharpenAmount: single;
280 procedure SetDefaultSharpenAmount(value: single);
281
282 //motion blur config
DefaultBlurMotionAnglenull283 function DefaultBlurMotionAngle: double;
DefaultBlurMotionDistancenull284 function DefaultBlurMotionDistance: single;
DefaultBlurMotionOrientednull285 function DefaultBlurMotionOriented: boolean;
286 procedure SetDefaultBlurMotionAngle(value: double);
287 procedure SetDefaultBlurMotionDistance(value: single);
288 procedure SetDefaultBlurMotionOriented(value: boolean);
289
290 //custom blur config
DefaultCustomBlurMaskUTF8null291 function DefaultCustomBlurMaskUTF8: string;
292 procedure SetDefaultCustomBlurMaskUTF8(value: string);
293
294 //emboss config
DefaultEmbossAnglenull295 function DefaultEmbossAngle: double;
296 procedure SetDefaultEmbossAngle(value: double);
297
298 //rain config
DefaultRainWindnull299 function DefaultRainWind: double;
300 procedure SetDefaultRainWind(value: double);
DefaultRainQuantitynull301 function DefaultRainQuantity: double;
302 procedure SetDefaultRainQuantity(value: double);
303
304 //twirl config
DefaultTwirlRadiusnull305 function DefaultTwirlRadius: double;
306 procedure SetDefaultTwirlRadius(value: double);
DefaultTwirlTurnnull307 function DefaultTwirlTurn: double;
308 procedure SetDefaultTwirlTurn(value: double);
309
310 //wave displacement config
DefaultWaveDisplacementWavelengthnull311 function DefaultWaveDisplacementWavelength: double;
312 procedure SetDefaultWaveDisplacementWavelength(value: double);
DefaultWaveDisplacementAmountnull313 function DefaultWaveDisplacementAmount: double;
314 procedure SetDefaultWaveDisplacementAmount(value: double);
DefaultWaveDisplacementPhasenull315 function DefaultWaveDisplacementPhase: double;
316 procedure SetDefaultWaveDisplacementPhase(value: double);
317
318 //phong filter
DefaultPhongFilterAltitudenull319 function DefaultPhongFilterAltitude: integer;
320 procedure SetDefaultPhongFilterAltitude(value: integer);
321
322 //color config
DefaultPosterizeLevelsnull323 function DefaultPosterizeLevels: integer;
324 procedure SetDefaultPosterizeLevels(value: integer);
DefaultPosterizeByLightnessnull325 function DefaultPosterizeByLightness: boolean;
326 procedure SetDefaultPosterizeByLightness(value: boolean);
DefaultUseGSBAnull327 function DefaultUseGSBA: boolean;
328 procedure SetDefaultUseGSBA(value: boolean);
329
330 property RecentFilesCount : integer read GetRecentFilesCount;
331 property RecentFile[Index: Integer]: string read GetRecentFile;
332 property RecentDirectoriesCount : integer read GetRecentDirectoriesCount;
333 property RecentDirectory[Index: Integer]: string read GetRecentDirectory;
334
335 property ColorizePresetCount: integer read GetColorizePresetCount;
336 property ColorizePreset[Index: Integer]: TVariableSet read GetColorizePreset;
337
338 property BrushCount: integer read GetBrushCount;
339 property BrushInfo[Index: integer]: string read GetBrushInfo;
340
341 //ImageList
ImageListLastFoldernull342 function ImageListLastFolder: string;
343 procedure SetImageListLastFolder(value: string);
ImageListAutoZoomnull344 function ImageListAutoZoom: Boolean;
345 procedure SetImageListAutoZoom(value: Boolean);
ImageListAutoUnchecknull346 function ImageListAutoUncheck: Boolean;
347 procedure SetImageListAutoUncheck(value: Boolean);
ImageListAutoUncheckModenull348 function ImageListAutoUncheckMode: Integer;
349 procedure SetImageListAutoUncheckMode(value: integer);
350 end;
351
GetActualConfignull352 function GetActualConfig: TIniFile;
DefaultPicturesDirectorynull353 function DefaultPicturesDirectory: string;
354
355 var
356 ActualConfigDirUTF8 : string;
357 MenuDefinitionKeys,MenuDefinitionValues: TStringList;
358
359 implementation
360
361 uses uparse, LCLProc, BGRAUTF8, LazFileUtils, UFileSystem, UDarkTheme;
362
363 const maxRecentFiles = 10;
364 maxRecentDirectories = 10;
365
366 //returns the config file to use
GetActualConfignull367 function GetActualConfig: TIniFile;
368 var
369 PortableConfig: TIniFile;
370 AppDirSys: string;
371 PortableConfigFilenameSys: string;
372 ActualConfigFilenameSys: string;
373 {$IFDEF DARWIN}
374 ConfigPath: string;
375 {$ENDIF}
376 i: integer;
377 begin
378 ActualConfigFilenameSys := '';
379
380 //check if a config file path is defined
381 AppDirSys := ExtractFilePath(Application.ExeName);
382 PortableConfigFilenameSys := AppDirSys+'lazpaint.ini';
383 If FileExists(PortableConfigFilenameSys) then
384 begin
385 PortableConfig := TIniFile.Create(PortableConfigFilenameSys);
386 ActualConfigFilenameSys:= PortableConfig.ReadString('General','ConfigFile','');
387 if ActualConfigFilenameSys <> '' then
388 ActualConfigFilenameSys:= ExpandFileName(AppDirSys+ActualConfigFilenameSys);
389 MenuDefinitionKeys.Clear;
390 MenuDefinitionValues.Clear;
391 PortableConfig.ReadSection('Menu',MenuDefinitionKeys);
392 for i := 0 to MenuDefinitionKeys.Count-1 do
393 MenuDefinitionValues.Add(PortableConfig.ReadString('Menu',MenuDefinitionKeys[i],''));
394 PortableConfig.Free;
395 end;
396
397 //otherwise, use default path
398 if ActualConfigFilenameSys = '' then
399 begin
400 CreateDir(GetAppConfigDir(False));
401 ActualConfigFilenameSys := GetAppConfigFile(False,False);
402 end;
403
404 {$IFDEF DARWIN}
405 ConfigPath := ExtractFilePath(ActualConfigFilenameSys);
406 CreateDir(ConfigPath);
407 {$ENDIF}
408 result := TIniFile.Create(ActualConfigFilenameSys,True);
409 ActualConfigDirUTF8 := SysToUTF8(ExtractFilePath(ActualConfigFilenameSys));
410 end;
411
DefaultPicturesDirectorynull412 function DefaultPicturesDirectory: string;
413 begin
414 DefaultPicturesDirectory := SysToUTF8(GetUserDir);
415 if DirectoryExistsUTF8(AppendPathDelim(DefaultPicturesDirectory)+'Pictures') then
416 DefaultPicturesDirectory := AppendPathDelim(DefaultPicturesDirectory)+'Pictures';
417 end;
418
419 { TLazPaintConfig }
420
TLazPaintConfig.DefaultImageWidthnull421 function TLazPaintConfig.DefaultImageWidth: integer;
422 begin
423 result := iniOptions.ReadInteger('General','DefaultImageWidth',640);
424 end;
425
TLazPaintConfig.DefaultImageHeightnull426 function TLazPaintConfig.DefaultImageHeight: integer;
427 begin
428 result := iniOptions.ReadInteger('General','DefaultImageHeight',480);
429 end;
430
431 procedure TLazPaintConfig.SetDefaultImageWidth(value: integer);
432 begin
433 iniOptions.WriteInteger('General','DefaultImageWidth',value);
434 end;
435
436 procedure TLazPaintConfig.SetDefaultImageHeight(value: integer);
437 begin
438 iniOptions.WriteInteger('General','DefaultImageHeight',value);
439 end;
440
441 procedure TLazPaintConfig.SetDefaultImageBackgroundColor(value: TBGRAPixel);
442 begin
443 iniOptions.WriteString('General','DefaultImageBackColor',BGRAToStr(value));
444 end;
445
DefaultImageBackgroundColornull446 function TLazPaintConfig.DefaultImageBackgroundColor: TBGRAPixel;
447 begin
448 result := StrToBGRA(iniOptions.ReadString('General','DefaultImageBackColor','00000000'));
449 end;
450
TLazPaintConfig.DefaultIconImageWidthnull451 function TLazPaintConfig.DefaultIconImageWidth: integer;
452 begin
453 result := iniOptions.ReadInteger('General','DefaultIconImageWidth',128);
454 end;
455
DefaultIconImageHeightnull456 function TLazPaintConfig.DefaultIconImageHeight: integer;
457 begin
458 result := iniOptions.ReadInteger('General','DefaultIconImageHeight',128);
459 end;
460
DefaultIconImageBitDepthnull461 function TLazPaintConfig.DefaultIconImageBitDepth: integer;
462 begin
463 result := iniOptions.ReadInteger('General','DefaultIconImageBitDepth',32);
464 end;
465
466 procedure TLazPaintConfig.SetDefaultIconImageWidth(value: integer);
467 begin
468 iniOptions.WriteInteger('General','DefaultIconImageWidth',value);
469 end;
470
471 procedure TLazPaintConfig.SetDefaultIconImageHeight(value: integer);
472 begin
473 iniOptions.WriteInteger('General','DefaultIconImageHeight',value);
474 end;
475
476 procedure TLazPaintConfig.SetDefaultIconImageBitDepth(value: integer);
477 begin
478 iniOptions.WriteInteger('General','DefaultIconImageBitDepth',value);
479 end;
480
481 procedure TLazPaintConfig.SetDefaultIconImageBackgroundColor(value: TBGRAPixel);
482 begin
483 iniOptions.WriteString('General','DefaultIconImageBackColor',BGRAToStr(value));
484 end;
485
TLazPaintConfig.DefaultIconImageBackgroundColornull486 function TLazPaintConfig.DefaultIconImageBackgroundColor: TBGRAPixel;
487 begin
488 result := StrToBGRA(iniOptions.ReadString('General','DefaultIconImageBackColor','00000000'));
489 end;
490
DefaultResampleKeepAspectRationull491 function TLazPaintConfig.DefaultResampleKeepAspectRatio: boolean;
492 begin
493 result := iniOptions.ReadBool('General','ResampleKeepAspectRatio',true);
494 end;
495
TLazPaintConfig.DefaultResampleQualitynull496 function TLazPaintConfig.DefaultResampleQuality: integer;
497 begin
498 result := iniOptions.ReadInteger('General','ResampleQuality',2);
499 end;
500
501 procedure TLazPaintConfig.SetDefaultResampleKeepAspectRatio(value: boolean);
502 begin
503 iniOptions.WriteBool('General','ResampleKeepAspectRatio',value);
504 end;
505
506 procedure TLazPaintConfig.SetDefaultResampleQuality(value: integer);
507 begin
508 iniOptions.WriteInteger('General','ResampleQuality',value);
509 end;
510
DefaultScreenSizenull511 function TLazPaintConfig.DefaultScreenSize: TRect;
512 begin
513 result := StrToRect(iniOptions.ReadString('Window','ScreenSize',''));
514 end;
515
DefaultDockLayersAndColorsnull516 function TLazPaintConfig.DefaultDockLayersAndColors: boolean;
517 begin
518 result := iniOptions.ReadBool('Window','DockLayersAndColors',true);
519 end;
520
521 procedure TLazPaintConfig.SetDefaultDockLayersAndColors(value: boolean);
522 begin
523 iniOptions.WriteBool('Window','DockLayersAndColors',value);
524 end;
525
TLazPaintConfig.DefaultDockLayersAndColorsWidthnull526 function TLazPaintConfig.DefaultDockLayersAndColorsWidth: integer;
527 begin
528 result := iniOptions.ReadInteger('Window','DockLayersAndColorsWidth',0);
529 end;
530
531 procedure TLazPaintConfig.SetDefaultDockLayersAndColorsWidth(AValue: integer);
532 begin
533 iniOptions.WriteInteger('Window','DockLayersAndColorsWidth',AValue);
534 end;
535
536 procedure TLazPaintConfig.SetDefaultScreenSize(value: TRect);
537 begin
538 iniOptions.WriteString('Window','ScreenSize',RectToStr(value));
539 end;
540
TLazPaintConfig.DefaultMainWindowMaximizednull541 function TLazPaintConfig.DefaultMainWindowMaximized: boolean;
542 begin
543 result := iniOptions.ReadBool('Window','MainWindowMaximized',false);
544 end;
545
546 procedure TLazPaintConfig.SetDefaultMainWindowMaximized(value: boolean);
547 begin
548 iniOptions.WriteBool('Window','MainWindowMaximized',value);
549 end;
550
DefaultMainWindowPositionnull551 function TLazPaintConfig.DefaultMainWindowPosition: TRect;
552 begin
553 result := StrToRect(iniOptions.ReadString('Window','MainWindowPosition',''));
554 end;
555
556 procedure TLazPaintConfig.SetDefaultMainWindowPosition(value: TRect);
557 begin
558 iniOptions.WriteString('Window','MainWindowPosition',RectToStr(value));
559 SetDefaultMainWindowMaximized(False);
560 end;
561
TLazPaintConfig.DefaultColorWindowPositionnull562 function TLazPaintConfig.DefaultColorWindowPosition: TRect;
563 begin
564 result := StrToRect(iniOptions.ReadString('Window','ColorWindowPosition',''));
565 end;
566
567 procedure TLazPaintConfig.SetDefaultColorWindowPosition(value: TRect);
568 begin
569 iniOptions.WriteString('Window','ColorWindowPosition',RectToStr(value));
570 end;
571
DefaultLayerWindowPositionnull572 function TLazPaintConfig.DefaultLayerWindowPosition: TRect;
573 begin
574 result := StrToRect(iniOptions.ReadString('Window','LayerWindowPosition',''));
575 end;
576
577 procedure TLazPaintConfig.SetDefaultLayerWindowPosition(value: TRect);
578 begin
579 iniOptions.WriteString('Window','LayerWindowPosition',RectToStr(value));
580 end;
581
TLazPaintConfig.DefaultLayerStackZoomnull582 function TLazPaintConfig.DefaultLayerStackZoom: single;
583 begin
584 result := iniOptions.ReadFloat('Window', 'LayerStackZoom', EmptySingle);
585 end;
586
587 procedure TLazPaintConfig.SetDefaultLayerStackZoom(value: single);
588 begin
589 iniOptions.WriteFloat('Window', 'LayerStackZoom', value);
590 end;
591
TLazPaintConfig.DefaultToolboxWindowPositionnull592 function TLazPaintConfig.DefaultToolboxWindowPosition: TRect;
593 begin
594 result := StrToRect(iniOptions.ReadString('Window','ToolboxWindowPosition',''));
595 end;
596
597 procedure TLazPaintConfig.SetDefaultToolboxWindowPosition(value: TRect);
598 begin
599 iniOptions.WriteString('Window','ToolboxWindowPosition',RectToStr(value));
600 end;
601
TLazPaintConfig.DefaultToolboxDockingnull602 function TLazPaintConfig.DefaultToolboxDocking: string;
603 begin
604 result := iniOptions.ReadString('Window','ToolBoxDocking','Left');
605 end;
606
607 procedure TLazPaintConfig.SetDefaultToolboxDocking(value: string);
608 begin
609 iniOptions.WriteString('Window','ToolBoxDocking',value);
610 end;
611
TLazPaintConfig.DefaultImageListPositionnull612 function TLazPaintConfig.DefaultImageListPosition: TRect;
613 begin
614 result := StrToRect(iniOptions.ReadString('Window','ImagelistWindowPosition',''));
615 end;
616
617 procedure TLazPaintConfig.SetDefaultImagelistWindowPosition(value: TRect);
618 begin
619 iniOptions.WriteString('Window','ImagelistWindowPosition',RectToStr(value));
620 end;
621
TLazPaintConfig.DefaultBrowseWindowMaximizednull622 function TLazPaintConfig.DefaultBrowseWindowMaximized: boolean;
623 begin
624 result := iniOptions.ReadBool('Window','BrowseWindowMaximized',false);
625 end;
626
627 procedure TLazPaintConfig.SetDefaultBrowseWindowMaximized(value: boolean);
628 begin
629 iniOptions.WriteBool('Window','BrowseWindowMaximized',value);
630 end;
631
DefaultBrowseWindowPositionnull632 function TLazPaintConfig.DefaultBrowseWindowPosition: TRect;
633 begin
634 result := StrToRect(iniOptions.ReadString('Window','BrowseWindowPosition',''));
635 end;
636
637 procedure TLazPaintConfig.SetDefaultBrowseWindowPosition(value: TRect);
638 begin
639 iniOptions.WriteString('Window','BrowseWindowPosition',RectToStr(value));
640 end;
641
DefaultPreviewDialogMaximizednull642 function TLazPaintConfig.DefaultPreviewDialogMaximized: boolean;
643 begin
644 result := iniOptions.ReadBool('Window','PreviewDialogMaximized',false);
645 end;
646
647 procedure TLazPaintConfig.SetDefaultPreviewDialogMaximized(value: boolean);
648 begin
649 iniOptions.WriteBool('Window','PreviewDialogMaximized',value);
650 end;
651
DefaultPreviewDialogPositionnull652 function TLazPaintConfig.DefaultPreviewDialogPosition: TRect;
653 begin
654 result := StrToRect(iniOptions.ReadString('Window','PreviewDialogPosition',''));
655 end;
656
657 procedure TLazPaintConfig.SetDefaultPreviewDialogPosition(value: TRect);
658 begin
659 iniOptions.WriteString('Window','PreviewDialogPosition',RectToStr(value));
660 end;
661
DefaultPaletteToolbarVisiblenull662 function TLazPaintConfig.DefaultPaletteToolbarVisible: boolean;
663 begin
664 result := iniOptions.ReadBool('Toolbar','PaletteToolbar',true);
665 end;
666
667 procedure TLazPaintConfig.SetDefaultPaletteToolbarVisible(value: boolean);
668 begin
669 iniOptions.WriteBool('Toolbar','PaletteToolbar',value);
670 end;
671
DefaultColorWindowVisiblenull672 function TLazPaintConfig.DefaultColorWindowVisible: boolean;
673 begin
674 result := iniOptions.ReadBool('Window','ColorWindowVisible',true);
675 end;
676
677 procedure TLazPaintConfig.SetDefaultColorWindowVisible(value: boolean);
678 begin
679 iniOptions.WriteBool('Window','ColorWindowVisible',value);
680 end;
681
TLazPaintConfig.DefaultLayerWindowVisiblenull682 function TLazPaintConfig.DefaultLayerWindowVisible: boolean;
683 begin
684 result := iniOptions.ReadBool('Window','LayerWindowVisible',true);
685 end;
686
687 procedure TLazPaintConfig.SetDefaultLayerWindowVisible(value: boolean);
688 begin
689 iniOptions.WriteBool('Window','LayerWindowVisible',value);
690 end;
691
DefaultToolboxWindowVisiblenull692 function TLazPaintConfig.DefaultToolboxWindowVisible: boolean;
693 begin
694 result := iniOptions.ReadBool('Window','ToolboxWindowVisible',true);
695 end;
696
TLazPaintConfig.DefaultImagelistWindowVisiblenull697 function TLazPaintConfig.DefaultImagelistWindowVisible: boolean;
698 begin
699 result := iniOptions.ReadBool('Window','ImagelistWindowVisible',false);
700 end;
701
702 procedure TLazPaintConfig.SetDefaultToolboxWindowVisible(value: boolean);
703 begin
704 iniOptions.WriteBool('Window','ToolboxWindowVisible',value);
705 end;
706
707 procedure TLazPaintConfig.SetDefaultImagelistWindowVisible(value: boolean);
708 begin
709 iniOptions.WriteBool('Window','ImagelistWindowVisible',value);
710 end;
711
DefaultGridVisiblenull712 function TLazPaintConfig.DefaultGridVisible: boolean;
713 begin
714 result := iniOptions.ReadBool('General','GridVisible',true);
715 end;
716
717 procedure TLazPaintConfig.SetDefaultGridVisible(value: boolean);
718 begin
719 iniOptions.WriteBool('General','GridVisible',value);
720 end;
721
DefaultZoomToolbarVisiblenull722 function TLazPaintConfig.DefaultZoomToolbarVisible: boolean;
723 begin
724 result := iniOptions.ReadBool('Toolbar','ZoomToolbar',true);
725 end;
726
727 procedure TLazPaintConfig.SetDefaultZoomToolbarVisible(value: boolean);
728 begin
729 iniOptions.WriteBool('Toolbar','ZoomToolbar',value);
730 end;
731
TLazPaintConfig.DefaultFileToolbarVisiblenull732 function TLazPaintConfig.DefaultFileToolbarVisible: boolean;
733 begin
734 result := iniOptions.ReadBool('Toolbar','FileToolbar',true);
735 end;
736
737 procedure TLazPaintConfig.SetDefaultFileToolbarVisible(value: boolean);
738 begin
739 iniOptions.WriteBool('Toolbar','FileToolbar',value);
740 end;
741
TLazPaintConfig.DefaultUndoRedoToolbarVisiblenull742 function TLazPaintConfig.DefaultUndoRedoToolbarVisible: boolean;
743 begin
744 result := iniOptions.ReadBool('Toolbar','UndoRedoToolbar',true);
745 end;
746
747 procedure TLazPaintConfig.SetDefaultUndoRedoToolbarVisible(value: boolean);
748 begin
749 iniOptions.WriteBool('Toolbar','UndoRedoToolbar',value);
750 end;
751
TLazPaintConfig.DefaultCopyPasteToolbarVisiblenull752 function TLazPaintConfig.DefaultCopyPasteToolbarVisible: boolean;
753 begin
754 result := iniOptions.ReadBool('Toolbar','CopyPasteToolbar',false);
755 end;
756
757 procedure TLazPaintConfig.SetDefaultCopyPasteToolbarVisible(value: boolean);
758 begin
759 iniOptions.WriteBool('Toolbar','CopyPasteToolbar',value);
760 end;
761
TLazPaintConfig.DefaultCoordinatesToolbarVisiblenull762 function TLazPaintConfig.DefaultCoordinatesToolbarVisible: boolean;
763 begin
764 result := iniOptions.ReadBool('Toolbar','CoordinatesToolbar',true);
765 end;
766
767 procedure TLazPaintConfig.SetDefaultCoordinatesToolbarVisible(value: boolean);
768 begin
769 iniOptions.WriteBool('Toolbar','CoordinatesToolbar',value);
770 end;
771
GetStatusBarVisiblenull772 function TLazPaintConfig.GetStatusBarVisible: boolean;
773 begin
774 result := iniOptions.ReadBool('Toolbar','StatusBar',true);
775 end;
776
777 procedure TLazPaintConfig.SetStatusBarVisible(value: boolean);
778 begin
779 iniOptions.WriteBool('Toolbar','StatusBar',value);
780 end;
781
GetWorkspaceColornull782 function TLazPaintConfig.GetWorkspaceColor: TColor;
783 begin
784 if not FWorkspaceColorEvaluated then
785 begin
786 if GetDarkTheme then
787 FWorkspaceColor := StrToBGRA(iniOptions.ReadString('General','DarkWorkspaceColor', '#2D3B49'), clAppWorkspace)
788 else
789 FWorkspaceColor := StrToBGRA(iniOptions.ReadString('General','WorkspaceColor', '#BBD1E8'), clAppWorkspace);
790 FWorkspaceColorEvaluated := true;
791 end;
792 result := FWorkspaceColor;
793 end;
794
795 procedure TLazPaintConfig.SetWorkspaceColor(value: TColor);
796 begin
797 if GetDarkTheme then
798 iniOptions.WriteString('General','DarkWorkspaceColor', BGRAToStr(value))
799 else
800 iniOptions.WriteString('General','WorkspaceColor', BGRAToStr(value));
801 FWorkspaceColor:= value;
802 FWorkspaceColorEvaluated:= true;
803 end;
804
TLazPaintConfig.DefaultUseImageBrowsernull805 function TLazPaintConfig.DefaultUseImageBrowser: boolean;
806 begin
807 result := iniOptions.ReadBool('General','UseImageBrowser',{$IFDEF DARWIN}false{$ELSE}true{$ENDIF});
808 end;
809
810 procedure TLazPaintConfig.SetDefaultUseImageBrowser(value: boolean);
811 begin
812 iniOptions.WriteBool('General','UseImageBrowser',value);
813 end;
814
TLazPaintConfig.DefaultToolForeColornull815 function TLazPaintConfig.DefaultToolForeColor: TBGRAPixel;
816 begin
817 result := StrToBGRA(iniOptions.ReadString('Tool','ForeColor','00000080'));
818 end;
819
DefaultToolBackColornull820 function TLazPaintConfig.DefaultToolBackColor: TBGRAPixel;
821 begin
822 result := StrToBGRA(iniOptions.ReadString('Tool','BackColor','0080FFC0'));
823 end;
824
DefaultToolOutlineColornull825 function TLazPaintConfig.DefaultToolOutlineColor: TBGRAPixel;
826 begin
827 result := StrToBGRA(iniOptions.ReadString('Tool','OutlineColor','FF0000C0'));
828 end;
829
830 procedure TLazPaintConfig.SetDefaultToolForeColor(value: TBGRAPixel);
831 begin
832 iniOptions.WriteString('Tool','ForeColor',BGRAToStr(value));
833 end;
834
835 procedure TLazPaintConfig.SetDefaultToolBackColor(value: TBGRAPixel);
836 begin
837 iniOptions.WriteString('Tool','BackColor',BGRAToStr(value));
838 end;
839
840 procedure TLazPaintConfig.SetDefaultToolOutlineColor(value: TBGRAPixel);
841 begin
842 iniOptions.WriteString('Tool','OutlineColor',BGRAToStr(value));
843 end;
844
TLazPaintConfig.DefaultToolForeGradientnull845 function TLazPaintConfig.DefaultToolForeGradient: string;
846 begin
847 result := iniOptions.ReadString('Tool','ForeGradient','');
848 end;
849
TLazPaintConfig.DefaultToolBackGradientnull850 function TLazPaintConfig.DefaultToolBackGradient: string;
851 begin
852 result := iniOptions.ReadString('Tool','BackGradient','');
853 end;
854
DefaultToolOutlineGradientnull855 function TLazPaintConfig.DefaultToolOutlineGradient: string;
856 begin
857 result := iniOptions.ReadString('Tool','OutlineGradient','');
858 end;
859
860 procedure TLazPaintConfig.SetDefaultToolForeGradient(value: string);
861 begin
862 iniOptions.WriteString('Tool','ForeGradient',value);
863 end;
864
865 procedure TLazPaintConfig.SetDefaultToolBackGradient(value: string);
866 begin
867 iniOptions.WriteString('Tool','BackGradient',value);
868 end;
869
870 procedure TLazPaintConfig.SetDefaultToolOutlineGradient(value: string);
871 begin
872 iniOptions.WriteString('Tool','OutlineGradient',value);
873 end;
874
TLazPaintConfig.DefaultToolPenWidthnull875 function TLazPaintConfig.DefaultToolPenWidth: single;
876 begin
877 result := iniOptions.ReadFloat('Tool','PenWidth',5);
878 end;
879
880 procedure TLazPaintConfig.SetDefaultToolPenWidth(value: single);
881 begin
882 iniOptions.WriteFloat('Tool','PenWidth',value);
883 end;
884
TLazPaintConfig.DefaultToolEraserWidthnull885 function TLazPaintConfig.DefaultToolEraserWidth: single;
886 begin
887 result := iniOptions.ReadFloat('Tool','EraserWidth',10);
888 end;
889
890 procedure TLazPaintConfig.SetDefaultToolEraserWidth(value: single);
891 begin
892 iniOptions.WriteFloat('Tool','EraserWidth',value);
893 end;
894
TLazPaintConfig.DefaultToolOptionDrawShapenull895 function TLazPaintConfig.DefaultToolOptionDrawShape: boolean;
896 begin
897 result := iniOptions.ReadBool('Tool','DrawShape',true);
898 end;
899
900 procedure TLazPaintConfig.SetDefaultToolOptionDrawShape(value: boolean);
901 begin
902 iniOptions.WriteBool('Tool','DrawShape',value);
903 end;
904
TLazPaintConfig.DefaultToolOptionFillShapenull905 function TLazPaintConfig.DefaultToolOptionFillShape: boolean;
906 begin
907 result := iniOptions.ReadBool('Tool','FillShape',true);
908 end;
909
910 procedure TLazPaintConfig.SetDefaultToolOptionFillShape(value: boolean);
911 begin
912 iniOptions.WriteBool('Tool','FillShape',value);
913 end;
914
TLazPaintConfig.DefaultToolOptionCloseShapenull915 function TLazPaintConfig.DefaultToolOptionCloseShape: boolean;
916 begin
917 result := iniOptions.ReadBool('Tool','CloseShape',true);
918 end;
919
920 procedure TLazPaintConfig.SetDefaultToolOptionCloseShape(value: boolean);
921 begin
922 iniOptions.WriteBool('Tool','CloseShape',value);
923 end;
924
TLazPaintConfig.DefaultToolTolerancenull925 function TLazPaintConfig.DefaultToolTolerance: integer;
926 begin
927 result := iniOptions.ReadInteger('Tool','Tolerance',64);
928 end;
929
930 procedure TLazPaintConfig.SetDefaultToolTolerance(value: integer);
931 begin
932 iniOptions.WriteInteger('Tool','Tolerance',value);
933 end;
934
DefaultToolTextOutlinenull935 function TLazPaintConfig.DefaultToolTextOutline: boolean;
936 begin
937 result := iniOptions.ReadBool('Tool','TextOutline',false);
938 end;
939
940 procedure TLazPaintConfig.SetDefaultToolTextOutline(value: boolean);
941 begin
942 iniOptions.WriteBool('Tool','TextOutline',value);
943 end;
944
TLazPaintConfig.DefaultToolTextOutlineWidthnull945 function TLazPaintConfig.DefaultToolTextOutlineWidth: single;
946 begin
947 result := iniOptions.ReadFloat('Tool','TextOutlineWidth',2);
948 end;
949
950 procedure TLazPaintConfig.SetDefaultToolTextOutlineWidth(value: single);
951 begin
952 iniOptions.WriteFloat('Tool','TextOutlineWidth',value);
953 end;
954
DefaultToolTextShadownull955 function TLazPaintConfig.DefaultToolTextShadow: boolean;
956 begin
957 result := iniOptions.ReadBool('Tool','TextShadow',false);
958 end;
959
960 procedure TLazPaintConfig.SetDefaultToolTextShadow(value: boolean);
961 begin
962 iniOptions.WriteBool('Tool','TextShadow',value);
963 end;
964
DefaultToolTextFontnull965 function TLazPaintConfig.DefaultToolTextFont: TFont;
966 var fontStyle: TFontStyles;
967 begin
968 tempFont.Name := iniOptions.ReadString('Tool','TextFontName','');
969 tempFont.Size := iniOptions.ReadInteger('Tool','TextFontSize',10);
970 fontStyle := [];
971 if iniOptions.ReadBool('Tool','TextFontBold',False) then fontStyle += [fsBold];
972 if iniOptions.ReadBool('Tool','TextFontItalic',False) then fontStyle += [fsItalic];
973 if iniOptions.ReadBool('Tool','TextFontStrikeOut',False) then fontStyle += [fsStrikeOut];
974 if iniOptions.ReadBool('Tool','TextFontUnderline',False) then fontStyle += [fsUnderline];
975 tempFont.Style := fontStyle;
976 result := tempFont;
977 end;
978
979 procedure TLazPaintConfig.SetDefaultToolTextFont(AName: string; ASize: single;
980 AStyle: TFontStyles);
981 begin
982 iniOptions.WriteString('Tool','TextFontName',AName);
983 iniOptions.WriteInteger('Tool','TextFontSize',round(ASize));
984 iniOptions.DeleteKey('Tool','TextFontHeight');
985 iniOptions.WriteBool('Tool','TextFontBold',fsBold in AStyle);
986 iniOptions.WriteBool('Tool','TextFontItalic',fsItalic in AStyle);
987 iniOptions.WriteBool('Tool','TextFontStrikeOut',fsStrikeOut in AStyle);
988 iniOptions.WriteBool('Tool','TextFontUnderline',fsUnderline in AStyle);
989 end;
990
DefaultToolTextBlurnull991 function TLazPaintConfig.DefaultToolTextBlur: single;
992 begin
993 result := iniOptions.ReadFloat('Tool','TextBlur',4);
994 end;
995
996 procedure TLazPaintConfig.SetDefaultToolTextBlur(value: single);
997 begin
998 iniOptions.WriteFloat('Tool','TextBlur',value);
999 end;
1000
TLazPaintConfig.DefaultToolTextShadowOffsetXnull1001 function TLazPaintConfig.DefaultToolTextShadowOffsetX: integer;
1002 begin
1003 result := iniOptions.ReadInteger('Tool','TextShadowX',5);
1004 end;
1005
1006 procedure TLazPaintConfig.SetDefaultToolTextShadowOffsetX(value: integer);
1007 begin
1008 iniOptions.WriteInteger('Tool','TextShadowX',value);
1009 end;
1010
DefaultToolTextShadowOffsetYnull1011 function TLazPaintConfig.DefaultToolTextShadowOffsetY: integer;
1012 begin
1013 result := iniOptions.ReadInteger('Tool','TextShadowY',5);
1014 end;
1015
1016 procedure TLazPaintConfig.SetDefaultToolTextShadowOffsetY(value: integer);
1017 begin
1018 iniOptions.WriteInteger('Tool','TextShadowY',value);
1019 end;
1020
1021 procedure TLazPaintConfig.SetDefaultToolTextShadowOffset(value: TPoint);
1022 begin
1023 SetDefaultToolTextShadowOffsetX(value.X);
1024 SetDefaultToolTextShadowOffsetY(value.Y);
1025 end;
1026
DefaultToolTextShadowOffsetnull1027 function TLazPaintConfig.DefaultToolTextShadowOffset: TPoint;
1028 begin
1029 result := Point(DefaultToolTextShadowOffsetX,DefaultToolTextShadowOffsetY);
1030 end;
1031
DefaultToolTextPhongnull1032 function TLazPaintConfig.DefaultToolTextPhong: boolean;
1033 begin
1034 result := iniOptions.ReadBool('Tool','TextPhong',false);
1035 end;
1036
1037 procedure TLazPaintConfig.SetDefaultToolTextPhong(value: boolean);
1038 begin
1039 iniOptions.WriteBool('Tool','TextPhong',value);
1040 end;
1041
ToolPopupMessageShownCountnull1042 function TLazPaintConfig.ToolPopupMessageShownCount(index: integer): integer;
1043 begin
1044 result := iniOptions.ReadInteger('Popup','ToolPopupMessage' + inttostr(index),0);
1045 end;
1046
1047 procedure TLazPaintConfig.SetToolPopupMessageShownCount(index: integer;
1048 AValue: integer);
1049 begin
1050 iniOptions.WriteInteger('Popup','ToolPopupMessage' + inttostr(index), avalue);
1051 end;
1052
DefaultToolLightPositionXnull1053 function TLazPaintConfig.DefaultToolLightPositionX: single;
1054 begin
1055 result := iniOptions.ReadFloat('Tool','LightPositionX',0);
1056 end;
1057
1058 procedure TLazPaintConfig.SetDefaultToolLightPositionX(value: single);
1059 begin
1060 iniOptions.WriteFloat('Tool','LightPositionX',value);
1061 end;
1062
DefaultToolLightPositionYnull1063 function TLazPaintConfig.DefaultToolLightPositionY: single;
1064 begin
1065 result := iniOptions.ReadFloat('Tool','LightPositionY',0);
1066 end;
1067
1068 procedure TLazPaintConfig.SetDefaultToolLightPositionY(value: single);
1069 begin
1070 iniOptions.WriteFloat('Tool','LightPositionY',value);
1071 end;
1072
1073 procedure TLazPaintConfig.SetDefaultToolLightPosition(const value: TPointF);
1074 begin
1075 SetDefaultToolLightPositionX(value.X);
1076 SetDefaultToolLightPositionY(value.Y);
1077 end;
1078
DefaultToolLightPositionnull1079 function TLazPaintConfig.DefaultToolLightPosition: TPointF;
1080 begin
1081 result := PointF(DefaultToolLightPositionX,DefaultToolLightPositionY);
1082 end;
1083
TLazPaintConfig.DefaultToolLightAltitudenull1084 function TLazPaintConfig.DefaultToolLightAltitude: integer;
1085 begin
1086 result := iniOptions.ReadInteger('Filter','LightPositionZ',100);
1087 end;
1088
1089 procedure TLazPaintConfig.SetDefaultToolLightAltitude(value: integer);
1090 begin
1091 iniOptions.WriteInteger('Filter','LightPositionZ',value);
1092 end;
1093
DefaultToolShapeAltitudenull1094 function TLazPaintConfig.DefaultToolShapeAltitude: integer;
1095 begin
1096 result := iniOptions.ReadInteger('Filter','ShapeAltitude',50);
1097 end;
1098
1099 procedure TLazPaintConfig.SetDefaultToolShapeAltitude(value: integer);
1100 begin
1101 iniOptions.WriteInteger('Filter','ShapeAltitude',value);
1102 end;
1103
DefaultToolShapeBorderSizenull1104 function TLazPaintConfig.DefaultToolShapeBorderSize: integer;
1105 begin
1106 result := iniOptions.ReadInteger('Filter','ShapeBorderSize',20);
1107 end;
1108
1109 procedure TLazPaintConfig.SetDefaultToolShapeBorderSize(value: integer);
1110 begin
1111 iniOptions.WriteInteger('Filter','ShapeBorderSize',value);
1112 end;
1113
DefaultToolShapeTypenull1114 function TLazPaintConfig.DefaultToolShapeType: TPhongShapeKind;
1115 var
1116 str: String;
1117 begin
1118 str := iniOptions.ReadString('Filter','ShapeType','Rectangle');
1119 if str = 'RoundRectangle' then result := pskRoundRectangle else
1120 if str = 'Sphere' then result := pskHalfSphere else
1121 if str = 'Cone' then result := pskConeTop else
1122 if str = 'VerticalCone' then result := pskConeSide else
1123 if str = 'VerticalCylinder' then result := pskVertCylinder else
1124 if str = 'HorizontalCylinder' then result := pskHorizCylinder
1125 else result := pskRectangle;
1126 end;
1127
1128 procedure TLazPaintConfig.SetDefaultToolShapeType(value: TPhongShapeKind);
1129 var
1130 str: String;
1131 begin
1132 case value of
1133 pskRoundRectangle: str := 'RoundRectangle';
1134 pskHalfSphere: str := 'Sphere';
1135 pskConeTop: str := 'Cone';
1136 pskConeSide: str := 'VerticalCone';
1137 pskVertCylinder: str := 'VerticalCylinder';
1138 pskHorizCylinder: str := 'HorizontalCylinder';
1139 else str:= 'Rectangle'
1140 end;
1141 iniOptions.WriteString('Filter','ShapeType',str);
1142 end;
1143
DefaultRetrieveSelectionAnswernull1144 function TLazPaintConfig.DefaultRetrieveSelectionAnswer: TModalResult;
1145 begin
1146 result := iniOptions.ReadInteger('Tool','RetrieveSelectionAnswer', 0);
1147 end;
1148
1149 procedure TLazPaintConfig.SetDefaultRetrieveSelectionAnswer(value: TModalResult);
1150 begin
1151 iniOptions.WriteInteger('Tool','RetrieveSelectionAnswer', value);
1152 end;
1153
DefaultTransformSelectionAnswernull1154 function TLazPaintConfig.DefaultTransformSelectionAnswer: TModalResult;
1155 begin
1156 result := iniOptions.ReadInteger('Tool','TransformSelectionAnswer', 0);
1157 end;
1158
1159 procedure TLazPaintConfig.SetDefaultTransformSelectionAnswer(value: TModalResult);
1160 begin
1161 iniOptions.WriteInteger('Tool','TransformSelectionAnswer', value);
1162 end;
1163
TLazPaintConfig.DefaultBlurRadiusnull1164 function TLazPaintConfig.DefaultBlurRadius: single;
1165 begin
1166 result := iniOptions.ReadFloat('Filter','BlurRadius',5);
1167 end;
1168
1169 procedure TLazPaintConfig.SetDefaultBlurRadius(value: single);
1170 begin
1171 iniOptions.WriteFloat('Filter','BlurRadius',value);
1172 end;
1173
TLazPaintConfig.DefaultPixelateSizenull1174 function TLazPaintConfig.DefaultPixelateSize: integer;
1175 begin
1176 result := iniOptions.ReadInteger('Filter','PixelateSize',5);
1177 end;
1178
1179 procedure TLazPaintConfig.SetDefaultPixelateSize(value: integer);
1180 begin
1181 iniOptions.WriteInteger('Filter','PixelateSize',value);
1182 end;
1183
DefaultPixelateQualitynull1184 function TLazPaintConfig.DefaultPixelateQuality: string;
1185 begin
1186 result := iniOptions.ReadString('Filter','PixelateQuality','Linear');
1187 end;
1188
1189 procedure TLazPaintConfig.SetDefaultPixelateQuality(value: string);
1190 begin
1191 iniOptions.WriteString('Filter','PixelateQuality',value);
1192 end;
1193
TLazPaintConfig.DefaultSharpenAmountnull1194 function TLazPaintConfig.DefaultSharpenAmount: single;
1195 begin
1196 result := iniOptions.ReadFloat('Filter','SharpenAmount',1);
1197 end;
1198
1199 procedure TLazPaintConfig.SetDefaultSharpenAmount(value: single);
1200 begin
1201 iniOptions.WriteFloat('Filter','SharpenAmount',value);
1202 end;
1203
DefaultBlurMotionAnglenull1204 function TLazPaintConfig.DefaultBlurMotionAngle: double;
1205 begin
1206 result := iniOptions.ReadFloat('Filter','MotionBlurAngle',0);
1207 end;
1208
TLazPaintConfig.DefaultBlurMotionDistancenull1209 function TLazPaintConfig.DefaultBlurMotionDistance: single;
1210 begin
1211 result := iniOptions.ReadFloat('Filter','MotionBlurDistance',5);
1212 end;
1213
TLazPaintConfig.DefaultBlurMotionOrientednull1214 function TLazPaintConfig.DefaultBlurMotionOriented: boolean;
1215 begin
1216 result := iniOptions.ReadBool('Filter','MotionBlurOriented',true);
1217 end;
1218
1219 procedure TLazPaintConfig.SetDefaultBlurMotionAngle(value: double);
1220 begin
1221 iniOptions.WriteFloat('Filter','MotionBlurAngle',value);
1222 end;
1223
1224 procedure TLazPaintConfig.SetDefaultBlurMotionDistance(value: single);
1225 begin
1226 iniOptions.WriteFloat('Filter','MotionBlurDistance',value);
1227 end;
1228
1229 procedure TLazPaintConfig.SetDefaultBlurMotionOriented(value: boolean);
1230 begin
1231 iniOptions.WriteBool('Filter','MotionBlurOriented',value);
1232 end;
1233
DefaultCustomBlurMaskUTF8null1234 function TLazPaintConfig.DefaultCustomBlurMaskUTF8: string;
1235 begin
1236 result := iniOptions.ReadString('Filter','CustomBlurMask','');
1237 end;
1238
1239 procedure TLazPaintConfig.SetDefaultCustomBlurMaskUTF8(value: string);
1240 begin
1241 iniOptions.WriteString('Filter','CustomBlurMask',value);
1242 end;
1243
TLazPaintConfig.DefaultEmbossAnglenull1244 function TLazPaintConfig.DefaultEmbossAngle: double;
1245 begin
1246 result := iniOptions.ReadFloat('Filter','EmbossAngle',45);
1247 end;
1248
1249 procedure TLazPaintConfig.SetDefaultEmbossAngle(value: double);
1250 begin
1251 iniOptions.WriteFloat('Filter','EmbossAngle',value);
1252 end;
1253
TLazPaintConfig.DefaultRainWindnull1254 function TLazPaintConfig.DefaultRainWind: double;
1255 begin
1256 result := iniOptions.ReadFloat('Filter','RainWind',-0.5);
1257 end;
1258
1259 procedure TLazPaintConfig.SetDefaultRainWind(value: double);
1260 begin
1261 iniOptions.WriteFloat('Filter','RainWind',value);
1262 end;
1263
DefaultRainQuantitynull1264 function TLazPaintConfig.DefaultRainQuantity: double;
1265 begin
1266 result := iniOptions.ReadFloat('Filter','RainQuantity',0.5);
1267 end;
1268
1269 procedure TLazPaintConfig.SetDefaultRainQuantity(value: double);
1270 begin
1271 iniOptions.WriteFloat('Filter','RainQuantity',value);
1272 end;
1273
DefaultTwirlRadiusnull1274 function TLazPaintConfig.DefaultTwirlRadius: double;
1275 begin
1276 result := iniOptions.ReadFloat('Filter','TwirlRadius',100);
1277 end;
1278
1279 procedure TLazPaintConfig.SetDefaultTwirlRadius(value: double);
1280 begin
1281 iniOptions.WriteFloat('Filter','TwirlRadius',value);
1282 end;
1283
DefaultTwirlTurnnull1284 function TLazPaintConfig.DefaultTwirlTurn: double;
1285 begin
1286 result := iniOptions.ReadFloat('Filter','TwirlTurn',1);
1287 end;
1288
1289 procedure TLazPaintConfig.SetDefaultTwirlTurn(value: double);
1290 begin
1291 iniOptions.WriteFloat('Filter','TwirlTurn',value);
1292 end;
1293
DefaultWaveDisplacementWavelengthnull1294 function TLazPaintConfig.DefaultWaveDisplacementWavelength: double;
1295 begin
1296 result := iniOptions.ReadFloat('Filter','WaveDisplacementWavelength',100);
1297 end;
1298
1299 procedure TLazPaintConfig.SetDefaultWaveDisplacementWavelength(value: double);
1300 begin
1301 iniOptions.WriteFloat('Filter','WaveDisplacementWavelength',value);
1302 end;
1303
TLazPaintConfig.DefaultWaveDisplacementAmountnull1304 function TLazPaintConfig.DefaultWaveDisplacementAmount: double;
1305 begin
1306 result := iniOptions.ReadFloat('Filter','WaveDisplacementAmount',50);
1307 end;
1308
1309 procedure TLazPaintConfig.SetDefaultWaveDisplacementAmount(value: double);
1310 begin
1311 iniOptions.WriteFloat('Filter','WaveDisplacementAmount',value);
1312 end;
1313
TLazPaintConfig.DefaultWaveDisplacementPhasenull1314 function TLazPaintConfig.DefaultWaveDisplacementPhase: double;
1315 begin
1316 result := iniOptions.ReadFloat('Filter','WaveDisplacementPhase',0);
1317 end;
1318
1319 procedure TLazPaintConfig.SetDefaultWaveDisplacementPhase(value: double);
1320 begin
1321 iniOptions.WriteFloat('Filter','WaveDisplacementPhase',value);
1322 end;
1323
DefaultPhongFilterAltitudenull1324 function TLazPaintConfig.DefaultPhongFilterAltitude: integer;
1325 begin
1326 result := iniOptions.ReadInteger('Filter','MapAltitude',10);
1327 end;
1328
1329 procedure TLazPaintConfig.SetDefaultPhongFilterAltitude(value: integer);
1330 begin
1331 iniOptions.WriteInteger('Filter','MapAltitude',value);
1332 end;
1333
TLazPaintConfig.DefaultPosterizeLevelsnull1334 function TLazPaintConfig.DefaultPosterizeLevels: integer;
1335 begin
1336 result := iniOptions.ReadInteger('Filter','PosterizeLevels',4);
1337 end;
1338
1339 procedure TLazPaintConfig.SetDefaultPosterizeLevels(value: integer);
1340 begin
1341 iniOptions.WriteInteger('Filter','PosterizeLevels',value);
1342 end;
1343
TLazPaintConfig.DefaultPosterizeByLightnessnull1344 function TLazPaintConfig.DefaultPosterizeByLightness: boolean;
1345 begin
1346 result := iniOptions.ReadBool('Filter','PosterizeByLightness',True);
1347 end;
1348
1349 procedure TLazPaintConfig.SetDefaultPosterizeByLightness(value: boolean);
1350 begin
1351 iniOptions.WriteBool('Filter','PosterizeByLightness',value);
1352 end;
1353
DefaultUseGSBAnull1354 function TLazPaintConfig.DefaultUseGSBA: boolean;
1355 begin
1356 result := iniOptions.ReadBool('Filter','UseGSBA',True);
1357 end;
1358
1359 procedure TLazPaintConfig.SetDefaultUseGSBA(value: boolean);
1360 begin
1361 iniOptions.WriteBool('Filter','UseGSBA',value);
1362 end;
1363
1364 procedure TLazPaintConfig.InitRecentFiles;
1365 var i: integer;
1366 begin
1367 recentFiles := TStringList.Create;
1368 iniOptions.ReadSection('RecentFiles',recentFiles);
1369 for i := 0 to recentFiles.Count-1 do
1370 recentFiles[i] := iniOptions.ReadString('RecentFiles',recentFiles[i],'');
1371 for i := recentFiles.Count-1 downto 0 do
1372 if not FileManager.FileExists(recentFiles[i]) then recentFiles.Delete(i);
1373
1374 recentDirs := TStringList.Create;
1375 iniOptions.ReadSection('RecentDirectories',recentDirs);
1376 for i := 0 to recentDirs.Count-1 do
1377 recentDirs[i] := iniOptions.ReadString('RecentDirectories',recentDirs[i],'');
1378 for i := recentDirs.Count-1 downto 0 do
1379 if not FileManager.IsDirectory(recentDirs[i]) then recentDirs.Delete(i);
1380 end;
1381
1382 procedure TLazPaintConfig.FinalizeRecentFiles;
1383 var i: integer;
1384 begin
1385 iniOptions.EraseSection('RecentFiles');
1386 for i := 0 to recentFiles.Count-1 do
1387 iniOptions.WriteString('RecentFiles','File'+inttostr(I+1),recentFiles[i]);
1388 recentFiles.Free;
1389
1390 iniOptions.EraseSection('RecentDirectories');
1391 for i := 0 to recentDirs.Count-1 do
1392 iniOptions.WriteString('RecentDirectories','Dir'+inttostr(I+1),recentDirs[i]);
1393 recentDirs.Free;
1394 end;
1395
DefaultRememberStartupTargetDirectorynull1396 function TLazPaintConfig.DefaultRememberStartupTargetDirectory: boolean;
1397 begin
1398 result := iniOptions.ReadBool('Startup', 'RememberTargetDirectory', false);
1399 end;
1400
1401 procedure TLazPaintConfig.SetRememberStartupTargetDirectory(AValue: boolean);
1402 begin
1403 iniOptions.WriteBool('Startup', 'RememberTargetDirectory', AValue);
1404 end;
1405
TLazPaintConfig.DefaultRememberStartupExportDirectorynull1406 function TLazPaintConfig.DefaultRememberStartupExportDirectory: boolean;
1407 begin
1408 result := iniOptions.ReadBool('Startup', 'RememberExportDirectory', false);
1409 end;
1410
1411 procedure TLazPaintConfig.SetRememberStartupExportDirectory(AValue: boolean);
1412 begin
1413 iniOptions.WriteBool('Startup', 'RememberExportDirectory', AValue);
1414 end;
1415
DefaultRememberStartupSourceDirectorynull1416 function TLazPaintConfig.DefaultRememberStartupSourceDirectory: boolean;
1417 begin
1418 result := iniOptions.ReadBool('Startup', 'RememberSourceDirectory', false);
1419 end;
1420
1421 procedure TLazPaintConfig.SetRememberStartupSourceDirectory(AValue: boolean);
1422 begin
1423 iniOptions.WriteBool('Startup', 'RememberSourceDirectory', AValue);
1424 end;
1425
TLazPaintConfig.DefaultStartupSourceDirectorynull1426 function TLazPaintConfig.DefaultStartupSourceDirectory: string;
1427 begin
1428 result := iniOptions.ReadString('Startup', 'SourceDirectory', '');
1429 end;
1430
1431 procedure TLazPaintConfig.SetStartupSourceDirectory(AValue: string);
1432 begin
1433 iniOptions.WriteString('Startup', 'SourceDirectory', AValue);
1434 end;
1435
DefaultStartupTargetDirectorynull1436 function TLazPaintConfig.DefaultStartupTargetDirectory: string;
1437 begin
1438 result := iniOptions.ReadString('Startup', 'TargetDirectory', '');
1439 end;
1440
1441 procedure TLazPaintConfig.SetStartupTargetDirectory(AValue: string);
1442 begin
1443 iniOptions.WriteString('Startup', 'TargetDirectory', AValue);
1444 end;
1445
DefaultStartupExportDirectorynull1446 function TLazPaintConfig.DefaultStartupExportDirectory: string;
1447 begin
1448 result := iniOptions.ReadString('Startup', 'ExportDirectory', '');
1449 end;
1450
1451 procedure TLazPaintConfig.SetStartupExportDirectory(AValue: string);
1452 begin
1453 iniOptions.WriteString('Startup', 'ExportDirectory', AValue);
1454 end;
1455
DefaultRememberSaveFormatnull1456 function TLazPaintConfig.DefaultRememberSaveFormat: boolean;
1457 begin
1458 result := iniOptions.ReadBool('Startup', 'RememberSaveFormat', false);
1459 end;
1460
1461 procedure TLazPaintConfig.SetRememberSaveFormat(AValue: boolean);
1462 begin
1463 iniOptions.WriteBool('Startup', 'RememberSaveFormat', AValue);
1464 end;
1465
TLazPaintConfig.DefaultSaveExtensionsnull1466 function TLazPaintConfig.DefaultSaveExtensions: string;
1467 begin
1468 result := iniOptions.ReadString('Startup', 'SaveExtensions', '');
1469 end;
1470
1471 procedure TLazPaintConfig.SetSaveExtensions(AValue: string);
1472 begin
1473 iniOptions.WriteString('Startup', 'SaveExtensions', AValue);
1474 end;
1475
1476 procedure TLazPaintConfig.SetBrushes(ABrushes: TStringList);
1477 var
1478 i: Integer;
1479 begin
1480 iniOptions.EraseSection('Brushes');
1481 iniOptions.WriteInteger('Brushes','Count',ABrushes.Count);
1482 for i := 0 to ABrushes.Count-1 do
1483 iniOptions.WriteString('Brushes','Brush'+inttostr(I+1),ABrushes[i]);
1484 end;
1485
TLazPaintConfig.DefaultJpegQualitynull1486 function TLazPaintConfig.DefaultJpegQuality: integer;
1487 begin
1488 result := iniOptions.ReadInteger('General','JpegQuality',100);
1489 end;
1490
1491 procedure TLazPaintConfig.SetDefaultJpegQuality(value: integer);
1492 begin
1493 iniOptions.WriteInteger('General','JpegQuality',value);
1494 end;
1495
TLazPaintConfig.DefaultWebPLosslessnull1496 function TLazPaintConfig.DefaultWebPLossless: boolean;
1497 begin
1498 result := iniOptions.ReadBool('General','WebPLossless',true);
1499 end;
1500
1501 procedure TLazPaintConfig.SetDefaultWebPLossless(value: boolean);
1502 begin
1503 iniOptions.WriteBool('General','WebPLossless',value);
1504 end;
1505
DefaultSaveOptionDialogMaximizednull1506 function TLazPaintConfig.DefaultSaveOptionDialogMaximized: boolean;
1507 begin
1508 result := iniOptions.ReadBool('Window','SaveOptionDialogMaximized',false);
1509 end;
1510
1511 procedure TLazPaintConfig.SetDefaultSaveOptionDialogMaximized(value: boolean);
1512 begin
1513 iniOptions.WriteBool('Window','SaveOptionDialogMaximized',value);
1514 end;
1515
1516 procedure TLazPaintConfig.InitColorizePresets;
1517 var presetsStr: TStringList;
1518 i: integer;
1519 begin
1520 presetsStr := TStringList.Create;
1521 iniOptions.ReadSection('Colorize',presetsStr);
1522 colorizePresets := TList.Create;
1523 for i := 0 to presetsStr.Count-1 do
1524 begin
1525 AddColorizePreset(TVariableSet.Create('ColorColorize',iniOptions.ReadString('Colorize',presetsStr[i],'')));
1526 end;
1527 presetsStr.free;
1528 if ColorizePresetCount = 0 then
1529 begin
1530 AddColorizePreset('Antartic',211,0.660,True);
1531 AddColorizePreset('Mars',16.5,0.902,True);
1532 AddColorizePreset('Purple',291,0.634,False);
1533 AddColorizePreset('Sepia',31.0,0.119,False);
1534 end;
1535 end;
1536
AddColorizePresetnull1537 function TLazPaintConfig.AddColorizePreset(AName: string; AHue,
1538 ASaturation: double; ACorrection: Boolean): integer;
1539 var
1540 params: TVariableSet;
1541 begin
1542 params := TVariableSet.Create('ColorColorize');
1543 params.AddString('Name',AName);
1544 params.AddFloat('Hue', AHue);
1545 params.AddFloat('Saturation',ASaturation);
1546 params.AddBoolean('Correction',ACorrection);
1547 result := AddColorizePreset(params);
1548 end;
1549
AddColorizePresetnull1550 function TLazPaintConfig.AddColorizePreset(AParams: TVariableSet): integer;
1551 var i: integer;
1552 s: string;
1553 begin
1554 s := AParams.Strings['Name'];
1555 for i := ColorizePresetCount-1 downto 0 do
1556 if CompareText(colorizePreset[i].Strings['Name'],s) = 0 then
1557 RemoveColorizePreset(i);
1558 result := colorizePresets.Add(AParams);
1559 end;
1560
1561 procedure TLazPaintConfig.RemoveColorizePreset(AIndex: integer);
1562 begin
1563 if (AIndex >= 0) and (AIndex < ColorizePresetCount) then
1564 begin
1565 ColorizePreset[AIndex].Free;
1566 colorizePresets.Delete(AIndex);
1567 end;
1568 end;
1569
IndexOfColorizePresetnull1570 function TLazPaintConfig.IndexOfColorizePreset(AName: string): integer;
1571 var i: integer;
1572 begin
1573 for i := ColorizePresetCount-1 downto 0 do
1574 if CompareText(colorizePreset[i].Strings['Name'],AName) = 0 then
1575 begin
1576 result := i;
1577 exit;
1578 end;
1579 result := -1;
1580 end;
1581
1582 procedure TLazPaintConfig.FinalizeColorizePresets;
1583 var i: integer;
1584 begin
1585 iniOptions.EraseSection('Colorize');
1586 for i := 0 to ColorizePresetCount-1 do
1587 iniOptions.WriteString('Colorize','Preset'+inttostr(I+1),ColorizePreset[i].VariablesAsString);
1588
1589 for i := 0 to ColorizePresetCount-1 do
1590 ColorizePreset[i].Free;
1591 colorizePresets.Free;
1592 end;
1593
DefaultLangagenull1594 function TLazPaintConfig.DefaultLangage: string;
1595 begin
1596 result := ClassGetDefaultLangage(iniOptions);
1597 end;
1598
TLazPaintConfig.ClassGetDefaultLangagenull1599 class function TLazPaintConfig.ClassGetDefaultLangage(AIni: TIniFile): string;
1600 begin
1601 result := AIni.ReadString('General','Language','');
1602 if result = '' then result := 'auto';
1603 end;
1604
1605 procedure TLazPaintConfig.SetDefaultLangage(value: string);
1606 begin
1607 if value = 'auto' then value := '';
1608 iniOptions.WriteString('General','Language',value);
1609 end;
1610
GetLastUpdateChecknull1611 function TLazPaintConfig.GetLastUpdateCheck: TDateTime;
1612 begin
1613 result := iniOptions.ReadInt64('General','LastUpdateCheck',0);
1614 end;
1615
1616 procedure TLazPaintConfig.SetLastUpdateCheck(value: TDateTime);
1617 begin
1618 iniOptions.WriteInt64('General','LastUpdateCheck',round(value));
1619 end;
1620
LatestVersionnull1621 function TLazPaintConfig.LatestVersion: string;
1622 begin
1623 result := iniOptions.ReadString('General','LatestOnlineVersion','');
1624 end;
1625
1626 procedure TLazPaintConfig.SetLatestVersion(value: string);
1627 begin
1628 iniOptions.WriteString('General','LatestOnlineVersion',value);
1629 end;
1630
1631 procedure TLazPaintConfig.GetUpdatedLanguages(AList: TStringList);
1632 begin
1633 ClassGetUpdatedLanguages(AList,iniOptions,FVersion);
1634 end;
1635
1636 procedure TLazPaintConfig.SetUpdatedLanguages(AList: TStringList);
1637 begin
1638 ClassSetUpdatedLanguages(AList,iniOptions,FVersion);
1639 end;
1640
1641 class procedure TLazPaintConfig.ClassGetUpdatedLanguages(AList: TStringList;
1642 AIni: TIniFile; AVersion: string);
1643 begin
1644 AList.CommaText := AIni.ReadString('General','UpdatedLanguages'+AVersion,'');
1645 end;
1646
1647 class procedure TLazPaintConfig.ClassSetUpdatedLanguages(AList: TStringList;
1648 AIni: TIniFile; AVersion: string);
1649 begin
1650 AIni.WriteString('General','UpdatedLanguages'+AVersion,AList.CommaText)
1651 end;
1652
1653 procedure TLazPaintConfig.AddUpdatedLanguage(ALang: string);
1654 var list: TStringList;
1655 begin
1656 list := TStringList.Create;
1657 GetUpdatedLanguages(list);
1658 if list.IndexOf(ALang)=-1 then
1659 begin
1660 list.Add(ALang);
1661 SetUpdatedLanguages(list);
1662 end;
1663 list.Free;
1664 end;
1665
Default3dObjectDirectorynull1666 function TLazPaintConfig.Default3dObjectDirectory: string;
1667 begin
1668 result := iniOptions.ReadString('General','3dObjectDirectory','');
1669 end;
1670
1671 procedure TLazPaintConfig.SetDefault3dObjectDirectory(value: string);
1672 begin
1673 iniOptions.WriteString('General','3dObjectDirectory',ChompPathDelim(value))
1674 end;
1675
TLazPaintConfig.DefaultTextureDirectorynull1676 function TLazPaintConfig.DefaultTextureDirectory: string;
1677 begin
1678 result := iniOptions.ReadString('General','TextureDirectory',DefaultPicturesDirectory);
1679 end;
1680
1681 procedure TLazPaintConfig.SetDefaultTextureDirectory(value: string);
1682 begin
1683 iniOptions.WriteString('General','TextureDirectory',ChompPathDelim(value))
1684 end;
1685
TLazPaintConfig.DefaultBrushDirectorynull1686 function TLazPaintConfig.DefaultBrushDirectory: string;
1687 begin
1688 result := iniOptions.ReadString('General','BrushDirectory',DefaultPicturesDirectory);
1689 end;
1690
1691 procedure TLazPaintConfig.SetDefaultBrushDirectory(value: string);
1692 begin
1693 iniOptions.WriteString('General','BrushDirectory',ChompPathDelim(value))
1694 end;
1695
TLazPaintConfig.DefaultPaletteDirectorynull1696 function TLazPaintConfig.DefaultPaletteDirectory: string;
1697 begin
1698 result := iniOptions.ReadString('General','PaletteDirectory','');
1699 end;
1700
1701 procedure TLazPaintConfig.SetDefaultPaletteDirectory(value: string);
1702 begin
1703 iniOptions.WriteString('General','PaletteDirectory',ChompPathDelim(value))
1704 end;
1705
TLazPaintConfig.DefaultScriptDirectorynull1706 function TLazPaintConfig.DefaultScriptDirectory: string;
1707 begin
1708 result := iniOptions.ReadString('General','ScriptDirectory','');
1709 end;
1710
1711 procedure TLazPaintConfig.SetDefaultScriptDirectory(value: string);
1712 begin
1713 iniOptions.WriteString('General','ScriptDirectory',ChompPathDelim(value))
1714 end;
1715
DefaultIconSizenull1716 function TLazPaintConfig.DefaultIconSize(defaultValue: integer): integer;
1717 begin
1718 result := iniOptions.ReadInteger('General','DefaultIconSize',0);
1719 if result > 48 then result := 48;
1720 if result = 0 then result := defaultValue;
1721 end;
1722
1723 procedure TLazPaintConfig.SetDefaultIconSize(value: integer);
1724 begin
1725 iniOptions.WriteInteger('General','DefaultIconSize',value);
1726 end;
1727
GetDarkThemenull1728 function TLazPaintConfig.GetDarkTheme: boolean;
1729 begin
1730 if not FDarkThemeEvaluated then
1731 begin
1732 if GetDarkThemePreference = dtpAuto then
1733 begin
1734 FDarkTheme := DarkThemeInstance.IsSystemDarkTheme;
1735 DarkThemeInstance.HasSystemDarkThemeChanged;
1736 end else
1737 FDarkTheme := iniOptions.ReadBool('General','DarkTheme', false);
1738 FDarkThemeEvaluated:= true;
1739 end;
1740 result := FDarkTheme;
1741 end;
1742
1743 procedure TLazPaintConfig.SetDarkTheme(AValue: boolean);
1744 begin
1745 if FDarkThemeEvaluated and (AValue = FDarkTheme) then exit;
1746 iniOptions.WriteBool('General','DarkTheme', AValue);
1747 FDarkTheme:= AValue;
1748 FDarkThemeEvaluated:= true;
1749 FWorkspaceColorEvaluated:= false;
1750 end;
1751
GetDarkThemePreferencenull1752 function TLazPaintConfig.GetDarkThemePreference: TDarkThemePreference;
1753 var
1754 s: String;
1755 begin
1756 if not FDarkThemePreferenceEvaluated then
1757 begin
1758 s := iniOptions.ReadString('General','DarkThemePreference', 'auto');
1759 if CompareText(s,'dark')=0 then FDarkThemePreference:= dtpDark
1760 else if CompareText(s,'light')=0 then FDarkThemePreference:= dtpLight
1761 else FDarkThemePreference:= dtpAuto;
1762 FDarkThemePreferenceEvaluated:= true;
1763 end;
1764 result := FDarkThemePreference;
1765 end;
1766
1767 procedure TLazPaintConfig.SetDarkThemePreference(AValue: TDarkThemePreference);
1768 var
1769 s: String;
1770 begin
1771 if FDarkThemeEvaluated and (AValue = FDarkThemePreference) then exit;
1772 case AValue of
1773 dtpDark: s := 'Dark';
1774 dtpLight: s := 'Light';
1775 else s := 'Auto';
1776 end;
1777 iniOptions.WriteString('General','DarkThemePreference', s);
1778 FDarkThemePreference:= AValue;
1779 FDarkThemePreferenceEvaluated:= true;
1780 end;
1781
ScreenSizeChangednull1782 function TLazPaintConfig.ScreenSizeChanged: boolean;
1783 var currentScreenSize,previousScreenSize: TRect;
1784 begin
1785 currentScreenSize := rect(0,0,screen.Width,screen.Height);
1786 previousScreenSize := DefaultScreenSize;
1787 if not CompareRect(@previousScreenSize,@currentScreenSize.left) then
1788 begin
1789 SetDefaultScreenSize(currentScreenSize);
1790 result := true;
1791 end else
1792 result := false;
1793 end;
1794
1795 procedure TLazPaintConfig.AddRecentFile(filename: string);
1796 var idx : integer;
1797 begin
1798 idx := recentFiles.IndexOf(filename);
1799 if idx <> -1 then
1800 recentFiles.Delete(idx);
1801 recentFiles.Insert(0,filename);
1802 while recentFiles.count > maxRecentFiles do
1803 recentFiles.Delete(recentFiles.count-1);
1804 end;
1805
1806 procedure TLazPaintConfig.AddRecentDirectory(dirname: string);
1807 var idx : integer;
1808 begin
1809 dirname := ChompPathDelim(dirname);
1810 idx := recentDirs.IndexOf(dirname);
1811 if idx <> -1 then
1812 recentDirs.Delete(idx);
1813 recentDirs.Insert(0,dirname);
1814 while recentDirs.count > maxRecentDirectories do
1815 recentDirs.Delete(recentDirs.count-1);
1816 end;
1817
TLazPaintConfig.GetRecentFilesCountnull1818 function TLazPaintConfig.GetRecentFilesCount: integer;
1819 begin
1820 result := recentFiles.Count;
1821 end;
1822
GetColorizePresetnull1823 function TLazPaintConfig.GetColorizePreset(Index: Integer): TVariableSet;
1824 begin
1825 result := TVariableSet(colorizePresets[Index]);
1826 end;
1827
GetBrushCountnull1828 function TLazPaintConfig.GetBrushCount: integer;
1829 begin
1830 result := iniOptions.ReadInteger('Brushes','Count',0);
1831 end;
1832
TLazPaintConfig.GetBrushInfonull1833 function TLazPaintConfig.GetBrushInfo(Index: integer): string;
1834 begin
1835 result := iniOptions.ReadString('Brushes','Brush'+IntToStr(index+1),'');
1836 end;
1837
GetColorizePresetCountnull1838 function TLazPaintConfig.GetColorizePresetCount: integer;
1839 begin
1840 result := colorizePresets.Count;
1841 end;
1842
TLazPaintConfig.GetRecentDirectoriesCountnull1843 function TLazPaintConfig.GetRecentDirectoriesCount: integer;
1844 begin
1845 result := recentDirs.Count;
1846 end;
1847
GetRecentDirectorynull1848 function TLazPaintConfig.GetRecentDirectory(Index: Integer): string;
1849 begin
1850 result := recentDirs[Index];
1851 end;
1852
GetRecentFilenull1853 function TLazPaintConfig.GetRecentFile(Index: Integer): string;
1854 begin
1855 result := recentFiles[Index];
1856 end;
1857
ImageListLastFoldernull1858 function TLazPaintConfig.ImageListLastFolder: string;
1859 begin
1860 result := iniOptions.ReadString('ImageList','LastFolder','');
1861 end;
1862
1863 procedure TLazPaintConfig.SetImageListLastFolder(value: string);
1864 begin
1865 iniOptions.WriteString('ImageList','LastFolder',ChompPathDelim(value));
1866 end;
1867
TLazPaintConfig.ImageListAutoZoomnull1868 function TLazPaintConfig.ImageListAutoZoom: Boolean;
1869 begin
1870 result := iniOptions.ReadBool('ImageList','AutoZoom',True);
1871 end;
1872
1873 procedure TLazPaintConfig.SetImageListAutoZoom(value: Boolean);
1874 begin
1875 iniOptions.WriteBool('ImageList','AutoZoom',Value);
1876 end;
1877
ImageListAutoUnchecknull1878 function TLazPaintConfig.ImageListAutoUncheck: Boolean;
1879 begin
1880 result := iniOptions.ReadBool('ImageList','AutoUncheck',True);
1881 end;
1882
1883 procedure TLazPaintConfig.SetImageListAutoUncheck(value: Boolean);
1884 begin
1885 iniOptions.WriteBool('ImageList','AutoUncheck',Value);
1886 end;
1887
TLazPaintConfig.ImageListAutoUncheckModenull1888 function TLazPaintConfig.ImageListAutoUncheckMode: Integer;
1889 begin
1890 result := iniOptions.ReadInteger('ImageList','AutoUncheckMode',0);
1891 end;
1892
1893 procedure TLazPaintConfig.SetImageListAutoUncheckMode(value: integer);
1894 begin
1895 iniOptions.WriteInteger('ImageList','AutoUncheckMode',value);
1896 end;
1897
1898
1899 constructor TLazPaintConfig.Create(ini: TIniFile; AVersion: string);
1900 begin
1901 FVersion:= AVersion;
1902 iniOptions := ini;
1903 InitRecentFiles;
1904
1905 if ScreenSizeChanged then
1906 begin
1907 SetDefaultMainWindowPosition(EmptyRect);
1908 SetDefaultColorWindowPosition(EmptyRect);
1909 SetDefaultToolboxWindowPosition(EmptyRect);
1910 SetDefaultLayerWindowPosition(EmptyRect);
1911 SetDefaultImagelistWindowPosition(EmptyRect);
1912 SetDefaultBrowseWindowPosition(EmptyRect);
1913 end;
1914
1915 tempFont := TFont.Create;
1916 Languages := TStringList.Create;
1917
1918 InitColorizePresets;
1919 end;
1920
1921 destructor TLazPaintConfig.Destroy;
1922 begin
1923 FinalizeRecentFiles;
1924 FinalizeColorizePresets;
1925 iniOptions.Free;
1926 tempFont.Free;
1927 Languages.Free;
1928 end;
1929
1930 initialization
1931
1932 MenuDefinitionKeys := TStringList.Create;
1933 MenuDefinitionValues := TStringList.Create;
1934
1935 finalization
1936
1937 MenuDefinitionKeys.Free;
1938 MenuDefinitionValues.Free;
1939
1940 end.
1941