| 1 | unit GR32_Dsgn_Misc;
|
|---|
| 2 |
|
|---|
| 3 | (* ***** BEGIN LICENSE BLOCK *****
|
|---|
| 4 | * Version: MPL 1.1 or LGPL 2.1 with linking exception
|
|---|
| 5 | *
|
|---|
| 6 | * The contents of this file are subject to the Mozilla Public License Version
|
|---|
| 7 | * 1.1 (the "License"); you may not use this file except in compliance with
|
|---|
| 8 | * the License. You may obtain a copy of the License at
|
|---|
| 9 | * http://www.mozilla.org/MPL/
|
|---|
| 10 | *
|
|---|
| 11 | * Software distributed under the License is distributed on an "AS IS" basis,
|
|---|
| 12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|---|
| 13 | * for the specific language governing rights and limitations under the
|
|---|
| 14 | * License.
|
|---|
| 15 | *
|
|---|
| 16 | * Alternatively, the contents of this file may be used under the terms of the
|
|---|
| 17 | * Free Pascal modified version of the GNU Lesser General Public License
|
|---|
| 18 | * Version 2.1 (the "FPC modified LGPL License"), in which case the provisions
|
|---|
| 19 | * of this license are applicable instead of those above.
|
|---|
| 20 | * Please see the file LICENSE.txt for additional information concerning this
|
|---|
| 21 | * license.
|
|---|
| 22 | *
|
|---|
| 23 | * The Original Code is Graphics32
|
|---|
| 24 | *
|
|---|
| 25 | * The Initial Developers of the Original Code are
|
|---|
| 26 | * Mattias Andersson <mattias@centaurix.com>
|
|---|
| 27 | * Andre Beckedorf <andre@metaexception.de>
|
|---|
| 28 | *
|
|---|
| 29 | * Portions created by the Initial Developer are Copyright (C) 2005-2009
|
|---|
| 30 | * the Initial Developer. All Rights Reserved.
|
|---|
| 31 | *
|
|---|
| 32 | * Contributor(s):
|
|---|
| 33 | *
|
|---|
| 34 | * ***** END LICENSE BLOCK ***** *)
|
|---|
| 35 |
|
|---|
| 36 | interface
|
|---|
| 37 |
|
|---|
| 38 | {$I GR32.inc}
|
|---|
| 39 |
|
|---|
| 40 | uses
|
|---|
| 41 | {$IFDEF FPC} LCLIntf, LazIDEIntf, PropEdits,{$ELSE}
|
|---|
| 42 | Windows, DesignIntf, DesignEditors, ToolsAPI,{$ENDIF}
|
|---|
| 43 | Classes, TypInfo, GR32_Containers;
|
|---|
| 44 |
|
|---|
| 45 | type
|
|---|
| 46 | TCustomClassProperty = class(TClassProperty)
|
|---|
| 47 | private
|
|---|
| 48 | function HasSubProperties: Boolean;
|
|---|
| 49 | protected
|
|---|
| 50 | class function GetClassList: TClassList; virtual;
|
|---|
| 51 | procedure SetClassName(const CustomClass: string); virtual; {$IFNDEF BCB} abstract; {$ENDIF}
|
|---|
| 52 | function GetObject: TObject; virtual; {$IFNDEF BCB} abstract; {$ENDIF}
|
|---|
| 53 | public
|
|---|
| 54 | function GetAttributes: TPropertyAttributes; override;
|
|---|
| 55 | procedure GetValues(Proc: TGetStrProc); override;
|
|---|
| 56 | procedure SetValue(const Value: string); override;
|
|---|
| 57 | function GetValue: string; override;
|
|---|
| 58 | end;
|
|---|
| 59 |
|
|---|
| 60 | TKernelClassProperty = class(TCustomClassProperty)
|
|---|
| 61 | protected
|
|---|
| 62 | class function GetClassList: TClassList; override;
|
|---|
| 63 | procedure SetClassName(const CustomClass: string); override;
|
|---|
| 64 | function GetObject: TObject; override;
|
|---|
| 65 | end;
|
|---|
| 66 |
|
|---|
| 67 | TResamplerClassProperty = class(TCustomClassProperty)
|
|---|
| 68 | protected
|
|---|
| 69 | class function GetClassList: TClassList; override;
|
|---|
| 70 | procedure SetClassName(const CustomClass: string); override;
|
|---|
| 71 | function GetObject: TObject; override;
|
|---|
| 72 | end;
|
|---|
| 73 |
|
|---|
| 74 | implementation
|
|---|
| 75 |
|
|---|
| 76 | uses GR32, GR32_Resamplers;
|
|---|
| 77 |
|
|---|
| 78 | {$IFDEF COMPILER2005_UP}
|
|---|
| 79 | var
|
|---|
| 80 | GSplashScreen : HBITMAP;
|
|---|
| 81 | {$ENDIF}
|
|---|
| 82 |
|
|---|
| 83 | { TCustomClassProperty }
|
|---|
| 84 |
|
|---|
| 85 | function TCustomClassProperty.GetAttributes: TPropertyAttributes;
|
|---|
| 86 | begin
|
|---|
| 87 | Result := inherited GetAttributes - [paReadOnly] +
|
|---|
| 88 | [paValueList, paRevertable, paVolatileSubProperties];
|
|---|
| 89 | if not HasSubProperties then Exclude(Result, paSubProperties);
|
|---|
| 90 | end;
|
|---|
| 91 |
|
|---|
| 92 | class function TCustomClassProperty.GetClassList: TClassList;
|
|---|
| 93 | begin
|
|---|
| 94 | Result := nil;
|
|---|
| 95 | end;
|
|---|
| 96 |
|
|---|
| 97 | function TCustomClassProperty.GetValue: string;
|
|---|
| 98 | begin
|
|---|
| 99 | if PropCount > 0 then
|
|---|
| 100 | Result := GetObject.ClassName
|
|---|
| 101 | else
|
|---|
| 102 | Result := '';
|
|---|
| 103 | end;
|
|---|
| 104 |
|
|---|
| 105 | procedure TCustomClassProperty.GetValues(Proc: TGetStrProc);
|
|---|
| 106 | var
|
|---|
| 107 | I: Integer;
|
|---|
| 108 | L: TClassList;
|
|---|
| 109 | begin
|
|---|
| 110 | L := GetClassList;
|
|---|
| 111 | if Assigned(L) then
|
|---|
| 112 | for I := 0 to L.Count - 1 do
|
|---|
| 113 | Proc(L.Items[I].ClassName);
|
|---|
| 114 | end;
|
|---|
| 115 |
|
|---|
| 116 | function TCustomClassProperty.HasSubProperties: Boolean;
|
|---|
| 117 | begin
|
|---|
| 118 | if PropCount > 0 then
|
|---|
| 119 | Result := GetTypeData(GetObject.ClassInfo)^.PropCount > 0
|
|---|
| 120 | else
|
|---|
| 121 | Result := False;
|
|---|
| 122 | end;
|
|---|
| 123 |
|
|---|
| 124 | procedure TCustomClassProperty.SetValue(const Value: string);
|
|---|
| 125 | var
|
|---|
| 126 | L: TClassList;
|
|---|
| 127 | begin
|
|---|
| 128 | L := GetClassList;
|
|---|
| 129 | if Assigned(L) and Assigned(L.Find(Value)) then
|
|---|
| 130 | SetClassName(Value)
|
|---|
| 131 | else SetStrValue('');
|
|---|
| 132 | Modified;
|
|---|
| 133 | end;
|
|---|
| 134 |
|
|---|
| 135 | {$IFDEF BCB}
|
|---|
| 136 | class function TCustomClassProperty.GetClassList: TClassList;
|
|---|
| 137 | begin
|
|---|
| 138 | Result := nil;
|
|---|
| 139 | end;
|
|---|
| 140 |
|
|---|
| 141 | procedure TCustomClassProperty.SetClassName(const CustomClass: string);
|
|---|
| 142 | begin
|
|---|
| 143 | end;
|
|---|
| 144 |
|
|---|
| 145 | function TCustomClassProperty.GetObject: TObject;
|
|---|
| 146 | begin
|
|---|
| 147 | Result := nil;
|
|---|
| 148 | end;
|
|---|
| 149 | {$ENDIF}
|
|---|
| 150 |
|
|---|
| 151 | { TKernelClassProperty }
|
|---|
| 152 |
|
|---|
| 153 | class function TKernelClassProperty.GetClassList: TClassList;
|
|---|
| 154 | begin
|
|---|
| 155 | Result := KernelList;
|
|---|
| 156 | end;
|
|---|
| 157 |
|
|---|
| 158 | function TKernelClassProperty.GetObject: TObject;
|
|---|
| 159 | begin
|
|---|
| 160 | Result := TKernelResampler(GetComponent(0)).Kernel;
|
|---|
| 161 | end;
|
|---|
| 162 |
|
|---|
| 163 | procedure TKernelClassProperty.SetClassName(const CustomClass: string);
|
|---|
| 164 | begin
|
|---|
| 165 | TKernelResampler(GetComponent(0)).KernelClassName := CustomClass;
|
|---|
| 166 | end;
|
|---|
| 167 |
|
|---|
| 168 | { TResamplerClassProperty }
|
|---|
| 169 |
|
|---|
| 170 | class function TResamplerClassProperty.GetClassList: TClassList;
|
|---|
| 171 | begin
|
|---|
| 172 | Result := ResamplerList;
|
|---|
| 173 | end;
|
|---|
| 174 |
|
|---|
| 175 | function TResamplerClassProperty.GetObject: TObject;
|
|---|
| 176 | begin
|
|---|
| 177 | Result := TBitmap32(GetComponent(0)).Resampler;
|
|---|
| 178 | end;
|
|---|
| 179 |
|
|---|
| 180 | procedure TResamplerClassProperty.SetClassName(
|
|---|
| 181 | const CustomClass: string);
|
|---|
| 182 | begin
|
|---|
| 183 | TBitmap32(GetComponent(0)).ResamplerClassName := CustomClass;
|
|---|
| 184 | end;
|
|---|
| 185 |
|
|---|
| 186 | initialization
|
|---|
| 187 | {$IFDEF COMPILER2005_UP}
|
|---|
| 188 | // Add Splash Screen
|
|---|
| 189 | GSplashScreen := LoadBitmap(hInstance, 'GR32');
|
|---|
| 190 | (SplashScreenServices as IOTasplashScreenServices).AddPluginBitmap(
|
|---|
| 191 | 'GR32' + ' ' + Graphics32Version, GSplashScreen);
|
|---|
| 192 | {$ENDIF}
|
|---|
| 193 |
|
|---|
| 194 | end.
|
|---|