|
@@ -29,18 +29,27 @@ Type
|
|
isSpecial : Boolean;
|
|
isSpecial : Boolean;
|
|
KeyCode : Longint;
|
|
KeyCode : Longint;
|
|
end;
|
|
end;
|
|
|
|
+ TClipRect = record
|
|
|
|
+ x,y,w,h : Single;
|
|
|
|
+ end;
|
|
|
|
+ TTransform = record
|
|
|
|
+ m11,m12,m21,m22,m31,m32 : TFresnelFloat;
|
|
|
|
+ end;
|
|
|
|
|
|
{ TFresnelHelper }
|
|
{ TFresnelHelper }
|
|
|
|
|
|
TFresnelHelper = Class
|
|
TFresnelHelper = Class
|
|
Private
|
|
Private
|
|
- class var _CurrentID : TCanvasID;
|
|
|
|
|
|
+ class var
|
|
|
|
+ _CurrentID : TCanvasID;
|
|
|
|
+ _CurrentMenuID : TMenuID;
|
|
Public
|
|
Public
|
|
Class function FresnelColorToHTMLColor(aColor : TCanvasColor) : string;
|
|
Class function FresnelColorToHTMLColor(aColor : TCanvasColor) : string;
|
|
Class function FresnelColorToHTMLColor(aRed, aGreen, aBlue, aAlpha: TCanvasColorComponent): string;
|
|
Class function FresnelColorToHTMLColor(aRed, aGreen, aBlue, aAlpha: TCanvasColorComponent): string;
|
|
class Function MouseButtonToShiftState(aButton: Integer): TShiftStateEnum;
|
|
class Function MouseButtonToShiftState(aButton: Integer): TShiftStateEnum;
|
|
Class Function ShiftStateToInt(aState : TShiftState) : Integer;
|
|
Class Function ShiftStateToInt(aState : TShiftState) : Integer;
|
|
Class Function AllocateCanvasID : TCanvasID;
|
|
Class Function AllocateCanvasID : TCanvasID;
|
|
|
|
+ Class Function AllocateMenuID : TMenuID;
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TCanvasEvent }
|
|
{ TCanvasEvent }
|
|
@@ -56,6 +65,37 @@ Type
|
|
constructor Create(aCanvasID : TCanvasID; aMsg : TCanvasMessageID; p0 : TCanvasMessageParam; p1: TCanvasMessageParam = 0; p2: TCanvasMessageParam = 0;p3: TCanvasMessageParam = 0);
|
|
constructor Create(aCanvasID : TCanvasID; aMsg : TCanvasMessageID; p0 : TCanvasMessageParam; p1: TCanvasMessageParam = 0; p2: TCanvasMessageParam = 0;p3: TCanvasMessageParam = 0);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ { TMainMenuBuilder }
|
|
|
|
+ TMenuFlag = (mfInvisible,mfChecked,mfRadio);
|
|
|
|
+ TMenuFlags = set of TMenuFlag;
|
|
|
|
+
|
|
|
|
+ TMainMenuBuilder = Class(TObject)
|
|
|
|
+ private
|
|
|
|
+ FApi: TWasmFresnelApi;
|
|
|
|
+ FMenuParent: TJSHTMLElement;
|
|
|
|
+ protected
|
|
|
|
+ Procedure DoMenuClick(aEvent : TJSEvent);
|
|
|
|
+ function DoAddMenuItem(aParentID,aMenuID : TMenuID; aCaption : String; Flags : TMenuFlags; ShortCut : Longint; aData : TWasmPointer) : TJSHTMLElement; virtual; abstract;
|
|
|
|
+ function DoRemoveMenuItem(aMenuID : TMenuID) : Boolean; virtual; abstract;
|
|
|
|
+ function DoUpdateMenuItem(aMenuID : TMenuID; aFlags : TMenuFlags; aFlagsToUpdate : TMenuFlags) : boolean; virtual; abstract;
|
|
|
|
+ Public
|
|
|
|
+ Constructor Create(aApi : TWasmFresnelApi; aMenuParent : TJSHTMLElement); virtual;
|
|
|
|
+ function AddMenuItem(aParentID,aMenuID : TMenuID; aCaption : String; Flags : TMenuFlags; ShortCut : Longint; aData : TWasmPointer) : TJSHTMLElement;
|
|
|
|
+ function RemoveMenuItem(aMenuID : TMenuID) : Boolean;
|
|
|
|
+ function UpdateMenuItem(aMenuID : TMenuID; aFlags : TMenuFlags; aFlagsToUpdate : TMenuFlags) : boolean;
|
|
|
|
+ Property MenuParent : TJSHTMLElement Read FMenuParent;
|
|
|
|
+ Property API : TWasmFresnelApi Read FApi;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ { TDefaultMainMenuBuilder }
|
|
|
|
+ TDefaultMainMenuBuilder = class(TMainMenuBuilder)
|
|
|
|
+ Protected
|
|
|
|
+ function FindMenuElement(aMenuID: Integer): TJSHTMLElement;
|
|
|
|
+ function DoAddMenuItem(aParentID, aMenuID: TMenuID; aCaption: String; Flags : TMenuFlags; ShortCut : Longint; aData: TWasmPointer): TJSHTMLElement; override;
|
|
|
|
+ function DoRemoveMenuItem(aMenuID : TMenuID) : Boolean; override;
|
|
|
|
+ function DoUpdateMenuItem(aMenuID : TMenuID; aFlags : TMenuFlags; aFlagsToUpdate : TMenuFlags) : boolean; override;
|
|
|
|
+ end;
|
|
|
|
+
|
|
{ TCanvasReference }
|
|
{ TCanvasReference }
|
|
TCanvasType = (ctElement,ctOffscreen);
|
|
TCanvasType = (ctElement,ctOffscreen);
|
|
|
|
|
|
@@ -66,12 +106,19 @@ Type
|
|
FFont: String;
|
|
FFont: String;
|
|
FStrokeStyle: JSValue;
|
|
FStrokeStyle: JSValue;
|
|
FTitle: String;
|
|
FTitle: String;
|
|
-
|
|
|
|
|
|
+ FClipRects : Array of TClipRect;
|
|
|
|
+ FLastTransform : TTransform;
|
|
procedure InitProperties;
|
|
procedure InitProperties;
|
|
|
|
+ procedure SaveTransform(m11, m12, m21, m22, m31, m32: TFresnelFloat);
|
|
procedure SetFillStyle(AValue: JSValue);
|
|
procedure SetFillStyle(AValue: JSValue);
|
|
procedure SetFont(AValue: String);
|
|
procedure SetFont(AValue: String);
|
|
procedure SetStrokeStyle(AValue: JSValue);
|
|
procedure SetStrokeStyle(AValue: JSValue);
|
|
procedure SetTextBaseLine(AValue: String);
|
|
procedure SetTextBaseLine(AValue: String);
|
|
|
|
+ procedure SetClipPath;
|
|
|
|
+ procedure AddClipRect(aRect : TClipRect);
|
|
|
|
+ procedure SaveState;
|
|
|
|
+ procedure RestoreState(aApplyProperties: Boolean);
|
|
|
|
+ function SetTransform(m11,m12,m21,m22,m31,m32 : TFresnelFloat; DoReset : Boolean) : TCanvasError;
|
|
function DoMouseClick(aEvent: TJSEvent): boolean;
|
|
function DoMouseClick(aEvent: TJSEvent): boolean;
|
|
function DoMouseDblClick(aEvent: TJSEvent): boolean;
|
|
function DoMouseDblClick(aEvent: TJSEvent): boolean;
|
|
function DoMouseDown(aEvent: TJSEvent): boolean;
|
|
function DoMouseDown(aEvent: TJSEvent): boolean;
|
|
@@ -89,6 +136,7 @@ Type
|
|
windowtitle,
|
|
windowtitle,
|
|
canvasParent :TJSHTMLElement;
|
|
canvasParent :TJSHTMLElement;
|
|
FTextBaseLine : String;
|
|
FTextBaseLine : String;
|
|
|
|
+ FMenuBuilder : TMainMenuBuilder;
|
|
constructor Create(aID : TCanvasID; aAPI : TWasmFresnelApi; aCanvas : TJSHTMLCanvasElement; aParent : TJSHTMLElement);
|
|
constructor Create(aID : TCanvasID; aAPI : TWasmFresnelApi; aCanvas : TJSHTMLCanvasElement; aParent : TJSHTMLElement);
|
|
constructor CreateOffScreen(aID : TCanvasID;aAPI : TWasmFresnelApi; aWidth,aHeight: Longint);
|
|
constructor CreateOffScreen(aID : TCanvasID;aAPI : TWasmFresnelApi; aWidth,aHeight: Longint);
|
|
procedure PrepareCanvas;
|
|
procedure PrepareCanvas;
|
|
@@ -101,13 +149,19 @@ Type
|
|
property Font : String Read FFont Write SetFont;
|
|
property Font : String Read FFont Write SetFont;
|
|
property Title : String Read FTitle Write SetTitle;
|
|
property Title : String Read FTitle Write SetTitle;
|
|
property CanvasType : TCanvasType Read FCanvasType;
|
|
property CanvasType : TCanvasType Read FCanvasType;
|
|
|
|
+ property MenuBuilder : TMainMenuBuilder Read FMenuBuilder Write FMenuBuilder;
|
|
end;
|
|
end;
|
|
|
|
+
|
|
|
|
+
|
|
{ TWasmFresnelApi }
|
|
{ TWasmFresnelApi }
|
|
|
|
|
|
TTimerCallback = Procedure (aCurrent,aPrevious : Double);
|
|
TTimerCallback = Procedure (aCurrent,aPrevious : Double);
|
|
|
|
+ TMenuClickCallback = Procedure (aMenuID : TMenuID; aUserData : TWasmPointer);
|
|
TDebugApi = (daText,daClipRect);
|
|
TDebugApi = (daText,daClipRect);
|
|
TDebugApis = Set of TDebugApi;
|
|
TDebugApis = Set of TDebugApi;
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
TWasmFresnelApi = class(TImportExtension)
|
|
TWasmFresnelApi = class(TImportExtension)
|
|
Public
|
|
Public
|
|
class var
|
|
class var
|
|
@@ -122,13 +176,11 @@ Type
|
|
FFocusedCanvas: TCanvasReference;
|
|
FFocusedCanvas: TCanvasReference;
|
|
FLastFocused: TCanvasReference;
|
|
FLastFocused: TCanvasReference;
|
|
FLogAPICalls : Boolean;
|
|
FLogAPICalls : Boolean;
|
|
|
|
+ FMenuSupport: Boolean;
|
|
FTimerID : NativeInt;
|
|
FTimerID : NativeInt;
|
|
FTimerInterval: NativeInt;
|
|
FTimerInterval: NativeInt;
|
|
FLastTick: TDateTime;
|
|
FLastTick: TDateTime;
|
|
FKeyMap : TJSObject;
|
|
FKeyMap : TJSObject;
|
|
- procedure DrawBaseLine(C: TJSCanvasRenderingContext2D; S: String; X, Y: Double);
|
|
|
|
- procedure DrawClipRect(Ref: TCanvasReference; aX, aY, aWidth,
|
|
|
|
- aHeight: double);
|
|
|
|
procedure SetCreateDefaultCanvas(AValue: Boolean);
|
|
procedure SetCreateDefaultCanvas(AValue: Boolean);
|
|
procedure SetFocusedCanvas(AValue: TCanvasReference);
|
|
procedure SetFocusedCanvas(AValue: TCanvasReference);
|
|
Protected
|
|
Protected
|
|
@@ -137,6 +189,10 @@ Type
|
|
Procedure LogCall(Const Fmt : String; const Args : Array of const);
|
|
Procedure LogCall(Const Fmt : String; const Args : Array of const);
|
|
function GetCanvas(aID : TCanvasID) : TJSCanvasRenderingContext2D;
|
|
function GetCanvas(aID : TCanvasID) : TJSCanvasRenderingContext2D;
|
|
function GetCanvasRef(aID: TCanvasID): TCanvasReference;
|
|
function GetCanvasRef(aID: TCanvasID): TCanvasReference;
|
|
|
|
+ function CreateMenuBuilder(aParent: TJSHTMLELement): TMainMenuBuilder; virtual;
|
|
|
|
+ // Debug
|
|
|
|
+ procedure DrawBaseLine(C: TJSCanvasRenderingContext2D; S: String; X, Y: Double);
|
|
|
|
+ procedure DrawClipRect(Ref: TCanvasReference; aX, aY, aWidth, aHeight: double);
|
|
// Canvas
|
|
// Canvas
|
|
function allocatecanvas(SizeX, SizeY : Longint; aID: TWasmPointer): TCanvasError;
|
|
function allocatecanvas(SizeX, SizeY : Longint; aID: TWasmPointer): TCanvasError;
|
|
function allocateoffscreencanvas(SizeX, SizeY : Longint; aBitmap : TWasmPointer; aID: TWasmPointer): TCanvasError;
|
|
function allocateoffscreencanvas(SizeX, SizeY : Longint; aBitmap : TWasmPointer; aID: TWasmPointer): TCanvasError;
|
|
@@ -186,6 +242,11 @@ Type
|
|
// Events
|
|
// Events
|
|
function GetEvent(aID: TWasmPointer; aMsg: TWasmPointer; Data : TWasmPointer): TCanvasError;
|
|
function GetEvent(aID: TWasmPointer; aMsg: TWasmPointer; Data : TWasmPointer): TCanvasError;
|
|
function GetEventCount(aCount: TWasmPointer): TCanvasError;
|
|
function GetEventCount(aCount: TWasmPointer): TCanvasError;
|
|
|
|
+ // Menu
|
|
|
|
+ Function HandleMenuClick(aMenuID : TMenuID; aData : TWasmPointer) : Boolean;
|
|
|
|
+ function AddMenuItem(aCanvasID : TCanvasId; aParentID : TMenuID; aCaption : TWasmPointer; aCaptionLen : Longint; aData: TWasmPointer; aFlags : Longint; aShortCut : Longint; aMenuID : PMenuID) : TCanvasError;
|
|
|
|
+ function DeleteMenuItem(aCanvasID : TCanvasId; aMenuID : TMenuID) : TCanvasError;
|
|
|
|
+ function UpdateMenuItem(aCanvasID : TCanvasId; aMenuID : TMenuID; aFlags : Longint; aShortCut : Longint) : TCanvasError;
|
|
// Key handlers are global
|
|
// Key handlers are global
|
|
function DoKeyDownEvent(aEvent: TJSEvent): boolean;
|
|
function DoKeyDownEvent(aEvent: TJSEvent): boolean;
|
|
function DoKeyUpEvent(aEvent: TJSEvent): boolean;
|
|
function DoKeyUpEvent(aEvent: TJSEvent): boolean;
|
|
@@ -213,6 +274,7 @@ Type
|
|
Property CanvasParent : TJSHTMLELement Read FCanvasParent Write FCanvasParent;
|
|
Property CanvasParent : TJSHTMLELement Read FCanvasParent Write FCanvasParent;
|
|
Property CreateDefaultCanvas : Boolean read FCreateDefaultCanvas Write SetCreateDefaultCanvas;
|
|
Property CreateDefaultCanvas : Boolean read FCreateDefaultCanvas Write SetCreateDefaultCanvas;
|
|
Property LogAPICalls : Boolean Read FLogAPICalls Write FLogAPICalls;
|
|
Property LogAPICalls : Boolean Read FLogAPICalls Write FLogAPICalls;
|
|
|
|
+ Property MenuSupport : Boolean Read FMenuSupport Write FMenuSupport;
|
|
Property TimerInterval : NativeInt Read FTimerInterval Write FTimerInterval;
|
|
Property TimerInterval : NativeInt Read FTimerInterval Write FTimerInterval;
|
|
Property DebugAPIs : TDebugApis Read FDebugApis Write FDebugApis;
|
|
Property DebugAPIs : TDebugApis Read FDebugApis Write FDebugApis;
|
|
end;
|
|
end;
|
|
@@ -221,6 +283,22 @@ Implementation
|
|
|
|
|
|
uses sysutils;
|
|
uses sysutils;
|
|
|
|
|
|
|
|
+Function FlagsToMenuFlags(Flags : Longint) : TMenuFlags;
|
|
|
|
+
|
|
|
|
+ procedure add(aFlag: Longint; aMenuFlag : TMenuFlag);
|
|
|
|
+
|
|
|
|
+ begin
|
|
|
|
+ if (Flags and aFlag)=aFlag then
|
|
|
|
+ Include(Result,aMenuFlag);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+begin
|
|
|
|
+ Result:=[];
|
|
|
|
+ Add(MENU_FLAGS_INVISIBLE,mfInvisible);
|
|
|
|
+ Add(MENU_FLAGS_CHECKED,mfChecked);
|
|
|
|
+ Add(MENU_FLAGS_RADIO,mfRadio);
|
|
|
|
+end;
|
|
|
|
+
|
|
type
|
|
type
|
|
|
|
|
|
{ TJSKeyNameObjectCreator }
|
|
{ TJSKeyNameObjectCreator }
|
|
@@ -279,7 +357,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-class Function TFresnelHelper.ShiftStateToInt(aState : TShiftState) : Integer;
|
|
|
|
|
|
+class function TFresnelHelper.ShiftStateToInt(aState: TShiftState): Integer;
|
|
|
|
|
|
var
|
|
var
|
|
S : TShiftStateEnum;
|
|
S : TShiftStateEnum;
|
|
@@ -401,6 +479,60 @@ begin
|
|
canvascontext.textBaseline:=aValue;
|
|
canvascontext.textBaseline:=aValue;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TCanvasReference.SetClipPath;
|
|
|
|
+
|
|
|
|
+var
|
|
|
|
+ P : TJSPath2D;
|
|
|
|
+ R : TClipRect;
|
|
|
|
+begin
|
|
|
|
+ RestoreState(True);
|
|
|
|
+ SaveState;
|
|
|
|
+ if Length(FClipRects)=0 then
|
|
|
|
+ exit;
|
|
|
|
+ P:=TJSPath2D.New;
|
|
|
|
+ For R in FClipRects do
|
|
|
|
+ P.Rect(R.X,R.Y,R.w,R.h);
|
|
|
|
+ CanvasContext.Clip(P);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TCanvasReference.AddClipRect(aRect: TClipRect);
|
|
|
|
+begin
|
|
|
|
+ TJSArray(FClipRects).Push(aRect)
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TCanvasReference.SaveState;
|
|
|
|
+begin
|
|
|
|
+ CanvasContext.Save;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TCanvasReference.RestoreState(aApplyProperties : Boolean);
|
|
|
|
+begin
|
|
|
|
+ CanvasContext.Restore;
|
|
|
|
+ ApplyProperties;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TCanvasReference.SaveTransform(m11,m12,m21,m22,m31,m32: TFresnelFloat);
|
|
|
|
+
|
|
|
|
+begin
|
|
|
|
+ FLastTransform.m11:=m11;
|
|
|
|
+ FLastTransform.m12:=m12;
|
|
|
|
+ FLastTransform.m21:=m21;
|
|
|
|
+ FLastTransform.m22:=m22;
|
|
|
|
+ FLastTransform.m31:=m31;
|
|
|
|
+ FLastTransform.m32:=m32;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TCanvasReference.SetTransform(m11, m12, m21, m22, m31, m32: TFresnelFloat; DoReset: Boolean): TCanvasError;
|
|
|
|
+begin
|
|
|
|
+ if DoReset then
|
|
|
|
+ begin
|
|
|
|
+ CanvasContext.setTransform(m11,m12,m21,m22,m31,m32);
|
|
|
|
+ SaveTransform(m11,m12,m21,m22,m31,m32);
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ CanvasContext.transform(m11,m12,m21,m22,m31,m32);
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TCanvasReference.PrepareCanvas;
|
|
procedure TCanvasReference.PrepareCanvas;
|
|
|
|
|
|
begin
|
|
begin
|
|
@@ -411,6 +543,7 @@ begin
|
|
Canvas.AddEventListener('click',@DoMouseClick);
|
|
Canvas.AddEventListener('click',@DoMouseClick);
|
|
Canvas.AddEventListener('dblclick',@DoMouseDblClick);
|
|
Canvas.AddEventListener('dblclick',@DoMouseDblClick);
|
|
Canvas.AddEventListener('scroll',@DoMouseWheel);
|
|
Canvas.AddEventListener('scroll',@DoMouseWheel);
|
|
|
|
+ FClipRects:=[];
|
|
InitProperties;
|
|
InitProperties;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -435,6 +568,12 @@ begin
|
|
FFillStyle := canvascontext.fillStyle;
|
|
FFillStyle := canvascontext.fillStyle;
|
|
FStrokeStyle := canvascontext.strokeStyle;
|
|
FStrokeStyle := canvascontext.strokeStyle;
|
|
FFont := canvascontext.font;
|
|
FFont := canvascontext.font;
|
|
|
|
+ FLastTransform.m11:=1;
|
|
|
|
+ FLastTransform.m12:=0;
|
|
|
|
+ FLastTransform.m21:=0;
|
|
|
|
+ FLastTransform.m32:=1;
|
|
|
|
+ FLastTransform.m31:=0;
|
|
|
|
+ FLastTransform.m32:=0;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TCanvasReference.ApplyProperties;
|
|
procedure TCanvasReference.ApplyProperties;
|
|
@@ -443,6 +582,8 @@ begin
|
|
canvascontext.fillStyle:=FFillStyle;
|
|
canvascontext.fillStyle:=FFillStyle;
|
|
canvascontext.strokeStyle:=FStrokeStyle;
|
|
canvascontext.strokeStyle:=FStrokeStyle;
|
|
canvascontext.font:=FFont;
|
|
canvascontext.font:=FFont;
|
|
|
|
+ With FLastTransform do
|
|
|
|
+ canvascontext.setTransform(m11,m12,m21,m22,m31,m32);
|
|
end;
|
|
end;
|
|
|
|
|
|
function TCanvasReference.MouseToEvent(aEvent : TJSMouseEvent;aMessageID : TCanvasMessageID) : TCanvasEvent;
|
|
function TCanvasReference.MouseToEvent(aEvent : TJSMouseEvent;aMessageID : TCanvasMessageID) : TCanvasEvent;
|
|
@@ -525,7 +666,7 @@ begin
|
|
SendEvent;
|
|
SendEvent;
|
|
end;
|
|
end;
|
|
|
|
|
|
-Class function TCanvasReference.EncodeShiftState(keyEvent : TJSKeyboardEvent) : longint;
|
|
|
|
|
|
+class function TCanvasReference.EncodeShiftState(keyEvent: TJSKeyboardEvent): longint;
|
|
|
|
|
|
|
|
|
|
var
|
|
var
|
|
@@ -622,6 +763,116 @@ begin
|
|
SendEvent;
|
|
SendEvent;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+{ TMainMenuBuilder }
|
|
|
|
+
|
|
|
|
+procedure TMainMenuBuilder.DoMenuClick(aEvent: TJSEvent);
|
|
|
|
+
|
|
|
|
+var
|
|
|
|
+ S : String;
|
|
|
|
+ MenuID : integer;
|
|
|
|
+ UserData : TWasmPointer;
|
|
|
|
+ menuEl : TJSHTMLElement;
|
|
|
|
+
|
|
|
|
+begin
|
|
|
|
+ MenuEl:=TJSHTMLElement(aEvent.currentTargetHTMLElement.parentElement);
|
|
|
|
+ S:=MenuEl.dataset['menuId'];
|
|
|
|
+ MenuID:=StrToIntDef(S,-1);
|
|
|
|
+ S:=MenuEl.dataset['menuUserData'];
|
|
|
|
+ UserData:=StrToIntDef(S,-1);
|
|
|
|
+ if (UserData<>-1) and (MenuID<>-1) then
|
|
|
|
+ Api.HandleMenuClick(MenuID,UserData);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+constructor TMainMenuBuilder.Create(aApi: TWasmFresnelApi; aMenuParent: TJSHTMLElement);
|
|
|
|
+begin
|
|
|
|
+ FAPI:=aApi;
|
|
|
|
+ FMenuParent:=aMenuParent;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TMainMenuBuilder.AddMenuItem(aParentID,aMenuID: TMenuID; aCaption: String; Flags : TMenuFlags; ShortCut : Longint; aData: TWasmPointer): TJSHTMLElement;
|
|
|
|
+begin
|
|
|
|
+ Result:=DoAddMenuItem(aParentID,aMenuID,aCaption,Flags,ShortCut,aData);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TMainMenuBuilder.RemoveMenuItem(aMenuID: TMenuID): Boolean;
|
|
|
|
+begin
|
|
|
|
+ Result:=DoRemoveMenuItem(aMenuID);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TMainMenuBuilder.UpdateMenuItem(aMenuID: TMenuID; aFlags: TMenuFlags; aFlagsToUpdate: TMenuFlags): boolean;
|
|
|
|
+begin
|
|
|
|
+ Result:=DoUpdateMenuItem(aMenuID,aFlags,aFlagsToUpdate);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+{ TDefaultMainMenuBuilder }
|
|
|
|
+
|
|
|
|
+function TDefaultMainMenuBuilder.FindMenuElement(aMenuID : Integer) : TJSHTMLElement;
|
|
|
|
+
|
|
|
|
+begin
|
|
|
|
+ Result:=TJSHTMLElement(MenuParent.querySelector('li[data-menu-id="'+IntToStr(aMenuID)+'"]'))
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TDefaultMainMenuBuilder.DoAddMenuItem(aParentID,aMenuID: TMenuID; aCaption: String; Flags : TMenuFlags; ShortCut : Longint; aData: TWasmPointer): TJSHTMLElement;
|
|
|
|
+
|
|
|
|
+var
|
|
|
|
+ CaptionEl,MenuEl,ListEl,parentEl : TJSHTMLElement;
|
|
|
|
+
|
|
|
|
+begin
|
|
|
|
+ Result:=nil;
|
|
|
|
+ if AParentID=0 then
|
|
|
|
+ ParentEl:=MenuParent
|
|
|
|
+ else
|
|
|
|
+ ParentEl:=FindMenuElement(aParentID);
|
|
|
|
+ if Not assigned(ParentEl) then exit;
|
|
|
|
+ ListEl:=TJSHTMLElement(ParentEl.QuerySelector('ul'));
|
|
|
|
+ if Not Assigned(ListEl) then
|
|
|
|
+ begin
|
|
|
|
+ ListEl:=TJSHTMLElement(Document.createElement('ul'));
|
|
|
|
+ if ParentEl=MenuParent then
|
|
|
|
+ ListEl.classList.Add('fresnel-mainmenu')
|
|
|
|
+ else
|
|
|
|
+ ListEl.classList.Add('fresnel-submenu');
|
|
|
|
+ ParentEl.appendChild(ListEl);
|
|
|
|
+ end;
|
|
|
|
+ MenuEl:=TJSHTMLElement(Document.CreateElement('li'));
|
|
|
|
+ ListEl.appendChild(MenuEl);
|
|
|
|
+ MenuEl.dataset.Map['menuId']:=IntToStr(aMenuID);
|
|
|
|
+ MenuEl.dataset.Map['menuUserData']:=IntToStr(aData);
|
|
|
|
+ if aCaption='-' then
|
|
|
|
+ begin
|
|
|
|
+ MenuEl.ClassList.add('fresnel-menu-separator');
|
|
|
|
+ CaptionEl:=TJSHTMLElement(Document.CreateElement('hr'))
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ MenuEl.classList.Add('fresnel-menu-item');
|
|
|
|
+ CaptionEl:=TJSHTMLElement(Document.CreateElement('span'));
|
|
|
|
+ if mfChecked in Flags then
|
|
|
|
+ aCaption:=#$2611+' '+aCaption;
|
|
|
|
+ CaptionEl.InnerText:=aCaption;
|
|
|
|
+ CaptionEl.AddEventListener('click',@DoMenuClick);
|
|
|
|
+ end;
|
|
|
|
+ MenuEl.appendChild(CaptionEl);
|
|
|
|
+ Result:=MenuEl;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TDefaultMainMenuBuilder.DoRemoveMenuItem(aMenuID: TMenuID) : Boolean;
|
|
|
|
+
|
|
|
|
+var
|
|
|
|
+ El : TJSHTMLElement;
|
|
|
|
+
|
|
|
|
+begin
|
|
|
|
+ El:=FindMenuElement(aMenuID);
|
|
|
|
+ Result:=Assigned(El);
|
|
|
|
+ if Result then
|
|
|
|
+ El.parentElement.removeChild(El);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TDefaultMainMenuBuilder.DoUpdateMenuItem(aMenuID: TMenuID; aFlags: TMenuFlags; aFlagsToUpdate: TMenuFlags): boolean;
|
|
|
|
+begin
|
|
|
|
+ Result:=False;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
|
|
constructor TWasmFresnelApi.Create(aEnv: TPas2JSWASIEnvironment);
|
|
constructor TWasmFresnelApi.Create(aEnv: TPas2JSWASIEnvironment);
|
|
|
|
|
|
@@ -693,12 +944,23 @@ begin
|
|
Result:=nil;
|
|
Result:=nil;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TWasmFresnelApi.CreateMenuBuilder(aParent : TJSHTMLELement): TMainMenuBuilder;
|
|
|
|
+begin
|
|
|
|
+ Result:=TDefaultMainMenuBuilder.Create(Self,aParent);
|
|
|
|
+end;
|
|
|
|
+
|
|
class function TFresnelHelper.AllocateCanvasID: TCanvasID;
|
|
class function TFresnelHelper.AllocateCanvasID: TCanvasID;
|
|
begin
|
|
begin
|
|
Inc(_CurrentID);
|
|
Inc(_CurrentID);
|
|
Result:=_CurrentID;
|
|
Result:=_CurrentID;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+class function TFresnelHelper.AllocateMenuID: TMenuID;
|
|
|
|
+begin
|
|
|
|
+ Inc(_CurrentMenuID);
|
|
|
|
+ Result:=_CurrentMenuID;
|
|
|
|
+end;
|
|
|
|
+
|
|
{ TCanvasEvent }
|
|
{ TCanvasEvent }
|
|
|
|
|
|
constructor TCanvasEvent.Create(aCanvasID: TCanvasID; aMsg: TCanvasMessageID);
|
|
constructor TCanvasEvent.Create(aCanvasID: TCanvasID; aMsg: TCanvasMessageID);
|
|
@@ -804,6 +1066,9 @@ begin
|
|
aObject['event_get']:=@GetEvent;
|
|
aObject['event_get']:=@GetEvent;
|
|
aObject['event_count']:=@GetEventCount;
|
|
aObject['event_count']:=@GetEventCount;
|
|
aObject['event_set_special_keymap']:=@SetSpecialKeyMap;
|
|
aObject['event_set_special_keymap']:=@SetSpecialKeyMap;
|
|
|
|
+ aObject['menu_add_item']:=@AddMenuItem;
|
|
|
|
+ aObject['menu_remove_item']:=@DeleteMenuItem;
|
|
|
|
+ aObject['menu_update_item']:=@UpdateMenuItem;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TWasmFresnelApi.StartTimerTick;
|
|
procedure TWasmFresnelApi.StartTimerTick;
|
|
@@ -878,7 +1143,7 @@ begin
|
|
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWasmFresnelApi.GetCanvasSizes(aID: TCanvasID; aWidth, aHeight: TWasmPointer): TCanvasError;
|
|
|
|
|
|
+function TWasmFresnelApi.GetCanvasSizes(aID: TCanvasID; aWidth, aHeight: PFresnelFloat): TCanvasError;
|
|
|
|
|
|
var
|
|
var
|
|
Ref: TCanvasReference;
|
|
Ref: TCanvasReference;
|
|
@@ -1120,7 +1385,7 @@ Window.createImageBitmap(ImgData)._then(
|
|
Result:=ECANVAS_SUCCESS;
|
|
Result:=ECANVAS_SUCCESS;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWasmFresnelApi.DrawImageEx(aID: TCanvasID; DrawData : TWasmPointer; aImageData: TWasmPointer): TCanvasError;
|
|
|
|
|
|
+function TWasmFresnelApi.DrawImageEx(aID: TCanvasID; DrawData: PFresnelFloat; aImageData: TWasmPointer): TCanvasError;
|
|
|
|
|
|
var
|
|
var
|
|
V : TJSDataView;
|
|
V : TJSDataView;
|
|
@@ -1284,8 +1549,7 @@ begin
|
|
Result:=ECANVAS_SUCCESS;
|
|
Result:=ECANVAS_SUCCESS;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWasmFresnelApi.DrawPath(aID: TCanvasID; aFlags: Longint;
|
|
|
|
- aPathCount: longint; aPath: TWasmPointer): TCanvasError;
|
|
|
|
|
|
+function TWasmFresnelApi.DrawPath(aID: TCanvasID; aFlags: Longint; aPathCount: longint; aPath: PFresnelFloat): TCanvasError;
|
|
var
|
|
var
|
|
Canv:TJSCanvasRenderingContext2D;
|
|
Canv:TJSCanvasRenderingContext2D;
|
|
P2D : TJSPath2D;
|
|
P2D : TJSPath2D;
|
|
@@ -1363,8 +1627,8 @@ begin
|
|
Result:=ECANVAS_SUCCESS;
|
|
Result:=ECANVAS_SUCCESS;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWasmFresnelApi.PointInPath(aID: TCanvasID; aX,aY: TFresnelFloat;
|
|
|
|
- aPointCount: Integer; aPointData: TWasmPointer; aRes: TWasmPointer): TCanvasError;
|
|
|
|
|
|
+function TWasmFresnelApi.PointInPath(aID: TCanvasID; aX, aY: TFresnelFloat; aPointCount: Integer; aPointData: PFresnelFloat;
|
|
|
|
+ aRes: TWasmPointer): TCanvasError;
|
|
var
|
|
var
|
|
Canv:TJSCanvasRenderingContext2D;
|
|
Canv:TJSCanvasRenderingContext2D;
|
|
P2D : TJSPath2D;
|
|
P2D : TJSPath2D;
|
|
@@ -1446,8 +1710,8 @@ function TWasmFresnelApi.SetTransform(aID: TCanvasID; Flags: Longint; m11, m12,
|
|
m21, m22, m31, m32: TFresnelFloat): TCanvasError;
|
|
m21, m22, m31, m32: TFresnelFloat): TCanvasError;
|
|
|
|
|
|
var
|
|
var
|
|
- Canv:TJSCanvasRenderingContext2D;
|
|
|
|
-
|
|
|
|
|
|
+ Ref : TCanvasReference;
|
|
|
|
+ DoReset : Boolean;
|
|
begin
|
|
begin
|
|
{$IFNDEF NOLOGAPICALLS}
|
|
{$IFNDEF NOLOGAPICALLS}
|
|
If LogAPICalls then
|
|
If LogAPICalls then
|
|
@@ -1455,16 +1719,12 @@ begin
|
|
LogCall('Canvas.SetTransform(%d,%d,[%g,%g,%g,%g,%g,%g])',[aID,Flags,m11,m12,m21,m22,m31,m32]);
|
|
LogCall('Canvas.SetTransform(%d,%d,[%g,%g,%g,%g,%g,%g])',[aID,Flags,m11,m12,m21,m22,m31,m32]);
|
|
end;
|
|
end;
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
- Canv:=GetCanvas(aID);
|
|
|
|
- if Not Assigned(Canv) then
|
|
|
|
|
|
+ Ref:=GetCanvasRef(aID);
|
|
|
|
+ if Not Assigned(Ref) then
|
|
Exit(ECANVAS_NOCANVAS);
|
|
Exit(ECANVAS_NOCANVAS);
|
|
- if (Flags and TRANSFORM_RESET)<>0 then
|
|
|
|
- begin
|
|
|
|
- canv.resetTransform();
|
|
|
|
- canv.setTransform(m11,m12,m21,m22,m31,m32)
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- canv.transform(m11,m12,m21,m22,m31,m32);
|
|
|
|
|
|
+ DoReset:=(Flags and TRANSFORM_RESET)<>0;
|
|
|
|
+// canv.setTransform(m11,m12,m21,m22,m31,m32)
|
|
|
|
+ Ref.SetTransform(m11,m12,m21,m22,m31,m32,DoReset);
|
|
Result:=ECANVAS_SUCCESS;
|
|
Result:=ECANVAS_SUCCESS;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -1529,6 +1789,7 @@ begin
|
|
if Not Assigned(Ref) then
|
|
if Not Assigned(Ref) then
|
|
exit;
|
|
exit;
|
|
Ref.title:=S;
|
|
Ref.title:=S;
|
|
|
|
+ Exit(ECANVAS_SUCCESS);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -1581,7 +1842,8 @@ begin
|
|
Ref:=GetCanvasRef(aID);
|
|
Ref:=GetCanvasRef(aID);
|
|
if Not Assigned(Ref) then
|
|
if Not Assigned(Ref) then
|
|
exit;
|
|
exit;
|
|
- Ref.CanvasContext.Save;
|
|
|
|
|
|
+ Ref.SaveState;
|
|
|
|
+ Ref.FClipRects:=[];
|
|
if (aFlags and STATE_FLAGS_RESTORE_PROPS)<>0 then
|
|
if (aFlags and STATE_FLAGS_RESTORE_PROPS)<>0 then
|
|
Ref.ApplyProperties;
|
|
Ref.ApplyProperties;
|
|
Result:=ECANVAS_SUCCESS;
|
|
Result:=ECANVAS_SUCCESS;
|
|
@@ -1603,13 +1865,11 @@ begin
|
|
Ref:=GetCanvasRef(aID);
|
|
Ref:=GetCanvasRef(aID);
|
|
if Not Assigned(Ref) then
|
|
if Not Assigned(Ref) then
|
|
exit;
|
|
exit;
|
|
- Ref.CanvasContext.Restore;
|
|
|
|
- if (aFlags and STATE_FLAGS_RESTORE_PROPS)<>0 then
|
|
|
|
- Ref.ApplyProperties;
|
|
|
|
|
|
+ Ref.RestoreState((aFlags and STATE_FLAGS_RESTORE_PROPS)<>0);
|
|
Result:=ECANVAS_SUCCESS;
|
|
Result:=ECANVAS_SUCCESS;
|
|
end;
|
|
end;
|
|
|
|
|
|
-Procedure TWasmFresnelApi.DrawClipRect(Ref : TCanvasReference; aX,aY,aWidth,aHeight: double);
|
|
|
|
|
|
+procedure TWasmFresnelApi.DrawClipRect(Ref: TCanvasReference; aX, aY, aWidth, aHeight: double);
|
|
|
|
|
|
var
|
|
var
|
|
col : jsvalue;
|
|
col : jsvalue;
|
|
@@ -1619,7 +1879,7 @@ begin
|
|
With Ref.canvascontext do
|
|
With Ref.canvascontext do
|
|
begin
|
|
begin
|
|
col:=strokeStyle;
|
|
col:=strokeStyle;
|
|
- strokeStyle:='rgb(255 0 0)';
|
|
|
|
|
|
+ strokeStyle:='rgb(0 255 0)';
|
|
lw:=linewidth;
|
|
lw:=linewidth;
|
|
lineWidth:=1;
|
|
lineWidth:=1;
|
|
strokeRect(aX-1,aY-1,aWidth+2,aHeight+2);
|
|
strokeRect(aX-1,aY-1,aWidth+2,aHeight+2);
|
|
@@ -1633,7 +1893,7 @@ function TWasmFresnelApi.ClipAddRect(aID: TCanvasID; aX,aY,aWidth,aHeight: TFres
|
|
|
|
|
|
var
|
|
var
|
|
Ref : TCanvasReference;
|
|
Ref : TCanvasReference;
|
|
- P2D : TJSPath2D;
|
|
|
|
|
|
+ Rect : TClipRect;
|
|
|
|
|
|
begin
|
|
begin
|
|
{$IFNDEF NOLOGAPICALLS}
|
|
{$IFNDEF NOLOGAPICALLS}
|
|
@@ -1648,9 +1908,12 @@ begin
|
|
exit;
|
|
exit;
|
|
if daClipRect in DebugAPIs then
|
|
if daClipRect in DebugAPIs then
|
|
DrawClipRect(Ref,aX,aY,aWidth,aHeight);
|
|
DrawClipRect(Ref,aX,aY,aWidth,aHeight);
|
|
- P2D:=TJSPath2D.New;
|
|
|
|
- P2D.rect(aX,aY,aWidth,aHeight);
|
|
|
|
- Ref.canvascontext.clip(P2D);
|
|
|
|
|
|
+ Rect.X:=aX;
|
|
|
|
+ Rect.Y:=aY;
|
|
|
|
+ Rect.W:=aWidth;
|
|
|
|
+ Rect.H:=aHeight;
|
|
|
|
+ Ref.AddClipRect(Rect);
|
|
|
|
+ Ref.SetClipPath;
|
|
Result:=ECANVAS_SUCCESS;
|
|
Result:=ECANVAS_SUCCESS;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -1675,20 +1938,36 @@ var
|
|
else
|
|
else
|
|
Console.Error('No more tick callback !');
|
|
Console.Error('No more tick callback !');
|
|
if not Continue then
|
|
if not Continue then
|
|
|
|
+ begin
|
|
|
|
+ {$IFNDEF NOLOGAPICALLS}
|
|
|
|
+ If LogAPICalls then
|
|
|
|
+ LogCall('FresnelAPi.TimerTick(%d), return value false, deactivate',[aTimerID]);
|
|
|
|
+ {$ENDIF}
|
|
DeAllocateTimer(aTimerID);
|
|
DeAllocateTimer(aTimerID);
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
begin
|
|
begin
|
|
|
|
+ {$IFNDEF NOLOGAPICALLS}
|
|
|
|
+ If LogAPICalls then
|
|
|
|
+ LogCall('FresnelApi.AllocateTimer(%d,[%x])',[aInterval,UserData]);
|
|
|
|
+ {$ENDIF}
|
|
Callback:=InstanceExports['__fresnel_timer_tick'];
|
|
Callback:=InstanceExports['__fresnel_timer_tick'];
|
|
if Not Assigned(Callback) then
|
|
if Not Assigned(Callback) then
|
|
Exit(0);
|
|
Exit(0);
|
|
aTimerID:=Window.setInterval(@HandleTimer,aInterval);
|
|
aTimerID:=Window.setInterval(@HandleTimer,aInterval);
|
|
Result:=aTimerID;
|
|
Result:=aTimerID;
|
|
|
|
+ {$IFNDEF NOLOGAPICALLS}
|
|
|
|
+ If LogAPICalls then
|
|
|
|
+ LogCall('FresnelApi.AllocateTimer(%d,[%x] => %d)',[aInterval,UserData,Result]);
|
|
|
|
+ {$ENDIF}
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TWasmFresnelApi.DeallocateTimer(timerid: TTimerID);
|
|
procedure TWasmFresnelApi.DeallocateTimer(timerid: TTimerID);
|
|
begin
|
|
begin
|
|
- window.clearTimeout(TimerID);
|
|
|
|
|
|
+ If LogAPICalls then
|
|
|
|
+ LogCall('FresnelApi.DeAllocateTimer(%d)',[TimerID]);
|
|
|
|
+ window.clearInterval(TimerID);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -1871,6 +2150,96 @@ begin
|
|
Result:=EWASMEVENT_SUCCESS;
|
|
Result:=EWASMEVENT_SUCCESS;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TWasmFresnelApi.HandleMenuClick(aMenuID: TMenuID; aData: TWasmPointer): Boolean;
|
|
|
|
+
|
|
|
|
+var
|
|
|
|
+ Callback : JSValue;
|
|
|
|
+
|
|
|
|
+begin
|
|
|
|
+ Result:=False;
|
|
|
|
+ if not assigned(InstanceExports) then
|
|
|
|
+ Console.warn('No instance exports !')
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ Callback:=InstanceExports['__fresnel_menu_click'];
|
|
|
|
+ if Assigned(Callback) then
|
|
|
|
+ begin
|
|
|
|
+ TMenuClickCallback(CallBack)(aMenuID,AData);
|
|
|
|
+ Result:=True;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ Console.warn('No menu click callback !');
|
|
|
|
+ end
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TWasmFresnelApi.AddMenuItem(aCanvasID: TCanvasId; aParentID: TMenuID; aCaption: TWasmPointer; aCaptionLen: Longint;
|
|
|
|
+ aData: TWasmPointer; aFlags: Longint; aShortCut: Longint; aMenuID: PMenuID): TCanvasError;
|
|
|
|
+
|
|
|
|
+var
|
|
|
|
+ S : String;
|
|
|
|
+ Ref : TCanvasReference;
|
|
|
|
+ lMenuID : TMenuID;
|
|
|
|
+ el : TJSHTMLElement;
|
|
|
|
+ lFlags : TMenuFlags;
|
|
|
|
+
|
|
|
|
+begin
|
|
|
|
+ S:=Env.GetUTF8StringFromMem(aCaption,aCaptionLen);
|
|
|
|
+ {$IFNDEF NOLOGAPICALLS}
|
|
|
|
+ If LogAPICalls then
|
|
|
|
+ begin
|
|
|
|
+ LogCall('FresnelAPI.AddMenuItem(%d,"%s",%d,[%x],[%x])',[aCanvasID,S,aParentID,aData,aMenuID]);
|
|
|
|
+ end;
|
|
|
|
+ {$ENDIF}
|
|
|
|
+ if not MenuSupport then
|
|
|
|
+ Exit(ECANVAS_NOMENUSUPPORT);
|
|
|
|
+ Ref:=GetCanvasRef(aCanvasID);
|
|
|
|
+ if not assigned(Ref) then
|
|
|
|
+ Exit(ECANVAS_NOCANVAS);
|
|
|
|
+ if not Assigned(Ref.MenuBuilder)then
|
|
|
|
+ Exit(ECANVAS_NOMENUSUPPORT);
|
|
|
|
+ lMenuID:=TFresnelHelper.AllocateMenuID;
|
|
|
|
+ LFlags:=FlagsToMenuFlags(aFlags);
|
|
|
|
+ if Ref.MenuBuilder.AddMenuItem(aParentID,lMenuID,S,lFlags,aShortCut,aData)<>Nil then
|
|
|
|
+ begin
|
|
|
|
+ Env.SetMemInfoInt32(aMenuID,lMenuID);
|
|
|
|
+ El:=TJSHTMLELement(Document.GetElementByID('ffm'+IntToStr(aCanvasID)));
|
|
|
|
+ if assigned(el) then
|
|
|
|
+ el.style.removeProperty('display');
|
|
|
|
+ end;
|
|
|
|
+ Result:=ECANVAS_SUCCESS;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TWasmFresnelApi.DeleteMenuItem(aCanvasID: TCanvasId; aMenuID: TMenuID): TCanvasError;
|
|
|
|
+var
|
|
|
|
+ S : String;
|
|
|
|
+ Ref : TCanvasReference;
|
|
|
|
+ lMenuID : TMenuID;
|
|
|
|
+ el : TJSHTMLElement;
|
|
|
|
+ lFlags : TMenuFlags;
|
|
|
|
+
|
|
|
|
+begin
|
|
|
|
+ {$IFNDEF NOLOGAPICALLS}
|
|
|
|
+ If LogAPICalls then
|
|
|
|
+ begin
|
|
|
|
+ LogCall('FresnelAPI.AddMenuItem(%d,%d)',[aCanvasID,aMenuID]);
|
|
|
|
+ end;
|
|
|
|
+ {$ENDIF}
|
|
|
|
+ if not MenuSupport then
|
|
|
|
+ Exit(ECANVAS_NOMENUSUPPORT);
|
|
|
|
+ Ref:=GetCanvasRef(aCanvasID);
|
|
|
|
+ if not assigned(Ref) then
|
|
|
|
+ Exit(ECANVAS_NOCANVAS);
|
|
|
|
+ if not Assigned(Ref.MenuBuilder)then
|
|
|
|
+ Exit(ECANVAS_NOMENUSUPPORT);
|
|
|
|
+ Ref.MenuBuilder.RemoveMenuItem(aMenuID);
|
|
|
|
+ Result:=ECANVAS_SUCCESS;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TWasmFresnelApi.UpdateMenuItem(aCanvasID: TCanvasId; aMenuID: TMenuID; aFlags: Longint; aShortCut: Longint): TCanvasError;
|
|
|
|
+begin
|
|
|
|
+
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
function TWasmFresnelApi.getcanvasbyid(aCanvasElementID: TWasmPointer; aElementIDLen: Longint; aID: TWasmPointer): TCanvasError;
|
|
function TWasmFresnelApi.getcanvasbyid(aCanvasElementID: TWasmPointer; aElementIDLen: Longint; aID: TWasmPointer): TCanvasError;
|
|
@@ -1922,7 +2291,7 @@ end;
|
|
function TWasmFresnelApi.allocatecanvas(SizeX, SizeY: Longint; aID: TWasmPointer): TCanvasError;
|
|
function TWasmFresnelApi.allocatecanvas(SizeX, SizeY: Longint; aID: TWasmPointer): TCanvasError;
|
|
|
|
|
|
Var
|
|
Var
|
|
- CTitle,CParent : TJSHTMLElement;
|
|
|
|
|
|
+ CMenu,CTitle,CParent : TJSHTMLElement;
|
|
Canv : TJSHTMLCanvasElement;
|
|
Canv : TJSHTMLCanvasElement;
|
|
Ref : TCanvasReference;
|
|
Ref : TCanvasReference;
|
|
V : TJSDataView;
|
|
V : TJSDataView;
|
|
@@ -1945,6 +2314,14 @@ begin
|
|
CTitle.id:='fft'+sID;
|
|
CTitle.id:='fft'+sID;
|
|
CTitle.className:='fresnel-window-title';
|
|
CTitle.className:='fresnel-window-title';
|
|
CParent.AppendChild(CTitle);
|
|
CParent.AppendChild(CTitle);
|
|
|
|
+ if MenuSupport then
|
|
|
|
+ begin
|
|
|
|
+ CMenu:=TJSHTMLElement(document.createElement('div'));
|
|
|
|
+ CMenu.id:='ffm'+sID;
|
|
|
|
+ CMenu.className:='fresnel-window-menu';
|
|
|
|
+ CMenu.style.setProperty('display','none');
|
|
|
|
+ CParent.AppendChild(CMenu);
|
|
|
|
+ end;
|
|
Canv:=TJSHTMLCanvasElement(document.createElement('CANVAS'));
|
|
Canv:=TJSHTMLCanvasElement(document.createElement('CANVAS'));
|
|
Canv.id:='ffc'+sID;
|
|
Canv.id:='ffc'+sID;
|
|
Canv.className:='fresnel-window-client';
|
|
Canv.className:='fresnel-window-client';
|
|
@@ -1956,6 +2333,8 @@ begin
|
|
Ref:=TCanvasReference.Create(aCanvasID,Self,Canv,CParent);
|
|
Ref:=TCanvasReference.Create(aCanvasID,Self,Canv,CParent);
|
|
Ref.WindowTitle:=CTitle;
|
|
Ref.WindowTitle:=CTitle;
|
|
Ref.textBaseline:='top';
|
|
Ref.textBaseline:='top';
|
|
|
|
+ If MenuSupport then
|
|
|
|
+ Ref.MenuBuilder:=CreateMenuBuilder(CMenu);
|
|
// Writeln('Set Ref.textBaseline ',Ref.textBaseline,' to ',Ref.canvascontext.textBaseline);
|
|
// Writeln('Set Ref.textBaseline ',Ref.textBaseline,' to ',Ref.canvascontext.textBaseline);
|
|
FCanvases[sID]:=Ref;
|
|
FCanvases[sID]:=Ref;
|
|
v.setUint32(aID, aCanvasID, env.IsLittleEndian);
|
|
v.setUint32(aID, aCanvasID, env.IsLittleEndian);
|