source: trunk/Packages/Graphics32/GR32_Dsgn_Misc.pas

Last change on this file was 2, checked in by chronos, 5 years ago
File size: 5.2 KB
Line 
1unit 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
36interface
37
38{$I GR32.inc}
39
40uses
41 {$IFDEF FPC} LCLIntf, LazIDEIntf, PropEdits,{$ELSE}
42 Windows, DesignIntf, DesignEditors, ToolsAPI,{$ENDIF}
43 Classes, TypInfo, GR32_Containers;
44
45type
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
74implementation
75
76uses GR32, GR32_Resamplers;
77
78{$IFDEF COMPILER2005_UP}
79var
80 GSplashScreen : HBITMAP;
81{$ENDIF}
82
83{ TCustomClassProperty }
84
85function TCustomClassProperty.GetAttributes: TPropertyAttributes;
86begin
87 Result := inherited GetAttributes - [paReadOnly] +
88 [paValueList, paRevertable, paVolatileSubProperties];
89 if not HasSubProperties then Exclude(Result, paSubProperties);
90end;
91
92class function TCustomClassProperty.GetClassList: TClassList;
93begin
94 Result := nil;
95end;
96
97function TCustomClassProperty.GetValue: string;
98begin
99 if PropCount > 0 then
100 Result := GetObject.ClassName
101 else
102 Result := '';
103end;
104
105procedure TCustomClassProperty.GetValues(Proc: TGetStrProc);
106var
107 I: Integer;
108 L: TClassList;
109begin
110 L := GetClassList;
111 if Assigned(L) then
112 for I := 0 to L.Count - 1 do
113 Proc(L.Items[I].ClassName);
114end;
115
116function TCustomClassProperty.HasSubProperties: Boolean;
117begin
118 if PropCount > 0 then
119 Result := GetTypeData(GetObject.ClassInfo)^.PropCount > 0
120 else
121 Result := False;
122end;
123
124procedure TCustomClassProperty.SetValue(const Value: string);
125var
126 L: TClassList;
127begin
128 L := GetClassList;
129 if Assigned(L) and Assigned(L.Find(Value)) then
130 SetClassName(Value)
131 else SetStrValue('');
132 Modified;
133end;
134
135{$IFDEF BCB}
136class function TCustomClassProperty.GetClassList: TClassList;
137begin
138 Result := nil;
139end;
140
141procedure TCustomClassProperty.SetClassName(const CustomClass: string);
142begin
143end;
144
145function TCustomClassProperty.GetObject: TObject;
146begin
147 Result := nil;
148end;
149{$ENDIF}
150
151{ TKernelClassProperty }
152
153class function TKernelClassProperty.GetClassList: TClassList;
154begin
155 Result := KernelList;
156end;
157
158function TKernelClassProperty.GetObject: TObject;
159begin
160 Result := TKernelResampler(GetComponent(0)).Kernel;
161end;
162
163procedure TKernelClassProperty.SetClassName(const CustomClass: string);
164begin
165 TKernelResampler(GetComponent(0)).KernelClassName := CustomClass;
166end;
167
168{ TResamplerClassProperty }
169
170class function TResamplerClassProperty.GetClassList: TClassList;
171begin
172 Result := ResamplerList;
173end;
174
175function TResamplerClassProperty.GetObject: TObject;
176begin
177 Result := TBitmap32(GetComponent(0)).Resampler;
178end;
179
180procedure TResamplerClassProperty.SetClassName(
181 const CustomClass: string);
182begin
183 TBitmap32(GetComponent(0)).ResamplerClassName := CustomClass;
184end;
185
186initialization
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
194end.
Note: See TracBrowser for help on using the repository browser.