Window management: Difference between revisions

m
syntax highlighting fixup automation
(Added Wren)
m (syntax highlighting fixup automation)
Line 33:
 
=={{header|AutoHotkey}}==
<langsyntaxhighlight AutoHotkeylang="autohotkey">F1:: ;; when user hits the F1 key, do the following
WinGetTitle, window, A ; get identity of active window into a variable
WinMove, %window%, , 100, 100, 800, 800 ; move window to coordinates, 100, 100
Line 53:
}
WinClose, % window
return</langsyntaxhighlight>
 
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<langsyntaxhighlight lang="bbcbasic"> SWP_NOMOVE = 2
SWP_NOZORDER = 4
SW_MAXIMIZE = 3
Line 94:
PRINT "Closing the window in two seconds..."
WAIT 200
QUIT</langsyntaxhighlight>
 
=={{header|C}}==
C does not have any standard windowing library, although cross platform libraries are available, and although it's technically possible to create windows from scratch given the '''''Dark powers''''' that C commands, I chose the simplest option, the Windows API. On running this program, the user is taken over all the sub tasks listed in this task one by one.
===Windows===
<syntaxhighlight lang="c">
<lang C>
#include<windows.h>
#include<unistd.h>
Line 238:
return Msg.wParam;
}
</syntaxhighlight>
</lang>
 
=={{header|Gambas}}==
<langsyntaxhighlight lang="gambas">sWindow As New String[4]
'________________________
Public Sub Form_Open()
Line 327:
End If
 
End</langsyntaxhighlight>
Output:
<pre>
Line 352:
{{libheader|gotk3}}
{{trans|Nim}}
<langsyntaxhighlight lang="go">package main
 
import (
Line 451:
window.ShowAll()
gtk.Main()
}</langsyntaxhighlight>
 
=={{header|HicEst}}==
<langsyntaxhighlight lang="hicest">CHARACTER title="Rosetta Window_management"
REAL :: w=-333, h=25, x=1, y=0.5 ! pixels < 0, relative window size 0...1, script character size > 1
 
Line 463:
WINDOW(WIN=wh, MAXimize) ! maximize (hides the script window)
WINDOW(Kill=wh) ! close
END</langsyntaxhighlight>
 
=={{header|Icon}} and {{header|Unicon}}==
The demo program opens three windows, one with a running commentary on the action.
<langsyntaxhighlight Iconlang="icon">link graphics
 
procedure main()
Line 519:
WWrite(W3,"Enter Q or q here to quit")
WDone(W3)
end</langsyntaxhighlight>
 
{{libheader|Icon Programming Library}}
Line 526:
=={{header|Java}}==
Java cannot (easily) manipulate windows created by other programs. This code manipulates windows that it has created, but any window created in the same JVM can be controlled similarly. This example uses Swing - for AWT or SWT go figure.
<langsyntaxhighlight Javalang="java">import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Frame;
Line 717:
}
}
</syntaxhighlight>
</lang>
 
=={{header|Julia}}==
Uses the Gtk windowing package, so the package can manage Gtk's windows.
<langsyntaxhighlight lang="julia">using Gtk
 
function controlwindow(win, lab)
Line 764:
 
runwindow()
</syntaxhighlight>
</lang>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
Mathematica can only easily access and control windows created by itself.
<langsyntaxhighlight Mathematicalang="mathematica">nb=NotebookCreate[]; (*Create a window and store in a variable*)
nb===nb2 (*test for equality with another window object*)
SetOptions[nb,Visible->False](*Hide*)
Line 774:
NotebookClose[nb] (*Close*)
SetOptions[nb,WindowMargins->{{x,Automatic},{y,Automatic}}](*Move to x,y screen position*)
SetOptions[nb,WindowSize->{100,100}](*Resize*)</langsyntaxhighlight>
 
=={{header|Nim}}==
==={{libheader|gintro}}===
<langsyntaxhighlight Nimlang="nim">import os
import gintro/[glib, gobject, gtk, gio]
from gintro/gdk import processAllUpdates
Line 862:
let app = newApplication(Application, "Rosetta.Window.Management")
discard app.connect("activate", activate)
discard app.run()</langsyntaxhighlight>
 
 
==={{libheader|Gtk2}}===
<langsyntaxhighlight lang="nim">import os
import gdk2, glib2, gtk2
 
Line 941:
discard bQuit.signal_connect("clicked", SIGNAL_FUNC(thisDestroy), nil)
window.show_all()
main()</langsyntaxhighlight>
 
==={{libheader|IUP}}===
<langsyntaxhighlight lang="nim">import iup
 
# assumes you have the iup .dll or .so installed
Line 1,011:
discard dlg.show()
discard mainloop()
iup.Close()</langsyntaxhighlight>
 
=={{header|Oz}}==
Line 1,022:
because it shows how to extend an object's interface even when we don't have control over object creation.
 
<langsyntaxhighlight lang="oz">declare
[QTk] = {Module.link ['x-oz://system/wp/QTk.ozf']}
 
Line 1,109:
end
in
{Record.forAll Windows CreateWindow}</langsyntaxhighlight>
 
=={{header|Perl}}==
Line 1,119:
I wrote the code using the Tk module, as that's what I had on my computer, and I was too lazy to install Tkx. Translating from perl/tk to Tkx should be fairly trivial.
 
<langsyntaxhighlight Perllang="perl">#!perl
use strict;
use warnings;
Line 1,196:
 
__END__
</syntaxhighlight>
</lang>
 
In the Tcl code I translated from, the second label of the main window had a textvariable attribute. For some reason, this didn't work correctly for me, either due to a bug in Tk.pm, or some other reason. Because of that, I kept around a handle to that second label ($lab), and called configure on it when I needed it's text to change.
Line 1,206:
{{libheader|Phix/basics}}
{{libheader|Phix/pGUI}}
<!--<langsyntaxhighlight Phixlang="phix">-->
<span style="color: #000080;font-style:italic;">-- demo\rosetta\Window_management.exw</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">pGUI</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
Line 1,279:
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</langsyntaxhighlight>-->
 
=={{header|PicoLisp}}==
The following works on ErsatzLisp, the Java version of PicoLisp.
<langsyntaxhighlight PicoLisplang="picolisp">$ ersatz/pil +
: (setq
JFrame "javax.swing.JFrame"
Line 1,322:
 
# Close window
(java Win 'dispose)</langsyntaxhighlight>
 
=={{header|PureBasic}}==
<langsyntaxhighlight PureBasiclang="purebasic">;- Create a linked list to store created windows.
NewList Windows()
Define i, j, dh, dw, flags, err$, x, y
Line 1,384:
Delay(2000)
 
End</langsyntaxhighlight>
 
=={{header|Python}}==
Line 1,390:
{{libheader|tkinter}}
Using the tkinter GUI:
<syntaxhighlight lang="python">
<lang Python>
from tkinter import *
import tkinter.messagebox
Line 1,423:
 
mainloop()
</syntaxhighlight>
</lang>
 
=={{header|Racket}}==
<langsyntaxhighlight lang="racket">
#lang racket/gui
 
Line 1,444:
(say 'Resize) (send frame resize 100 100) (sleep 1)
(say 'Close) (send frame show #f) (sleep 1) ; that's how we close a window
</syntaxhighlight>
</lang>
 
=={{header|Raku}}==
Line 1,451:
This are generic window handling routines. They work for any window managed by the X11 display server, not just windows created by the program.
 
<syntaxhighlight lang="raku" perl6line>use X11::libxdo;
 
my $xdo = Xdo.new;
Line 1,514:
$xdo.raise-window($id);
sleep .25;
</syntaxhighlight>
</lang>
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
 
Load "guilib.ring"
Line 1,672:
###--------------------------------------------
 
</syntaxhighlight>
</lang>
 
=={{header|Tcl}}==
{{libheader|Tk}}
<langsyntaxhighlight lang="tcl">package require Tk
 
# How to open a window
Line 1,737:
grid [button .b4 -text "Maximize" -command maximizeWin] -
grid [button .b5 -text "Move" -command moveWin] -
grid [button .b6 -text "Resize" -command resizeWin] -</langsyntaxhighlight>
 
=={{header|Wren}}==
Line 1,744:
 
The following just manipulates a window created by the application itself and works fine on Ubuntu 20.04.
<langsyntaxhighlight lang="ecmascript">/* window_management.wren */
 
var GTK_WINDOW_TOPLEVEL = 0
Line 1,860:
buttonBox.add(btnClose)
 
Window.showAll()</langsyntaxhighlight>
<br>
We now embed the above script in the following C program, build and run.
<langsyntaxhighlight lang="c">/* gcc `pkg-config --cflags gtk+-3.0` -DGDK_VERSION_MIN_REQIRED=GDK_VERSION_3_2 window_management.c -o window_management `pkg-config --libs gtk+-3.0` -lwren -lm */
 
#include <stdlib.h>
Line 2,112:
free(script);
return 0;
}</langsyntaxhighlight>
10,333

edits