GR32_Dsgn_Misc.pas 5.1 KB

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