diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-08-21 17:47:52 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-08-21 17:47:52 +0000 |
commit | 860a90b965388ea400b40892e4ae574a2667fbd3 (patch) | |
tree | ad578f7a27546d2d79af77b87682d8b14c8ca97d /src/corelib | |
parent | 95169d06036e38e00d20b85fa6ca8c9ce2b88cb5 (diff) | |
download | fpGUI-860a90b965388ea400b40892e4ae574a2667fbd3.tar.xz |
* Removed OS based Double Click from GDI.
* Manually implemented OS independent Double Click support in TfpgWidget.
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/fpgfx.pas | 7 | ||||
-rw-r--r-- | src/corelib/gdi/gfx_gdi.pas | 10 | ||||
-rw-r--r-- | src/corelib/gfx_widget.pas | 37 | ||||
-rw-r--r-- | src/corelib/gfxbase.pas | 18 |
4 files changed, 56 insertions, 16 deletions
diff --git a/src/corelib/fpgfx.pas b/src/corelib/fpgfx.pas index a7c5fd8e..064b964a 100644 --- a/src/corelib/fpgfx.pas +++ b/src/corelib/fpgfx.pas @@ -266,6 +266,8 @@ procedure fpgSetNamedFont(afontid, afontdesc: string); procedure fpgInitTimers; procedure fpgCheckTimers; function fpgClosestTimer(ctime: TDateTime; amaxtime: integer): integer; +function fpgGetTickCount: DWord; + // Rectangle routines function InflateRect(var Rect: TRect; dx: Integer; dy: Integer): Boolean; @@ -359,6 +361,11 @@ begin Result := -1; end; +function fpgGetTickCount: DWord; +begin + Result := DWord(Trunc(Now * 24 * 60 * 60 * 1000)); +end; + function InflateRect(var Rect: TRect; dx: Integer; dy: Integer): Boolean; begin if Assigned(@Rect) then diff --git a/src/corelib/gdi/gfx_gdi.pas b/src/corelib/gdi/gfx_gdi.pas index 1b8d82c0..673ecff1 100644 --- a/src/corelib/gdi/gfx_gdi.pas +++ b/src/corelib/gdi/gfx_gdi.pas @@ -436,7 +436,7 @@ begin WM_MOUSEMOVE, WM_LBUTTONDOWN, WM_LBUTTONUP, - WM_LBUTTONDBLCLK, +// WM_LBUTTONDBLCLK, WM_RBUTTONDOWN, WM_RBUTTONUP: begin @@ -497,8 +497,8 @@ begin if PopupListFirst = nil then ReleaseCapture; end; - WM_LBUTTONDBLCLK: - mcode := FPGM_DOUBLECLICK; + //WM_LBUTTONDBLCLK: + //mcode := FPGM_DOUBLECLICK; else mcode := 0; end; @@ -518,8 +518,8 @@ begin WM_LBUTTONDOWN, WM_LBUTTONUP, - WM_LBUTTONDBLCLK: - msgp.mouse.Buttons := MOUSE_LEFT; + //WM_LBUTTONDBLCLK: + //msgp.mouse.Buttons := MOUSE_LEFT; WM_RBUTTONDOWN, WM_RBUTTONUP: diff --git a/src/corelib/gfx_widget.pas b/src/corelib/gfx_widget.pas index 51e98178..2b454e80 100644 --- a/src/corelib/gfx_widget.pas +++ b/src/corelib/gfx_widget.pas @@ -113,6 +113,15 @@ function FindKeyboardFocus: TfpgWidget; implementation + +{ Double click support } +const + DOUBLECLICK_MS = 320; // the max time between left-clicks for doubleclick +var + uLastClickWidget: TfpgWidget; + uLastClickTime: DWord; + + function FindKeyboardFocus: TfpgWidget; begin Result := nil; @@ -303,15 +312,35 @@ end; procedure TfpgWidget.MsgMouseUp(var msg: TfpgMessageRec); var mb: TMouseButton; + IsDblClick: boolean; + t: DWord; begin if not FEnabled then exit; // Do we want this here? + + IsDblClick := False; case msg.Params.mouse.Buttons of MOUSE_LEFT: begin mb := mbLeft; - HandleLMouseUp(msg.Params.mouse.x, msg.Params.mouse.y, msg.Params.mouse.shiftstate); + t := fpgGetTickCount - uLastClickTime; +// writeln('diff: ', t, ' DoubleClick_MS:', DOUBLECLICK_MS); + if uLastClickWidget = self then + IsDblClick := (t) <= DOUBLECLICK_MS // we detected a double click + else + uLastClickWidget := self; + uLastClickTime := fpgGetTickCount; +// Writeln('IsDblClick: ', IsDblClick); + if IsDblClick then + begin + HandleDoubleClick(msg.Params.mouse.x, msg.Params.mouse.y, msg.Params.mouse.Buttons, msg.Params.mouse.shiftstate); + if Assigned(FOnDoubleClick) then + FOnDoubleClick(self, mb, msg.Params.mouse.shiftstate, + Point(msg.Params.mouse.x, msg.Params.mouse.y)); + end + else + HandleLMouseUp(msg.Params.mouse.x, msg.Params.mouse.y, msg.Params.mouse.shiftstate); end; MOUSE_RIGHT: begin @@ -323,7 +352,7 @@ begin mb := mbMiddle; end; end; - if Assigned(FOnMouseUp) then + if Assigned(FOnMouseUp) and not IsDblClick then FOnMouseUp(self, mb, msg.Params.mouse.shiftstate, Point(msg.Params.mouse.x, msg.Params.mouse.y)); end; @@ -338,6 +367,7 @@ end; procedure TfpgWidget.MsgDoubleClick(var msg: TfpgMessageRec); begin +(* // If we don't generate a mouse down, we get a rapid click // delay under Windows. HandleLMouseDown(msg.Params.mouse.x, msg.Params.mouse.y, msg.Params.mouse.shiftstate); @@ -347,6 +377,7 @@ begin if Assigned(FOnDoubleClick) then FOnDoubleClick(self, mbLeft, msg.Params.mouse.shiftstate, Point(msg.Params.mouse.x, msg.Params.mouse.y)); +*) end; procedure TfpgWidget.MsgMouseEnter(var msg: TfpgMessageRec); @@ -860,6 +891,8 @@ end; initialization FocusRootWidget := nil; + uLastClickWidget := nil; + uLastClickTime := 0; end. diff --git a/src/corelib/gfxbase.pas b/src/corelib/gfxbase.pas index 7d6b34b0..7b26daf0 100644 --- a/src/corelib/gfxbase.pas +++ b/src/corelib/gfxbase.pas @@ -384,19 +384,19 @@ type { ******** Helper functions ******** } { Keyboard } -function KeycodeToText(AKey: Word; AShiftState: TShiftState): string; -function CheckClipboardKey(AKey: Word; AShiftstate: TShiftState): TClipboardKeyType; +function KeycodeToText(AKey: Word; AShiftState: TShiftState): string; +function CheckClipboardKey(AKey: Word; AShiftstate: TShiftState): TClipboardKeyType; { Color } -function fpgColorToRGBTriple(const AColor: TfpgColor): TRGBTriple; -function RGBTripleTofpgColor(const AColor: TRGBTriple): TfpgColor; -function fpgGetRed(const AColor: TfpgColor): word; -function fpgGetGreen(const AColor: TfpgColor): word; -function fpgGetBlue(const AColor: TfpgColor): word; -function fpgGetAlpha(const AColor: TfpgColor): word; +function fpgColorToRGBTriple(const AColor: TfpgColor): TRGBTriple; +function RGBTripleTofpgColor(const AColor: TRGBTriple): TfpgColor; +function fpgGetRed(const AColor: TfpgColor): word; +function fpgGetGreen(const AColor: TfpgColor): word; +function fpgGetBlue(const AColor: TfpgColor): word; +function fpgGetAlpha(const AColor: TfpgColor): word; { Points } -function PtInRect(const ARect: TfpgRect; const APoint: TPoint): Boolean; +function PtInRect(const ARect: TfpgRect; const APoint: TPoint): Boolean; procedure SortRect(var ARect: TRect); procedure SortRect(var left, top, right, bottom: integer); |