Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Window-creation/00-META.yaml
Normal file
5
Task/Window-creation/00-META.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
from: http://rosettacode.org/wiki/Window_creation
|
||||
note: GUI
|
||||
requires:
|
||||
- Graphics
|
||||
2
Task/Window-creation/00-TASK.txt
Normal file
2
Task/Window-creation/00-TASK.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Display a [[GUI]] window. The window need not have any contents, but should respond to requests to be closed.
|
||||
|
||||
39
Task/Window-creation/ALGOL-68/window-creation.alg
Normal file
39
Task/Window-creation/ALGOL-68/window-creation.alg
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
PROGRAM firstgtk CONTEXT VOID
|
||||
USE standard
|
||||
BEGIN
|
||||
MODE GDATA = REF BITS;
|
||||
MODE GUINT = BITS;
|
||||
MODE GSIZE = BITS;
|
||||
MODE GTYPE = GSIZE;
|
||||
MODE GTYPECLASS = STRUCT(GTYPE g type);
|
||||
MODE GTYPEINSTANCE = STRUCT(REF GTYPECLASS g class);
|
||||
MODE GTKWIDGETPRIVATE = REF BITS;
|
||||
|
||||
MODE GOBJECT = STRUCT(
|
||||
GTYPEINSTANCE g type instance,
|
||||
GUINT ref count,
|
||||
REF GDATA qdata);
|
||||
|
||||
MODE GTKWIDGET = STRUCT(
|
||||
GOBJECT parent instance,
|
||||
REF GTKWIDGETPRIVATE priv);
|
||||
|
||||
PROC(REF INT,REF CCHARPTRPTR)VOID gtk init = ALIEN "GTK_INIT"
|
||||
"#define GTK_INIT(argc,argv) gtk_init(argc,argv)";
|
||||
PROC(INT)REF GTKWIDGET gtk window new = ALIEN "GTK_WINDOW_NEW"
|
||||
"#define GTK_WINDOW_NEW(type) (void *)gtk_window_new(type)";
|
||||
PROC(REF GTKWIDGET)VOID gtk widget show = ALIEN "GTK_WIDGET_SHOW"
|
||||
"#define GTK_WIDGET_SHOW(widget) gtk_widget_show((void *)widget)";
|
||||
PROC gtk main = VOID: CODE "gtk_main();";
|
||||
|
||||
INT gtk window toplevel = 0;
|
||||
FILE argf;
|
||||
REF GTKWIDGET window;
|
||||
|
||||
open(argf,"",arg channel);
|
||||
gtk init(argc,argv);
|
||||
window:=gtk window new(gtk window toplevel);
|
||||
gtk widget show(window);
|
||||
gtk main
|
||||
END
|
||||
FINISH
|
||||
41
Task/Window-creation/Ada/window-creation.ada
Normal file
41
Task/Window-creation/Ada/window-creation.ada
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
with Gtk.Window; use Gtk.Window;
|
||||
with Gtk.Widget; use Gtk.Widget;
|
||||
|
||||
with Gtk.Handlers;
|
||||
with Gtk.Main;
|
||||
|
||||
procedure Windowed_Application is
|
||||
Window : Gtk_Window;
|
||||
|
||||
package Handlers is new Gtk.Handlers.Callback (Gtk_Widget_Record);
|
||||
package Return_Handlers is
|
||||
new Gtk.Handlers.Return_Callback (Gtk_Widget_Record, Boolean);
|
||||
|
||||
function Delete_Event (Widget : access Gtk_Widget_Record'Class)
|
||||
return Boolean is
|
||||
begin
|
||||
return False;
|
||||
end Delete_Event;
|
||||
|
||||
procedure Destroy (Widget : access Gtk_Widget_Record'Class) is
|
||||
begin
|
||||
Gtk.Main.Main_Quit;
|
||||
end Destroy;
|
||||
|
||||
begin
|
||||
Gtk.Main.Init;
|
||||
Gtk.Window.Gtk_New (Window);
|
||||
Return_Handlers.Connect
|
||||
( Window,
|
||||
"delete_event",
|
||||
Return_Handlers.To_Marshaller (Delete_Event'Access)
|
||||
);
|
||||
Handlers.Connect
|
||||
( Window,
|
||||
"destroy",
|
||||
Handlers.To_Marshaller (Destroy'Access)
|
||||
);
|
||||
Show (Window);
|
||||
|
||||
Gtk.Main.Main;
|
||||
end Windowed_Application;
|
||||
1
Task/Window-creation/AmigaBASIC/window-creation.basic
Normal file
1
Task/Window-creation/AmigaBASIC/window-creation.basic
Normal file
|
|
@ -0,0 +1 @@
|
|||
WINDOW 2,"New Window"
|
||||
2
Task/Window-creation/AutoHotkey/window-creation.ahk
Normal file
2
Task/Window-creation/AutoHotkey/window-creation.ahk
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Gui, Add, Text,, Hello
|
||||
Gui, Show
|
||||
9
Task/Window-creation/AutoIt/window-creation.autoit
Normal file
9
Task/Window-creation/AutoIt/window-creation.autoit
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
GUICreate("Test")
|
||||
GUISetState(@SW_SHOW)
|
||||
|
||||
Do
|
||||
Switch GUIGetMsg()
|
||||
Case -3 ; $GUI_EVENT_CLOSE
|
||||
Exit
|
||||
EndSwitch
|
||||
Until False
|
||||
2
Task/Window-creation/BASIC256/window-creation.basic
Normal file
2
Task/Window-creation/BASIC256/window-creation.basic
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
clg
|
||||
text (50,50, "I write in the graphics area")
|
||||
3
Task/Window-creation/BBC-BASIC/window-creation.basic
Normal file
3
Task/Window-creation/BBC-BASIC/window-creation.basic
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
INSTALL @lib$+"WINLIB2"
|
||||
dlg% = FN_newdialog("GUI Window", 0, 0, 200, 150, 8, 1000)
|
||||
PROC_showdialog(dlg%)
|
||||
7
Task/Window-creation/BaCon/window-creation.bacon
Normal file
7
Task/Window-creation/BaCon/window-creation.bacon
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
REM empty window
|
||||
INCLUDE "hug.bac"
|
||||
|
||||
mainwin = WINDOW("Rosetta Code empty", 400, 300)
|
||||
|
||||
REM start gtk event loop...
|
||||
DISPLAY
|
||||
10
Task/Window-creation/C++/window-creation-1.cpp
Normal file
10
Task/Window-creation/C++/window-creation-1.cpp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
QMainWindow window;
|
||||
window.show();
|
||||
return app.exec();
|
||||
}
|
||||
21
Task/Window-creation/C++/window-creation-2.cpp
Normal file
21
Task/Window-creation/C++/window-creation-2.cpp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#include <iostream>
|
||||
#include <gtkmm.h>
|
||||
|
||||
int
|
||||
main( int argc, char* argv[] )
|
||||
{
|
||||
try
|
||||
{
|
||||
Gtk::Main m( argc, argv ) ;
|
||||
Gtk::Window win ;
|
||||
m.run( win ) ;
|
||||
}
|
||||
|
||||
catch( std::exception const & exc )
|
||||
{
|
||||
std::cout << exc.what() << std::endl ;
|
||||
exit( -1 ) ;
|
||||
}
|
||||
|
||||
exit( 0 ) ;
|
||||
}
|
||||
15
Task/Window-creation/C-sharp/window-creation.cs
Normal file
15
Task/Window-creation/C-sharp/window-creation.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
public class Window {
|
||||
[STAThread]
|
||||
static void Main() {
|
||||
Form form = new Form();
|
||||
|
||||
form.Text = "Window";
|
||||
form.Disposed += delegate { Application.Exit(); };
|
||||
|
||||
form.Show();
|
||||
Application.Run();
|
||||
}
|
||||
}
|
||||
22
Task/Window-creation/C/window-creation-1.c
Normal file
22
Task/Window-creation/C/window-creation-1.c
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Opens an 800x600 16bit color window.
|
||||
* Done here with ANSI C.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "SDL.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
SDL_Surface *screen;
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
atexit(SDL_Quit);
|
||||
screen = SDL_SetVideoMode( 800, 600, 16, SDL_SWSURFACE | SDL_HWPALETTE );
|
||||
|
||||
return 0;
|
||||
}
|
||||
16
Task/Window-creation/C/window-creation-2.c
Normal file
16
Task/Window-creation/C/window-creation-2.c
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_signal_connect(GTK_OBJECT(window), "destroy",
|
||||
GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
|
||||
gtk_widget_show(window);
|
||||
gtk_main();
|
||||
|
||||
return 0;
|
||||
}
|
||||
15
Task/Window-creation/C/window-creation-3.c
Normal file
15
Task/Window-creation/C/window-creation-3.c
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
g_signal_connect (window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
|
||||
gtk_widget_show(window);
|
||||
gtk_main();
|
||||
|
||||
return 0;
|
||||
}
|
||||
40
Task/Window-creation/C/window-creation-4.c
Normal file
40
Task/Window-creation/C/window-creation-4.c
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// A C+GLUT implementation of the Creating a Window task at Rosetta Code
|
||||
// http://rosettacode.org/wiki/Creating_a_Window
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
// This function is not strictly necessary to meet the requirements of the task.
|
||||
void onKeyPress(unsigned char key, int x, int y)
|
||||
{
|
||||
// If you have any cleanup or such, you need to use C's
|
||||
// onexit routine for registering cleanup callbacks.
|
||||
exit(0);
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// Pulls out any command-line arguments that are specific to GLUT,
|
||||
// And leaves a command-line argument set without any of those arguments
|
||||
// when it returns.
|
||||
// (If you want a copy, take a copy first.)
|
||||
glutInit(&argc, argv);
|
||||
|
||||
// Tell GLUT we want to create a window.
|
||||
// It won't *actually* be created until we call glutMainLoop below.
|
||||
glutCreateWindow("Goodbye, World!");
|
||||
|
||||
// Register a callback to handle key press events (so we can quit on
|
||||
// when someone hits a key) This part is not necessary to meet the
|
||||
// requirements of the task.
|
||||
glutKeyboardFunc(&onKeyPress);
|
||||
|
||||
// Put the execution of the app in glut's hands. Most GUI environments
|
||||
// involve a message loop that communicate window events. GLUT handles
|
||||
// most of these with defaults, except for any we register callbacks
|
||||
// for. (Like the onKeyPress above.)
|
||||
glutMainLoop();
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
6
Task/Window-creation/Clojure/window-creation.clj
Normal file
6
Task/Window-creation/Clojure/window-creation.clj
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(import '(javax.swing JFrame))
|
||||
|
||||
(let [frame (JFrame. "A Window")]
|
||||
(doto frame
|
||||
(.setSize 600 800)
|
||||
(.setVisible true)))
|
||||
1
Task/Window-creation/Common-Lisp/window-creation-1.lisp
Normal file
1
Task/Window-creation/Common-Lisp/window-creation-1.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(capi:display (make-instance 'capi:interface :title "A Window"))
|
||||
4
Task/Window-creation/Common-Lisp/window-creation-2.lisp
Normal file
4
Task/Window-creation/Common-Lisp/window-creation-2.lisp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(require :mcclim)
|
||||
(cl:defpackage #:rc-window
|
||||
(:use #:clim-lisp #:clim))
|
||||
(cl:in-package #:rc-window)
|
||||
5
Task/Window-creation/Common-Lisp/window-creation-3.lisp
Normal file
5
Task/Window-creation/Common-Lisp/window-creation-3.lisp
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(define-application-frame rc-window ()
|
||||
()
|
||||
(:layouts (:default)))
|
||||
|
||||
(run-frame-top-level (make-application-frame 'rc-window))
|
||||
7
Task/Window-creation/Common-Lisp/window-creation-4.lisp
Normal file
7
Task/Window-creation/Common-Lisp/window-creation-4.lisp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
(defun create-window ()
|
||||
"Creates a window"
|
||||
(let ((window (jnew (jconstructor "javax.swing.JFrame"))))
|
||||
(jcall (jmethod "javax.swing.JFrame" "setVisible" "boolean")
|
||||
window (make-immediate-object t :boolean))))
|
||||
|
||||
(create-window)
|
||||
9
Task/Window-creation/D/window-creation-1.d
Normal file
9
Task/Window-creation/D/window-creation-1.d
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
module Window;
|
||||
|
||||
import fltk4d.all;
|
||||
|
||||
void main() {
|
||||
auto window = new Window(300, 300, "A window");
|
||||
window.show;
|
||||
FLTK.run;
|
||||
}
|
||||
32
Task/Window-creation/D/window-creation-2.d
Normal file
32
Task/Window-creation/D/window-creation-2.d
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import derelict.sdl.sdl;
|
||||
|
||||
int main(char[][] args)
|
||||
{
|
||||
DerelictSDL.load();
|
||||
|
||||
SDL_Event event;
|
||||
auto done = false;
|
||||
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
scope(exit) SDL_Quit();
|
||||
|
||||
SDL_SetVideoMode(1024, 768, 0, SDL_OPENGL);
|
||||
SDL_WM_SetCaption("My first Window", "SDL test");
|
||||
|
||||
while (!done)
|
||||
{
|
||||
if (SDL_PollEvent(&event) == 1)
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_QUIT:
|
||||
done = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
6
Task/Window-creation/D/window-creation-3.d
Normal file
6
Task/Window-creation/D/window-creation-3.d
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import qd;
|
||||
|
||||
void main() {
|
||||
screen(640, 480);
|
||||
while (true) events();
|
||||
}
|
||||
56
Task/Window-creation/Delphi/window-creation-1.delphi
Normal file
56
Task/Window-creation/Delphi/window-creation-1.delphi
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
// The project file (Project1.dpr)
|
||||
program Project1;
|
||||
|
||||
uses
|
||||
Forms,
|
||||
// Include file with Window class declaration (see below)
|
||||
Unit0 in 'Unit1.pas' {Form1};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
||||
|
||||
// The Window class declaration
|
||||
unit Unit1;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Forms;
|
||||
|
||||
type
|
||||
TForm1 = class(TForm)
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm} // The window definition resource (see below)
|
||||
|
||||
end.
|
||||
|
||||
// A textual rendition of the Window (form) definition file (Unit1.dfm)
|
||||
object Form1: TForm1
|
||||
Left = 469
|
||||
Top = 142
|
||||
Width = 800
|
||||
Height = 600
|
||||
Caption = 'Form1'
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'MS Shell Dlg 2'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poScreenCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
end
|
||||
63
Task/Window-creation/Delphi/window-creation-2.delphi
Normal file
63
Task/Window-creation/Delphi/window-creation-2.delphi
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
program Project3;
|
||||
|
||||
uses
|
||||
Windows,
|
||||
Messages;
|
||||
|
||||
var
|
||||
WndClass: TWndClass;
|
||||
Msg: TMsg;
|
||||
winT, winL: Integer;
|
||||
|
||||
// Initial height/width of the window
|
||||
const
|
||||
winW: Integer = 800;
|
||||
winH: Integer = 600;
|
||||
|
||||
// Callback function to processes messages sent to the window
|
||||
function WindowProc(hWnd,Msg,wParam,lParam:Integer): Integer; stdcall;
|
||||
begin
|
||||
// Trap the WM_DESTROY message
|
||||
if (Msg = WM_DESTROY) then PostQuitMessage(0);
|
||||
Result := DefWindowProc(hWnd,Msg,wParam,lParam);
|
||||
end;
|
||||
|
||||
begin
|
||||
// Fill the WndClass structure with the window class attributes
|
||||
// to be registered by the RegisterClass function
|
||||
with WndClass do
|
||||
begin
|
||||
lpszClassName:= 'Form1';
|
||||
lpfnWndProc := @WindowProc; // Pointer to our message handling callback
|
||||
style := CS_OWNDC or // Request a unique device context
|
||||
CS_VREDRAW or // Redraw window when resized vertically
|
||||
CS_HREDRAW; // Redraw window when resized horizontally
|
||||
hInstance := hInstance; // The instance that the window procedure of this class is within
|
||||
hbrBackground := HBRUSH(COLOR_BTNFACE+1); // Background colour of the window
|
||||
end;
|
||||
|
||||
// Register the window class for use by CreateWindow
|
||||
RegisterClass(WndClass);
|
||||
|
||||
// Calculate initial top and left positions of the window
|
||||
winT := (GetSystemMetrics(SM_CYFULLSCREEN) - winH) div 2;
|
||||
winL := (GetSystemMetrics(SM_CXFULLSCREEN) - winW) div 2;
|
||||
|
||||
// Create the window
|
||||
CreateWindow(WndClass.lpszClassName, // Class name
|
||||
'Form1', // Window name
|
||||
WS_OVERLAPPEDWINDOW or WS_VISIBLE, // Window style
|
||||
winL, // Horizontal Position (Left)
|
||||
winT, // Vertical Position (Top)
|
||||
winW, // Width
|
||||
winH, // Height
|
||||
0, // Window parent/owner handle
|
||||
0, // Menu handle
|
||||
hInstance, // Handle to application instance
|
||||
nil); // Pointer to window creation data
|
||||
|
||||
// Handle messages
|
||||
while GetMessage(Msg,0,0,0) do
|
||||
DispatchMessage(Msg);
|
||||
|
||||
end.
|
||||
5
Task/Window-creation/Dragon/window-creation.dragon
Normal file
5
Task/Window-creation/Dragon/window-creation.dragon
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
select "GUI"
|
||||
|
||||
window = newWindow("Window")
|
||||
window.setSize(400,600)
|
||||
window.setVisible()
|
||||
19
Task/Window-creation/Eiffel/window-creation-1.e
Normal file
19
Task/Window-creation/Eiffel/window-creation-1.e
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
class
|
||||
APPLICATION
|
||||
inherit
|
||||
EV_APPLICATION
|
||||
create
|
||||
make_and_launch
|
||||
feature {NONE} -- Initialization
|
||||
make_and_launch
|
||||
-- Initialize and launch application
|
||||
do
|
||||
default_create
|
||||
create first_window
|
||||
first_window.show
|
||||
launch
|
||||
end
|
||||
feature {NONE} -- Implementation
|
||||
first_window: MAIN_WINDOW
|
||||
-- Main window.
|
||||
end
|
||||
51
Task/Window-creation/Eiffel/window-creation-2.e
Normal file
51
Task/Window-creation/Eiffel/window-creation-2.e
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
class
|
||||
MAIN_WINDOW
|
||||
inherit
|
||||
EV_TITLED_WINDOW
|
||||
redefine
|
||||
initialize
|
||||
end
|
||||
create
|
||||
default_create
|
||||
feature {NONE} -- Initialization
|
||||
initialize
|
||||
-- Build the interface for this window.
|
||||
do
|
||||
-- Call initialize in parent class EV_TITLED_WINDOW
|
||||
Precursor {EV_TITLED_WINDOW}
|
||||
-- Build a container for widgets for this window
|
||||
build_main_container
|
||||
-- Add the container to this window
|
||||
extend (main_container)
|
||||
-- Add `request_close_window' to the actions taken when the user clicks
|
||||
-- on the cross in the title bar.
|
||||
close_request_actions.extend (agent request_close_window)
|
||||
-- Set the title of the window
|
||||
set_title ("Rosetta Code")
|
||||
-- Set the initial size of the window
|
||||
set_size (400, 400)
|
||||
end
|
||||
feature {NONE} -- Implementation, Close event
|
||||
request_close_window
|
||||
-- The user wants to close the window
|
||||
do
|
||||
-- Destroy this window
|
||||
destroy;
|
||||
-- Destroy application
|
||||
(create {EV_ENVIRONMENT}).application.destroy
|
||||
end
|
||||
feature {NONE} -- Implementation
|
||||
main_container: EV_VERTICAL_BOX
|
||||
-- Main container contains all widgets displayed in this window.
|
||||
-- In this case a single text area.
|
||||
build_main_container
|
||||
-- Create and populate `main_container'.
|
||||
require
|
||||
main_container_not_yet_created: main_container = Void
|
||||
do
|
||||
create main_container
|
||||
main_container.extend (create {EV_TEXT})
|
||||
ensure
|
||||
main_container_created: main_container /= Void
|
||||
end
|
||||
end
|
||||
19
Task/Window-creation/Eiffel/window-creation-3.e
Normal file
19
Task/Window-creation/Eiffel/window-creation-3.e
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
class
|
||||
APPLICATION
|
||||
inherit
|
||||
WINFORMS_FORM
|
||||
rename
|
||||
make as make_form
|
||||
end
|
||||
create
|
||||
make
|
||||
feature {NONE} -- Initialization
|
||||
make
|
||||
-- Run application.
|
||||
do
|
||||
-- Set window title
|
||||
set_text ("Rosetta Code")
|
||||
-- Launch application
|
||||
{WINFORMS_APPLICATION}.run_form (Current)
|
||||
end
|
||||
end
|
||||
1
Task/Window-creation/Emacs-Lisp/window-creation.l
Normal file
1
Task/Window-creation/Emacs-Lisp/window-creation.l
Normal file
|
|
@ -0,0 +1 @@
|
|||
(make-frame)
|
||||
5
Task/Window-creation/Euphoria/window-creation-1.euphoria
Normal file
5
Task/Window-creation/Euphoria/window-creation-1.euphoria
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
include arwen.ew
|
||||
|
||||
constant win = create(Window, "ARWEN window", 0, 0,100,100,640,480,{0,0})
|
||||
|
||||
WinMain(win, SW_NORMAL)
|
||||
6
Task/Window-creation/Euphoria/window-creation-2.euphoria
Normal file
6
Task/Window-creation/Euphoria/window-creation-2.euphoria
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
include GtkEngine.e
|
||||
|
||||
constant win = create(GtkWindow,"title=EuGTK Window;size=640x480;border=10;$destroy=Quit")
|
||||
|
||||
show_all(win)
|
||||
main()
|
||||
10
Task/Window-creation/Euphoria/window-creation-3.euphoria
Normal file
10
Task/Window-creation/Euphoria/window-creation-3.euphoria
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
include EuWinGUI.ew
|
||||
|
||||
Window("EuWinGUI window",100,100,640,480)
|
||||
|
||||
-- Event loop
|
||||
while True do
|
||||
WaitEvent()
|
||||
end while
|
||||
|
||||
CloseApp(0)
|
||||
5
Task/Window-creation/Euphoria/window-creation-4.euphoria
Normal file
5
Task/Window-creation/Euphoria/window-creation-4.euphoria
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
include Win32Lib.ew
|
||||
|
||||
constant win = createEx( Window, "Win32Lib", 0, Default, Default, 640, 480, 0, 0 )
|
||||
|
||||
WinMain( win, Normal )
|
||||
5
Task/Window-creation/Euphoria/window-creation-5.euphoria
Normal file
5
Task/Window-creation/Euphoria/window-creation-5.euphoria
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
include wxeu/wxeud.e
|
||||
|
||||
constant win = create( wxFrame, {0, -1, "wxEuphoria window", -1, -1, 640, 480} )
|
||||
|
||||
wxMain( win )
|
||||
6
Task/Window-creation/F-Sharp/window-creation.fs
Normal file
6
Task/Window-creation/F-Sharp/window-creation.fs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
open System.Windows.Forms
|
||||
|
||||
[<System.STAThread>]
|
||||
do
|
||||
Form(Text = "F# Window")
|
||||
|> Application.Run
|
||||
3
Task/Window-creation/Factor/window-creation.factor
Normal file
3
Task/Window-creation/Factor/window-creation.factor
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
USING: ui ui.gadgets.labels ;
|
||||
|
||||
"This is a window..." <label> "Really?" open-window
|
||||
9
Task/Window-creation/Fantom/window-creation.fantom
Normal file
9
Task/Window-creation/Fantom/window-creation.fantom
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
using fwt
|
||||
|
||||
class Main
|
||||
{
|
||||
public static Void main ()
|
||||
{
|
||||
Window().open
|
||||
}
|
||||
}
|
||||
33
Task/Window-creation/Forth/window-creation-1.fth
Normal file
33
Task/Window-creation/Forth/window-creation-1.fth
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
include ffl/gsv.fs
|
||||
|
||||
\ Open the connection to the gtk-server and load the Gtk2 definitions
|
||||
s" gtk-server.cfg" s" ffl-fifo" gsv+open 0= [IF]
|
||||
|
||||
\ Convert the string event to a widget id
|
||||
: event>widget
|
||||
0. 2swap >number 2drop d>s
|
||||
;
|
||||
|
||||
0 value window
|
||||
|
||||
: window-creation
|
||||
gtk_init
|
||||
|
||||
\ Create the window
|
||||
GTK_WINDOW_TOPLEVEL gtk_window_new to window
|
||||
|
||||
window gtk_widget_show
|
||||
|
||||
\ Wait for an event
|
||||
BEGIN
|
||||
s" WAIT" gtk_server_callback
|
||||
event>widget window =
|
||||
UNTIL
|
||||
|
||||
0 gtk_exit
|
||||
;
|
||||
|
||||
window-creation
|
||||
|
||||
gsv+close drop
|
||||
[THEN]
|
||||
5
Task/Window-creation/Forth/window-creation-2.fth
Normal file
5
Task/Window-creation/Forth/window-creation-2.fth
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Window+ w \ create a window
|
||||
View v \ create a view
|
||||
300 30 430 230 put: frameRect \ size a rectangle for the view
|
||||
frameRect " Test" docWindow v new: w \ activate the view and window
|
||||
show: w \ display the window
|
||||
16
Task/Window-creation/FreeBASIC/window-creation.basic
Normal file
16
Task/Window-creation/FreeBASIC/window-creation.basic
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#Include "windows.bi"
|
||||
|
||||
Dim As HWND Window_Main
|
||||
Dim As MSG msg
|
||||
|
||||
'Create the window:
|
||||
Window_Main = CreateWindow("#32770", "I am a window - close me!", WS_OVERLAPPEDWINDOW Or WS_VISIBLE, 100, 100, 350, 200, 0, 0, 0, 0)
|
||||
|
||||
'Windows message loop:
|
||||
While GetMessage(@msg, Window_Main, 0, 0)
|
||||
TranslateMessage(@msg)
|
||||
DispatchMessage(@msg)
|
||||
If msg.hwnd = Window_Main And msg.message = WM_COMMAND Then End
|
||||
Wend
|
||||
|
||||
End
|
||||
1
Task/Window-creation/Frink/window-creation.frink
Normal file
1
Task/Window-creation/Frink/window-creation.frink
Normal file
|
|
@ -0,0 +1 @@
|
|||
g=(new graphics).show[]
|
||||
1
Task/Window-creation/FutureBasic/window-creation.basic
Normal file
1
Task/Window-creation/FutureBasic/window-creation.basic
Normal file
|
|
@ -0,0 +1 @@
|
|||
window 1
|
||||
1
Task/Window-creation/GUISS/window-creation-1.guiss
Normal file
1
Task/Window-creation/GUISS/window-creation-1.guiss
Normal file
|
|
@ -0,0 +1 @@
|
|||
Start,Programs,Accessories,Notepad
|
||||
1
Task/Window-creation/GUISS/window-creation-2.guiss
Normal file
1
Task/Window-creation/GUISS/window-creation-2.guiss
Normal file
|
|
@ -0,0 +1 @@
|
|||
Window:Notepad,Button:Close
|
||||
3
Task/Window-creation/Gambas/window-creation.gambas
Normal file
3
Task/Window-creation/Gambas/window-creation.gambas
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Public Sub Form_Open()
|
||||
|
||||
End
|
||||
15
Task/Window-creation/Go/window-creation-1.go
Normal file
15
Task/Window-creation/Go/window-creation-1.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/mattn/go-gtk/glib"
|
||||
"github.com/mattn/go-gtk/gtk"
|
||||
)
|
||||
|
||||
func main() {
|
||||
gtk.Init(nil)
|
||||
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
|
||||
window.Connect("destroy",
|
||||
func(*glib.CallbackContext) { gtk.MainQuit() }, "")
|
||||
window.Show()
|
||||
gtk.Main()
|
||||
}
|
||||
22
Task/Window-creation/Go/window-creation-2.go
Normal file
22
Task/Window-creation/Go/window-creation-2.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
)
|
||||
|
||||
func main() {
|
||||
window, err := sdl.CreateWindow("RC Window Creation",
|
||||
sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
|
||||
320, 200, 0)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
for {
|
||||
if _, ok := sdl.WaitEvent().(*sdl.QuitEvent); ok {
|
||||
break
|
||||
}
|
||||
}
|
||||
window.Destroy()
|
||||
}
|
||||
22
Task/Window-creation/Go/window-creation-3.go
Normal file
22
Task/Window-creation/Go/window-creation-3.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"code.google.com/p/x-go-binding/ui"
|
||||
"code.google.com/p/x-go-binding/ui/x11"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
win, err := x11.NewWindow()
|
||||
if err != nil {
|
||||
log.Fatalf("Error: %v\n", err)
|
||||
}
|
||||
defer win.Close()
|
||||
|
||||
for ev := range win.EventChan() {
|
||||
switch e := ev.(type) {
|
||||
case ui.ErrEvent:
|
||||
log.Fatalf("Error: %v\n", e.Err)
|
||||
}
|
||||
}
|
||||
}
|
||||
6
Task/Window-creation/Haskell/window-creation.hs
Normal file
6
Task/Window-creation/Haskell/window-creation.hs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import Graphics.HGL
|
||||
|
||||
aWindow = runGraphics $
|
||||
withWindow_ "Rosetta Code task: Creating a window" (300, 200) $ \ w -> do
|
||||
drawInWindow w $ text (100, 100) "Hello World"
|
||||
getKey w
|
||||
4
Task/Window-creation/HicEst/window-creation.hicest
Normal file
4
Task/Window-creation/HicEst/window-creation.hicest
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
WINDOW(WINdowhandle=handle, Width=80, Height=-400, X=1, Y=1/2, TItle="Rosetta Window_creation Example")
|
||||
! window units: as pixels < 0, as relative window size 0...1, ascurrent character sizes > 1
|
||||
|
||||
WRITE(WINdowhandle=handle) '... some output ...'
|
||||
7
Task/Window-creation/Icon/window-creation.icon
Normal file
7
Task/Window-creation/Icon/window-creation.icon
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
link graphics
|
||||
|
||||
procedure main(arglist)
|
||||
|
||||
WOpen("size=300, 300", "fg=blue", "bg=light gray")
|
||||
WDone()
|
||||
end
|
||||
1
Task/Window-creation/J/window-creation-1.j
Normal file
1
Task/Window-creation/J/window-creation-1.j
Normal file
|
|
@ -0,0 +1 @@
|
|||
wdinfo 'Hamlet';'To be, or not to be: that is the question:'
|
||||
15
Task/Window-creation/J/window-creation-2.j
Normal file
15
Task/Window-creation/J/window-creation-2.j
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
MINWDW=: noun define
|
||||
pc minwdw;
|
||||
pas 162 85;pcenter;
|
||||
)
|
||||
|
||||
minwdw_run=: monad define
|
||||
wd MINWDW
|
||||
wd 'pshow;'
|
||||
)
|
||||
|
||||
minwdw_close=: monad define
|
||||
wd'pclose'
|
||||
)
|
||||
|
||||
minwdw_run ''
|
||||
10
Task/Window-creation/Java/window-creation.java
Normal file
10
Task/Window-creation/Java/window-creation.java
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import javax.swing.JFrame;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) throws Exception {
|
||||
JFrame w = new JFrame("Title");
|
||||
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
w.setSize(800,600);
|
||||
w.setVisible(true);
|
||||
}
|
||||
}
|
||||
5
Task/Window-creation/Julia/window-creation.julia
Normal file
5
Task/Window-creation/Julia/window-creation.julia
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# v0.6
|
||||
|
||||
using Tk
|
||||
|
||||
w = Toplevel("Example")
|
||||
9
Task/Window-creation/Kotlin/window-creation.kotlin
Normal file
9
Task/Window-creation/Kotlin/window-creation.kotlin
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import javax.swing.JFrame
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
JFrame("Title").apply {
|
||||
setSize(800, 600)
|
||||
defaultCloseOperation = JFrame.EXIT_ON_CLOSE
|
||||
isVisible = true
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
nomainwin
|
||||
open "GUI Window" for window as #1
|
||||
wait
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
nomainwin
|
||||
open "GUI Window" for window as #1
|
||||
#1 "trapclose Quit"
|
||||
wait
|
||||
sub Quit hndl$
|
||||
close #hndl$
|
||||
end
|
||||
end sub
|
||||
12
Task/Window-creation/Lingo/window-creation.lingo
Normal file
12
Task/Window-creation/Lingo/window-creation.lingo
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
win = window().new("New Window")
|
||||
w = 320
|
||||
h = 240
|
||||
firstScreen = _system.deskTopRectList[1]
|
||||
x = firstScreen.width/2 - w/2
|
||||
y = firstScreen.height/2- h/2
|
||||
win.rect = rect(x,y,x+w,y+h)
|
||||
-- Director needs a binary movie file (*.dir) for opening new windows. But this
|
||||
-- movie file can be totally empty, and if it's write protected in the filesystem,
|
||||
-- it can be re-used for multiple windows.
|
||||
win.filename = _movie.path & "empty.dir"
|
||||
win.open()
|
||||
11
Task/Window-creation/Lua/window-creation.lua
Normal file
11
Task/Window-creation/Lua/window-creation.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
local iup = require "iuplua"
|
||||
|
||||
iup.dialog{
|
||||
title = "Window";
|
||||
iup.vbox{
|
||||
margin = "10x10";
|
||||
iup.label{title = "A window"}
|
||||
}
|
||||
}:show()
|
||||
|
||||
iup.MainLoop()
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
Module DisplayWindow {
|
||||
Declare MyForm Form
|
||||
Method MyForm,"Show",1
|
||||
}
|
||||
DisplayWindow
|
||||
1
Task/Window-creation/Mathematica/window-creation.math
Normal file
1
Task/Window-creation/Mathematica/window-creation.math
Normal file
|
|
@ -0,0 +1 @@
|
|||
CreateDocument[]
|
||||
1
Task/Window-creation/Nanoquery/window-creation.nanoquery
Normal file
1
Task/Window-creation/Nanoquery/window-creation.nanoquery
Normal file
|
|
@ -0,0 +1 @@
|
|||
w = new(Nanoquery.Util.Windows.Window).setSize(300,300).setTitle("Nanoquery").show()
|
||||
54
Task/Window-creation/NetRexx/window-creation.netrexx
Normal file
54
Task/Window-creation/NetRexx/window-creation.netrexx
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols binary
|
||||
|
||||
import javax.swing.JFrame
|
||||
import javax.swing.JLabel
|
||||
import java.awt.BorderLayout
|
||||
import java.awt.Font
|
||||
import java.awt.Color
|
||||
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
parse arg showText .
|
||||
select
|
||||
when showText.length = 0 then addText = isTrue
|
||||
when 'YES'.abbrev(showText.upper) then addText = isTrue
|
||||
when showText = '.' then addText = isTrue
|
||||
otherwise addText = isFalse
|
||||
end
|
||||
title = 'Rosetta Code - Window Creation'
|
||||
createFrame(title, addText)
|
||||
|
||||
return
|
||||
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
method createFrame(title, addText = boolean 0) public static
|
||||
do
|
||||
fenester = JFrame(title)
|
||||
fenester.setSize(600, 200)
|
||||
fenester.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
|
||||
if addText then decorate(fenester)
|
||||
fenester.setVisible(isTrue)
|
||||
|
||||
catch ex = Exception
|
||||
ex.printStackTrace()
|
||||
end
|
||||
|
||||
return
|
||||
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
method decorate(fenester = JFrame, textStr = 'This page intentionally left blank.') private static returns JFrame
|
||||
textlbl = JLabel(textStr)
|
||||
textfont = Font(Font.SERIF, Font.BOLD, 20)
|
||||
textlbl.setHorizontalAlignment(JLabel.CENTER)
|
||||
textlbl.setFont(textfont)
|
||||
textlbl.setForeground(Color.ORANGE)
|
||||
fenester.add(textlbl, BorderLayout.CENTER)
|
||||
|
||||
return fenester
|
||||
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
method isTrue() public static returns boolean
|
||||
return (1 == 1)
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
method isFalse() public static returns boolean
|
||||
return \(1 == 1)
|
||||
12
Task/Window-creation/Nim/window-creation-1.nim
Normal file
12
Task/Window-creation/Nim/window-creation-1.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import gintro/[glib, gobject, gtk, gio]
|
||||
|
||||
proc activate(app: Application) =
|
||||
## Activate the application.
|
||||
let window = newApplicationWindow(app)
|
||||
window.setTitle("Window for Rosetta")
|
||||
window.setSizeRequest(640, 480)
|
||||
window.showAll()
|
||||
|
||||
let app = newApplication(Application, "Rosetta.Window")
|
||||
discard app.connect("activate", activate)
|
||||
discard app.run()
|
||||
47
Task/Window-creation/Nim/window-creation-2.nim
Normal file
47
Task/Window-creation/Nim/window-creation-2.nim
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import gdk2, glib2, gtk2
|
||||
|
||||
const
|
||||
Inside = "Mouse is over label"
|
||||
OutSide = "Mouse is not over label"
|
||||
|
||||
# Context transmitted to callback.
|
||||
type Context = object
|
||||
label: PLabel
|
||||
overButton: bool
|
||||
|
||||
|
||||
proc changeLabel(p: PWidget; event: gdk2.PEventCrossing; context: var Context) {.cdecl.} =
|
||||
context.label.set_text(if context.overButton: OutSide else: Inside)
|
||||
context.overButton = not context.overButton
|
||||
|
||||
proc thisDestroy(widget: PWidget, data: Pgpointer) {.cdecl.} =
|
||||
main_quit()
|
||||
|
||||
|
||||
var context: Context
|
||||
nim_init()
|
||||
|
||||
let window = window_new(gtk2.WINDOW_TOPLEVEL)
|
||||
let stackbox = vbox_new(true, 10)
|
||||
let button1 = button_new("Move mouse over button")
|
||||
let buttonstyle = copy(button1.get_style())
|
||||
buttonstyle.bg[STATE_PRELIGHT] = TColor(pixel: 0, red: 255, green: 0, blue: 0)
|
||||
button1.set_style(buttonstyle)
|
||||
let button2 = button_new()
|
||||
context = Context(label: label_new(Outside), overButton: false)
|
||||
let button3 = button_new("Quit")
|
||||
|
||||
button2.add(context.label)
|
||||
stackbox.pack_start(button1, true, true, 0)
|
||||
stackbox.pack_start(button2, true, true, 0)
|
||||
stackbox.pack_start(button3, true, true, 0)
|
||||
window.set_border_width(5)
|
||||
window.add(stackbox)
|
||||
|
||||
discard window.signal_connect("destroy", SIGNAL_FUNC(thisDestroy), nil)
|
||||
discard button1.signal_connect("enter_notify_event", SIGNAL_FUNC(changeLabel), addr(context))
|
||||
discard button1.signal_connect("leave_notify_event", SIGNAL_FUNC(changeLabel), addr(context))
|
||||
discard button3.signal_connect("clicked", SIGNAL_FUNC(thisDestroy), nil)
|
||||
|
||||
window.show_all()
|
||||
main()
|
||||
48
Task/Window-creation/Nim/window-creation-3.nim
Normal file
48
Task/Window-creation/Nim/window-creation-3.nim
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import
|
||||
sdl, sdl_image, colors
|
||||
|
||||
var
|
||||
screen, greeting: PSurface
|
||||
r: TRect
|
||||
event: TEvent
|
||||
bgColor = colChocolate.int32
|
||||
|
||||
if init(INIT_VIDEO) != 0:
|
||||
quit "SDL failed to initialize!"
|
||||
|
||||
screen = SetVideoMode(640, 480, 16, SWSURFACE or ANYFORMAT)
|
||||
if screen.isNil:
|
||||
quit($sdl.getError())
|
||||
|
||||
greeting = IMG_load("tux.png")
|
||||
if greeting.isNil:
|
||||
echo "Failed to load tux.png"
|
||||
else:
|
||||
## convert the image to alpha and free the old one
|
||||
var s = greeting.displayFormatAlpha()
|
||||
swap(greeting, s)
|
||||
s.freeSurface()
|
||||
|
||||
r.x = 0
|
||||
r.y = 0
|
||||
|
||||
block game_loop:
|
||||
while true:
|
||||
|
||||
while pollEvent(addr event) > 0:
|
||||
case event.kind
|
||||
of QUITEV:
|
||||
break game_loop
|
||||
of KEYDOWN:
|
||||
if EvKeyboard(addr event).keysym.sym == K_ESCAPE:
|
||||
break game_loop
|
||||
else:
|
||||
discard
|
||||
|
||||
discard fillRect(screen, nil, bgColor)
|
||||
discard blitSurface(greeting, nil, screen, addr r)
|
||||
discard flip(screen)
|
||||
|
||||
greeting.freeSurface()
|
||||
screen.freeSurface()
|
||||
sdl.Quit()
|
||||
64
Task/Window-creation/Nim/window-creation-4.nim
Normal file
64
Task/Window-creation/Nim/window-creation-4.nim
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import x11/[xlib, xutil, x]
|
||||
|
||||
const
|
||||
WINDOW_WIDTH = 400
|
||||
WINDOW_HEIGHT = 300
|
||||
|
||||
type WindowData = tuple[display: PDisplay; window: Window]
|
||||
|
||||
proc createWindow: WindowData =
|
||||
let width: cuint = WINDOW_WIDTH
|
||||
let height: cuint = WINDOW_HEIGHT
|
||||
var sizeHints: XSizeHints
|
||||
|
||||
let display = XOpenDisplay(nil)
|
||||
if display == nil:
|
||||
echo "Connection to X server failed."
|
||||
quit QuitFailure
|
||||
|
||||
let screen = XDefaultScreen(display)
|
||||
var rootwin = XRootWindow(display, screen)
|
||||
let win = XCreateSimpleWindow(display, rootwin, 100, 10, width, height, 5,
|
||||
XBlackPixel(display, screen), XWhitePixel(display, screen))
|
||||
sizeHints.flags = PSize or PMinSize or PMaxSize
|
||||
sizeHints.min_width = width.cint
|
||||
sizeHints.max_width = width.cint
|
||||
sizeHints.min_height = height.cint
|
||||
sizeHints.max_height = height.cint
|
||||
discard XSetStandardProperties(
|
||||
display, win, "Simple Window", "window", 0, nil, 0, addr(sizeHints))
|
||||
discard XSelectInput(display, win, ButtonPressMask or KeyPressMask or PointerMotionMask)
|
||||
discard XMapWindow(display, win)
|
||||
result = (display, win)
|
||||
|
||||
proc closeWindow(data: WindowData) =
|
||||
discard XDestroyWindow(data.display, data.window)
|
||||
discard XCloseDisplay(data.display)
|
||||
|
||||
proc processEvent(xev: var XEvent) =
|
||||
var key: KeySym
|
||||
case xev.theType.int
|
||||
of KeyPress:
|
||||
key = XLookupKeysym(cast[ptr XKeyEvent](addr(xev)), 0)
|
||||
if key.int != 0:
|
||||
echo "keyboard event ", key.int
|
||||
if key.int == 65307: # <Esc>
|
||||
quit QuitSuccess
|
||||
of ButtonPressMask, PointerMotionMask:
|
||||
echo "Mouse event"
|
||||
else:
|
||||
discard
|
||||
|
||||
proc eventloop(data: WindowData) =
|
||||
var xev: XEvent
|
||||
discard XFlush(data.display)
|
||||
var numEvents = XPending(data.display).int
|
||||
while numEvents != 0:
|
||||
dec numEvents
|
||||
discard XNextEvent(data.display, addr(xev))
|
||||
processEvent(xev)
|
||||
|
||||
let windata = createWindow()
|
||||
while true:
|
||||
eventloop(windata)
|
||||
windata.closeWindow()
|
||||
13
Task/Window-creation/Nim/window-creation-5.nim
Normal file
13
Task/Window-creation/Nim/window-creation-5.nim
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import glut
|
||||
|
||||
var win: int = 0
|
||||
|
||||
proc myOnKeyPress(c: int8, v1, v2: cint) {.cdecl.} =
|
||||
echo(c)
|
||||
if c == 27:
|
||||
glutDestroyWindow(win)
|
||||
|
||||
glutInit()
|
||||
win = glutCreateWindow("Goodbye, World!")
|
||||
glutKeyboardFunc(TGlut1Char2IntCallback(myOnKeyPress))
|
||||
glutMainLoop()
|
||||
9
Task/Window-creation/Nim/window-creation-6.nim
Normal file
9
Task/Window-creation/Nim/window-creation-6.nim
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# test a Windows GUI application
|
||||
|
||||
import
|
||||
windows, shellapi, nb30, mmsystem, shfolder
|
||||
|
||||
#proc MessageBox(hWnd: int, lpText, lpCaption: CString, uType: uint): int
|
||||
# {stdcall, import: "MessageBox", header: "<windows.h>"}
|
||||
|
||||
discard MessageBox(0, "Hello World!", "Nim GUI Application", 0)
|
||||
24
Task/Window-creation/Nim/window-creation-7.nim
Normal file
24
Task/Window-creation/Nim/window-creation-7.nim
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import iup
|
||||
|
||||
# assumes you have the iup .dll or .so installed
|
||||
|
||||
discard iup.open(nil,nil)
|
||||
|
||||
|
||||
# now use a Dialog box to show a message
|
||||
var lbl = label("Hello World")
|
||||
setAttribute(lbl,"PADDING","10x10")
|
||||
|
||||
var contents = hbox(lbl, nil)
|
||||
#SetAttribute(contents, "MARGIN", "5x5")
|
||||
|
||||
var dlg = dialog(contents)
|
||||
#SetAttribute(dlg, "SIZE", "100x50")
|
||||
|
||||
discard dlg.show()
|
||||
|
||||
# a window via a quick message box, sitting on top of the main dialog window
|
||||
discard Alarm("MyTitle","Hello World","Ok", "Not Ok", nil)
|
||||
|
||||
discard mainloop()
|
||||
iup.close()
|
||||
18
Task/Window-creation/Nim/window-creation-8.nim
Normal file
18
Task/Window-creation/Nim/window-creation-8.nim
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import wx
|
||||
|
||||
{.experimental.}
|
||||
|
||||
const
|
||||
TITLE = "Rosetta Code - Window Creation Nim"
|
||||
WIDTH = 300
|
||||
HEIGHT = 300
|
||||
|
||||
let
|
||||
POSITION = construct_wxPoint(100,100)
|
||||
SIZE = construct_wxSize(WIDTH,HEIGHT)
|
||||
|
||||
let window = cnew construct_wxFrame(nil, wxID_ANY, TITLE, POSITION, SIZE)
|
||||
|
||||
window.show(true)
|
||||
|
||||
run_main_loop()
|
||||
6
Task/Window-creation/OCaml/window-creation-1.ocaml
Normal file
6
Task/Window-creation/OCaml/window-creation-1.ocaml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
let () =
|
||||
let top = Tk.openTk() in
|
||||
Wm.title_set top "An Empty Window";
|
||||
Wm.geometry_set top "240x180";
|
||||
Tk.mainLoop ();
|
||||
;;
|
||||
6
Task/Window-creation/OCaml/window-creation-2.ocaml
Normal file
6
Task/Window-creation/OCaml/window-creation-2.ocaml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
open Graphics
|
||||
|
||||
let () =
|
||||
open_graph " 800x600";
|
||||
let _ = read_line() in
|
||||
close_graph ()
|
||||
11
Task/Window-creation/OCaml/window-creation-3.ocaml
Normal file
11
Task/Window-creation/OCaml/window-creation-3.ocaml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
open GMain
|
||||
|
||||
let window = GWindow.window ~border_width:2 ()
|
||||
let button = GButton.button ~label:"Hello World" ~packing:window#add ()
|
||||
|
||||
let () =
|
||||
window#event#connect#delete ~callback:(fun _ -> true);
|
||||
window#connect#destroy ~callback:Main.quit;
|
||||
button#connect#clicked ~callback:window#destroy;
|
||||
window#show ();
|
||||
Main.main ()
|
||||
5
Task/Window-creation/OCaml/window-creation-4.ocaml
Normal file
5
Task/Window-creation/OCaml/window-creation-4.ocaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
let () =
|
||||
Sdl.init [`VIDEO];
|
||||
let _ = Sdlvideo.set_video_mode 200 200 [] in
|
||||
Sdltimer.delay 2000;
|
||||
Sdl.quit ()
|
||||
16
Task/Window-creation/OCaml/window-creation-5.ocaml
Normal file
16
Task/Window-creation/OCaml/window-creation-5.ocaml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
open Sdl
|
||||
|
||||
let () =
|
||||
let width, height = (640, 480) in
|
||||
Sdl.init [`VIDEO];
|
||||
let window, renderer =
|
||||
Render.create_window_and_renderer
|
||||
~width ~height ~flags:[]
|
||||
in
|
||||
let rgb = (0, 255, 0) in
|
||||
let a = 255 in
|
||||
Render.set_draw_color renderer rgb a;
|
||||
Render.clear renderer;
|
||||
Render.render_present renderer;
|
||||
Timer.delay 3000;
|
||||
Sdl.quit ()
|
||||
14
Task/Window-creation/OCaml/window-creation-6.ocaml
Normal file
14
Task/Window-creation/OCaml/window-creation-6.ocaml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
let () =
|
||||
let app = SFRenderWindow.make (640, 480) "OCaml-SFML Windowing" in
|
||||
|
||||
let rec loop () =
|
||||
let continue =
|
||||
match SFRenderWindow.pollEvent app with
|
||||
| Some SFEvent.Closed -> false
|
||||
| _ -> true
|
||||
in
|
||||
SFRenderWindow.clear app SFColor.black;
|
||||
SFRenderWindow.display app;
|
||||
if continue then loop ()
|
||||
in
|
||||
loop ()
|
||||
12
Task/Window-creation/OCaml/window-creation-7.ocaml
Normal file
12
Task/Window-creation/OCaml/window-creation-7.ocaml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
open Xlib
|
||||
|
||||
let () =
|
||||
let d = xOpenDisplay "" in
|
||||
let s = xDefaultScreen d in
|
||||
let w = xCreateSimpleWindow d (xRootWindow d s) 10 10 100 100 1
|
||||
(xBlackPixel d s) (xWhitePixel d s) in
|
||||
xSelectInput d w [KeyPressMask];
|
||||
xMapWindow d w;
|
||||
let _ = xNextEventFun d in (* waits any key-press event *)
|
||||
xCloseDisplay d;
|
||||
;;
|
||||
14
Task/Window-creation/Objeck/window-creation.objeck
Normal file
14
Task/Window-creation/Objeck/window-creation.objeck
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
use Gtk2;
|
||||
|
||||
bundle Default {
|
||||
class GtkHello {
|
||||
function : Main(args : String[]) ~ Nil {
|
||||
window := GtkWindow->New();
|
||||
delete_callback := Events->DeleteEvent(GtkWidget) ~ Nil;
|
||||
window->SignalConnect(Signal->Destroy, window->As(GtkWidget), delete_callback);
|
||||
window->SetTitle("Title");
|
||||
window->Show();
|
||||
Appliction->Main();
|
||||
}
|
||||
}
|
||||
}
|
||||
49
Task/Window-creation/Objective-C/window-creation.m
Normal file
49
Task/Window-creation/Objective-C/window-creation.m
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#include <Foundation/Foundation.h>
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
@interface Win : NSWindow
|
||||
{
|
||||
}
|
||||
- (void)applicationDidFinishLaunching: (NSNotification *)notification;
|
||||
- (BOOL)applicationShouldTerminateAfterLastWindowClosed: (NSNotification *)notification;
|
||||
@end
|
||||
|
||||
|
||||
@implementation Win : NSWindow
|
||||
-(instancetype) init
|
||||
{
|
||||
if ((self = [super
|
||||
initWithContentRect: NSMakeRect(0, 0, 800, 600)
|
||||
styleMask: (NSTitledWindowMask | NSClosableWindowMask)
|
||||
backing: NSBackingStoreBuffered
|
||||
defer: NO])) {
|
||||
|
||||
[self setTitle: @"A Window"];
|
||||
[self center];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching: (NSNotification *)notification
|
||||
{
|
||||
[self orderFront: self];
|
||||
}
|
||||
|
||||
- (BOOL)applicationShouldTerminateAfterLastWindowClosed: (NSNotification *)notification
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
@end
|
||||
|
||||
int main()
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
[NSApplication sharedApplication];
|
||||
Win *mywin = [[Win alloc] init];
|
||||
[NSApp setDelegate: mywin];
|
||||
[NSApp runModalForWindow: mywin];
|
||||
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
30
Task/Window-creation/Odin/window-creation.odin
Normal file
30
Task/Window-creation/Odin/window-creation.odin
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package main
|
||||
|
||||
import "vendor:sdl2"
|
||||
|
||||
main :: proc() {
|
||||
using sdl2
|
||||
|
||||
window: ^Window = ---
|
||||
renderer: ^Renderer = ---
|
||||
event: Event = ---
|
||||
|
||||
Init(INIT_VIDEO)
|
||||
CreateWindowAndRenderer(
|
||||
640, 480,
|
||||
WINDOW_SHOWN,
|
||||
&window, &renderer
|
||||
)
|
||||
|
||||
SetWindowTitle(window, "Empty window")
|
||||
RenderPresent(renderer)
|
||||
|
||||
for event.type != .QUIT {
|
||||
Delay(10)
|
||||
PollEvent(&event)
|
||||
}
|
||||
|
||||
DestroyRenderer(renderer)
|
||||
DestroyWindow(window)
|
||||
Quit()
|
||||
}
|
||||
18
Task/Window-creation/Oz/window-creation.oz
Normal file
18
Task/Window-creation/Oz/window-creation.oz
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
functor
|
||||
import
|
||||
Application
|
||||
QTk at 'x-oz://system/wp/QTk.ozf'
|
||||
define
|
||||
proc {OnClose}
|
||||
{Application.exit 0}
|
||||
end
|
||||
|
||||
%% Descripe the GUI in a declarative style.
|
||||
GUIDescription = td(label(text:"Hello World!")
|
||||
action:OnClose %% Exit app when window closes.
|
||||
)
|
||||
|
||||
%% Create a window object from the description and show it.
|
||||
Window = {QTk.build GUIDescription}
|
||||
{Window show}
|
||||
end
|
||||
17
Task/Window-creation/Pascal/window-creation.pas
Normal file
17
Task/Window-creation/Pascal/window-creation.pas
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
Program WindowCreation_SDL;
|
||||
|
||||
{$linklib SDL}
|
||||
|
||||
uses
|
||||
SDL,
|
||||
SysUtils;
|
||||
|
||||
var
|
||||
screen: PSDL_Surface;
|
||||
|
||||
begin
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
screen := SDL_SetVideoMode( 800, 600, 16, (SDL_SWSURFACE or SDL_HWPALETTE) );
|
||||
sleep(2000);
|
||||
SDL_Quit;
|
||||
end.
|
||||
4
Task/Window-creation/Perl/window-creation-1.pl
Normal file
4
Task/Window-creation/Perl/window-creation-1.pl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
use Tk;
|
||||
|
||||
MainWindow->new();
|
||||
MainLoop;
|
||||
7
Task/Window-creation/Perl/window-creation-2.pl
Normal file
7
Task/Window-creation/Perl/window-creation-2.pl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
use SDL::App;
|
||||
use SDL::Event;
|
||||
|
||||
$app = SDL::App->new;
|
||||
$app->loop({
|
||||
SDL_QUIT() => sub { exit 0; },
|
||||
});
|
||||
8
Task/Window-creation/Perl/window-creation-3.pl
Normal file
8
Task/Window-creation/Perl/window-creation-3.pl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
use Gtk3 '-init';
|
||||
|
||||
$window = Gtk3::Window->new;
|
||||
$window->signal_connect(
|
||||
destroy => sub { Gtk3->main_quit; }
|
||||
);
|
||||
$window->show_all;
|
||||
Gtk3->main;
|
||||
8
Task/Window-creation/Perl/window-creation-4.pl
Normal file
8
Task/Window-creation/Perl/window-creation-4.pl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use QtGui4;
|
||||
|
||||
my $app = Qt::Application(\@ARGV);
|
||||
my $window = Qt::MainWindow;
|
||||
$window->show;
|
||||
exit $app->exec;
|
||||
5
Task/Window-creation/Perl/window-creation-5.pl
Normal file
5
Task/Window-creation/Perl/window-creation-5.pl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
use Wx;
|
||||
|
||||
$window = Wx::Frame->new(undef, -1, 'title');
|
||||
$window->Show;
|
||||
Wx::SimpleApp->new->MainLoop;
|
||||
11
Task/Window-creation/Phix/window-creation.phix
Normal file
11
Task/Window-creation/Phix/window-creation.phix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
(phixonline)-->
|
||||
<span style="color: #000080;font-style:italic;">-- demo\rosetta\Window_creation.exw</span>
|
||||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
|
||||
<span style="color: #008080;">include</span> <span style="color: #000000;">pGUI</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
|
||||
<span style="color: #7060A8;">IupOpen</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #7060A8;">IupShow</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">IupDialog</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">IupVbox</span><span style="color: #0000FF;">({</span><span style="color: #7060A8;">IupLabel</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"hello"</span><span style="color: #0000FF;">)},</span><span style="color: #008000;">"MARGIN=200x200"</span><span style="color: #0000FF;">),</span><span style="color: #008000;">"TITLE=Hello"</span><span style="color: #0000FF;">))</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #7060A8;">platform</span><span style="color: #0000FF;">()!=</span><span style="color: #004600;">JS</span> <span style="color: #008080;">then</span>
|
||||
<span style="color: #7060A8;">IupMainLoop</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<!--
|
||||
6
Task/Window-creation/PicoLisp/window-creation.l
Normal file
6
Task/Window-creation/PicoLisp/window-creation.l
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(load "@lib/openGl.l")
|
||||
|
||||
(glutInit)
|
||||
(glutCreateWindow "Goodbye, World!")
|
||||
(keyboardFunc '(() (bye)))
|
||||
(glutMainLoop)
|
||||
1
Task/Window-creation/PowerShell/window-creation-1.psh
Normal file
1
Task/Window-creation/PowerShell/window-creation-1.psh
Normal file
|
|
@ -0,0 +1 @@
|
|||
New-Window -Show
|
||||
4
Task/Window-creation/PowerShell/window-creation-2.psh
Normal file
4
Task/Window-creation/PowerShell/window-creation-2.psh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$form = New-Object Windows.Forms.Form
|
||||
$form.Text = "A Window"
|
||||
$form.Size = New-Object Drawing.Size(150,150)
|
||||
$form.ShowDialog() | Out-Null
|
||||
|
|
@ -0,0 +1 @@
|
|||
size(1000,1000);
|
||||
1
Task/Window-creation/Prolog/window-creation.pro
Normal file
1
Task/Window-creation/Prolog/window-creation.pro
Normal file
|
|
@ -0,0 +1 @@
|
|||
?- new(D, window('Prolog Window')), send(D, open).
|
||||
14
Task/Window-creation/PureBasic/window-creation.basic
Normal file
14
Task/Window-creation/PureBasic/window-creation.basic
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
Define MyWin.i, Event.i
|
||||
|
||||
MyWin = OpenWindow(#PB_Any, 412, 172, 402, 94, "PureBasic")
|
||||
|
||||
; Event loop
|
||||
Repeat
|
||||
Event = WaitWindowEvent()
|
||||
Select Event
|
||||
Case #PB_Event_Gadget
|
||||
; Handle any gadget events here
|
||||
Case #PB_Event_CloseWindow
|
||||
Break
|
||||
EndSelect
|
||||
ForEver
|
||||
4
Task/Window-creation/Python/window-creation-1.py
Normal file
4
Task/Window-creation/Python/window-creation-1.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import Tkinter
|
||||
|
||||
w = Tkinter.Tk()
|
||||
w.mainloop()
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue