|
@@ -22,13 +22,13 @@ uses
|
|
|
|
|
|
type
|
|
|
{$IFDEF FresnelSkia}
|
|
|
- TWinApiFontEngine = TFresnelSkiaFontEngine;
|
|
|
- TWinApiRenderer = TFresnelSkiaRenderer;
|
|
|
+ TWin32FontEngine = TFresnelSkiaFontEngine;
|
|
|
+ TWin32Renderer = TFresnelSkiaRenderer;
|
|
|
{$ENDIF}
|
|
|
|
|
|
- { TWinApiWSForm }
|
|
|
+ { TWin32WSForm }
|
|
|
|
|
|
- TWinApiWSForm = class(TFresnelWSForm)
|
|
|
+ TWin32WSForm = class(TFresnelWSForm)
|
|
|
private
|
|
|
FForm: TFresnelCustomForm;
|
|
|
FWindow: HWND;
|
|
@@ -65,11 +65,11 @@ type
|
|
|
property Form: TFresnelCustomForm read FForm write SetForm;
|
|
|
end;
|
|
|
|
|
|
- { TWinApiWidgetSet }
|
|
|
+ { TWin32WidgetSet }
|
|
|
|
|
|
- TWinApiWidgetSet = class(TFresnelWidgetSet)
|
|
|
+ TWin32WidgetSet = class(TFresnelWidgetSet)
|
|
|
private
|
|
|
- FFontEngine: TWinApiFontEngine;
|
|
|
+ FFontEngine: TWin32FontEngine;
|
|
|
public
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
destructor Destroy; override;
|
|
@@ -79,17 +79,17 @@ type
|
|
|
procedure AppSetTitle(const ATitle: string); override;
|
|
|
|
|
|
procedure CreateWSForm(aFresnelForm: TFresnelComponent); override;
|
|
|
- property FontEngineWinApi: TWinApiFontEngine read FFontEngine;
|
|
|
+ property FontEngineWin32: TWin32FontEngine read FFontEngine;
|
|
|
end;
|
|
|
|
|
|
type
|
|
|
- TWinApiWindowInfo = record
|
|
|
- Form: TWinApiWSForm;
|
|
|
+ TWin32WindowInfo = record
|
|
|
+ Form: TWin32WSForm;
|
|
|
end;
|
|
|
- PWinApiWindowInfo = ^TWinApiWindowInfo;
|
|
|
+ PWin32WindowInfo = ^TWin32WindowInfo;
|
|
|
|
|
|
var
|
|
|
- WinApiWidgetSet: TWinApiWidgetSet;
|
|
|
+ Win32WidgetSet: TWin32WidgetSet;
|
|
|
WindowInfoAtom: ATOM;
|
|
|
WindowInfoAtomStr: LPCSTR;
|
|
|
|
|
@@ -140,21 +140,21 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-function AllocWindowInfo(Window: HWND): PWinApiWindowInfo;
|
|
|
+function AllocWindowInfo(Window: HWND): PWin32WindowInfo;
|
|
|
var
|
|
|
- WindowInfo: PWinApiWindowInfo;
|
|
|
+ WindowInfo: PWin32WindowInfo;
|
|
|
begin
|
|
|
New(WindowInfo);
|
|
|
- WindowInfo^ := Default(TWinApiWindowInfo);
|
|
|
+ WindowInfo^ := Default(TWin32WindowInfo);
|
|
|
Windows.SetProp(Window, WindowInfoAtomStr, {%H-}PtrUInt(WindowInfo));
|
|
|
Result := WindowInfo;
|
|
|
end;
|
|
|
|
|
|
function DisposeWindowInfo(Window: HWND): boolean;
|
|
|
var
|
|
|
- WindowInfo: PWinApiWindowInfo;
|
|
|
+ WindowInfo: PWin32WindowInfo;
|
|
|
begin
|
|
|
- WindowInfo := {%H-}PWinApiWindowInfo(Windows.GetProp(Window, WindowInfoAtomStr));
|
|
|
+ WindowInfo := {%H-}PWin32WindowInfo(Windows.GetProp(Window, WindowInfoAtomStr));
|
|
|
Result := Windows.RemoveProp(Window, WindowInfoAtomStr) <> 0;
|
|
|
if Result then
|
|
|
begin
|
|
@@ -162,14 +162,14 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-function GetWinApiWindowInfo(Window: HWND): PWinApiWindowInfo;
|
|
|
+function GetWin32WindowInfo(Window: HWND): PWin32WindowInfo;
|
|
|
begin
|
|
|
- Result := {%H-}PWinApiWindowInfo(Windows.GetProp(Window, WindowInfoAtomStr));
|
|
|
+ Result := {%H-}PWin32WindowInfo(Windows.GetProp(Window, WindowInfoAtomStr));
|
|
|
end;
|
|
|
|
|
|
function WindowProc(aHandle: HWND; aMsg: UINT; aWParam: WPARAM; aLParam: LPARAM): LRESULT; stdcall;
|
|
|
var
|
|
|
- aForm: TWinApiWSForm;
|
|
|
+ aForm: TWin32WSForm;
|
|
|
|
|
|
function DoMouseMsg(MouseEvt: TEventID; Button: TMouseButton): LRESULT;
|
|
|
var
|
|
@@ -190,9 +190,9 @@ var
|
|
|
end;
|
|
|
|
|
|
var
|
|
|
- aWndInfo: PWinApiWindowInfo;
|
|
|
+ aWndInfo: PWin32WindowInfo;
|
|
|
begin
|
|
|
- aWndInfo:=GetWinApiWindowInfo(aHandle);
|
|
|
+ aWndInfo:=GetWin32WindowInfo(aHandle);
|
|
|
if aWndInfo<>nil then
|
|
|
begin
|
|
|
aForm:=aWndInfo^.Form;
|
|
@@ -248,9 +248,9 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-{ TWinApiWSForm }
|
|
|
+{ TWin32WSForm }
|
|
|
|
|
|
-procedure TWinApiWSForm.SetForm(AValue: TFresnelCustomForm);
|
|
|
+procedure TWin32WSForm.SetForm(AValue: TFresnelCustomForm);
|
|
|
begin
|
|
|
if FForm=AValue then Exit;
|
|
|
FForm:=AValue;
|
|
@@ -258,7 +258,7 @@ begin
|
|
|
FreeNotification(FForm);
|
|
|
end;
|
|
|
|
|
|
-procedure TWinApiWSForm.Notification(AComponent: TComponent; Operation: TOperation
|
|
|
+procedure TWin32WSForm.Notification(AComponent: TComponent; Operation: TOperation
|
|
|
);
|
|
|
begin
|
|
|
inherited Notification(AComponent, Operation);
|
|
@@ -269,7 +269,7 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-function TWinApiWSForm.GetFormBounds: TFresnelRect;
|
|
|
+function TWin32WSForm.GetFormBounds: TFresnelRect;
|
|
|
var
|
|
|
r: TRect;
|
|
|
begin
|
|
@@ -280,20 +280,20 @@ begin
|
|
|
Result.SetRect(r);
|
|
|
end;
|
|
|
|
|
|
-function TWinApiWSForm.GetCaption: TFresnelCaption;
|
|
|
+function TWin32WSForm.GetCaption: TFresnelCaption;
|
|
|
begin
|
|
|
Result:='';
|
|
|
- // todo: TWinApiWSForm.GetCaption
|
|
|
- raise Exception.Create('TWinApiWSForm.GetCaption ToDo');
|
|
|
+ // todo: TWin32WSForm.GetCaption
|
|
|
+ raise Exception.Create('TWin32WSForm.GetCaption ToDo');
|
|
|
end;
|
|
|
|
|
|
-function TWinApiWSForm.GetVisible: boolean;
|
|
|
+function TWin32WSForm.GetVisible: boolean;
|
|
|
begin
|
|
|
- // todo: TWinApiWSForm.GetVisible
|
|
|
+ // todo: TWin32WSForm.GetVisible
|
|
|
Result:=true;
|
|
|
end;
|
|
|
|
|
|
-procedure TWinApiWSForm.DeleteDrawBuffer;
|
|
|
+procedure TWin32WSForm.DeleteDrawBuffer;
|
|
|
begin
|
|
|
if FDrawBuffer=0 then exit;
|
|
|
DeleteObject(FDrawBuffer);
|
|
@@ -301,7 +301,7 @@ begin
|
|
|
FDrawBufferData:=nil;
|
|
|
end;
|
|
|
|
|
|
-function TWinApiWSForm.HandlePaintMsg: LRESULT;
|
|
|
+function TWin32WSForm.HandlePaintMsg: LRESULT;
|
|
|
const
|
|
|
BlendFunction: TBlendFunction = (
|
|
|
BlendOp: AC_SRC_OVER;
|
|
@@ -371,7 +371,7 @@ begin
|
|
|
Result:=0;
|
|
|
end;
|
|
|
|
|
|
-procedure TWinApiWSForm.RegisterWindowClass(const aClassName: PChar);
|
|
|
+procedure TWin32WSForm.RegisterWindowClass(const aClassName: PChar);
|
|
|
var
|
|
|
wc: TWNDCLASS;
|
|
|
begin
|
|
@@ -384,24 +384,24 @@ begin
|
|
|
RegisterClass(wc);
|
|
|
end;
|
|
|
|
|
|
-procedure TWinApiWSForm.SetFormBounds(const AValue: TFresnelRect);
|
|
|
+procedure TWin32WSForm.SetFormBounds(const AValue: TFresnelRect);
|
|
|
var
|
|
|
r: TRect;
|
|
|
begin
|
|
|
r:=AValue.GetRect;
|
|
|
if not SetWindowPos(FWindow,0,r.Left,r.Top,r.Width,r.Height,0) then
|
|
|
begin
|
|
|
- // todo: handle TWinApiWSForm.SetFormBounds failed
|
|
|
+ // todo: handle TWin32WSForm.SetFormBounds failed
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-procedure TWinApiWSForm.SetCaption(AValue: TFresnelCaption);
|
|
|
+procedure TWin32WSForm.SetCaption(AValue: TFresnelCaption);
|
|
|
begin
|
|
|
- // todo: TWinApiWSForm.SetCaption
|
|
|
+ // todo: TWin32WSForm.SetCaption
|
|
|
if AValue='' then ;
|
|
|
end;
|
|
|
|
|
|
-procedure TWinApiWSForm.SetVisible(const AValue: boolean);
|
|
|
+procedure TWin32WSForm.SetVisible(const AValue: boolean);
|
|
|
var
|
|
|
CmdShow: longint;
|
|
|
begin
|
|
@@ -412,7 +412,7 @@ begin
|
|
|
ShowWindow(FWindow,CmdShow);
|
|
|
end;
|
|
|
|
|
|
-function TWinApiWSForm.GetClientSize: TFresnelPoint;
|
|
|
+function TWin32WSForm.GetClientSize: TFresnelPoint;
|
|
|
var
|
|
|
r: TRect;
|
|
|
begin
|
|
@@ -422,17 +422,17 @@ begin
|
|
|
Result.Y:=r.Height;
|
|
|
end;
|
|
|
|
|
|
-procedure TWinApiWSForm.Invalidate;
|
|
|
+procedure TWin32WSForm.Invalidate;
|
|
|
begin
|
|
|
Windows.InvalidateRect(FWindow,nil,true);
|
|
|
end;
|
|
|
|
|
|
-procedure TWinApiWSForm.InvalidateRect(const aRect: TFresnelRect);
|
|
|
+procedure TWin32WSForm.InvalidateRect(const aRect: TFresnelRect);
|
|
|
begin
|
|
|
Windows.InvalidateRect(FWindow,aRect.GetRect,true);
|
|
|
end;
|
|
|
|
|
|
-procedure TWinApiWSForm.HandleMouseMsg(XPos, YPos: longint;
|
|
|
+procedure TWin32WSForm.HandleMouseMsg(XPos, YPos: longint;
|
|
|
MouseEventId: TEventID; Button: TMouseButton; Shiftstate: TShiftState);
|
|
|
var
|
|
|
WSData: TFresnelMouseEventInit;
|
|
@@ -453,11 +453,11 @@ begin
|
|
|
if ssMiddle in Shiftstate then
|
|
|
Include(WSData.Buttons,mbMiddle);
|
|
|
|
|
|
- //writeln('TWinApiWSForm.HandleMouseMsg ',XPos,',',YPos,' ',MouseEventId,' ',Button);
|
|
|
+ //writeln('TWin32WSForm.HandleMouseMsg ',XPos,',',YPos,' ',MouseEventId,' ',Button);
|
|
|
Form.WSMouseXY(WSData,MouseEventId);
|
|
|
end;
|
|
|
|
|
|
-procedure TWinApiWSForm.HandleSizeMsg;
|
|
|
+procedure TWin32WSForm.HandleSizeMsg;
|
|
|
var
|
|
|
aFormRect, aClientRect: TRect;
|
|
|
FreRect: TFresnelRect;
|
|
@@ -476,13 +476,13 @@ begin
|
|
|
Form.WSResize(FreRect,aClientRect.Right,aClientRect.Bottom);
|
|
|
end;
|
|
|
|
|
|
-constructor TWinApiWSForm.Create(AOwner: TComponent);
|
|
|
+constructor TWin32WSForm.Create(AOwner: TComponent);
|
|
|
begin
|
|
|
inherited Create(AOwner);
|
|
|
- SetRenderer(TWinApiRenderer.Create(Self));
|
|
|
+ SetRenderer(TWin32Renderer.Create(Self));
|
|
|
end;
|
|
|
|
|
|
-destructor TWinApiWSForm.Destroy;
|
|
|
+destructor TWin32WSForm.Destroy;
|
|
|
begin
|
|
|
SetRenderer(Nil);
|
|
|
DestroyWSWindow;
|
|
@@ -490,13 +490,13 @@ begin
|
|
|
inherited Destroy;
|
|
|
end;
|
|
|
|
|
|
-function TWinApiWSForm.CreateWSWindow: HWND;
|
|
|
+function TWin32WSForm.CreateWSWindow: HWND;
|
|
|
const
|
|
|
// todo: create unique classname
|
|
|
aClassName = 'FresnelWindow';
|
|
|
var
|
|
|
aRect: TRect;
|
|
|
- Info: PWinApiWindowInfo;
|
|
|
+ Info: PWin32WindowInfo;
|
|
|
begin
|
|
|
aRect:=Form.FormBounds.GetRect;
|
|
|
|
|
@@ -511,53 +511,54 @@ begin
|
|
|
ShowWindow(FWindow,SW_SHOW);
|
|
|
end;
|
|
|
|
|
|
-procedure TWinApiWSForm.DestroyWSWindow;
|
|
|
+procedure TWin32WSForm.DestroyWSWindow;
|
|
|
begin
|
|
|
if FWindow=0 then exit;
|
|
|
DisposeWindowInfo(FWindow);
|
|
|
- // todo: TWinApiWSForm.DestroyWSWindow
|
|
|
+ // todo: TWin32WSForm.DestroyWSWindow
|
|
|
end;
|
|
|
|
|
|
-{ TWinApiWidgetSet }
|
|
|
+{ TWin32WidgetSet }
|
|
|
|
|
|
-constructor TWinApiWidgetSet.Create(AOwner: TComponent);
|
|
|
+constructor TWin32WidgetSet.Create(AOwner: TComponent);
|
|
|
begin
|
|
|
inherited Create(AOwner);
|
|
|
|
|
|
- WinApiWidgetSet:=Self;
|
|
|
- FWSFormClass:=TWinApiWSForm;
|
|
|
+ Win32WidgetSet:=Self;
|
|
|
+ FWSFormClass:=TWin32WSForm;
|
|
|
|
|
|
- FFontEngine:=TWinApiFontEngine.Create(nil);
|
|
|
+ FFontEngine:=TWin32FontEngine.Create(nil);
|
|
|
TFresnelFontEngine.WSEngine:=FFontEngine;
|
|
|
end;
|
|
|
|
|
|
-destructor TWinApiWidgetSet.Destroy;
|
|
|
+destructor TWin32WidgetSet.Destroy;
|
|
|
begin
|
|
|
TFresnelFontEngine.WSEngine:=nil;
|
|
|
FreeAndNil(FFontEngine);
|
|
|
- WinApiWidgetSet:=nil;
|
|
|
+ Win32WidgetSet:=nil;
|
|
|
inherited Destroy;
|
|
|
end;
|
|
|
|
|
|
-procedure TWinApiWidgetSet.AppWaitMessage;
|
|
|
+procedure TWin32WidgetSet.AppWaitMessage;
|
|
|
var
|
|
|
aWaitHandleCount, timeout, retVal: DWORD;
|
|
|
pHandles: Windows.LPHANDLE;
|
|
|
begin
|
|
|
- writeln('TWinApiWidgetSet.AppWaitMessage START');
|
|
|
+ //writeln('TWin32WidgetSet.AppWaitMessage START');
|
|
|
aWaitHandleCount:=0;
|
|
|
pHandles:=nil;
|
|
|
timeout := INFINITE;
|
|
|
retVal := Windows.MsgWaitForMultipleObjects(aWaitHandleCount, pHandles,
|
|
|
false, timeout, QS_ALLINPUT);
|
|
|
- writeln('TWinApiWidgetSet.AppWaitMessage END ',retVal);
|
|
|
+ if retVal>0 then ;
|
|
|
+ //writeln('TWin32WidgetSet.AppWaitMessage END ',retVal);
|
|
|
end;
|
|
|
|
|
|
-procedure TWinApiWidgetSet.AppProcessMessages;
|
|
|
+procedure TWin32WidgetSet.AppProcessMessages;
|
|
|
var
|
|
|
aMessage: TMsg;
|
|
|
begin
|
|
|
- writeln('TWinApiWidgetSet.AppProcessMessages START');
|
|
|
+ //writeln('TWin32WidgetSet.AppProcessMessages START');
|
|
|
AMessage := Default(TMsg);
|
|
|
while PeekMessage(AMessage, 0, 0, 0, PM_REMOVE) do
|
|
|
begin
|
|
@@ -570,36 +571,36 @@ begin
|
|
|
TranslateMessage(aMessage);
|
|
|
DispatchMessage(aMessage);
|
|
|
end;
|
|
|
- writeln('TWinApiWidgetSet.AppProcessMessages END');
|
|
|
+ //writeln('TWin32WidgetSet.AppProcessMessages END');
|
|
|
end;
|
|
|
|
|
|
-procedure TWinApiWidgetSet.AppTerminate;
|
|
|
+procedure TWin32WidgetSet.AppTerminate;
|
|
|
begin
|
|
|
Application.Terminate;
|
|
|
end;
|
|
|
|
|
|
-procedure TWinApiWidgetSet.AppSetTitle(const ATitle: string);
|
|
|
+procedure TWin32WidgetSet.AppSetTitle(const ATitle: string);
|
|
|
begin
|
|
|
if ATitle='' then ;
|
|
|
//if FAppHandle <> 0 then
|
|
|
//begin
|
|
|
// ws:=UTF8ToUTF16(ATitle);
|
|
|
- // todo: TWinApiWidgetSet.AppSetTitle
|
|
|
+ // todo: TWin32WidgetSet.AppSetTitle
|
|
|
//Windows.SetWindowTextW(FAppHandle, PWideChar(ws));
|
|
|
//end;
|
|
|
end;
|
|
|
|
|
|
-procedure TWinApiWidgetSet.CreateWSForm(aFresnelForm: TFresnelComponent);
|
|
|
+procedure TWin32WidgetSet.CreateWSForm(aFresnelForm: TFresnelComponent);
|
|
|
var
|
|
|
aForm: TFresnelCustomForm;
|
|
|
- aWSForm: TWinApiWSForm;
|
|
|
+ aWSForm: TWin32WSForm;
|
|
|
begin
|
|
|
if not (aFresnelForm is TFresnelCustomForm) then
|
|
|
- raise Exception.Create('TWinApiWidgetSet.CreateWSForm '+aFresnelForm.ToString);
|
|
|
+ raise Exception.Create('TWin32WidgetSet.CreateWSForm '+aFresnelForm.ToString);
|
|
|
aForm:=TFresnelCustomForm(aFresnelForm);
|
|
|
- aForm.FontEngine:=FontEngineWinApi;
|
|
|
+ aForm.FontEngine:=FontEngineWin32;
|
|
|
|
|
|
- aWSForm:=TWinApiWSForm.Create(aForm);
|
|
|
+ aWSForm:=TWin32WSForm.Create(aForm);
|
|
|
aWSForm.Form:=aForm;
|
|
|
aForm.WSForm:=aWSForm;
|
|
|
aWSForm.CreateWSWindow;
|
|
@@ -608,13 +609,13 @@ end;
|
|
|
initialization
|
|
|
WindowInfoAtom := Windows.GlobalAddAtom('WindowInfo');
|
|
|
WindowInfoAtomStr:={%H-}lpcstr(PtrUint(WindowInfoAtom));
|
|
|
- TWinApiWidgetSet.Create(nil);
|
|
|
+ TWin32WidgetSet.Create(nil);
|
|
|
|
|
|
finalization
|
|
|
Windows.GlobalDeleteAtom(WindowInfoAtom);
|
|
|
WindowInfoAtom := 0;
|
|
|
WindowInfoAtomStr:=nil;
|
|
|
- WinApiWidgetSet.Free; // it will nil itself
|
|
|
+ Win32WidgetSet.Free; // it will nil itself
|
|
|
|
|
|
end.
|
|
|
|