fixed loading TMemo.Lines - During Loading

git-svn-id: trunk@6447 -
This commit is contained in:
mattias 2005-01-01 14:38:37 +00:00
parent 2df9ef7b90
commit e35647ff98
5 changed files with 34 additions and 11 deletions

View File

@ -3147,11 +3147,13 @@ begin
Perform(CM_TEXTCHANGED, 0, 0);
end;
{------------------------------------------------------------------------------}
{ TControl SetText }
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------
TControl SetText
------------------------------------------------------------------------------}
procedure TControl.SetText(const Value: TCaption);
begin
//if CompareText(ClassName,'TMEMO')=0 then
// debugln('TControl.SetText A ',DbgSName(Self),' GetText="',GetText,'" Value="',Value,'" FCaption="',FCaption,'"');
if GetText = Value then Exit;
// Check if SetTextBuf is overridden, otherwise
@ -3169,11 +3171,13 @@ begin
DebugLn('Note: SetTextBuf is overridden for: ', Classname);
SetTextBuf(PChar(Value));
end;
//if CompareText(ClassName,'TMEMO')=0 then
// debugln('TControl.SetText END ',DbgSName(Self),' FCaption="',FCaption,'"');
end;
{------------------------------------------------------------------------------}
{ TControl Update }
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------
TControl Update
------------------------------------------------------------------------------}
procedure TControl.Update;
begin
if Parent<>nil then Parent.Update;
@ -3456,6 +3460,9 @@ end;
{ =============================================================================
$Log$
Revision 1.228 2005/01/01 14:38:36 mattias
fixed loading TMemo.Lines - During Loading
Revision 1.227 2004/12/22 23:54:21 mattias
started TControl.AnchorSide

View File

@ -34,7 +34,7 @@ begin
TMemoStrings(FLines).MemoWidgetClass := TWSCustomMemoClass(WidgetSetClass);
FVertScrollbar := TMemoScrollBar.Create(Self, sbVertical);
FHorzScrollbar := TMemoScrollBar.Create(Self, sbHorizontal);
SetInitialBounds(0,0,185,90);
SetInitialBounds(0,0,150,90);
end;
{------------------------------------------------------------------------------
@ -49,7 +49,7 @@ begin
FreeThenNil(FLines);
FreeThenNil(FVertScrollbar);
FreeThenNil(FHorzScrollbar);
inherited destroy;
inherited Destroy;
end;
{------------------------------------------------------------------------------
@ -178,6 +178,9 @@ end;
{ =============================================================================
$Log$
Revision 1.32 2005/01/01 14:38:36 mattias
fixed loading TMemo.Lines - During Loading
Revision 1.31 2004/11/15 12:37:52 mattias
added check handleallocated on loading memo

View File

@ -110,7 +110,7 @@ end;
Returns:
------------------------------------------------------------------------------}
procedure TMemoStrings.Insert(index : Integer; const S: String);
procedure TMemoStrings.Insert(Index: Integer; const S: String);
var
TempStrings: TStringList;
Cnt: Integer;
@ -123,11 +123,18 @@ begin
CurText := FMemo.Text;
TempStrings.Text := CurText;
Cnt:=TempStrings.Count;
//debugln('TMemoStrings.Insert A Index=',dbgs(Index),' Cnt=',dbgs(Cnt),' S="',S,'" FMemo.HandleAllocated=',dbgs(FMemo.HandleAllocated));
if Index=Cnt then begin
if FMemo.HandleAllocated then begin
// IMPORTANT:
// TControl.FCaption is only updated with FMemo.Text:=s calls
// That's why, FMemoWidgetClass.AppendText does not update
// TControl.FCaption and can not be used during loading.
if (FMemo.HandleAllocated) and (not (csLoading in FMemo.ComponentState))
then begin
LastLine:=S+LineEnding;
if (CurText<>'') and (not (CurText[length(CurText)] in [#10,#13])) then
LastLine:=LineEnding+LastLine;
//debugln('TMemoStrings.Insert AppendText LastLine="',LastLine,'"');
FMemoWidgetClass.AppendText(FMemo, LastLine);
end else begin
TempStrings.Insert(Index, S);
@ -148,6 +155,9 @@ end;
{ =============================================================================
$Log$
Revision 1.12 2005/01/01 14:38:36 mattias
fixed loading TMemo.Lines - During Loading
Revision 1.11 2004/09/10 17:59:57 micha
convert LM_APPENDTEXT to interface method

View File

@ -399,12 +399,13 @@ begin
csMemo : begin
P:= GetWidgetInfo(P, True)^.CoreWidget;
//debugln('TGtkWSWinControl.SetText A ',dbgs(gtk_text_get_length(PGtkText(P))),' AText="',AText,'"');
gtk_text_freeze(PGtkText(P));
gtk_text_set_point(PGtkText(P), 0);
gtk_text_forward_delete(PGtkText(P), gtk_text_get_length(PGtkText(P)));
gtk_text_insert(PGtkText(P), nil, nil, nil, pLabel, -1);
gtk_text_thaw(PGtkText(P));
//debugln('TGtkWSWinControl.SetText B ',dbgs(gtk_text_get_length(PGtkText(P))));
end;
csPage:

View File

@ -854,8 +854,10 @@ begin
Widget:=GetWidgetInfo(Pointer(ACustomMemo.Handle), true)^.CoreWidget;
gtk_text_freeze(PGtkText(Widget));
CurMemoLen := gtk_text_get_length(PGtkText(Widget));
//debugln('TGtkWSCustomMemo.AppendText "',AText,'" CurMemoLen=',dbgs(CurMemoLen));
gtk_editable_insert_text(PGtkOldEditable(Widget), PChar(AText), Length(AText),
@CurMemoLen);
//debugln('TGtkWSCustomMemo.AppendText B CurMemoLen=',dbgs(CurMemoLen));
gtk_text_thaw(PGtkText(Widget));
end;