GR32.Design.Misc.pas 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. unit GR32.Design.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. * ***** END LICENSE BLOCK ***** *)
  32. interface
  33. {$include GR32.inc}
  34. uses
  35. {$IFDEF FPC} LCLIntf, LazIDEIntf, PropEdits,{$ELSE}
  36. Windows, DesignIntf, DesignEditors, ToolsAPI,{$ENDIF}
  37. Classes, TypInfo, GR32_Containers;
  38. type
  39. TCustomClassProperty = class(TClassProperty)
  40. private
  41. function HasSubProperties: Boolean;
  42. protected
  43. class function GetClassList: TClassList; virtual;
  44. procedure SetClassName(const CustomClass: string); virtual; {$IFNDEF BCB} abstract; {$ENDIF}
  45. function GetObject: TObject; virtual; {$IFNDEF BCB} abstract; {$ENDIF}
  46. public
  47. function GetAttributes: TPropertyAttributes; override;
  48. procedure GetValues(Proc: TGetStrProc); override;
  49. procedure SetValue(const Value: string); override;
  50. function GetValue: string; override;
  51. end;
  52. TKernelClassProperty = class(TCustomClassProperty)
  53. protected
  54. class function GetClassList: TClassList; override;
  55. procedure SetClassName(const CustomClass: string); override;
  56. function GetObject: TObject; override;
  57. end;
  58. TResamplerClassProperty = class(TCustomClassProperty)
  59. protected
  60. class function GetClassList: TClassList; override;
  61. procedure SetClassName(const CustomClass: string); override;
  62. function GetObject: TObject; override;
  63. end;
  64. implementation
  65. uses
  66. GR32,
  67. GR32_Resamplers;
  68. { TCustomClassProperty }
  69. function TCustomClassProperty.GetAttributes: TPropertyAttributes;
  70. begin
  71. Result := inherited GetAttributes - [paReadOnly] +
  72. [paValueList, paRevertable, paVolatileSubProperties];
  73. if not HasSubProperties then Exclude(Result, paSubProperties);
  74. end;
  75. class function TCustomClassProperty.GetClassList: TClassList;
  76. begin
  77. Result := nil;
  78. end;
  79. function TCustomClassProperty.GetValue: string;
  80. begin
  81. if PropCount > 0 then
  82. Result := GetObject.ClassName
  83. else
  84. Result := '';
  85. end;
  86. procedure TCustomClassProperty.GetValues(Proc: TGetStrProc);
  87. var
  88. I: Integer;
  89. L: TClassList;
  90. begin
  91. L := GetClassList;
  92. if Assigned(L) then
  93. for I := 0 to L.Count - 1 do
  94. Proc(L.Items[I].ClassName);
  95. end;
  96. function TCustomClassProperty.HasSubProperties: Boolean;
  97. begin
  98. if PropCount > 0 then
  99. Result := GetTypeData(GetObject.ClassInfo)^.PropCount > 0
  100. else
  101. Result := False;
  102. end;
  103. procedure TCustomClassProperty.SetValue(const Value: string);
  104. var
  105. L: TClassList;
  106. begin
  107. L := GetClassList;
  108. if Assigned(L) and Assigned(L.Find(Value)) then
  109. SetClassName(Value)
  110. else SetStrValue('');
  111. Modified;
  112. end;
  113. {$IFDEF BCB}
  114. procedure TCustomClassProperty.SetClassName(const CustomClass: string);
  115. begin
  116. end;
  117. function TCustomClassProperty.GetObject: TObject;
  118. begin
  119. Result := nil;
  120. end;
  121. {$ENDIF}
  122. { TKernelClassProperty }
  123. class function TKernelClassProperty.GetClassList: TClassList;
  124. begin
  125. Result := TClassList(KernelList);
  126. end;
  127. function TKernelClassProperty.GetObject: TObject;
  128. begin
  129. Result := TKernelResampler(GetComponent(0)).Kernel;
  130. end;
  131. procedure TKernelClassProperty.SetClassName(const CustomClass: string);
  132. begin
  133. TKernelResampler(GetComponent(0)).KernelClassName := CustomClass;
  134. end;
  135. { TResamplerClassProperty }
  136. class function TResamplerClassProperty.GetClassList: TClassList;
  137. begin
  138. Result := TClassList(ResamplerList);
  139. end;
  140. function TResamplerClassProperty.GetObject: TObject;
  141. begin
  142. Result := TBitmap32(GetComponent(0)).Resampler;
  143. end;
  144. procedure TResamplerClassProperty.SetClassName(
  145. const CustomClass: string);
  146. begin
  147. TBitmap32(GetComponent(0)).ResamplerClassName := CustomClass;
  148. end;
  149. {$IFNDEF FPC}
  150. var
  151. GSplashScreen : HBITMAP;
  152. {$ENDIF}
  153. initialization
  154. {$IFNDEF FPC}
  155. // Add Splash Screen
  156. GSplashScreen := LoadBitmap(hInstance, 'GR32');
  157. (SplashScreenServices as IOTasplashScreenServices).AddPluginBitmap('Graphics32', GSplashScreen, False, 'Open Source', Graphics32Version);
  158. {$ENDIF}
  159. end.