From: Andreas H. <ah...@us...> - 2004-05-16 11:01:11
|
Update of /cvsroot/jvcl/dev/JVCL3/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26324/run Modified Files: JvEasterEgg.pas JvEnterTab.pas JvMouseGesture.pas JvPageManager.pas Log Message: CLX compatible Index: JvEnterTab.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/run/JvEnterTab.pas,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** JvEnterTab.pas 15 May 2004 11:28:15 -0000 1.10 --- JvEnterTab.pas 16 May 2004 11:00:57 -0000 1.11 *************** *** 37,41 **** {$ENDIF VCL} {$IFDEF VisualCLX} ! Qt, QGraphics, QControls, QWindows, {$ENDIF VisualCLX} JvComponent; --- 37,41 ---- {$ENDIF VCL} {$IFDEF VisualCLX} ! Qt, QGraphics, QControls, QForms, QWindows, {$ENDIF VisualCLX} JvComponent; Index: JvEasterEgg.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/run/JvEasterEgg.pas,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** JvEasterEgg.pas 31 Mar 2004 07:43:15 -0000 1.4 --- JvEasterEgg.pas 16 May 2004 11:00:56 -0000 1.5 *************** *** 31,35 **** uses ! Messages, SysUtils, Classes, Controls, Forms, Windows, JvComponent; --- 31,41 ---- uses ! SysUtils, Classes, ! {$IFDEF VCL} ! Windows, Messages, Controls, Forms, ! {$ENDIF VCL} ! {$IFDEF VisualCLX} ! Qt, QControls, QForms, Types, QWindows, ! {$ENDIF VisualCLX} JvComponent; *************** *** 43,47 **** --- 49,58 ---- FForm: TCustomForm; FCurString: string; + {$IFDEF VCL} function NewWndProc(var Msg: TMessage): Boolean; + {$ENDIF VCL} + {$IFDEF VisualCLX} + function NewEventFilter(Sender: QObjectH; Event: QEventH): Boolean; + {$ENDIF VisualCLX} public constructor Create(AOwner: TComponent); override; *************** *** 56,63 **** implementation uses JvWndProcHook; ! ! // (rom) added by me. Should go to JCL function DownCase(Ch: Char): Char; --- 67,74 ---- implementation + {$IFDEF VCL} uses JvWndProcHook; ! {$ENDIF VCL} function DownCase(Ch: Char): Char; *************** *** 77,81 **** --- 88,97 ---- FForm := GetParentForm(TControl(AOwner)); if (FForm <> nil) and not (csDesigning in ComponentState) then + {$IFDEF VCL} RegisterWndProcHook(FForm, NewWndProc, hoAfterMsg); + {$ENDIF VCL} + {$IFDEF VisualCLX} + InstallApplicationHook(NewEventFilter); + {$ENDIF VisualCLX} end; *************** *** 83,90 **** --- 99,112 ---- begin if (FForm <> nil) and not (csDesigning in ComponentState) then + {$IFDEF VCL} UnregisterWndProcHook(FForm, NewWndProc, hoAfterMsg); + {$ENDIF VCL} + {$IFDEF VisualCLX} + UninstallApplicationHook(NewEventFilter); + {$ENDIF VisualCLX} inherited Destroy; end; + {$IFDEF VCL} function TJvEasterEgg.NewWndProc(var Msg: TMessage): Boolean; var *************** *** 95,100 **** with Msg do begin - // (rom) simplified - // Result := CallWindowProc(FOldWndProc, FForm.Handle, Msg, WParam, LParam); if FActive and (FEgg <> '') then case Msg of --- 117,120 ---- *************** *** 123,126 **** --- 143,186 ---- end; end; + {$ENDIF VCL} + {$IFDEF VisualCLX} + function TJvEasterEgg.NewEventFilter(Sender: QObjectH; Event: QEventH): Boolean; + var + Shift: TShiftState; + KeyCode: Word; + KeyChar: Char; + begin + Result := False; + if Active and (FEgg <> '') and (QEvent_type(Event) = QEventType_KeyRelease) then + begin + KeyCode := QKeyEvent_key(QKeyEventH(Event)); + KeyChar := Char(QKeyEvent_ascii(QKeyEventH(Event))); + Shift := ButtonStateToShiftState(QKeyEvent_state(QKeyEventH(Event))); + if (KeyCode = Key_Shift) then + Include(Shift, ssShift); + if (KeyCode = Key_Control) then + Include(Shift, ssCtrl); + if (KeyCode = Key_Alt) then + Include(Shift, ssAlt); + + if Shift = FControlKeys then + begin + if ssShift in Shift then + FCurString := FCurString + UpCase(KeyChar) + else + FCurString := FCurString + DownCase(KeyChar); + if FCurString = Egg then + begin + if Assigned(FOnEggFound) then + FOnEggFound(Self); + FCurString := ''; + end + else + if Length(FCurString) >= Length(Egg) then + FCurString := Copy(FCurString, 2, Length(Egg)); + end; + end; + end; + {$ENDIF VisualCLX} end. Index: JvPageManager.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/run/JvPageManager.pas,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** JvPageManager.pas 14 May 2004 22:49:43 -0000 1.8 --- JvPageManager.pas 16 May 2004 11:00:57 -0000 1.9 *************** *** 34,38 **** {$ENDIF VCL} {$IFDEF VisualCLX} ! QControls, QForms, QStdCtrls, QExtCtrls, QActnList, {$ENDIF VisualCLX} SysUtils, Classes; --- 34,38 ---- {$ENDIF VCL} {$IFDEF VisualCLX} ! QControls, QForms, QStdCtrls, QExtCtrls, QActnList, QNotebook, {$ENDIF VisualCLX} SysUtils, Classes; *************** *** 190,194 **** implementation - // (rom) changed to var var Registered: Boolean = False; --- 190,193 ---- *************** *** 206,210 **** if FPageManager <> nil then FPageManager.RemoveProxy(Self); - //if (FPageName <> nil) and (FPageName^ <> '') then Dispose(FPageName); inherited Destroy; end; --- 205,208 ---- Index: JvMouseGesture.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/run/JvMouseGesture.pas,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** JvMouseGesture.pas 15 May 2004 07:00:04 -0000 1.16 --- JvMouseGesture.pas 16 May 2004 11:00:57 -0000 1.17 *************** *** 52,56 **** Known Issues: - - Port to Kylix for hook class -----------------------------------------------------------------------------} // $Id$ --- 52,55 ---- *************** *** 63,74 **** uses ! SysUtils, Classes, Dialogs, ! {$IFDEF MSWINDOWS} ! Windows, Messages, Forms, JvComponent; - {$ENDIF MSWINDOWS} - {$IFDEF LINUX} - QForms; - {$ENDIF LINUX} type --- 62,73 ---- uses ! SysUtils, Classes, ! {$IFDEF VCL} ! Windows, Messages, ! {$ENDIF VCL} ! {$IFDEF VisualCLX} ! Qt, QControls, QForms, Types, QWindows, ! {$ENDIF VisualCLX} JvComponent; type *************** *** 320,325 **** end; - {$IFDEF MSWINDOWS} - { Description This class implements a application wide mouse hook for mouse gestures. --- 319,322 ---- *************** *** 337,340 **** --- 334,338 ---- } FHookInstalled: Boolean; + {$IFDEF VCL} { Description Field for hook handle *************** *** 344,347 **** --- 342,346 ---- Field for method pointer } + {$ENDIF VCL} FOnJvMouseGestureCustomInterpretation: TOnJvMouseGestureCustomInterpretation; { Description *************** *** 391,394 **** --- 390,394 ---- TRUE if hook was installed successfully } + {$IFDEF VCL} property HookInstalled: Boolean read FHookInstalled; //True if a hook is installed { Description *************** *** 396,399 **** --- 396,400 ---- } property CurrentHook: HHook read FCurrentHook; //contains the handle of the currently installed hook + {$ENDIF VCL} published { Description *************** *** 421,424 **** --- 422,426 ---- end; + {$IFDEF VCL} { Description Hook call back function. *************** *** 426,435 **** } function JvMouseGestureHook(code: Integer; wParam: Word; lParam: Longword): Longword; stdcall; ! ! {$ENDIF MSWINDOWS} ! ! {$IFDEF LINUX} ! // to be done in a later version ! {$ENDIF LINUX} implementation --- 428,435 ---- } function JvMouseGestureHook(code: Integer; wParam: Word; lParam: Longword): Longword; stdcall; ! {$ENDIF VCL} ! {$IFDEF VisualCLX} ! function JvMouseGestureHook(App: TObject; Sender: QObjectH; Event: QEventH): Boolean; ! {$ENDIF VisualCLX} implementation *************** *** 459,462 **** --- 459,463 ---- //<combine JvMouseGestureHookAlreadyInstalled> JvMouseGestureHookActive: Boolean = False; + {$IFDEF VCL} //<combine JvMouseGestureHookAlreadyInstalled> JvMouseButtonDown: Cardinal = WM_RBUTTONDOWN; *************** *** 464,470 **** JvMouseButtonUp: Cardinal = WM_RBUTTONUP; - {$IFDEF MSWINDOWS} JvCurrentHook: HHook = 0; //contains the handle of the currently installed hook ! {$ENDIF MSWINDOWS} //=== TJvMouseGesture ======================================================== --- 465,476 ---- JvMouseButtonUp: Cardinal = WM_RBUTTONUP; JvCurrentHook: HHook = 0; //contains the handle of the currently installed hook ! {$ENDIF VCL} ! {$IFDEF VisualCLX} ! //<combine JvMouseGestureHookAlreadyInstalled> ! JvMouseButtonDown: ButtonState = ButtonState_RightButton; ! //<combine JvMouseGestureHookAlreadyInstalled> ! JvMouseButtonUp: ButtonState = ButtonState_RightButton; ! {$ENDIF VisualCLX} //=== TJvMouseGesture ======================================================== *************** *** 491,498 **** begin FTrailActive := False; ! try ! FreeAndNil(FGestureList); ! except ! end; inherited Destroy; end; --- 497,501 ---- begin FTrailActive := False; ! FreeAndNil(FGestureList); inherited Destroy; end; *************** *** 802,807 **** //=== TJvMouseGestureHook ==================================================== - {$IFDEF MSWINDOWS} - constructor TJvMouseGestureHook.Create(AOwner: TComponent); begin --- 805,808 ---- *************** *** 811,834 **** destructor TJvMouseGestureHook.Destroy; begin FreeAndNil(JvMouseGestureInterpreter); if JvMouseGestureHookAlreadyInstalled then JvMouseGestureHookAlreadyInstalled := UnhookWindowsHookEx(JvCurrentHook); inherited Destroy; end; procedure TJvMouseGestureHook.CreateForThreadOrSystem(AOwner: TComponent; ADwThreadID: Cardinal); begin if JvMouseGestureHookAlreadyInstalled then - begin raise EJVCLException.CreateRes(@RsECannotHookTwice); - Halt; - end; JvMouseGestureInterpreter := TJvMouseGesture.Create(nil); - FMouseButton := JvMButtonRight; - if csDesigning in ComponentState then begin --- 812,848 ---- destructor TJvMouseGestureHook.Destroy; + {$IFDEF VisualCLX} + var + Method: TMethod; + {$ENDIF VisualCLX} begin FreeAndNil(JvMouseGestureInterpreter); if JvMouseGestureHookAlreadyInstalled then + {$IFDEF VCL} JvMouseGestureHookAlreadyInstalled := UnhookWindowsHookEx(JvCurrentHook); + {$ENDIF VCL} + {$IFDEF VisualCLX} + begin + Method.Code := @JvMouseGestureHook; + Method.Data := nil; + UninstallApplicationHook(TApplicationHook(Method)); + JvMouseGestureHookAlreadyInstalled := False; + end; + {$ENDIF VisualCLX} inherited Destroy; end; procedure TJvMouseGestureHook.CreateForThreadOrSystem(AOwner: TComponent; ADwThreadID: Cardinal); + {$IFDEF VisualCLX} + var + Method: TMethod; + {$ENDIF VisualCLX} begin if JvMouseGestureHookAlreadyInstalled then raise EJVCLException.CreateRes(@RsECannotHookTwice); JvMouseGestureInterpreter := TJvMouseGesture.Create(nil); FMouseButton := JvMButtonRight; if csDesigning in ComponentState then begin *************** *** 839,842 **** --- 853,857 ---- FActive := FActivationMode = JvOnAppStart; + {$IFDEF VCL} //install hook FCurrentHook := SetWindowsHookEx(WH_MOUSE, @JvMouseGestureHook, 0, ADwThreadID); *************** *** 849,852 **** --- 864,876 ---- JvMouseGestureHookAlreadyInstalled := FHookInstalled; JvCurrentHook := FCurrentHook; + {$ENDIF VCL} + {$IFDEF VisualCLX} + Method.Code := @JvMouseGestureHook; + Method.Data := Self; + InstallApplicationHook(TApplicationHook(Method)); + + JvMouseGestureHookAlreadyInstalled := True; + FHookInstalled := True; + {$ENDIF VisualCLX} // map event *************** *** 856,860 **** else JvMouseGestureInterpreter.OnJvMouseGestureCustomInterpretation := nil; - end; --- 880,883 ---- *************** *** 877,880 **** --- 900,904 ---- begin FMouseButton := Value; + {$IFDEF VCL} case Value of JvMButtonLeft: *************** *** 894,897 **** --- 918,941 ---- end; end; + {$ENDIF VCL} + {$IFDEF VisualCLX} + case Value of + JvMButtonLeft: + begin + JvMouseButtonDown := ButtonState_LeftButton; + JvMouseButtonUp := ButtonState_LeftButton; + end; + JvMButtonMiddle: + begin + JvMouseButtonDown := ButtonState_MidButton; + JvMouseButtonUp := ButtonState_MidButton; + end; + JvMButtonRight: + begin + JvMouseButtonDown := ButtonState_RightButton; + JvMouseButtonUp := ButtonState_RightButton; + end; + end; + {$ENDIF VisualCLX} end; *************** *** 906,909 **** --- 950,954 ---- //============================================================================ + {$IFDEF VCL} function JvMouseGestureHook(Code: Integer; wParam: Word; lParam: Longword): Longword; stdcall; var *************** *** 916,922 **** Exit; end; - Result := Code; - if not JvMouseGestureHookActive then Exit; --- 961,965 ---- *************** *** 936,945 **** JvMouseGestureInterpreter.EndMouseGesture; end; ! {$ENDIF MSWINDOWS} ! ! {$IFDEF LINUX} ! {$ENDIF LINUX} end. --- 979,1024 ---- JvMouseGestureInterpreter.EndMouseGesture; end; + {$ENDIF VCL} ! {$IFDEF VisualCLX} ! function JvMouseGestureHook(App: TObject; Sender: QObjectH; Event: QEventH): Boolean; ! var ! locY: Integer; ! locX: Integer; ! etype: QEventType; ! Btn: ButtonState; ! begin ! Result := False; ! if not JvMouseGestureHookActive then ! Exit; ! etype := QEvent_type(Event); ! case etype of ! QEventType_MouseButtonPress, ! QEventType_MouseButtonRelease, ! QEventType_MouseMove: ! begin ! locX := QMouseEvent_globalX(QMouseEventH(Event)); ! locY := QMouseEvent_globalY(QMouseEventH(Event)); ! Btn := QMouseEvent_button(QMouseEventH(Event)); ! case etype of ! QEventType_MouseMove: ! JvMouseGestureInterpreter.TrailMouseGesture(locX, locY); ! QEventType_MouseButtonPress: ! begin ! if Btn = JvMouseButtonDown then ! JvMouseGestureInterpreter.StartMouseGesture(locX, locY); ! end; ! QEventType_MouseButtonRelease: ! begin ! if Btn = JvMouseButtonUp then ! JvMouseGestureInterpreter.EndMouseGesture; ! end; ! end; ! Result := True; ! end; ! end; ! end; ! {$ENDIF VisualCLX} end. |