summaryrefslogtreecommitdiff
path: root/src/corelib
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2010-09-21 13:40:15 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2010-09-23 16:24:42 +0200
commit2de0a19405347f240eb9b6294ea6d631a38da2c6 (patch)
tree271bd5e65b9557cfa21baf3caee389ca6c7e287d /src/corelib
parenta86b77cde8c444f6e62b3ec89288dff43680de15 (diff)
downloadfpGUI-2de0a19405347f240eb9b6294ea6d631a38da2c6.tar.xz
implement the higher level TfpgDrag and TfpgMimeData classes.
These are independant of the backend - they contain common code and interface. TfpgDrag will be used to initiate a drag action (acting as the source of a drag), and contain the data available for that drag action.
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/fpg_main.pas53
-rw-r--r--src/corelib/x11/fpg_interface.pas2
-rw-r--r--src/corelib/x11/fpg_x11.pas4
3 files changed, 58 insertions, 1 deletions
diff --git a/src/corelib/fpg_main.pas b/src/corelib/fpg_main.pas
index e77a025f..fa6b44d5 100644
--- a/src/corelib/fpg_main.pas
+++ b/src/corelib/fpg_main.pas
@@ -29,7 +29,8 @@ uses
Classes,
SysUtils,
fpg_base,
- fpg_interface;
+ fpg_interface,
+ fpg_impl;
type
TOrientation = (orVertical, orHorizontal);
@@ -332,6 +333,25 @@ type
end;
+ TfpgMimeData = class(TfpgMimeDataImpl)
+ end;
+
+
+ TfpgDrag = class(TfpgDragImpl)
+ private
+ FTarget: TfpgWinHandle;
+ procedure SetMimeData(const AValue: TfpgMimeDataBase);
+ protected
+ function GetSource: TfpgWindow; reintroduce;
+ public
+ constructor Create(ASource: TfpgWindow);
+ function Execute(const ADropActions: TfpgDropActions; const ADefaultAction: TfpgDropAction = daCopy): TfpgDropAction; override;
+ property Source: TfpgWindow read GetSource;
+ property Target: TfpgWinHandle read FTarget write FTarget;
+ property MimeData: TfpgMimeDataBase read FMimeData write SetMimeData;
+ end;
+
+
var
fpgStyle: TfpgStyle; { TODO -ograemeg : move this into fpgApplication }
fpgCaret: TfpgCaret; { TODO -ograemeg : move this into fpgApplication }
@@ -2386,6 +2406,37 @@ begin
Result.UpdateImage;
end;
+
+{ TfpgDrag }
+
+procedure TfpgDrag.SetMimeData(const AValue: TfpgMimeDataBase);
+begin
+ if Assigned(FMimeData) then
+ FMimeData.Free;
+ FMimeData := AValue;
+end;
+
+function TfpgDrag.GetSource: TfpgWindow;
+begin
+ Result := TfpgWindow(inherited GetSource);
+end;
+
+constructor TfpgDrag.Create(ASource: TfpgWindow);
+begin
+ inherited Create;
+ FSource := ASource;
+end;
+
+function TfpgDrag.Execute(const ADropActions: TfpgDropActions;
+ const ADefaultAction: TfpgDropAction): TfpgDropAction;
+begin
+ Assert(FMimeData <> nil, ClassName + ': No mimedata was set before starting the drag');
+ Assert(FSource <> nil, ClassName + ': No Source window was specified before starting the drag');
+ inherited Execute(ADropActions, ADefaultAction);
+end;
+
+
+
initialization
uApplication := nil;
uClipboard := nil;
diff --git a/src/corelib/x11/fpg_interface.pas b/src/corelib/x11/fpg_interface.pas
index c4adf079..3a1e1920 100644
--- a/src/corelib/x11/fpg_interface.pas
+++ b/src/corelib/x11/fpg_interface.pas
@@ -33,6 +33,8 @@ type
TfpgApplicationImpl = TfpgX11Application;
TfpgClipboardImpl = TfpgX11Clipboard;
TfpgFileListImpl = TfpgX11FileList;
+ TfpgMimeDataImpl = TfpgX11MimeData;
+ TfpgDragImpl = TfpgX11Drag;
implementation
diff --git a/src/corelib/x11/fpg_x11.pas b/src/corelib/x11/fpg_x11.pas
index 6419818c..166e1205 100644
--- a/src/corelib/x11/fpg_x11.pas
+++ b/src/corelib/x11/fpg_x11.pas
@@ -346,6 +346,10 @@ type
end;
+ TfpgX11MimeData = class(TfpgMimeDataBase)
+ end;
+
+
TfpgX11Drag = class(TfpgDragBase)
private
FLastTarget: TfpgWinHandle;