[#9811] Ruby book — WATANABE Tetsuya <tetsu@...>

今日のひとこと(10/05)

22 messages 1998/10/05
[#9812] Re: Ruby book — matz@... (Yukihiro Matsumoto) 1998/10/05

まつもと ゆきひろです

[#9813] Re: Ruby book — "D.Kanda" <MAP2303@...> 1998/10/05

[#9815] Re: Ruby book — matz@... (Yukihiro Matsumoto) 1998/10/05

まつもと ゆきひろです

[#9827] Are there any NNTP Client Class? — Takeshi UME Imai <takeshi@...>

はじめまして。今井といいます。

17 messages 1998/10/05
[#9828] Re: Are there any NNTP Client Class? — aamine@... 1998/10/05

はじめまして、あおきともうします。

[#9869] man-1.1/Marshal.html — ttate@...

立石です。

47 messages 1998/10/07
[#9872] Re: man-1.1/Marshal.html — matz@... (Yukihiro Matsumoto) 1998/10/08

まつもと ゆきひろです

[#9880] comments on manual (Re: man-1.1/Marshal.html) — Motoyuki Kasahara <m-kasahr@...> 1998/10/08

SRA の笠原です。

[#9881] Re: comments on manual (Re: man-1.1/Marshal.html) — matz@... (Yukihiro Matsumoto) 1998/10/08

まつもと ゆきひろです

[#9909] Re: comments on manual (Re: man-1.1/Marshal.html) — Motoyuki Kasahara <m-kasahr@...> 1998/10/09

SRA の笠原です。

[#9936] Re: comments on manual (Re: man-1.1/Marshal.html) — matz@... (Yukihiro Matsumoto) 1998/10/09

まつもと ゆきひろです

[#9939] Re: comments on manual (Re: man-1.1/Marshal.html) — Shin-ichro Hara <sinara@...> 1998/10/09

原です。

[#9940] Re: comments on manual (Re: man-1.1/Marshal.html) — matz@... (Yukihiro Matsumoto) 1998/10/09

まつもと ゆきひろです

[#9941] Re: comments on manual (Re: man-1.1/Marshal.html) — Shin-ichro Hara <sinara@...> 1998/10/09

原です。

[#9942] Re: comments on manual (Re: man-1.1/Marshal.html) — matz@... (Yukihiro Matsumoto) 1998/10/09

まつもと ゆきひろです

[#9944] read(nil) (Re: comments on manual) — Shin-ichro Hara <sinara@...> 1998/10/09

原です。

[#9884] List of UserInterface Kits for Ruby ? — a.furudo@...

20 messages 1998/10/08
[#9906] Re: List of UserInterface Kits for Ruby ? — matz@... (Yukihiro Matsumoto) 1998/10/09

まつもと ゆきひろです

[#9885] 文字化け失礼、再送 — Akihiro Furudo <a.furudo@...>

26 messages 1998/10/08
[#9888] Re: 文字化け失礼、再送 — ttate@... 1998/10/08

立石です。

[#9897] お礼と、 Ruby/Gtk(i18n) について質問 — Akihiro Furudo <A.Furudo@...> 1998/10/08

[#9982] Re: お礼と、 Ruby/Gtk(i18n) について質問 — Daisuke Kanda <MAP2303@...> 1998/10/11

[#10320] Ruby/Gtk を FreeBSD にインストール (re:9982) — Akihiro Furudo <a.furudo@...> 1998/10/24

[#10328] Re: Ruby/Gtk を FreeBSD にインストール (re:9982) — Daisuke Kanda <MAP2303@...> 1998/10/25

[#9976] ruby:struct -> ext module -> ruby — Kikutani Makoto <kikutani@...>

きくたにです。

17 messages 1998/10/11

[#9999] ruby on HP-UX — AU6M-IWM@... (Iwama Misao)

20 messages 1998/10/12
[#10001] Re: ruby on HP-UX — matz@... (Yukihiro Matsumoto) 1998/10/12

まつもと ゆきひろです

[#10030] Ruby/Gtk text widget — TAKAHASHI Masayoshi <maki@...>

高橋です。

29 messages 1998/10/12
[#10035] Re: Ruby/Gtk text widget — Daisuke Kanda <MAP2303@...> 1998/10/12

[#10038] ruby/gtk method naming (Re: Re: Ruby/Gtk text widget) — "D.Kanda" <MAP2303@...> 1998/10/13

[#10067] Re: ruby/gtk method naming (Re: Re: Ruby/Gtk text widget) — Kazumi Okamoto <kazusan@...> 1998/10/13

岡本です。

[#10092] for が修飾子だったら — ARIMA Yasuhiro <fit0298@...>

有馬@FITECです。

46 messages 1998/10/14
[#10093] Re: for が修飾子だったら — matz@... (Yukihiro Matsumoto) 1998/10/14

まつもと ゆきひろです

[#10236] Array.html again — Motoyuki Kasahara <m-kasahr@...>

笠原です。こんにちは。

18 messages 1998/10/22
[#10237] Re: Array.html again — Kanda <MAP2303@...> 1998/10/22

[#10239] Re: Array.html again — matz@... (Yukihiro Matsumoto) 1998/10/22

まつもと ゆきひろです

[#10311] Re: 大規模プログラムの友 — m_seki@... (SEKI)

At 11:23 PM 98.10.23 +0900, Takashi Nakai wrote:

24 messages 1998/10/23
[#10312] Re: 大規模プログラムの友 — Takashi Nakai <nakai@...1.sys.to.casio.co.jp> 1998/10/23

ど〜も、(またしても)中井です。

[#10369] Re: 大規模プログラムの友 — matz@... (Yukihiro Matsumoto) 1998/10/27

まつもと ゆきひろです

[#10415] split — flare@... (Takashi Ikeda)

ふれあです。

20 messages 1998/10/28

[#10473] case with Class — MineroAoki <aamine@...>

あおきです。

46 messages 1998/10/29
[#10483] Re: case with Class — matz@... (Yukihiro Matsumoto) 1998/10/30

まつもと ゆきひろです

[#10521] Re: case with Class — aamine@... 1998/10/30

こんにちは。あおきです。

[#10523] Re: case with Class — gotoken@... (GOTO Kentaro) 1998/10/30

ごとけんです

[#10530] Re: case with Class — aamine@... 1998/10/31

あおきです。

[#10544] Re: case with Class — shugo@... (MAEDA Shugo) 1998/10/31

前田です。

[#10548] Re: case with Class — Wakou Aoyama <wakou@...> 1998/10/31

青山です。

[#10555] Re: case with Class — shugo@... (MAEDA Shugo) 1998/11/01

前田です。

[#10566] Re: case with Class — Wakou Aoyama <wakou@...> 1998/11/01

青山です。

[ruby-list:10071] Re: Ruby/Gtk text widget

From: Daisuke Kanda <MAP2303@...>
Date: 1998-10-13 21:18:05 UTC
List: ruby-list #10071
  かんだです。

[ruby-list:10037] Re: Ruby/Gtk text widget

TAKAHASHI> 高橋です。

TAKAHASHI> >   昔 Color.new を作ったような気がしたんですけれど、見当たらないです
TAKAHASHI> > ねぇ…。不都合なことでもあったかしら。
TAKAHASHI> >   ではっと、style からもらってこようとしたら、SEGV で落ちた(^^; ちょっ
TAKAHASHI> > と見てみます。
TAKAHASHI> 
TAKAHASHI> よろしくお願いします。

  Gtk::Editable に insert_text は定義されていました。でもちょっとバグあり
だったので修正。Gtk::Text#indert_text は Editable のを使うのと同じみたいな
ので作りませんでした。

  Gtk::Text と Gtk::DrawingArea のサンプルもつけときます。


Attachments (3)

gtktext.rb (602 Bytes, text/x-ruby)
require 'gtk'

window = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL)
window.signal_connect("delete_event") { exit }
window.signal_connect("destroy_event") { exit }
window.realize

box = Gtk::VBox.new(FALSE, 0)
window.add(box)
box.show

$str = "Hello, world."
$text = Gtk::Text.new(Gtk::Adjustment.new(0,0,0,0,0,0),
		      Gtk::Adjustment.new(0,0,0,0,0,0))
box.pack_start($text)
$text.show

button = Gtk::Button.new("append")
box.pack_start(button)
button.show

button.signal_connect("clicked") { |w,e|
  $text.insert_text($str + "\n", $text.get_point)
}


window.show
Gtk::main()
gtkdrawing.rb (1.87 KB, text/x-ruby)
require 'gtk'

class Canvas < Gtk::DrawingArea
  def initialize
    super
    signal_connect("expose_event") { |w,e| expose_event(w,e) }
    signal_connect("configure_event") { |w, e| configure_event(w,e) }
    @buffer = nil
    @bgc = nil
  end

  def expose_event(w,e)
    if ! @buffer.nil?
      rec = e.area
      w.window.draw_pixmap(@bgc, @buffer, rec.x, rec.y,
			   rec.x, rec.y, rec.width, rec.height)
    end
    false
  end

  def clear(b = @buffer)
    return if b.nil?

    g = b.get_geometry
    @bgc = self.style.bg_gc(self.state) if @bgc.nil?
    if (g[2] > 0 && g[3] > 0)
      b.draw_rectangle(@bgc, true, 0,0, g[2], g[3])
    end
  end

  def configure_event(w,e)
    g = w.window.get_geometry
    if (g[2] > 0 && g[3] > 0)
      b = Gdk::Pixmap::new(w.window, g[2], g[3], -1)
      clear(b)
      if not @buffer.nil?
	g = @buffer.get_geometry
	b.draw_pixmap(@bgc, @buffer, 0,0,
		      g[0], g[1], g[2], g[3])
      end
      @buffer = b
    end
    true
  end
end

class A < Canvas
  def initialize
    super
    signal_connect("button_press_event") { |w,e| pressed(w,e) }
    set_events(Gdk::BUTTON_PRESS_MASK)
  end
  def pressed(widget, ev)
    if not @last.nil?
      @buffer.draw_line(widget.style.fg_gc(widget.state),
			@last.x, @last.y, ev.x, ev.y)

      x1,x2 = if (@last.x < ev.x)
	      then [@last.x, ev.x]
	      else [ev.x,    @last.x]
	      end
      y1,y2 = if (@last.y < ev.y)
	    then [@last.y, ev.y]
	    else [ev.y,    @last.y]
	    end
      widget.draw(Gdk::Rectangle.new(x1,y1,x2-x1+1,y2-y1+1))
    end
    @last = nil
    @last = ev
    true
  end
end

window = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL)
window.signal_connect("delete_event") { exit }
window.signal_connect("destroy_event") { exit }
window.realize

canvas = A.new
window.add(canvas)
canvas.show

window.show
Gtk::main()
ruby-gtk.0.13.p1 (5.05 KB, text/x-diff)
diff -cr ruby-gtk-0.13/gtk.c ruby-gtk-0.13-p1/gtk.c
*** ruby-gtk-0.13/gtk.c	Mon Sep 28 05:51:10 1998
--- ruby-gtk-0.13-p1/gtk.c	Wed Oct 14 04:45:17 1998
***************
*** 5020,5036 ****
  }
  
  static VALUE
! edit_insert_text(self, new_text)
!     VALUE self;
  {
!     gint pos;
  
      Check_Type(new_text, T_STRING);
      gtk_editable_insert_text(GTK_EDITABLE(get_widget(self)),
  			     RSTRING(new_text)->ptr,
  			     RSTRING(new_text)->len,
! 			     &pos);
!     return INT2NUM(pos);
  }
  
  static VALUE
--- 5020,5036 ----
  }
  
  static VALUE
! edit_insert_text(self, new_text, pos)
!     VALUE self, new_text, pos;
  {
!     gint p = NUM2INT(pos);
  
      Check_Type(new_text, T_STRING);
      gtk_editable_insert_text(GTK_EDITABLE(get_widget(self)),
  			     RSTRING(new_text)->ptr,
  			     RSTRING(new_text)->len,
! 			     &p);
!     return INT2NUM(p);
  }
  
  static VALUE
***************
*** 5902,5908 ****
      int i = NUM2INT(idx);
  
      if (i < 0 || 5 < i) ArgError("state out of range");
!     return make_gdkcolor(get_gstyle(self)->fg[i]);
  }
  
  static VALUE
--- 5902,5908 ----
      int i = NUM2INT(idx);
  
      if (i < 0 || 5 < i) ArgError("state out of range");
!     return make_gdkcolor(&get_gstyle(self)->fg[i]);
  }
  
  static VALUE
***************
*** 5912,5918 ****
      int i = NUM2INT(idx);
  
      if (i < 0 || 5 < i) ArgError("state out of range");
!     return make_gdkcolor(get_gstyle(self)->bg[i]);
  }
  
  static VALUE
--- 5912,5918 ----
      int i = NUM2INT(idx);
  
      if (i < 0 || 5 < i) ArgError("state out of range");
!     return make_gdkcolor(&get_gstyle(self)->bg[i]);
  }
  
  static VALUE
***************
*** 5922,5928 ****
      int i = NUM2INT(idx);
  
      if (i < 0 || 5 < i) ArgError("state out of range");
!     return make_gdkcolor(get_gstyle(self)->light[i]);
  }
  
  static VALUE
--- 5922,5928 ----
      int i = NUM2INT(idx);
  
      if (i < 0 || 5 < i) ArgError("state out of range");
!     return make_gdkcolor(&get_gstyle(self)->light[i]);
  }
  
  static VALUE
***************
*** 5932,5938 ****
      int i = NUM2INT(idx);
  
      if (i < 0 || 5 < i) ArgError("state out of range");
!     return make_gdkcolor(get_gstyle(self)->dark[i]);
  }
  
  static VALUE
--- 5932,5938 ----
      int i = NUM2INT(idx);
  
      if (i < 0 || 5 < i) ArgError("state out of range");
!     return make_gdkcolor(&get_gstyle(self)->dark[i]);
  }
  
  static VALUE
***************
*** 5942,5948 ****
      int i = NUM2INT(idx);
  
      if (i < 0 || 5 < i) ArgError("state out of range");
!     return make_gdkcolor(get_gstyle(self)->mid[i]);
  }
  
  static VALUE
--- 5942,5948 ----
      int i = NUM2INT(idx);
  
      if (i < 0 || 5 < i) ArgError("state out of range");
!     return make_gdkcolor(&get_gstyle(self)->mid[i]);
  }
  
  static VALUE
***************
*** 5952,5958 ****
      int i = NUM2INT(idx);
  
      if (i < 0 || 5 < i) ArgError("state out of range");
!     return make_gdkcolor(get_gstyle(self)->text[i]);
  }
  
  static VALUE
--- 5952,5958 ----
      int i = NUM2INT(idx);
  
      if (i < 0 || 5 < i) ArgError("state out of range");
!     return make_gdkcolor(&get_gstyle(self)->text[i]);
  }
  
  static VALUE
***************
*** 5962,5968 ****
      int i = NUM2INT(idx);
  
      if (i < 0 || 5 < i) ArgError("state out of range");
!     return make_gdkcolor(get_gstyle(self)->base[i]);
  }
  
  #define DEFINE_STYLE_SET_COLOR(func, type) \
--- 5962,5968 ----
      int i = NUM2INT(idx);
  
      if (i < 0 || 5 < i) ArgError("state out of range");
!     return make_gdkcolor(&get_gstyle(self)->base[i]);
  }
  
  #define DEFINE_STYLE_SET_COLOR(func, type) \
***************
*** 5995,6007 ****
  static VALUE
  style_black(self)
  {
!     return make_gdkcolor(get_gstyle(self)->black);
  }
  
  static VALUE
  style_white(self)
  {
!     return make_gdkcolor(get_gstyle(self)->white);
  }
  
  static VALUE
--- 5995,6007 ----
  static VALUE
  style_black(self)
  {
!     return make_gdkcolor(&get_gstyle(self)->black);
  }
  
  static VALUE
  style_white(self)
  {
!     return make_gdkcolor(&get_gstyle(self)->white);
  }
  
  static VALUE
***************
*** 7213,7219 ****
  
      /* Editable */
      rb_define_method(gEditable, "select_region", edit_sel_region, 2);
!     rb_define_method(gEditable, "insert_text", edit_insert_text, 3);
      rb_define_method(gEditable, "delete_text", edit_delete_text, 2);
      rb_define_method(gEditable, "get_chars", edit_get_chars, 2);
      rb_define_method(gEditable, "cut_clipboard", edit_cut_clipboard, 1);
--- 7213,7219 ----
  
      /* Editable */
      rb_define_method(gEditable, "select_region", edit_sel_region, 2);
!     rb_define_method(gEditable, "insert_text", edit_insert_text, 2);
      rb_define_method(gEditable, "delete_text", edit_delete_text, 2);
      rb_define_method(gEditable, "get_chars", edit_get_chars, 2);
      rb_define_method(gEditable, "cut_clipboard", edit_cut_clipboard, 1);

In This Thread