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

View File

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

View File

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

View File

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

View File

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