Skip to content

Commit 59dd64c

Browse files
committed
Added asMain parameter
1 parent 68f2dbf commit 59dd64c

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/EmptyFlow.SciterAPI/Client/HostWindowsAPI.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ public void CloseWindow ( IntPtr window ) {
3131
/// <param name="debugOutput">It will be showed output in stout or not.</param>
3232
/// <param name="hostCallback">Host callback, can be remake all default events like bahaviour, create window or so on. If omit will be apply default just like in main window.</param>
3333
/// <param name="parent">Can be specified parent window, can be useful in some cases.</param>
34+
/// <param name="asMain">Point to main window will be stored to SciterAPIHost instance and can be accessed via <see cref="MainWindow"/> property.</param>
3435
/// <returns>Pointer to created window.</returns>
35-
public nint CreateWindow ( int width = 0, int height = 0, int x = 0, int y = 0, WindowsFlags? flags = default, bool debugOutput = false, SciterHostCallback? hostCallback = default, nint parent = default ) {
36+
public nint CreateWindow ( int width = 0, int height = 0, int x = 0, int y = 0, WindowsFlags? flags = default, bool debugOutput = false, SciterHostCallback? hostCallback = default, nint parent = default, bool asMain = false ) {
37+
if ( asMain && m_mainWindow != nint.Zero ) throw new Exception ( "The main window had already been created earlier!" );
38+
3639
var rectangePointer = nint.Zero;
3740
if ( width > 0 && height > 0 ) {
3841
var rectangle = new SciterRectangle ( x, y, width, height );
@@ -63,6 +66,8 @@ public void CloseWindow ( IntPtr window ) {
6366

6467
m_callbacks.RegisterWindowCallback ( windowPointer, hostCallback );
6568

69+
if ( asMain ) m_mainWindow = windowPointer;
70+
6671
return windowPointer;
6772
}
6873

src/EmptyFlow.SciterAPI/Client/SciterAPIHost.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,21 @@ public static IntPtr WindowsDelegateImplementaion ( IntPtr hwnd, uint msg, IntPt
104104
return 0;
105105
}
106106

107+
public void EnableDebugMode () => m_basicApi.SciterSetOption ( IntPtr.Zero, RtOptions.SCITER_SET_DEBUG_MODE, new IntPtr ( 1 ) );
108+
109+
public void EnableFeatures ( SciterRuntimeFeatures? features = default ) {
110+
var appliedFeature = features.HasValue ? features.Value : DefaultRuntimeFeatures;
111+
m_basicApi.SciterSetOption ( IntPtr.Zero, RtOptions.SCITER_SET_SCRIPT_RUNTIME_FEATURES, new IntPtr ( (int) appliedFeature ) );
112+
}
113+
114+
/// <summary>
115+
/// Create main window shortcut.
116+
/// </summary>
117+
/// <param name="width">Width of window.</param>
118+
/// <param name="height">Height of window.</param>
119+
/// <param name="enableDebug">Not worked now, need to use method <see cref="EnableDebugMode"/></param>
120+
/// <param name="enableFeature">Not worked now, need to use method <see cref="EnableFeatures"/></param>
121+
/// <param name="flags">Setup window flags.</param>
107122
public void CreateMainWindow ( int width = 0, int height = 0, bool enableDebug = false, bool enableFeature = false, WindowsFlags? flags = default ) {
108123
if ( enableDebug ) m_basicApi.SciterSetOption ( IntPtr.Zero, RtOptions.SCITER_SET_DEBUG_MODE, new IntPtr ( 1 ) );
109124
if ( enableFeature ) m_basicApi.SciterSetOption ( IntPtr.Zero, RtOptions.SCITER_SET_SCRIPT_RUNTIME_FEATURES, new IntPtr ( (int) DefaultRuntimeFeatures ) );

src/EmptyFlow.SciterAPI/EmptyFlow.SciterAPI.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
<Version>1.2.1.0</Version>
2222
<PackageLicenseFile>LICENSE</PackageLicenseFile>
2323
<PackageReleaseNotes>
24-
SciterAPIHost.CreateWindow extra way to create additional (from main) windows from C#
24+
SciterAPIHost.CreateWindow new way to create windows from C#
2525
SciterAPIHost.LoadFile added parameter windowPointer
2626
SciterAPIHost.LoadHtml added parameter windowPointer
2727
SciterAPIHost.AddWindowEventHandler added parameter windowPointer
2828
SciterAPIHost.UpdateWindow request calculation of layout of elements inside the window
2929
SciterAPIHost.CountOfScreens get count of screens
30+
SciterAPIHost.EnableDebugMode now enabling these mode to responsible of method CreateMainWindow
31+
SciterAPIHost.EnableFeatures now enabling these mode to responsible of method CreateMainWindow
3032
Move SciterEventHandler basic stuff to lite class SciterEventHandlerRaw
3133
Fixed window management methods in SciterAPIHost for custom window
3234
Added new class DeveloperConsole contains few helpers can be useful in development

0 commit comments

Comments
 (0)