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"/>
|
||||
</Item6>
|
||||
</RequiredPackages>
|
||||
<Units Count="45">
|
||||
<Units Count="46">
|
||||
<Unit0>
|
||||
<Filename Value="coedit.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
|
@ -376,6 +376,10 @@
|
|||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
</Unit44>
|
||||
<Unit45>
|
||||
<Filename Value="..\src\ce_lcldragdrop.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit45>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
|
|
@ -10,7 +10,7 @@ uses
|
|||
ce_observer, ce_libman, ce_tools, ce_dcd, ce_main, ce_writableComponent,
|
||||
ce_symstring, ce_staticmacro, ce_inspectors, ce_editoroptions, ce_dockoptions,
|
||||
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}
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ type
|
|||
fOnChanging: TTabChangingEvent;
|
||||
fSplitter: TSplitter;
|
||||
fOldSplitPos: integer;
|
||||
fOnDragDrop: TDragDropEvent;
|
||||
fOnDragOver: TDragOverEvent;
|
||||
|
||||
procedure btnCloseClick(sender: TObject);
|
||||
procedure btnMoveLeftClick(sender: TObject);
|
||||
|
@ -74,6 +76,9 @@ type
|
|||
procedure changedNotify;
|
||||
procedure updateButtonsState;
|
||||
|
||||
procedure setOnDragOver(value: TDragOverEvent);
|
||||
procedure setOnDragDrop(value: TDragDropEvent);
|
||||
|
||||
public
|
||||
constructor Create(aowner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
|
@ -99,6 +104,9 @@ type
|
|||
|
||||
property onChanged: TNotifyEvent read fOnChanged write fOnChanged;
|
||||
property onChanging: TTabChangingEvent read fOnChanging write fOnChanging;
|
||||
|
||||
property OnDragOver read fOnDragOver write setOnDragOver;
|
||||
property OnDragDrop read fOnDragDrop write setOnDragDrop;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
@ -218,6 +226,23 @@ begin
|
|||
inherited;
|
||||
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;
|
||||
begin
|
||||
updateButtonsState;
|
||||
|
|
|
@ -65,6 +65,7 @@ inherited CEDubProjectEditorWidget: TCEDubProjectEditorWidget
|
|||
Align = alClient
|
||||
BorderSpacing.Around = 4
|
||||
DefaultItemHeight = 16
|
||||
DragMode = dmAutomatic
|
||||
HideSelection = False
|
||||
Images = imgList
|
||||
ReadOnly = True
|
||||
|
@ -85,12 +86,12 @@ inherited CEDubProjectEditorWidget: TCEDubProjectEditorWidget
|
|||
ClientWidth = 395
|
||||
object propTree: TTreeView
|
||||
Left = 4
|
||||
Height = 324
|
||||
Height = 316
|
||||
Top = 32
|
||||
Width = 387
|
||||
Align = alClient
|
||||
BorderSpacing.Around = 4
|
||||
DefaultItemHeight = 18
|
||||
DefaultItemHeight = 16
|
||||
HideSelection = False
|
||||
Images = imgList
|
||||
ReadOnly = True
|
||||
|
@ -152,7 +153,7 @@ inherited CEDubProjectEditorWidget: TCEDubProjectEditorWidget
|
|||
object Panel1: TPanel
|
||||
Left = 2
|
||||
Height = 26
|
||||
Top = 360
|
||||
Top = 352
|
||||
Width = 391
|
||||
Align = alBottom
|
||||
BorderSpacing.Around = 2
|
||||
|
|
|
@ -85,6 +85,9 @@ type
|
|||
implementation
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
ce_lcldragdrop;
|
||||
|
||||
{$REGION Standard Comp/Obj------------------------------------------------------}
|
||||
constructor TCEEditorWidget.create(aOwner: TComponent);
|
||||
begin
|
||||
|
@ -97,6 +100,8 @@ begin
|
|||
pageControl.onChanging:=@PageControlChanging;
|
||||
pageControl.closeButton.OnClick:=@pageCloseBtnClick;
|
||||
pageControl.addButton.OnClick:=@pageBtnAddCLick;
|
||||
pageControl.OnDragDrop:= @ddHandler.DragDrop;
|
||||
pageControl.OnDragOver:= @ddHandler.DragOver;
|
||||
AssignPng(pageControl.moveLeftButton, 'go_previous');
|
||||
AssignPng(pageControl.moveRightButton, 'go_next');
|
||||
AssignPng(pageControl.addButton, 'document_add');
|
||||
|
@ -380,7 +385,7 @@ begin
|
|||
if not DcdWrapper.available then exit;
|
||||
//
|
||||
DcdWrapper.getDeclFromCursor(fname, srcpos);
|
||||
if (fname <> fDoc.fileName) and fileExists(fname) then
|
||||
if (fname <> fDoc.fileName) and fname.fileExists then
|
||||
begin
|
||||
page := pageControl.splitPage;
|
||||
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
|
||||
Classes, SysUtils, LazFileUtils, SynEditKeyCmds, SynHighlighterLFM, Forms, StdCtrls,
|
||||
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_widget, ce_messages, ce_interfaces, ce_editor, ce_projinspect, ce_projconf,
|
||||
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_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
|
||||
|
||||
|
@ -709,6 +709,8 @@ begin
|
|||
LoadSettings;
|
||||
layoutUpdateMenu;
|
||||
fMultidoc := getMultiDocHandler;
|
||||
OnDragDrop:= @ddHandler.DragDrop;
|
||||
OnDragOver:= @ddHandler.DragOver;
|
||||
//
|
||||
checkCompilo;
|
||||
//
|
||||
|
|
|
@ -29,7 +29,7 @@ inherited CEMiniExplorerWidget: TCEMiniExplorerWidget
|
|||
AutoWidthLastColumn = True
|
||||
Columns = <
|
||||
item
|
||||
Width = 330
|
||||
Width = 314
|
||||
end>
|
||||
ReadOnly = True
|
||||
ShowColumnHeaders = False
|
||||
|
@ -91,8 +91,9 @@ inherited CEMiniExplorerWidget: TCEMiniExplorerWidget
|
|||
AutoWidthLastColumn = True
|
||||
Columns = <
|
||||
item
|
||||
Width = 330
|
||||
Width = 314
|
||||
end>
|
||||
DragMode = dmAutomatic
|
||||
ReadOnly = True
|
||||
ShowColumnHeaders = False
|
||||
SmallImages = imgList
|
||||
|
@ -100,6 +101,7 @@ inherited CEMiniExplorerWidget: TCEMiniExplorerWidget
|
|||
ViewStyle = vsReport
|
||||
OnDblClick = lstFilesDblClick
|
||||
OnEnter = lstFilesEnter
|
||||
OnStartDrag = lstFilesStartDrag
|
||||
end
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
|
|
|
@ -81,6 +81,7 @@ type
|
|||
procedure lstFavEnter(Sender: TObject);
|
||||
procedure lstFilesDblClick(Sender: TObject);
|
||||
procedure lstFilesEnter(Sender: TObject);
|
||||
procedure lstFilesStartDrag(Sender: TObject; var DragObject: TDragObject);
|
||||
procedure TreeEnter(Sender: TObject);
|
||||
private
|
||||
fProj: ICECommonProject;
|
||||
|
@ -503,6 +504,12 @@ begin
|
|||
fLastListOrTree := lstFiles;
|
||||
end;
|
||||
|
||||
procedure TCEMiniExplorerWidget.lstFilesStartDrag(Sender: TObject;
|
||||
var DragObject: TDragObject);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCEMiniExplorerWidget.shellOpenSelected;
|
||||
var
|
||||
fname: string = '';
|
||||
|
|
|
@ -29,6 +29,7 @@ inherited CEProjectInspectWidget: TCEProjectInspectWidget
|
|||
AutoExpand = True
|
||||
BorderSpacing.Around = 2
|
||||
DefaultItemHeight = 16
|
||||
DragMode = dmAutomatic
|
||||
Images = imgList
|
||||
ReadOnly = True
|
||||
RightClickSelect = True
|
||||
|
|
|
@ -235,7 +235,7 @@ var
|
|||
implementation
|
||||
|
||||
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;
|
||||
begin
|
||||
|
@ -456,6 +456,9 @@ begin
|
|||
Font.Size:=10;
|
||||
SetDefaultCoeditKeystrokes(Self); // not called in inherited if owner = nil !
|
||||
//
|
||||
OnDragDrop:= @ddHandler.DragDrop;
|
||||
OnDragOver:= @ddHandler.DragOver;
|
||||
//
|
||||
ShowHint := false;
|
||||
InitHintWins;
|
||||
fDDocDelay := 200;
|
||||
|
|
Loading…
Reference in New Issue