mirror of https://gitlab.com/basile.b/dexed.git
added D&D from mini-explorer and from proj inspectors
This commit is contained in:
parent
1edee4eba8
commit
123e7c50dd
|
@ -137,7 +137,7 @@
|
||||||
<PackageName Value="LCL"/>
|
<PackageName Value="LCL"/>
|
||||||
</Item6>
|
</Item6>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="45">
|
<Units Count="46">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="coedit.lpr"/>
|
<Filename Value="coedit.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
|
@ -376,6 +376,10 @@
|
||||||
<HasResources Value="True"/>
|
<HasResources Value="True"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
</Unit44>
|
</Unit44>
|
||||||
|
<Unit45>
|
||||||
|
<Filename Value="..\src\ce_lcldragdrop.pas"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
</Unit45>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
|
|
|
@ -10,7 +10,7 @@ uses
|
||||||
ce_observer, ce_libman, ce_tools, ce_dcd, ce_main, ce_writableComponent,
|
ce_observer, ce_libman, ce_tools, ce_dcd, ce_main, ce_writableComponent,
|
||||||
ce_symstring, ce_staticmacro, ce_inspectors, ce_editoroptions, ce_dockoptions,
|
ce_symstring, ce_staticmacro, ce_inspectors, ce_editoroptions, ce_dockoptions,
|
||||||
ce_shortcutseditor, ce_mru, ce_processes, ce_dubproject, ce_dialogs,
|
ce_shortcutseditor, ce_mru, ce_processes, ce_dubproject, ce_dialogs,
|
||||||
ce_dubprojeditor, ce_gdb, ce_controls, ce_dfmt;
|
ce_dubprojeditor, ce_gdb, ce_controls, ce_dfmt, ce_lcldragdrop;
|
||||||
|
|
||||||
{$R *.res}
|
{$R *.res}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ type
|
||||||
fOnChanging: TTabChangingEvent;
|
fOnChanging: TTabChangingEvent;
|
||||||
fSplitter: TSplitter;
|
fSplitter: TSplitter;
|
||||||
fOldSplitPos: integer;
|
fOldSplitPos: integer;
|
||||||
|
fOnDragDrop: TDragDropEvent;
|
||||||
|
fOnDragOver: TDragOverEvent;
|
||||||
|
|
||||||
procedure btnCloseClick(sender: TObject);
|
procedure btnCloseClick(sender: TObject);
|
||||||
procedure btnMoveLeftClick(sender: TObject);
|
procedure btnMoveLeftClick(sender: TObject);
|
||||||
|
@ -74,6 +76,9 @@ type
|
||||||
procedure changedNotify;
|
procedure changedNotify;
|
||||||
procedure updateButtonsState;
|
procedure updateButtonsState;
|
||||||
|
|
||||||
|
procedure setOnDragOver(value: TDragOverEvent);
|
||||||
|
procedure setOnDragDrop(value: TDragDropEvent);
|
||||||
|
|
||||||
public
|
public
|
||||||
constructor Create(aowner: TComponent); override;
|
constructor Create(aowner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
@ -99,6 +104,9 @@ type
|
||||||
|
|
||||||
property onChanged: TNotifyEvent read fOnChanged write fOnChanged;
|
property onChanged: TNotifyEvent read fOnChanged write fOnChanged;
|
||||||
property onChanging: TTabChangingEvent read fOnChanging write fOnChanging;
|
property onChanging: TTabChangingEvent read fOnChanging write fOnChanging;
|
||||||
|
|
||||||
|
property OnDragOver read fOnDragOver write setOnDragOver;
|
||||||
|
property OnDragDrop read fOnDragDrop write setOnDragDrop;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
@ -218,6 +226,23 @@ begin
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCEPageControl.setOnDragOver(value: TDragOverEvent);
|
||||||
|
begin
|
||||||
|
if fOnDragOver = value then
|
||||||
|
exit;
|
||||||
|
fOnDragOver:=value;
|
||||||
|
fContent.OnDragOver:=value;
|
||||||
|
fTabs.OnDragOver:=value;
|
||||||
|
end;
|
||||||
|
procedure TCEPageControl.setOnDragDrop(value: TDragDropEvent);
|
||||||
|
begin
|
||||||
|
if fOnDragDrop = value then
|
||||||
|
exit;
|
||||||
|
fOnDragDrop:=value;
|
||||||
|
fContent.OnDragDrop:=value;
|
||||||
|
fTabs.OnDragDrop:=value;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCEPageControl.changedNotify;
|
procedure TCEPageControl.changedNotify;
|
||||||
begin
|
begin
|
||||||
updateButtonsState;
|
updateButtonsState;
|
||||||
|
|
|
@ -65,6 +65,7 @@ inherited CEDubProjectEditorWidget: TCEDubProjectEditorWidget
|
||||||
Align = alClient
|
Align = alClient
|
||||||
BorderSpacing.Around = 4
|
BorderSpacing.Around = 4
|
||||||
DefaultItemHeight = 16
|
DefaultItemHeight = 16
|
||||||
|
DragMode = dmAutomatic
|
||||||
HideSelection = False
|
HideSelection = False
|
||||||
Images = imgList
|
Images = imgList
|
||||||
ReadOnly = True
|
ReadOnly = True
|
||||||
|
@ -85,12 +86,12 @@ inherited CEDubProjectEditorWidget: TCEDubProjectEditorWidget
|
||||||
ClientWidth = 395
|
ClientWidth = 395
|
||||||
object propTree: TTreeView
|
object propTree: TTreeView
|
||||||
Left = 4
|
Left = 4
|
||||||
Height = 324
|
Height = 316
|
||||||
Top = 32
|
Top = 32
|
||||||
Width = 387
|
Width = 387
|
||||||
Align = alClient
|
Align = alClient
|
||||||
BorderSpacing.Around = 4
|
BorderSpacing.Around = 4
|
||||||
DefaultItemHeight = 18
|
DefaultItemHeight = 16
|
||||||
HideSelection = False
|
HideSelection = False
|
||||||
Images = imgList
|
Images = imgList
|
||||||
ReadOnly = True
|
ReadOnly = True
|
||||||
|
@ -152,7 +153,7 @@ inherited CEDubProjectEditorWidget: TCEDubProjectEditorWidget
|
||||||
object Panel1: TPanel
|
object Panel1: TPanel
|
||||||
Left = 2
|
Left = 2
|
||||||
Height = 26
|
Height = 26
|
||||||
Top = 360
|
Top = 352
|
||||||
Width = 391
|
Width = 391
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
BorderSpacing.Around = 2
|
BorderSpacing.Around = 2
|
||||||
|
|
|
@ -85,6 +85,9 @@ type
|
||||||
implementation
|
implementation
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
|
uses
|
||||||
|
ce_lcldragdrop;
|
||||||
|
|
||||||
{$REGION Standard Comp/Obj------------------------------------------------------}
|
{$REGION Standard Comp/Obj------------------------------------------------------}
|
||||||
constructor TCEEditorWidget.create(aOwner: TComponent);
|
constructor TCEEditorWidget.create(aOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
|
@ -97,6 +100,8 @@ begin
|
||||||
pageControl.onChanging:=@PageControlChanging;
|
pageControl.onChanging:=@PageControlChanging;
|
||||||
pageControl.closeButton.OnClick:=@pageCloseBtnClick;
|
pageControl.closeButton.OnClick:=@pageCloseBtnClick;
|
||||||
pageControl.addButton.OnClick:=@pageBtnAddCLick;
|
pageControl.addButton.OnClick:=@pageBtnAddCLick;
|
||||||
|
pageControl.OnDragDrop:= @ddHandler.DragDrop;
|
||||||
|
pageControl.OnDragOver:= @ddHandler.DragOver;
|
||||||
AssignPng(pageControl.moveLeftButton, 'go_previous');
|
AssignPng(pageControl.moveLeftButton, 'go_previous');
|
||||||
AssignPng(pageControl.moveRightButton, 'go_next');
|
AssignPng(pageControl.moveRightButton, 'go_next');
|
||||||
AssignPng(pageControl.addButton, 'document_add');
|
AssignPng(pageControl.addButton, 'document_add');
|
||||||
|
@ -380,7 +385,7 @@ begin
|
||||||
if not DcdWrapper.available then exit;
|
if not DcdWrapper.available then exit;
|
||||||
//
|
//
|
||||||
DcdWrapper.getDeclFromCursor(fname, srcpos);
|
DcdWrapper.getDeclFromCursor(fname, srcpos);
|
||||||
if (fname <> fDoc.fileName) and fileExists(fname) then
|
if (fname <> fDoc.fileName) and fname.fileExists then
|
||||||
begin
|
begin
|
||||||
page := pageControl.splitPage;
|
page := pageControl.splitPage;
|
||||||
if assigned(page) then
|
if assigned(page) then
|
||||||
|
|
|
@ -0,0 +1,154 @@
|
||||||
|
unit ce_lcldragdrop;
|
||||||
|
|
||||||
|
{$I ce_defines.inc}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, Controls, ComCtrls,
|
||||||
|
ce_common, ce_nativeproject, ce_dubproject, ce_interfaces,
|
||||||
|
ce_dialogs;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
TDDHandler = class(TObject, ICEProjectObserver)
|
||||||
|
private
|
||||||
|
fProj: ICECommonProject;
|
||||||
|
procedure projNew(aProject: ICECommonProject);
|
||||||
|
procedure projChanged(aProject: ICECommonProject);
|
||||||
|
procedure projClosing(aProject: ICECommonProject);
|
||||||
|
procedure projFocused(aProject: ICECommonProject);
|
||||||
|
procedure projCompiling(aProject: ICECommonProject);
|
||||||
|
function getFilename(src: TObject): string;
|
||||||
|
public
|
||||||
|
constructor create;
|
||||||
|
destructor destroy; override;
|
||||||
|
procedure DragOver(Sender, Source: TObject; X, Y: Integer;
|
||||||
|
State: TDragState; var Accept: Boolean);
|
||||||
|
procedure DragDrop(Sender, Source: TObject; X, Y: Integer);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
ddHandler: TDDHandler;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
ce_observer;
|
||||||
|
|
||||||
|
constructor TDDHandler.create;
|
||||||
|
begin
|
||||||
|
EntitiesConnector.addObserver(self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TDDHandler.destroy;
|
||||||
|
begin
|
||||||
|
EntitiesConnector.removeObserver(self);
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDDHandler.projNew(aProject: ICECommonProject);
|
||||||
|
begin
|
||||||
|
fProj := aProject;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDDHandler.projChanged(aProject: ICECommonProject);
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDDHandler.projClosing(aProject: ICECommonProject);
|
||||||
|
begin
|
||||||
|
if (fProj <> nil) and (fProj = aProject) then
|
||||||
|
fProj := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDDHandler.projFocused(aProject: ICECommonProject);
|
||||||
|
begin
|
||||||
|
fProj := aProject;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDDHandler.projCompiling(aProject: ICECommonProject);
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TDDHandler.getFilename(src: TObject): string;
|
||||||
|
var
|
||||||
|
lst: TListView;
|
||||||
|
trv: TTreeView;
|
||||||
|
begin
|
||||||
|
result := '';
|
||||||
|
if src.isNil then exit;
|
||||||
|
// from mini-explorer
|
||||||
|
if src is TListView then
|
||||||
|
begin
|
||||||
|
lst := TListView(src);
|
||||||
|
if lst.Selected.isNotNil and lst.Selected.Data.isNotNil then
|
||||||
|
result := PString(lst.Selected.Data)^;
|
||||||
|
end
|
||||||
|
// from CE/DUB project inspector
|
||||||
|
else if src is TTreeView then
|
||||||
|
begin
|
||||||
|
trv := TTreeView(src);
|
||||||
|
if trv.Selected.isNotNil then
|
||||||
|
begin
|
||||||
|
result := trv.Selected.Text;
|
||||||
|
if (not result.fileExists) and assigned(fProj) then
|
||||||
|
result := fProj.filename.extractFilePath + result;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDDHandler.DragOver(Sender, Source: TObject; X, Y: Integer;
|
||||||
|
State: TDragState; var Accept: Boolean);
|
||||||
|
var
|
||||||
|
fname: string;
|
||||||
|
begin
|
||||||
|
fname := getFilename(Source);
|
||||||
|
Accept := fname.fileExists and (not fname.dirExists);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDDHandler.DragDrop(Sender, Source: TObject; X, Y: Integer);
|
||||||
|
var
|
||||||
|
fname: string;
|
||||||
|
proj: boolean = false;
|
||||||
|
begin
|
||||||
|
if Source.isNil then exit;
|
||||||
|
fname := getFilename(Source);
|
||||||
|
if not fname.fileExists then exit;
|
||||||
|
|
||||||
|
if isValidNativeProject(fname) then
|
||||||
|
begin
|
||||||
|
if assigned(fProj) then
|
||||||
|
begin
|
||||||
|
if fProj.modified and (dlgFileChangeClose(fname) = mrCancel) then
|
||||||
|
exit;
|
||||||
|
fProj.getProject.Free;
|
||||||
|
end;
|
||||||
|
TCENativeProject.create(nil);
|
||||||
|
proj := true;
|
||||||
|
end
|
||||||
|
else if isValidDubProject(fname) then
|
||||||
|
begin
|
||||||
|
if assigned(fProj) then
|
||||||
|
begin
|
||||||
|
if fProj.modified and (dlgFileChangeClose(fname) = mrCancel) then
|
||||||
|
exit;
|
||||||
|
fProj.getProject.Free;
|
||||||
|
end;
|
||||||
|
TCEDubProject.create(nil);
|
||||||
|
proj := true;
|
||||||
|
end;
|
||||||
|
if assigned(fProj) and proj then
|
||||||
|
fProj.loadFromFile(fname)
|
||||||
|
else
|
||||||
|
getMultiDocHandler.openDocument(fname);
|
||||||
|
end;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
ddHandler:= TDDHandler.create;
|
||||||
|
|
||||||
|
finalization
|
||||||
|
ddHandler.free;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
|
@ -7,12 +7,12 @@ interface
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LazFileUtils, SynEditKeyCmds, SynHighlighterLFM, Forms, StdCtrls,
|
Classes, SysUtils, LazFileUtils, SynEditKeyCmds, SynHighlighterLFM, Forms, StdCtrls,
|
||||||
AnchorDocking, AnchorDockStorage, AnchorDockOptionsDlg, Controls, Graphics, strutils,
|
AnchorDocking, AnchorDockStorage, AnchorDockOptionsDlg, Controls, Graphics, strutils,
|
||||||
Dialogs, Menus, ActnList, ExtCtrls, process, XMLPropStorage, SynExportHTML,
|
Dialogs, Menus, ActnList, ExtCtrls, process, XMLPropStorage, SynExportHTML, ComCtrls,
|
||||||
ce_common, ce_dmdwrap, ce_nativeproject, ce_dcd, ce_synmemo, ce_writableComponent,
|
ce_common, ce_dmdwrap, ce_nativeproject, ce_dcd, ce_synmemo, ce_writableComponent,
|
||||||
ce_widget, ce_messages, ce_interfaces, ce_editor, ce_projinspect, ce_projconf,
|
ce_widget, ce_messages, ce_interfaces, ce_editor, ce_projinspect, ce_projconf,
|
||||||
ce_search, ce_miniexplorer, ce_libman, ce_libmaneditor, ce_todolist, ce_observer,
|
ce_search, ce_miniexplorer, ce_libman, ce_libmaneditor, ce_todolist, ce_observer,
|
||||||
ce_toolseditor, ce_procinput, ce_optionseditor, ce_symlist, ce_mru, ce_processes,
|
ce_toolseditor, ce_procinput, ce_optionseditor, ce_symlist, ce_mru, ce_processes,
|
||||||
ce_infos, ce_dubproject, ce_dialogs, ce_dubprojeditor, ce_gdb, ce_dfmt;
|
ce_infos, ce_dubproject, ce_dialogs, ce_dubprojeditor, ce_gdb, ce_dfmt, ce_lcldragdrop;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
@ -709,6 +709,8 @@ begin
|
||||||
LoadSettings;
|
LoadSettings;
|
||||||
layoutUpdateMenu;
|
layoutUpdateMenu;
|
||||||
fMultidoc := getMultiDocHandler;
|
fMultidoc := getMultiDocHandler;
|
||||||
|
OnDragDrop:= @ddHandler.DragDrop;
|
||||||
|
OnDragOver:= @ddHandler.DragOver;
|
||||||
//
|
//
|
||||||
checkCompilo;
|
checkCompilo;
|
||||||
//
|
//
|
||||||
|
|
|
@ -29,7 +29,7 @@ inherited CEMiniExplorerWidget: TCEMiniExplorerWidget
|
||||||
AutoWidthLastColumn = True
|
AutoWidthLastColumn = True
|
||||||
Columns = <
|
Columns = <
|
||||||
item
|
item
|
||||||
Width = 330
|
Width = 314
|
||||||
end>
|
end>
|
||||||
ReadOnly = True
|
ReadOnly = True
|
||||||
ShowColumnHeaders = False
|
ShowColumnHeaders = False
|
||||||
|
@ -91,8 +91,9 @@ inherited CEMiniExplorerWidget: TCEMiniExplorerWidget
|
||||||
AutoWidthLastColumn = True
|
AutoWidthLastColumn = True
|
||||||
Columns = <
|
Columns = <
|
||||||
item
|
item
|
||||||
Width = 330
|
Width = 314
|
||||||
end>
|
end>
|
||||||
|
DragMode = dmAutomatic
|
||||||
ReadOnly = True
|
ReadOnly = True
|
||||||
ShowColumnHeaders = False
|
ShowColumnHeaders = False
|
||||||
SmallImages = imgList
|
SmallImages = imgList
|
||||||
|
@ -100,6 +101,7 @@ inherited CEMiniExplorerWidget: TCEMiniExplorerWidget
|
||||||
ViewStyle = vsReport
|
ViewStyle = vsReport
|
||||||
OnDblClick = lstFilesDblClick
|
OnDblClick = lstFilesDblClick
|
||||||
OnEnter = lstFilesEnter
|
OnEnter = lstFilesEnter
|
||||||
|
OnStartDrag = lstFilesStartDrag
|
||||||
end
|
end
|
||||||
object Panel1: TPanel
|
object Panel1: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
|
|
|
@ -81,6 +81,7 @@ type
|
||||||
procedure lstFavEnter(Sender: TObject);
|
procedure lstFavEnter(Sender: TObject);
|
||||||
procedure lstFilesDblClick(Sender: TObject);
|
procedure lstFilesDblClick(Sender: TObject);
|
||||||
procedure lstFilesEnter(Sender: TObject);
|
procedure lstFilesEnter(Sender: TObject);
|
||||||
|
procedure lstFilesStartDrag(Sender: TObject; var DragObject: TDragObject);
|
||||||
procedure TreeEnter(Sender: TObject);
|
procedure TreeEnter(Sender: TObject);
|
||||||
private
|
private
|
||||||
fProj: ICECommonProject;
|
fProj: ICECommonProject;
|
||||||
|
@ -503,6 +504,12 @@ begin
|
||||||
fLastListOrTree := lstFiles;
|
fLastListOrTree := lstFiles;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCEMiniExplorerWidget.lstFilesStartDrag(Sender: TObject;
|
||||||
|
var DragObject: TDragObject);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCEMiniExplorerWidget.shellOpenSelected;
|
procedure TCEMiniExplorerWidget.shellOpenSelected;
|
||||||
var
|
var
|
||||||
fname: string = '';
|
fname: string = '';
|
||||||
|
|
|
@ -29,6 +29,7 @@ inherited CEProjectInspectWidget: TCEProjectInspectWidget
|
||||||
AutoExpand = True
|
AutoExpand = True
|
||||||
BorderSpacing.Around = 2
|
BorderSpacing.Around = 2
|
||||||
DefaultItemHeight = 16
|
DefaultItemHeight = 16
|
||||||
|
DragMode = dmAutomatic
|
||||||
Images = imgList
|
Images = imgList
|
||||||
ReadOnly = True
|
ReadOnly = True
|
||||||
RightClickSelect = True
|
RightClickSelect = True
|
||||||
|
|
|
@ -235,7 +235,7 @@ var
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
ce_interfaces, ce_staticmacro, ce_dcd, SynEditHighlighterFoldBase;
|
ce_interfaces, ce_staticmacro, ce_dcd, SynEditHighlighterFoldBase, ce_lcldragdrop;
|
||||||
|
|
||||||
function TCEEditorHintWindow.CalcHintRect(MaxWidth: Integer; const AHint: String; AData: Pointer): TRect;
|
function TCEEditorHintWindow.CalcHintRect(MaxWidth: Integer; const AHint: String; AData: Pointer): TRect;
|
||||||
begin
|
begin
|
||||||
|
@ -456,6 +456,9 @@ begin
|
||||||
Font.Size:=10;
|
Font.Size:=10;
|
||||||
SetDefaultCoeditKeystrokes(Self); // not called in inherited if owner = nil !
|
SetDefaultCoeditKeystrokes(Self); // not called in inherited if owner = nil !
|
||||||
//
|
//
|
||||||
|
OnDragDrop:= @ddHandler.DragDrop;
|
||||||
|
OnDragOver:= @ddHandler.DragOver;
|
||||||
|
//
|
||||||
ShowHint := false;
|
ShowHint := false;
|
||||||
InitHintWins;
|
InitHintWins;
|
||||||
fDDocDelay := 200;
|
fDDocDelay := 200;
|
||||||
|
|
Loading…
Reference in New Issue