mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-08 21:19:17 +02:00
added clipboard support for TCustomEdit from Colin
git-svn-id: trunk@4753 -
This commit is contained in:
parent
1e4cf2c054
commit
65e03eb325
@ -86,8 +86,8 @@ var
|
||||
OldText, NewText: string;
|
||||
begin
|
||||
OldText:=Text;
|
||||
NewText:=LeftStr(OldText,SelStart-1)+Val
|
||||
+RightStr(OldText,length(OldText)-SelStart-SelLength+1);
|
||||
NewText:=LeftStr(OldText,SelStart)+Val
|
||||
+RightStr(OldText,length(OldText)-SelStart-SelLength);
|
||||
Text:=NewText;
|
||||
end;
|
||||
|
||||
@ -162,6 +162,51 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCustomEdit.ClearSelection
|
||||
Params: -
|
||||
Returns: nothing
|
||||
|
||||
Delete selected text.
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomEdit.ClearSelection;
|
||||
begin
|
||||
if SelLength > 0 then
|
||||
SelText := '';
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCustomEdit.ClearSelection
|
||||
Params: -
|
||||
Returns: nothing
|
||||
|
||||
Copy selected text to clipboard.
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomEdit.CopyToClipboard;
|
||||
begin
|
||||
if (EchoMode <> emNormal) and (SelLength > 0) then
|
||||
Clipboard.AsText := SelText;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCustomEdit.ClearSelection
|
||||
Params: -
|
||||
Returns: nothing
|
||||
|
||||
Move selected text to clipboard.
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomEdit.CutToClipboard;
|
||||
begin
|
||||
CopyToClipboard;
|
||||
ClearSelection;
|
||||
end;
|
||||
|
||||
procedure TCustomEdit.PasteFromClipboard;
|
||||
begin
|
||||
if Clipboard.HasFormat(CF_TEXT) then
|
||||
SelText := Clipboard.AsText;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCustomEdit.GetModified
|
||||
Params: none
|
||||
@ -270,7 +315,7 @@ Procedure TCustomEdit.CMTextChanged(var Message : TLMessage);
|
||||
var
|
||||
Temp : String;
|
||||
Begin
|
||||
//check to see if the charcase should effect the text.
|
||||
//check to see if the charcase should affect the text.
|
||||
if FCharCase = ecUppercase then
|
||||
Begin
|
||||
Temp := Uppercase(text);
|
||||
@ -310,6 +355,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.19 2003/11/01 18:58:15 mattias
|
||||
added clipboard support for TCustomEdit from Colin
|
||||
|
||||
Revision 1.18 2003/09/20 13:27:49 mattias
|
||||
varois improvements for ParentColor from Micha
|
||||
|
||||
|
@ -72,6 +72,14 @@ begin
|
||||
Lines.Clear;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TCustomMemo.Clear;
|
||||
------------------------------------------------------------------------------}
|
||||
function TCustomMemo.GetTextLen: Integer;
|
||||
begin
|
||||
Result := Length(Text);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TCustomMemo.SetHorzScrollBar(const AValue: TMemoScrollBar);
|
||||
------------------------------------------------------------------------------}
|
||||
@ -159,6 +167,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.17 2003/11/01 18:58:15 mattias
|
||||
added clipboard support for TCustomEdit from Colin
|
||||
|
||||
Revision 1.16 2003/06/13 11:58:46 mattias
|
||||
fixed readonly of properties
|
||||
|
||||
|
@ -3544,55 +3544,54 @@ begin
|
||||
if ScrolledLeft>GetMaxScrollLeft then ScrolledLeft:=GetMaxScrollLeft;
|
||||
if ScrolledTop>GetMaxScrollTop then ScrolledTop:=GetMaxScrollTop;
|
||||
Exclude(FStates,tvsScrollbarChanged);
|
||||
if fScrollBars <> ssNone then begin
|
||||
if fScrollBars in [ssBoth, ssHorizontal] then begin
|
||||
// horizontal scrollbar
|
||||
ScrollInfo.cbSize := SizeOf(ScrollInfo);
|
||||
ScrollInfo.fMask := SIF_ALL or SIF_DISABLENOSCROLL;
|
||||
ScrollInfo.nTrackPos := 0;
|
||||
ScrollInfo.nMin := 0;
|
||||
ScrollInfo.nPage := Max(1,(ClientWidth-ScrollBarWidth)-2*BorderWidth);
|
||||
ScrollInfo.nMax := Max(1,GetMaxScrollLeft+integer(ScrollInfo.nPage));
|
||||
ScrollInfo.nPos := Max(FScrolledLeft,0);
|
||||
if not CompareMem(@ScrollInfo,@FLastHorzScrollInfo,SizeOf(TScrollInfo))
|
||||
then begin
|
||||
FLastHorzScrollInfo:=ScrollInfo;
|
||||
SetScrollInfo(Handle, SB_HORZ, ScrollInfo, True);
|
||||
ShowScrollBar(Handle,SB_HORZ,True);
|
||||
end;
|
||||
//writeln('>>>>>>>>>> [TCustomTreeView.UpdateScrollbars] nMin=',ScrollInfo.nMin,
|
||||
//' nMax=',ScrollInfo.nMax,' nPage=',ScrollInfo.nPage,
|
||||
//' nPos=',ScrollInfo.nPos,' GetMaxScrollLeft=',GetMaxScrollLeft,
|
||||
//' ClientW=',ClientWidth,
|
||||
//' MaxRight=',FMaxRight
|
||||
//);
|
||||
end else begin
|
||||
FLastHorzScrollInfo.cbSize:=0;
|
||||
ShowScrollBar(Handle,SB_HORZ,false);
|
||||
if fScrollBars in [ssBoth, ssHorizontal] then begin
|
||||
// horizontal scrollbar
|
||||
ScrollInfo.cbSize := SizeOf(ScrollInfo);
|
||||
ScrollInfo.fMask := SIF_ALL or SIF_DISABLENOSCROLL;
|
||||
ScrollInfo.nTrackPos := 0;
|
||||
ScrollInfo.nMin := 0;
|
||||
ScrollInfo.nPage := Max(1,(ClientWidth-ScrollBarWidth)-2*BorderWidth);
|
||||
ScrollInfo.nMax := Max(1,GetMaxScrollLeft+integer(ScrollInfo.nPage));
|
||||
ScrollInfo.nPos := Max(FScrolledLeft,0);
|
||||
if not CompareMem(@ScrollInfo,@FLastHorzScrollInfo,SizeOf(TScrollInfo))
|
||||
then begin
|
||||
FLastHorzScrollInfo:=ScrollInfo;
|
||||
SetScrollInfo(Handle, SB_HORZ, ScrollInfo, True);
|
||||
ShowScrollBar(Handle,SB_HORZ,True);
|
||||
end;
|
||||
if fScrollBars in [ssBoth, ssVertical] then begin
|
||||
// vertical scrollbar
|
||||
ScrollInfo.cbSize := SizeOf(ScrollInfo);
|
||||
ScrollInfo.fMask := SIF_ALL or SIF_DISABLENOSCROLL;
|
||||
ScrollInfo.nTrackPos := 0;
|
||||
ScrollInfo.nMin := 0;
|
||||
ScrollInfo.nPage := Max(1,(ClientHeight-ScrollBarWidth)-FDefItemHeight);
|
||||
ScrollInfo.nMax := Max(1,GetMaxScrollTop+integer(ScrollInfo.nPage));
|
||||
ScrollInfo.nTrackPos := 0;
|
||||
ScrollInfo.nPos := Max(0,FScrolledTop);
|
||||
if not CompareMem(@ScrollInfo,@FLastVertScrollInfo,SizeOf(TScrollInfo))
|
||||
then begin
|
||||
FLastVertScrollInfo:=ScrollInfo;
|
||||
SetScrollInfo(Handle, SB_VERT, ScrollInfo, True);
|
||||
ShowScrollBar(Handle,SB_VERT,True);
|
||||
end;
|
||||
//writeln('>>>>>>>>>> [TCustomTreeView.UpdateScrollbars] nMin=',ScrollInfo.nMin,
|
||||
//' nMax=',ScrollInfo.nMax,' nPage=',ScrollInfo.nPage,
|
||||
//' nPos=',ScrollInfo.nPos,' GetMaxScrollTop=',GetMaxScrollTop);
|
||||
end else begin
|
||||
FLastVertScrollInfo.cbSize:=0;
|
||||
ShowScrollBar(Handle,SB_VERT,false);
|
||||
//writeln('>>>>>>>>>> [TCustomTreeView.UpdateScrollbars] nMin=',ScrollInfo.nMin,
|
||||
//' nMax=',ScrollInfo.nMax,' nPage=',ScrollInfo.nPage,
|
||||
//' nPos=',ScrollInfo.nPos,' GetMaxScrollLeft=',GetMaxScrollLeft,
|
||||
//' ClientW=',ClientWidth,
|
||||
//' MaxRight=',FMaxRight
|
||||
//);
|
||||
end else begin
|
||||
FLastHorzScrollInfo.cbSize:=0;
|
||||
ShowScrollBar(Handle,SB_HORZ,false);
|
||||
end;
|
||||
if fScrollBars in [ssBoth, ssVertical] then begin
|
||||
// vertical scrollbar
|
||||
ScrollInfo.cbSize := SizeOf(ScrollInfo);
|
||||
ScrollInfo.fMask := SIF_ALL or SIF_DISABLENOSCROLL;
|
||||
ScrollInfo.nTrackPos := 0;
|
||||
ScrollInfo.nMin := 0;
|
||||
ScrollInfo.nPage := Max(1,(ClientHeight-ScrollBarWidth)-FDefItemHeight);
|
||||
ScrollInfo.nMax := Max(1,GetMaxScrollTop+integer(ScrollInfo.nPage));
|
||||
ScrollInfo.nTrackPos := 0;
|
||||
ScrollInfo.nPos := Max(0,FScrolledTop);
|
||||
if not CompareMem(@ScrollInfo,@FLastVertScrollInfo,SizeOf(TScrollInfo))
|
||||
then begin
|
||||
FLastVertScrollInfo:=ScrollInfo;
|
||||
SetScrollInfo(Handle, SB_VERT, ScrollInfo, True);
|
||||
ShowScrollBar(Handle,SB_VERT,True);
|
||||
end;
|
||||
//writeln('>>>>>>>>>> [TCustomTreeView.UpdateScrollbars] Vert On nMin=',ScrollInfo.nMin,
|
||||
//' nMax=',ScrollInfo.nMax,' nPage=',ScrollInfo.nPage,
|
||||
//' nPos=',ScrollInfo.nPos,' GetMaxScrollTop=',GetMaxScrollTop);
|
||||
end else begin
|
||||
//writeln('>>>>>>>>>> [TCustomTreeView.UpdateScrollbars] Vert Off ');
|
||||
FLastVertScrollInfo.cbSize:=0;
|
||||
ShowScrollBar(Handle,SB_VERT,false);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
@ -32,8 +32,7 @@ interface
|
||||
uses
|
||||
VCLGlobals, Classes, SysUtils, LCLStrConsts, LCLType, LCLProc,
|
||||
Graphics, GraphType, LMessages, Controls, ExtendedStrings, LCLIntf,
|
||||
GraphMath, Forms;
|
||||
|
||||
ClipBrd, GraphMath, Forms;
|
||||
|
||||
type
|
||||
|
||||
@ -477,6 +476,10 @@ type
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure SelectAll;
|
||||
procedure ClearSelection; virtual;
|
||||
procedure CopyToClipboard; virtual;
|
||||
procedure CutToClipboard; virtual;
|
||||
procedure PasteFromClipboard; virtual;
|
||||
property CharCase : TEditCharCase read FCharCase write SetCharCase default ecNormal;
|
||||
property EchoMode : TEchoMode read FEchoMode write SetEchoMode default emNormal;
|
||||
property MaxLength : Integer read FMaxLength write SetMaxLength default -1;
|
||||
@ -535,6 +538,7 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure Append(const Value : String);
|
||||
procedure Clear;
|
||||
function GetTextLen: Integer;
|
||||
public
|
||||
property Lines: TStrings read FLines write SetLines;
|
||||
property ScrollBars: TScrollStyle read FScrollBars write SetScrollBars;
|
||||
@ -981,7 +985,6 @@ procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
type
|
||||
TMemoStrings = class(TStrings)
|
||||
private
|
||||
@ -1002,25 +1005,6 @@ begin
|
||||
TRadioButton,TListBox,TComboBox,TScrollBar,TGroupBox,TStaticText]);
|
||||
end;
|
||||
|
||||
{ TComboBoxStrings = class(TStrings)
|
||||
private
|
||||
ComboBox: TCustomComboBox;
|
||||
protected
|
||||
function Get(Index: Integer): string; override;
|
||||
function GetCount: Integer; override;
|
||||
function GetObject(Index: Integer): TObject; override;
|
||||
procedure PutObject(Index: Integer; AObject: TObject); override;
|
||||
procedure SetUpdateState(Updating: Boolean); override;
|
||||
public
|
||||
function Add(const S: string): Integer; override;
|
||||
procedure Clear; override;
|
||||
procedure Delete(Index: Integer); override;
|
||||
function IndexOf(const S: string): Integer; override;
|
||||
procedure Insert(Index: Integer; const S: string); override;
|
||||
end;
|
||||
}
|
||||
|
||||
|
||||
|
||||
{$IFDef NewCheckBox}
|
||||
Procedure TCheckbox.DoAutoSize;
|
||||
@ -1476,6 +1460,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.109 2003/11/01 18:58:15 mattias
|
||||
added clipboard support for TCustomEdit from Colin
|
||||
|
||||
Revision 1.108 2003/10/16 23:54:27 marc
|
||||
Implemented new gtk keyevent handling
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user