Recent

Author Topic: Analog of IsDefaultPropertyValue in Free Pascal.  (Read 1444 times)

dmitryb

  • Jr. Member
  • **
  • Posts: 62
Analog of IsDefaultPropertyValue in Free Pascal.
« on: September 30, 2018, 12:41:42 am »
Hi All

What is the analog of Delphi function IsDefaultPropertyValue in Free Pascal?

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Analog of IsDefaultPropertyValue in Free Pascal.
« Reply #1 on: September 30, 2018, 03:15:31 am »
Hi, quick observation:

in objectinspector.pp is nested method
Code: Pascal  [Select][+][-]
  1. procedure DrawValue(DrawState: TPropEditDrawState);
  2.   var
  3.     OldFont: TFont;
  4.   begin
  5.     if ARow<>ItemIndex then
  6.     begin
  7.       OldFont:=Canvas.Font;
  8.       if CurRow.Editor.ValueIsStreamed then
  9.         Canvas.Font:=FValueFont
  10.       else
  11.         Canvas.Font:=FDefaultValueFont;
  12.       CurRow.Editor.PropDrawValue(Canvas,ValueRect,DrawState);
  13.       Canvas.Font:=OldFont;
  14.     end;
  15.     CurRow.LastPaintedValue:=CurRow.Editor.GetVisualValue;
  16.   end;
important is method Editor.ValueIsStreamed which decides whether to paint value in OI with clMaroon or clWindowText color.

propedits.pp line 3447:
Code: Pascal  [Select][+][-]
  1. function TPropertyEditor.ValueIsStreamed: boolean;
  2. begin
  3.   if HasStoredFunction then
  4.     Result := CallStoredFunction
  5.   else
  6.     Result := True;
  7.   if Result and HasDefaultValue then
  8.     Result := GetDefaultValue<>GetVisualValue;
  9. end;

I hope it will help you.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

dmitryb

  • Jr. Member
  • **
  • Posts: 62
Re: Analog of IsDefaultPropertyValue in Free Pascal.
« Reply #2 on: September 30, 2018, 03:42:52 am »
Thank you.
I see, it is necessary to pull out pieces of code from the TPropertyEditor class.

 

TinyPortal © 2005-2018