~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to ext/tk/sample/demos-jp/paned2.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# paned2.rb --
 
2
#
 
3
# This demonstration script creates a toplevel window containing
 
4
# a paned window that separates two windows vertically.
 
5
#
 
6
# based on "Id: paned2.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp"
 
7
 
 
8
if defined?($paned2_demo) && $paned2_demo
 
9
  $paned2_demo.destroy 
 
10
  $paned2_demo = nil
 
11
end
 
12
 
 
13
$paned2_demo = TkToplevel.new {|w|
 
14
  title("Vertical Paned Window Demonstration")
 
15
  iconname("paned2")
 
16
  positionWindow(w)
 
17
}
 
18
 
 
19
TkLabel.new($paned2_demo, 
 
20
            :font=>$font, :wraplength=>'4i', :justify=>:left, 
 
21
            :text=><<EOL).pack(:side=>:top)
 
22
���Υ���������С��դ��Υ��������åȤ��֤��줿��ĤΥ�����ɥ��δ֤λ��ڤ��Ȥϡ���Ĥ��ΰ�򤽤줾��Υ�����ɥ��Τ����ʬ�䤹�뤿��Τ�ΤǤ������ܥ���ǻ��ڤ������ȡ�ʬ�䥵�����ѹ����������ǤϺ�ɽ���Ϥʤ��줺�����ꤵ�����Ȥ���ɽ������������ޤ����ޥ����ˤ����ڤ�������ɿ路�ƥ��������ѹ�����ɽ�����ʤ���褦�ˤ��������ϡ��ޥ���������ܥ����ȤäƤ���������
 
23
�⤷���ʤ����ȤäƤ��� Ruby �˥�󥯤���Ƥ��� Tk �饤�֥�꤬ panedwindow ��������Ƥ��ʤ�
 
24
��硢���Υǥ�Ϥ��ޤ�ư���ʤ��Ϥ��Ǥ������ξ��ˤ� panedwindow ����������Ƥ���褦��
 
25
��꿷�����С������� Tk ���Ȥ߹�碌�ƻ
 
26
�褦�ˤ��Ƥ���������
 
27
EOL
 
28
 
 
29
# The bottom buttons
 
30
TkFrame.new($paned2_demo){|f|
 
31
  pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
 
32
 
 
33
  TkButton.new(f, :text=>'�Ĥ���', :width=>15, :command=>proc{
 
34
                 $paned2_demo.destroy
 
35
                 $paned2_demo = nil
 
36
               }).pack(:side=>:left, :expand=>true)
 
37
 
 
38
  TkButton.new(f, :text=>'�����ɻ���', :width=>15, :command=>proc{
 
39
                 showCode 'paned2'
 
40
               }).pack(:side=>:left, :expand=>true)
 
41
}
 
42
 
 
43
paneList = TkVariable.new  # define as normal variable (not array)
 
44
paneList.value = [         # ruby's array --> tcl's list
 
45
    'Ruby/Tk �Υ��������åȰ���',
 
46
    'TkButton', 
 
47
    'TkCanvas', 
 
48
    'TkCheckbutton', 
 
49
    'TkEntry', 
 
50
    'TkFrame', 
 
51
    'TkLabel', 
 
52
    'TkLabelframe', 
 
53
    'TkListbox', 
 
54
    'TkMenu', 
 
55
    'TkMenubutton', 
 
56
    'TkMessage', 
 
57
    'TkPanedwindow', 
 
58
    'TkRadiobutton', 
 
59
    'TkScale', 
 
60
    'TkScrollbar', 
 
61
    'TkSpinbox', 
 
62
    'TkText', 
 
63
    'TkToplevel'
 
64
]
 
65
 
 
66
# Create the pane itself
 
67
TkPanedwindow.new($paned2_demo, :orient=>:vertical){|f|
 
68
  pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
 
69
 
 
70
  add(TkFrame.new(f){|paned2_top|
 
71
        TkListbox.new(paned2_top, :listvariable=>paneList) {
 
72
          # Invert the first item to highlight it
 
73
          itemconfigure(0, :background=>self.cget(:foreground), 
 
74
                           :foreground=>self.cget(:background) )
 
75
          yscrollbar(TkScrollbar.new(paned2_top).pack(:side=>:right, 
 
76
                                                      :fill=>:y))
 
77
          pack(:fill=>:both, :expand=>true)
 
78
        }
 
79
      }, 
 
80
 
 
81
      TkFrame.new(f, :height=>120) {|paned2_bottom|
 
82
        # The bottom window is a text widget with scrollbar
 
83
        paned2_xscr = TkScrollbar.new(paned2_bottom)
 
84
        paned2_yscr = TkScrollbar.new(paned2_bottom)
 
85
        paned2_text = TkText.new(paned2_bottom, :width=>30, :wrap=>:non) {
 
86
          insert('1.0', '���������֤���Ƥ���Τϡ�' + 
 
87
                        '�������̤Υƥ����ȥ��������åȤǤ���')
 
88
          xscrollbar(paned2_xscr)
 
89
          yscrollbar(paned2_yscr)
 
90
        }
 
91
        Tk.grid(paned2_text, paned2_yscr, :sticky=>'nsew')
 
92
        Tk.grid(paned2_xscr, :sticky=>'nsew')
 
93
        TkGrid.columnconfigure(paned2_bottom, 0, :weight=>1)
 
94
        TkGrid.rowconfigure(paned2_bottom, 0, :weight=>1)
 
95
      } )
 
96
}