|
@@ -16,6 +16,7 @@ uses
|
|
System.Skia, Fresnel.SkiaRenderer,
|
|
System.Skia, Fresnel.SkiaRenderer,
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
// fresnel
|
|
// fresnel
|
|
|
|
+ UTF8Utils,
|
|
Fresnel.Classes, Fresnel.Forms, Fresnel.WidgetSet, Fresnel.DOM,
|
|
Fresnel.Classes, Fresnel.Forms, Fresnel.WidgetSet, Fresnel.DOM,
|
|
Fresnel.Events, FCL.Events;
|
|
Fresnel.Events, FCL.Events;
|
|
|
|
|
|
@@ -50,6 +51,8 @@ type
|
|
function GetClientSize: TFresnelPoint; override;
|
|
function GetClientSize: TFresnelPoint; override;
|
|
procedure Invalidate; override;
|
|
procedure Invalidate; override;
|
|
procedure InvalidateRect(const aRect: TFresnelRect); override;
|
|
procedure InvalidateRect(const aRect: TFresnelRect); override;
|
|
|
|
+ procedure HandleMouseMsg(XPos,YPos: longint; MouseEventId: TEventID;
|
|
|
|
+ Button: TMouseButton; Shiftstate: TShiftState); virtual;
|
|
function HandlePaintMsg: LRESULT; virtual;
|
|
function HandlePaintMsg: LRESULT; virtual;
|
|
procedure HandleSizeMsg; virtual;
|
|
procedure HandleSizeMsg; virtual;
|
|
public
|
|
public
|
|
@@ -85,14 +88,27 @@ type
|
|
end;
|
|
end;
|
|
PWinApiWindowInfo = ^TWinApiWindowInfo;
|
|
PWinApiWindowInfo = ^TWinApiWindowInfo;
|
|
|
|
|
|
-
|
|
|
|
var
|
|
var
|
|
WinApiWidgetSet: TWinApiWidgetSet;
|
|
WinApiWidgetSet: TWinApiWidgetSet;
|
|
WindowInfoAtom: ATOM;
|
|
WindowInfoAtom: ATOM;
|
|
WindowInfoAtomStr: LPCSTR;
|
|
WindowInfoAtomStr: LPCSTR;
|
|
|
|
|
|
|
|
+function KeyboardStateToShiftState: TShiftState;
|
|
|
|
+procedure CreateDrawBuffer(const aMemDC: HDC; const aWidth, aHeight: Integer;
|
|
|
|
+ out aBuffer: HBITMAP; out aData: Pointer; out aStride: Integer);
|
|
|
|
+
|
|
implementation
|
|
implementation
|
|
|
|
|
|
|
|
+function KeyboardStateToShiftState: TShiftState;
|
|
|
|
+begin
|
|
|
|
+ Result := [];
|
|
|
|
+ if GetKeyState(VK_SHIFT) < 0 then Include(Result, ssShift);
|
|
|
|
+ if GetKeyState(VK_CONTROL) < 0 then Include(Result, ssCtrl);
|
|
|
|
+ if GetKeyState(VK_MENU) < 0 then Include(Result, ssAlt);
|
|
|
|
+ if (GetKeyState(VK_LWIN) < 0) or
|
|
|
|
+ (GetKeyState(VK_RWIN) < 0) then Include(Result, ssMeta);
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure CreateDrawBuffer(const aMemDC: HDC; const aWidth, aHeight: Integer;
|
|
procedure CreateDrawBuffer(const aMemDC: HDC; const aWidth, aHeight: Integer;
|
|
out aBuffer: HBITMAP; out aData: Pointer; out aStride: Integer);
|
|
out aBuffer: HBITMAP; out aData: Pointer; out aStride: Integer);
|
|
const
|
|
const
|
|
@@ -153,9 +169,28 @@ end;
|
|
|
|
|
|
function WindowProc(aHandle: HWND; aMsg: UINT; aWParam: WPARAM; aLParam: LPARAM): LRESULT; stdcall;
|
|
function WindowProc(aHandle: HWND; aMsg: UINT; aWParam: WPARAM; aLParam: LPARAM): LRESULT; stdcall;
|
|
var
|
|
var
|
|
- XPos, YPos: LongInt;
|
|
|
|
- aWndInfo: PWinApiWindowInfo;
|
|
|
|
aForm: TWinApiWSForm;
|
|
aForm: TWinApiWSForm;
|
|
|
|
+
|
|
|
|
+ function DoMouseMsg(MouseEvt: TEventID; Button: TMouseButton): LRESULT;
|
|
|
|
+ var
|
|
|
|
+ XPos, YPos: LongInt;
|
|
|
|
+ ShiftState: TShiftState;
|
|
|
|
+ begin
|
|
|
|
+ XPos := GET_X_LPARAM(aLParam);
|
|
|
|
+ YPos := GET_Y_LPARAM(aLParam);
|
|
|
|
+ ShiftState:=KeyboardStateToShiftState;
|
|
|
|
+ if MK_LBUTTON and aWParam>0 then
|
|
|
|
+ Include(ShiftState,ssLeft);
|
|
|
|
+ if MK_RBUTTON and aWParam>0 then
|
|
|
|
+ Include(ShiftState,ssRight);
|
|
|
|
+ if MK_MBUTTON and aWParam>0 then
|
|
|
|
+ Include(ShiftState,ssMiddle);
|
|
|
|
+ aForm.HandleMouseMsg(XPos,YPos,MouseEvt,Button,ShiftState);
|
|
|
|
+ Result:=0;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+var
|
|
|
|
+ aWndInfo: PWinApiWindowInfo;
|
|
begin
|
|
begin
|
|
aWndInfo:=GetWinApiWindowInfo(aHandle);
|
|
aWndInfo:=GetWinApiWindowInfo(aHandle);
|
|
if aWndInfo<>nil then
|
|
if aWndInfo<>nil then
|
|
@@ -185,13 +220,22 @@ begin
|
|
writeln('KeyUp: ',aWParam);
|
|
writeln('KeyUp: ',aWParam);
|
|
exit(0);
|
|
exit(0);
|
|
end;
|
|
end;
|
|
- WM_LBUTTONDOWN:
|
|
|
|
- begin
|
|
|
|
- XPos := GET_X_LPARAM(aLParam);
|
|
|
|
- YPos := GET_Y_LPARAM(aLParam);
|
|
|
|
- writeln('LButtonDown ',XPos,',',YPos);
|
|
|
|
- exit(0);
|
|
|
|
- end;
|
|
|
|
|
|
+
|
|
|
|
+ //WM_LBUTTONDBLCLK: exit(DoMouseMsg(1, True, True));
|
|
|
|
+ WM_LBUTTONDOWN: exit(DoMouseMsg(evtMouseDown,mbLeft));
|
|
|
|
+ WM_LBUTTONUP: exit(DoMouseMsg(evtMouseUp,mbLeft));
|
|
|
|
+ //WM_RBUTTONDBLCLK: exit(DoMouseMsg(2, True, True));
|
|
|
|
+ WM_RBUTTONDOWN: exit(DoMouseMsg(evtMouseDown,mbRight));
|
|
|
|
+ WM_RBUTTONUP: exit(DoMouseMsg(evtMouseUp,mbRight));
|
|
|
|
+ //WM_MBUTTONDBLCLK: exit(DoMouseMsg(3, True, True));
|
|
|
|
+ WM_MBUTTONDOWN: exit(DoMouseMsg(evtMouseDown,mbMiddle));
|
|
|
|
+ WM_MBUTTONUP: exit(DoMouseMsg(evtMouseUp,mbMiddle));
|
|
|
|
+ //WM_XBUTTONDBLCLK: exit(DoMouseMsg(4, True, True));
|
|
|
|
+ WM_XBUTTONDOWN: exit(DoMouseMsg(evtMouseDown,mbFourth));
|
|
|
|
+ WM_XBUTTONUP: exit(DoMouseMsg(evtMouseUp,mbFourth));
|
|
|
|
+
|
|
|
|
+ WM_MOUSEMOVE: exit(DoMouseMsg(evtMouseMove,mbLeft));
|
|
|
|
+
|
|
WM_CLOSE:
|
|
WM_CLOSE:
|
|
begin
|
|
begin
|
|
PostQuitMessage(0);
|
|
PostQuitMessage(0);
|
|
@@ -388,6 +432,31 @@ begin
|
|
Windows.InvalidateRect(FWindow,aRect.GetRect,true);
|
|
Windows.InvalidateRect(FWindow,aRect.GetRect,true);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TWinApiWSForm.HandleMouseMsg(XPos, YPos: longint;
|
|
|
|
+ MouseEventId: TEventID; Button: TMouseButton; Shiftstate: TShiftState);
|
|
|
|
+var
|
|
|
|
+ WSData: TFresnelMouseEventInit;
|
|
|
|
+ p: TPoint;
|
|
|
|
+begin
|
|
|
|
+ WSData:=Default(TFresnelMouseEventInit);
|
|
|
|
+ WSData.Button:=Button;
|
|
|
|
+ WSData.PagePos.X:=XPos;
|
|
|
|
+ WSData.PagePos.Y:=YPos;
|
|
|
|
+ // Note: WSData.ControlPos is set by Form.WSMouseXY
|
|
|
|
+ Windows.GetCursorPos(p);
|
|
|
|
+ WSData.ScreenPos.SetLocation(p);
|
|
|
|
+ WSData.Shiftstate:=ShiftState;
|
|
|
|
+ if ssLeft in Shiftstate then
|
|
|
|
+ Include(WSData.Buttons,mbLeft);
|
|
|
|
+ if ssRight in Shiftstate then
|
|
|
|
+ Include(WSData.Buttons,mbRight);
|
|
|
|
+ if ssMiddle in Shiftstate then
|
|
|
|
+ Include(WSData.Buttons,mbMiddle);
|
|
|
|
+
|
|
|
|
+ //writeln('TWinApiWSForm.HandleMouseMsg ',XPos,',',YPos,' ',MouseEventId,' ',Button);
|
|
|
|
+ Form.WSMouseXY(WSData,MouseEventId);
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TWinApiWSForm.HandleSizeMsg;
|
|
procedure TWinApiWSForm.HandleSizeMsg;
|
|
var
|
|
var
|
|
aFormRect, aClientRect: TRect;
|
|
aFormRect, aClientRect: TRect;
|
|
@@ -514,7 +583,7 @@ begin
|
|
if ATitle='' then ;
|
|
if ATitle='' then ;
|
|
//if FAppHandle <> 0 then
|
|
//if FAppHandle <> 0 then
|
|
//begin
|
|
//begin
|
|
- // ws:=ATitle;
|
|
|
|
|
|
+ // ws:=UTF8ToUTF16(ATitle);
|
|
// todo: TWinApiWidgetSet.AppSetTitle
|
|
// todo: TWinApiWidgetSet.AppSetTitle
|
|
//Windows.SetWindowTextW(FAppHandle, PWideChar(ws));
|
|
//Windows.SetWindowTextW(FAppHandle, PWideChar(ws));
|
|
//end;
|
|
//end;
|