summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2010-10-29 12:38:03 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2010-10-29 12:38:03 +0200
commitd3bc090ffb6c1a96e2a6cb01f474f9318c4c84f1 (patch)
treef6924e6a611b6acedbda74562769c42a9dfdae19
parent5b0c88e262642f787e96588599db19b618c58250 (diff)
downloadfpGUI-d3bc090ffb6c1a96e2a6cb01f474f9318c4c84f1.tar.xz
Moved OnDragStartDetected from TfpgWidget to TfpgWindowBase
* also introduced virtual DoDragStartDetected which executes the OnDragStartDetected event * We also added a override of DoDragStartDetected in GDI for some extra tasks.
-rw-r--r--src/corelib/fpg_base.pas11
-rw-r--r--src/corelib/fpg_widget.pas8
-rw-r--r--src/corelib/gdi/fpg_gdi.pas10
3 files changed, 23 insertions, 6 deletions
diff --git a/src/corelib/fpg_base.pas b/src/corelib/fpg_base.pas
index c81d9cd8..a5289474 100644
--- a/src/corelib/fpg_base.pas
+++ b/src/corelib/fpg_base.pas
@@ -435,6 +435,8 @@ type
FSizeIsDirty: Boolean;
FPosIsDirty: Boolean;
FMouseCursorIsDirty: Boolean;
+ FOnDragStartDetected: TNotifyEvent;
+ FDragActive: boolean;
function HandleIsValid: boolean; virtual; abstract;
procedure DoUpdateWindowPosition; virtual; abstract;
procedure DoAllocateWindowHandle(AParent: TfpgWindowBase); virtual; abstract;
@@ -447,6 +449,7 @@ type
procedure DoSetMouseCursor; virtual; abstract;
procedure DoDNDEnabled(const AValue: boolean); virtual; abstract;
procedure DoAcceptDrops(const AValue: boolean); virtual; abstract;
+ procedure DoDragStartDetected; virtual;
procedure SetParent(const AValue: TfpgWindowBase); virtual;
function GetParent: TfpgWindowBase; virtual;
function GetCanvas: TfpgCanvasBase; virtual;
@@ -459,6 +462,7 @@ type
procedure SetWidth(const AValue: TfpgCoord);
procedure HandleMove(x, y: TfpgCoord); virtual;
procedure HandleResize(AWidth, AHeight: TfpgCoord); virtual;
+ property OnDragStartDetected: TNotifyEvent read FOnDragStartDetected write FOnDragStartDetected;
public
// The standard constructor.
constructor Create(AOwner: TComponent); override;
@@ -1137,6 +1141,12 @@ begin
Result := MinHeight;
end;
+procedure TfpgWindowBase.DoDragStartDetected;
+begin
+ if Assigned(FOnDragStartDetected) then
+ FOnDragStartDetected(self);
+end;
+
procedure TfpgWindowBase.SetParent(const AValue: TfpgWindowBase);
begin
FParent := AValue;
@@ -1257,6 +1267,7 @@ begin
FSizeIsDirty := True;
FMaxWidth := 0;
FMaxHeight := 0;
+ FDragActive := False;
end;
procedure TfpgWindowBase.AfterConstruction;
diff --git a/src/corelib/fpg_widget.pas b/src/corelib/fpg_widget.pas
index 45a480dc..374a76ed 100644
--- a/src/corelib/fpg_widget.pas
+++ b/src/corelib/fpg_widget.pas
@@ -47,7 +47,6 @@ type
FOnDragDrop: TfpgDragDropEvent;
FOnDragEnter: TfpgDragEnterEvent;
FOnDragLeave: TNotifyEvent;
- FOnDragStartDetected: TNotifyEvent;
FOnEnter: TNotifyEvent;
FOnExit: TNotifyEvent;
FOnMouseDown: TMouseButtonEvent;
@@ -61,7 +60,6 @@ type
FOnScreen: boolean;
FOnShowHint: THintEvent;
FDragStartPos: TfpgPoint;
- FDragActive: boolean;
alist: TList;
procedure SetActiveWidget(const AValue: TfpgWidget);
function IsShowHintStored: boolean;
@@ -142,7 +140,6 @@ type
{ property events }
property OnClick: TNotifyEvent read FOnClick write FOnClick;
property OnDoubleClick: TMouseButtonEvent read FOnDoubleClick write FOnDoubleClick;
- property OnDragStartDetected: TNotifyEvent read FOnDragStartDetected write FOnDragStartDetected;
property OnEnter: TNotifyEvent read FOnEnter write FOnEnter;
property OnExit: TNotifyEvent read FOnExit write FOnExit;
property OnKeyPress: TKeyPressEvent read FOnKeyPress write FOnKeyPress;
@@ -471,7 +468,6 @@ begin
FBackgroundColor := clWindowBackground;
FTextColor := clText1;
FAcceptDrops := False;
- FDragActive := False;
FOnClickPending := False;
inherited Create(AOwner);
@@ -728,8 +724,8 @@ begin
if not FDragActive and (FDragStartPos.ManhattanLength(fpgPoint(msg.Params.mouse.x, msg.Params.mouse.y)) > fpgApplication.StartDragDistance) then
begin
FDragActive := True;
- if Assigned(OnDragStartDetected) then
- OnDragStartDetected(self);
+ // In Windows dragging is a blocking function, so FDragActive is false after this call
+ DoDragStartDetected;
end;
end;
diff --git a/src/corelib/gdi/fpg_gdi.pas b/src/corelib/gdi/fpg_gdi.pas
index a6a94c4d..c1560042 100644
--- a/src/corelib/gdi/fpg_gdi.pas
+++ b/src/corelib/gdi/fpg_gdi.pas
@@ -186,6 +186,7 @@ type
procedure DoSetMouseCursor; override;
procedure DoDNDEnabled(const AValue: boolean); override;
procedure DoAcceptDrops(const AValue: boolean); override;
+ procedure DoDragStartDetected; override;
property WinHandle: TfpgWinHandle read FWinHandle;
public
constructor Create(AOwner: TComponent); override;
@@ -1906,6 +1907,15 @@ begin
end;
end;
+procedure TfpgGDIWindow.DoDragStartDetected;
+begin
+ inherited DoDragStartDetected;
+ { In windows OLE dragging is a blocking function, so it never returns until
+ OnStartDragDetected is complete. So we need to set FDragActive to False
+ here. }
+ FDragActive := False;
+end;
+
constructor TfpgGDIWindow.Create(AOwner: TComponent);
begin
inherited Create(AOwner);