disabled inline, added TTISpinEdit, added history skill to TTIComboBox

git-svn-id: trunk@8018 -
This commit is contained in:
mattias 2005-10-31 19:17:48 +00:00
parent e90d89dda6
commit 72e97eced6
8 changed files with 270 additions and 41 deletions

View File

@ -219,7 +219,7 @@ type
function StringIsKeyWord(const Word: string): boolean;
// cursor moving
procedure MoveCursorToNodeStart(ANode: TCodeTreeNode); inline;
procedure MoveCursorToNodeStart(ANode: TCodeTreeNode); {$IFDEF UseInline}inline;{$ENDIF}
procedure MoveCursorToCleanPos(ACleanPos: integer);
procedure MoveCursorToCleanPos(ACleanPos: PChar);
procedure MoveCursorToAtomPos(const AnAtomPos: TAtomPosition);
@ -242,14 +242,14 @@ type
// read atoms
function AtomIs(const AnAtom: shortstring): boolean;
function UpAtomIs(const AnAtom: shortstring): boolean;
function ReadNextAtomIs(const AnAtom: shortstring): boolean; inline;
function ReadNextUpAtomIs(const AnAtom: shortstring): boolean; inline;
function ReadNextAtomIsChar(const c: char): boolean; inline;
function AtomIsChar(const c: char): boolean; inline;
function ReadNextAtomIs(const AnAtom: shortstring): boolean; {$IFDEF UseInline}inline;{$ENDIF}
function ReadNextUpAtomIs(const AnAtom: shortstring): boolean; {$IFDEF UseInline}inline;{$ENDIF}
function ReadNextAtomIsChar(const c: char): boolean; {$IFDEF UseInline}inline;{$ENDIF}
function AtomIsChar(const c: char): boolean; {$IFDEF UseInline}inline;{$ENDIF}
function AtomIsKeyWord: boolean;
function AtomIsNumber: boolean; inline;
function AtomIsNumber: boolean; {$IFDEF UseInline}inline;{$ENDIF}
function AtomIsRealNumber: boolean;
function AtomIsStringConstant: boolean; inline;
function AtomIsStringConstant: boolean; {$IFDEF UseInline}inline;{$ENDIF}
function AtomIsCharConstant: boolean;
function AtomIsIdentifier(ExceptionOnNotFound: boolean): boolean;
function LastAtomIs(BackIndex: integer;
@ -276,7 +276,7 @@ type
function ExtractIdentifier(CleanStartPos: integer): string;
procedure CreateChildNode;
procedure EndChildNode; inline;
procedure EndChildNode; {$IFDEF UseInline}inline;{$ENDIF}
function DoAtom: boolean; virtual;
// write lock

View File

@ -207,7 +207,7 @@ type
function ReturnFromIncludeFileAndIsEnd: boolean;
function ReadIdentifier: string;
function ReadUpperIdentifier: string;
procedure SkipSpace; inline;
procedure SkipSpace; {$IFDEF UseInline}inline;{$ENDIF}
procedure SkipComment;
procedure SkipDelphiComment;
procedure SkipOldTPComment;
@ -219,9 +219,9 @@ type
procedure UpdateCleanedSource(SourcePos: integer);
function ReturnFromIncludeFile: boolean;
procedure InitKeyWordList;
function DoEndToken: boolean; inline;
function DoDefaultIdentToken: boolean; inline;
function DoEndOfInterfaceToken: boolean; inline;
function DoEndToken: boolean; {$IFDEF UseInline}inline;{$ENDIF}
function DoDefaultIdentToken: boolean; {$IFDEF UseInline}inline;{$ENDIF}
function DoEndOfInterfaceToken: boolean; {$IFDEF UseInline}inline;{$ENDIF}
private
// directives
FDirectiveName: shortstring;

View File

@ -429,12 +429,15 @@ Type
end;
{ TICustomComboBox }
{ TTICustomComboBox }
TTICustomComboBox = class(TCustomComboBox)
private
FHistoryCaseSensitive: boolean;
FLink: TPropertyLink;
FMaxHistoryCount: integer;
procedure SetLink(const AValue: TPropertyLink);
procedure SetMaxHistoryCount(const AValue: integer);
protected
procedure LinkLoadFromProperty(Sender: TObject); virtual;
procedure LinkSaveToProperty(Sender: TObject); virtual;
@ -448,6 +451,10 @@ Type
procedure Loaded; override;
procedure EditingDone; override;
property Link: TPropertyLink read FLink write SetLink;
property MaxHistoryCount: integer read FMaxHistoryCount
write SetMaxHistoryCount;// set this to a value > 0 to enable history
property HistoryCaseSensitive: boolean read FHistoryCaseSensitive
write FHistoryCaseSensitive;
end;
@ -466,7 +473,9 @@ Type
property DropDownCount;
property Enabled;
property Font;
property HistoryCaseSensitive;
property Link;
property MaxHistoryCount;
property MaxLength;
property OnChange;
property OnChangeBounds;
@ -1166,6 +1175,64 @@ Type
end;
{ TTICustomSpinEdit }
TTICustomSpinEdit = class(TCustomSpinEdit)
private
FLink: TPropertyLink;
FUseRTTIMinMax: boolean;
procedure SetLink(const AValue: TPropertyLink);
procedure SetUseRTTIMinMax(const AValue: boolean);
protected
procedure LinkLoadFromProperty(Sender: TObject); virtual;
procedure LinkSaveToProperty(Sender: TObject); virtual;
procedure LinkEditorChanged(Sender: TObject); virtual;
procedure GetRTTIMinMax; virtual;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure Loaded; override;
procedure EditingDone; override;
property Link: TPropertyLink read FLink write SetLink;
property UseRTTIMinMax: boolean read FUseRTTIMinMax write SetUseRTTIMinMax default true;
end;
{ TTISpinEdit }
TTISpinEdit = class(TTICustomSpinEdit)
published
property Align;
property Anchors;
property BorderSpacing;
property ClimbRate;
property Constraints;
property Enabled;
property Link;
property MaxValue;
property MinValue;
property OnChange;
property OnChangeBounds;
property OnClick;
property OnEnter;
property OnExit;
Property OnKeyDown;
property OnKeyPress;
Property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabStop;
property TabOrder;
property UseRTTIMinMax;
property Visible;
end;
{ TTICustomTrackBar }
TTICustomTrackBar = class(TCustomTrackBar)
@ -1395,8 +1462,8 @@ procedure Register;
begin
RegisterComponents('RTTI',[TTIEdit,TTIComboBox,TTIButton,TTICheckBox,
TTILabel,TTIGroupBox,TTIRadioGroup,TTICheckGroup,TTICheckListBox,
TTIListBox,TTIMemo,TTICalendar,TTIImage,TTIFloatSpinEdit,TTITrackBar,
TTIProgressBar,TTIMaskEdit,TTIColorButton,TMultiPropertyLink]);
TTIListBox,TTIMemo,TTICalendar,TTIImage,TTIFloatSpinEdit,TTISpinEdit,
TTITrackBar,TTIProgressBar,TTIMaskEdit,TTIColorButton,TMultiPropertyLink]);
end;
{ TAliasStrings }
@ -2284,6 +2351,12 @@ begin
FLink.Assign(AValue);
end;
procedure TTICustomComboBox.SetMaxHistoryCount(const AValue: integer);
begin
if FMaxHistoryCount=AValue then exit;
FMaxHistoryCount:=AValue;
end;
procedure TTICustomComboBox.LinkLoadFromProperty(Sender: TObject);
begin
if Sender=nil then ;
@ -2294,11 +2367,25 @@ begin
end;
procedure TTICustomComboBox.LinkSaveToProperty(Sender: TObject);
var
i: Integer;
begin
if Sender=nil then ;
//debugln('TTICustomComboBox.LinkSaveToProperty ',dbgsName(Self),' FLink.GetAsText=',FLink.GetAsText,' Text=',Text);
if (FLink.Editor=nil) then exit;
FLink.SetAsText(Text);
// update history
if (MaxHistoryCount>0) and ((Items.Count=0) or (Items[0]<>Text)) then begin
Items.BeginUpdate;
Items.Insert(0,Text);
for i:=Items.Count-1 downto 1 do
if (i>=MaxHistoryCount) or (Items[i]=Text)
or ((not HistoryCaseSensitive) and (AnsiCompareText(Items[i],Text)=0))
then
Items.Delete(i);
Items.EndUpdate;
end;
end;
constructor TTICustomComboBox.Create(TheOwner: TComponent);
@ -2909,6 +2996,134 @@ begin
FLink.EditingDone;
end;
{ TTICustomSpinEdit }
procedure TTICustomSpinEdit.SetLink(const AValue: TPropertyLink);
begin
if FLink=AValue then exit;
FLink.Assign(AValue);
end;
procedure TTICustomSpinEdit.SetUseRTTIMinMax(const AValue: boolean);
begin
if FUseRTTIMinMax=AValue then exit;
FUseRTTIMinMax:=AValue;
if UseRTTIMinMax then GetRTTIMinMax;
end;
procedure TTICustomSpinEdit.LinkLoadFromProperty(Sender: TObject);
begin
if Sender=nil then ;
if (FLink.Editor=nil) then exit;
try
Value:=StrToInt(FLink.GetAsText);
except
end;
end;
procedure TTICustomSpinEdit.LinkSaveToProperty(Sender: TObject);
begin
if Sender=nil then ;
if FLink.Editor=nil then exit;
FLink.SetAsText(IntToStr(Value));
end;
procedure TTICustomSpinEdit.LinkEditorChanged(Sender: TObject);
var
TypeData: PTypeData;
PropKind: TTypeKind;
OldLinkSaveEnabled: Boolean;
f: integer;
begin
if Sender=nil then ;
if FLink.Editor=nil then exit;
OldLinkSaveEnabled:=FLink.SaveEnabled;
FLink.SaveEnabled:=false;
try
PropKind:=FLink.Editor.GetPropType^.Kind;
case PropKind of
tkInteger,tkChar,tkEnumeration,tkWChar:
begin
TypeData:=GetTypeData(FLink.Editor.GetPropType);
MinValue:=TypeData^.MinValue;
MaxValue:=TypeData^.MaxValue;
ClimbRate:=1;
DecimalPlaces:=0;
end;
tkInt64:
begin
TypeData:=GetTypeData(FLink.Editor.GetPropType);
MinValue:=TypeData^.MinInt64Value;
MaxValue:=TypeData^.MaxInt64Value;
ClimbRate:=1;
DecimalPlaces:=0;
end;
tkQWord:
begin
TypeData:=GetTypeData(FLink.Editor.GetPropType);
MinValue:=TypeData^.MinQWordValue;
MaxValue:=TypeData^.MaxQWordValue;
ClimbRate:=1;
DecimalPlaces:=0;
end;
else
begin
try
f:=StrToInt(FLink.GetAsText);
except
end;
if f<MinValue then MinValue:=f;
if f>MaxValue then MaxValue:=f;
end;
end;
finally
FLink.SaveEnabled:=OldLinkSaveEnabled;
end;
end;
procedure TTICustomSpinEdit.GetRTTIMinMax;
begin
if UseRTTIMinMax then GetRTTIMinMax;
end;
constructor TTICustomSpinEdit.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
FUseRTTIMinMax:=true;
FLink:=TPropertyLink.Create(Self);
FLink.Filter:=[{tkUnknown,}tkInteger,{tkChar,tkEnumeration,}
tkFloat,{tkSet,tkMethod,}tkSString,tkLString,tkAString,
tkWString{,tkVariant,tkArray,tkRecord,tkInterface,}
{tkClass,tkObject,tkWChar,tkBool},tkInt64,
tkQWord{,tkDynArray,tkInterfaceRaw}];
FLink.OnLoadFromProperty:=@LinkLoadFromProperty;
FLink.OnSaveToProperty:=@LinkSaveToProperty;
FLink.OnEditorChanged:=@LinkEditorChanged;
end;
destructor TTICustomSpinEdit.Destroy;
begin
FreeThenNil(FLink);
inherited Destroy;
end;
procedure TTICustomSpinEdit.Loaded;
begin
inherited Loaded;
FLink.LoadFromProperty;
end;
procedure TTICustomSpinEdit.EditingDone;
begin
inherited EditingDone;
FLink.EditingDone;
end;
{ TTICustomImage }
function TTICustomImage.LinkTestEditor(const ATestEditor: TPropertyEditor

View File

@ -510,6 +510,8 @@ begin
FTIObjectCount:=TCollection(FListObject).Count
else if FListObject is TList then
FTIObjectCount:=TList(FListObject).Count
else if FListObject is TFPList then
FTIObjectCount:=TFPList(FListObject).Count
else begin
// ListObject is not valid
end;
@ -1033,6 +1035,7 @@ var
List: TList;
AnObject: TObject;
ACollection: TCollection;
FPList: TFPList;
begin
Result:=nil;
if (Index<0) or (Index>=TIObjectCount) then exit;
@ -1067,6 +1070,18 @@ begin
AnObject:=TObject(List[Index]);
Result:=AnObject as TPersistent;
end;
end else if ListObject is TFPList then begin
FPList:=TFPList(ListObject);
if csDesigning in ComponentState then begin
try
AnObject:=TObject(FPList[Index]);
Result:=AnObject as TPersistent;
except
end;
end else begin
AnObject:=TObject(FPList[Index]);
Result:=AnObject as TPersistent;
end;
end;
end;

View File

@ -10171,6 +10171,7 @@ begin
end;
dec(y);
end;
Result:=1;
end;
end;
{$ENDIF}

View File

@ -222,8 +222,8 @@ begin
end else begin
{$IFDEF SYN_LAZARUS}
i:=-1;
if Assigned(fOnTokenNotFound) then
fOnTokenNotFound(Self,'',AEditor,i);
if Assigned(OnTokenNotFound) then
OnTokenNotFound(Self,'',AEditor,i);
if i>=0 then
ExecuteCompletion(FCompletions[i], AEditor);
{$ENDIF}
@ -245,8 +245,8 @@ begin
ParseCompletionList;
Len := Length(AToken);
{$IFDEF SYN_LAZARUS}
if (Len=0) and Assigned(fOnTokenNotFound) then
fOnTokenNotFound(Self,AToken,AEditor,i);
if (Len=0) and Assigned(OnTokenNotFound) then
OnTokenNotFound(Self,AToken,AEditor,i);
{$ENDIF}
if (Len > 0) and (AEditor <> nil) and not AEditor.ReadOnly
and (fCompletions.Count > 0)

View File

@ -32,9 +32,8 @@ interface
uses
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, SynEdit, SynHighlighterPas, ExtCtrls,
SynEditAutoComplete, IDECommands, SrcEditorIntf,
InputHistory, LazarusIDEStrConsts, EditorOptions;
StdCtrls, Buttons, SynEdit, SynHighlighterPas, ExtCtrls, SynEditAutoComplete,
IDECommands, SrcEditorIntf, InputHistory, LazarusIDEStrConsts, EditorOptions;
type
@ -73,26 +72,26 @@ type
{ TCodeTemplateEditForm }
TCodeTemplateEditForm = class(TForm)
TokenLabel:TLabel;
TokenEdit:TEdit;
CommentLabel:TLabel;
CommentEdit:TEdit;
OkButton:TButton;
CancelButton:TButton;
TokenLabel: TLabel;
TokenEdit: TEdit;
CommentLabel: TLabel;
CommentEdit: TEdit;
OkButton: TButton;
CancelButton: TButton;
procedure CodeTemplateEditFormResize(Sender: TObject);
procedure OkButtonClick(Sender:TObject);
procedure OkButtonClick(Sender: TObject);
public
constructor Create(AOwner:TComponent); override;
SynAutoComplete:TSynEditAutoComplete;
TemplateIndex:integer;
constructor Create(TheOwner: TComponent); override;
SynAutoComplete: TSynEditAutoComplete;
TemplateIndex: integer;
end;
function ShowCodeTemplateDialog: TModalResult;
function AddCodeTemplate(ASynAutoComplete:TSynEditAutoComplete;
var Token,Comment:ansistring):TModalResult;
function EditCodeTemplate(ASynAutoComplete:TSynEditAutoComplete;
Index:integer):TModalResult;
function AddCodeTemplate(ASynAutoComplete: TSynEditAutoComplete;
var Token, Comment: string): TModalResult;
function EditCodeTemplate(ASynAutoComplete: TSynEditAutoComplete;
Index: integer): TModalResult;
implementation
@ -159,9 +158,9 @@ end;
{ TCodeTemplateEditForm }
constructor TCodeTemplateEditForm.Create(AOwner:TComponent);
constructor TCodeTemplateEditForm.Create(TheOwner:TComponent);
begin
inherited Create(AOwner);
inherited Create(TheOwner);
if LazarusResources.Find(ClassName)=nil then begin
Width:=300;
Height:=150;

View File

@ -155,8 +155,7 @@ type
Function GetModified: Boolean;
procedure SetModified(NewValue:boolean);
Function GetInsertMode: Boolean;
procedure SetCodeTemplates(
NewCodeTemplates: TSynEditAutoComplete);
procedure SetCodeTemplates(NewCodeTemplates: TSynEditAutoComplete);
procedure SetPopupMenu(NewPopupMenu: TPopupMenu);
function GotoLine(Value: Integer): Integer;
@ -648,7 +647,7 @@ type
Property CodeTemplateModul: TSynEditAutoComplete
read FCodeTemplateModul write FCodeTemplateModul;
procedure OnCodeTemplateTokenNotFound(Sender: TObject; AToken: string;
AnEditor: TCustomSynEdit; var Index:integer);
AnEditor: TCustomSynEdit; var Index:integer);
procedure OnWordCompletionGetSource(
var Source: TStrings; SourceIndex: integer);
procedure OnIdentCompletionTimer(Sender: TObject);