fixed TSynEdit.RealGetText

git-svn-id: trunk@5433 -
This commit is contained in:
mattias 2004-04-26 10:01:27 +00:00
parent 2bdcedfc76
commit 0ce0cd43a4
4 changed files with 33 additions and 14 deletions
components/synedit
lcl

View File

@ -1579,7 +1579,10 @@ end;
{$IFDEF SYN_LAZARUS}
function TCustomSynEdit.RealGetText: string;
begin
Result := Lines.Text;
if fLines<>nil then
Result := Lines.Text
else
Result := '';
end;
{$ENDIF}

View File

@ -665,14 +665,14 @@ type
* exchange text between widgets and VCL. This means a lot of
* (unnecesary) text copies.
* The LCL uses strings for exchanging text (more efficient).
* To maintain VCL compatebility, the virtual RealGet/SetText is
* To maintain VCL compatibility, the virtual RealGet/SetText is
* introduced. These functions interface with the LCLInterface. The
* default Get/SetTextbuf implementation calls the RealGet/SetText.
* As long as the Get/SetTextBuf isn't overridden Get/SetText
* calls RealGet/SetText to avoid PChar copiing.
* To keep things optimal, LCL implementations should always
* override RealGet/SetText. Get/SetTextBuf is only kept for
* compatebility.
* compatibility.
*)
TControl = class(TLCLComponent)
@ -1469,7 +1469,7 @@ type
procedure Hide;
procedure Repaint; override;
Procedure SetFocus; override;
Function FindChildControl(ControlName : String) : TControl;
Function FindChildControl(const ControlName: String): TControl;
procedure FlipChildren(AllLevels: Boolean); dynamic;
Procedure GetTabOrderList(List : TList);
function HandleAllocated: Boolean;
@ -2260,6 +2260,9 @@ end.
{ =============================================================================
$Log$
Revision 1.198 2004/04/26 10:01:27 mattias
fixed TSynEdit.RealGetText
Revision 1.197 2004/04/20 23:39:01 marc
* Fixed setting of TWincontrol.Text during load

View File

@ -1155,7 +1155,7 @@ end;
{------------------------------------------------------------------------------}
{ TWinControl FindChildControl }
{------------------------------------------------------------------------------}
function TWinControl.FindChildControl(ControlName: string): TControl;
function TWinControl.FindChildControl(const ControlName: string): TControl;
var
I: Integer;
begin
@ -2088,7 +2088,7 @@ begin
FillChar(Params, SizeOf(Params),0);
with Params do
begin
Caption := @FCaption;
Caption := PChar(FCaption);
Style := WS_CHILD or WS_CLIPSIBLINGS;
if (Parent <> nil) then WndParent := Parent.Handle;
end;
@ -3081,8 +3081,9 @@ begin
EnableWindow(Handle, Enabled);
// Delay the setting of text until it is complete loaded
// Delay the setting of text until it is completely loaded
if not (csLoading in ComponentState)
and TWSWinControlClass(WidgetSetClass).HasText(Self)
then TWSWinControlClass(WidgetSetClass).SetText(Self, FCaption);
SetProp(Handle,'WinControl',TWinControl(Self));
@ -3129,7 +3130,8 @@ begin
if HandleAllocated
then begin
// Set cached caption
TWSWinControlClass(WidgetSetClass).SetText(Self, FCaption);
if TWSWinControlClass(WidgetSetClass).HasText(Self) then
TWSWinControlClass(WidgetSetClass).SetText(Self, FCaption);
if [wcfColorChanged,wcfFontChanged]*FFlags<>[] then
begin
@ -3156,7 +3158,8 @@ begin
if HandleAllocated
then begin
// make sure our text is saved
FCaption := GetText;
if TWSWinControlClass(WidgetSetClass).HasText(Self) then
FCaption := GetText;
DestroyComponent;
Handle := 0;
end;
@ -3331,7 +3334,8 @@ function TWinControl.RealGetText: TCaption;
begin
if not HandleAllocated
or (csLoading in ComponentState)
or not TWSWinControlClass(WidgetSetClass).GetText(Self, Result)
or (not TWSWinControlClass(WidgetSetClass).HasText(Self))
or (not TWSWinControlClass(WidgetSetClass).GetText(Self, Result))
then Result := inherited RealGetText;
end;
@ -3346,6 +3350,7 @@ function TWinControl.GetTextLen: Integer;
begin
if not HandleAllocated
or (csLoading in ComponentState)
or (not TWSWinControlClass(WidgetSetClass).HasText(Self))
or not TWSWinControlClass(WidgetSetClass).GetTextLen(Self, Result)
then Result := inherited GetTextLen;
end;
@ -3360,7 +3365,8 @@ end;
procedure TWinControl.RealSetText(const Value: TCaption);
begin
if HandleAllocated
and (not (csLoading in ComponentState))
and (not (csLoading in ComponentState))
and TWSWinControlClass(WidgetSetClass).HasText(Self)
then TWSWinControlClass(WidgetSetClass).SetText(Self, Value);
inherited;
end;
@ -3478,6 +3484,9 @@ end;
{ =============================================================================
$Log$
Revision 1.222 2004/04/26 10:01:27 mattias
fixed TSynEdit.RealGetText
Revision 1.221 2004/04/23 11:18:28 mattias
fixed unsetting csFocusing

View File

@ -60,16 +60,17 @@ type
{ TWSWinControl }
TWSWinControlClass = class of TWSWinControl;
TWSWinControl = class(TWSControl)
private
protected
public
class function HasText(const AWinControl: TWinControl): Boolean; virtual;
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; virtual;
class function GetTextLen(const AWinControl: TWinControl; var ALength: Integer): Boolean; virtual;
class procedure SetCursor(const AControl: TControl; const ACursor: TCursor); override;
class procedure SetText(const AWinControl: TWinControl; const AText: String); virtual;
end;
TWSWinControlClass = class of TWSWinControl;
{ TWSGraphicControl }
@ -109,6 +110,11 @@ end;
{ TWSWinControl }
function TWSWinControl.HasText(const AWinControl: TWinControl): Boolean;
begin
Result := true;
end;
function TWSWinControl.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
begin
Result := CNSendMessage(LM_GETTEXT, AWinControl, @AText) <> 0;
@ -133,7 +139,6 @@ begin
CNSendMessage(LM_SetLabel, AWinControl, PChar(AText));
end;
initialization
////////////////////////////////////////////////////
@ -145,7 +150,6 @@ initialization
// RegisterWSComponent(TDragImageList, TWSDragImageList);
RegisterWSComponent(TControl, TWSControl);
RegisterWSComponent(TWinControl, TWSWinControl);
// RegisterWSComponent(TWinControl, TWSWinControl);
// RegisterWSComponent(TGraphicControl, TWSGraphicControl);
// RegisterWSComponent(TCustomControl, TWSCustomControl);
// RegisterWSComponent(TImageList, TWSImageList);