- TCustomMemo.WantReturns implementation (0008352)

git-svn-id: trunk@11124 -
This commit is contained in:
paul 2007-05-10 14:12:03 +00:00
parent 99df3c959b
commit 3c6665616c
3 changed files with 38 additions and 4 deletions

View File

@ -30,6 +30,7 @@ constructor TCustomMemo.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fCompStyle := csMemo;
FWantReturns := true;
FWantTabs := false;
FWordWrap := True;
//FLines := TMemoStrings.Create(Self);
@ -93,6 +94,15 @@ begin
FVertScrollBar:=AValue;
end;
procedure TCustomMemo.SetWantReturns(const AValue: Boolean);
begin
if FWantReturns = AValue then
exit;
FWantReturns := AValue;
if HandleAllocated then
TWSCustomMemoClass(WidgetSetClass).SetWantReturns(Self, AValue);
end;
{------------------------------------------------------------------------------
function TCustomMemo.StoreScrollBars: boolean;
------------------------------------------------------------------------------}
@ -217,13 +227,27 @@ end;
procedure TCustomMemo.ControlKeyDown(var Key: Word; Shift: TShiftState);
begin
if not ReadOnly then begin
if (Key=VK_RETURN) and (Shift=[]) then exit;
if FWantTabs and (Key=VK_TAB) and (Shift-[ssShift]=[]) then exit;
if not ReadOnly then
begin
if FWantReturns and (Key=VK_RETURN) and (Shift=[]) then
exit;
if FWantTabs and (Key=VK_TAB) and (Shift-[ssShift]=[]) then
exit;
end;
inherited ControlKeyDown(Key, Shift);
end;
procedure TCustomMemo.CNChar(var Message: TLMKeyUp);
begin
inherited CNChar(Message);
if not FWantReturns and (Message.CharCode = VK_RETURN) then
begin
Message.CharCode := VK_UNKNOWN;
Message.Result := 1;
end;
end;
procedure TCustomMemo.SetWantTabs(const NewWantTabs: boolean);
begin
if FWantTabs = NewWantTabs then exit;

View File

@ -723,6 +723,7 @@ type
FLines: TStrings;
FScrollBars: TScrollStyle;
FVertScrollBar: TMemoScrollBar;
FWantReturns: Boolean;
FWantTabs: boolean;
FWordWrap: Boolean;
procedure SetHorzScrollBar(const AValue: TMemoScrollBar);
@ -737,12 +738,14 @@ type
procedure SetAlignment(const AValue: TAlignment);
procedure SetLines(const Value: TStrings);
procedure SetSelText(const Val: string); override;
procedure SetWantReturns(const AValue: Boolean);
procedure SetWantTabs(const NewWantTabs: boolean);
procedure SetWordWrap(const Value: boolean);
procedure SetScrollBars(const Value: TScrollStyle);
procedure Loaded; override;
function WordWrapIsStored: boolean; virtual;
procedure ControlKeyDown(var Key: Word; Shift: TShiftState); override;
procedure CNChar(var Message: TLMKeyUp); message CN_CHAR;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
@ -756,7 +759,8 @@ type
property VertScrollBar: TMemoScrollBar
read FVertScrollBar write SetVertScrollBar stored StoreScrollBars;
property ScrollBars: TScrollStyle read FScrollBars write SetScrollBars;
property WantTabs: boolean read FWantTabs write SetWantTabs default false;
property WantReturns: Boolean read FWantReturns write SetWantReturns default true;
property WantTabs: Boolean read FWantTabs write SetWantTabs default false;
property WordWrap: Boolean read FWordWrap write SetWordWrap stored WordWrapIsStored default true;
end;
@ -853,6 +857,7 @@ type
property TabOrder;
property TabStop;
property Visible;
property WantReturns;
property WantTabs;
property WordWrap;
end;

View File

@ -146,6 +146,7 @@ type
class procedure SetAlignment(const ACustomMemo: TCustomMemo; const AAlignment: TAlignment); virtual;
class procedure SetScrollbars(const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle); virtual;
class procedure SetWantTabs(const ACustomMemo: TCustomMemo; const NewWantTabs: boolean); virtual;
class procedure SetWantReturns(const ACustomMemo: TCustomMemo; const NewWantReturns: boolean); virtual;
class procedure SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); virtual;
end;
TWSCustomMemoClass = class of TWSCustomMemo;
@ -419,6 +420,10 @@ class procedure TWSCustomMemo.SetWantTabs(const ACustomMemo: TCustomMemo; const
begin
end;
class procedure TWSCustomMemo.SetWantReturns(const ACustomMemo: TCustomMemo; const NewWantReturns: boolean);
begin
end;
class procedure TWSCustomMemo.SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean);
begin
end;