mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-31 00:22:51 +02:00
started OI favourites
git-svn-id: trunk@7033 -
This commit is contained in:
parent
ee3c00fb35
commit
89a38f7ff1
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -421,7 +421,6 @@ designer/changeclassdialog.lfm svneol=native#text/plain
|
||||
designer/changeclassdialog.lrs svneol=native#text/pascal
|
||||
designer/changeclassdialog.pas svneol=native#text/pascal
|
||||
designer/controlselection.pp svneol=native#text/pascal
|
||||
designer/customeditor.pp svneol=native#text/pascal
|
||||
designer/designer.pp svneol=native#text/pascal
|
||||
designer/designermenu.pp svneol=native#text/pascal
|
||||
designer/designerprocs.pas svneol=native#text/pascal
|
||||
@ -431,6 +430,7 @@ designer/jitforms.pp svneol=native#text/pascal
|
||||
designer/menueditorform.pas svneol=native#text/pascal
|
||||
designer/menupropedit.pp svneol=native#text/pascal
|
||||
designer/noncontrolforms.pas svneol=native#text/pascal
|
||||
designer/objinspext.pas svneol=native#text/pascal
|
||||
designer/scalecompsdlg.pp svneol=native#text/pascal
|
||||
designer/sizecompsdlg.pp svneol=native#text/pascal
|
||||
designer/taborderdlg.lfm svneol=native#text/plain
|
||||
|
@ -65,6 +65,8 @@ type
|
||||
const PersistentClassName, AncestorClassName, Identifier: string;
|
||||
var IsDefined: boolean) of object;
|
||||
|
||||
{ TCodeToolManager }
|
||||
|
||||
TCodeToolManager = class
|
||||
private
|
||||
FAbortable: boolean;
|
||||
@ -304,6 +306,7 @@ type
|
||||
function GatherIdentifiers(Code: TCodeBuffer; X,Y: integer): boolean;
|
||||
function GetIdentifierAt(Code: TCodeBuffer; X,Y: integer;
|
||||
var Identifier: string): boolean;
|
||||
function IdentItemCheckHasChilds(IdentItem: TIdentifierListItem): boolean;
|
||||
|
||||
// rename identifier
|
||||
function FindReferences(IdentifierCode: TCodeBuffer;
|
||||
@ -1461,6 +1464,21 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCodeToolManager.IdentItemCheckHasChilds(IdentItem: TIdentifierListItem
|
||||
): boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
{$IFDEF CTDEBUG}
|
||||
DebugLn('TCodeToolManager.IdentItemCheckHasChilds A ');
|
||||
{$ENDIF}
|
||||
try
|
||||
IdentItem.CheckHasChilds;
|
||||
Result:=true;
|
||||
except
|
||||
on e: Exception do HandleException(e);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCodeToolManager.FindReferences(IdentifierCode: TCodeBuffer;
|
||||
X, Y: integer; TargetCode: TCodeBuffer; SkipComments: boolean;
|
||||
var ListOfPCodeXYPosition: TList): boolean;
|
||||
|
@ -1078,6 +1078,7 @@ var
|
||||
Params: TFindDeclarationParams;
|
||||
begin
|
||||
if (iliBaseExprTypeValid in Flags) then exit;
|
||||
BaseExprType:=CleanExpressionType;
|
||||
BaseExprType.Desc:=xtNone;
|
||||
if (Node<>nil) and (Tool<>nil) then begin
|
||||
Tool.ActivateGlobalWriteLock;
|
||||
|
@ -2018,7 +2018,7 @@ begin
|
||||
// don't fire the event if key is to be ignored
|
||||
if not (sfIgnoreNextChar in fStateFlags) then begin
|
||||
{$IFDEF VerboseKeyboard}
|
||||
DebugLn('TCustomSynEdit.UTF8KeyPress ',DbgSName(Self),' Key="',DbgStr(Key),'" UseUTF8=',dbgs(UseUTF8));
|
||||
DebugLn('TCustomSynEdit.KeyPress ',DbgSName(Self),' Key="',DbgStr(Key),'" UseUTF8=',dbgs(UseUTF8));
|
||||
{$ENDIF}
|
||||
if Assigned(OnKeyPress) then OnKeyPress(Self, Key);
|
||||
CommandProcessor(ecChar, Key, nil);
|
||||
|
@ -1,64 +0,0 @@
|
||||
{
|
||||
/***************************************************************************
|
||||
CustomEditor.pp
|
||||
-------------------
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* This source is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This code is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* General Public License for more details. *
|
||||
* *
|
||||
* A copy of the GNU General Public License is available on the World *
|
||||
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
||||
* obtain it by writing to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
* *
|
||||
***************************************************************************
|
||||
}
|
||||
unit CustomEditor;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
classes,AbstractEditor, FileSystem;
|
||||
|
||||
type
|
||||
|
||||
TCustomEditor = class(TAbstractEditor)
|
||||
private
|
||||
FSource : TStrings; //Holds the source retrieved from TFileSystem
|
||||
Function GetSource: TStrings; //Returns the source from TFileSystem
|
||||
Procedure SetSource(value : TStrings); //Set's the source in the TFileSystem
|
||||
public
|
||||
constructor Create;
|
||||
destructor destroy;
|
||||
Function Filename : String; override;
|
||||
property Source: TStrings read GetSource write SetSource; //Holds the source retrieved from TFileSystem
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
constructor TCustomEditor.Create;
|
||||
Begin
|
||||
//Create the TFileSystem
|
||||
end;
|
||||
|
||||
Function TCustomEditor.GetSource : TStrings;
|
||||
Begin
|
||||
Result := nil;
|
||||
End;
|
||||
|
||||
|
||||
end.
|
244
designer/objinspext.pas
Normal file
244
designer/objinspext.pas
Normal file
@ -0,0 +1,244 @@
|
||||
{
|
||||
*****************************************************************************
|
||||
* *
|
||||
* See the file COPYING.modifiedLGPL, included in this distribution, *
|
||||
* for details about the copyright. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* *
|
||||
*****************************************************************************
|
||||
|
||||
Author: Mattias Gaertner
|
||||
|
||||
Abstract:
|
||||
Extension for the Object Inspector.
|
||||
- Favourites properties
|
||||
}
|
||||
unit ObjInspExt;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, ObjectInspector, Forms, Controls, Buttons, StdCtrls,
|
||||
ExtCtrls, Dialogs,
|
||||
ConfigStorage, LazarusIDEStrConsts;
|
||||
|
||||
type
|
||||
|
||||
{ TOIAddRemoveFavouriteDlg }
|
||||
|
||||
TOIAddRemoveFavouriteDlg = class(TForm)
|
||||
NoteLabel: TLabel;
|
||||
ClassCombobox: TComboBox;
|
||||
OkButton: TButton;
|
||||
CancelButton: TButton;
|
||||
procedure OkButtonClick(Sender: TObject);
|
||||
private
|
||||
FAddMode: Boolean;
|
||||
FObjectInspector: TObjectInspector;
|
||||
FPropertyName: string;
|
||||
procedure SetAddMode(const AValue: Boolean);
|
||||
procedure SetObjectInspector(const AValue: TObjectInspector);
|
||||
procedure UpdateLabel;
|
||||
procedure UpdateComboBox;
|
||||
procedure UpdateMode;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
public
|
||||
property ObjectInspector: TObjectInspector read FObjectInspector
|
||||
write SetObjectInspector;
|
||||
property PropertyName: string read FPropertyName;
|
||||
property AddMode: Boolean read FAddMode write SetAddMode;
|
||||
end;
|
||||
|
||||
function CreateDefaultOIFavouriteProperties: TOIFavouriteProperties;
|
||||
function ShowAddRemoveFavouriteDialog(ObjInspector: TObjectInspector;
|
||||
Add: Boolean): TModalResult;
|
||||
function LoadOIFavouriteProperties: TOIFavouriteProperties;
|
||||
procedure SaveOIFavouriteProperties(ObjInspector: TObjectInspector);
|
||||
|
||||
implementation
|
||||
|
||||
function CreateDefaultOIFavouriteProperties: TOIFavouriteProperties;
|
||||
|
||||
procedure Add(ABaseClass: TPersistentClass; const APropertyName: string);
|
||||
begin
|
||||
Result.Add(TOIFavouriteProperty.Create(ABaseClass,APropertyName,true));
|
||||
end;
|
||||
|
||||
begin
|
||||
Result:=TOIFavouriteProperties.Create;
|
||||
// TControl
|
||||
Add(TControl,'Name');
|
||||
Add(TControl,'Anchors');
|
||||
Add(TControl,'Caption');
|
||||
Add(TControl,'OnClick');
|
||||
// miscellaneous
|
||||
Add(TGroupBox,'Align');
|
||||
Add(TImage,'Align');
|
||||
end;
|
||||
|
||||
function ShowAddRemoveFavouriteDialog(ObjInspector: TObjectInspector;
|
||||
Add: Boolean): TModalResult;
|
||||
var
|
||||
OIAddRemoveFavouriteDlg: TOIAddRemoveFavouriteDlg;
|
||||
begin
|
||||
OIAddRemoveFavouriteDlg:=TOIAddRemoveFavouriteDlg.Create(nil);
|
||||
OIAddRemoveFavouriteDlg.ObjectInspector:=ObjInspector;
|
||||
OIAddRemoveFavouriteDlg.AddMode:=Add;
|
||||
Result:=OIAddRemoveFavouriteDlg.ShowModal;
|
||||
OIAddRemoveFavouriteDlg.Free;
|
||||
end;
|
||||
|
||||
function LoadOIFavouriteProperties: TOIFavouriteProperties;
|
||||
begin
|
||||
Result:=CreateDefaultOIFavouriteProperties;
|
||||
// TODO: load and merge
|
||||
end;
|
||||
|
||||
procedure SaveOIFavouriteProperties(ObjInspector: TObjectInspector);
|
||||
begin
|
||||
// TODO save only changes
|
||||
end;
|
||||
|
||||
{ TOIAddRemoveFavouriteDlg }
|
||||
|
||||
procedure TOIAddRemoveFavouriteDlg.OkButtonClick(Sender: TObject);
|
||||
var
|
||||
NewClassName: String;
|
||||
CurClass: TClass;
|
||||
NewFavourite: TOIFavouriteProperty;
|
||||
begin
|
||||
NewClassName:=ClassCombobox.Text;
|
||||
if (ObjectInspector<>nil) and (ObjectInspector.Selection<>nil)
|
||||
and (ObjectInspector.Selection.Count>0) then begin
|
||||
CurClass:=ObjectInspector.Selection[0].ClassType;
|
||||
while CurClass.InheritsFrom(TPersistent) do begin
|
||||
if CompareText(NewClassName,CurClass.ClassName)=0 then begin
|
||||
NewFavourite:=TOIFavouriteProperty.Create(TPersistentClass(CurClass),
|
||||
PropertyName,AddMode);
|
||||
ObjectInspector.Favourites.DeleteConstraints(NewFavourite);
|
||||
ObjectInspector.Favourites.Add(NewFavourite);
|
||||
ObjectInspector.FavouriteGrid.BuildPropertyList;
|
||||
ModalResult:=mrOk;
|
||||
exit;
|
||||
end;
|
||||
CurClass:=CurClass.ClassParent;
|
||||
end;
|
||||
end;
|
||||
MessageDlg('Class not found','Class "'+NewClassName+'" not found.',mtError,
|
||||
[mbOk],0);
|
||||
end;
|
||||
|
||||
procedure TOIAddRemoveFavouriteDlg.SetObjectInspector(const AValue: TObjectInspector
|
||||
);
|
||||
var
|
||||
CurRow: TOIPropertyGridRow;
|
||||
begin
|
||||
if FObjectInspector=AValue then exit;
|
||||
FObjectInspector:=AValue;
|
||||
CurRow:=ObjectInspector.GetActivePropertyRow;
|
||||
if (CurRow<>nil) and (CurRow.Editor<>nil) then
|
||||
FPropertyName:=CurRow.Editor.GetName;
|
||||
UpdateLabel;
|
||||
UpdateComboBox;
|
||||
end;
|
||||
|
||||
procedure TOIAddRemoveFavouriteDlg.SetAddMode(const AValue: Boolean);
|
||||
begin
|
||||
if FAddMode=AValue then exit;
|
||||
FAddMode:=AValue;
|
||||
UpdateMode;
|
||||
end;
|
||||
|
||||
procedure TOIAddRemoveFavouriteDlg.UpdateLabel;
|
||||
begin
|
||||
NoteLabel.Caption:='Choose a base class for the favourite '
|
||||
+'property "'+PropertyName+'".';
|
||||
end;
|
||||
|
||||
procedure TOIAddRemoveFavouriteDlg.UpdateComboBox;
|
||||
var
|
||||
CurClass: TClass;
|
||||
NewItems: TStringList;
|
||||
begin
|
||||
NewItems:=TStringList.Create;
|
||||
if (ObjectInspector<>nil) and (ObjectInspector.Selection<>nil)
|
||||
and (ObjectInspector.Selection.Count>0) then begin
|
||||
CurClass:=ObjectInspector.Selection[0].ClassType;
|
||||
// add only classes, that are TPersistent and have a registered class
|
||||
while CurClass.InheritsFrom(TPersistent) do begin
|
||||
NewItems.Add(CurClass.ClassName);
|
||||
CurClass:=CurClass.ClassParent;
|
||||
end;
|
||||
end;
|
||||
ClassCombobox.Items.Assign(NewItems);
|
||||
if ClassCombobox.Items.Count>0 then
|
||||
ClassCombobox.ItemIndex:=0;
|
||||
NewItems.Free;
|
||||
end;
|
||||
|
||||
procedure TOIAddRemoveFavouriteDlg.UpdateMode;
|
||||
begin
|
||||
if AddMode then begin
|
||||
Caption:='Add to favourite properties';
|
||||
OkButton.Caption:='Add';
|
||||
end else begin
|
||||
Caption:='Remove from favourite properties';
|
||||
OkButton.Caption:='Remove';
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TOIAddRemoveFavouriteDlg.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
|
||||
Name:='OIAddToFavouriteDlg';
|
||||
Width:=300;
|
||||
Height:=150;
|
||||
Position:=poDesktopCenter;
|
||||
|
||||
NoteLabel:=TLabel.Create(Self);
|
||||
with NoteLabel do begin
|
||||
Name:='NoteLabel';
|
||||
SetBounds(5,5,Self.ClientWidth-10,50);
|
||||
WordWrap:=true;
|
||||
Parent:=Self;
|
||||
end;
|
||||
|
||||
ClassCombobox:=TComboBox.Create(Self);
|
||||
with ClassCombobox do begin
|
||||
Name:='ClassCombobox';
|
||||
SetBounds(5,60,200,Height);
|
||||
Parent:=Self;
|
||||
end;
|
||||
|
||||
OkButton:=TButton.Create(Self);
|
||||
with OkButton do begin
|
||||
Name:='AddButton';
|
||||
SetBounds(5,100,80,25);
|
||||
Caption:='Add';
|
||||
Parent:=Self;
|
||||
OnClick:=@OkButtonClick;
|
||||
end;
|
||||
DefaultControl:=OkButton;
|
||||
|
||||
CancelButton:=TButton.Create(Self);
|
||||
with CancelButton do begin
|
||||
Name:='CancelButton';
|
||||
SetBounds(120,100,80,25);
|
||||
Caption:='Cancel';
|
||||
Parent:=Self;
|
||||
ModalResult:=mrCancel;
|
||||
end;
|
||||
CancelControl:=CancelButton;
|
||||
|
||||
UpdateMode;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
36
ide/main.pp
36
ide/main.pp
@ -84,7 +84,7 @@ uses
|
||||
// help manager
|
||||
HelpManager,
|
||||
// designer
|
||||
ComponentPalette, ComponentReg,
|
||||
ComponentPalette, ComponentReg, ObjInspExt,
|
||||
Designer, FormEditor, CustomFormEditor,
|
||||
ControlSelection, AnchorEditor,
|
||||
{$DEFINE UseNewMenuEditor}
|
||||
@ -333,11 +333,13 @@ type
|
||||
procedure OIOnShowOptions(Sender: TObject);
|
||||
procedure OIRemainingKeyUp(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
procedure OnPropHookGetMethods(TypeData:PTypeData; Proc:TGetStringProc);
|
||||
function OnPropHookMethodExists(const AMethodName:ShortString;
|
||||
procedure OIOnAddToFavourites(Sender: TObject);
|
||||
procedure OIOnRemoveFromFavourites(Sender: TObject);
|
||||
procedure OnPropHookGetMethods(TypeData: PTypeData; Proc:TGetStringProc);
|
||||
function OnPropHookMethodExists(const AMethodName: ShortString;
|
||||
TypeData: PTypeData;
|
||||
var MethodIsCompatible, MethodIsPublished,
|
||||
IdentIsMethod: boolean): boolean;
|
||||
IdentIsMethod: boolean): boolean;
|
||||
function OnPropHookCreateMethod(const AMethodName:ShortString;
|
||||
ATypeInfo:PTypeInfo): TMethod;
|
||||
procedure OnPropHookShowMethod(const AMethodName:ShortString);
|
||||
@ -451,7 +453,6 @@ type
|
||||
procedure Notification(AComponent: TComponent;
|
||||
Operation: TOperation); override;
|
||||
|
||||
procedure ToolButtonClick(Sender: TObject);
|
||||
procedure OnApplyWindowLayout(ALayout: TIDEWindowLayout);
|
||||
procedure AddRecentProjectFileToEnvironment(const AFilename: string);
|
||||
|
||||
@ -1123,6 +1124,16 @@ begin
|
||||
OnExecuteIDECommand(Sender,Key,Shift,caDesign);
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OIOnAddToFavourites(Sender: TObject);
|
||||
begin
|
||||
ShowAddRemoveFavouriteDialog(ObjectInspector1,true);
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OIOnRemoveFromFavourites(Sender: TObject);
|
||||
begin
|
||||
ShowAddRemoveFavouriteDialog(ObjectInspector1,false);
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OnPropHookGetMethods(TypeData:PTypeData;
|
||||
Proc:TGetStringProc);
|
||||
var ActiveSrcEdit: TSourceEditor;
|
||||
@ -1141,12 +1152,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TMainIDE.ToolButtonClick(Sender: TObject);
|
||||
Begin
|
||||
Assert(False, 'Trace:TOOL BUTTON CLICK!');
|
||||
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TMainIDE.MainIDEFormClose(Sender: TObject;
|
||||
var CloseAction: TCloseAction);
|
||||
@ -1333,6 +1338,12 @@ begin
|
||||
ObjectInspector1.OnSelectPersistentsInOI:=@OIOnSelectPersistents;
|
||||
ObjectInspector1.OnShowOptions:=@OIOnShowOptions;
|
||||
ObjectInspector1.OnRemainingKeyUp:=@OIRemainingKeyUp;
|
||||
{$IFDEF EnableOIFavourites}
|
||||
ObjectInspector1.ShowFavouritePage:=true;
|
||||
{$ENDIF}
|
||||
ObjectInspector1.Favourites:=LoadOIFavouriteProperties;
|
||||
ObjectInspector1.OnAddToFavourites:=@OIOnAddToFavourites;
|
||||
ObjectInspector1.OnRemoveFromFavourites:=@OIOnRemoveFromFavourites;
|
||||
|
||||
GlobalDesignHook:=TPropertyEditorHook.Create;
|
||||
GlobalDesignHook.GetPrivateDirectory:=AppendPathDelim(GetPrimaryConfigPath);
|
||||
@ -11533,6 +11544,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.863 2005/03/29 09:30:14 mattias
|
||||
started OI favourites
|
||||
|
||||
Revision 1.862 2005/03/23 10:45:05 mattias
|
||||
fixed ambigious with ambiguous
|
||||
|
||||
|
@ -36,7 +36,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, BasicCodeTools, CodeTree, CodeToolManager,
|
||||
PascalParserTool, IdentCompletionTool, GraphType, Graphics, EditorOptions,
|
||||
SynEdit, SynCompletion;
|
||||
SynEdit, SynCompletion, MainIntf;
|
||||
|
||||
type
|
||||
TCompletionType = (
|
||||
@ -283,13 +283,18 @@ begin
|
||||
Result:='';
|
||||
CursorToLeft:=0;
|
||||
CursorAtEnd:=true;
|
||||
ValueType:=icvIdentifier;
|
||||
Index:=aCompletion.Position;
|
||||
IdentList:=CodeToolBoss.IdentifierList;
|
||||
|
||||
IdentItem:=IdentList.FilteredItems[Index];
|
||||
IdentItem.CheckHasChilds;
|
||||
ValueType:=icvIdentifier;
|
||||
if IdentItem=nil then exit;
|
||||
|
||||
if not CodeToolBoss.IdentItemCheckHasChilds(IdentItem) then begin
|
||||
MainIDEInterface.DoJumpToCodeToolBossError;
|
||||
exit;
|
||||
end;
|
||||
|
||||
Result:=GetIdentifier(IdentItem.Identifier);
|
||||
|
||||
case IdentItem.GetDesc of
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -43,6 +43,7 @@ resourcestring
|
||||
|
||||
oisProperties='Properties';
|
||||
oisEvents='Events';
|
||||
oisFavourites = 'Favourites';
|
||||
oisSetToDefault = 'Set to default: %s';
|
||||
oisSetToDefaultValue = 'Set to default value';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user