Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions public/usage-examples/windows/current_window-1-example-oop.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using SplashKitSDK;

namespace CurrentWindowExample
{
public static class Program
{
public static void Main()
{
Window displayWindow = SplashKit.OpenWindow("Current Window Example", 800, 600);

while (!SplashKit.QuitRequested())
{
SplashKit.ProcessEvents();

displayWindow = SplashKit.CurrentWindow();

int width = SplashKit.WindowWidth(displayWindow);
int height = SplashKit.WindowHeight(displayWindow);
string caption = SplashKit.WindowCaption(displayWindow);
string currentStatus = SplashKit.IsCurrentWindow(displayWindow).ToString();

SplashKit.ClearWindow(displayWindow, Color.White);

SplashKit.DrawText("Using current_window()", Color.Black, 20, 20);
SplashKit.DrawText("Caption: " + caption, Color.Black, 20, 60);
SplashKit.DrawText("Window Width: " + width, Color.Black, 20, 100);
SplashKit.DrawText("Window Height: " + height, Color.Black, 20, 140);
SplashKit.DrawText("Is Current Window: " + currentStatus, Color.Black, 20, 180);

SplashKit.FillRectangle(Color.Blue, 20, 230, width - 40, 80);
SplashKit.DrawText("This rectangle is drawn in the current window.", Color.White, 40, 260);

SplashKit.RefreshWindow(displayWindow, 60U);
}

SplashKit.CloseWindow(displayWindow);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using SplashKitSDK;
using static SplashKitSDK.SplashKit;

Window displayWindow = OpenWindow("Current Window Example", 800, 600);

while (!QuitRequested())
{
ProcessEvents();

displayWindow = CurrentWindow();

int width = WindowWidth(displayWindow);
int height = WindowHeight(displayWindow);
string caption = WindowCaption(displayWindow);
string currentStatus = IsCurrentWindow(displayWindow).ToString();

ClearWindow(displayWindow, ColorWhite());

DrawText("Using current_window()", ColorBlack(), 20, 20);
DrawText("Caption: " + caption, ColorBlack(), 20, 60);
DrawText("Window Width: " + width, ColorBlack(), 20, 100);
DrawText("Window Height: " + height, ColorBlack(), 20, 140);
DrawText("Is Current Window: " + currentStatus, ColorBlack(), 20, 180);

FillRectangle(ColorBlue(), 20, 230, width - 40, 80);
DrawText("This rectangle is drawn in the current window.", ColorWhite(), 40, 260);

RefreshWindow(displayWindow, 60U);
}

CloseWindow(displayWindow);
36 changes: 36 additions & 0 deletions public/usage-examples/windows/current_window-1-example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "splashkit.h"
#include <string>

int main()
{
window display_window = open_window("Current Window Example", 800, 600);

while (!quit_requested())
{
process_events();

display_window = current_window();

int width = window_width(display_window);
int height = window_height(display_window);
string caption = window_caption(display_window);
string current_status = is_current_window(display_window) ? "true" : "false";

clear_window(display_window, COLOR_WHITE);

draw_text("Using current_window()", COLOR_BLACK, 20, 20);
draw_text("Caption: " + caption, COLOR_BLACK, 20, 60);
draw_text("Window Width: " + std::to_string(width), COLOR_BLACK, 20, 100);
draw_text("Window Height: " + std::to_string(height), COLOR_BLACK, 20, 140);
draw_text("Is Current Window: " + current_status, COLOR_BLACK, 20, 180);

fill_rectangle(COLOR_BLUE, 20, 230, width - 40, 80);
draw_text("This rectangle is drawn in the current window.", COLOR_WHITE, 40, 260);

refresh_window(display_window, 60);
}

close_window(display_window);

return 0;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions public/usage-examples/windows/current_window-1-example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from splashkit import *

display_window = open_window("Current Window Example", 800, 600)

while not quit_requested():
process_events()

display_window = current_window()

width = window_width(display_window)
height = window_height(display_window)
caption = window_caption(display_window)
current_status = str(is_current_window(display_window))

clear_window(display_window, color_white())

draw_text_no_font_no_size("Using current_window()", color_black(), 20, 20)
draw_text_no_font_no_size("Caption: " + caption, color_black(), 20, 60)
draw_text_no_font_no_size("Window Width: " + str(width), color_black(), 20, 100)
draw_text_no_font_no_size("Window Height: " + str(height), color_black(), 20, 140)
draw_text_no_font_no_size("Is Current Window: " + current_status, color_black(), 20, 180)

fill_rectangle(color_blue(), 20, 230, width - 40, 80)
draw_text_no_font_no_size("This rectangle is drawn in the current window.", color_white(), 40, 260)

refresh_window_with_target_fps(display_window, 60)

close_window(display_window)
1 change: 1 addition & 0 deletions public/usage-examples/windows/current_window-1-example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Using the Current Window Object