mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-01-22 22:11:06 +00:00
Move samples/tutorial to monkeyguide module.
svn path=/trunk/gtk-sharp/; revision=10488
This commit is contained in:
parent
44265207bf
commit
6e12be4da1
|
@ -1,33 +0,0 @@
|
|||
|
||||
SUBDIRS = helloworld \
|
||||
helloworld2 \
|
||||
base \
|
||||
arrow \
|
||||
aspectframe \
|
||||
filesel \
|
||||
frame \
|
||||
label \
|
||||
table \
|
||||
buttons \
|
||||
radiobuttons \
|
||||
scrolledwin \
|
||||
checkbox \
|
||||
eventbox \
|
||||
packing \
|
||||
rangewidget \
|
||||
spinbutton \
|
||||
scribble \
|
||||
togglebutton \
|
||||
|
||||
all:
|
||||
list='$(SUBDIRS)'; \
|
||||
for subdir in $$list; do \
|
||||
(cd $$subdir && $(MAKE)); \
|
||||
done
|
||||
|
||||
clean:
|
||||
list='$(SUBDIRS)'; \
|
||||
for subdir in $$list; do \
|
||||
(cd $$subdir && $(MAKE) clean); \
|
||||
done
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) arrow.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,85 +0,0 @@
|
|||
// arrow.cs - Gtk# Tutorial example
|
||||
//
|
||||
// Author: Johannes Roith <johannes@jroith.de>
|
||||
//
|
||||
// (c) 2002 Johannes Roith
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
|
||||
public class arrow
|
||||
{
|
||||
|
||||
static void delete_event (object obj, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
/* Create an Arrow widget with the specified parameters
|
||||
* and pack it into a button */
|
||||
|
||||
static Widget create_arrow_button(ArrowType arrow_type, ShadowType shadow_type )
|
||||
{
|
||||
|
||||
Button button = new Button ();
|
||||
Arrow arrow = new Arrow (arrow_type, shadow_type);
|
||||
|
||||
button.Add(arrow);
|
||||
|
||||
button.Show();
|
||||
arrow.Show();
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
/* Initialize the toolkit */
|
||||
Application.Init ();
|
||||
|
||||
/* Create a new window */
|
||||
Window window = new Window ("Arrow Buttons");
|
||||
|
||||
/* It's a good idea to do this for all windows. */
|
||||
|
||||
window.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
/* Sets the border width of the window. */
|
||||
window.BorderWidth = 10;
|
||||
|
||||
/* Create a box to hold the arrows/buttons */
|
||||
HBox box = new HBox (false, 0);
|
||||
box.BorderWidth = 2;
|
||||
window.Add(box);
|
||||
|
||||
/* Pack and show all our widgets */
|
||||
box.Show();
|
||||
|
||||
Widget button1 = create_arrow_button(ArrowType.Up, ShadowType.In);
|
||||
box.PackStart (button1, false, false, 3);
|
||||
|
||||
Widget button2 = create_arrow_button(ArrowType.Down, ShadowType.Out);
|
||||
box.PackStart (button2, false, false, 3);
|
||||
|
||||
Widget button3 = create_arrow_button(ArrowType.Left, ShadowType.EtchedIn);
|
||||
box.PackStart (button3, false, false, 3);
|
||||
|
||||
Widget button4 = create_arrow_button(ArrowType.Right, ShadowType.EtchedOut);
|
||||
box.PackStart (button4, false, false, 3);
|
||||
|
||||
|
||||
window.ShowAll ();
|
||||
|
||||
/* Rest in Application.Run() and wait for the fun to begin! */
|
||||
Application.Run();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) aspectframe.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,57 +0,0 @@
|
|||
// aspectframe.cs - Gtk# Tutorial example
|
||||
//
|
||||
// Author: Johannes Roith <johannes@jroith.de>
|
||||
//
|
||||
// (c) 2002 Johannes Roith
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
|
||||
public class aspectframe
|
||||
{
|
||||
|
||||
static void delete_event (object obj, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
Application.Init ();
|
||||
|
||||
/* Create new window */
|
||||
Window window = new Window ("Aspect Frame");
|
||||
window.BorderWidth = 10;
|
||||
|
||||
window.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
/* Create an aspect_frame and add it to our toplevel window */
|
||||
|
||||
AspectFrame aspect_frame = new AspectFrame("2x1", (float)0.5,(float)0.5, 2, false);
|
||||
|
||||
window.Add(aspect_frame);
|
||||
aspect_frame.Show();
|
||||
|
||||
/* Now add a child widget to the aspect frame */
|
||||
|
||||
DrawingArea drawing_area = new DrawingArea();
|
||||
|
||||
/* Ask for a 200x200 window, but the AspectFrame will give us a 200x100
|
||||
* window since we are forcing a 2x1 aspect ratio */
|
||||
drawing_area.SetSizeRequest (200, 200);
|
||||
aspect_frame.Add(drawing_area);
|
||||
drawing_area.Show();
|
||||
|
||||
window.ShowAll();
|
||||
|
||||
Application.Run();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) base.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,31 +0,0 @@
|
|||
// base.cs - Gtk# Tutorial example
|
||||
//
|
||||
// Author: Johannes Roith <johannes@jroith.de>
|
||||
//
|
||||
// (c) 2002 Johannes Roith
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
|
||||
|
||||
public class baseclass {
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
Application.Init ();
|
||||
|
||||
Window window = new Window ("base");
|
||||
window.Show();
|
||||
|
||||
Application.Run ();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) buttons.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,96 +0,0 @@
|
|||
// buttons.cs - Gtk# Tutorial example
|
||||
//
|
||||
// Author: Johannes Roith <johannes@jroith.de>
|
||||
//
|
||||
// (c) 2002 Johannes Roith
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
|
||||
public class buttons
|
||||
{
|
||||
|
||||
/* Create a new hbox with an image and a label packed into it
|
||||
* and return the box. */
|
||||
|
||||
static Widget xpm_label_box(string xpm_filename, string label_text )
|
||||
{
|
||||
|
||||
|
||||
/* Create box for image and label */
|
||||
HBox box = new HBox(false, 0);
|
||||
box.BorderWidth = 2;
|
||||
|
||||
/* Now on to the image stuff */
|
||||
Gtk.Image image = new Gtk.Image(xpm_filename);
|
||||
|
||||
/* Create a label for the button */
|
||||
Label label = new Label (label_text);
|
||||
|
||||
/* Pack the image and label into the box */
|
||||
box.PackStart (image, false, false, 3);
|
||||
box.PackStart(label, false, false, 3);
|
||||
|
||||
image.Show();
|
||||
label.Show();
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
|
||||
/* Our usual callback function */
|
||||
static void callback( object obj, EventArgs args)
|
||||
{
|
||||
Console.WriteLine("Hello again - cool button was pressed");
|
||||
}
|
||||
|
||||
/* another callback */
|
||||
static void delete_event (object obj, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
Application.Init();
|
||||
|
||||
/* Create a new window */
|
||||
Window window = new Window ("Pixmap'd Buttons!");
|
||||
|
||||
/* It's a good idea to do this for all windows. */
|
||||
window.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
/* Sets the border width of the window. */
|
||||
window.BorderWidth = 10;
|
||||
|
||||
/* Create a new button */
|
||||
Button button = new Button();
|
||||
|
||||
/* Connect the "clicked" signal of the button to our callback */
|
||||
button.Clicked += new EventHandler (callback);
|
||||
|
||||
/* This calls our box creating function */
|
||||
Widget box = xpm_label_box ("info.xpm", "cool button");
|
||||
|
||||
/* Pack and show all our widgets */
|
||||
box.Show();
|
||||
|
||||
button.Add(box);
|
||||
|
||||
button.Show();
|
||||
|
||||
window.Add(button);
|
||||
|
||||
window.ShowAll();
|
||||
|
||||
/* Rest in gtk_main and wait for the fun to begin! */
|
||||
Application.Run();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
/* XPM */
|
||||
static char *openfile[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 20 19 66 2",
|
||||
/* colors */
|
||||
".. c None",
|
||||
".# c #000000",
|
||||
".a c #dfdfdf",
|
||||
".b c #7f7f7f",
|
||||
".c c #006f6f",
|
||||
".d c #00efef",
|
||||
".e c #009f9f",
|
||||
".f c #004040",
|
||||
".g c #00bfbf",
|
||||
".h c #ff0000",
|
||||
".i c #ffffff",
|
||||
".j c #7f0000",
|
||||
".k c #007070",
|
||||
".l c #00ffff",
|
||||
".m c #00a0a0",
|
||||
".n c #004f4f",
|
||||
".o c #00cfcf",
|
||||
".p c #8f8f8f",
|
||||
".q c #6f6f6f",
|
||||
".r c #a0a0a0",
|
||||
".s c #7f7f00",
|
||||
".t c #007f7f",
|
||||
".u c #5f5f5f",
|
||||
".v c #707070",
|
||||
".w c #00f0f0",
|
||||
".x c #009090",
|
||||
".y c #ffff00",
|
||||
".z c #0000ff",
|
||||
".A c #00afaf",
|
||||
".B c #00d0d0",
|
||||
".C c #00dfdf",
|
||||
".D c #005f5f",
|
||||
".E c #00b0b0",
|
||||
".F c #001010",
|
||||
".G c #00c0c0",
|
||||
".H c #000f0f",
|
||||
".I c #00007f",
|
||||
".J c #005050",
|
||||
".K c #002f2f",
|
||||
".L c #dfcfcf",
|
||||
".M c #dfd0d0",
|
||||
".N c #006060",
|
||||
".O c #00e0e0",
|
||||
".P c #00ff00",
|
||||
".Q c #002020",
|
||||
".R c #dfc0c0",
|
||||
".S c #008080",
|
||||
".T c #001f1f",
|
||||
".U c #003f3f",
|
||||
".V c #007f00",
|
||||
".W c #00000f",
|
||||
".X c #000010",
|
||||
".Y c #00001f",
|
||||
".Z c #000020",
|
||||
".0 c #00002f",
|
||||
".1 c #000030",
|
||||
".2 c #00003f",
|
||||
".3 c #000040",
|
||||
".4 c #00004f",
|
||||
".5 c #000050",
|
||||
".6 c #00005f",
|
||||
".7 c #000060",
|
||||
".8 c #00006f",
|
||||
".9 c #000070",
|
||||
"#. c #7f7f80",
|
||||
"## c #9f9f9f",
|
||||
/* pixels */
|
||||
"........................................",
|
||||
"........................................",
|
||||
"........................................",
|
||||
".......................#.#.#............",
|
||||
".....................#.......#...#......",
|
||||
"...............................#.#......",
|
||||
".......#.#.#.................#.#.#......",
|
||||
".....#.y.i.y.#.#.#.#.#.#.#..............",
|
||||
".....#.i.y.i.y.i.y.i.y.i.#..............",
|
||||
".....#.y.i.y.i.y.i.y.i.y.#..............",
|
||||
".....#.i.y.i.y.#.#.#.#.#.#.#.#.#.#.#....",
|
||||
".....#.y.i.y.#.s.s.s.s.s.s.s.s.s.#......",
|
||||
".....#.i.y.#.s.s.s.s.s.s.s.s.s.#........",
|
||||
".....#.y.#.s.s.s.s.s.s.s.s.s.#..........",
|
||||
".....#.#.s.s.s.s.s.s.s.s.s.#............",
|
||||
".....#.#.#.#.#.#.#.#.#.#.#..............",
|
||||
"........................................",
|
||||
"........................................",
|
||||
"........................................"
|
||||
};
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) checkbuttons.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,59 +0,0 @@
|
|||
// checkbuttons.cs - GTK# Tutorial example
|
||||
//
|
||||
// Authors: Alejandro Sanchez Acosta <raciel@es.gnu.org>
|
||||
// Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
|
||||
//
|
||||
// (C) 2002 Alejandro Sanchez Acosta <raciel@es.gnu.org>
|
||||
// Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
|
||||
public class checkbuttons
|
||||
{
|
||||
static void delete_event(object obj, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
static void clickedCallback(object obj, EventArgs args)
|
||||
{
|
||||
if (((CheckButton) obj).Active)
|
||||
Console.WriteLine ("CheckButton clicked, I'm activating");
|
||||
else
|
||||
Console.WriteLine ("CheckButton clicked, I'm desactivating");
|
||||
}
|
||||
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Application.Init();
|
||||
|
||||
HBox hbox = new HBox(false, 0);
|
||||
hbox.BorderWidth = 2;
|
||||
|
||||
CheckButton cb1 = new CheckButton ("CheckButton 1");
|
||||
cb1.Clicked += new EventHandler (clickedCallback);
|
||||
|
||||
CheckButton cb2 = new CheckButton ("CheckButton 2");
|
||||
cb2.Clicked += new EventHandler (clickedCallback);
|
||||
|
||||
hbox.PackStart(cb1, false, false, 3);
|
||||
hbox.PackStart(cb2, false, false, 3);
|
||||
|
||||
Window window = new Window ("Check buttons");
|
||||
window.BorderWidth = 10;
|
||||
window.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
window.Add(hbox);
|
||||
window.ShowAll();
|
||||
Application.Run();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r gdk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) eventbox.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,68 +0,0 @@
|
|||
// eventbox.cs - Gtk# Tutorial example
|
||||
//
|
||||
// Author: Alejandro Sánchez Acosta <raciel@es.gnu.org>
|
||||
// Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
|
||||
//
|
||||
// (c) 2002 Alejandro Sánchez Acosta
|
||||
// Cesar Octavio Lopez Nataren
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using Gdk;
|
||||
using GdkSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
public class eventbox
|
||||
{
|
||||
|
||||
static void delete_event (object obj, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
static void exitbutton_event (object obj, ButtonPressEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
Gtk.Window window;
|
||||
Gdk.CursorType cursortype;
|
||||
EventBox eventbox;
|
||||
Label label;
|
||||
|
||||
Application.Init();
|
||||
|
||||
window = new Gtk.Window ("Eventbox");
|
||||
window.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
window.BorderWidth = 10;
|
||||
|
||||
eventbox = new EventBox ();
|
||||
window.Add (eventbox);
|
||||
eventbox.Show();
|
||||
|
||||
label = new Label ("Click here to quit, quit, quit, quit");
|
||||
eventbox.Add(label);
|
||||
label.Show();
|
||||
|
||||
label.SetSizeRequest(110, 20);
|
||||
|
||||
/* eventbox.Events = GDK_BUTTON_PRESS_MASK; */ //Add this feature
|
||||
|
||||
eventbox.ButtonPressEvent += new ButtonPressEventHandler (exitbutton_event);
|
||||
|
||||
eventbox.Realize();
|
||||
|
||||
eventbox.GdkWindow.Cursor = Cursor.New(CursorType.Hand1);
|
||||
|
||||
window.Show();
|
||||
|
||||
Application.Run();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) filesel.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,69 +0,0 @@
|
|||
// filesel.cs - Gtk# Tutorial example
|
||||
//
|
||||
// Author: Johannes Roith <johannes@jroith.de>
|
||||
//
|
||||
// (c) 2002 Johannes Roith
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
|
||||
public class filesel
|
||||
{
|
||||
|
||||
static FileSelection filew;
|
||||
|
||||
/* Get the selected filename and print it to the console */
|
||||
|
||||
static void file_ok_sel_event( object obj, EventArgs args )
|
||||
{
|
||||
Console.WriteLine("{0}\n",filew.Filename);
|
||||
}
|
||||
|
||||
static void delete_event (object obj, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
static void cancel_event (object obj, EventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
Application.Init ();
|
||||
|
||||
|
||||
/* Create a new file selection widget */
|
||||
filew = new FileSelection("File selection");
|
||||
|
||||
filew.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
/* Connect the ok_button to file_ok_sel function */
|
||||
filew.OkButton.Clicked +=new EventHandler (file_ok_sel_event);
|
||||
|
||||
/* Connect the cancel_button to destroy the widget */
|
||||
|
||||
filew.CancelButton.Clicked +=new EventHandler (cancel_event);
|
||||
|
||||
|
||||
/* Lets set the filename, as if this were a save dialog, and we are giving
|
||||
a default filename */
|
||||
|
||||
filew.Filename = "penguin.png";
|
||||
|
||||
filew.Show();
|
||||
|
||||
Application.Run();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) frame.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,66 +0,0 @@
|
|||
// frame.cs - Gtk# Tutorial example
|
||||
//
|
||||
// Author: Johannes Roith <johannes@jroith.de>
|
||||
//
|
||||
// (c) 2002 Johannes Roith
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
|
||||
public class frame
|
||||
{
|
||||
|
||||
static void delete_event (object obj, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public static void Main( string[] args)
|
||||
{
|
||||
|
||||
/* Initialise GTK */
|
||||
Application.Init();
|
||||
|
||||
/* Create a new window */
|
||||
Window window = new Window ("Frame Example");
|
||||
|
||||
/* Here we connect the "destroy" event to a signal handler */
|
||||
window.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
window.SetSizeRequest(300, 300);
|
||||
/* Sets the border width of the window. */
|
||||
window.BorderWidth= 10;
|
||||
|
||||
/* Create a Frame */
|
||||
Frame frame = new Frame("MyFrame");
|
||||
window.Add(frame);
|
||||
|
||||
/* Set the frame's label */
|
||||
frame.Label = "GTK Frame Widget";
|
||||
|
||||
/* Align the label at the right of the frame */
|
||||
|
||||
frame.SetLabelAlign((float)1.0,(float)0.0);
|
||||
|
||||
/* Set the style of the frame */
|
||||
frame.ShadowType = (ShadowType) 4;
|
||||
|
||||
frame.Show();
|
||||
|
||||
/* Display the window & all widgets*/
|
||||
window.ShowAll();
|
||||
|
||||
/* Enter the event loop */
|
||||
Application.Run();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) helloworld.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,83 +0,0 @@
|
|||
// helloworld.cs - Gtk# Tutorial example
|
||||
//
|
||||
// Author: Johannes Roith <johannes@jroith.de>
|
||||
//
|
||||
// (c) 2002 Johannes Roith
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
|
||||
public class helloworld {
|
||||
|
||||
/* This is a callback function. The data arguments are ignored
|
||||
* in this example. More on callbacks below. */
|
||||
static void hello (object obj, EventArgs args)
|
||||
{
|
||||
Console.WriteLine("Hello World");
|
||||
Application.Quit ();
|
||||
}
|
||||
|
||||
static void delete_event (object obj, DeleteEventArgs args)
|
||||
{
|
||||
/* If you return FALSE in the "delete_event" signal handler,
|
||||
* GTK will emit the "destroy" signal. Returning TRUE means
|
||||
* you don't want the window to be destroyed.
|
||||
* This is useful for popping up 'are you sure you want to quit?'
|
||||
* type dialogs. */
|
||||
|
||||
Console.WriteLine ("delete event occurred\n");
|
||||
Application.Quit ();
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
/* This is called in all GTK applications. Arguments are parsed
|
||||
* from the command line and are returned to the application. */
|
||||
Application.Init ();
|
||||
|
||||
/* create a new window */
|
||||
Window window = new Window ("helloworld");
|
||||
/* When the window is given the "delete_event" signal (this is given
|
||||
* by the window manager, usually by the "close" option, or on the
|
||||
* titlebar), we ask it to call the delete_event () function
|
||||
* as defined above. The data passed to the callback
|
||||
* function is NULL and is ignored in the callback function. */
|
||||
|
||||
window.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
/* Sets the border width of the window. */
|
||||
window.BorderWidth = 10;
|
||||
/* gtk_container_set_border_width (GTK_CONTAINER (window), 10);*/
|
||||
|
||||
/* Creates a new button with the label "Hello World". */
|
||||
Button btn = new Button ("Hello World");
|
||||
|
||||
/* When the button receives the "clicked" signal, it will call the
|
||||
* function hello() passing it NULL as its argument. The hello()
|
||||
* function is defined above. */
|
||||
btn.Clicked += new EventHandler (hello);
|
||||
|
||||
|
||||
/* This packs the button into the window (a gtk container). */
|
||||
window.Add (btn);
|
||||
|
||||
/* The final step is to display this newly created widget. */
|
||||
window.ShowAll ();
|
||||
|
||||
|
||||
/* All GTK applications must have a gtk_main(). Control ends here
|
||||
* and waits for an event to occur (like a key press or
|
||||
* mouse event).
|
||||
* In C#, we use Application.Run(), as used in Windows.Forms*/
|
||||
|
||||
Application.Run ();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) helloworld2.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,100 +0,0 @@
|
|||
// helloworld2.cs - Gtk# Tutorial example
|
||||
//
|
||||
// Author: Johannes Roith <johannes@jroith.de>
|
||||
//
|
||||
// (c) 2002 Johannes Roith
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
|
||||
public class helloworld2
|
||||
{
|
||||
|
||||
/* Our new improved callback. The data is extracted from obj and
|
||||
* is printed to stdout. */
|
||||
|
||||
static void callback( object obj, EventArgs args)
|
||||
{
|
||||
Button mybutton = (Button) obj;
|
||||
Console.WriteLine("Hello again - {0} was pressed", (string) mybutton.Label);
|
||||
// Have to figure out, how to recieve button name
|
||||
}
|
||||
|
||||
/* Exit event */
|
||||
static void delete_event (object obj, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
|
||||
/* This is called in all GTK applications. Arguments are parsed
|
||||
* from the command line and are returned to the application. */
|
||||
Application.Init ();
|
||||
|
||||
/* Create a new window */
|
||||
Window window = new Window ("helloworld");
|
||||
|
||||
/* This is a new call, which just resets the title of our
|
||||
* new window to "Hello Buttons!" */
|
||||
window.Title ="Hello Buttons!";
|
||||
|
||||
/* Here we just set a handler for delete_event that immediately
|
||||
* exits GTK. */
|
||||
window.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
/* Sets the border width of the window. */
|
||||
window.BorderWidth = 10;
|
||||
|
||||
/* We create a box to pack widgets into. This is described in detail
|
||||
* in the "packing" section. The box is not really visible, it
|
||||
* is just used as a tool to arrange widgets. */
|
||||
HBox box1 = new HBox (false, 0);
|
||||
|
||||
/* Put the box into the main window. */
|
||||
window.Add (box1);
|
||||
|
||||
/* Creates a new button with the label "Button 1". */
|
||||
ToggleButton button1 = new ToggleButton ("Button 1");
|
||||
|
||||
/* Now when the button is clicked, we call the "callback" event
|
||||
* with a pointer to "button 1" as its argument */
|
||||
button1.Clicked += new EventHandler (callback);
|
||||
|
||||
/* Instead of gtk_container_add, we pack this button into the invisible
|
||||
* box, which has been packed into the window. */
|
||||
box1.PackStart (button1, true, true, 0);
|
||||
|
||||
/* Always remember this step, this tells GTK that our preparation for
|
||||
* this button is complete, and it can now be displayed. */
|
||||
button1.Show();
|
||||
|
||||
/* Do these same steps again to create a second button */
|
||||
Button button2 = new Button ("Button 2");
|
||||
|
||||
/* Call the same callback function with a different argument,
|
||||
* passing a pointer to "button 2" instead. */
|
||||
button2.Clicked += new EventHandler (callback);
|
||||
|
||||
box1.PackStart (button2, true, true, 0);
|
||||
|
||||
/* The order in which we show the buttons is not really important, but I
|
||||
* recommend showing the window last, so it all pops up at once. */
|
||||
|
||||
window.ShowAll ();
|
||||
|
||||
/* Rest in Application.Run and wait for the fun to begin! */
|
||||
Application.Run();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) label.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,133 +0,0 @@
|
|||
// label.cs - Gtk# Tutorial example
|
||||
//
|
||||
// Author: Alejandro Sánchez Acosta <raciel@es.gnu.org>
|
||||
// Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
|
||||
//
|
||||
// (c) 2002 Alejandro Sánchez Acosta
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
public class label
|
||||
{
|
||||
|
||||
static void delete_event (object obj, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
static void exitbutton_event (object obj, EventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
|
||||
Widget widget;
|
||||
Window window;
|
||||
HBox hbox;
|
||||
VBox vbox;
|
||||
Frame frame;
|
||||
Label label;
|
||||
|
||||
Application.Init ();
|
||||
|
||||
|
||||
window = new Window ("Label sample");
|
||||
|
||||
window.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
window.Title = "Label";
|
||||
|
||||
hbox = new HBox (false, 5);
|
||||
vbox = new VBox (false, 5);
|
||||
|
||||
window.Add (hbox);
|
||||
hbox.PackStart (vbox, false, false, 0);
|
||||
|
||||
window.BorderWidth = 5;
|
||||
|
||||
frame = new Frame ("Normal Label");
|
||||
label = new Label ("This is a normal label");
|
||||
|
||||
frame.Add (label);
|
||||
vbox.PackStart (frame, false, false, 0);
|
||||
|
||||
frame = new Frame ("Multiline Label");
|
||||
label = new Label ("This is a Multi-line label\nSecond Line\nThird Line");
|
||||
|
||||
frame.Add (label);
|
||||
vbox.PackStart (frame, false, false, 0);
|
||||
|
||||
frame = new Frame ("Left Justified Label");
|
||||
label = new Label ("This is a Left-Justified\n" + "Multi-line label.\n" + "Third line");
|
||||
label.Justify = Justification.Left;
|
||||
|
||||
frame.Add (label);
|
||||
vbox.PackStart (frame, false, false, 0);
|
||||
|
||||
frame = new Frame ("Right Justified Label");
|
||||
label = new Label ("This is a Right Justified\nMulti-line label.\n" + "Fourth Line, (j/k)");
|
||||
label.Justify = Justification.Right;
|
||||
frame.Add (label);
|
||||
vbox.PackStart (frame, false, false, 0);
|
||||
|
||||
vbox = new VBox (false, 5);
|
||||
hbox.PackStart(vbox, false, false, 0);
|
||||
|
||||
frame = new Frame ("Line wrapped Label");
|
||||
label = new Label ("This is an example of a line-wrapped label. It " +
|
||||
"should not be taking up the entire " /* big space to test spacing */ +
|
||||
"width allocated to it, but automatically " +
|
||||
"wraps the words to fit. " +
|
||||
"The time has come, for all good men, to come to " +
|
||||
"the aid of their party. " +
|
||||
"The sixth sheik's six sheep's sick.\n" +
|
||||
" It supports multiple paragraphs correctly, " +
|
||||
"and correctly adds " +
|
||||
"many extra spaces. ");
|
||||
|
||||
label.LineWrap = true;
|
||||
|
||||
frame.Add (label);
|
||||
vbox.PackStart(frame, false, false, 0);
|
||||
|
||||
frame = new Frame ("Filled wrapped label");
|
||||
label = new Label ("This is an example of a line-wrapped, filled label. " +
|
||||
"It should be taking " +
|
||||
"up the entire width allocated to it. " +
|
||||
"Here is a sentence to prove " +
|
||||
"my point. Here is another sentence. " +
|
||||
"Here comes the sun, do de do de do.\n" +
|
||||
" This is a new paragraph.\n" +
|
||||
" This is another newer, longer, better " +
|
||||
"paragraph. It is coming to an end, "+
|
||||
"unfortunately.");
|
||||
|
||||
label.Justify = Justification.Fill;
|
||||
label.Wrap = true;
|
||||
frame.Add (label);
|
||||
vbox.PackStart (frame, false, false, 0);
|
||||
|
||||
|
||||
frame = new Frame ("Underlined label");
|
||||
|
||||
label = new Label ("This label is underlined!\n" + "This one is underlined in quite a funky fastion");
|
||||
|
||||
label.Justify = Justification.Left;
|
||||
label.Pattern = "_________________________ _ _________ _ ______ __ _______ ___";
|
||||
|
||||
frame.Add (label);
|
||||
vbox.PackStart (frame, false, false, 0);
|
||||
|
||||
window.ShowAll ();
|
||||
|
||||
Application.Run ();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r gdk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) notebook.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,175 +0,0 @@
|
|||
// notebook.cs - Gtk# Tutorial example
|
||||
//
|
||||
//
|
||||
// Author: Alejandro Sánchez Acosta <raciel@es.gnu.org>
|
||||
// Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
|
||||
//
|
||||
// (c) 2002 Alejandro Sánchez Acosta
|
||||
// Cesar Octavio Lopez Nataren
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using Gdk;
|
||||
using GdkSharp;
|
||||
using Glib;
|
||||
using GlibSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
public class notebook
|
||||
{
|
||||
|
||||
static void delete_event (object obj, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
static void exitbutton_event (object obj, EventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
static void nextPage (object obj, EventArgs args)
|
||||
{
|
||||
notebook1.NextPage ();
|
||||
}
|
||||
|
||||
static void prevPage (object obj, EventArgs args)
|
||||
{
|
||||
notebook1.PrevPage ();
|
||||
}
|
||||
|
||||
// FIXME
|
||||
static void rotate_book (object obj, EventArgs args)
|
||||
{
|
||||
// notebook1.TabPos = ((notebook1.TabPos + 1)% 4);
|
||||
}
|
||||
|
||||
static void tabsborder_book (object obj, EventArgs args)
|
||||
{
|
||||
bool tval = false;
|
||||
bool bval = false;
|
||||
if (notebook1.ShowTabs == false)
|
||||
tval = true;
|
||||
if (notebook1.ShowBorder == false)
|
||||
bval = true;
|
||||
notebook1.ShowTabs = tval;
|
||||
notebook1.ShowBorder = bval;
|
||||
}
|
||||
|
||||
static void remove_book (object obj, EventArgs args)
|
||||
{
|
||||
int page;
|
||||
page = notebook1.CurrentPage;
|
||||
notebook1.RemovePage (page);
|
||||
notebook1.QueueDraw();
|
||||
}
|
||||
|
||||
static Gtk.Window window;
|
||||
static Button button;
|
||||
static Table table;
|
||||
static Notebook notebook1;
|
||||
static Frame frame;
|
||||
static Label label;
|
||||
static CheckButton checkbutton;
|
||||
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
|
||||
int i;
|
||||
string bufferf;
|
||||
string bufferl;
|
||||
|
||||
|
||||
Application.Init();
|
||||
|
||||
window = new Gtk.Window ("Notebook");
|
||||
window.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
window.BorderWidth = 10;
|
||||
|
||||
table = new Table (3, 6, false);
|
||||
window.Add (table);
|
||||
|
||||
notebook1 = new Notebook();
|
||||
notebook1.TabPos = PositionType.Top;
|
||||
table.Attach (notebook1, 0, 6, 0 ,1);
|
||||
notebook1.Show();
|
||||
|
||||
for (i=0; i<5; i++){
|
||||
bufferf = "Append Frame" + (i+1).ToString();
|
||||
bufferl = "Page " + (i+1).ToString();
|
||||
|
||||
frame = new Frame (bufferf);
|
||||
frame.BorderWidth = 10;
|
||||
frame.SetSizeRequest (100, 75);
|
||||
frame.Show();
|
||||
|
||||
label = new Label (bufferf);
|
||||
frame.Add (label); label.Show();
|
||||
|
||||
label = new Label (bufferl);
|
||||
notebook1.AppendPage (frame, label);
|
||||
}
|
||||
|
||||
checkbutton = new CheckButton ("Check me please!");
|
||||
checkbutton.SetSizeRequest (100, 75);
|
||||
checkbutton.Show();
|
||||
|
||||
label = new Label ("Add page");
|
||||
notebook1.InsertPage (checkbutton, label, 2);
|
||||
|
||||
for (i=0; i<5; i++) {
|
||||
bufferf = "Append Frame" + (i+1).ToString();
|
||||
bufferl = "Page " + (i+1).ToString();
|
||||
frame = new Frame (bufferf);
|
||||
frame.BorderWidth = 10;
|
||||
frame.SetSizeRequest (100, 75);
|
||||
frame.Show();
|
||||
|
||||
label = new Label (bufferf);
|
||||
frame.Add (label);
|
||||
label.Show();
|
||||
label = new Label (bufferl);
|
||||
notebook1.PrependPage (frame, label);
|
||||
}
|
||||
notebook1.CurrentPage = 3;
|
||||
button = new Button ("close");
|
||||
button.Clicked += new EventHandler (exitbutton_event);
|
||||
table.Attach (button, 0, 1, 1, 2);
|
||||
button.Show();
|
||||
|
||||
button = new Button ("next page");
|
||||
button.Clicked += new EventHandler (nextPage);
|
||||
table.Attach (button, 1, 2, 1, 2);
|
||||
button.Show();
|
||||
|
||||
button = new Button ("prev page");
|
||||
button.Clicked += new EventHandler (prevPage);
|
||||
|
||||
table.Attach (button, 2, 3, 1, 2);
|
||||
button.Show();
|
||||
|
||||
button = new Button ("tab position");
|
||||
button.Clicked += new EventHandler (rotate_book);
|
||||
table.Attach (button, 3, 4, 1, 2);
|
||||
button.Show();
|
||||
|
||||
button = new Button ("tables/border on/off");
|
||||
button.Clicked += new EventHandler (tabsborder_book);
|
||||
table.Attach (button, 4, 5, 1, 2);
|
||||
button.Show();
|
||||
|
||||
button = new Button ("remove page");
|
||||
button.Clicked += new EventHandler (remove_book);
|
||||
table.Attach (button, 5, 6, 1, 2);
|
||||
button.Show();
|
||||
table.Show();
|
||||
window.Show();
|
||||
|
||||
Application.Run();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r gdk-sharp.dll \
|
||||
-r glib-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) packing.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,236 +0,0 @@
|
|||
// packingdemo.cs - Gtk# Tutorial example
|
||||
//
|
||||
// Author: Alejandro Sánchez Acosta <raciel@es.gnu.org>
|
||||
// Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
|
||||
//
|
||||
// (c) 2002 Alejandro Sánchez Acosta
|
||||
// Cesar Octavio Lopez Nataren
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using Gdk;
|
||||
using GdkSharp;
|
||||
using Glib;
|
||||
using GlibSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
public class fixedcontainer
|
||||
{
|
||||
|
||||
public int x = 50;
|
||||
public int y = 50;
|
||||
|
||||
static Gtk.HBox make_box (bool homogeneous, int spacing, bool expand, bool fill, uint padding)
|
||||
{
|
||||
HBox box;
|
||||
Box box1;
|
||||
Button button;
|
||||
string padstr;
|
||||
|
||||
box = new HBox (homogeneous, spacing);
|
||||
button = new Button ("gtk_box_pack");
|
||||
box.PackStart (button, expand, fill, padding);
|
||||
|
||||
button.Show();
|
||||
|
||||
button = new Button ("(box,");
|
||||
|
||||
box.PackStart (button, expand, fill, padding);
|
||||
button.Show();
|
||||
|
||||
button = new Button ("button");
|
||||
box.PackStart (button, expand, fill, padding);
|
||||
button.Show();
|
||||
|
||||
if (expand == true)
|
||||
button = new Button ("TRUE");
|
||||
else
|
||||
button = new Button ("FALSE");
|
||||
box.PackStart (button, expand, fill, padding);
|
||||
button.Show();
|
||||
|
||||
button = new Button (fill ? "TRUE," : "FALSE,");
|
||||
|
||||
box.PackStart(button, expand, fill, padding);
|
||||
button.Show();
|
||||
|
||||
padstr=padding.ToString()+");";
|
||||
|
||||
button = new Button (padstr);
|
||||
box.PackStart (button, expand, fill, padding);
|
||||
button.Show();
|
||||
return box;
|
||||
}
|
||||
|
||||
static void delete_event (object obj, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
static void exitbutton_event (object obj, ButtonPressEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public static int Main (string[] args)
|
||||
{
|
||||
Gtk.Window window;
|
||||
Button button;
|
||||
VBox box1;
|
||||
HBox box2;
|
||||
HSeparator separator;
|
||||
Misc misc;
|
||||
Box quitbox;
|
||||
int which;
|
||||
Gtk.Label label;
|
||||
Application.Init();
|
||||
|
||||
if (args.Length !=1) {
|
||||
Console.WriteLine ("Usage: packbox num, where num is 1, 2 o 3");
|
||||
return (1);
|
||||
}
|
||||
|
||||
which = Convert.ToInt32 (args[0]);
|
||||
|
||||
window = new Gtk.Window ("packingdemo");
|
||||
|
||||
window.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
window.BorderWidth = 10;
|
||||
|
||||
box1 = new VBox (false, 0);
|
||||
|
||||
switch (which) {
|
||||
case 1:
|
||||
label=new Gtk.Label("gtk_hbox_new (FALSE, 0);");
|
||||
|
||||
box2 = new HBox (false, 0);
|
||||
|
||||
label.SetAlignment (0, 0);
|
||||
box1.PackStart (label, false, false, 0);
|
||||
|
||||
label.Show();
|
||||
|
||||
box2 = make_box (false, 0, false, false, 0);
|
||||
|
||||
box1.PackStart (box2, false, false, 0);
|
||||
box2.Show();
|
||||
|
||||
box2 = make_box (false, 0, true, false, 0);
|
||||
box1.PackStart (box2, false, false, 0);
|
||||
box2.Show();
|
||||
|
||||
box2 = make_box (false, 0, true, true, 0);
|
||||
box1.PackStart (box2, false, false, 0);
|
||||
box2.Show();
|
||||
|
||||
separator = new HSeparator ();
|
||||
|
||||
box1.PackStart (separator, false, true, 5);
|
||||
separator.Show();
|
||||
|
||||
box1 = new VBox (true, 0);
|
||||
label=new Gtk.Label("gtk_hbox_new (TRUE, 0);");
|
||||
label.SetAlignment (0, 0);
|
||||
|
||||
box1.PackStart(label, false, false, 0);
|
||||
label.Show();
|
||||
|
||||
box2 = make_box (true, 0, true, true, 0);
|
||||
|
||||
box1.PackStart (box2, false, false, 0);
|
||||
box2.Show();
|
||||
|
||||
box2 = make_box (true, 0, true, true, 0);
|
||||
box1.PackStart(box2, false, false, 0);
|
||||
box2.Show();
|
||||
|
||||
separator = new HSeparator();
|
||||
|
||||
box1.PackStart (separator, false, true, 5);
|
||||
separator.Show();
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
box2 = new HBox (false, 10);
|
||||
label = new Gtk.Label("gtk_hbox_new (FALSE, 10);");
|
||||
|
||||
label.SetAlignment (0, 0);
|
||||
box1.PackStart (box2, false, false, 0);
|
||||
box1.Show();
|
||||
|
||||
box2 = make_box (false, 10, true, true, 0);
|
||||
box1.PackStart (box2, false, false, 0);
|
||||
box2.Show();
|
||||
|
||||
separator = new HSeparator ();
|
||||
|
||||
box1.PackStart (separator, false, true, 5);
|
||||
separator.Show();
|
||||
|
||||
box2 = new HBox (false, 0);
|
||||
|
||||
label=new Gtk.Label("gtk_hbox_new (FALSE, 0);");
|
||||
label.SetAlignment (0, 0);
|
||||
box1.PackStart (label, false, false, 0);
|
||||
label.Show();
|
||||
|
||||
box2 = make_box (false, 0, true, false, 10);
|
||||
box1.PackStart (box2, false, false, 0);
|
||||
box2.Show();
|
||||
|
||||
box2 = make_box (false, 0, true, true, 10);
|
||||
box1.PackStart (box2, false, false, 0);
|
||||
box2.Show();
|
||||
|
||||
separator = new HSeparator ();
|
||||
box1.PackStart(separator, false, true, 5);
|
||||
separator.Show();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
box2 = make_box (false, 0, false, false, 0);
|
||||
label = new Label ("end");
|
||||
box2.PackEnd(label, false, false, 0);
|
||||
label.Show();
|
||||
|
||||
box1.PackStart(box2, false, false, 0);
|
||||
box2.Show();
|
||||
|
||||
separator = new HSeparator();
|
||||
separator.SetSizeRequest(400, 5);
|
||||
box1.PackStart (separator, false, true, 5);
|
||||
separator.Show();
|
||||
break;
|
||||
}
|
||||
quitbox = new HBox (false, 0);
|
||||
|
||||
button = new Button ("Quit");
|
||||
|
||||
button.Clicked += new EventHandler (ClickedEventHandler);
|
||||
|
||||
quitbox.PackStart(button, true, false, 0);
|
||||
box1.PackStart (quitbox, false, false, 0);
|
||||
|
||||
window.Add(box1);
|
||||
button.Show();
|
||||
quitbox.Show();
|
||||
|
||||
box1.Show();
|
||||
window.Show();
|
||||
|
||||
Application.Run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ClickedEventHandler(object sender, EventArgs e)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) radiobuttons.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,88 +0,0 @@
|
|||
// radiobuttons.cs - Gtk# Tutorial example
|
||||
//
|
||||
// Author: Johannes Roith <johannes@jroith.de>
|
||||
//
|
||||
// (c) 2002 Johannes Roith
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
|
||||
public class radiobuttons
|
||||
{
|
||||
|
||||
static GLib.SList group = null;
|
||||
|
||||
static void delete_event (object obj, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
static void exitbutton_event (object obj, EventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
Application.Init();
|
||||
|
||||
|
||||
Window window = new Window("radio buttons");
|
||||
|
||||
window.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
window.BorderWidth = 0;
|
||||
|
||||
VBox box1 = new VBox (false, 0);
|
||||
window.Add(box1);
|
||||
box1.Show();
|
||||
|
||||
VBox box2 = new VBox (false, 10);
|
||||
box2.BorderWidth = 10;
|
||||
box1.PackStart(box2, true, true, 0);
|
||||
box2.Show();
|
||||
|
||||
RadioButton radiobutton = new RadioButton (null, "button1");
|
||||
box2.PackStart(radiobutton, true, true, 0);
|
||||
radiobutton.Show();
|
||||
group = radiobutton.Group;
|
||||
RadioButton radiobutton2 = new RadioButton(group, "button2");
|
||||
radiobutton2.Active = true;
|
||||
box2.PackStart(radiobutton2, true, true, 0);
|
||||
radiobutton2.Show();
|
||||
|
||||
RadioButton radiobutton3 = RadioButton.NewWithLabelFromWidget(radiobutton, "button3");
|
||||
box2.PackStart(radiobutton3, true, true, 0);
|
||||
radiobutton3.Show();
|
||||
|
||||
HSeparator separator = new HSeparator ();
|
||||
box1.PackStart (separator,false, true, 0);
|
||||
separator.Show();
|
||||
|
||||
VBox box3 = new VBox(false, 10);
|
||||
box3.BorderWidth = 10;
|
||||
box1.PackStart(box3,false, true, 0);
|
||||
box3.Show();
|
||||
|
||||
Button button = new Button ("close");
|
||||
button.Clicked += new EventHandler (exitbutton_event);
|
||||
|
||||
box3.PackStart(button, true, true, 0);
|
||||
button.CanDefault = true;
|
||||
button.GrabDefault();
|
||||
button.Show();
|
||||
|
||||
window.ShowAll();
|
||||
|
||||
Application.Run();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r gdk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) rangeWidgetsSample.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,295 +0,0 @@
|
|||
// checkbuttons.cs - GTK# Tutorial example
|
||||
//
|
||||
// Authors: Alejandro Sanchez Acosta <raciel@es.gnu.org>
|
||||
// Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
|
||||
//
|
||||
// (C) 2002 Alejandro Sanchez Acosta <raciel@es.gnu.org>
|
||||
// Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
|
||||
public class rangeWidgetsSamples
|
||||
{
|
||||
static HScale hscale;
|
||||
static VScale vscale;
|
||||
|
||||
static void cb_pos_menu_select (object obj, PositionType pos)
|
||||
{
|
||||
/* Set the value position on both scale widgets */
|
||||
((Scale) hscale).ValuePos = pos;
|
||||
((Scale) vscale).ValuePos = pos;
|
||||
}
|
||||
|
||||
|
||||
static void cb_update_menu_select (object obj, UpdateType policy)
|
||||
{
|
||||
/* Set the update policy for both scale widgets */
|
||||
((Range) hscale).UpdatePolicy = policy;
|
||||
((Range) vscale).UpdatePolicy = policy;
|
||||
}
|
||||
|
||||
|
||||
static void cb_digits_scale (Adjustment adj)
|
||||
{
|
||||
/* Set the number of decimal places to which adj->value is rounded */
|
||||
|
||||
/* FIXME: this might be wrong */
|
||||
// ((Scale) hscale) = adj.Value;
|
||||
// ((Scale) vscale) = adj.Value;
|
||||
}
|
||||
|
||||
|
||||
// FIXME
|
||||
static void cb_page_size (Adjustment get, Adjustment set)
|
||||
{
|
||||
/* Set the page size and page increment size of the sample
|
||||
* adjustment to the value specified by the "Page Size" scale */
|
||||
//set.PageSize = get.Value;
|
||||
//set->page_increment = = get.Value;
|
||||
|
||||
/* This sets the adjustment and makes it emit the "changed" signal to
|
||||
reconfigure all the widgets that are attached to this signal. */
|
||||
//set.ClampPage (
|
||||
}
|
||||
|
||||
// FIXME
|
||||
static void cb_draw_value (ToggleButton button)
|
||||
{
|
||||
/* Turn the value display on the scale widgets off or on depending
|
||||
* on the state of the checkbutton */
|
||||
//((Scale) hscale).DrawValue button.Active
|
||||
//((Scale) vscale).DrawValue button.Active
|
||||
}
|
||||
|
||||
|
||||
/* Convenience functions */
|
||||
|
||||
// FIXME:
|
||||
static Widget make_menu_item (string name /*, callback , gpointer */)
|
||||
{
|
||||
Widget w = null;
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
static void scale_set_default_values (Scale s)
|
||||
{
|
||||
s.UpdatePolicy = UpdateType.Continuous;
|
||||
s.Digits = 1;
|
||||
s.ValuePos = PositionType.Top;
|
||||
s.DrawValue = true;
|
||||
}
|
||||
|
||||
static void create_range_controls ()
|
||||
{
|
||||
Window window;
|
||||
VBox box1, box3;
|
||||
Box box2;
|
||||
Button button;
|
||||
HScrollbar scrollbar;
|
||||
HSeparator separator;
|
||||
Widget item; /* FIXME: find out the exactly widgets */
|
||||
OptionMenu opt;
|
||||
Menu menu;
|
||||
Label label;
|
||||
Scale scale;
|
||||
Adjustment adj1, adj2;
|
||||
|
||||
window = new Window (WindowType.Toplevel);
|
||||
// window.DeleteEvent += new DeleteEventHandler
|
||||
window.Title = "range controls";
|
||||
|
||||
box1 = new VBox (false, 0);
|
||||
window.Add (box1);
|
||||
box1.ShowAll ();
|
||||
|
||||
box2 = new HBox (false, 0);
|
||||
box2.BorderWidth = 10;
|
||||
box1.PackStart (box2, true, true, 0);
|
||||
box2.ShowAll ();
|
||||
|
||||
/* value, lower, upper, step_increment, page_increment, page_size */
|
||||
/* Note that the page_size value only makes a difference for
|
||||
* scrollbar widgets, and the highest value you'll get is actually
|
||||
* (upper - page_size). */
|
||||
adj1 = new Adjustment (0.0, 0.0, 101.0, 0.1, 1.0, 1.0);
|
||||
|
||||
vscale = new VScale ((Adjustment) adj1);
|
||||
scale_set_default_values (vscale);
|
||||
|
||||
box2.PackStart (vscale, true, true, 0);
|
||||
vscale.ShowAll ();
|
||||
|
||||
box3 = new VBox (false, 10);
|
||||
box2.PackStart (box3, true, true, 0);
|
||||
box3.ShowAll ();
|
||||
|
||||
/* Reuse the same adjustment */
|
||||
hscale = new HScale ((Adjustment) adj1);
|
||||
hscale.SetSizeRequest (200, -1);
|
||||
scale_set_default_values (hscale);
|
||||
|
||||
box3.PackStart (hscale, true, true, 0);
|
||||
hscale.ShowAll ();
|
||||
|
||||
/* reuse the same adjustment again */
|
||||
scrollbar = new HScrollbar ((Adjustment) adj1);
|
||||
|
||||
/* Notice how this causes the scales to always be updated
|
||||
* continuously when the scrollbar is moved */
|
||||
scrollbar.UpdatePolicy = UpdateType.Continuous;
|
||||
|
||||
box3.PackStart (scrollbar, true, true, 0);
|
||||
scrollbar.ShowAll ();
|
||||
|
||||
box2 = new HBox (false, 10);
|
||||
box2.BorderWidth = 10;
|
||||
box1.PackStart (box2, true, true, 0);
|
||||
box2.ShowAll ();
|
||||
|
||||
/* A checkbutton to control whether the value is displayed or not */
|
||||
button = new Button ("Display value on scale widgets");
|
||||
//FIXME
|
||||
//((ToggleButton) button).Active = true;
|
||||
// FIXME: find out the handler signature
|
||||
//((ToggleButton) button).Toggled +=
|
||||
box2.PackStart (button, true, true, 0);
|
||||
button.ShowAll ();
|
||||
|
||||
box2 = new HBox (false, 10);
|
||||
box2.BorderWidth = 10;
|
||||
|
||||
/* An option menu to change the position of the value */
|
||||
label = new Label ("Scale Value Position:");
|
||||
box2.PackStart (label, false, false, 0);
|
||||
label.ShowAll ();
|
||||
|
||||
opt = new OptionMenu ();
|
||||
menu = new Menu ();
|
||||
|
||||
//FIXME:
|
||||
item = new MenuItem ();
|
||||
menu.Append (item);
|
||||
|
||||
// item =
|
||||
menu.Append (item);
|
||||
|
||||
// item =
|
||||
menu.Append (item);
|
||||
|
||||
// item =
|
||||
menu.Append (item);
|
||||
|
||||
((OptionMenu) opt).Menu = menu;
|
||||
box2.PackStart (opt, true, true, 0);
|
||||
opt.ShowAll ();
|
||||
|
||||
box1.PackStart (box2, true, true, 0);
|
||||
box2.ShowAll ();
|
||||
|
||||
box2 = new HBox (false, 10);
|
||||
box2.BorderWidth = 10;
|
||||
|
||||
/* Yet another option menu, this time for the update policy of the
|
||||
* scale widgets */
|
||||
label = new Label ("Scale Update Policy:");
|
||||
box2.PackStart (label, false, false, 0);
|
||||
label.ShowAll ();
|
||||
|
||||
opt = new OptionMenu ();
|
||||
menu = new Menu ();
|
||||
|
||||
// FIXME: continuous
|
||||
item = new MenuItem ();
|
||||
menu.Append (item);
|
||||
|
||||
// FIXME: discontinuous
|
||||
item = new MenuItem ();
|
||||
menu.Append (item);
|
||||
|
||||
//FIXME: delayed
|
||||
item = new MenuItem ();
|
||||
menu.Append (item);
|
||||
|
||||
opt.Menu = menu;
|
||||
|
||||
box2.PackStart (opt, true, true, 0);
|
||||
opt.ShowAll ();
|
||||
|
||||
box1.PackStart (box2, true, true, 0);
|
||||
box2.ShowAll ();
|
||||
|
||||
box2 = new HBox (false, 10);
|
||||
box2.BorderWidth = 10;
|
||||
|
||||
/* An HScale widget for adjusting the number of digits on the
|
||||
* sample scales. */
|
||||
label = new Label ("Scale Digits:");
|
||||
box2.PackStart (label, false, false, 0);
|
||||
label.ShowAll ();
|
||||
|
||||
adj2 = new Adjustment (1.0, 0.0, 5.0, 1.0, 1.0, 0.0);
|
||||
//FIXME: add a value_changed signal handler
|
||||
scale = new HScale (adj2);
|
||||
scale.Digits = 0;
|
||||
|
||||
box2.PackStart (scale, true, true, 0);
|
||||
scale.ShowAll ();
|
||||
|
||||
box1.PackStart (box2, true, true, 0);
|
||||
box2.ShowAll ();
|
||||
|
||||
box2 = new HBox (false, 10);
|
||||
box2.BorderWidth = 10;
|
||||
|
||||
/* And, one last HScale widget for adjusting the page size of the
|
||||
* scrollbar. */
|
||||
label = new Label ("Scrollbar Page Size:");
|
||||
box2.PackStart (label, false, false, 0);
|
||||
label.ShowAll ();
|
||||
|
||||
adj2 = new Adjustment (1.0, 1.0, 101.0, 1.0, 1.0, 0.0);
|
||||
// FIXME: write a value_changed signal handler
|
||||
scale = new HScale (adj2);
|
||||
scale.Digits = 0;
|
||||
box2.PackStart (scale, true, true, 0);
|
||||
scale.ShowAll ();
|
||||
|
||||
box1.PackStart (box2, true, true, 0);
|
||||
box2.ShowAll ();
|
||||
|
||||
separator = new HSeparator ();
|
||||
box1.PackStart (separator, false, true, 0);
|
||||
separator.ShowAll ();
|
||||
|
||||
box2 = new VBox (false, 10);
|
||||
box2.BorderWidth = 10;
|
||||
box1.PackStart (box2, false, true, 0);
|
||||
box2.ShowAll ();
|
||||
|
||||
button = new Button ("Quit");
|
||||
// FIXME: write a clicked signal handler
|
||||
box2.PackStart (button, true, true, 0);
|
||||
//FIXME: set widget flags
|
||||
//FIXME: grab default
|
||||
button.ShowAll ();
|
||||
|
||||
window.ShowAll ();
|
||||
}
|
||||
|
||||
|
||||
public static void Main (string [] args)
|
||||
{
|
||||
Application.Init ();
|
||||
create_range_controls ();
|
||||
Application.Run ();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r gdk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) Scribble.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,133 +0,0 @@
|
|||
// Scribble.cs - port of Gtk+ scribble demo
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// (c) 2002 Rachel Hestilow
|
||||
|
||||
namespace GtkSamples {
|
||||
|
||||
using Gtk;
|
||||
using Gdk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
|
||||
public class Scribble {
|
||||
private static Gtk.DrawingArea darea;
|
||||
private static Gdk.Pixmap pixmap = null;
|
||||
|
||||
public static int Main (string[] args)
|
||||
{
|
||||
Application.Init ();
|
||||
Gtk.Window win = new Gtk.Window ("Scribble demo");
|
||||
win.DeleteEvent += new DeleteEventHandler (Window_Delete);
|
||||
|
||||
darea = new Gtk.DrawingArea ();
|
||||
darea.SetSizeRequest (200, 200);
|
||||
win.Add (darea);
|
||||
|
||||
darea.ExposeEvent += new ExposeEventHandler (ExposeEvent);
|
||||
darea.ConfigureEvent += new ConfigureEventHandler (ConfigureEvent);
|
||||
darea.MotionNotifyEvent += new MotionNotifyEventHandler (MotionNotifyEvent);
|
||||
darea.ButtonPressEvent += new ButtonPressEventHandler (ButtonPressEvent);
|
||||
darea.Events = (int)EventMask.ExposureMask |
|
||||
(int)EventMask.LeaveNotifyMask |
|
||||
(int)EventMask.ButtonPressMask |
|
||||
(int)EventMask.PointerMotionMask |
|
||||
(int)EventMask.PointerMotionHintMask;
|
||||
|
||||
win.ShowAll ();
|
||||
Application.Run ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void Window_Delete (object obj, DeleteEventArgs args)
|
||||
{
|
||||
SignalArgs sa = (SignalArgs) args;
|
||||
Application.Quit ();
|
||||
sa.RetVal = true;
|
||||
}
|
||||
|
||||
static void ExposeEvent (object obj, ExposeEventArgs args)
|
||||
{
|
||||
Gdk.EventExpose ev = args.Event;
|
||||
Gdk.Window window = ev.window;
|
||||
// FIXME: mcs bug
|
||||
Gdk.Rectangle area = ev.area;
|
||||
// FIXME: array marshalling not done yet so no FG */
|
||||
window.DrawDrawable (darea.Style.BlackGC,
|
||||
pixmap,
|
||||
area.x, area.y,
|
||||
area.x, area.y,
|
||||
area.width, area.height);
|
||||
|
||||
SignalArgs sa = (SignalArgs) args;
|
||||
sa.RetVal = false;
|
||||
}
|
||||
|
||||
static void ConfigureEvent (object obj, ConfigureEventArgs args)
|
||||
{
|
||||
Gdk.EventConfigure ev = args.Event;
|
||||
Gdk.Window window = ev.window;
|
||||
Gdk.Rectangle allocation = darea.Allocation;
|
||||
pixmap = new Gdk.Pixmap (window,
|
||||
allocation.width,
|
||||
allocation.height,
|
||||
-1);
|
||||
pixmap.DrawRectangle (darea.Style.WhiteGC, 1, 0, 0,
|
||||
allocation.width, allocation.height);
|
||||
|
||||
SignalArgs sa = (SignalArgs) args;
|
||||
sa.RetVal = true;
|
||||
}
|
||||
|
||||
static void DrawBrush (double x, double y)
|
||||
{
|
||||
Gdk.Rectangle update_rect = new Gdk.Rectangle ();
|
||||
update_rect.x = (int) x - 5;
|
||||
update_rect.y = (int) y - 5;
|
||||
update_rect.width = 10;
|
||||
update_rect.height = 10;
|
||||
|
||||
pixmap.DrawRectangle (darea.Style.BlackGC, 1,
|
||||
update_rect.x, update_rect.y,
|
||||
update_rect.width, update_rect.height);
|
||||
darea.QueueDrawArea (update_rect.x, update_rect.y,
|
||||
update_rect.width, update_rect.height);
|
||||
}
|
||||
|
||||
static void ButtonPressEvent (object obj, ButtonPressEventArgs args)
|
||||
{
|
||||
Gdk.EventButton ev = args.Event;
|
||||
if (ev.button == 1 && pixmap != null)
|
||||
DrawBrush (ev.x, ev.y);
|
||||
|
||||
SignalArgs sa = (SignalArgs) args;
|
||||
sa.RetVal = true;
|
||||
}
|
||||
|
||||
static void MotionNotifyEvent (object obj, MotionNotifyEventArgs args)
|
||||
{
|
||||
int x, y;
|
||||
Gdk.ModifierType state;
|
||||
Gdk.EventMotion ev = args.Event;
|
||||
Gdk.Window window = ev.window;
|
||||
|
||||
if (ev.is_hint != 0) {
|
||||
int s;
|
||||
window.GetPointer (out x, out y, out s);
|
||||
state = (Gdk.ModifierType) s;
|
||||
} else {
|
||||
x = (int) ev.x;
|
||||
y = (int) ev.y;
|
||||
state = (Gdk.ModifierType) ev.state;
|
||||
}
|
||||
|
||||
if ((state & Gdk.ModifierType.Button1Mask) != 0 && pixmap != null)
|
||||
DrawBrush (x, y);
|
||||
|
||||
SignalArgs sa = (SignalArgs) args;
|
||||
sa.RetVal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) scrolledwin.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,107 +0,0 @@
|
|||
// scrolledwin.cs - Gtk# Tutorial example
|
||||
//
|
||||
// Author: Johannes Roith <johannes@jroith.de>
|
||||
//
|
||||
// (c) 2002 Johannes Roith
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
|
||||
public class scrolledwin
|
||||
{
|
||||
|
||||
static void delete_event (object obj, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
static void quitbutton_event (object obj, EventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
|
||||
string buffer;
|
||||
uint i, j;
|
||||
|
||||
Application.Init();
|
||||
|
||||
/* Create a new dialog window for the scrolled window to be
|
||||
* packed into. */
|
||||
Dialog window = new Dialog();
|
||||
window.Title = "GtkScrolledWindow example";
|
||||
window.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
window.BorderWidth = 0;
|
||||
window.SetSizeRequest(300, 300);
|
||||
|
||||
/* create a new scrolled window. */
|
||||
ScrolledWindow scrolled_window = new ScrolledWindow (null, null);
|
||||
|
||||
scrolled_window.BorderWidth= 10;
|
||||
|
||||
/* the policy is one of GTK_POLICY AUTOMATIC, or GTK_POLICY_ALWAYS.
|
||||
* GTK_POLICY_AUTOMATIC will automatically decide whether you need
|
||||
* scrollbars, whereas GTK_POLICY_ALWAYS will always leave the scrollbars
|
||||
* there. The first one is the horizontal scrollbar, the second,
|
||||
* the vertical. */
|
||||
|
||||
scrolled_window.SetPolicy (PolicyType.Automatic, PolicyType.Always);
|
||||
|
||||
/* The dialog window is created with a vbox packed into it. */
|
||||
|
||||
window.VBox.PackStart(scrolled_window, true, true, 0);
|
||||
scrolled_window.Show();
|
||||
|
||||
/* create a table of 10 by 10 squares. */
|
||||
Table table = new Table(10, 10, false);
|
||||
|
||||
/* set the spacing to 10 on x and 10 on y */
|
||||
table.RowSpacings = 10;
|
||||
table.ColSpacings = 10;
|
||||
|
||||
|
||||
/* pack the table into the scrolled window */
|
||||
scrolled_window.AddWithViewport(table);
|
||||
table.Show();
|
||||
|
||||
/* this simply creates a grid of toggle buttons on the table
|
||||
* to demonstrate the scrolled window. */
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
for (j = 0; j < 10; j++) {
|
||||
buffer = "button (" + i + "," + j + ")\n";
|
||||
ToggleButton button = new ToggleButton (buffer);
|
||||
table.Attach(button, i, i+1, j, j+1);
|
||||
button.Show();
|
||||
}
|
||||
|
||||
/* Add a "close" button to the bottom of the dialog */
|
||||
Button button = new Button("close");
|
||||
button.Clicked += new EventHandler (quitbutton_event);
|
||||
|
||||
/* this makes it so the button is the default. */
|
||||
|
||||
button.CanDefault = true;
|
||||
window.ActionArea.PackStart(button, true, true, 0);
|
||||
|
||||
/* This grabs this button to be the default button. Simply hitting
|
||||
* the "Enter" key will cause this button to activate. */
|
||||
button.GrabDefault();
|
||||
button.Show();
|
||||
|
||||
window.Show();
|
||||
|
||||
Application.Run();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r gdk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) SpinButton.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,225 +0,0 @@
|
|||
// SpinButton.cs - Gtk# Tutorial example
|
||||
//
|
||||
// Author: Alejandro Sánchez Acosta <raciel@es.gnu.org>
|
||||
// Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
|
||||
//
|
||||
// (c) 2002 Alejandro Sánchez Acosta
|
||||
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
using System.Text;
|
||||
|
||||
public class SpinButtonSample
|
||||
{
|
||||
static Gtk.Window window;
|
||||
static Frame frame;
|
||||
static HBox hbox;
|
||||
static VBox main_vbox;
|
||||
static VBox vbox;
|
||||
static VBox vbox2;
|
||||
static SpinButton spinner;
|
||||
static SpinButton spinner1;
|
||||
static SpinButton spinner2;
|
||||
static Button button;
|
||||
static Label label;
|
||||
static Label val_label;
|
||||
static Adjustment adj;
|
||||
|
||||
static void toggle_snap (object obj, EventArgs args)
|
||||
{
|
||||
spinner1.SnapToTicks = ((ToggleButton) obj).Active;
|
||||
}
|
||||
|
||||
static void toggle_numeric (object obj, EventArgs args)
|
||||
{
|
||||
spinner1.Numeric = ((ToggleButton) obj).Active;
|
||||
}
|
||||
|
||||
// FIXME: exception emitted when called.
|
||||
static void change_digits (object obj, EventArgs args)
|
||||
{
|
||||
spinner1.Digits = (uint) ((SpinButton) obj).ValueAsInt;
|
||||
}
|
||||
|
||||
static void get_value (object obj, EventArgs args)
|
||||
{
|
||||
StringBuilder buff;
|
||||
Label label;
|
||||
SpinButton spin;
|
||||
|
||||
spin = spinner1;
|
||||
buff =new StringBuilder ("ERROR");
|
||||
|
||||
label = new Label ("1");
|
||||
label.Text = buff.ToString ();
|
||||
}
|
||||
|
||||
static void delete_event (object obj, DeleteEventArgs args)
|
||||
{
|
||||
SignalArgs sa = (SignalArgs) args;
|
||||
Application.Quit();
|
||||
sa.RetVal = true;
|
||||
}
|
||||
|
||||
static void exitbutton_event (object obj, EventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
Application.Init();
|
||||
|
||||
window = new Gtk.Window ("SpinButton#");
|
||||
window.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
main_vbox = new VBox (false, 5);
|
||||
main_vbox.BorderWidth = 10;
|
||||
window.Add (main_vbox);
|
||||
|
||||
frame = new Frame ("Not accelerated");
|
||||
main_vbox.PackStart (frame, true, true, 0);
|
||||
|
||||
vbox = new VBox (false, 0);
|
||||
vbox.BorderWidth = 5;
|
||||
frame.Add (vbox);
|
||||
|
||||
// Day, month, year spinners
|
||||
|
||||
hbox = new HBox (false, 0);
|
||||
vbox.PackStart (hbox, true, true, 5);
|
||||
|
||||
vbox2 = new VBox (false, 0);
|
||||
hbox.PackStart (vbox2, true, true, 5);
|
||||
|
||||
label = new Label ("Day :");
|
||||
((Gtk.Misc) label).SetAlignment ((float) 0.0, (float) 0.5);
|
||||
vbox2.PackStart (label, false, true, 0);
|
||||
|
||||
adj = new Adjustment (1.0, 1.0, 31.0, 1.0, 5.0, 0.0);
|
||||
|
||||
spinner = new SpinButton (adj, 0, 0);
|
||||
|
||||
spinner.Wrap = true;
|
||||
vbox2.PackStart (spinner, false, true, 0);
|
||||
|
||||
vbox2 = new VBox (false, 0);
|
||||
hbox.PackStart (vbox2, true, true, 5);
|
||||
|
||||
label = new Label ("Month :");
|
||||
((Gtk.Misc) label).SetAlignment ((float) 0.0, (float) 0.5);
|
||||
|
||||
vbox2.PackStart (label, false, true, 0);
|
||||
|
||||
adj = new Adjustment (1.0, 1.0, 12.0, 1.0,
|
||||
5.0, 0.0);
|
||||
|
||||
spinner = new SpinButton (adj, 0, 0);
|
||||
spinner.Wrap = true;
|
||||
vbox2.PackStart (spinner, false, true, 0);
|
||||
|
||||
vbox2 = new VBox (false, 0);
|
||||
hbox.PackStart (vbox2, true, true, 5);
|
||||
|
||||
label = new Label ("Year :");
|
||||
((Gtk.Misc) label).SetAlignment ((float) 0.0, (float) 0.5);
|
||||
vbox2.PackStart (label, false, true, 0);
|
||||
|
||||
adj = new Adjustment (1998.0, 0.0, 2100.0, 1.0, 100.0, 0.0);
|
||||
|
||||
spinner = new SpinButton (adj, 0, 0);
|
||||
spinner.Wrap = false;
|
||||
spinner.SetSizeRequest (55, -1);
|
||||
vbox2.PackStart (spinner, false, true, 0);
|
||||
|
||||
frame = new Frame ("Accelerated");
|
||||
main_vbox.PackStart (frame, true, true, 0);
|
||||
|
||||
vbox = new VBox (false, 0);
|
||||
vbox.BorderWidth = 5;
|
||||
frame.Add (vbox);
|
||||
|
||||
hbox = new HBox (false, 0);
|
||||
vbox.PackStart (hbox, false, true, 5);
|
||||
|
||||
vbox2 = new VBox (false, 0);
|
||||
hbox.PackStart (vbox2, true, true, 5);
|
||||
|
||||
label = new Label ("Value :");
|
||||
((Gtk.Misc) label).SetAlignment ((float) 0.0, (float) 0.5);
|
||||
vbox2.PackStart (label, false, true, 0);
|
||||
|
||||
adj = new Adjustment (0.0, -10000.0, 10000.0, 0.5, 100.0, 0.0);
|
||||
|
||||
spinner1 = new SpinButton (adj, 1.0, 2);
|
||||
spinner1.Wrap = true;
|
||||
spinner1.SetSizeRequest (100, -1);
|
||||
vbox2.PackStart (spinner1, false, true, 0);
|
||||
|
||||
vbox2 = new VBox (false, 0);
|
||||
hbox.PackStart (vbox2, true, true, 5);
|
||||
|
||||
label = new Label ("Digits :");
|
||||
((Gtk.Misc) label).SetAlignment ((float) 0, (float) 0.5);
|
||||
vbox2.PackStart (label, false, true, 0);
|
||||
|
||||
adj = new Adjustment (2, 1, 5, 1, 1, 0);
|
||||
|
||||
spinner2 = new SpinButton (adj, 0.0, 0);
|
||||
spinner2.Wrap = true;
|
||||
|
||||
adj.ValueChanged += new EventHandler (change_digits);
|
||||
vbox2.PackStart (spinner2, false, true, 0);
|
||||
|
||||
hbox = new HBox (false, 0);
|
||||
vbox.PackStart (hbox, false, true, 5);
|
||||
|
||||
button = new CheckButton ("Snap to 0.5-ticks");
|
||||
button.Clicked += new EventHandler (toggle_snap);
|
||||
vbox.PackStart (button, true, true, 0);
|
||||
((Gtk.ToggleButton) button).Active = true;
|
||||
|
||||
button = new CheckButton ("Numeric only input mode");
|
||||
button.Clicked += new EventHandler (toggle_numeric);
|
||||
vbox.PackStart (button, true, true, 0);
|
||||
((Gtk.ToggleButton) button).Active = true;
|
||||
|
||||
val_label = new Label ("");
|
||||
|
||||
hbox = new HBox (false, 0);
|
||||
vbox.PackStart (hbox, false, true, 5);
|
||||
button = new Button ("Value as Int");
|
||||
button.SetData ("user_data", val_label);
|
||||
|
||||
button.Clicked += new EventHandler (get_value);
|
||||
hbox.PackStart (button, true, true, 5);
|
||||
|
||||
button = new Button ("Value as Float");
|
||||
button.SetData ("user_data", val_label);
|
||||
button.Clicked += new EventHandler (get_value);
|
||||
hbox.PackStart (button, true, true, 5);
|
||||
label.Text = "0";
|
||||
|
||||
vbox.PackStart (val_label, true, true, 0);
|
||||
val_label.Text = "0";
|
||||
|
||||
hbox = new HBox (false, 0);
|
||||
main_vbox.PackStart (hbox, false, true, 0);
|
||||
|
||||
button = new Button ("Close");
|
||||
button.Clicked += new EventHandler (exitbutton_event);
|
||||
|
||||
hbox.PackStart (button, true, true, 5);
|
||||
|
||||
window.ShowAll();
|
||||
|
||||
Application.Run ();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) table.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,112 +0,0 @@
|
|||
// table.cs - Gtk# Tutorial example
|
||||
//
|
||||
// Author: Johannes Roith <johannes@jroith.de>
|
||||
//
|
||||
// (c) 2002 Johannes Roith
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
|
||||
public class table
|
||||
{
|
||||
|
||||
/* Our new improved callback. The data passed to this function
|
||||
* is printed to stdout. */
|
||||
|
||||
static void callback( object obj, EventArgs args)
|
||||
{
|
||||
Button mybutton = (Button) obj;
|
||||
Console.WriteLine("Hello again - {0} was pressed", (string) mybutton.Label);
|
||||
// Have to figure out, how to recieve button name
|
||||
}
|
||||
|
||||
/* another event */
|
||||
static void delete_event (object obj, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
static void exit_event (object obj, EventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
|
||||
|
||||
Application.Init ();
|
||||
|
||||
|
||||
/* Create a new window */
|
||||
Window window = new Window ("Table");
|
||||
|
||||
|
||||
/* Set a handler for delete_event that immediately
|
||||
* exits GTK. */
|
||||
window.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
/* Sets the border width of the window. */
|
||||
window.BorderWidth= 20;
|
||||
|
||||
/* Create a 2x2 table */
|
||||
Table table = new Table (2, 2, true);
|
||||
|
||||
/* Put the table in the main window */
|
||||
window.Add(table);
|
||||
|
||||
/* Create first button */
|
||||
Button button = new Button("button 1");
|
||||
|
||||
/* When the button is clicked, we call the "callback" function
|
||||
* with a pointer to "button 1" as its argument */
|
||||
button.Clicked += new EventHandler (callback);
|
||||
|
||||
|
||||
/* Insert button 1 into the upper left quadrant of the table */
|
||||
table.Attach(button, 0, 1, 0, 1);
|
||||
|
||||
button.Show();
|
||||
|
||||
/* Create second button */
|
||||
|
||||
Button button2 = new Button("button 2");
|
||||
|
||||
/* When the button is clicked, we call the "callback" function
|
||||
* with a pointer to "button 2" as its argument */
|
||||
|
||||
button2.Clicked += new EventHandler (callback);
|
||||
|
||||
/* Insert button 2 into the upper right quadrant of the table */
|
||||
table.Attach(button2, 1, 2, 0, 1);
|
||||
|
||||
button2.Show();
|
||||
|
||||
/* Create "Quit" button */
|
||||
Button quitbutton = new Button("Quit");
|
||||
|
||||
/* When the button is clicked, we call the "delete_event" function
|
||||
* and the program exits */
|
||||
quitbutton.Clicked += new EventHandler (exit_event);
|
||||
|
||||
/* Insert the quit button into the both
|
||||
* lower quadrants of the table */
|
||||
table.Attach(quitbutton, 0, 2, 1, 2);
|
||||
|
||||
quitbutton.Show();
|
||||
|
||||
table.Show();
|
||||
window.ShowAll();
|
||||
|
||||
Application.Run();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
CSC = mcs
|
||||
|
||||
DLLS = -r glib-sharp.dll \
|
||||
-r gtk-sharp.dll \
|
||||
-r System.Drawing.dll
|
||||
|
||||
all:
|
||||
$(CSC) /unsafe $(DLLS) togglebutton.cs
|
||||
clean:
|
||||
rm -f *.exe
|
|
@ -1,80 +0,0 @@
|
|||
// togglebuttons.cs - Gtk# Tutorial example
|
||||
//
|
||||
// Author: Alejandro Sánchez Acosta <raciel@es.gnu.org>
|
||||
// Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
|
||||
//
|
||||
// (c) 2002 Alejandro Sánchez Acosta
|
||||
|
||||
namespace GtkSharpTutorial {
|
||||
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
public class togglebuttons
|
||||
{
|
||||
|
||||
static void delete_event (object obj, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
static void exitbutton_event (object obj, EventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
Application.Init();
|
||||
|
||||
|
||||
Window window = new Window("toggle buttons");
|
||||
|
||||
window.DeleteEvent += new DeleteEventHandler (delete_event);
|
||||
|
||||
window.BorderWidth = 0;
|
||||
|
||||
VBox box1 = new VBox (false, 0);
|
||||
window.Add(box1);
|
||||
box1.Show();
|
||||
|
||||
VBox box2 = new VBox (false, 10);
|
||||
box2.BorderWidth = 10;
|
||||
box1.PackStart(box2, true, true, 0);
|
||||
box2.Show();
|
||||
|
||||
ToggleButton togglebutton = new ToggleButton ("button1");
|
||||
box2.PackStart(togglebutton, true, true, 0);
|
||||
togglebutton.Show();
|
||||
ToggleButton togglebutton2 = new ToggleButton("button2");
|
||||
togglebutton2.Active = true;
|
||||
box2.PackStart(togglebutton2, true, true, 0);
|
||||
togglebutton2.Show();
|
||||
|
||||
HSeparator separator = new HSeparator ();
|
||||
box1.PackStart (separator,false, true, 0);
|
||||
separator.Show();
|
||||
|
||||
VBox box3 = new VBox(false, 10);
|
||||
box3.BorderWidth = 10;
|
||||
box1.PackStart(box3,false, true, 0);
|
||||
box3.Show();
|
||||
|
||||
Button button = new Button ("close");
|
||||
button.Clicked += new EventHandler (exitbutton_event);
|
||||
|
||||
box3.PackStart(button, true, true, 0);
|
||||
button.CanDefault = true;
|
||||
button.GrabDefault();
|
||||
button.Show();
|
||||
|
||||
window.ShowAll();
|
||||
|
||||
Application.Run();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue