Fedora8を使ってみる

Fedora8をデスクトップとして使ってみる

2.ボタンクリック時にテキストを表示

2007年02月25日 | Glade
参考

using System;
using Gtk;
using Glade;

class DemoWindow {
void on_button1_clicked(object o, EventArgs e)
{
Console.WriteLine("Clicked!");
}

public DemoWindow ()
{
Glade.XML gui = new Glade.XML("./project1.glade","window1","");
gui.Autoconnect (this);
}
}

class GtkSharpDemo {
static void Main()
{
Gtk.Application.Init();
DemoWindow dw = new DemoWindow();
Gtk.Application.Run();
}
}

mcs -pkg:gtk-sharp-2.0 -pkg:glade-sharp-2.0 demo.cs して、
$ mono demo.exe で起動します。

編集

1.GUIアプリを作る

2007年02月25日 | Glade
参考

using Gtk;
using Glade;

class DemoWindow {
public DemoWindow ()
{
Glade.XML gui = new Glade.XML("./project1.glade","window1","");
}
}

class GtkSharpDemo {
static void Main()
{
Gtk.Application.Init();
DemoWindow dw = new DemoWindow();
Gtk.Application.Run();
}
}

mcs -pkg:gtk-sharp-2.0 -pkg:glade-sharp-2.0 demo.cs して、
$ mono demo.exe で起動します。

参考

編集

9.[]でペンのサイズ変更

2007年02月25日 | gtk2
参考

int gPenSize=80;

/* キーが押された時の処理 */
void key_press(GtkWidget *widget,
GdkEventKey *event,
gpointer data){
//printf("key code: %d key: %sn", event->keyval, event->string);
if(event->keyval == 91) gPenSize--;
if(event->keyval == 93) gPenSize++;
}

/* ペンのサイズ */
update_rect.x = x - (gPenSize / 2);
update_rect.y = y - (gPenSize / 2);
update_rect.width = gPenSize;
update_rect.height = gPenSize;

(main の中)
/* キー入力を監視 */
gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
GTK_SIGNAL_FUNC(key_press), NULL);

gcc hello.c -o base `pkg-config --cflags --libs gtk+-2.0`

編集