----Next_Part(Sun_Nov_28_09:51:15_1999_335)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

こんにちは。

Gtk::Calendarです。

----Next_Part(Sun_Nov_28_09:51:15_1999_335)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="rbgtkcalendar.c"

#include "global.h"

static VALUE
cal_init(self)
    VALUE self;
{
    set_widget(self, gtk_calendar_new());
    return Qnil;
}

static VALUE
cal_select_month(self, month, year)
    VALUE self, month, year;
{
    gint ret;

    ret  tk_calendar_select_month(GTK_CALENDAR(get_widget(self)),
				    FIX2INT(month),
				    FIX2INT(year));
    return INT2FIX(ret);
}

static VALUE
cal_select_day(self, day)
    VALUE self, day;
{
    gtk_calendar_select_day(GTK_CALENDAR(get_widget(self)), FIX2INT(day));
    return self;
}

static VALUE
cal_mark_day(self, day)
    VALUE self, day;
{
    gint ret;

    ret  tk_calendar_mark_day(GTK_CALENDAR(get_widget(self)), FIX2INT(day));
    return INT2FIX(ret);
}

static VALUE
cal_unmark_day(self, day)
    VALUE self, day;
{
    gint ret;

    ret  tk_calendar_unmark_day(GTK_CALENDAR(get_widget(self)), FIX2INT(day));
    return INT2FIX(ret);
}

static VALUE
cal_clear_marks(self)
    VALUE self;
{
    gtk_calendar_clear_marks(GTK_CALENDAR(get_widget(self)));
    return self;
}

static VALUE
cal_display_options(self, flags)
    VALUE self, flags;
{
    gtk_calendar_display_options(GTK_CALENDAR(get_widget(self)),
				 FIX2INT(flags));
    return self;
}

static VALUE
cal_get_date(self)
    VALUE self;
{
    VALUE ret;
    guint year, month, day;

    gtk_calendar_get_date(GTK_CALENDAR(get_widget(self)),
			  &year, &month, &day);
    ret  b_ary_new();
    rb_ary_push(ret, INT2FIX(year));
    rb_ary_push(ret, INT2FIX(month));
    rb_ary_push(ret, INT2FIX(day));
    return ret;
}

static VALUE
cal_freeze(self)
    VALUE self;
{
    gtk_calendar_freeze(GTK_CALENDAR(get_widget(self)));
    return self;
}

static VALUE
cal_thaw(self)
    VALUE self;
{
    gtk_calendar_thaw(GTK_CALENDAR(get_widget(self)));
    return self;
}

void Init_gtk_calendar()
{
    gCalendar  b_define_class_under(mGtk, "Calendar", gWidget);

    rb_define_const(gCalendar, "SHOW_HEADING",
		    INT2FIX(GTK_CALENDAR_SHOW_HEADING));
    rb_define_const(gCalendar, "SHOW_DAY_NAMES",
		    INT2FIX(GTK_CALENDAR_SHOW_DAY_NAMES));
    rb_define_const(gCalendar, "NO_MONTH_CHANGE",
		    INT2FIX(GTK_CALENDAR_NO_MONTH_CHANGE));
    rb_define_const(gCalendar, "SHOW_WEEK_NUMBERS",
		    INT2FIX(GTK_CALENDAR_SHOW_WEEK_NUMBERS));
    rb_define_const(gCalendar, "WEEK_START_MONDAY",
		    INT2FIX(GTK_CALENDAR_WEEK_START_MONDAY));

    rb_define_const(gCalendar, "SIGNAL_MONTH_CHANGED",
		    rb_str_new2("month_changed"));
    rb_define_const(gCalendar, "SIGNAL_DAY_SELECTED",
		    rb_str_new2("day_selected"));
    rb_define_const(gCalendar, "SIGNAL_DAY_SELECTED_DOUBLE_CLICK",
		    rb_str_new2("day_selected_double_click"));
    rb_define_const(gCalendar, "SIGNAL_PREV_MONTH",
		    rb_str_new2("prev_month"));
    rb_define_const(gCalendar, "SIGNAL_NEXT_MONTH",
		    rb_str_new2("next_month"));
    rb_define_const(gCalendar, "SIGNAL_PREV_YEAR",
		    rb_str_new2("prev_year"));
    rb_define_const(gCalendar, "SIGNAL_NEXT_YEAR",
		    rb_str_new2("next_year"));

    rb_define_method(gCalendar, "initialize", cal_init, 0);
    rb_define_method(gCalendar, "select_month", cal_select_month, 2);
    rb_define_method(gCalendar, "select_day", cal_select_day, 1);
    rb_define_method(gCalendar, "mark_day", cal_mark_day, 1);
    rb_define_method(gCalendar, "unmark_day", cal_unmark_day, 1);
    rb_define_method(gCalendar, "clear_marks", cal_clear_marks, 0);
    rb_define_method(gCalendar, "display_options", cal_display_options, 1);
    rb_define_method(gCalendar, "get_date", cal_get_date, 0);
    rb_define_method(gCalendar, "freeze", cal_freeze, 0);
    rb_define_method(gCalendar, "thaw", cal_thaw, 0);

    rb_define_alias(gCalendar, "date", "get_date");
}

/* * Local Variables: * c-file-style: "bsd" * End: */ ----Next_Part(Sun_Nov_28_09:51:15_1999_335)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cal.rb" require 'gtk' cal tk::Calendar.new w tk::Window.new(Gtk::WINDOW_TOPLEVEL) w.add(cal).show_all.signal_connect('delete_event') do Gtk::main_quit end cal.select_month(7, 1974) cal.select_day(15) cal.mark_day(20) cal.clear_marks #cal.display_options(Gtk::Calendar::SHOW_HEADING | # Gtk::Calendar::SHOW_DAY_NAMES | # Gtk::Calendar::NO_MONTH_CHANGE | # Gtk::Calendar::SHOW_WEEK_NUMBERS | # Gtk::Calendar::WEEK_START_MONDAY) year, month, day al.get_date print "this is #{month} #{day}, #{year}\n" cal.signal_connect('day_selected') do year, month, day al.date print "selected day: ", day, "\n" end cal.signal_connect('month_changed') do year, month, day al.date print "changed month: ", month, "\n" end cal.signal_connect('day_selected_double_click') do year, month, day al.date print "dclicked day: ", day, "\n" end cal.signal_connect('prev_month') do year, month, day al.date print "prev month: ", month, "\n" end cal.signal_connect('next_month') do year, month, day al.date print "next_month: ", month, "\n" end cal.signal_connect('prev_year') do year, month, day al.date print "prev_year: ", year, "\n" end cal.signal_connect('next_year') do year, month, day al.date print "next year: ", year, "\n" end Gtk::main ----Next_Part(Sun_Nov_28_09:51:15_1999_335)----