Menu

#9 CanModify in addition to ReadOnly (TSynEdit and TDBSynEdit)

open
nobody
None
5
2015-01-21
2004-12-15
Nashev
No

in TSynEdit = class added

********
property PaintLock: Integer read fPaintLock;
property ReadOnly: Boolean read GetReadOnly
write SetReadOnly default FA
746a747,749
> // Nashev begin;
> function CanModify: Boolean; virtual;
> // Nashev end;
property SelAvail: Boolean read GetSelAvail;
property SelTabBlock: Boolean read
GetSelTabBlock;

********

> function TCustomSynEdit.CanModify: Boolean;
> begin
> Result := not ReadOnly;
> end;

> function TCustomDBSynEdit.CanModify: Boolean;
> begin
> Result := FDataLink.CanModify;
> end;

********

and all using of ReadOnly chanded to CanModify:

********
SText: string;
begin
1131c1134
< if not ReadOnly and SelAvail then begin

---
> if CanModify and SelAvail then begin

SText := SelText;
DoCopyToClipboard(SText);
********
{$ENDIF}
begin
3086c3089
< if ReadOnly then

---
> if not CanModify then

exit;
DoOnPaintTransient(ttBefore);

********
procedure TCustomSynEdit.SetSelText(const Value:
string);
begin
3604c3607
< if not ReadOnly then

---
> if CanModify then

SetSelTextPrimitive(FSelectionMode,
PChar(Value), nil);
end;
********
procedure TCustomSynEdit.WMCut(var Message:
TMessage);
begin
4380c4383
< if not ReadOnly then
---
> if CanModify then
CutToClipboard;
Message.Result := ord(True);
********
procedure TCustomSynEdit.WMPaste(var Message:
TMessage);
begin
4464c4467
< if not ReadOnly then
---
> if CanModify then
PasteFromClipboard;
Message.Result := ord(True);
********
function TCustomSynEdit.GetCanUndo: Boolean;
begin
4992c4995
< result := not ReadOnly and fUndoList.CanUndo;

---
> result := CanModify and fUndoList.CanUndo;

end;

function TCustomSynEdit.GetCanRedo: Boolean;
begin
4997c5000
< result := not ReadOnly and fRedoList.CanUndo;

---
> result := CanModify and fRedoList.CanUndo;

end;

********
begin
{$IFDEF SYN_CLX}
5003c5006
< Result := not ReadOnly and Clipboard.
Provides(CF_TEXT);
---
> Result := CanModify and Clipboard.
Provides(CF_TEXT);
{$ELSE}
5005c5008
< Result := not ReadOnly and Clipboard.
HasFormat(CF_TEXT)
---
> Result := CanModify and Clipboard.
HasFormat(CF_TEXT)
or Clipboard.HasFormat(SynEditClipboardFormat)
{$ENDIF}
********

begin
5045c5048
< if ReadOnly then

---
> if not CanModify then

exit;

********

begin
5263c5266
< if ReadOnly then

---
> if not CanModify then

exit;

********
begin
inherited;
5566c5569
< if (Source is TCustomSynEdit) and not
TCustomSynEdit(Source).ReadOnly then
---
> if (Source is TCustomSynEdit) and
TCustomSynEdit(Source).CanModify then
begin
Accept := True;
********
iPoint: TPoint;

begin
5594c5597
< if not ReadOnly and (Source is TCustomSynEdit)
---
> if CanModify and (Source is TCustomSynEdit)
and TCustomSynEdit(Source).SelAvail
then begin
********
{begin}

ecDeleteLastChar:
6180c6183
< if not ReadOnly then begin
---
> if CanModify then begin
DoOnPaintTransientEx(ttBefore,true);

try
********
end;
ecDeleteChar:
6329c6332
< if not ReadOnly then begin
---
> if CanModify then begin
DoOnPaintTransient(ttBefore);

if SelAvail then
********
end;
ecDeleteWord, ecDeleteEOL:
6381c6384
< if not ReadOnly then begin
---
> if CanModify then begin
DoOnPaintTransient(ttBefore);

Len := Length(LineText);
********
end;
ecDeleteLastWord, ecDeleteBOL:
6406c6409
< if not ReadOnly then begin
---
> if CanModify then begin
DoOnPaintTransient(ttBefore);

if Command = ecDeleteLastWord then
********
{end}

ecDeleteLine:
6430c6433
< if not ReadOnly and not ((Lines.Count = 1)
and (Length(Lines[0]) = 0
---
> if CanModify and not ((Lines.Count = 1) and
(Length(Lines[0]) = 0))
then begin
DoOnPaintTransient(ttBefore);

********
ecClearAll:
begin
6457c6460
< if not ReadOnly then ClearAll;
---
> if CanModify then ClearAll;
end;
ecInsertLine,
ecLineBreak:
6461c6464
< if not ReadOnly then begin
---
> if CanModify then begin
if SelAvail then begin
fUndoList.AddChange(crDelete,
fBlockBegin, fBlockEnd, SelText,
********
end;
ecTab:
6566c6569
< if not ReadOnly then DoTabKey;
---
> if CanModify then DoTabKey;
ecShiftTab:
6568c6571
< if not ReadOnly then DoShiftTabKey;

---
> if CanModify then DoShiftTabKey;

ecMatchBracket:
FindMatchingBracket;
ecChar:
// #127 is Ctrl + Backspace, #32 is space
6573c6576
< if not ReadOnly and (AChar >= #32) and
(AChar <> #127) then begin
---
> if CanModify and (AChar >= #32) and (AChar
<> #127) then begin
if SelAvail then begin
BeginUndoBlock;
********
ecToggleCase,
ecTitleCase:
6704c6707
< if not ReadOnly then
DoCaseChange(Command);
---
> if CanModify then DoCaseChange(Command)
;
ecUndo:
begin
6707c6710
< if not ReadOnly then Undo;
---
> if CanModify then Undo;
end;
ecRedo:
begin
6711c6714
< if not ReadOnly then Redo;
---
> if CanModify then Redo;
end;
ecGotoMarker0..ecGotoMarker9:
********
ecCut:
begin
6737c6740
< if (not ReadOnly) and SelAvail then
---
> if CanModify and SelAvail then
CutToClipboard;
end;
********
ecPaste:
begin
6746c6749
< if not ReadOnly then PasteFromClipboard;
---
> if CanModify then PasteFromClipboard;
end;
ecScrollUp, ecScrollDown:
********
end;
ecBlockIndent:
6800c6803
< if not ReadOnly then DoBlockIndent;
---
> if CanModify then DoBlockIndent;
ecBlockUnindent:
6802c6805
< if not ReadOnly then DoBlockUnindent;
---
> if CanModify then DoBlockUnindent;
ecNormalSelect,
ecColumnSelect,
********
{$IFDEF SYN_MBCSSUPPORT}
ecImeStr:
6818c6821
< if not ReadOnly then begin
---
> if CanModify then begin
SetString(s, PChar(Data), StrLen(Data));
if SelAvail then begin
********
{begin}

(* ecReplaceAll:
6867c6870
< if not ReadOnly then begin
---
> if CanModify then begin
SetString(s, PChar(Data), StrLen(Data));
BeginUndoBlock;
********

Discussion


Log in to post a comment.