Top Level Namespace

Includes:
ParseDate

Defined Under Namespace

Modules: DemoBasic, DemoDialog, DemoDnD, DemoManager, DemoSelect, DemoTree, DemoVar, MultiTkIp_PseudoToplevel_Evaluable, TclTkLib, Tk, TkBgError, TkBindCore, TkCanvasItemConfig, TkClipboard, TkComm, TkComposite, TkConfigMethod, TkConsole, TkCore, TkEvent, TkGrid, TkItemConfigMethod, TkItemConfigOptkeys, TkItemFontOptkeys, TkKinput, TkListItemConfig, TkMacResource, TkManageFocus, TkMenuEntryConfig, TkMenuSpec, TkOptionDB, TkPack, TkPackage, TkPalette, TkPlace, TkSelection, TkSystemMenu, TkTextTagConfig, TkTreatFont, TkTreatItemFont, TkTreatTagFont, TkUtil, TkValidation, TkWinDDE, TkWinRegistry, TkWinfo, TkXIM, TkcTagAccess Classes: AnimatedImageLabel, AnimatedTextLabel, AnimatedWaveDemo, BLT_Calendar_sample, BLT_Graph_Demo, BWidget_Demo, BtnFrame, Button_clone, Button_with_Frame, Clock, Editable_TkListbox, Hash, Mail, MultiTkIp, MultiTkIp_OK, Object, PendulumAnimationDemo, RemoteTkIp, Spinner_demo, TclTkIp, TkAlignBox, TkAutoScrollbox, TkBalloonHelp, TkBindTag, TkBindTagAll, TkBitmapImage, TkButton, TkCallbackBreak, TkCallbackContinue, TkCallbackEntry, TkCallbackRedo, TkCallbackRetry, TkCallbackReturn, TkCallbackThrow, TkCanvas, TkCheckButton, TkCombobox, TkDatabaseClass, TkDialog, TkDialogObj, TkDialog_Demo1, TkDialog_Demo2, TkEntry, TkFont, TkFrame, TkGoldberg_Demo, TkHBox, TkHRBox, TkHTML_File_Viewer, TkImage, TkImg_demo, TkKernel, TkLabel, TkLabelFrame, TkListbox, TkLocalJumpError, TkMenu, TkMenuClone, TkMenubar, TkMenubutton, TkMessage, TkMsgCatalog, TkMultiColumnList, TkMultiListFrame, TkMultiListbox, TkNamespace, TkObject, TkOptionMenubutton, TkPanedWindow, TkPhotoImage, TkPixmapImage, TkRTTimer, TkRadioButton, TkRoot, TkScale, TkScrollbar, TkScrollbox, TkSpinbox, TkSysMenu_Apple, TkSysMenu_Help, TkSysMenu_System, TkText, TkTextFrame, TkTextIO, TkTextImage, TkTextMark, TkTextMarkAnchor, TkTextMarkCurrent, TkTextMarkInsert, TkTextNamedMark, TkTextNamedTag, TkTextTag, TkTextTagSel, TkTextWin, TkTextWindow, TkTimer, TkToplevel, TkTree, TkTreeCtrl_demo, TkVBBox, TkVBox, TkValidateCommand, TkVarAccess, TkVariable, TkVirtualEvent, TkWarning, TkWarningObj, TkWindow, TkXScrollbar, TkYScrollbar, TkcArc, TkcBitmap, TkcGroup, TkcImage, TkcItem, TkcLine, TkcOval, TkcPolygon, TkcRectangle, TkcTag, TkcTagAll, TkcTagCurrent, TkcTagString, TkcText, TkcWindow, Unicodeout_SampleFrame, ViewIcons

Constant Summary collapse

TkCloneMenu =
TkMenuClone
TkMenuButton =
TkMenubutton
TkOptionMenuButton =
TkOptionMenubutton
TopLevel =
TkToplevel
Frame =
TkFrame
Label =
TkLabel
Button =
TkButton
Radiobutton =
TkRadioButton
Checkbutton =
TkCheckButton
Message =
TkMessage
Entry =
TkEntry
Spinbox =
TkSpinbox
Text =
TkText
Scale =
TkScale
Scrollbar =
TkScrollbar
Listbox =
TkListbox
TkMenu
TkMenubutton
Canvas =
TkCanvas
Arc =
TkcArc
Bitmap =
TkcBitmap
Line =
TkcLine
Oval =
TkcOval
Polygon =
TkcPolygon
Rectangle =
TkcRectangle
TextItem =
TkcText
WindowItem =
TkcWindow
BitmapImage =
TkBitmapImage
PhotoImage =
TkPhotoImage
Selection =
TkSelection
Winfo =
TkWinfo
Pack =
TkPack
Grid =
TkGrid
Place =
TkPlace
Variable =
TkVariable
Font =
TkFont
VirtualEvent =
TkVirtualEvent
TkAfter =
TkTimer
TkDialog2 =
TkDialogObj
TkWarning2 =
TkWarningObj
TkMsgCat =
TkMsgCatalog
TkOption =
TkOptionDB
TkResourceDB =
TkOptionDB
TkcNamedTag =
TkcTagString
TkNamedVirtualEvent =
TkVirtualEvent::PreDefVirtEvent
TkLabelframe =
TkLabelFrame
TkHLBox =
TkHBox
TkVTBox =
TkVBox
TkCheckbutton =
TkCheckButton
TkPanedwindow =
TkPanedWindow
TkRadiobutton =
TkRadioButton
ImgFile =
['images','tcllogo.gif'].join(File::Separator)

Instance Method Summary collapse

Instance Method Details

#anyUnreadDescendants(t, i) ⇒ Object



434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
# File 'sample/tkextlib/treectrl/outlook-newgroup.rb', line 434

def anyUnreadDescendants(t, i)
  itemList = []
  item = t.item_firstchild(i)
  itemList.push(item) if item != ''

  while item = itemList.pop
    return true unless @Message[:read][item]

    item2 = t.item_nextsibling(item)
    itemList.push(item2) if item2 != ''
    item2 = t.item_firstchild(item)
    itemList.push(item2) if item2 != ''
  end
  false
end

#arrowMove1(c, x, y) ⇒ Object

arrowMove1 – This method is called for each mouse motion event on box1 (the one at the vertex of the arrow). It updates the controlling parameters for the line and arrowhead.

Arguments: c - The name of the canvas window. x, y - The coordinates of the mouse.



185
186
187
188
189
190
191
192
193
194
# File 'sample/demos-en/arrow.rb', line 185

def arrowMove1(c,x,y)
  v = $demo_arrowInfo
  newA = (v.x2+5-c.canvasx(x).round)/10
  newA = 0 if newA < 0
  newA = 25 if newA > 25
  if newA != v.a
    c.move('box1', 10*(v.a-newA), 0)
    v.a = newA
  end
end

#arrowMove2(c, x, y) ⇒ Object

arrowMove2 – This method is called for each mouse motion event on box2 (the one at the trailing tip of the arrowhead). It updates the controlling parameters for the line and arrowhead.

Arguments: c - The name of the canvas window. x, y - The coordinates of the mouse.



205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'sample/demos-en/arrow.rb', line 205

def arrowMove2(c,x,y)
  v = $demo_arrowInfo
  newB = (v.x2+5-c.canvasx(x).round)/10
  newB = 0 if newB < 0
  newB = 25 if newB > 25
  newC = (v.y+5-c.canvasy(y).round-5*v.width)/10
  newC = 0 if newC < 0
  newC = 20 if newC > 20
  if newB != v.b || newC != v.c
    c.move('box2', 10*(v.b-newB), 10*(v.c-newC))
    v.b = newB
    v.c = newC
  end
end

#arrowMove3(c, x, y) ⇒ Object

arrowMove3 – This method is called for each mouse motion event on box3 (the one that controls the thickness of the line). It updates the controlling parameters for the line and arrowhead.

Arguments: c - The name of the canvas window. x, y - The coordinates of the mouse.



229
230
231
232
233
234
235
236
237
238
# File 'sample/demos-en/arrow.rb', line 229

def arrowMove3(c,x,y)
  v = $demo_arrowInfo
  newWidth = (v.y+2-c.canvasy(y).round)/5
  newWidth = 0 if newWidth < 0
  newWidth = 20 if newWidth > 20
  if newWidth != v.width
    c.move('box3', 0, 5*(v.width-newWidth))
    v.width = newWidth
  end
end

#arrowSetup(c) ⇒ Object

arrowSetup – This method regenerates all the text and graphics in the canvas window. It’s called when the canvas is initially created, and also whenever any of the parameters of the arrow head are changed interactively.

Arguments: c - Name of the canvas widget.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'sample/demos-en/arrow.rb', line 18

def arrowSetup(c)
  v = $demo_arrowInfo

  # Remember the current box, if there is one.
  tags = c.gettags('current')
  if tags != []
    cur = tags.find{|t| t.kind_of?(String) && t =~ /^box[1-3]$/ }
  else
    cur = nil
  end

  # Create the arrow and outline.
  c.delete('all')
  TkcLine.new(c, v.x1, v.y, v.x2, v.y, 
              { 'width'=>10 * v.width, 
                'arrowshape'=>[10*v.a, 10*v.b, 10*v.c], 
                'arrow'=>'last' 
              }.update(v.bigLineStyle) )
  xtip = v.x2 - 10*v.b
  deltaY = 10*v.c + 5*v.width
  TkcLine.new(c, v.x2, v.y, xtip, v.y + deltaY, 
              v.x2 - 10*v.a, v.y, xtip, v.y - deltaY, v.x2, v.y, 
              'width'=>2, 'capstyle'=>'round', 'joinstyle'=>'round')

  # Create the boxes for reshaping the line and arrowhead.
  TkcRectangle.new(c, v.x2-10*v.a-5, v.y-5, v.x2-10*v.a+5, v.y+5, 
                   {'tags'=>['box1', $arrowTag_box]}.update(v.boxStyle) )
  TkcRectangle.new(c, xtip-5, v.y-deltaY-5, xtip+5, v.y-deltaY+5, 
                   {'tags'=>['box2', $arrowTag_box]}.update(v.boxStyle) )
  TkcRectangle.new(c, v.x1-5, v.y-5*v.width-5, v.x1+5, v.y-5*v.width+5, 
                   {'tags'=>['box3', $arrowTag_box]}.update(v.boxStyle) )
  c.itemconfigure cur, v.activeStyle if cur

  # Create three arrows in actual size with the same parameters
  TkcLine.new(c, v.x2+50, 0, v.x2+50, 1000, 'width'=>2)
  tmp = v.x2+100
  TkcLine.new(c, tmp, v.y-125, tmp, v.y-75, 'width'=>v.width, 
              'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c])
  TkcLine.new(c, tmp-25, v.y, tmp+25, v.y, 'width'=>v.width, 
              'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c])
  TkcLine.new(c, tmp-25, v.y+75, tmp+25, v.y+125, 'width'=>v.width, 
              'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c])

  # Create a bunch of other arrows and text items showing the 
  # current dimensions.
  tmp = v.x2+10
  TkcLine.new(c, tmp, v.y-5*v.width, tmp, v.y-deltaY, 
              'arrow'=>'both', 'arrowshape'=>v.smallTips)
  TkcText.new(c, v.x2+15, v.y-deltaY+5*v.c, 'text'=>v.c, 'anchor'=>'w')
  tmp = v.x1-10
  TkcLine.new(c, tmp, v.y-5*v.width, tmp, v.y+5*v.width, 
              'arrow'=>'both', 'arrowshape'=>v.smallTips)
  TkcText.new(c, v.x1-15, v.y, 'text'=>v.width, 'anchor'=>'e')
  tmp = v.y+5*v.width+10*v.c+10
  TkcLine.new(c, v.x2-10*v.a, tmp, v.x2, tmp, 
              'arrow'=>'both', 'arrowshape'=>v.smallTips)
  TkcText.new(c, v.x2-5*v.a, tmp+5, 'text'=>v.a, 'anchor'=>'n')
  tmp = tmp+25
  TkcLine.new(c, v.x2-10*v.b, tmp, v.x2, tmp, 
              'arrow'=>'both', 'arrowshape'=>v.smallTips)
  TkcText.new(c, v.x2-5*v.b, tmp+5, 'text'=>v.b, 'anchor'=>'n')

  TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w', 
              'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
  TkcText.new(c, v.x1, 330, 
              'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]", 'anchor'=>'w', 
              'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')

  v.count += 1
end

#bitmapRow(w, *args) ⇒ Object

bitmapRow – Create a row of bitmap items in a window.

Arguments: w - The parent window that is to contain the row. args - The names of one or more bitmaps, which will be displayed

in a new row across the bottom of w along with their
names.


17
18
19
20
21
22
23
24
25
26
27
28
# File 'sample/demos-en/bitmap.rb', line 17

def bitmapRow(w,*args)
  TkFrame.new(w){|row|
    pack('side'=>'top', 'fill'=>'both')
    for bitmap in args 
      TkFrame.new(row){|base|
        pack('side'=>'left', 'fill'=>'both', 'pady'=>'.25c', 'padx'=>'.25c')
        TkLabel.new(base, 'text'=>bitmap, 'width'=>9).pack('side'=>'bottom')
        TkLabel.new(base, 'bitmap'=>bitmap).pack('side'=>'bottom')
      }
    end
  }
end

#browse(dir, file) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'sample/tkbrowse.rb', line 52

def browse (dir, file)
  file="#{dir}/#{file}"
  if File.directory? file
    browsedir(file)
  else
    if File.file? file
      if ENV['EDITOR']
        system format("%s %s&", ENV['EDITOR'], file)
      else
        system "xedit #{file}&"
      end
    else
      STDERR.print "\"#{file}\" isn't a directory or regular file"
    end
  end
end

#browsedir(dir) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'sample/tkbrowse.rb', line 19

def browsedir (dir)
  if $dirlist.key? dir
    $dirlist[dir]
  else
    top = if $dirlist.size > 0 then TkToplevel.new else nil end
    list = TkScrollbox.new(top) {
      relief 'raised'
      width 20
      height 20
      setgrid 'yes'
      pack
    }
    list.insert 'end', *`ls #{dir}`.split

    # Set up bindings for the browser.

    list.focus
    list.bind "Control-q", proc{exit}
    list.bind "Control-c", proc{exit}
    list.bind "Control-p", proc{
      print "selection <", TkSelection.get, ">\n"
    }

    list.bind "Double-Button-1", proc{
      for i in TkSelection.get.split
        print "clicked ", i, "\n"
        browse dir, i
      end
    }
    $dirlist[dir] = list
  end
end

#butPress(w, color) ⇒ Object

Method that’s invoked when the button embedded in the canvas is invoked.



370
371
372
373
374
# File 'sample/demos-en/items.rb', line 370

def butPress(w,color)
  i = TkcText.new(w, '25c', '18.1c', 
                  'text'=>'Ouch!!', 'fill'=>color, 'anchor'=>'n')
  Tk.after(500, proc{w.delete i})
end

#changepage(tbl_list, tbl, ent, col, var, elem, op) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'sample/tkextlib/tktable/spreadsheet.rb', line 44

def changepage(tbl_list, tbl, ent, col, var, elem, op)
  if elem != ''
    page = var[elem]
  else
    page = var.value
  end
  if tbl[:variable] != tbl_list[page].id
    tbl.selection_clear_all
    tbl.variable(tbl_list[page])
    ent.textvariable(tbl_list[page].ref('active'))
    tbl.activate('origin')
    tbl.tag_configure('colored', :bg=>col[page])
    tbl.see('active')
  end
end

#changeState(st) ⇒ Object



934
935
936
937
938
939
940
941
942
# File 'sample/tkextlib/tile/demo.rb', line 934

def changeState(st)
  if $Widget.value != ''
    if $State.bool_element(st)
      $Widget.window.state(st)
    else
      $Widget.window.state("!#{st}")
    end
  end
end

#changeToolbarsObject



280
281
282
283
284
285
286
287
288
# File 'sample/tkextlib/tile/demo.rb', line 280

def changeToolbars
  foreachWidget($TOOLBARS, 
                proc{|w|
                  begin
                    w.compound($V[:COMPOUND])
                  rescue
                  end
                })
end

#checkObject



100
101
102
103
104
105
106
107
108
# File 'sample/tkbiff.rb', line 100

def check
  $check_time = Time.now
  size = File.size($spool)
  if size and size != $spool_size
    $spool_size = size
    pop_up if size > 0
  end
  Tk.after 5000, proc{check}
end

#check_pkg(file, verbose = false) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/tkextlib/pkg_checker.rb', line 91

def check_pkg(file, verbose=false)
  pkg_list = get_pkg_list(file)

  error_list = []
  success_list = {}

  pkg_list.each{|name, type|
    next if success_list[name]

    begin
      case type
      when :package
        ver = TkPackage.require(name)
        success_list[name] = ver
        error_list.delete_if{|n, t| n == name}

      when :library
        Tk.load_tcllibrary(name)
        success_list[name] = :library
        error_list.delete_if{|n, t| n == name}

      when :script
        Tk.load_tclscript(name)
        success_list[name] = :script
        error_list.delete_if{|n, t| n == name}

      when :require_ruby_lib
        require name

      end
    rescue => e
      if verbose
        error_list << [name, type, e.message]
      else
        error_list << [name, type]
      end
    end
  }

  success_list.dup.each{|name, ver|
    unless ver.kind_of?(String)
      begin
        ver = TkPackage.require(name)
        sccess_list[name] = ver
      rescue
      end
    end
  }

  [success_list, error_list]
end

#colorize(num) ⇒ Object



16
17
18
19
# File 'sample/tkextlib/tktable/valid.rb', line 16

def colorize(num)
  num = Integer(num)
  return 'colored' if (num > 0 && num % 2 == 1)
end

#compareOnOff(w, c, item1, item2) ⇒ Object

TreeCtrl 1.0



258
259
260
261
262
263
264
265
266
267
268
# File 'sample/tkextlib/treectrl/mailwasher.rb', line 258

def compareOnOff(w, c, item1, item2)
  s1 = w.item_state_forcolumn(item1, c)
  s2 = w.item_state_forcolumn(item2, c)
  if (s1 == s2)
    0
  elsif (s1 == 'CHECK')
    -1
  else
    1
  end
end

#cursor_window(top = nil) ⇒ Object



1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
# File 'sample/tkextlib/treectrl/demo.rb', line 1151

def cursor_window(top = nil)
  top.destroy if top.kind_of?(TkWindow) && top.winfo_exist?
  top = TkToplevel.new(:title=>'Cursor Window')

  c = TkCanvas.new(top, :background=>'white', 
                   :width=>50*10, :highlightthickness=>0, 
                   :borderwidth=>0).pack(:expand=>true, :fill=>:both)
  cursors = %w(
	X_cursor
	arrow
	based_arrow_down
	based_arrow_up
	boat
	bogosity
	bottom_left_corner
	bottom_right_corner
	bottom_side
	bottom_tee
	box_spiral
	center_ptr
	circle
	clock
	coffee_mug
	cross
	cross_reverse
	crosshair
	diamond_cross
	dot
	dotbox
	double_arrow
	draft_large
	draft_small
	draped_box
	exchange
	fleur
	gobbler
	gumby
	hand1
	hand2
	heart
	icon
	iron_cross
	left_ptr
	left_side
	left_tee
	leftbutton
	ll_angle
	lr_angle
	man
	middlebutton
	mouse
	pencil
	pirate
	plus
	question_arrow
	right_ptr
	right_side
	right_tee
	rightbutton
	rtl_logo
	sailboat
	sb_down_arrow
	sb_h_double_arrow
	sb_left_arrow
	sb_right_arrow
	sb_up_arrow
	sb_v_double_arrow
	shuttle
	sizing
	spider
	spraycan
	star
	target
	tcross
	top_left_arrow
	top_left_corner
	top_right_corner
	top_side
	top_tee
	trek
	ul_angle
	umbrella
	ur_angle
	watch
	xterm
    )

  orig_cursor = c.cursor
  col = 0
  row = 0

  cursors.each{|cur|
    x = col * 50
    y = row * 40

    begin
      c.cursor = cur

      r = TkcRectangle.new(c, x, y, x+50, y+40, 
                           :fill=>'gray90', :outline=>'black', :width=>2)
      t = TkcText.new(c, x+50/2, y+4, :text=>cur, :anchor=>:n, :width=>42)

      col += 1
      if col >= 10
        col = 0
        row += 1
      end

      r.bind('Enter', proc{c.cursor = cur; r.fill = 'linen'})
      r.bind('Leave', proc{c.cursor = ''; r.fill = 'gray90'})

      t.bind('Enter', proc{c.cursor = cur})
      t.bind('Leave', proc{c.cursor = ''})
    rescue
      c.cursor = orig_cursor
    end
  }

  c.cursor = orig_cursor
  c.height = (row + 1) * 40
end

#def_puzzleswitch_proc(w, num) ⇒ Object



74
75
76
# File 'sample/demos-en/puzzle.rb', line 74

def def_puzzleswitch_proc(w, num)
  proc{puzzleSwitch w, num}
end

#demoBitmaps(t) ⇒ Object

Demo: Bitmaps



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'sample/tkextlib/treectrl/bitmaps.rb', line 4

def demoBitmaps(t)
  #if $Version_1_1_OrLater
  if @has_bgimg
    t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, 
                :selectmode=>:browse, :orient=>:horizontal, :wrap=>'5 items', 
                :showheader=>false, :backgroundimage=>@images['sky'])
  else
    t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, 
                :selectmode=>:browse, :orient=>:horizontal, :wrap=>'5 items', 
                :showheader=>false)
  end

  if $HasColumnCreate
    t.column_create(:itembackground=>['gray90', []])
  else
    t.column_configure(0, :itembackground=>['gray90', []])
  end

  t.element_create('elemTxt', :text, 
                   :fill=>[@SystemHighlightText, ['selected', 'focus']])
  t.element_create('elemSelTxt', :rect, :showfocus=>true, 
                   :fill=>[@SystemHighlight, ['selected', 'focus']])
  t.element_create('elemSelBmp', :rect, :outlinewidth=>4, 
                   :outline=>[@SystemHighlight, ['selected', 'focus']])
  t.element_create('elemBmp', :bitmap, 
                   :foreground=>[@SystemHighlight, ['selected', 'focus']], 
                   :background=>'linen', 
                   :bitmap=>['question' ['selected']])

  s = t.style_create('STYLE', :orient=>:vertical)
  t.style_elements(s, ['elemSelBmp', 'elemBmp', 'elemSelTxt', 'elemTxt'])
  t.style_layout(s, 'elemSelBmp', :union=>'elemBmp', :ipadx=>6, :ipady=>6)
  t.style_layout(s, 'elemBmp',    :pady=>[0, 6], :expand=>:we)
  t.style_layout(s, 'elemSelTxt', :union=>'elemTxt', :ipadx=>2)
  t.style_layout(s, 'elemTxt',    :expand=>:we)

  # Set default item style
  if $Version_1_1_OrLater
    t.defaultstyle = [s]
  end

  bitmap_names = %w(error gray75 gray50 gray25 gray12 
                    hourglass info questhead question warning)

  bitmap_names.each{|name|
    i = t.item_create
    unless $Version_1_1_OrLater
      t.item_style_set(i, 0, s)
    end
    t.item_text(i, 0, name)
    t.item_element_configure(i, 0, 'elemBmp', :bitmap=>name)
    t.item_lastchild(:root, i)
  }

  bitmap_names.each{|name|
    i = t.item_create
    t.item_style_set(i, 0, s)
    t.item_text(i, 0, name)
    if true
      t.item_element_configure(i, 0, 'elemBmp', :bitmap=>name, 
                               :foreground=>['brown', ''], 
                               :background=>['', ''])
    else
      t.item_element_configure(i, 0, 'elemBmp', :bitmap=>name, 
                               :foreground=>[
                                 @SystemHighlight, ['selected', 'focus'], 
                                 'brown', []
                               ], 
                               :background=>['', []])
    end
    t.item_lastchild(:root, i)
  }
end

#demoExplorerAux(t, dir_proc, file_proc) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'sample/tkextlib/treectrl/explorer.rb', line 2

def demoExplorerAux(t, dir_proc, file_proc)
  base_dir = File.dirname(File.dirname(@ScriptDir))

  clicks = Tk::Clock.clicks
  globDirs = Dir.glob(File.join(base_dir, '*')).find_all{|file|
    FileTest.directory?(file)
  }
  clickGlobDirs = Tk::Clock.clicks - clicks

  clicks = Tk::Clock.clicks
  list = globDirs.sort
  clickSortDirs = Tk::Clock.clicks - clicks

  clicks = Tk::Clock.clicks
  list.each{|file| dir_proc.call(file)}
  clickAddDirs = Tk::Clock.clicks - clicks

  clicks = Tk::Clock.clicks
  globFiles = Dir.glob(File.join(base_dir, '*')).find_all{|file|
    FileTest.file?(file)
  }
  clickGlobFiles = Tk::Clock.clicks - clicks

  clicks = Tk::Clock.clicks
  list = globFiles.sort
  clickSortFiles = Tk::Clock.clicks - clicks

  clicks = Tk::Clock.clicks
  list.each{|file| file_proc.call(file)}
  clickAddFiles = Tk::Clock.clicks - clicks

  gd = '%.2g' % (clickGlobDirs / 1000000.0)
  sd = '%.2g' % (clickSortDirs / 1000000.0)
  ad = '%.2g' % (clickAddDirs  / 1000000.0)
  gf = '%.2g' % (clickGlobFiles / 1000000.0)
  sf = '%.2g' % (clickSortFiles / 1000000.0)
  af = '%.2g' % (clickAddFiles  / 1000000.0)

  puts "dirs(#{globDirs.length}) glob/sort/add #{gd}/#{sd}/#{ad}    files(#{globFiles.length}) glob/sort/add #{gf}/#{sf}/#{af}"

  @Priv[:DirCnt, t] = globDirs.length
end

#demoExplorerDetails(t) ⇒ Object

Demo: explorer files



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'sample/tkextlib/treectrl/explorer.rb', line 48

def demoExplorerDetails(t)
  height = t.font.metrics(:linespace)
  height = 18 if height < 18

  t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, 
              :itemheight=>height, :selectmode=>:extended, 
              :xscrollincrement=>20, :scrollmargin=>16, 
              :xscrolldelay=>[500, 50], :yscrolldelay=>[500, 50])

  init_pics('small-*')

  if $HasColumnCreate
    t.column_create(:text=>'Name', :tag=>'name', 
                    :width=>200, :arrow=>:up, :arrowpad=>6)
    t.column_create(:text=>'Size', :tag=>'size', :justify=>:right, 
                    :width=>60, :arrowside=>:left, :arrowgravity=>:right)
    t.column_create(:text=>'Type', :tag=>'type', :width=>120)
    t.column_create(:text=>'Modified', :tag=>'modified', :width=>130)
  else
    t.column_configure(0, :text=>'Name', :tag=>'name', 
                       :width=>200, :arrow=>:up, :arrowpad=>6)
    t.column_configure(1, :text=>'Size', :tag=>'size', :justify=>:right, 
                       :width=>60, :arrowside=>:left, :arrowgravity=>:right)
    t.column_configure(2, :text=>'Type', :tag=>'type', :width=>120)
    t.column_configure(3, :text=>'Modified', :tag=>'modified', :width=>130)
  end

  t.element_create('e1', :image, 
                   :image=>[
                     @sel_images['small-folder'], ['selected'], 
                     @images['small-folder'], []
                   ])
  t.element_create('e2', :text, :lines=>1, 
                   :fill=>[@SystemHighlightText, ['selected', 'focus']])
  t.element_create('txtType', :text, :lines=>1)
  t.element_create('txtSize', :text, :lines=>1, 
                   :datatype=>:integer, :format=>'%dKB')
  t.element_create('txtDate', :text, :lines=>1, 
                   :datatype=>:time, :format=>'%d/%m/%y %I:%M %p')
  t.element_create('e4', :rect, :showfocus=>true,
                   :fill=>[
                     @SystemHighlight, ['selected', 'focus'], 
                     'gray', ['selected', '!focus']
                   ])

  # image + text
  s = t.style_create('styName', :orient=>:horizontal)
  t.style_elements(s, ['e4', 'e1', 'e2'])
  t.style_layout(s, 'e1', :expand=>:ns)
  t.style_layout(s, 'e2', :padx=>[2,0], :squeeze=>:x, :expand=>:ns)
  t.style_layout(s, 'e4', :union=>['e2'], :iexpand=>:ns, :ipadx=>2)

  # column 1: text
  s = t.style_create('stySize')
  t.style_elements(s, ['txtSize'])
  t.style_layout(s, 'txtSize', :padx=>6, :squeeze=>:x, :expand=>:ns)

  # column 2: text
  s = t.style_create('styType')
  t.style_elements(s, ['txtType'])
  t.style_layout(s, 'txtType', :padx=>6, :squeeze=>:x, :expand=>:ns)

  # column 3: text
  s = t.style_create('styDate')
  t.style_elements(s, ['txtDate'])
  t.style_layout(s, 'txtDate', :padx=>6, :squeeze=>:x, :expand=>:ns)

  @Priv[:edit, t] = ['e2']
  @Priv[:sensitive, t] = [ ['name', 'styName', 'e1', 'e2'] ]
  @Priv[:dragimage, t] = [ ['name', 'styName', 'e1', 'e2'] ]

  t.notify_bind(t, 'Edit-accept', 
                proc{|w, i, tt| w.item_text(i, 0, tt)}, '%T %I %t')

  dir_proc = proc{|file|
    item = t.item_create
    t.item_style_set(item, 0, 'styName', 2, 'styType', 3, 'styDate')
    t.item_complex(item, 
                   [['e2', {:text=>File.basename(file)}]], 
                   [], 
                   [['txtType', {:text=>'Folder'}]], 
                   [['txtDate', {:data=>File.mtime(file).tv_sec}]])
    t.item_lastchild(:root, item)
  }

  file_proc = proc{|file|
    item = t.item_create
    t.item_style_set(item, 0, 'styName', 1, 'stySize', 
                           2, 'styType', 3, 'styDate')

    ext = File.extname(file)
    case ext
    when '.dll'
      img = 'small-dll'
    when '.exe'
      img = 'small-exe'
    when '.txt'
      img = 'small-txt'
    else
      img = 'small-file'
    end

    type = ext.upcase
    type = type[1..-1] << ' ' unless type.empty?
    type << 'File'

    t.item_complex(item, 
                   [ 
                     ['e1', {:image=>[@sel_images[img], ['selected'], 
                                      @images[img], []]}],
                     ['e2', {:text=>File.basename(file)}]
                   ], 
                   [ ['txtSize', {:data=>File.size(file)/1024 + 1}] ], 
                   [ ['txtType', {:text=>type}] ], 
                   [ ['txtDate', {:data=>File.mtime(file).tv_sec}] ]
                   )
    t.item_lastchild(:root, item)
  }

  demoExplorerAux(t, dir_proc, file_proc)

  @SortColumn = 0
  t.notify_bind(t, 'Header-invoke', 
                proc{|w, c| explorerHeaderInvoke(t, w, c)}, '%T %C')

  t.bindtags = [ t, 'TreeCtrlFileList', Tk::TreeCtrl, t.winfo_toplevel, :all ]
end

#demoExplorerLargeIcons(t) ⇒ Object



240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'sample/tkextlib/treectrl/explorer.rb', line 240

def demoExplorerLargeIcons(t)
  # Item height is 32 for icon, 4 padding, 3 lines of text
  itemHeight = 32 + 4 + t.font.metrics(:linespace) * 3

  t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, 
              :selectmode=>:extended, :wrap=>:window, :orient=>:horizontal, 
              :itemheight=>itemHeight, :showheader=>false, :scrollmargin=>16, 
              :xscrolldelay=>[500, 50], :yscrolldelay=>[500, 50])

  init_pics('big-*')

  if $HasColumnCreate
    t.column_create(:width=>75)
  else
    t.column_configure(0, :width=>75)
  end

  t.element_create('elemImg', :image, 
                   :image=>[
                     @sel_images['big-folder'], ['selected'], 
                     @images['big-folder'], []
                   ])
  t.element_create('elemTxt', :text, :justify=>:center, 
                   :lines=>1, :width=>71, :wrap=>:word, 
                   :fill=>[@SystemHighlightText, ['selected', 'focus']])
  t.element_create('elemSel', :rect, :showfocus=>true, 
                   :fill=>[
                     @SystemHighlight, ['selected', 'focus'], 
                     'gray', ['selected']
                   ])

  # image + text
  s = t.style_create('STYLE', :orient=>:vertical)
  t.style_elements(s, ['elemSel', 'elemImg', 'elemTxt'])
  t.style_layout(s, 'elemImg', :expand=>:we)
  t.style_layout(s, 'elemTxt', 
                 :pady=>[4,0], :padx=>2, :squeeze=>:x, :expand=>:we)
  t.style_layout(s, 'elemSel', :union=>['elemTxt'])

  @Priv[:edit, t] = ['elemTxt']
  @Priv[:sensitive, t] = [ [0, 'STYLE', 'elemImg', 'elemTxt'] ]
  @Priv[:dragimage, t] = [ [0, 'STYLE', 'elemImg', 'elemTxt'] ]

  t.notify_bind(t, 'Edit-accept', 
                proc{|w, i, tt| w.item_text(i, 0, tt)}, '%T %I %t')

  dir_proc = proc{|file|
    item = t.item_create
    t.item_style_set(item, 0, 'STYLE')
    t.item_text(item, 0, File.basename(file))
    t.item_lastchild(:root, item)
  }

  file_proc = proc{|file|
    item = t.item_create
    t.item_style_set(item, 0, 'STYLE')

    ext = File.extname(file)
    case ext
    when '.dll'
      img = 'big-dll'
    when '.exe'
      img = 'big-exe'
    when '.txt'
      img = 'big-txt'
    else
      img = 'big-file'
    end

    type = ext.upcase
    type = type[1..-1] << ' ' unless type.empty?
    type << 'File'

    t.item_complex(item, 
                   [ 
                     ['elemImg', {:image=>[@sel_images[img], ['selected'], 
                                           @images[img], []]}],
                     ['elemTxt', {:text=>File.basename(file)}]
                   ])
    t.item_lastchild(:root, item)
  }

  demoExplorerAux(t, dir_proc, file_proc)

  t.activate(t.index('root firstchild'))

  t.notify_bind(t, 'ActiveItem', 
                proc{|w, a, c|
                  w.item_element_configure(a, 0, 'elemTxt', :lines=>'')
                  w.item_element_configure(c, 0, 'elemTxt', :lines=>3)
                }, '%T %p %c')

  t.bindtags = [ t, 'TreeCtrlFileList', Tk::TreeCtrl, t.winfo_toplevel, :all ]
end

#demoExplorerList(t) ⇒ Object

Tree is vertical, wrapping occurs at bottom of window, each range has the same width (as wide as the longest item), xscrollincrement is by range



345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'sample/tkextlib/treectrl/explorer.rb', line 345

def demoExplorerList(t)
  height = t.font.metrics(:linespace) + 2
  height = 18 if height < 18

  t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, 
              :itemheight=>height, :selectmode=>:extended, :wrap=>:window, 
              :showheader=>false, :scrollmargin=>16, 
              :xscrolldelay=>[500, 50], :yscrolldelay=>[500, 50])

  init_pics('small-*')

  if $HasColumnCreate
    t.column_create(:widthhack=>true)
  else
    t.column_configure(0, :widthhack=>true)
  end

  t.element_create('elemImg', :image, 
                   :image=>[
                     @sel_images['small-folder'], ['selected'], 
                     @images['small-folder'], []
                   ])
  t.element_create('elemTxt', :text, :lines=>1, 
                   :fill=>[@SystemHighlightText, ['selected', 'focus']])
  t.element_create('elemSel', :rect, :showfocus=>true, 
                   :fill=>[
                     @SystemHighlight, ['selected', 'focus'], 
                     'gray', ['selected', '!focus']
                   ])

  # image + text
  s = t.style_create('STYLE')
  t.style_elements(s, ['elemSel', 'elemImg', 'elemTxt'])
  t.style_layout(s, 'elemImg', :expand=>:ns)
  t.style_layout(s, 'elemTxt', :squeeze=>:x, :expand=>:ns, :padx=>[2,0])
  t.style_layout(s, 'elemSel', :union=>['elemTxt'], :iexpand=>:ns, :ipadx=>2)

  @Priv[:edit, t] = ['elemTxt']
  @Priv[:sensitive, t] = [ [0, 'STYLE', 'elemImg', 'elemTxt'] ]
  @Priv[:dragimage, t] = [ [0, 'STYLE', 'elemImg', 'elemTxt'] ]

  t.notify_bind(t, 'Edit-accept', 
                proc{|w, i, tt| w.item_text(i, 0, tt)}, '%T %I %t')

  dir_proc = proc{|file|
    item = t.item_create
    t.item_style_set(item, 0, 'STYLE')
    t.item_text(item, 0, File.basename(file))
    t.item_lastchild(:root, item)
  }

  file_proc = proc{|file|
    item = t.item_create
    t.item_style_set(item, 0, 'STYLE')

    ext = File.extname(file)
    case ext
    when '.dll'
      img = 'small-dll'
    when '.exe'
      img = 'small-exe'
    when '.txt'
      img = 'small-txt'
    else
      img = 'small-file'
    end

    type = ext.upcase
    type = type[1..-1] << ' ' unless type.empty?
    type << 'File'

    t.item_complex(item, 
                   [ 
                     ['elemImg', {:image=>[@sel_images[img], ['selected'], 
                                           @images[img], []]}],
                     ['elemTxt', {:text=>File.basename(file)}]
                   ])
    t.item_lastchild(:root, item)
  }

  demoExplorerAux(t, dir_proc, file_proc)

  t.activate(t.item_firstchild(:root))

  t.bindtags = [ t, 'TreeCtrlFileList', Tk::TreeCtrl, t.winfo_toplevel, :all ]
end

#demoExplorerSmallIcons(t) ⇒ Object

Tree is horizontal, wrapping occurs at right edge of window, each item is as wide as the smallest needed multiple of 110 pixels



337
338
339
340
341
# File 'sample/tkextlib/treectrl/explorer.rb', line 337

def demoExplorerSmallIcons(t)
  demoExplorerList(t)
  t.configure(:orient=>:horizontal, :xscrollincrement=>0)
  t.column_configure(0, :width=>'', :stepwidth=>110, :widthhack=>false)
end

#demoHelpContents(t) ⇒ Object

Demo: Help contents



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'sample/tkextlib/treectrl/help.rb', line 4

def demoHelpContents(t)
  height = t.font.metrics(:linespace)
  height = 18 if height < 18
  t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, 
              :itemheight=>height, :selectmode=>:browse)

  init_pics('help-*')

  if $Version_1_1_OrLater
    t.column_create(:text=>'Help Contents')
  else # TreeCtrl 1.0
    t.column_configure(0, :text=>'Help Contents')
  end

  # Define a new item state
  t.state_define('mouseover')

  t.element_create('e1', :image, :image=>@images['help-page'])
  t.element_create('e2', :image, :image=>[
                     @images['help-book-open'], ['open'], 
                     @images['help-book-closed'], [], 
                   ])
  t.element_create('e3', :text, 
                   :font=>[t.font.dup.underline(true), ['mouseover']], 
                   :fill=>[
                     @SystemHighlightText, ['selected', 'focus'], 
                     'blue', ['mouseover']
                   ])
  t.element_create('e4', :rect, :showfocus=>true, 
                   :fill=>[@SystemHighlight, ['selected', 'focus']])

  # book
  s = t.style_create('s1')
  t.style_elements(s, ['e4', 'e1', 'e3'])
  t.style_layout(s, 'e1', :padx=>[0,4], :expand=>:ns)
  t.style_layout(s, 'e3', :expand=>:ns)
  t.style_layout(s, 'e4', :union=>['e3'], :iexpand=>:ns, :ipadx=>2)

  # page
  s = t.style_create('s2')
  t.style_elements(s, ['e4', 'e2', 'e3'])
  t.style_layout(s, 'e2', :padx=>[0,4], :expand=>:ns)
  t.style_layout(s, 'e3', :expand=>:ns)
  t.style_layout(s, 'e4', :union=>['e3'], :iexpand=>:ns, :ipadx=>2)

  parentList = [:root, '', '', '', '', '', '']
  parent = :root
  [
     [0, 's1', "Welcome to Help"], 
     [0, 's2', "Introducing Windows 98"], 
        [1, 's2', "How to Use Help"], 
           [2, 's1', "Find a topic"], 
           [2, 's1', "Get more out of help"],
        [1, 's2', "Register Your Software"],
           [2, 's1', "Registering Windows 98 online"], 
        [1, 's2', "What's New in Windows 98"], 
           [2, 's1', "Innovative, easy-to-use features"], 
           [2, 's1', "Improved reliability"], 
           [2, 's1', "A faster operating system"], 
           [2, 's1', "True Web integration"], 
           [2, 's1', "More entertaining and fun"], 
        [1, 's2', "If You're New to Windows 98"], 
           [2, 's2', "Tips for Macintosh Users"], 
              [3, 's1', "Why does the mouse have two buttons?"]
  ].each{|depth, style, text|
    item = t.item_create
    t.item_style_set(item, 0, style)
    t.item_element_configure(item, 0, 'e3', :text=>text)
    if $Version_1_1_OrLater
      t.item_collapse(item)
    else # TreeCtrl 1.0
      t.collapse(item)
    end
    t.item_lastchild(parentList[depth], item)
    depth += 1
    parentList[depth] = item
  }

  treeCtrlHelp = TkBindTag.new

  treeCtrlHelp.bind('Double-ButtonPress-1', 
                    proc{|w, x, y|
                      if w.identify(x, y)[0] == 'header'
                        Tk::TreeCtrl::BindCallback.doubleButton1(w, x, y)
                      else
                        helpButton1(w, x, y)
                      end
                      Tk.callback_break
                    }, '%W %x %y')

  treeCtrlHelp.bind('ButtonPress-1', 
                    proc{|w, x, y|
                      helpButton1(w, x, y)
                      Tk.callback_break
                    }, '%W %x %y')

  treeCtrlHelp.bind('Button1-Motion', 
                    proc{|w, x, y|
                      helpMotion1(w, x, y)
                      Tk.callback_break
                    }, '%W %x %y')

  treeCtrlHelp.bind('Button1-Leave', 
                    proc{|w, x, y|
                      helpLeave1(w, x, y)
                      Tk.callback_break
                    }, '%W %x %y')

  treeCtrlHelp.bind('ButtonRelease-1', 
                    proc{|w, x, y|
                      helpRelease1(w, x, y)
                      Tk.callback_break
                    }, '%W %x %y')

  treeCtrlHelp.bind('Motion', proc{|w, x, y| helpMotion(w, x, y) }, '%W %x %y')

  treeCtrlHelp.bind('Leave', proc{|w, x, y| helpMotion(w, x, y) }, '%W %x %y')

  treeCtrlHelp.bind('KeyPress-Return', 
                    proc{|w, x, y|
                      if w.selection_get.length == 1
                        if $Version_1_1_OrLater
                          w.item_toggle(w.selection_get[0])
                        else # TreeCtrl 1.0
                          w.toggle(w.selection_get[0])
                        end
                      end
                      Tk.callback_break
                    }, '%W %x %y')

  @Priv[:help, :prev] = ''

  t.bindtags = [ t, treeCtrlHelp, Tk::TreeCtrl, t.winfo_toplevel, :all ]
end

#demoHelpContents2(t) ⇒ Object

This is an alternate implementation that does not define a new item state to change the appearance of the item under the cursor.



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'sample/tkextlib/treectrl/help.rb', line 141

def demoHelpContents2(t)
  height = t.font.metrics(:linespace)
  height = 18 if height < 18
  t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, 
              :itemheight=>height, :selectmode=>:browse)

  init_pics('help-*')

  if $Version_1_1_OrLater
    t.column_create(:text=>'Help Contents')
  else # TreeCtrl 1.0
    t.column_configure(0, :text=>'Help Contents')
  end

  t.element_create('e1', :image, :image=>@images['help-page'])
  t.element_create('e2', :image, :image=>[
                     @images['help-book-open'], ['open'], 
                     @images['help-book-closed'], [], 
                   ])
  t.element_create('e3', :text, 
                   :fill=>[
                     @SystemHighlightText, ['selected', 'focus'], 
                     'blue', []
                   ])
  t.element_create('e4', :rect, :showfocus=>true, 
                   :fill=>[@SystemHighligh, ['selected', 'focus']])
  t.element_create('e5', :text, :font=>t.font.dup.underline(true), 
                   :fill=>[
                     @SystemHighlightText, ['selected', 'focus'], 
                     'blue', []
                   ])

  # book
  s = t.style_create('s1')
  t.style_elements(s, ['e4', 'e1', 'e3'])
  t.style_layout(s, 'e1', :padx=>[0,4], :expand=>:ns)
  t.style_layout(s, 'e3', :expand=>:ns)
  t.style_layout(s, 'e4', :union=>['e3'], :iexpand=>:ns, :ipadx=>2)

  # page
  s = t.style_create('s2')
  t.style_elements(s, ['e4', 'e2', 'e3'])
  t.style_layout(s, 'e2', :padx=>[0,4], :expand=>:ns)
  t.style_layout(s, 'e3', :expand=>:ns)
  t.style_layout(s, 'e4', :union=>['e3'], :iexpand=>:ns, :ipadx=>2)

  # book (focus)
  s = t.style_create('s1.f')
  t.style_elements(s, ['e4', 'e1', 'e5'])
  t.style_layout(s, 'e1', :padx=>[0,4], :expand=>:ns)
  t.style_layout(s, 'e5', :expand=>:ns)
  t.style_layout(s, 'e4', :union=>['e5'], :iexpand=>:ns, :ipadx=>2)

  # page (focus)
  s = t.style_create('s2')
  t.style_elements(s, ['e4', 'e2', 'e5'])
  t.style_layout(s, 'e2', :padx=>[0,4], :expand=>:ns)
  t.style_layout(s, 'e5', :expand=>:ns)
  t.style_layout(s, 'e4', :union=>['e5'], :iexpand=>:ns, :ipadx=>2)

  parentList = [:root, '', '', '', '', '', '']
  parent = :root
  [
     [0, 's1', "Welcome to Help"], 
     [0, 's2', "Introducing Windows 98"], 
        [1, 's2', "How to Use Help"], 
           [2, 's1' "Find a topic"], 
           [2, 's1', "Get more out of help"],
        [1, 's2', "Register Your Software"],
           [2, 's1', "Registering Windows 98 online"], 
        [1, 's2', "What's New in Windows 98"], 
           [2, 's1', "Innovative, easy-to-use features"], 
           [2, 's1', "Improved reliability"], 
           [2, 's1', "A faster operating system"], 
           [2, 's1', "True Web integration"], 
           [2, 's1', "More entertaining and fun"], 
        [1, 's2', "If You're New to Windows 98"], 
           [2, 's2', "Tips for Macintosh Users"], 
              [3, 's1', "Why does the mouse have two buttons?"]
  ].each{|depth, style, text|
    item = t.item_create
    t.item_style_set(item, 0, style)
    t.item_element_configure(item, 0, 'e3', :text=>text)
    if $Version_1_1_OrLater
      t.item_collapse(item)
    else # TreeCtrl 1.0
      t.collapse(item)
    end
    t.item_lastchild(parentList[depth], item)
    depth += 1
    parentList[depth] = item
  }

  treeCtrlHelp = TkBindTag.new

  treeCtrlHelp.bind('Double-ButtonPress-1', 
                    proc{|w, x, y|
                      if w.identify(x, y)[0] == 'header'
                        Tk::TreeCtrl::BindCallback.doubleButton1(w, x, y)
                      else
                        helpButton1(w, x, y)
                      end
                      Tk.callback_break
                    }, '%W %x %y')

  treeCtrlHelp.bind('ButtonPress-1', 
                    proc{|w, x, y|
                      helpButton1(w, x, y)
                      Tk.callback_break
                    }, '%W %x %y')

  treeCtrlHelp.bind('Button1-Motion', 
                    proc{|w, x, y|
                      helpMotion1(w, x, y)
                      Tk.callback_break
                    }, '%W %x %y')

  treeCtrlHelp.bind('Button1-Leave', 
                    proc{|w, x, y|
                      helpLeave1(w, x, y)
                      Tk.callback_break
                    }, '%W %x %y')

  treeCtrlHelp.bind('ButtonRelease-1', 
                    proc{|w, x, y|
                      helpRelease1(w, x, y)
                      Tk.callback_break
                    }, '%W %x %y')

  treeCtrlHelp.bind('Motion', proc{|w, x, y| helpMotion(w, x, y) }, '%W %x %y')

  treeCtrlHelp.bind('Leave', proc{|w, x, y| helpMotion(w, x, y) }, '%W %x %y')

  treeCtrlHelp.bind('KeyPress-Return', 
                    proc{|w, x, y|
                      if w.selection_get.length == 1
                        w.item_toggle(w.selection_get[0])
                      end
                      Tk.callback_break
                    }, '%W %x %y')

  @Priv[:help, :prev] = ''

  t.bindtags = [ t, treeCtrlHelp, Tk::TreeCtrl, t.winfo_toplevel, :all ]
end

#demoIMovie(t) ⇒ Object

Demo: iMovie



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'sample/tkextlib/treectrl/imovie.rb', line 4

def demoIMovie(t)
  t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, 
              :selectmode=>:browse, :orient=>:horizontal, :wrap=>:window, 
              :showheader=>false, :background=>'#dcdcdc')

  if $HasColumnCreate
    t.column_create
  end

  init_pics('imovie-*')

  case @thisPlatform
  when 'macintosh', 'macosx'
    font1 = TkFont.new(['Geneva', 9])
    font2 = TkFont.new(['Geneva', 10])
  when 'unix'
    font1 = TkFont.new(['Helvetica', -12])
    font2 = TkFont.new(['Helvetica', -14])
  else
    font1 = TkFont.new(['Helvetica', 8])
    font2 = TkFont.new(['Helvetica', 10])
  end

  t.element_create('elemTime', :text, :font=>font1)
  t.element_create('elemName', :text, :font=>font2, :lines=>1, :width=>80)
  t.element_create('elemRect', :rect, :outline=>'#827878', :outlinewidth=>1, 
                   :fill=>['#ffdc5a', ['selected'], 'white', []])
  t.element_create('elemImg', :image)
  t.element_create('elemShadow', :rect, :outline=>'gray', :outlinewidth=>1, 
                   :open=>:wn)

  s = t.style_create('STYLE', :orient=>:vertical)
  t.style_elements(s, [
                     'elemShadow', 'elemRect', 'elemTime', 
                     'elemImg', 'elemName'
                   ])
  t.style_layout(s, 'elemShadow', :detach=>true, 
                 :padx=>[1,2], :pady=>[1,2], :iexpand=>:es)
  t.style_layout(s, 'elemTime', :padx=>[2,0])
  t.style_layout(s, 'elemImg', :pady=>[0,1])
  t.style_layout(s, 'elemName', :expand=>:we, :ipady=>[0,2], :padx=>[0,3], 
                 :squeeze=>:x)
  t.style_layout(s, 'elemRect', :union=>['elemTime', 'elemImg', 'elemName'], 
                 :ipadx=>6, :padx=>[0,3], :pady=>[0,3])

  # Set default item style
  if $Version_1_1_OrLater
    t.defaultstyle([s])
  end

  (0..4).each{|i|
    [
      ['15:20', 'Clip 1', @images['imovie-01']], 
      ['19:18', 'Clip 2', @images['imovie-02']], 
      ['07:20', 'Clip 3', @images['imovie-03']], 
      ['07:20', 'Clip 4', @images['imovie-04']], 
      ['07:20', 'Clip 5', @images['imovie-05']], 
      ['07:20', 'Clip 6', @images['imovie-06']], 
      ['07:20', 'Clip 7', @images['imovie-07']]
    ].each{|time, name, image|
      item = t.item_create
      unless $Version_1_1_OrLater
        t.item_style_set(item, 0, s)
      end
      t.item_element_configure(item, 0, 'elemTime', :text=>time)
      t.item_element_configure(item, 0, 'elemName', :text=>name)
      t.item_element_configure(item, 0, 'elemImg', :image=>image)
      t.item_lastchild(:root, item)
    }
  }

  t.notify_bind(t, 'Edit-accept', proc{|w, i, c, e, tt|
                  w.item_element_configure(i, c, e, :text=>tt)
                }, '%T %I %C %E %t')

  iMovie = TkBindTag.new
  iMovie.bind('ButtonPress-1', proc{|w, x, y|
                iMovieButton1(w, x, y)
              }, '%W %x %y')

  t.bindtags = [t, iMovie, Tk::TreeCtrl, t.winfo_toplevel, TkBindTag::ALL]
end

#demoInternetOptions(t) ⇒ Object



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'sample/tkextlib/treectrl/www-options.rb', line 1

def demoInternetOptions (t)
  @Option = TkVarAccess.new_hash('::Option')

  height = t.font.metrics(:linespace) + 2
  height = 18 if height < 18
  t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, 
              :itemheight=>height, :selectmode=>:browse)

  init_pics('internet-*')

  if $HasColumnCreate
    t.column_create(:text=>'Internet Options')
  else
    t.column_configure(0, :text=>'Internet Options')
  end

  t.state_define('check')
  t.state_define('radio')
  t.state_define('on')

  t.element_create('e1', :image, :image=>[
                     @images['internet-check-on'],  ['check', 'on'], 
                     @images['internet-check-off'], ['check'], 
                     @images['internet-radio-on'],  ['radio', 'on'], 
                     @images['internet-radio-off'], ['radio']
                   ])
  t.element_create('e2', :text, 
                   :fill=>[@SystemHighlightText, ['selected', 'focus']])
  t.element_create('e3', :rect, :showfocus=>true, 
                   :fill=>[@SystemHighlight, ['selected', 'focus']])

  s = t.style_create('s1')
  t.style_elements(s, ['e3', 'e1', 'e2'])
  t.style_layout(s, 'e1', :padx=>[0,4], :expand=>:ns)
  t.style_layout(s, 'e2', :expand=>:ns)
  t.style_layout(s, 'e3', :union=>['e2'], :iexpand=>:ns, :ipadx=>2)

  parentList = [:root, '', '', '', '', '', '']
  parent = :root
  [
    [0, :print, "Printing", "", ""], 
        [1, :off, "Print background colors and images", "o1", ""], 
    [0, :search, "Search from Address bar", "", ""], 
        [1, :search, "When searching", "", ""], 
            [2, :off, "Display results, and go to the most likely sites", 
                                                                 "o2", "r1"], 
            [2, :off, "Do not search from the Address bar", "o3", "r1"], 
            [2, :off, "Just display the results in the main window", 
                                                                 "o4", "r1"],
            [2, :on, "Just go to the most likely site", "o5", "r1"], 
    [0, :security, "Security", "", ""], 
        [1, :on, "Check for publisher's certificate revocation", "o5", ""], 
        [1, :off, "Check for server certificate revocation (requires restart)",
                                                                 "o6", ""]
  ].each{|depth, setting, text, option, group|
    item = t.item_create()
    t.item_style_set(item, 0, 's1')
    t.item_element_configure(item, 0, 'e2', :text=>text)
    @Option[:option, item] = option
    @Option[:group, item] = group
    if setting == :on || setting == :off
      @Option[:setting, item] = setting
      if group == ''
        t.item_state_set(item, 'check')
        if setting == :on
          t.item_state_set(item, 'on')
        end
      else
        if setting == :on
          @Option[:current, group] = item
          t.item_state_set(item, 'on')
        end
        t.item_state_set(item, 'radio')
      end
    else
      t.item_element_configure(item, 0, 'e1', 
                               :image=>@images["internet-#{setting}"])
    end
    t.item_lastchild(parentList[depth], item)
    depth += 1
    parentList[depth] = item
  }

  treeCtrlOption = TkBindTag.new
  treeCtrlOption.bind('Double-ButtonPress-1', proc{|w, x, y|
                        Tk::TreeCtrl::BindCallback.doubleButton1(w, x, y)
                      }, '%W %x %y')
  treeCtrlOption.bind('ButtonPress-1', proc{|w, x, y|
                        optionButton1(w, x, y)
                        Tk.callback_break
                      }, '%W %x %y')
  treeCtrlOption.bind('Button1-Motion', proc{|w, x, y|
                        optionMotion1(w, x, y)
                        Tk.callback_break
                      }, '%W %x %y')
  treeCtrlOption.bind('Button1-Leave', proc{|w, x, y|
                        optionLeave1(w, x, y)
                        Tk.callback_break
                      }, '%W %x %y')
  treeCtrlOption.bind('ButtonRelease-1', proc{|w, x, y|
                        optionRelease1(w, x, y)
                        Tk.callback_break
                      }, '%W %x %y')

  t.bindtags = [
    t, treeCtrlOption, Tk::TreeCtrl, t.winfo_toplevel, TkBindTag::ALL
  ]
end

#demoInternetOptions_2(t) ⇒ Object

Alternate implementation that doesn’t rely on run-time styles



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'sample/tkextlib/treectrl/www-options.rb', line 146

def demoInternetOptions_2(t)
  height = t.font.metrics(:linespace) + 2
  height = 18 if height < 18
  t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, 
              :itemheight=>height, :selectmode=>:browse)

  init_pics('internet-*')

  t.column_configure(0, :text=>'Internet Options')

  t.element_create('e1', :image)
  t.element_create('e2', :text, 
                   :fill=>[@SystemHighlightText, ['selected', 'focus']])
  t.element_create('e3', :rect, :showfocus=>true, 
                   :fill=>[@SystemHighlight, ['selected', 'focus']])

  s = t.style_create('s1')
  t.style_elements('s1', ['e3', 'e1', 'e2'])
  t.style_layout(s, 'e1', :padx=>[0,4], :expand=>:ns)
  t.style_layout(s, 'e2', :expand=>:ns)
  t.style_layout(s, 'e3', :union=>['e2'], :iexpand=>:ns, :ipadx=>2)

  parentList = [:root, '', '', '', '', '', '']
  parent = :root
  [
    [0, :print, "Printing", "", ""], 
        [1, :off, "Print background colors and images", "o1", ""], 
    [0, :search, "Search from Address bar", "", ""], 
        [1, :search, "When searching", "", ""], 
            [2, :off, "Display results, and go to the most likely sites", 
                                                                 "o2", "r1"], 
            [2, :off, "Do not search from the Address bar", "o3", "r1"], 
            [2, :off, "Just display the results in the main window", 
                                                                 "o4", "r1"],
            [2, :on, "Just go to the most likely site", "o5", "r1"], 
    [0, :security, "Security", "", ""], 
        [1, :on, "Check for publisher's certificate revocation", "o5", ""], 
        [1, :off, "Check for server certificate revocation (requires restart)",
                                                                 "o6", ""]
  ].each{|depth, setting, text, option, group|
    item = t.item_create()
    t.item_style_set(item, 0, 's1')
    t.item_element_configure(item, 0, 'e2', :text=>text)
    @Option[:option, item] = option
    @Option[:group, item] = group
    if setting == :on || setting == :off
      @Option[:setting, item] = setting
      if group == ''
        img = @images["internet-check-#{setting}"]
        t.item_element_configure(item, 0, 'e1', :image=>img)
      else
        if setting == :on
          @Option[:current, group] = item
        end
        img = @images["internet-radio-#{setting}"]
        t.item_element_configure(item, 0, 'e1', :image=>img)
      end
    else
      t.item_element_configure(item, 0, 'e1', 
                               :image=>@images["internet-#{setting}"])
    end
    t.item_lastchild(parentList[depth], item)
    depth += 1
    parentList[depth] = item
  }

  treeCtrlOption = TkBindTag.new
  treeCtrlOption.bind('Double-ButtonPress-1', proc{|w, x, y|
                        Tk::TreeCtrl::BindCallback.doubleButton1(w, x, y)
                      }, '%W %x %y')
  treeCtrlOption.bind('ButtonPress-1', proc{|w, x, y|
                        optionButton1(w, x, y)
                        Tk.callback_break
                      }, '%W %x %y')
  treeCtrlOption.bind('Button1-Motion', proc{|w, x, y|
                        optionMotion1(w, x, y)
                        Tk.callback_break
                      }, '%W %x %y')
  treeCtrlOption.bind('Button1-Leave', proc{|w, x, y|
                        optionLeave1(w, x, y)
                        Tk.callback_break
                      }, '%W %x %y')
  treeCtrlOption.bind('ButtonRelease-1', proc{|w, x, y|
                        optionRelease1(w, x, y)
                        Tk.callback_break
                      }, '%W %x %y')

  t.bindtags = [
    t, treeCtrlOption, Tk::TreeCtrl, t.winfo_toplevel, TkBindTag::ALL
  ]
end

#demoLayout(t) ⇒ Object

Demo: Layout



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'sample/tkextlib/treectrl/layout.rb', line 4

def demoLayout(t)
  t.configure(:showroot=>false, :showrootbutton=>true, :showbuttons=>true, 
              :showlines=>true, :itemheight=>0, :selectmode=>:browse)

  if $HasColumnCreate
    t.column_create(:text=>'Layout')
  else
    t.column_configure(0, :text=>'Layout')
  end

  t.element_create('e1', :rect, :width=>30, :height=>30, :fill=>'gray20')
  t.element_create('e2', :rect, :width=>30, :height=>30, :fill=>'gray40', 
                   :outline=>'blue', :outlinewidth=>3)
  t.element_create('e3', :rect, :fill=>'gray60')
  t.element_create('e4', :rect, :showfocus=>true, 
                   :fill=>[
                     @SystemHighlight, ['selected', 'focus'], 'gray80', []
                   ])
  t.element_create('e5', :rect, :fill=>'{sky blue}', :width=>20, :height=>20)
  t.element_create('e6', :rect, :fill=>'{sea green}', :width=>30, :height=>16)
  t.element_create('e7', :rect, :fill=>'{sky blue}', :width=>30, :height=>16)
  t.element_create('e8', :rect, :fill=>'gray70', :height=>1)

  s = t.style_create('s1')
  t.style_elements(s, ['e4', 'e3', 'e1', 'e2', 'e5', 'e6', 'e7'])
  t.style_layout(s, 'e1', :padx=>[28, 4], :pady=>4)
  t.style_layout(s, 'e2', :expand=>:es, :padx=>[0, 38])
  t.style_layout(s, 'e3', :union=>['e1', 'e2'], :ipadx=>4, :ipady=>4, :pady=>2)
  t.style_layout(s, 'e4', :detach=>true, :iexpand=>:es)
  t.style_layout(s, 'e5', :detach=>true, :padx=>[2,0], :pady=>2, :iexpand=>:s)
  t.style_layout(s, 'e6', :detach=>true, :expand=>:ws, 
                 :padx=>[0,2], :pady=>[2,0])
  t.style_layout(s, 'e7', :detach=>true, :expand=>:wn, 
                 :padx=>[0,2], :pady=>[0,2])

  if $Version_1_1_OrLater
    i = t.item_create(:button=>true)
  else
    i = t.item_create
    t.item_hasbutton(i, true)
  end
  t.item_style_set(i, 0, s)
  t.item_lastchild(:root, i)
  parent = i

  i = t.item_create()
  unless $Version_1_1_OrLater
    t.item_hasbutton(i, false)
  end
  t.item_style_set(i, 0, s)
  t.item_lastchild(parent, i)

  ### 

  s = t.style_create('s2')
  t.style_elements(s, ['e4', 'e3', 'e1'])
  t.style_layout(s, 'e1', :padx=>8, :pady=>8, :iexpand=>:e)
  t.style_layout(s, 'e3', :union=>['e1'], :ipadx=>[20,4], :ipady=>[4,12])
  t.style_layout(s, 'e4', :detach=>true, :iexpand=>:es)

  if $Version_1_1_OrLater
    i = t.item_create(:button=>true)
  else
    i = t.item_create
    t.item_hasbutton(i, true)
  end
  t.item_style_set(i, 0, s)
  t.item_lastchild(:root, i)

  i2 = t.item_create()
  unless $Version_1_1_OrLater
    t.item_hasbutton(i2, false)
  end
  t.item_style_set(i2, 0, s)
  t.item_lastchild(i, i2)

  ### 

  s = t.style_create('s3')
  t.style_elements(s, ['e4', 'e3', 'e1', 'e5', 'e6'])
  t.style_layout(s, 'e4', :union=>['e1', 'e6'], :ipadx=>8, :ipady=>[8,0])
  t.style_layout(s, 'e3', :union=>['e1', 'e5'], :ipadx=>4, :ipady=>4)
  t.style_layout(s, 'e5', :ipady=>[0,20])

  if $Version_1_1_OrLater
    i = t.item_create(:button=>true)
  else
    i = t.item_create
    t.item_hasbutton(i, true)
  end
  t.item_style_set(i, 0, s)
  t.item_lastchild(:root, i)

  i2 = t.item_create()
  unless $Version_1_1_OrLater
    t.item_hasbutton(i2, false)
  end
  t.item_style_set(i2, 0, s)
  t.item_lastchild(i, i2)

  ### 

  t.element_create('eb', :border, :background=>@SystemButtonFace, 
                   :relief=>[:sunken, ['selected'], :raised, []], 
                   :thickness=>2, :filled=>true)
  t.element_create('et', :text)

  text = "Here is a text element surrounded by a border element.\nResize the column to watch me wrap."

  s = t.style_create('e4')
  t.style_elements(s, ['eb', 'et'])
  t.style_layout(s, 'eb', :union=>['et'], :ipadx=>2, :ipady=>2)
  t.style_layout(s, 'et', :squeeze=>:x)

  if $Version_1_1_OrLater
    i = t.item_create(:button=>true)
  else
    i = t.item_create
    t.item_hasbutton(i, true)
  end
  t.item_style_set(i, 0, s)
  t.item_text(i, 0, text)
  t.item_lastchild(:root, i)
  parent = i

  i = t.item_create()
  unless $Version_1_1_OrLater
    t.item_hasbutton(i, false)
  end
  t.item_style_set(i, 0, s)
  t.item_text(i, 0, text)
  t.item_lastchild(parent, i)

  ### 

  styleNum = 5
  [ 
    [:horizontal, [:s, :ns, :n]], 
    [:vertical,   [:e, :we, :w]]
  ].each{|orient, expandList|
    expandList.each{|expand|
      s = t.style_create("s#{styleNum}", :orient=>orient)
      t.style_elements(s, ['e4', 'e8', 'e2', 'e5', 'e6'])
      t.style_layout(s, 'e4', :detach=>true, :iexpand=>:es)
      t.style_layout(s, 'e8', :detach=>true, :expand=>:n, :iexpand=>:e)
      t.style_layout(s, 'e2', :expand=>expand)
      t.style_layout(s, 'e5', :expand=>expand)
      t.style_layout(s, 'e6', :expand=>expand)
      styleNum += 1

      i = t.item_create()
      t.item_style_set(i, 0, s)
      t.item_lastchild(:root, i)
    }
  }
end

#demoMailWasher(t) ⇒ Object

Demo: MailWasher



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'sample/tkextlib/treectrl/mailwasher.rb', line 4

def demoMailWasher(t)
  init_pics('*checked')

  height = t.font.metrics(:linespace) + 2
  height = 18 if height < 18

  t.configure(:showroot=>false, :showrootbutton=>false, :showbuttons=>false, 
              :showlines=>false, :itemheight=>height, :selectmode=>:browse, 
              :xscrollincrement=>1)

  pad = 4

  if $Version_1_1_OrLater
    t.column_create(:text=>'Delete', :textpadx=>pad, :tag=>'delete')
    t.column_create(:text=>'Bounce', :textpadx=>pad, :tag=>'bounce')
    t.column_create(:text=>'Status', :width=>80, :textpadx=>pad, 
                    :tag=>'status')
    t.column_create(:text=>'Size', :width=>40, :textpadx=>pad, 
                    :justify=>:right, :tag=>'size')
    t.column_create(:text=>'From', :width=>140, :textpadx=>pad, :tag=>'from')
    t.column_create(:text=>'Subject', :width=>240, :textpadx=>pad, 
                    :tag=>'subject')
    t.column_create(:text=>'Received', :textpadx=>pad, :arrow=>:up, 
                    :arrowpad=>[4,0], :tag=>'received')
    t.column_create(:text=>'Attachments', :textpadx=>pad, :tag=>'attachments')

    t.state_define('CHECK')

    t.element_create('imgCheck', :image, :image=>[
                       @images['checked'], ['CHECK'], @images['unchecked'], []
                     ])

  else # TreeCtrl 1.0
    t.column_configure(0, :text=>'Delete', :textpadx=>pad, :tag=>'delete')
    t.column_configure(1, :text=>'Bounce', :textpadx=>pad, :tag=>'bounce')
    t.column_configure(2, :text=>'Status', :width=>80, :textpadx=>pad, 
                       :tag=>'status')
    t.column_configure(3, :text=>'Size', :width=>40, :textpadx=>pad, 
                       :justify=>:right, :tag=>'size')
    t.column_configure(4, :text=>'From', :width=>140, :textpadx=>pad, 
                       :tag=>'from')
    t.column_configure(5, :text=>'Subject', :width=>240, :textpadx=>pad, 
                       :tag=>'subject')
    t.column_configure(6, :text=>'Received', :textpadx=>pad, :arrow=>:up, 
                       :arrowpad=>[4,0], :tag=>'received')
    t.column_configure(7, :text=>'Attachments', :textpadx=>pad, 
                       :tag=>'attachments')

    t.element_create('imgOff', :image, :image=>@images['unchecked'])
    t.element_create('imgOn', :image, :image=>@images['checked'])
  end

  t.element_create('border', :rect, :open=>:nw, :outline=>'gray', 
                   :outlinewidth=>1, :fill=>[@SystemHighlight, ['selected']])
  t.element_create('txtAny', :text, :lines=>1, 
                   :fill=>[@SystemHighlightText, ['selected']])
  t.element_create('txtNone', :text, :text=>'none', :lines=>1, 
                   :fill=>[@SystemHighlightText, ['selected']])
  t.element_create('txtYes', :text, :text=>'yes', :lines=>1, 
                   :fill=>[@SystemHighlightText, ['selected']])
  t.element_create('txtNormal', :text, :text=>'Normal', :lines=>1, 
                   :fill=>[@SystemHighlightText, ['selected'], '#006800', []])
  t.element_create('txtPossSpam', :text, :text=>'Possible Spam', :lines=>1, 
                   :fill=>[@SystemHighlightText, ['selected'], '#787800', []])
  t.element_create('txtProbSpam', :text, :text=>'Probably Spam', :lines=>1, 
                   :fill=>[@SystemHighlightText, ['selected'], '#FF9000', []])
  t.element_create('txtBlacklist', :text, :text=>'Blacklisted', :lines=>1, 
                   :fill=>[@SystemHighlightText, ['selected'], '#FF5800', []])

  if $Version_1_1_OrLater
    s = t.style_create('styCheck')
    t.style_elements(s, ['border', 'imgCheck'])
    t.style_layout(s, 'border', :detach=>true, :iexpand=>:es)
    t.style_layout(s, 'imgCheck', :expand=>:news)
  else
    ['Off', 'On'].each{|name|
      s = t.style_create('sty' << name)
      i = 'img' << name
      t.style_elements(s, ['border', i])
      t.style_layout(s, 'border', :detach=>true, :iexpand=>:es)
      t.style_layout(s, i, :expand=>:news)
    }
  end

  pad = 4

  %w(Any None Yes Normal PossSpam ProbSpam Blacklist).each{|name|
    s = t.style_create('sty' << name)
    e = 'txt' << name
    t.style_elements(s, ['border', e])
    t.style_layout(s, 'border', :detach=>true, :iexpand=>:es)
    t.style_layout(s, e, :padx=>pad, :squeeze=>:x, :expand=>:ns)
  }

  [
    ['[email protected]',  "Your hair is thinning"], 
    ['[email protected]', "Your breasts are too small"], 
    ['[email protected]',  "Your penis is too small"], 
    ['[email protected]', "You are not very smart"], 
    ['[email protected]', "You need more money"], 
    ['[email protected]', "You need better friends"], 
    ['[email protected]', "Find out what your coworkers think about you"], 
    ['[email protected]', "Find out what you think about yourself"],
    ['[email protected]', "You need a better job"], 
    ['[email protected]', "Your mortgage is a joke"], 
    ['[email protected]', "You need more spam"]
  ].each{|frm, subj|
    item = t.item_create
    status = ['styNormal','styPossSpam','styProbSpam','styBlacklist'][rand(4)]
    attachments = ['styNone','styYes'][rand(2)]

    if $Version_1_1_OrLater
      delete = [false, true][rand(2)]
      bounce = [false, true][rand(2)]
      t.item_style_set(item, 
                       0, 'styCheck', 1, 'styCheck', 2, status, 3, 'styAny', 
                       4, 'styAny', 5, 'styAny', 6, 'styAny', 7, attachments)
      t.item_state_forcolumn(item, 'delete', 'CHECK') if delete
      t.item_state_forcolumn(item, 'bounce', 'CHECK') if bounce

    else # TreeCtrl 1.0
      delete = ['styOn', 'styOff'][rand(2)]
      bounce = ['styOn', 'styOff'][rand(2)]
      t.item_style_set(item, 
                       0, delete, 1, bounce, 2, status, 3, 'styAny', 
                       4, 'styAny', 5, 'styAny', 6, 'styAny', 7, attachments)
    end

    bytes = 512 + rand(1024 * 12)
    size = "#{bytes / 1024 + 1}KB"
    seconds = Tk::Clock.seconds - rand(100000)
    received = Tk::Clock.format(seconds, '%d/%m/%y %I:%M %p')
    t.item_text(item, 3, size, 4, frm, 5, subj, 6, received)
    t.item_lastchild(:root, item)
  }

  sortColumn = 6
  t.notify_bind(t, 'Header-invoke', 
                proc{|c, w|
                  if c == sortColumn
                    if w.column_cget(sortColumn, :arrow) == 'down'
                      order = :increasing
                      arrow = :up
                    else
                      order = :decreasing
                      arrow = :down
                    end
                  else
                    if w.column_cget(sortColumn, :arrow) == 'down'
                      order = :decreasing
                      arrow = :down
                    else
                      order = :increasing
                      arrow = :up
                    end
                    w.column_configure(sortColumn, :arrow=>:none)
                    sortColumn = c
                  end
                  w.column_configure(c, :arrow=>arrow)
                  case w.column_cget(c, :tag)
                  when 'bounce', 'delete'
                    w.item_sort(:root, order, 
                                { 
                                  :column=>c, 
                                  :command=>proc{|item1, item2|
                                    compareOnOff(w, c, item1, item2)
                                  }
                                }, 
                                { :column=>'subject', :dictionary=>true })
                  when 'status'
                    w.item_sort(:root, order, 
                                { :column=>c, :dictionary=>true })
                  when 'from'
                    w.item_sort(:root, order, 
                                { :column=>c, :dictionary=>true }, 
                                { :column=>'subject', :dictionary=>true })
                  when 'subject'
                    w.item_sort(:root, order, 
                                { :column=>c, :dictionary=>true })
                  when 'size'
                    w.item_sort(:root, order, 
                                { :column=>c, :dictionary=>true }, 
                                { :column=>'subject', :dictionary=>true })
                  when 'received'
                    w.item_sort(:root, order, 
                                { :column=>c, :dictionary=>true }, 
                                { :column=>'subject', :dictionary=>true })
                  when 'attachments'
                    w.item_sort(:root, order, 
                                { :column=>c, :dictionary=>true }, 
                                { :column=>'subject', :dictionary=>true })
                  end
                }, '%C %T')

  mailWasher = TkBindTag.new

  if $Version_1_1_OrLater
    mailWasher.bind('ButtonPress-1', 
                    proc{|w, x, y|
                      id = w.identify(x, y)
                      if id.empty?
                      elsif id[0] == 'header'
                      else
                        what, item, where, arg1, arg2, arg3 = id
                        if where == 'column'
                          tag = w.column_cget(arg1, :tag)
                          if tag == 'delete' || tag == 'bounce'
                            w.item_state_forcolumn(item, arg1, '~CHECK')
                          end
                        end
                      end
                    }, '%W %x %y')
  else # TreeCtrl 1.0
    mailWasher.bind('ButtonPress-1', 
                    proc{|w, x, y|
                      id = w.identify(x, y)
                      if id.empty?
                      elsif id[0] == 'header'
                      else
                        what, item, where, arg1, arg2, arg3 = id
                        if where == 'column'
                          tag = w.column_cget(arg1, :tag)
                          if tag == 'delete' || tag == 'bounce'
                            style = w.item_style_set(item, arg1)
                            if style == 'styOn'
                              style = 'styOff'
                            else
                              style = 'styOn'
                            end
                            w.item_style_set(item, arg1, style)
                            @display_styles_in_item.call(item)
                          end
                        end
                      end
                    }, '%W %x %y')
  end

  t.bindtags = [t, mailWasher, Tk::TreeCtrl, t.winfo_toplevel, TkBindTag::ALL]
end

#demoOutlookFolders(t) ⇒ Object

Demo: Outlook Express folder list



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'sample/tkextlib/treectrl/outlook-folders.rb', line 4

def demoOutlookFolders(t)
  init_pics('outlook-*')

  height = t.font.metrics(:linespace) + 2
  height = 18 if height < 18

  t.configure(:itemheight=>height, :selectmode=>:browse, :showlines=>true, 
              :showroot=>true, :showrootbutton=>false, :showbuttons=>true)

  if $HasColumnCreate
    t.column_create(:text=>'Folders')
  else
    t.column_configure(0, :text=>'Folders')
  end

  t.element_create('e1', :image)
  t.element_create('e2', :text, :lines=>1, 
                   :fill=>[@SystemHighlightText, ['selected', 'focus']])
  t.element_create('e3', :text, :lines=>1, :font=>t.font.dup.weight(:bold), 
                   :fill=>[@SystemHighlightText, ['selected', 'focus']])
  t.element_create('e4', :text, :fill=>'blue')
  t.element_create('e5', :image, :image=>@images['outlook-folder'])
  t.element_create('e6', :rect, :showfocus=>true, 
                   :fill=>[
                     @SystemHighlight, ['selected', 'focus'], 
                     'gray', ['selected', '!focus']
                   ])

  # image + text
  s = t.style_create('s1')
  t.style_elements(s, ['e6', 'e1', 'e2'])
  t.style_layout(s, 'e1', :expand=>:ns)
  t.style_layout(s, 'e2', :padx=>[4,0], :expand=>:ns, :squeeze=>:x)
  t.style_layout(s, 'e6', :union=>['e2'], :iexpand=>:ns, :ipadx=>2)

  # image + text + text
  s = t.style_create('s2')
  t.style_elements(s, ['e6', 'e1', 'e3', 'e4'])
  t.style_layout(s, 'e1', :expand=>:ns)
  t.style_layout(s, 'e3', :padx=>4, :expand=>:ns, :squeeze=>:x)
  t.style_layout(s, 'e4', :expand=>:ns)
  t.style_layout(s, 'e6', :union=>['e3'], :iexpand=>:ns, :ipadx=>2)

  # folder + text
  s = t.style_create('s3')
  t.style_elements(s, ['e6', 'e5', 'e2'])
  t.style_layout(s, 'e5', :expand=>:ns)
  t.style_layout(s, 'e2', :padx=>[4,0], :expand=>:ns, :squeeze=>:x)
  t.style_layout(s, 'e6', :union=>['e2'], :iexpand=>:ns, :ipadx=>2)

  # folder + text + text
  s = t.style_create('s4')
  t.style_elements(s, ['e6', 'e5', 'e3', 'e4'])
  t.style_layout(s, 'e5', :expand=>:ns)
  t.style_layout(s, 'e3', :padx=>4, :expand=>:ns, :squeeze=>:x)
  t.style_layout(s, 'e4', :expand=>:ns)
  t.style_layout(s, 'e6', :union=>['e3'], :iexpand=>:ns, :ipadx=>2)

  t.item_style_set(:root, 0, 's1')
  t.item_complex(:root, 
                 [
                   ['e1', {:image=>@images['outlook-main']}], 
                   ['e2', {:text=>'Outlook Express'}]
                 ])

  parentList = [:root, '', '', '', '', '', '']
  parent = :root
  [
     [0, :local, "Local Folders", true, 0], 
        [1, :inbox, 'Inbox', false, 5], 
        [1, :outbox, 'Outbox', false, 0], 
        [1, :sent, "Sent Items", false, 0], 
        [1, :deleted, "Deleted Items", false, 50], 
        [1, :draft, 'Drafts', false, 0], 
        [1, :folder, "Messages to Dad", false, 0], 
        [1, :folder, "Messages to Sis", false, 0], 
        [1, :folder, "Messages to Me", false, 0], 
           [2, :folder, "2001", false, 0], 
           [2, :folder, "2000", false, 0], 
           [2, :folder, "1999", false, 0], 
     [0, :server, "news.gmane.org", true, 0], 
        [1, :group, "gmane.comp.lang.lua.general", false, 498]
  ].each{|depth, img, text, button, unread|
    if $Version_1_1_OrLater
      item = t.item_create(:button=>button)
    else
      item = t.item_create
      t.item_hasbutton(item, button)
    end
    if img == :folder
      if unread != 0
        t.item_style_set(item, 0, 's4')
        t.item_complex(item, 
                       [['e3', {:text=>text}], ['e4', {:text=>"(#{unread})"}]])
      else
        t.item_style_set(item, 0, 's3')
        t.item_complex(item, [['e2', {:text=>text}]])
      end
    else
      if unread != 0
        t.item_style_set(item, 0, 's2')
        t.item_complex(item, 
                       [
                         ['e1', {:image=>@images["outlook-#{img}"]}], 
                         ['e3', {:text=>text}], 
                         ['e4', {:text=>"(#{unread})"}]
                       ])
      else
        t.item_style_set(item, 0, 's1')
        t.item_complex(item, 
                       [
                         ['e1', {:image=>@images["outlook-#{img}"]}], 
                         ['e2', {:text=>text}]
                       ])
      end
    end
    t.item_lastchild(parentList[depth], item)
    depth += 1
    parentList[depth] = item
  }
end

#demoOutlookNewsgroup(t) ⇒ Object

Demo: Outlook Express newsgroup messages



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'sample/tkextlib/treectrl/outlook-newgroup.rb', line 4

def demoOutlookNewsgroup(t)
  init_pics('outlook-*')

  height = t.font.metrics(:linespace)
  height = 18 if height < 18
  t.configure(:itemheight=>height, :selectmode=>:browse, :showlines=>false, 
              :showroot=>false, :showrootbutton=>false, :showbuttons=>true)

  if $Version_1_1_OrLater
    t.column_create(:image=>@images['outlook-clip'], :tag=>'clip')
    t.column_create(:image=>@images['outlook-arrow'], :tag=>'arrow')
    t.column_create(:image=>@images['outlook-watch'], :tag=>'watch')
    t.column_create(:text=>'Subject', :width=>250, :tag=>'subject')
    t.column_create(:text=>'From', :width=>150, :tag=>'from')
    t.column_create(:text=>'Sent', :width=>150, :tag=>'sent')
    t.column_create(:text=>'Size', :width=>60, :justify=>:right, :tag=>'size')
  else # TreeCtrl 1.0
    t.column_configure(0, :image=>@images['outlook-clip'], :tag=>'clip')
    t.column_configure(1, :image=>@images['outlook-arrow'], :tag=>'arrow')
    t.column_configure(2, :image=>@images['outlook-watch'], :tag=>'watch')
    t.column_configure(3, :text=>'Subject', :width=>250, :tag=>'subject')
    t.column_configure(4, :text=>'From', :width=>150, :tag=>'from')
    t.column_configure(5, :text=>'Sent', :width=>150, :tag=>'sent')
    t.column_configure(6, :text=>'Size', :width=>60, :justify=>:right, 
                       :tag=>'size')
  end

  # Would be nice if I could specify a column -tag too
  t.treecolumn = 3

  # State for a read message
  t.state_define('read')

  # State for a message with unread descendants
  t.state_define('unread')

  t.element_create('elemImg', :image, 
                   :image=>[
                     @sel_images['outlook-read-2'], 
                          ['selected', 'read', 'unread', '!open'], 
                     @images['outlook-read-2'], ['read', 'unread', '!open'],
                     @sel_images['outlook-read'], ['selected', 'read'], 
                     @images['outlook-read'], ['read'], 
                     @sel_images['outlook-unread'], ['selected'], 
                     @images['outlook-unread'], []
                   ])
  t.element_create('elemTxt', :text, :lines=>1, 
                   :fill=>[@SystemHighlightText, ['selected', 'focus']], 
                   :font=>[
                     t.font.dup.weight(:bold), ['read', 'unread', '!open'], 
                     t.font.dup.weight(:bold), ['!read']
                   ])
  t.element_create('sel.e', :rect, :open=>:e, :showfocus=>true, 
                   :fill=>[
                     @SystemHighlight, ['selected', 'focus'], 
                     'gray',  ['selected', '!focus']
                   ])
  t.element_create('sel.w', :rect, :open=>:w, :showfocus=>true, 
                   :fill=>[
                     @SystemHighlight, ['selected', 'focus'], 
                     'gray',  ['selected', '!focus']
                   ])
  t.element_create('sel.we', :rect, :open=>:we, :showfocus=>true, 
                   :fill=>[
                     @SystemHighlight, ['selected', 'focus'], 
                     'gray',  ['selected', '!focus']
                   ])

  # Image + text
  s = t.style_create('s1')
  t.style_elements(s, ['sel.e', 'elemImg', 'elemTxt'])
  t.style_layout(s, 'elemImg', :expand=>:ns)
  t.style_layout(s, 'elemTxt', :padx=>[2,6], :squeeze=>:x, :expand=>:ns)
  t.style_layout(s, 'sel.e', :union=>['elemTxt'], 
                 :iexpand=>:nes, :ipadx=>[2,0])

  # Text
  s = t.style_create('s2.we')
  t.style_elements(s, ['sel.we', 'elemTxt'])
  t.style_layout(s, 'elemTxt', :padx=>6, :squeeze=>:x, :expand=>:ns)
  t.style_layout(s, 'sel.we', :detach=>true, :iexpand=>:es)

  # Text
  s = t.style_create('s2.w')
  t.style_elements(s, ['sel.w', 'elemTxt'])
  t.style_layout(s, 'elemTxt', :padx=>6, :squeeze=>:x, :expand=>:ns)
  t.style_layout(s, 'sel.w', :detach=>true, :iexpand=>:es)

  # Set default item style
  if $Version_1_1_OrLater
    t.defaultstyle = ['', '', '', 's1', 's2.we', 's2.we', 's2.w']
  end

  msgCnt = 100
  thread = 0

  @Message = Hash.new{|k, v| k[v] = Hash.new}
  @Message[:count][0] = 0

  items = [t.index(:root)]

  (1...(msgCnt)).each{|i|
    item_i = t.item_create
    item_j = nil
    j = nil
    loop {
      j = rand(i)
      item_j = items[j]
      break if j == 0
      next if t.depth(item_j) == 5
      next if @Message[:count][@Message[:thread][item_j]] == 15
      break
    }
    t.item_lastchild(item_j, item_i)

    @Message[:read][item_i] = (rand(2) == 0)
    if j == 0
      thread += 1
      @Message[:thread][item_i] = thread
      @Message[:seconds][item_i] = (Tk::Clock.seconds - rand(500000))
      @Message[:seconds2][item_i] = @Message[:seconds][item_i]
      @Message[:count][thread] = 1
    else
      @Message[:thread][item_i] = @Message[:thread][item_j]
      @Message[:seconds][item_i] = (@Message[:seconds2][item_j] + rand(10000))
      @Message[:seconds2][item_i] = @Message[:seconds][item_i]
      @Message[:seconds2][item_j] = @Message[:seconds][item_i]
      @Message[:count][@Message[:thread][item_j]] += 1
    end
    items << item_i
  }

  (1...(msgCnt)).each{|i|
    item_i = items[i]
    subject = "This is thread number #{@Message[:thread][item_i]}"
    from = '[email protected]'
    sent = Tk::Clock.format(@Message[:seconds][item_i], "%d/%m/%y %I:%M %p")
    size = "#{1 + rand(10)}KB"

    # This message has been read
    t.item_state_set(item_i, 'read') if @Message[:read][item_i]

    # This message has unread descendants
    t.item_state_set(item_i, 'unread')  if anyUnreadDescendants(t, item_i)

    if t.item_numchildren(item_i) > 0
      if $Version_1_1_OrLater
        t.item_configure(item_i, :button=>true)
      else # TreeCtrl 1.0
        t.item_hasbutton(item_i, true)
      end

      # Collapse some messages
      if $Version_1_1_OrLater
        t.item_collapse(item_i) if rand(2) == 0
      else # TreeCtrl 1.0
        t.collapse(item_i) if rand(2) == 0
      end
    end

    unless $Version_1_1_OrLater
      t.item_style_set(item_i, 3, 's1', 4, 's2.we', 5, 's2.we', 6, 's2.w')
    end
    t.item_text(item_i, 3, subject, 4, from, 5, sent, 6, size)
  }

  # Do something when the selection changes
  t.notify_bind(t, 'Selection', 
                proc{|w|
                  if w.selection_count == 1
                    # One item is selected
                    if @Message[:afterId][:id]
                      Tk.after_cancel(@Message[:afterId][:id]) 
                    end
                    @Message[:afterId][:item] = w.selection_get[0]
                    @Message[:afterId][:id] = Tk.after(500, proc{
                                                         messageReadDelayed(w)
                                                       })
                  end
                }, '%T')
end

#demoOutlookNewsgroup2(t) ⇒ Object

Alternate implementation which does not rely on run-time states



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
# File 'sample/tkextlib/treectrl/outlook-newgroup.rb', line 206

def demoOutlookNewsgroup2(t)
  init_pics('outlook-*')

  height = t.font.metrics(:linespace)
  height = 18 if height < 18
  t.configure(:itemheight=>height, :selectmode=>:browse, :showlines=>false, 
              :showroot=>false, :showrootbutton=>false, :showbuttons=>true)

  if $Version_1_1_OrLater
    t.column_create(:image=>@images['outlook-clip'], :tag=>'clip')
    t.column_create(:image=>@images['outlook-arrow'], :tag=>'arrow')
    t.column_create(:image=>@images['outlook-watch'], :tag=>'watch')
    t.column_create(:text=>'Subject', :width=>250, :tag=>'subject')
    t.column_create(:text=>'From', :width=>150, :tag=>'from')
    t.column_create(:text=>'Sent', :width=>150, :tag=>'sent')
    t.column_create(:text=>'Size', :width=>60, :justify=>:right, :tag=>'size')
  else # TreeCtrl 1.0
    t.column_configure(0, :image=>@images['outlook-clip'], :tag=>'clip')
    t.column_configure(1, :image=>@images['outlook-arrow'], :tag=>'arrow')
    t.column_configure(2, :image=>@images['outlook-watch'], :tag=>'watch')
    t.column_configure(3, :text=>'Subject', :width=>250, :tag=>'subject')
    t.column_configure(4, :text=>'From', :width=>150, :tag=>'from')
    t.column_configure(5, :text=>'Sent', :width=>150, :tag=>'sent')
    t.column_configure(6, :text=>'Size', :width=>60, :justify=>:right, 
                       :tag=>'size')
  end

  t.treecolumn = 3

  t.element_create('image.unread', :image, :image=>@images['outlook-unread'])
  t.element_create('image.read', :image, :image=>@images['outlook-read'])
  t.element_create('image.read2', :image, :image=>@images['outlook-read-2'])
  t.element_create('text.read', :text, :lines=>1, 
                   :fill=>[@SystemHighlightText, ['selected', 'focus']])
  t.element_create('text.unread', :text, :lines=>1, 
                   :fill=>[@SystemHighlightText, ['selected', 'focus']], 
                   :font=>t.font.dup.weight(:bold))
  t.element_create('sel.e', :rect, :open=>:e, :showfocus=>true, 
                   :fill=>[
                     @SystemHighlight, ['selected', 'focus'], 
                     'gray',  ['selected', '!focus']
                   ])
  t.element_create('sel.w', :rect, :open=>:w, :showfocus=>true, 
                   :fill=>[
                     @SystemHighlight, ['selected', 'focus'], 
                     'gray',  ['selected', '!focus']
                   ])
  t.element_create('sel.we', :rect, :open=>:we, :showfocus=>true, 
                   :fill=>[
                     @SystemHighlight, ['selected', 'focus'], 
                     'gray',  ['selected', '!focus']
                   ])

  # Image + text
  s = t.style_create('unread')
  t.style_elements(s, ['sel.e', 'image.unread', 'text.unread'])
  t.style_layout(s, 'image.unread', :expand=>:ns)
  t.style_layout(s, 'text.unread', :padx=>[2,6], :squeeze=>:x, :expand=>:ns)
  t.style_layout(s, 'sel.e', :union=>['text.unread'], 
                 :iexpand=>:nes, :ipadx=>[2,0])

  # Image + text
  s = t.style_create('read')
  t.style_elements(s, ['sel.e', 'image.read', 'text.read'])
  t.style_layout(s, 'image.read', :expand=>:ns)
  t.style_layout(s, 'text.read', :padx=>[2,6], :squeeze=>:x, :expand=>:ns)
  t.style_layout(s, 'sel.e', :union=>['text.read'], 
                 :iexpand=>:nes, :ipadx=>[2,0])

  # Image + text
  s = t.style_create('read2')
  t.style_elements(s, ['sel.e', 'image.read2', 'text.unread'])
  t.style_layout(s, 'image.read2', :expand=>:ns)
  t.style_layout(s, 'text.unread', :padx=>[2,6], :squeeze=>:x, :expand=>:ns)
  t.style_layout(s, 'sel.e', :union=>['text.unread'], 
                 :iexpand=>:nes, :ipadx=>[2,0])

  # Text
  s = t.style_create('unread.we')
  t.style_elements(s, ['sel.we', 'text.unread'])
  t.style_layout(s, 'text.unread', :padx=>6, :squeeze=>:x, :expand=>:ns)
  t.style_layout(s, 'sel.we', :detach=>true, :iexpand=>:es)

  # Text
  s = t.style_create('read.we')
  t.style_elements(s, ['sel.we', 'text.read'])
  t.style_layout(s, 'text.read', :padx=>6, :squeeze=>:x, :expand=>:ns)
  t.style_layout(s, 'sel.we', :detach=>true, :iexpand=>:es)

  # Text
  s = t.style_create('unread.w')
  t.style_elements(s, ['sel.w', 'text.unread'])
  t.style_layout(s, 'text.unread', :padx=>6, :squeeze=>:x, :expand=>:ns)
  t.style_layout(s, 'sel.w', :detach=>true, :iexpand=>:es)

  # Text
  s = t.style_create('read.w')
  t.style_elements(s, ['sel.w', 'text.read'])
  t.style_layout(s, 'text.read', :padx=>6, :squeeze=>:x, :expand=>:ns)
  t.style_layout(s, 'sel.w', :detach=>true, :iexpand=>:es)

  msgCnt = 100
  thread = 0

  @Message = Hash.new{|k, v| k[v] = Hash.new}
  @Message[:count][0] = 0

  (1...(msgCnt)).each{|i|
    t.item_create
    j = nil
    loop {
      j = rand(i)
      break if j == 0
      next if t.depth(j) == 5
      next if @Message[:count][@Message[:thread][j]] == 15
      break
    }
    t.item_lastchild(j, i)

    @Message[:read][i] = (rand(2) == 0)
    if j == 0
      thread += 1
      @Message[:thread][i] = thread
      @Message[:seconds][i] = (Tk::Clock.seconds - rand(500000))
      @Message[:seconds2][i] = @Message[:seconds][i]
      @Message[:count][thread] = 1
    else
      @Message[:thread][i] = @Message[:thread][j]
      @Message[:seconds][i] = (@Message[:seconds2][j] + rand(10000))
      @Message[:seconds2][i] = @Message[:seconds][i]
      @Message[:seconds2][j] = @Message[:seconds][i]
      @Message[:count][@Message[:thread][j]] += 1
    end
  }

  (1...(msgCnt)).each{|i|
    subject = "This is thread number #{@Message[:thread][i]}"
    from = '[email protected]'
    sent = Tk::Clock.format(@Message[:seconds][i], "%d/%m/%y %I:%M %p")
    size = "#{1 + rand(10)}KB"
    if @Message[:read][i]
      style = 'read'
      style2 = 'read2'
    else
      style = 'unread'
      style2 = 'unread2'
    end
    t.item_style_set(i, 3, style, 4, "#{style2}.we", 5, "#{style2}.we", 
                     6, "#{style2}.w")
    t.item_text(i, 3, subject, 4, from, 5, sent, 6, size)
    if t.item_numchildren(i) > 0
      t.item_configure(item_i, :button=>true)
    end
  }

  # Do something when the selection changes
  t.notify_bind(t, 'Selection', 
                proc{|w|
                  if w.selection_count == 1
                    i = t.selection_get[0]
                    unless @Message[:read][i]
                      if t.item_isopen(i) || !anyUnreadDescendants(t, i)
                        # unread -> read
                        t.item_style_map(i, 'subject', 'read', 
                                         ['text.unread', 'text.read'])
                        t.item_style_map(i, 'from', 'read.we', 
                                         ['text.unread', 'text.read'])
                        t.item_style_map(i, 'sent', 'read.we', 
                                         ['text.unread', 'text.read'])
                        t.item_style_map(i, 'size', 'read.w', 
                                         ['text.unread', 'text.read'])
                      else
                        # unread -> read2
                        t.item_style_map(i, 'subject', 'read2', 
                                         ['text.unread', 'text.unread'])
                      end

                      @Message[:read][i] = true
                      @display_styles_in_item.call(i)
                    end
                  end
                }, '%T')

  t.notify_bind(t, 'Expand-after', 
                proc{|w, i|
                  if @Messge[:read][i] && anyUnreadDescendants(t, i)
                    # read2 -> read
                    t.item_style_map(i, 'subject', 'read', 
                                     ['text.unread', 'text.read'])
                    # unread -> read
                    t.item_style_map(i, 'from', 'read.we', 
                                     ['text.unread', 'text.read'])
                    t.item_style_map(i, 'sent', 'read.we', 
                                     ['text.unread', 'text.read'])
                    t.item_style_map(i, 'size', 'read.w', 
                                     ['text.unread', 'text.read'])
                  end
                }, '%T %I')

  t.notify_bind(t, 'Collapse-after', 
                proc{|w, i|
                  if @Messge[:read][i] && anyUnreadDescendants(t, i)
                    # read -> read2
                    t.item_style_map(i, 'subject', 'read2', 
                                     ['text.read', 'text.unread'])
                    # read -> unread
                    t.item_style_map(i, 'from', 'unread.we', 
                                     ['text.read', 'text.unread'])
                    t.item_style_map(i, 'sent', 'unread.we', 
                                     ['text.read', 'text.unread'])
                    t.item_style_map(i, 'size', 'unread.w', 
                                     ['text.read', 'text.unread'])
                  end
                }, '%T %I')

  (1...(msgCnt)).each{|i|
    if rand(2) == 0
      if t.item_numchildren(i) > 0
        if $Version_1_1_OrLater
          t.item_collapse(i)
        else # TreeCtrl 1.0
          t.collapse(i)
        end
      end
    end
  }
end

#demoRandom(t) ⇒ Object

Demo: random N items



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'sample/tkextlib/treectrl/random.rb', line 9

def demoRandom(t)
  init_pics('folder-*', 'small-*')

  height = t.font.metrics(:linespace)
  height = 18 if height < 18
  t.configure(:itemheight=>height, :selectmode=>:extended, 
              :showroot=>true, :showrootbutton=>true, :showbuttons=>true, 
              :showlines=>true, :scrollmargin=>16, 
              :xscrolldelay=>[500, 50], :yscrolldelay=>[500, 50])

  if $Version_1_1_OrLater
    t.column_create(:expand=>true, :text=>'Item', 
                    :itembackground=>['#e0e8f0', []], :tag=>'item')
    t.column_create(:text=>'Parent', :justify=>:center, 
                    :itembackground=>['gray90', []], :tag=>'parent')
    t.column_create(:text=>'Depth', :justify=>:center, 
                    :itembackground=>['linen', []], :tag=>'depth')
  else # TreeCtrl 1.0
    t.column_configure(0, :expand=>true, :text=>'Item', 
                       :itembackground=>['#e0e8f0', []], :tag=>'item')
    t.column_configure(1, :text=>'Parent', :justify=>:center, 
                       :itembackground=>['gray90', []], :tag=>'parent')
    t.column_configure(2, :text=>'Depth', :justify=>:center, 
                       :itembackground=>['linen', []], :tag=>'depth')
  end

  t.element_create('e1', :image, :image=>[
                     @images['folder-open'], ['open'], 
                     @images['folder-closed'], []
                   ])
  t.element_create('e2', :image, :image=>@images['small-file'])
  t.element_create('e3', :text, 
                   :fill=>[@SystemHighlightText, ['selected', 'focus']])
  t.element_create('e4', :text, :fill=>'blue')
  t.element_create('e6', :text)
  t.element_create('e5', :rect, :showfocus=>true, 
                   :fill=>[
                     @SystemHighlight, ['selected', 'focus'], 
                     'gray', ['selected', '!focus']
                   ])

  s = t.style_create('s1')
  t.style_elements(s, ['e5', 'e1', 'e3', 'e4'])
  t.style_layout(s, 'e1', :padx=>[0,4], :expand=>:ns)
  t.style_layout(s, 'e3', :padx=>[0,4], :expand=>:ns)
  t.style_layout(s, 'e4', :padx=>[0,6], :expand=>:ns)
  t.style_layout(s, 'e5', :union=>['e3'], :iexpand=>:ns, :ipadx=>2)

  s = t.style_create('s2')
  t.style_elements(s, ['e5', 'e2', 'e3'])
  t.style_layout(s, 'e2', :padx=>[0,4], :expand=>:ns)
  t.style_layout(s, 'e3', :padx=>[0,4], :expand=>:ns)
  t.style_layout(s, 'e5', :union=>['e3'], :iexpand=>:ns, :ipadx=>2)

  s = t.style_create('s3')
  t.style_elements(s, ['e6'])
  t.style_layout(s, 'e6', :padx=>6, :expand=>:ns)

  @Priv[:sensitive, t] = [
    [:item, 's1',  'e5', 'e1', 'e3'], 
    [:item, 's2',  'e5', 'e2', 'e3']
  ]
  @Priv[:dragimage, t] = [
    [:item, 's1',  'e1', 'e3'], 
    [:item, 's2',  'e2', 'e3']
  ]

  clicks = Tk::Clock.clicks
  items = [ t.index(:root) ]
  (1...(random_N())).each{|i|
    item_i = t.item_create
    item_j = nil
    loop {
      j = rand(i)
      item_j = items[j]
      break if t.depth(item_j) < 5
    }
    if $Version_1_1_OrLater
      t.item_collapse(item_i) if rand(2) == 0
    else # TreeCtrl 1.0
      t.collapse(item_i) if rand(2) == 0
    end
    if rand(2) == 0
      t.item_lastchild(item_j, item_i)
    else
      t.item_firstchild(item_j, item_i)
    end
    items << item_i
  }
  puts "created #{random_N() - 1} items in #{Tk::Clock.clicks - clicks} clicks"

  clicks = Tk::Clock.clicks
  (0...(random_N())).each{|i|
    item_i = items[i]
    numChildren = t.item_numchildren(item_i)
    if numChildren > 0
      if $Version_1_1_OrLater
        t.item_configure(item_i, :button=>true)
      else # TreeCtrl 1.0
        t.item_hasbutton(item_i, true)
      end
      t.item_style_set(item_i, 0, 's1', 1, 's3', 2, 's3')
      t.item_complex(item_i, 
                     [ ['e3', {:text=>"Item #{i}"}], 
                       ['e4', {:text=>"(#{numChildren})"}] ], 
                     [ ['e6', {:text=>"#{t.item_parent(item_i)}"}] ], 
                     [ ['e6', {:text=>"#{t.depth(item_i)}"}] ])
    else
      t.item_style_set(item_i, 1, 's3', 2, 's3', 0, 's2')
      t.item_complex(item_i, 
                     [ ['e3', {:text=>"Item #{i}"}] ], 
                     [ ['e6', {:text=>"#{t.item_parent(item_i)}"}] ], 
                     [ ['e6', {:text=>"#{t.depth(item_i)}"}] ])
    end
  }
  puts "configured #{random_N()} items in #{Tk::Clock.clicks - clicks} clicks"

  treeCtrlRandom = TkBindTag.new

  treeCtrlRandom.bind('Double-ButtonPress-1', 
                      proc{|w, x, y|
                        Tk::TreeCtrl::BindCallback.doubleButton1(w, x, y)
                        Tk.callback_break
                      }, '%W %x %y')

  treeCtrlRandom.bind('Control-ButtonPress-1', 
                      proc{|w, x, y|
                        @Priv['selectMode'] = :toggle
                        randomButton1(w, x, y)
                        Tk.callback_break
                      }, '%W %x %y')

  treeCtrlRandom.bind('Shift-ButtonPress-1', 
                      proc{|w, x, y|
                        @Priv['selectMode'] = :add
                        randomButton1(w, x, y)
                        Tk.callback_break
                      }, '%W %x %y')

  treeCtrlRandom.bind('ButtonPress-1', 
                      proc{|w, x, y|
                        @Priv['selectMode'] = :set
                        randomButton1(w, x, y)
                        Tk.callback_break
                      }, '%W %x %y')

  treeCtrlRandom.bind('Button1-Motion', 
                      proc{|w, x, y|
                        randomMotion1(w, x, y)
                        Tk.callback_break
                      }, '%W %x %y')

  treeCtrlRandom.bind('Button1-Leave', 
                      proc{|w, x, y|
                        randomLeave1(w, x, y)
                        Tk.callback_break
                      }, '%W %x %y')

  treeCtrlRandom.bind('ButtonRelease-1', 
                      proc{|w, x, y|
                        randomRelease1(w, x, y)
                        Tk.callback_break
                      }, '%W %x %y')

  t.bindtags = [ t, treeCtrlRandom, Tk::TreeCtrl, t.winfo_toplevel, :all ]
end

#demoRandom2(t) ⇒ Object

Demo: random N items, button images



500
501
502
503
504
505
506
507
508
# File 'sample/tkextlib/treectrl/random.rb', line 500

def demoRandom2(t)
  demoRandom(t)

  init_pics('mac-*')

  t.configure(:openbuttonimage=>@images['mac-collapse'], 
              :closedbuttonimage=>@images['mac-expand'], 
              :showlines=>false)
end

#do_motion(x, y) ⇒ Object



30
31
32
33
34
# File 'sample/tkline.rb', line 30

def do_motion(x, y)
  if $current_line
    $current_line.coords $start_x, $start_y, x, y
  end
end

#do_press(x, y) ⇒ Object



24
25
26
27
28
29
# File 'sample/tkline.rb', line 24

def do_press(x, y)
  $start_x = x
  $start_y = y
  $current_line = Line.new($c, x, y, x, y)
  start_random
end

#do_release(x, y) ⇒ Object



36
37
38
39
40
41
42
# File 'sample/tkline.rb', line 36

def do_release(x, y)
  if $current_line
    $current_line.coords $start_x, $start_y, x, y
    $current_line.fill 'black'
    $current_line = nil
  end
end

#drawlinesObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'sample/tcltklib/lines1.rb', line 5

def drawlines()
  print Time.now, "\n"

  for j in 0 .. 99
    print "*"
    $stdout.flush
    if (j & 1) != 0
      col = "blue"
    else
      col = "red"
    end
    for i in 0 .. 99
#      $a.e("create line", i, 0, 0, 500 - i, "-fill", col)
    end
  end

  print Time.now, "\n"

  for j in 0 .. 99
    print "*"
    $stdout.flush
    if (j & 1) != 0
      col = "blue"
    else
      col = "red"
    end
    for i in 0 .. 99
      $a.e("create line", i, 0, 0, 500 - i, "-fill", col)
    end
  end

  print Time.now, "\n"
#  $ip.commands()["destroy"].e($root)
end

#embDefBg(w) ⇒ Object



283
284
285
# File 'sample/demos-en/twind.rb', line 283

def embDefBg (w)
  w['background'] = w.configinfo('background')[3]
end

#embDefBg2(w) ⇒ Object



380
381
382
# File 'sample/demos-en/twind2.rb', line 380

def embDefBg2 (w)
  w['background'] = w.configinfo('background')[3]
end

#embPlotDown(w, x, y) ⇒ Object



258
259
260
261
262
263
264
# File 'sample/demos-en/twind.rb', line 258

def embPlotDown (w, x, y)
  w.dtag 'selected'
  w.addtag_withtag 'selected', 'current'
  w.raise 'current'
  $embPlot['lastX'] = x
  $embPlot['lastY'] = y
end

#embPlotDown2(w, x, y) ⇒ Object



355
356
357
358
359
360
361
# File 'sample/demos-en/twind2.rb', line 355

def embPlotDown2 (w, x, y)
  w.dtag 'selected'
  w.addtag_withtag 'selected', 'current'
  w.raise 'current'
  $embPlot2['lastX'] = x
  $embPlot2['lastY'] = y
end

#embPlotMove(w, x, y) ⇒ Object



266
267
268
269
270
# File 'sample/demos-en/twind.rb', line 266

def embPlotMove (w, x, y)
  w.move 'selected', x - $embPlot['lastX'], y - $embPlot['lastY']
  $embPlot['lastX'] = x
  $embPlot['lastY'] = y
end

#embPlotMove2(w, x, y) ⇒ Object



363
364
365
366
367
# File 'sample/demos-en/twind2.rb', line 363

def embPlotMove2 (w, x, y)
  w.move 'selected', x - $embPlot2['lastX'], y - $embPlot2['lastY']
  $embPlot2['lastX'] = x
  $embPlot2['lastY'] = y
end

#explorerHeaderInvoke(t, w, c) ⇒ Object



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'sample/tkextlib/treectrl/explorer.rb', line 176

def explorerHeaderInvoke(t, w, c)
  if (c == @SortColumn)
    if t.column_cget(@SortColumn, :arrow) == 'down'
      order = :increasing
      arrow = :up
    else
      order = :decreasing
      arrow = :down
    end
  else
    if t.column_cget(@SortColumn, :arrow) == 'down'
      order = :decreasing
      arrow = :down
    else
      order = :increasing
      arrow = :up
    end
    t.column_configure(@SortColumn, :arrow=>:none)
    @SortColumn = c
  end

  t.column_configure(c, :arrow=>arrow)
  dirCount = TkComm.number(@Priv[:DirCnt, t])
  lastDir = dirCount - 1
  case t.column_cget(c, :tag)
  when 'name'
    if dirCount > 0
      t.item_sort(:root, order, {:last=>"root child #{lastDir}"}, 
                  {:column=>c, :dictionary=>true})
    end
    if dirCount < t.numitems - 1
      t.item_sort(:root, order, {:first=>"root child #{dirCount}"}, 
                  {:column=>c, :dictionary=>true})
    end

  when 'size'
    if dirCount < t.numitems - 1
      t.item_sort(:root, order, {:first=>"root child #{dirCount}"}, 
                  {:column=>c, :integer=>true}, 
                  {:column=>'name', :dictionary=>true})
    end

  when 'type'
    if dirCount < t.numitems - 1
      t.item_sort(:root, order, {:first=>"root child #{dirCount}"}, 
                  {:column=>c, :dictionary=>true}, 
                  {:column=>'name', :dictionary=>true})
    end

  when 'modified'
    if dirCount > 0
      t.item_sort(:root, order, {:last=>"root child #{lastDir}"}, 
                  {:column=>c, :integer=>true}, 
                  {:column=>'name', :dictionary=>true})
    end
    if dirCount < t.numitems - 1
      t.item_sort(:root, order, {:first=>"root child #{dirCount}"}, 
                  {:column=>c, :integer=>true}, 
                  {:column=>'name', :dictionary=>true})
    end

  end
end

#fileDialog(w, ent, operation) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'sample/demos-en/filebox.rb', line 67

def fileDialog(w,ent,operation)
  #    Type names         Extension(s)             Mac File Type(s)
  #
  #--------------------------------------------------------
  types = [
    ['Text files',       ['.txt','.doc']          ], 
    ['Text files',       [],                      'TEXT' ], 
    ['Ruby Scripts',     ['.rb'],                 'TEXT' ], 
    ['Tcl Scripts',      ['.tcl'],                'TEXT' ], 
    ['C Source Files',   ['.c','.h']              ], 
    ['All Source Files', ['.rb','.tcl','.c','.h'] ], 
    ['Image Files',      ['.gif']                 ], 
    ['Image Files',      ['.jpeg','.jpg']         ], 
    ['Image Files',      [],                      ['GIFF','JPEG']], 
    ['All files',        '*'                      ]
  ]

  if operation == 'open'
    file = Tk.getOpenFile('filetypes'=>types, 'parent'=>w)
  else
    file = Tk.getSaveFile('filetypes'=>types, 'parent'=>w, 
                          'initialfile'=>'Untitled', 
                          'defaultextension'=>'.txt')
  end
  if file != ""
    ent.delete 0, 'end'
    ent.insert 0, file
    ent.xview 'end'
  end
end

#fill_headers(w, r = 10, c = 10) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'sample/tkextlib/tktable/valid.rb', line 21

def fill_headers(w, r=10, c=10)
  (1..(r-1)).each{|i| w.set([i,0], i.to_s)}

  (1..(c-1)).each{|j|
    if j % 3 == 1
      w.set([0,j], 'AlphaNum')
    elsif j % 2 == 1
      w.set([0,j], 'Alpha')
    elsif j != 0
      w.set([0,j], 'Real')
    end
  }
end

#fill_table(tbl_list, page, r = 10, c = 10) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'sample/tkextlib/tktable/spreadsheet.rb', line 28

def fill_table(tbl_list, page, r=10, c=10)
  ary = tbl_list[page]

  (0...r).each{|i|
    (0...c).each{|j|
      if i!=0 && j!=0
        ary[i,j] = "#{page} #{i},#{j}"
      elsif i!=0
        ary[i,j] = i.to_s
      else
        ary[i,j] = (64+j).chr
      end
    }
  }
end

#fillMenu(menu) ⇒ Object

Side-by side check, radio, and menu button comparison:



340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'sample/tkextlib/tile/demo.rb', line 340

def fillMenu(menu)
  %w(above below left right flush).each{|dir|
    menu.add(:command, :label=>Tk.tk_call('string', 'totitle', dir), 
             :command=>proc{ menu.winfo_parent.direction(dir) })
  }
  menu.add(:cascade, :label=>'Submenu', :menu=>(submenu = TkMenu.new(menu)))
  submenu.add(:command, :label=>'Subcommand 1')
  submenu.add(:command, :label=>'Subcommand 2')
  submenu.add(:command, :label=>'Subcommand 3')

  menu.add(:separator)
  menu.add(:command, :label=>'Quit', :command=>proc{Tk.root.destroy})
end

#fillTree(treeview) ⇒ Object



710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
# File 'sample/tkextlib/tile/demo.rb', line 710

def fillTree(treeview)
  id = treeview.focus_item
  unless TkWinfo.exist?(id)
    treeview.delete(id)
  end
  # Replace tree item children with current list of child windows.
  treeview.delete(treeview.children(id))
  for child in TkWinfo.children(id)
    treeview.insert(id, :end, :id=>child, :text=>TkWinfo.appname(child),
        :open=>false, :values=>[TkWinfo.classname(child)])
    unless TkWinfo.children(child).empty?
      # insert dummy child to show [+] indicator
      treeview.insert(child, :end)
    end
  end
end

#find_framework(tcl_hdr, tk_hdr) ⇒ Object

is_macosx = (/darwin/ =~ RUBY_PLATFORM)



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'extconf.rb', line 8

def find_framework(tcl_hdr, tk_hdr)
  if framework_dir = with_config("tcltk-framework")
    paths = [framework_dir]
  else
    unless tcl_hdr || tk_hdr ||
        enable_config("tcltk-framework", false) ||
        enable_config("mac-tcltk-framework", false)
      return false
    end
    paths = ["/Library/Frameworks", "/System/Library/Frameworks"]
  end

  checking_for('Tcl/Tk Framework') {
    paths.find{|dir|
      dir.strip!
      dir.chomp!('/')
      (tcl_hdr || FileTest.directory?(dir + "/Tcl.framework/") ) &&
        (tk_hdr || FileTest.directory?(dir + "/Tk.framework/") )
    }
  }
end

#find_tcl(tcllib, stubs) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'extconf.rb', line 52

def find_tcl(tcllib, stubs)
  paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
  if stubs
    func = "Tcl_InitStubs"
    lib = "tclstub"
  else
    func = "Tcl_FindExecutable"
    lib = "tcl"
  end
  if tcllib
    find_library(tcllib, func, *paths)
  elsif find_library(lib, func, *paths)
    true
  else
    %w[8.5 8.4 8.3 8.2 8.1 8.0 7.6].find { |ver|
      find_library("#{lib}#{ver}", func, *paths) or
        find_library("#{lib}#{ver.delete('.')}", func, *paths) or
        find_library("tcl#{ver}", func, *paths) or
        find_library("tcl#{ver.delete('.')}", func, *paths)
    }
  end
end

#find_tk(tklib, stubs) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'extconf.rb', line 75

def find_tk(tklib, stubs)
  paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
  if stubs
    func = "Tk_InitStubs"
    lib = "tkstub"
  else
    func = "Tk_Init"
    lib = "tk"
  end
  if tklib
    find_library(tklib, func, *paths)
  elsif find_library(lib, func, *paths)
    true
  else
    %w[8.5 8.4 8.3 8.2 8.1 8.0 4.2].find { |ver|
      find_library("#{lib}#{ver}", func, *paths) or
        find_library("#{lib}#{ver.delete('.')}", func, *paths) or
        find_library("tk#{ver}", func, *paths) or
        find_library("tk#{ver.delete('.')}", func, *paths)
    }
  end
end

#floor2_bg1(w, fill, outline) ⇒ Object

floor2_bg1 – This method represents part of the floorplan database. When invoked, it instantiates the background information for the first floor.

Arguments: w - The canvas window. fill - Fill color to use for the floor’s background. outline - Color to use for the floor’s outline.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'sample/demos-en/floor2.rb', line 101

def floor2_bg1(w,fill,outline)
  w.create(TkcPolygon,347,80,349,82,351,84,353,85,363,92,375,99,386,104,
                 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725,
                 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327,
                 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404,
                 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325,
                 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332,
                 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363,
                 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391,
                 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7,
                 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221,
                 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5,
                 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70,
                 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill)
  w.create(TkcLine,386,129,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,258,355,258,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,60,387,60,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,0,337,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,3,114,3,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,258,387,60,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,484,162,398,162, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,398,162,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,484,278,484,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,484,311,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,508,327,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,559,327,508,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,644,391,559,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,644,389,644,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,559,129,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,484,162,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,725,133,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,559,129,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,725,129,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,802,389,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,3,337,0,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,559,391,559,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,802,389,644,389, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,725,133,725,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,8,25,8,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,8,114,3,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,30,25,8,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,484,278,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,30,25,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,93,5,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,98,5,93,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,104,7,98,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,110,10,104,7, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,116,16,110,10, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,119,20,116,16, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,122,28,119,20, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,123,32,122,28, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,123,68,123,32, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,220,68,123,68, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,386,129,386,104, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,386,104,375,99, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,375,99,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,353,85,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,220,68,220,34, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,337,70,352,56, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,352,56,358,48, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,358,48,363,39, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,363,39,365,29, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,365,29,348,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,348,25,335,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,335,22,321,14, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,321,14,300,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,300,5,283,1, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,283,1,260,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,260,0,246,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,246,0,242,2, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,242,2,236,4, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,236,4,231,8, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,231,8,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,223,17,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,221,22,223,17, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,220,34,221,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,340,360,335,363, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,335,363,331,365, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,331,365,326,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,326,366,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,304,355,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,395,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,404,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,409,290,404,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,413,292,409,290, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,418,297,413,292, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,421,302,418,297, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,422,309,421,302, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,421,318,422,309, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,421,318,417,325, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,417,325,411,330, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,411,330,405,332, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,405,332,397,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,397,333,344,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,344,333,340,334, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,340,334,336,336, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,336,336,335,338, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,335,338,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,331,347,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,332,351,331,347, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,334,354,332,351, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,336,357,334,354, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,341,359,336,357, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,341,359,340,360, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,395,288,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,304,355,258,355, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,347,80,344,76, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,344,76,337,70, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,349,82,347,80, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,351,84,349,82, 'fill'=>outline, 'tags'=>['floor1','bg'])
  w.create(TkcLine,353,85,351,84, 'fill'=>outline, 'tags'=>['floor1','bg'])
end

#floor2_bg2(w, fill, outline) ⇒ Object

floor2_bg2 – This method represents part of the floorplan database. When invoked, it instantiates the background information for the first floor.

Arguments: w - The canvas window. fill - Fill color to use for the floor’s background. outline - Color to use for the floor’s outline.



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'sample/demos-en/floor2.rb', line 225

def floor2_bg2(w,fill,outline)
  w.create(TkcPolygon,559,129,484,129,484,162,398,162,398,129,315,129,
                 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391,
                 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280,
                 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644,
                 367,802,367,802,129,725,129,725,133,559,133,559,129,
                 'tags'=>['floor2','bg'], 'fill'=>fill)
  w.create(TkcLine,350,311,350,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,398,129,398,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,802,367,802,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,802,129,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,725,133,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,559,129,559,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,559,133,725,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,484,162,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,559,129,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,802,367,644,367, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,644,367,644,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,644,391,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,558,327,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,558,327,508,327, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,508,327,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,484,311,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,484,280,484,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,398,162,484,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,484,280,395,280, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,395,280,395,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,258,387,60,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,3,133,3,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,3,339,0,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,0,339,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,60,387,60,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,258,329,258,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,350,329,258,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,395,311,350,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,398,129,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,176,133,315,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,176,129,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,3,133,96,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,315,133,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,176,133,176,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  w.create(TkcLine,96,133,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
end

#floor2_bg3(w, fill, outline) ⇒ Object

floor2_bg3 – This method represents part of the floorplan database. When invoked, it instantiates the background information for the first floor.

Arguments: w - The canvas window. fill - Fill color to use for the floor’s background. outline - Color to use for the floor’s outline.



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'sample/demos-en/floor2.rb', line 280

def floor2_bg3(w,fill,outline)
  w.create(TkcPolygon,159,300,107,300,107,248,159,248,159,129,96,129,96,
                 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300,
                 'tags'=>['floor3','bg'], 'fill'=>fill)
  w.create(TkcPolygon,258,370,258,329,350,329,350,311,399,311,399,129,
                 315,129,315,133,176,133,176,129,159,129,159,370,258,370,
                 'tags'=>['floor3','bg'], 'fill'=>fill)
  w.create(TkcLine,96,133,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,176,129,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,176,129,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,315,133,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,315,133,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,399,129,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,399,311,399,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,399,311,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,350,329,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,350,329,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,258,370,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,60,370,258,370, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,60,370,60,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,0,391,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,21,331,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,21,331,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,96,133,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
  w.create(TkcLine,107,300,159,300,159,248,107,248,107,300, 
              'fill'=>outline, 'tags'=>['floor3','bg'])
end

#floor2_fg1(w, color) ⇒ Object

floor2_fg1 – This method represents part of the floorplan database. When invoked, it instantiates the foreground information for the first floor (office outlines and numbers).

Arguments: w - The canvas window. color - Color to use for drawing foreground information.



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
# File 'sample/demos-en/floor2.rb', line 318

def floor2_fg1(w,color)
  i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '101'
  $floorItems2['101'] = i
  w.create(TkcText,358,209, 'text'=>'101', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = 'Pub Lift1'
  $floorItems2['Pub Lift1'] = i
  w.create(TkcText,323,223, 'text'=>'Pub Lift1', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = 'Priv Lift1'
  $floorItems2['Priv Lift1'] = i
  w.create(TkcText,323,188, 'text'=>'Priv Lift1', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,42,389,42,337,1,337,1,389, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '110'
  $floorItems2['110'] = i
  w.create(TkcText,21.5,363, 'text'=>'110', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,59,389,59,385,90,385,90,337,44,337,44,389, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '109'
  $floorItems2['109'] = i
  w.create(TkcText,67,363, 'text'=>'109', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,51,300,51,253,6,253,6,300, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '111'
  $floorItems2['111'] = i
  w.create(TkcText,28.5,276.5, 'text'=>'111', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,98,248,98,309,79,309,79,248, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '117B'
  $floorItems2['117B'] = i
  w.create(TkcText,88.5,278.5, 'text'=>'117B', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,51,251,51,204,6,204,6,251, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '112'
  $floorItems2['112'] = i
  w.create(TkcText,28.5,227.5, 'text'=>'112', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,6,156,51,156,51,203,6,203, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '113'
  $floorItems2['113'] = i
  w.create(TkcText,28.5,179.5, 'text'=>'113', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,85,169,79,169,79,192,85,192, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '117A'
  $floorItems2['117A'] = i
  w.create(TkcText,82,180.5, 'text'=>'117A', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,77,302,77,168,53,168,53,302, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '117'
  $floorItems2['117'] = i
  w.create(TkcText,65,235, 'text'=>'117', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,51,155,51,115,6,115,6,155, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '114'
  $floorItems2['114'] = i
  w.create(TkcText,28.5,135, 'text'=>'114', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,95,115,53,115,53,168,95,168, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '115'
  $floorItems2['115'] = i
  w.create(TkcText,74,141.5, 'text'=>'115', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,87,113,87,27,10,27,10,113, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '116'
  $floorItems2['116'] = i
  w.create(TkcText,48.5,70, 'text'=>'116', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,89,91,128,91,128,113,89,131, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '118'
  $floorItems2['118'] = i
  w.create(TkcText,108.5,102, 'text'=>'118', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,178,128,178,132,216,132,216,91,
                     163,91,163,112,149,112,149,128, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '120'
  $floorItems2['120'] = i
  w.create(TkcText,189.5,111.5, 'text'=>'120', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,79,193,87,193,87,169,136,169,136,192,
                     156,192,156,169,175,169,175,246,79,246, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '122'
  $floorItems2['122'] = i
  w.create(TkcText,131,207.5, 'text'=>'122', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,138,169,154,169,154,191,138,191, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '121'
  $floorItems2['121'] = i
  w.create(TkcText,146,180, 'text'=>'121', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,99,300,126,300,126,309,99,309, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '106A'
  $floorItems2['106A'] = i
  w.create(TkcText,112.5,304.5, 'text'=>'106A', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,128,299,128,309,150,309,150,248,99,248,99,299, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '105'
  $floorItems2['105'] = i
  w.create(TkcText,124.5,278.5, 'text'=>'105', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,174,309,174,300,152,300,152,309, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '106B'
  $floorItems2['106B'] = i
  w.create(TkcText,163,304.5, 'text'=>'106B', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,176,299,176,309,216,309,216,248,152,248,152,299, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '104'
  $floorItems2['104'] = i
  w.create(TkcText,184,278.5, 'text'=>'104', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,138,385,138,337,91,337,91,385, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '108'
  $floorItems2['108'] = i
  w.create(TkcText,114.5,361, 'text'=>'108', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,256,337,140,337,140,385,256,385, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '107'
  $floorItems2['107'] = i
  w.create(TkcText,198,361, 'text'=>'107', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,300,353,300,329,260,329,260,353, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = 'Smoking'
  $floorItems2['Smoking'] = i
  w.create(TkcText,280,341, 'text'=>'Smoking', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,314,135,314,170,306,170,306,246,177,246,177,135, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '123'
  $floorItems2['123'] = i
  w.create(TkcText,245.5,190.5, 'text'=>'123', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,217,248,301,248,301,326,257,326,257,310,217,310, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '103'
  $floorItems2['103'] = i
  w.create(TkcText,259,287, 'text'=>'103', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,396,188,377,188,377,169,316,169,316,131,396,131, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '124'
  $floorItems2['124'] = i
  w.create(TkcText,356,150, 'text'=>'124', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,397,226,407,226,407,189,377,189,377,246,397,246, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '125'
  $floorItems2['125'] = i
  w.create(TkcText,392,217.5, 'text'=>'125', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,399,187,409,187,409,207,474,207,474,164,399,164, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '126'
  $floorItems2['126'] = i
  w.create(TkcText,436.5,185.5, 'text'=>'126', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,409,209,409,229,399,229,399,253,
                     486,253,486,239,474,239,474,209, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '127'
  $floorItems2['127'] = i
  w.create(TkcText,436.5,'231', 'text'=>'127', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,501,164,501,174,495,174,495,188,
                     490,188,490,204,476,204,476,164, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = 'MShower'
  $floorItems2['MShower'] = i
  w.create(TkcText,488.5,'184', 'text'=>'MShower', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,497,176,513,176,513,204,492,204,492,190,497,190, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = 'Closet'
  $floorItems2['Closet'] = i
  w.create(TkcText,502.5,190, 'text'=>'Closet', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,476,237,476,206,513,206,513,254,488,254,488,237, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = 'WShower'
  $floorItems2['WShower'] = i
  w.create(TkcText,494.5,230, 'text'=>'WShower', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,486,131,558,131,558,135,724,135,724,166,
                     697,166,697,275,553,275,531,254,515,254,
                     515,174,503,174,503,161,486,161, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '130'
  $floorItems2['130'] = i
  w.create(TkcText,638.5,205, 'text'=>'130', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,308,242,339,242,339,248,342,248,
                     342,246,397,246,397,276,393,276,
                     393,309,300,309,300,248,308,248, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '102'
  $floorItems2['102'] = i
  w.create(TkcText,367.5,278.5, 'text'=>'102', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,397,255,486,255,486,276,397,276, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '128'
  $floorItems2['128'] = i
  w.create(TkcText,441.5,265.5, 'text'=>'128', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,510,309,486,309,486,255,530,255,
                     552,277,561,277,561,325,510,325,
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '129'
  $floorItems2['129'] = i
  w.create(TkcText,535.5,293, 'text'=>'129', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,696,281,740,281,740,387,642,387,
                     642,389,561,389,561,277,696,277, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '133'
  $floorItems2['133'] = i
  w.create(TkcText,628.5,335, 'text'=>'133', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,742,387,742,281,800,281,800,387, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '132'
  $floorItems2['132'] = i
  w.create(TkcText,771,334, 'text'=>'132', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,800,168,800,280,699,280,699,168, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '134'
  $floorItems2['134'] = i
  w.create(TkcText,749.5,224, 'text'=>'134', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,726,131,726,166,800,166,800,131, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '135'
  $floorItems2['135'] = i
  w.create(TkcText,763,148.5, 'text'=>'135', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,340,360,335,363,331,365,326,366,304,366,
                     304,312,396,312,396,288,400,288,404,288,
                     409,290,413,292,418,297,421,302,422,309,
                     421,318,417,325,411,330,405,332,397,333,
                     344,333,340,334,336,336,335,338,332,342,
                     331,347,332,351,334,354,336,357,341,359, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = 'Ramona Stair'
  $floorItems2['Ramona Stair'] = i
  w.create(TkcText,368,323, 'text'=>'Ramona Stair', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,30,23,30,5,93,5,98,5,104,7,110,10,116,16,119,20,
                     122,28,123,32,123,68,220,68,220,87,90,87,90,23, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = 'University Stair'
  $floorItems2['University Stair'] = i
  w.create(TkcText,155,77.5, 'text'=>'University Stair', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,282,37,295,40,312,49,323,56,337,70,352,56,
                     358,48,363,39,365,29,348,25,335,22,321,14,
                     300,5,283,1,260,0,246,0,242,2,236,4,231,8,
                     227,13,223,17,221,22,220,34,260,34, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = 'Plaza Stair'
  $floorItems2['Plaza Stair'] = i
  w.create(TkcText,317.5,28.5, 'text'=>'Plaza Stair', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,220,34,260,34,282,37,295,40,312,49,
                     323,56,337,70,350,83,365,94,377,100,
                     386,104,386,128,220,128, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = 'Plaza Deck'
  $floorItems2['Plaza Deck'] = i
  w.create(TkcText,303,81, 'text'=>'Plaza Deck', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,257,336,77,336,6,336,6,301,77,301,77,310,257,310,
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '106'
  $floorItems2['106'] = i
  w.create(TkcText,131.5,318.5, 'text'=>'106', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,146,110,162,110,162,91,130,91,130,115,95,115,
                     95,128,114,128,114,151,157,151,157,153,112,153,
                     112,130,97,130,97,168,175,168,175,131,146,131, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels2[i.id] = '119'
  $floorItems2['119'] = i
  w.create(TkcText,143.5,133, 'text'=>'119', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  w.create(TkcLine,155,191,155,189, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,96,129,96,169, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,78,169,176,169, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,176,247,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,340,247,340,224, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,376,246,376,170, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,307,247,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,147,129,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,202,133,176,133, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,398,129,315,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,258,352,258,387, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,60,387,60,391, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,0,337,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,3,114,3,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,258,387,60,387, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,52,237,52,273, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,52,189,52,225, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,52,140,52,177, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,395,306,395,311, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,531,254,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,475,178,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,502,162,398,162, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,398,129,398,188, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,383,188,376,188, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,408,188,408,194, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,398,227,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,408,227,398,227, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,408,222,408,227, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,408,206,408,210, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,408,208,475,208, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,484,278,484,311, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,484,311,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,508,327,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,559,327,508,327, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,644,391,559,391, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,644,389,644,391, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,514,205,475,205, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,496,189,496,187, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,559,129,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,484,162,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,725,133,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,559,129,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,725,149,725,167, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,725,129,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,802,389,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,739,167,802,167, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,396,188,408,188, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,0,337,9,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,58,337,21,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,43,391,43,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,105,337,75,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,91,387,91,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,154,337,117,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,139,387,139,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,227,337,166,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,258,337,251,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,258,328,302,328, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,302,355,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,395,311,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,484,278,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,395,294,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,473,278,473,275, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,473,256,473,254, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,533,257,531,254, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,553,276,551,274, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,698,276,553,276, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,559,391,559,327, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,802,389,644,389, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,741,314,741,389, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,698,280,698,167, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,707,280,698,280, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,802,280,731,280, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,741,280,741,302, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,698,167,727,167, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,725,137,725,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,514,254,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,496,175,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,502,175,502,162, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,475,166,475,162, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,496,176,496,175, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,491,189,496,189, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,491,205,491,189, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,487,238,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,487,240,487,238, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,487,252,487,254, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,315,133,304,133, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,256,133,280,133, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,78,247,270,247, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,307,247,294,247, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,214,133,232,133, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,217,247,217,266, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,217,309,217,291, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,217,309,172,309, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,154,309,148,309, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,175,300,175,309, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,151,300,175,300, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,151,247,151,309, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,78,237,78,265, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,78,286,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,106,309,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,130,309,125,309, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,99,309,99,247, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,127,299,99,299, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,127,309,127,299, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,155,191,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,137,169,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,78,171,78,169, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,78,190,78,218, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,86,192,86,169, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,86,192,78,192, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,52,301,3,301, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,52,286,52,301, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,52,252,3,252, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,52,203,3,203, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,3,156,52,156, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,8,25,8,114, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,63,114,3,114, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,75,114,97,114, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,108,114,129,114, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,129,114,129,89, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,52,114,52,128, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,132,89,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,88,25,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,88,114,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,218,89,144,89, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,147,111,147,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,162,111,147,111, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,162,109,162,111, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,162,96,162,89, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,218,89,218,94, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,218,89,218,119, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,8,25,88,25, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,258,337,258,328, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,113,129,96,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,302,355,258,355, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,386,104,386,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,377,100,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,365,94,377,100, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,350,83,365,94, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,337,70,350,83, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,337,70,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,312,49,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,295,40,312,49, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,282,37,295,40, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,260,34,282,37, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,253,34,260,34, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,386,128,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
  w.create(TkcLine,113,152,113,129, 'fill'=>color, 'tags'=>['floor1','wall'])
end

#floor2_fg2(w, color) ⇒ Object

floor2_fg2 – This method represents part of the floorplan database. When invoked, it instantiates the foreground information for the second floor (office outlines and numbers).

Arguments: w - The canvas window. color - Color to use for drawing foreground information.



799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
# File 'sample/demos-en/floor2.rb', line 799

def floor2_fg2(w,color)
  i = TkcPolygon.new(w,748,188,755,188,755,205,758,205,758,222,
                     800,222,800,168,748,168, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '238'
  $floorItems2['238'] = i
  w.create(TkcText,774,195, 'text'=>'238', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,726,188,746,188,746,166,800,166,800,131,726,131,
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '237'
  $floorItems2['237'] = i
  w.create(TkcText,763,148.5, 'text'=>'237', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,497,187,497,204,559,204,559,324,641,324,
                     643,324,643,291,641,291,641,205,696,205,
                     696,291,694,291,694,314,715,314,715,291,
                     715,205,755,205,755,190,724,190,724,187, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '246'
  $floorItems2['246'] = i
  w.create(TkcText,600,264, 'text'=>'246', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,694,279,643,279,643,314,694,314, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '247'
  $floorItems2['247'] = i
  w.create(TkcText,668.5,296.5, 'text'=>'247', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,232,250,308,250,308,242,339,242,339,246,
                     397,246,397,255,476,255,476,250,482,250,559,250,
                     559,274,482,274,482,278,396,278,396,274,232,274, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '202'
  $floorItems2['202'] = i
  w.create(TkcText,285.5,260, 'text'=>'202', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,53,228,53,338,176,338,233,338,233,196,
                     306,196,306,180,175,180,175,169,156,169,
                     156,196,176,196,176,228, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '206'
  $floorItems2['206'] = i
  w.create(TkcText,143,267, 'text'=>'206', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,51,277,6,277,6,338,51,338, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '212'
  $floorItems2['212'] = i
  w.create(TkcText,28.5,307.5, 'text'=>'212', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,557,276,486,276,486,309,510,309,510,325,557,325, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '245'
  $floorItems2['245'] = i
  w.create(TkcText,521.5,300.5, 'text'=>'245', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,560,389,599,389,599,326,560,326, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '244'
  $floorItems2['244'] = i
  w.create(TkcText,579.5,357.5, 'text'=>'244', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,601,389,601,326,643,326,643,389, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '243'
  $floorItems2['243'] = i
  w.create(TkcText,622,357.5, 'text'=>'243', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,688,316,645,316,645,365,688,365, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '242'
  $floorItems2['242'] = i
  w.create(TkcText,666.5,340.5, 'text'=>'242', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,802,367,759,367,759,226,802,226, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = 'Barbecue Deck'
  $floorItems2['Barbecue Deck'] = i
  w.create(TkcText,780.5,296.5, 'text'=>'Barbecue Deck', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,755,262,755,314,717,314,717,262, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '240'
  $floorItems2['240'] = i
  w.create(TkcText,736,288, 'text'=>'240', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,755,316,689,316,689,365,755,365, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '241'
  $floorItems2['241'] = i
  w.create(TkcText,722,340.5, 'text'=>'241', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,755,206,717,206,717,261,755,261, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '239'
  $floorItems2['239'] = i
  w.create(TkcText,736,233.5, 'text'=>'239', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,695,277,643,277,643,206,695,206, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '248'
  $floorItems2['248'] = i
  w.create(TkcText,669,241.5, 'text'=>'248', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,676,135,676,185,724,185,724,135, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '236'
  $floorItems2['236'] = i
  w.create(TkcText,700,160, 'text'=>'236', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,675,135,635,135,635,145,628,145,628,185,675,185, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '235'
  $floorItems2['235'] = i
  w.create(TkcText,651.5,160, 'text'=>'235', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,626,143,633,143,633,135,572,135,
                     572,143,579,143,579,185,626,185, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '234'
  $floorItems2['234'] = i
  w.create(TkcText,606,160, 'text'=>'234', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,557,135,571,135,571,145,578,145,
                     578,185,527,185,527,131,557,131, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '233'
  $floorItems2['233'] = i
  w.create(TkcText,552.5,158, 'text'=>'233', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,476,249,557,249,557,205,476,205,
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '230'
  $floorItems2['230'] = i
  w.create(TkcText,516.5,227, 'text'=>'230', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,476,164,486,164,486,131,525,131,525,185,476,185, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '232'
  $floorItems2['232'] = i
  w.create(TkcText,500.5,158, 'text'=>'232', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,476,186,495,186,495,204,476,204, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '229'
  $floorItems2['229'] = i
  w.create(TkcText,485.5,195, 'text'=>'229', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,474,207,409,207,409,187,399,187,399,164,474,164, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '227'
  $floorItems2['227'] = i
  w.create(TkcText,436.5,185.5, 'text'=>'227', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,399,228,399,253,474,253,474,209,409,209,409,228, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '228'
  $floorItems2['228'] = i
  w.create(TkcText,436.5,231, 'text'=>'228', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,397,246,397,226,407,226,407,189,377,189,377,246, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '226'
  $floorItems2['226'] = i
  w.create(TkcText,392,217.5, 'text'=>'226', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,377,169,316,169,316,131,397,131,397,188,377,188, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '225'
  $floorItems2['225'] = i
  w.create(TkcText,356.5,150, 'text'=>'225', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,234,198,306,198,306,249,234,249, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '224'
  $floorItems2['224'] = i
  w.create(TkcText,270,223.5, 'text'=>'224', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,270,179,306,179,306,170,314,170,314,135,270,135, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '223'
  $floorItems2['223'] = i
  w.create(TkcText,292,157, 'text'=>'223', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,268,179,221,179,221,135,268,135, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '222'
  $floorItems2['222'] = i
  w.create(TkcText,244.5,157, 'text'=>'222', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,177,179,219,179,219,135,177,135, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '221'
  $floorItems2['221'] = i
  w.create(TkcText,198,157, 'text'=>'221', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,299,327,349,327,349,284,341,284,341,276,299,276, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '204'
  $floorItems2['204'] = i
  w.create(TkcText,324,301.5, 'text'=>'204', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,234,276,297,276,297,327,257,327,257,338,234,338, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '205'
  $floorItems2['205'] = i
  w.create(TkcText,265.5,307, 'text'=>'205', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,256,385,256,340,212,340,212,385,
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '207'
  $floorItems2['207'] = i
  w.create(TkcText,234,362.5, 'text'=>'207', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,210,340,164,340,164,385,210,385, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '208'
  $floorItems2['208'] = i
  w.create(TkcText,187,362.5, 'text'=>'208', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,115,340,162,340,162,385,115,385, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '209'
  $floorItems2['209'] = i
  w.create(TkcText,138.5,362.5, 'text'=>'209', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,89,228,89,156,53,156,53,228, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '217'
  $floorItems2['217'] = i
  w.create(TkcText,71,192, 'text'=>'217', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,89,169,97,169,97,190,89,190, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '217A'
  $floorItems2['217A'] = i
  w.create(TkcText,93,179.5, 'text'=>'217A', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,89,156,89,168,95,168,95,135,53,135,53,156, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '216'
  $floorItems2['216'] = i
  w.create(TkcText,71,145.5, 'text'=>'216', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,51,179,51,135,6,135,6,179, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '215'
  $floorItems2['215'] = i
  w.create(TkcText,28.5,157, 'text'=>'215', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,51,227,6,227,6,180,51,180, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '214'
  $floorItems2['214'] = i
  w.create(TkcText,28.5,203.5, 'text'=>'214', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,51,275,6,275,6,229,51,229, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '213'
  $floorItems2['213'] = i
  w.create(TkcText,28.5,252, 'text'=>'213', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,114,340,67,340,67,385,114,385, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '210'
  $floorItems2['210'] = i
  w.create(TkcText,90.5,362.5, 'text'=>'210', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,59,389,59,385,65,385,65,340,1,340,1,389, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '211'
  $floorItems2['211'] = i
  w.create(TkcText,33,364.5, 'text'=>'211', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,393,309,350,309,350,282,342,282,342,276,393,276, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '203'
  $floorItems2['203'] = i
  w.create(TkcText,367.5,292.5, 'text'=>'203', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,99,191,91,191,91,226,174,226,174,198,
                     154,198,154,192,109,192,109,169,99,169, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '220'
  $floorItems2['220'] = i
  w.create(TkcText,132.5,208.5, 'text'=>'220', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = 'Priv Lift2'
  $floorItems2['Priv Lift2'] = i
  w.create(TkcText,323,188, 'text'=>'Priv Lift2', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = 'Pub Lift 2'
  $floorItems2['Pub Lift 2'] = i
  w.create(TkcText,323,223, 'text'=>'Pub Lift 2', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,175,168,97,168,97,131,175,131, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '218'
  $floorItems2['218'] = i
  w.create(TkcText,136,149.5, 'text'=>'218', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,154,191,111,191,111,169,154,169, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '219'
  $floorItems2['219'] = i
  w.create(TkcText,132.5,180, 'text'=>'219', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels2[i.id] = '201'
  $floorItems2['201'] = i
  w.create(TkcText,358,209, 'text'=>'201', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  w.create(TkcLine,641,186,678,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,757,350,757,367, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,634,133,634,144, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,634,144,627,144, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,572,133,572,144, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,572,144,579,144, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,398,129,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,174,197,175,197, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,175,197,175,227, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,757,206,757,221, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,396,188,408,188, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,727,189,725,189, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,747,167,802,167, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,747,167,747,189, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,755,189,739,189, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,769,224,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,802,224,802,129, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,802,129,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,725,189,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,725,186,690,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,676,133,676,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,627,144,627,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,629,186,593,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,579,144,579,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,559,129,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,725,133,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,484,162,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,559,129,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,526,129,526,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,540,186,581,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,528,186,523,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,511,186,475,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,496,190,496,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,496,205,496,202, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,475,205,527,205, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,558,205,539,205, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,558,205,558,249, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,558,249,475,249, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,662,206,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,695,206,675,206, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,695,278,642,278, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,642,291,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,695,291,695,206, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,716,208,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,757,206,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,757,221,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,793,224,802,224, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,757,262,716,262, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,716,220,716,264, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,716,315,716,276, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,757,315,703,315, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,757,325,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,757,367,644,367, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,689,367,689,315, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,647,315,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,659,315,691,315, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,600,325,600,391, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,627,325,644,325, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,644,391,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,615,325,575,325, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,644,391,558,391, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,563,325,558,325, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,558,391,558,314, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,558,327,508,327, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,558,275,484,275, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,558,302,558,275, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,508,327,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,484,311,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,484,275,484,311, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,475,208,408,208, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,408,206,408,210, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,408,222,408,227, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,408,227,398,227, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,398,227,398,254, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,408,188,408,194, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,383,188,376,188, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,398,188,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,398,162,484,162, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,475,162,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,398,254,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,484,280,395,280, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,395,311,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,307,197,293,197, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,278,197,233,197, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,233,197,233,249, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,307,179,284,179, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,233,249,278,249, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,269,179,269,133, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,220,179,220,133, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,155,191,110,191, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,90,190,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,98,169,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,52,133,52,165, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,52,214,52,177, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,52,226,52,262, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,52,274,52,276, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,234,275,234,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,226,339,258,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,211,387,211,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,214,339,177,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,258,387,60,387, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,3,133,3,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,165,339,129,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,117,339,80,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,68,339,59,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,0,339,46,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,0,339,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,60,387,60,391, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,258,329,258,387, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,350,329,258,329, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,395,311,350,311, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,398,129,315,129, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,176,133,315,133, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,176,129,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,3,133,96,133, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,66,387,66,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,115,387,115,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,163,387,163,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,234,275,276,275, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,288,275,309,275, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,298,275,298,329, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,341,283,350,283, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,321,275,341,275, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,375,275,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,307,250,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,376,245,376,170, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,340,245,340,224, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,293,250,307,250, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,271,179,238,179, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,226,179,195,179, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,176,129,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,182,179,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,174,169,176,169, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,162,169,90,169, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,96,169,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,175,227,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,90,190,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,52,179,3,179, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,52,228,3,228, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,52,276,3,276, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,110,191,110,169, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,155,189,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,350,283,350,329, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,162,197,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
  w.create(TkcLine,341,275,341,283, 'fill'=>color, 'tags'=>['floor2','wall'])
end

#floor2_fg3(w, color) ⇒ Object

floor2_fg3 – This method represents part of the floorplan database. When invoked, it instantiates the foreground information for the third floor (office outlines and numbers).

Arguments: w - The canvas window. color - Color to use for drawing foreground information.



1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
# File 'sample/demos-en/floor2.rb', line 1281

def floor2_fg3(w,color)
  i = TkcPolygon.new(w,89,228,89,180,70,180,70,228,
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '316'
  $floorItems2['316'] = i
  w.create(TkcText,79.5,204, 'text'=>'316', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,115,368,162,368,162,323,115,323, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '309'
  $floorItems2['309'] = i
  w.create(TkcText,138.5,345.5, 'text'=>'309', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,164,323,164,368,211,368,211,323, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '308'
  $floorItems2['308'] = i
  w.create(TkcText,187.5,345.5, 'text'=>'308', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,256,368,212,368,212,323,256,323, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '307'
  $floorItems2['307'] = i
  w.create(TkcText,234,345.5, 'text'=>'307', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,244,276,297,276,297,327,260,327,260,321,244,321, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '305'
  $floorItems2['305'] = i
  w.create(TkcText,270.5,301.5, 'text'=>'305', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,251,219,251,203,244,203,244,219,
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '324B'
  $floorItems2['324B'] = i
  w.create(TkcText,247.5,211, 'text'=>'324B', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,251,249,244,249,244,232,251,232, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '324A'
  $floorItems2['324A'] = i
  w.create(TkcText,247.5,240.5, 'text'=>'324A', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,223,135,223,179,177,179,177,135, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '320'
  $floorItems2['320'] = i
  w.create(TkcText,200,157, 'text'=>'320', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,114,368,114,323,67,323,67,368, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '310'
  $floorItems2['310'] = i
  w.create(TkcText,90.5,345.5, 'text'=>'310', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,23,277,23,321,68,321,68,277, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '312'
  $floorItems2['312'] = i
  w.create(TkcText,45.5,299, 'text'=>'312', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,23,229,68,229,68,275,23,275, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '313'
  $floorItems2['313'] = i
  w.create(TkcText,45.5,252, 'text'=>'313', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,68,227,23,227,23,180,68,180, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '314'
  $floorItems2['314'] = i
  w.create(TkcText,40.5,203.5, 'text'=>'314', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,95,179,95,135,23,135,23,179, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '315'
  $floorItems2['315'] = i
  w.create(TkcText,59,157, 'text'=>'315', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,99,226,99,204,91,204,91,226, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '316B'
  $floorItems2['316B'] = i
  w.create(TkcText,95,215, 'text'=>'316B', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,91,202,99,202,99,180,91,180, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '316A'
  $floorItems2['316A'] = i
  w.create(TkcText,95,191, 'text'=>'316A', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,97,169,109,169,109,192,154,192,154,198,
                     174,198,174,226,101,226,101,179,97,179, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '319'
  $floorItems2['319'] = i
  w.create(TkcText,141.5,209, 'text'=>'319', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,65,368,58,368,58,389,1,389,1,333,23,333,23,323,65,323, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '311'
  $floorItems2['311'] = i
  w.create(TkcText,29.5,361, 'text'=>'311', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,154,191,111,191,111,169,154,169, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '318'
  $floorItems2['318'] = i
  w.create(TkcText,132.5,180, 'text'=>'318', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,175,168,97,168,97,131,175,131, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '317'
  $floorItems2['317'] = i
  w.create(TkcText,136,149.5, 'text'=>'317', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,274,194,274,221,306,221,306,194, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '323'
  $floorItems2['323'] = i
  w.create(TkcText,290,207.5, 'text'=>'323', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,306,222,274,222,274,249,306,249, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '325'
  $floorItems2['325'] = i
  w.create(TkcText,290,235.5, 'text'=>'325', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,263,179,224,179,224,135,263,135, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '321'
  $floorItems2['321'] = i
  w.create(TkcText,243.5,157, 'text'=>'321', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,314,169,306,169,306,192,273,192,
                     264,181,264,135,314,135, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '322'
  $floorItems2['322'] = i
  w.create(TkcText,293.5,163.5, 'text'=>'322', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = 'Pub Lift3'
  $floorItems2['Pub Lift3'] = i
  w.create(TkcText,323,223, 'text'=>'Pub Lift3', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = 'Priv Lift3'
  $floorItems2['Priv Lift3'] = i
  w.create(TkcText,323,188, 'text'=>'Priv Lift3', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,350,284,376,284,376,276,397,276,397,309,350,309, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '303'
  $floorItems2['303'] = i
  w.create(TkcText,373.5,292.5, 'text'=>'303', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,272,203,272,249,252,249,252,230,
                     244,230,244,221,252,221,252,203, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '324'
  $floorItems2['324'] = i
  w.create(TkcText,262,226, 'text'=>'324', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,299,276,299,327,349,327,349,284,341,284,341,276, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '304'
  $floorItems2['304'] = i
  w.create(TkcText,324,301.5, 'text'=>'304', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '301'
  $floorItems2['301'] = i
  w.create(TkcText,358,209, 'text'=>'301', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,397,246,377,246,377,185,397,185, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '327'
  $floorItems2['327'] = i
  w.create(TkcText,387,215.5, 'text'=>'327', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,316,131,316,169,377,169,377,185,397,185,397,131, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '326'
  $floorItems2['326'] = i
  w.create(TkcText,365.5,150, 'text'=>'326', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,308,251,242,251,242,274,342,274,342,282,375, 282,
                     375,274,397,274,397,248,339,248,339,242,308,242, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '302'
  $floorItems2['302'] = i
  w.create(TkcText,319.5,261, 'text'=>'302', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,70,321,242,321,242,200,259,200,259,203,272,203,
                     272,193,263,180,242,180,175,180,175,169,156,169,
                     156,196,177,196,177,228,107,228,70,228,70,275,107,275,
                     107,248,160,248,160,301,107,301,107,275,70,275, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels2[i.id] = '306'
  $floorItems2['306'] = i
  w.create(TkcText,200.5,284.5, 'text'=>'306', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  w.create(TkcLine,341,275,341,283, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,162,197,155,197, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,396,247,399,247, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,399,129,399,311, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,258,202,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,350,283,350,329, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,251,231,243,231, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,243,220,251,220, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,243,250,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,155,197,155,190, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,110,192,110,169, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,155,192,110,192, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,176,197,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,69,280,69,274, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,21,276,69,276, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,69,262,69,226, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,21,228,69,228, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,21,179,75,179, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,69,179,69,214, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,90,220,90,227, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,90,204,90,202, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,90,203,100,203, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,90,187,90,179, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,90,227,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,100,179,100,227, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,100,179,87,179, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,96,179,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,162,169,96,169, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,173,169,176,169, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,182,179,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,176,129,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,195,179,226,179, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,224,133,224,179, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,264,179,264,133, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,238,179,264,179, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,273,207,273,193, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,273,235,273,250, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,273,224,273,219, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,273,193,307,193, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,273,222,307,222, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,384,247,376,247, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,340,247,340,224, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,376,247,376,170, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,307,250,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,376,283,366,283, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,376,283,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,399,275,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,341,275,320,275, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,341,283,350,283, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,298,275,298,329, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,308,275,298,275, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,243,322,243,275, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,243,275,284,275, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,258,322,226,322, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,212,370,212,322, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,214,322,177,322, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,163,370,163,322, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,165,322,129,322, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,84,322,117,322, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,71,322,64,322, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,115,322,115,370, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,66,322,66,370, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,52,322,21,322, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,21,331,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,21,331,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,96,133,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,176,129,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,315,133,176,133, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,315,129,399,129, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,399,311,350,311, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,350,329,258,329, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,258,322,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,60,370,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,60,370,60,391, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,0,391,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,307,250,307,242, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
  w.create(TkcLine,258,250,243,250, 'fill'=>color, 'tags'=>['floor3','wall'])
end

#floor_bg1(w, fill, outline) ⇒ Object

floor_bg1 – This method represents part of the floorplan database. When invoked, it instantiates the background information for the first floor.

Arguments: w - The canvas window. fill - Fill color to use for the floor’s background. outline - Color to use for the floor’s outline.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'sample/demos-en/floor.rb', line 101

def floor_bg1(w,fill,outline)
  TkcPolygon.new(w,347,80,349,82,351,84,353,85,363,92,375,99,386,104,
                 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725,
                 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327,
                 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404,
                 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325,
                 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332,
                 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363,
                 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391,
                 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7,
                 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221,
                 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5,
                 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70,
                 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill)
  TkcLine.new(w,386,129,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,258,355,258,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,60,387,60,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,0,337,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,3,114,3,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,258,387,60,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,484,162,398,162, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,398,162,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,484,278,484,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,484,311,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,508,327,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,559,327,508,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,644,391,559,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,644,389,644,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,559,129,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,484,162,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,725,133,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,559,129,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,725,129,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,802,389,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,3,337,0,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,559,391,559,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,802,389,644,389, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,725,133,725,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,8,25,8,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,8,114,3,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,30,25,8,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,484,278,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,30,25,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,93,5,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,98,5,93,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,104,7,98,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,110,10,104,7, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,116,16,110,10, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,119,20,116,16, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,122,28,119,20, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,123,32,122,28, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,123,68,123,32, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,220,68,123,68, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,386,129,386,104, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,386,104,375,99, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,375,99,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,353,85,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,220,68,220,34, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,337,70,352,56, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,352,56,358,48, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,358,48,363,39, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,363,39,365,29, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,365,29,348,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,348,25,335,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,335,22,321,14, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,321,14,300,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,300,5,283,1, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,283,1,260,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,260,0,246,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,246,0,242,2, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,242,2,236,4, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,236,4,231,8, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,231,8,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,223,17,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,221,22,223,17, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,220,34,221,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,340,360,335,363, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,335,363,331,365, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,331,365,326,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,326,366,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,304,355,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,395,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,404,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,409,290,404,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,413,292,409,290, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,418,297,413,292, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,421,302,418,297, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,422,309,421,302, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,421,318,422,309, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,421,318,417,325, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,417,325,411,330, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,411,330,405,332, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,405,332,397,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,397,333,344,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,344,333,340,334, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,340,334,336,336, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,336,336,335,338, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,335,338,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,331,347,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,332,351,331,347, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,334,354,332,351, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,336,357,334,354, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,341,359,336,357, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,341,359,340,360, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,395,288,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,304,355,258,355, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,347,80,344,76, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,344,76,337,70, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,349,82,347,80, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,351,84,349,82, 'fill'=>outline, 'tags'=>['floor1','bg'])
  TkcLine.new(w,353,85,351,84, 'fill'=>outline, 'tags'=>['floor1','bg'])
end

#floor_bg2(w, fill, outline) ⇒ Object

floor_bg2 – This method represents part of the floorplan database. When invoked, it instantiates the background information for the first floor.

Arguments: w - The canvas window. fill - Fill color to use for the floor’s background. outline - Color to use for the floor’s outline.



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'sample/demos-en/floor.rb', line 225

def floor_bg2(w,fill,outline)
  TkcPolygon.new(w,559,129,484,129,484,162,398,162,398,129,315,129,
                 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391,
                 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280,
                 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644,
                 367,802,367,802,129,725,129,725,133,559,133,559,129,
                 'tags'=>['floor2','bg'], 'fill'=>fill)
  TkcLine.new(w,350,311,350,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,398,129,398,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,802,367,802,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,802,129,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,725,133,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,559,129,559,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,559,133,725,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,484,162,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,559,129,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,802,367,644,367, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,644,367,644,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,644,391,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,558,327,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,558,327,508,327, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,508,327,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,484,311,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,484,280,484,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,398,162,484,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,484,280,395,280, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,395,280,395,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,258,387,60,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,3,133,3,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,3,339,0,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,0,339,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,60,387,60,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,258,329,258,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,350,329,258,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,395,311,350,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,398,129,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,176,133,315,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,176,129,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,3,133,96,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,315,133,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,176,133,176,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
  TkcLine.new(w,96,133,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
end

#floor_bg3(w, fill, outline) ⇒ Object

floor_bg3 – This method represents part of the floorplan database. When invoked, it instantiates the background information for the first floor.

Arguments: w - The canvas window. fill - Fill color to use for the floor’s background. outline - Color to use for the floor’s outline.



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'sample/demos-en/floor.rb', line 280

def floor_bg3(w,fill,outline)
  TkcPolygon.new(w,159,300,107,300,107,248,159,248,159,129,96,129,96,
                 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300,
                 'tags'=>['floor3','bg'], 'fill'=>fill)
  TkcPolygon.new(w,258,370,258,329,350,329,350,311,399,311,399,129,
                 315,129,315,133,176,133,176,129,159,129,159,370,258,370,
                 'tags'=>['floor3','bg'], 'fill'=>fill)
  TkcLine.new(w,96,133,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,176,129,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,176,129,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,315,133,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,315,133,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,399,129,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,399,311,399,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,399,311,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,350,329,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,350,329,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,258,370,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,60,370,258,370, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,60,370,60,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,0,391,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,21,331,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,21,331,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,96,133,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
  TkcLine.new(w,107,300,159,300,159,248,107,248,107,300, 
              'fill'=>outline, 'tags'=>['floor3','bg'])
end

#floor_fg1(w, color) ⇒ Object

floor_fg1 – This method represents part of the floorplan database. When invoked, it instantiates the foreground information for the first floor (office outlines and numbers).

Arguments: w - The canvas window. color - Color to use for drawing foreground information.



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
# File 'sample/demos-en/floor.rb', line 318

def floor_fg1(w,color)
  i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '101'
  $floorItems['101'] = i
  TkcText.new(w,358,209, 'text'=>'101', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = 'Pub Lift1'
  $floorItems['Pub Lift1'] = i
  TkcText.new(w,323,223, 'text'=>'Pub Lift1', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = 'Priv Lift1'
  $floorItems['Priv Lift1'] = i
  TkcText.new(w,323,188, 'text'=>'Priv Lift1', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,42,389,42,337,1,337,1,389, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '110'
  $floorItems['110'] = i
  TkcText.new(w,21.5,363, 'text'=>'110', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,59,389,59,385,90,385,90,337,44,337,44,389, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '109'
  $floorItems['109'] = i
  TkcText.new(w,67,363, 'text'=>'109', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,51,300,51,253,6,253,6,300, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '111'
  $floorItems['111'] = i
  TkcText.new(w,28.5,276.5, 'text'=>'111', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,98,248,98,309,79,309,79,248, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '117B'
  $floorItems['117B'] = i
  TkcText.new(w,88.5,278.5, 'text'=>'117B', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,51,251,51,204,6,204,6,251, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '112'
  $floorItems['112'] = i
  TkcText.new(w,28.5,227.5, 'text'=>'112', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,6,156,51,156,51,203,6,203, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '113'
  $floorItems['113'] = i
  TkcText.new(w,28.5,179.5, 'text'=>'113', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,85,169,79,169,79,192,85,192, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '117A'
  $floorItems['117A'] = i
  TkcText.new(w,82,180.5, 'text'=>'117A', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,77,302,77,168,53,168,53,302, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '117'
  $floorItems['117'] = i
  TkcText.new(w,65,235, 'text'=>'117', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,51,155,51,115,6,115,6,155, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '114'
  $floorItems['114'] = i
  TkcText.new(w,28.5,135, 'text'=>'114', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,95,115,53,115,53,168,95,168, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '115'
  $floorItems['115'] = i
  TkcText.new(w,74,141.5, 'text'=>'115', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,87,113,87,27,10,27,10,113, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '116'
  $floorItems['116'] = i
  TkcText.new(w,48.5,70, 'text'=>'116', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,89,91,128,91,128,113,89,131, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '118'
  $floorItems['118'] = i
  TkcText.new(w,108.5,102, 'text'=>'118', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,178,128,178,132,216,132,216,91,
                     163,91,163,112,149,112,149,128, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '120'
  $floorItems['120'] = i
  TkcText.new(w,189.5,111.5, 'text'=>'120', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,79,193,87,193,87,169,136,169,136,192,
                     156,192,156,169,175,169,175,246,79,246, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '122'
  $floorItems['122'] = i
  TkcText.new(w,131,207.5, 'text'=>'122', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,138,169,154,169,154,191,138,191, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '121'
  $floorItems['121'] = i
  TkcText.new(w,146,180, 'text'=>'121', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,99,300,126,300,126,309,99,309, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '106A'
  $floorItems['106A'] = i
  TkcText.new(w,112.5,304.5, 'text'=>'106A', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,128,299,128,309,150,309,150,248,99,248,99,299, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '105'
  $floorItems['105'] = i
  TkcText.new(w,124.5,278.5, 'text'=>'105', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,174,309,174,300,152,300,152,309, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '106B'
  $floorItems['106B'] = i
  TkcText.new(w,163,304.5, 'text'=>'106B', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,176,299,176,309,216,309,216,248,152,248,152,299, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '104'
  $floorItems['104'] = i
  TkcText.new(w,184,278.5, 'text'=>'104', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,138,385,138,337,91,337,91,385, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '108'
  $floorItems['108'] = i
  TkcText.new(w,114.5,361, 'text'=>'108', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,256,337,140,337,140,385,256,385, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '107'
  $floorItems['107'] = i
  TkcText.new(w,198,361, 'text'=>'107', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,300,353,300,329,260,329,260,353, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = 'Smoking'
  $floorItems['Smoking'] = i
  TkcText.new(w,280,341, 'text'=>'Smoking', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,314,135,314,170,306,170,306,246,177,246,177,135, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '123'
  $floorItems['123'] = i
  TkcText.new(w,245.5,190.5, 'text'=>'123', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,217,248,301,248,301,326,257,326,257,310,217,310, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '103'
  $floorItems['103'] = i
  TkcText.new(w,259,287, 'text'=>'103', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,396,188,377,188,377,169,316,169,316,131,396,131, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '124'
  $floorItems['124'] = i
  TkcText.new(w,356,150, 'text'=>'124', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,397,226,407,226,407,189,377,189,377,246,397,246, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '125'
  $floorItems['125'] = i
  TkcText.new(w,392,217.5, 'text'=>'125', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,399,187,409,187,409,207,474,207,474,164,399,164, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '126'
  $floorItems['126'] = i
  TkcText.new(w,436.5,185.5, 'text'=>'126', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,409,209,409,229,399,229,399,253,
                     486,253,486,239,474,239,474,209, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '127'
  $floorItems['127'] = i
  TkcText.new(w,436.5,'231', 'text'=>'127', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,501,164,501,174,495,174,495,188,
                     490,188,490,204,476,204,476,164, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = 'MShower'
  $floorItems['MShower'] = i
  TkcText.new(w,488.5,'184', 'text'=>'MShower', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,497,176,513,176,513,204,492,204,492,190,497,190, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = 'Closet'
  $floorItems['Closet'] = i
  TkcText.new(w,502.5,190, 'text'=>'Closet', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,476,237,476,206,513,206,513,254,488,254,488,237, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = 'WShower'
  $floorItems['WShower'] = i
  TkcText.new(w,494.5,230, 'text'=>'WShower', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,486,131,558,131,558,135,724,135,724,166,
                     697,166,697,275,553,275,531,254,515,254,
                     515,174,503,174,503,161,486,161, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '130'
  $floorItems['130'] = i
  TkcText.new(w,638.5,205, 'text'=>'130', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,308,242,339,242,339,248,342,248,
                     342,246,397,246,397,276,393,276,
                     393,309,300,309,300,248,308,248, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '102'
  $floorItems['102'] = i
  TkcText.new(w,367.5,278.5, 'text'=>'102', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,397,255,486,255,486,276,397,276, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '128'
  $floorItems['128'] = i
  TkcText.new(w,441.5,265.5, 'text'=>'128', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,510,309,486,309,486,255,530,255,
                     552,277,561,277,561,325,510,325,
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '129'
  $floorItems['129'] = i
  TkcText.new(w,535.5,293, 'text'=>'129', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,696,281,740,281,740,387,642,387,
                     642,389,561,389,561,277,696,277, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '133'
  $floorItems['133'] = i
  TkcText.new(w,628.5,335, 'text'=>'133', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,742,387,742,281,800,281,800,387, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '132'
  $floorItems['132'] = i
  TkcText.new(w,771,334, 'text'=>'132', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,800,168,800,280,699,280,699,168, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '134'
  $floorItems['134'] = i
  TkcText.new(w,749.5,224, 'text'=>'134', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,726,131,726,166,800,166,800,131, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '135'
  $floorItems['135'] = i
  TkcText.new(w,763,148.5, 'text'=>'135', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,340,360,335,363,331,365,326,366,304,366,
                     304,312,396,312,396,288,400,288,404,288,
                     409,290,413,292,418,297,421,302,422,309,
                     421,318,417,325,411,330,405,332,397,333,
                     344,333,340,334,336,336,335,338,332,342,
                     331,347,332,351,334,354,336,357,341,359, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = 'Ramona Stair'
  $floorItems['Ramona Stair'] = i
  TkcText.new(w,368,323, 'text'=>'Ramona Stair', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,30,23,30,5,93,5,98,5,104,7,110,10,116,16,119,20,
                     122,28,123,32,123,68,220,68,220,87,90,87,90,23, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = 'University Stair'
  $floorItems['University Stair'] = i
  TkcText.new(w,155,77.5, 'text'=>'University Stair', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,282,37,295,40,312,49,323,56,337,70,352,56,
                     358,48,363,39,365,29,348,25,335,22,321,14,
                     300,5,283,1,260,0,246,0,242,2,236,4,231,8,
                     227,13,223,17,221,22,220,34,260,34, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = 'Plaza Stair'
  $floorItems['Plaza Stair'] = i
  TkcText.new(w,317.5,28.5, 'text'=>'Plaza Stair', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,220,34,260,34,282,37,295,40,312,49,
                     323,56,337,70,350,83,365,94,377,100,
                     386,104,386,128,220,128, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = 'Plaza Deck'
  $floorItems['Plaza Deck'] = i
  TkcText.new(w,303,81, 'text'=>'Plaza Deck', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,257,336,77,336,6,336,6,301,77,301,77,310,257,310,
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '106'
  $floorItems['106'] = i
  TkcText.new(w,131.5,318.5, 'text'=>'106', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  i = TkcPolygon.new(w,146,110,162,110,162,91,130,91,130,115,95,115,
                     95,128,114,128,114,151,157,151,157,153,112,153,
                     112,130,97,130,97,168,175,168,175,131,146,131, 
                     'fill'=>'', 'tags'=>['floor1','room'])
  $floorLabels[i.id] = '119'
  $floorItems['119'] = i
  TkcText.new(w,143.5,133, 'text'=>'119', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor1','label'])
  TkcLine.new(w,155,191,155,189, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,96,129,96,169, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,78,169,176,169, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,176,247,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,340,247,340,224, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,376,246,376,170, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,307,247,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,147,129,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,202,133,176,133, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,398,129,315,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,258,352,258,387, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,60,387,60,391, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,0,337,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,3,114,3,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,258,387,60,387, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,52,237,52,273, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,52,189,52,225, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,52,140,52,177, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,395,306,395,311, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,531,254,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,475,178,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,502,162,398,162, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,398,129,398,188, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,383,188,376,188, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,408,188,408,194, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,398,227,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,408,227,398,227, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,408,222,408,227, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,408,206,408,210, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,408,208,475,208, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,484,278,484,311, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,484,311,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,508,327,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,559,327,508,327, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,644,391,559,391, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,644,389,644,391, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,514,205,475,205, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,496,189,496,187, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,559,129,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,484,162,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,725,133,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,559,129,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,725,149,725,167, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,725,129,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,802,389,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,739,167,802,167, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,396,188,408,188, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,0,337,9,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,58,337,21,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,43,391,43,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,105,337,75,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,91,387,91,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,154,337,117,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,139,387,139,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,227,337,166,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,258,337,251,337, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,258,328,302,328, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,302,355,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,395,311,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,484,278,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,395,294,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,473,278,473,275, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,473,256,473,254, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,533,257,531,254, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,553,276,551,274, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,698,276,553,276, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,559,391,559,327, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,802,389,644,389, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,741,314,741,389, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,698,280,698,167, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,707,280,698,280, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,802,280,731,280, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,741,280,741,302, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,698,167,727,167, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,725,137,725,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,514,254,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,496,175,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,502,175,502,162, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,475,166,475,162, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,496,176,496,175, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,491,189,496,189, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,491,205,491,189, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,487,238,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,487,240,487,238, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,487,252,487,254, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,315,133,304,133, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,256,133,280,133, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,78,247,270,247, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,307,247,294,247, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,214,133,232,133, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,217,247,217,266, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,217,309,217,291, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,217,309,172,309, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,154,309,148,309, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,175,300,175,309, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,151,300,175,300, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,151,247,151,309, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,78,237,78,265, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,78,286,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,106,309,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,130,309,125,309, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,99,309,99,247, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,127,299,99,299, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,127,309,127,299, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,155,191,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,137,169,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,78,171,78,169, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,78,190,78,218, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,86,192,86,169, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,86,192,78,192, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,52,301,3,301, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,52,286,52,301, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,52,252,3,252, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,52,203,3,203, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,3,156,52,156, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,8,25,8,114, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,63,114,3,114, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,75,114,97,114, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,108,114,129,114, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,129,114,129,89, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,52,114,52,128, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,132,89,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,88,25,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,88,114,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,218,89,144,89, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,147,111,147,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,162,111,147,111, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,162,109,162,111, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,162,96,162,89, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,218,89,218,94, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,218,89,218,119, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,8,25,88,25, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,258,337,258,328, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,113,129,96,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,302,355,258,355, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,386,104,386,129, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,377,100,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,365,94,377,100, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,350,83,365,94, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,337,70,350,83, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,337,70,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,312,49,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,295,40,312,49, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,282,37,295,40, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,260,34,282,37, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,253,34,260,34, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,386,128,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
  TkcLine.new(w,113,152,113,129, 'fill'=>color, 'tags'=>['floor1','wall'])
end

#floor_fg2(w, color) ⇒ Object

floor_fg2 – This method represents part of the floorplan database. When invoked, it instantiates the foreground information for the second floor (office outlines and numbers).

Arguments: w - The canvas window. color - Color to use for drawing foreground information.



799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
# File 'sample/demos-en/floor.rb', line 799

def floor_fg2(w,color)
  i = TkcPolygon.new(w,748,188,755,188,755,205,758,205,758,222,
                     800,222,800,168,748,168, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '238'
  $floorItems['238'] = i
  TkcText.new(w,774,195, 'text'=>'238', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,726,188,746,188,746,166,800,166,800,131,726,131,
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '237'
  $floorItems['237'] = i
  TkcText.new(w,763,148.5, 'text'=>'237', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,497,187,497,204,559,204,559,324,641,324,
                     643,324,643,291,641,291,641,205,696,205,
                     696,291,694,291,694,314,715,314,715,291,
                     715,205,755,205,755,190,724,190,724,187, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '246'
  $floorItems['246'] = i
  TkcText.new(w,600,264, 'text'=>'246', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,694,279,643,279,643,314,694,314, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '247'
  $floorItems['247'] = i
  TkcText.new(w,668.5,296.5, 'text'=>'247', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,232,250,308,250,308,242,339,242,339,246,
                     397,246,397,255,476,255,476,250,482,250,559,250,
                     559,274,482,274,482,278,396,278,396,274,232,274, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '202'
  $floorItems['202'] = i
  TkcText.new(w,285.5,260, 'text'=>'202', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,53,228,53,338,176,338,233,338,233,196,
                     306,196,306,180,175,180,175,169,156,169,
                     156,196,176,196,176,228, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '206'
  $floorItems['206'] = i
  TkcText.new(w,143,267, 'text'=>'206', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,51,277,6,277,6,338,51,338, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '212'
  $floorItems['212'] = i
  TkcText.new(w,28.5,307.5, 'text'=>'212', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,557,276,486,276,486,309,510,309,510,325,557,325, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '245'
  $floorItems['245'] = i
  TkcText.new(w,521.5,300.5, 'text'=>'245', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,560,389,599,389,599,326,560,326, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '244'
  $floorItems['244'] = i
  TkcText.new(w,579.5,357.5, 'text'=>'244', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,601,389,601,326,643,326,643,389, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '243'
  $floorItems['243'] = i
  TkcText.new(w,622,357.5, 'text'=>'243', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,688,316,645,316,645,365,688,365, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '242'
  $floorItems['242'] = i
  TkcText.new(w,666.5,340.5, 'text'=>'242', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,802,367,759,367,759,226,802,226, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = 'Barbecue Deck'
  $floorItems['Barbecue Deck'] = i
  TkcText.new(w,780.5,296.5, 'text'=>'Barbecue Deck', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,755,262,755,314,717,314,717,262, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '240'
  $floorItems['240'] = i
  TkcText.new(w,736,288, 'text'=>'240', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,755,316,689,316,689,365,755,365, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '241'
  $floorItems['241'] = i
  TkcText.new(w,722,340.5, 'text'=>'241', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,755,206,717,206,717,261,755,261, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '239'
  $floorItems['239'] = i
  TkcText.new(w,736,233.5, 'text'=>'239', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,695,277,643,277,643,206,695,206, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '248'
  $floorItems['248'] = i
  TkcText.new(w,669,241.5, 'text'=>'248', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,676,135,676,185,724,185,724,135, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '236'
  $floorItems['236'] = i
  TkcText.new(w,700,160, 'text'=>'236', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,675,135,635,135,635,145,628,145,628,185,675,185, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '235'
  $floorItems['235'] = i
  TkcText.new(w,651.5,160, 'text'=>'235', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,626,143,633,143,633,135,572,135,
                     572,143,579,143,579,185,626,185, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '234'
  $floorItems['234'] = i
  TkcText.new(w,606,160, 'text'=>'234', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,557,135,571,135,571,145,578,145,
                     578,185,527,185,527,131,557,131, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '233'
  $floorItems['233'] = i
  TkcText.new(w,552.5,158, 'text'=>'233', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,476,249,557,249,557,205,476,205,
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '230'
  $floorItems['230'] = i
  TkcText.new(w,516.5,227, 'text'=>'230', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,476,164,486,164,486,131,525,131,525,185,476,185, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '232'
  $floorItems['232'] = i
  TkcText.new(w,500.5,158, 'text'=>'232', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,476,186,495,186,495,204,476,204, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '229'
  $floorItems['229'] = i
  TkcText.new(w,485.5,195, 'text'=>'229', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,474,207,409,207,409,187,399,187,399,164,474,164, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '227'
  $floorItems['227'] = i
  TkcText.new(w,436.5,185.5, 'text'=>'227', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,399,228,399,253,474,253,474,209,409,209,409,228, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '228'
  $floorItems['228'] = i
  TkcText.new(w,436.5,231, 'text'=>'228', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,397,246,397,226,407,226,407,189,377,189,377,246, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '226'
  $floorItems['226'] = i
  TkcText.new(w,392,217.5, 'text'=>'226', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,377,169,316,169,316,131,397,131,397,188,377,188, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '225'
  $floorItems['225'] = i
  TkcText.new(w,356.5,150, 'text'=>'225', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,234,198,306,198,306,249,234,249, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '224'
  $floorItems['224'] = i
  TkcText.new(w,270,223.5, 'text'=>'224', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,270,179,306,179,306,170,314,170,314,135,270,135, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '223'
  $floorItems['223'] = i
  TkcText.new(w,292,157, 'text'=>'223', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,268,179,221,179,221,135,268,135, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '222'
  $floorItems['222'] = i
  TkcText.new(w,244.5,157, 'text'=>'222', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,177,179,219,179,219,135,177,135, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '221'
  $floorItems['221'] = i
  TkcText.new(w,198,157, 'text'=>'221', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,299,327,349,327,349,284,341,284,341,276,299,276, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '204'
  $floorItems['204'] = i
  TkcText.new(w,324,301.5, 'text'=>'204', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,234,276,297,276,297,327,257,327,257,338,234,338, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '205'
  $floorItems['205'] = i
  TkcText.new(w,265.5,307, 'text'=>'205', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,256,385,256,340,212,340,212,385,
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '207'
  $floorItems['207'] = i
  TkcText.new(w,234,362.5, 'text'=>'207', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,210,340,164,340,164,385,210,385, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '208'
  $floorItems['208'] = i
  TkcText.new(w,187,362.5, 'text'=>'208', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,115,340,162,340,162,385,115,385, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '209'
  $floorItems['209'] = i
  TkcText.new(w,138.5,362.5, 'text'=>'209', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,89,228,89,156,53,156,53,228, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '217'
  $floorItems['217'] = i
  TkcText.new(w,71,192, 'text'=>'217', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,89,169,97,169,97,190,89,190, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '217A'
  $floorItems['217A'] = i
  TkcText.new(w,93,179.5, 'text'=>'217A', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,89,156,89,168,95,168,95,135,53,135,53,156, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '216'
  $floorItems['216'] = i
  TkcText.new(w,71,145.5, 'text'=>'216', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,51,179,51,135,6,135,6,179, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '215'
  $floorItems['215'] = i
  TkcText.new(w,28.5,157, 'text'=>'215', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,51,227,6,227,6,180,51,180, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '214'
  $floorItems['214'] = i
  TkcText.new(w,28.5,203.5, 'text'=>'214', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,51,275,6,275,6,229,51,229, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '213'
  $floorItems['213'] = i
  TkcText.new(w,28.5,252, 'text'=>'213', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,114,340,67,340,67,385,114,385, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '210'
  $floorItems['210'] = i
  TkcText.new(w,90.5,362.5, 'text'=>'210', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,59,389,59,385,65,385,65,340,1,340,1,389, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '211'
  $floorItems['211'] = i
  TkcText.new(w,33,364.5, 'text'=>'211', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,393,309,350,309,350,282,342,282,342,276,393,276, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '203'
  $floorItems['203'] = i
  TkcText.new(w,367.5,292.5, 'text'=>'203', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,99,191,91,191,91,226,174,226,174,198,
                     154,198,154,192,109,192,109,169,99,169, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '220'
  $floorItems['220'] = i
  TkcText.new(w,132.5,208.5, 'text'=>'220', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = 'Priv Lift2'
  $floorItems['Priv Lift2'] = i
  TkcText.new(w,323,188, 'text'=>'Priv Lift2', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = 'Pub Lift 2'
  $floorItems['Pub Lift 2'] = i
  TkcText.new(w,323,223, 'text'=>'Pub Lift 2', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,175,168,97,168,97,131,175,131, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '218'
  $floorItems['218'] = i
  TkcText.new(w,136,149.5, 'text'=>'218', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,154,191,111,191,111,169,154,169, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '219'
  $floorItems['219'] = i
  TkcText.new(w,132.5,180, 'text'=>'219', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, 
                     'fill'=>'', 'tags'=>['floor2','room'])
  $floorLabels[i.id] = '201'
  $floorItems['201'] = i
  TkcText.new(w,358,209, 'text'=>'201', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor2','label'])
  TkcLine.new(w,641,186,678,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,757,350,757,367, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,634,133,634,144, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,634,144,627,144, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,572,133,572,144, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,572,144,579,144, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,398,129,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,174,197,175,197, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,175,197,175,227, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,757,206,757,221, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,396,188,408,188, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,727,189,725,189, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,747,167,802,167, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,747,167,747,189, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,755,189,739,189, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,769,224,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,802,224,802,129, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,802,129,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,725,189,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,725,186,690,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,676,133,676,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,627,144,627,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,629,186,593,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,579,144,579,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,559,129,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,725,133,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,484,162,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,559,129,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,526,129,526,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,540,186,581,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,528,186,523,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,511,186,475,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,496,190,496,186, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,496,205,496,202, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,475,205,527,205, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,558,205,539,205, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,558,205,558,249, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,558,249,475,249, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,662,206,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,695,206,675,206, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,695,278,642,278, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,642,291,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,695,291,695,206, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,716,208,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,757,206,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,757,221,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,793,224,802,224, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,757,262,716,262, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,716,220,716,264, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,716,315,716,276, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,757,315,703,315, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,757,325,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,757,367,644,367, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,689,367,689,315, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,647,315,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,659,315,691,315, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,600,325,600,391, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,627,325,644,325, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,644,391,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,615,325,575,325, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,644,391,558,391, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,563,325,558,325, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,558,391,558,314, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,558,327,508,327, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,558,275,484,275, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,558,302,558,275, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,508,327,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,484,311,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,484,275,484,311, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,475,208,408,208, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,408,206,408,210, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,408,222,408,227, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,408,227,398,227, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,398,227,398,254, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,408,188,408,194, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,383,188,376,188, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,398,188,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,398,162,484,162, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,475,162,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,398,254,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,484,280,395,280, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,395,311,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,307,197,293,197, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,278,197,233,197, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,233,197,233,249, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,307,179,284,179, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,233,249,278,249, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,269,179,269,133, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,220,179,220,133, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,155,191,110,191, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,90,190,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,98,169,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,52,133,52,165, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,52,214,52,177, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,52,226,52,262, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,52,274,52,276, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,234,275,234,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,226,339,258,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,211,387,211,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,214,339,177,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,258,387,60,387, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,3,133,3,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,165,339,129,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,117,339,80,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,68,339,59,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,0,339,46,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,0,339,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,60,387,60,391, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,258,329,258,387, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,350,329,258,329, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,395,311,350,311, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,398,129,315,129, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,176,133,315,133, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,176,129,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,3,133,96,133, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,66,387,66,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,115,387,115,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,163,387,163,339, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,234,275,276,275, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,288,275,309,275, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,298,275,298,329, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,341,283,350,283, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,321,275,341,275, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,375,275,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,307,250,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,376,245,376,170, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,340,245,340,224, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,293,250,307,250, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,271,179,238,179, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,226,179,195,179, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,176,129,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,182,179,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,174,169,176,169, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,162,169,90,169, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,96,169,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,175,227,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,90,190,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,52,179,3,179, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,52,228,3,228, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,52,276,3,276, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,110,191,110,169, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,155,189,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,350,283,350,329, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,162,197,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
  TkcLine.new(w,341,275,341,283, 'fill'=>color, 'tags'=>['floor2','wall'])
end

#floor_fg3(w, color) ⇒ Object

floor_fg3 – This method represents part of the floorplan database. When invoked, it instantiates the foreground information for the third floor (office outlines and numbers).

Arguments: w - The canvas window. color - Color to use for drawing foreground information.



1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
# File 'sample/demos-en/floor.rb', line 1281

def floor_fg3(w,color)
  i = TkcPolygon.new(w,89,228,89,180,70,180,70,228,
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '316'
  $floorItems['316'] = i
  TkcText.new(w,79.5,204, 'text'=>'316', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,115,368,162,368,162,323,115,323, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '309'
  $floorItems['309'] = i
  TkcText.new(w,138.5,345.5, 'text'=>'309', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,164,323,164,368,211,368,211,323, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '308'
  $floorItems['308'] = i
  TkcText.new(w,187.5,345.5, 'text'=>'308', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,256,368,212,368,212,323,256,323, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '307'
  $floorItems['307'] = i
  TkcText.new(w,234,345.5, 'text'=>'307', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,244,276,297,276,297,327,260,327,260,321,244,321, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '305'
  $floorItems['305'] = i
  TkcText.new(w,270.5,301.5, 'text'=>'305', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,251,219,251,203,244,203,244,219,
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '324B'
  $floorItems['324B'] = i
  TkcText.new(w,247.5,211, 'text'=>'324B', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,251,249,244,249,244,232,251,232, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '324A'
  $floorItems['324A'] = i
  TkcText.new(w,247.5,240.5, 'text'=>'324A', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,223,135,223,179,177,179,177,135, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '320'
  $floorItems['320'] = i
  TkcText.new(w,200,157, 'text'=>'320', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,114,368,114,323,67,323,67,368, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '310'
  $floorItems['310'] = i
  TkcText.new(w,90.5,345.5, 'text'=>'310', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,23,277,23,321,68,321,68,277, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '312'
  $floorItems['312'] = i
  TkcText.new(w,45.5,299, 'text'=>'312', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,23,229,68,229,68,275,23,275, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '313'
  $floorItems['313'] = i
  TkcText.new(w,45.5,252, 'text'=>'313', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,68,227,23,227,23,180,68,180, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '314'
  $floorItems['314'] = i
  TkcText.new(w,40.5,203.5, 'text'=>'314', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,95,179,95,135,23,135,23,179, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '315'
  $floorItems['315'] = i
  TkcText.new(w,59,157, 'text'=>'315', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,99,226,99,204,91,204,91,226, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '316B'
  $floorItems['316B'] = i
  TkcText.new(w,95,215, 'text'=>'316B', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,91,202,99,202,99,180,91,180, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '316A'
  $floorItems['316A'] = i
  TkcText.new(w,95,191, 'text'=>'316A', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,97,169,109,169,109,192,154,192,154,198,
                     174,198,174,226,101,226,101,179,97,179, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '319'
  $floorItems['319'] = i
  TkcText.new(w,141.5,209, 'text'=>'319', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,65,368,58,368,58,389,1,389,1,333,23,333,23,323,65,323, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '311'
  $floorItems['311'] = i
  TkcText.new(w,29.5,361, 'text'=>'311', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,154,191,111,191,111,169,154,169, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '318'
  $floorItems['318'] = i
  TkcText.new(w,132.5,180, 'text'=>'318', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,175,168,97,168,97,131,175,131, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '317'
  $floorItems['317'] = i
  TkcText.new(w,136,149.5, 'text'=>'317', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,274,194,274,221,306,221,306,194, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '323'
  $floorItems['323'] = i
  TkcText.new(w,290,207.5, 'text'=>'323', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,306,222,274,222,274,249,306,249, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '325'
  $floorItems['325'] = i
  TkcText.new(w,290,235.5, 'text'=>'325', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,263,179,224,179,224,135,263,135, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '321'
  $floorItems['321'] = i
  TkcText.new(w,243.5,157, 'text'=>'321', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,314,169,306,169,306,192,273,192,
                     264,181,264,135,314,135, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '322'
  $floorItems['322'] = i
  TkcText.new(w,293.5,163.5, 'text'=>'322', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = 'Pub Lift3'
  $floorItems['Pub Lift3'] = i
  TkcText.new(w,323,223, 'text'=>'Pub Lift3', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = 'Priv Lift3'
  $floorItems['Priv Lift3'] = i
  TkcText.new(w,323,188, 'text'=>'Priv Lift3', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,350,284,376,284,376,276,397,276,397,309,350,309, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '303'
  $floorItems['303'] = i
  TkcText.new(w,373.5,292.5, 'text'=>'303', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,272,203,272,249,252,249,252,230,
                     244,230,244,221,252,221,252,203, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '324'
  $floorItems['324'] = i
  TkcText.new(w,262,226, 'text'=>'324', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,299,276,299,327,349,327,349,284,341,284,341,276, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '304'
  $floorItems['304'] = i
  TkcText.new(w,324,301.5, 'text'=>'304', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '301'
  $floorItems['301'] = i
  TkcText.new(w,358,209, 'text'=>'301', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,397,246,377,246,377,185,397,185, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '327'
  $floorItems['327'] = i
  TkcText.new(w,387,215.5, 'text'=>'327', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,316,131,316,169,377,169,377,185,397,185,397,131, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '326'
  $floorItems['326'] = i
  TkcText.new(w,365.5,150, 'text'=>'326', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,308,251,242,251,242,274,342,274,342,282,375, 282,
                     375,274,397,274,397,248,339,248,339,242,308,242, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '302'
  $floorItems['302'] = i
  TkcText.new(w,319.5,261, 'text'=>'302', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  i = TkcPolygon.new(w,70,321,242,321,242,200,259,200,259,203,272,203,
                     272,193,263,180,242,180,175,180,175,169,156,169,
                     156,196,177,196,177,228,107,228,70,228,70,275,107,275,
                     107,248,160,248,160,301,107,301,107,275,70,275, 
                     'fill'=>'', 'tags'=>['floor3','room'])
  $floorLabels[i.id] = '306'
  $floorItems['306'] = i
  TkcText.new(w,200.5,284.5, 'text'=>'306', 'fill'=>color, 
              'anchor'=>'c', 'tags'=>['floor3','label'])
  TkcLine.new(w,341,275,341,283, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,162,197,155,197, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,396,247,399,247, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,399,129,399,311, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,258,202,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,350,283,350,329, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,251,231,243,231, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,243,220,251,220, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,243,250,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,155,197,155,190, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,110,192,110,169, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,155,192,110,192, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,176,197,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,69,280,69,274, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,21,276,69,276, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,69,262,69,226, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,21,228,69,228, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,21,179,75,179, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,69,179,69,214, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,90,220,90,227, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,90,204,90,202, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,90,203,100,203, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,90,187,90,179, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,90,227,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,100,179,100,227, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,100,179,87,179, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,96,179,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,162,169,96,169, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,173,169,176,169, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,182,179,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,176,129,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,195,179,226,179, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,224,133,224,179, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,264,179,264,133, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,238,179,264,179, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,273,207,273,193, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,273,235,273,250, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,273,224,273,219, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,273,193,307,193, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,273,222,307,222, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,384,247,376,247, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,340,247,340,224, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,376,247,376,170, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,307,250,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,376,283,366,283, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,376,283,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,399,275,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,341,275,320,275, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,341,283,350,283, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,298,275,298,329, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,308,275,298,275, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,243,322,243,275, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,243,275,284,275, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,258,322,226,322, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,212,370,212,322, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,214,322,177,322, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,163,370,163,322, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,165,322,129,322, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,84,322,117,322, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,71,322,64,322, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,115,322,115,370, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,66,322,66,370, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,52,322,21,322, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,21,331,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,21,331,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,96,133,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,176,129,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,315,133,176,133, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,315,129,399,129, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,399,311,350,311, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,350,329,258,329, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,258,322,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,60,370,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,60,370,60,391, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,0,391,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,307,250,307,242, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
  TkcLine.new(w,258,250,243,250, 'fill'=>color, 'tags'=>['floor3','wall'])
end

#floorDisplay(w, active) ⇒ Object

floorDisplay – Recreate the floorplan display in the canvas given by “w”. The floor given by “active” is displayed on top with its office structure visible.

Arguments: w - Name of the canvas window. active - Number of active floor (1, 2, or 3).



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'sample/demos-en/floor.rb', line 18

def floorDisplay(w,active)
  return if $activeFloor == active

  w.delete('all')
  $activeFloor = active

  # First go through the three floors, displaying the backgrounds for 
  # each floor.

  floor_bg1(w,$floor_colors['bg1'],$floor_colors['outline1'])
  floor_bg2(w,$floor_colors['bg2'],$floor_colors['outline2'])
  floor_bg3(w,$floor_colors['bg3'],$floor_colors['outline3'])

  # Raise the background for the active floor so that it's on top.

  w.raise("floor#{active}")

  # Create a dummy item just to mark this point in the display list, 
  # so we can insert highlights here.

  TkcRectangle.new(w,0,100,1,101, 'fill'=>'', 'outline'=>'', 'tags'=>'marker')

  # Add the walls and labels for the active floor, along with 
  # transparent polygons that define the rooms on the floor.
  # Make sure that the room polygons are on top.

  $floorLabels.clear
  $floorItems.clear
  send("floor_fg#{active}", w, $floor_colors['offices'])
  w.raise('room')

  # Offset the floors diagonally from each other.

  w.move('floor1', '2c', '2c')
  w.move('floor2', '1c', '1c')

  # Create items for the room entry and its label.
  TkcWindow.new(w, 600, 100, 'anchor'=>'w', 'window'=>$floor_entry)
  TkcText.new(w, 600, 100, 'anchor'=>'e', 'text'=>"Room: ")
  w['scrollregion'] = w.bbox('all')
end

#floorDisplay2(w, active) ⇒ Object

floorDisplay2 – Recreate the floorplan display in the canvas given by “w”. The floor given by “active” is displayed on top with its office structure visible.

Arguments: w - Name of the canvas window. active - Number of active floor (1, 2, or 3).



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'sample/demos-en/floor2.rb', line 18

def floorDisplay2(w,active)
  return if $activeFloor2 == active

  w.delete('all')
  $activeFloor2 = active

  # First go through the three floors, displaying the backgrounds for 
  # each floor.

  floor2_bg1(w,$floor2_colors['bg1'],$floor2_colors['outline1'])
  floor2_bg2(w,$floor2_colors['bg2'],$floor2_colors['outline2'])
  floor2_bg3(w,$floor2_colors['bg3'],$floor2_colors['outline3'])

  # Raise the background for the active floor so that it's on top.

  w.raise("floor#{active}")

  # Create a dummy item just to mark this point in the display list, 
  # so we can insert highlights here.

  w.create(TkcRectangle,0,100,1,101,'fill'=>'','outline'=>'','tags'=>'marker')

  # Add the walls and labels for the active floor, along with 
  # transparent polygons that define the rooms on the floor.
  # Make sure that the room polygons are on top.

  $floorLabels2.clear
  $floorItems2.clear
  send("floor2_fg#{active}", w, $floor2_colors['offices'])
  w.raise('room')

  # Offset the floors diagonally from each other.

  w.move('floor1', '2c', '2c')
  w.move('floor2', '1c', '1c')

  # Create items for the room entry and its label.
  w.create(TkcWindow, 600, 100, 'anchor'=>'w', 'window'=>$floor2_entry)
  w.create(TkcText, 600, 100, 'anchor'=>'e', 'text'=>"Room: ")
  w['scrollregion'] = w.bbox('all')
end

#focusAndFlash(widget, fg, bg, count = 5) ⇒ Object

focusAndFlash – Error handler for entry widgets that forces the focus onto the widget and makes the widget flash by exchanging the foreground and background colours at intervals of 200ms (i.e. at approximately 2.5Hz).

Arguments: widget - entry widget to flash fg - Initial foreground colour bg - Initial background colour count - Counter to control the number of times flashed



61
62
63
64
65
66
67
68
# File 'sample/demos-en/entry3.rb', line 61

def focusAndFlash(widget, fg, bg, count=5)
  return if count <= 0
  TkTimer.new(200, count, 
              proc{widget.configure(:foreground=>bg, :background=>fg)}, 
              proc{widget.configure(:foreground=>fg, :background=>bg)}
              ).start
  widget.focus(true)
end

#focusMonitorObject



837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
# File 'sample/tkextlib/tile/demo.rb', line 837

def focusMonitor
  $FocusInf[:Widget] = focus_win = Tk.focus
  if focus_win
    $FocusInf[:WidgetClass] = focus_win.winfo_classname
    $FocusInf[:WidgetNext] = Tk.focus_next(focus_win)
  else
    $FocusInf[:WidgetClass] = $FocusInf[:WidgetNext] = ''
  end

  $FocusInf[:Grab] = grab_wins = Tk.current_grabs
  unless grab_wins.empty?
    $FocusInf[:GrabStatus] = grab_wins[0].grab_status
  else  
    $FocusInf[:GrabStatus] = ''
  end

  $Timers[:FocusMonitor] = Tk.after(200, proc{ focusMonitor() })
end

#foreachWidget(wins, cmd) ⇒ Object

Utilities:



140
141
142
143
144
145
# File 'sample/tkextlib/tile/demo.rb', line 140

def foreachWidget(wins, cmd)
  wins.each{|w|
    cmd.call(w)
    foreachWidget(w.winfo_children, cmd)
  }
end

#get_files(file) ⇒ Object



5
6
7
8
9
10
11
# File 'sample/tkextlib/iwidgets/sample/hierarchy.rb', line 5

def get_files(file)
  dir = (file.empty?)? ENV['HOME'] : TkComm._fromUTF8(file)
  Dir.chdir(dir) rescue return ''
  Dir['*'].sort.collect{|f|
    [TkComm._toUTF8(File.join(dir, f)), TkComm._toUTF8(f)]
  }
end

#get_pkg_list(file) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/tkextlib/pkg_checker.rb', line 66

def get_pkg_list(file)
  pkg_list = []

  File.foreach(file){|l|
    if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)TkPackage\s*\.\s*require\s*\(?\s*(["'])((\w|:)+)\1/
      pkg = [$2, :package]
      pkg_list << pkg unless pkg_list.member?(pkg)
    end
    if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)Tk\s*\.\s*load_tcllibrary\s*\(?\s*(["'])((\w|:)+)\1/
      pkg = [$2, :library]
      pkg_list << pkg unless pkg_list.member?(pkg)
    end
    if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)Tk\s*\.\s*load_tclscript\s*\(?\s*(["'])((\w|:)+)\1/
      pkg = [$2, :script]
      pkg_list << pkg unless pkg_list.member?(pkg)
    end
    if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)require\s*\(?\s*(["'])((\w|\/|:)+)\1/
      pkg = [$2, :require_ruby_lib]
      pkg_list << pkg unless pkg_list.member?(pkg)
    end
  }

  pkg_list
end

#help_msgObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/tkextlib/pkg_checker.rb', line 16

def help_msg
  print "Usage: #{$0} [-l] [-v] [-h] [--] [dir]\n"
  print "\tIf dir is omitted, check the directry that this command exists.\n"
  print "\tAvailable options are \n"
  print "\t  -l : Add dir to $LOAD_PATH\n"
  print "\t       (If dir == '<parent>/tkextlib', add <parent> also.)\n"
  print "\t  -v : Verbose mode (show reason of fail)\n"
  print "\t  -h : Show this message\n"
  print "\t  -- : End of options\n"
end

#helpButton1(w, x, y) ⇒ Object



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'sample/tkextlib/treectrl/help.rb', line 287

def helpButton1(w, x, y)
  w.set_focus
  id = w.identify(x, y)
  @Priv['buttonMode'] = ''
  if id[0] == 'header'
    Tk::TreeCtrl::BindCallback.buttonPress1(w, x, y)
  elsif id[0] == 'item'
    item = id[1]
    # didn't click an element
    return if id.length != 6
    if w.selection_includes(item)
      w.toggle(item)
      return
    end
    if w.selection_get.length > 0
      item2 = w.selection_get[0]
      if $Version_1_1_OrLater
        w.item_collapse(item2)
      else # TreeCtrl 1.0
        w.collapse(item2)
      end
      w.item_ancestors(item2).each{|i|
        if $Version_1_1_OrLater
          w.item_collapse(i) if w.compare(item, '!=', i)
        else # TreeCtrl 1.0
          w.collapse(i) if w.compare(item, '!=', i)
        end
      }
    end
    w.activate(item)
    if $Version_1_1_OrLater
      w.item_ancestors(item).each{|i|
        w.item_expand(i)
      }
      w.item_toggle(item)
    else # TreeCtrl 1.0
      w.expand(*(w.item_ancestors(item)))
      w.toggle(item)
    end
    w.selection_modify(item, :all)
  end
end

#helpLeave1(w, x, y) ⇒ Object



337
338
339
340
341
342
343
344
345
# File 'sample/tkextlib/treectrl/help.rb', line 337

def helpLeave1(w, x, y)
  # This is called when I do ButtonPress-1 on Unix for some reason,
  # and buttonMode is undefined.
  return unless @Priv.exist?('buttonMode')
  case @Priv['buttonMode']
  when 'header'
    w.column_configure(@Priv['column'], :sunken=>false)
  end
end

#helpMotion(w, x, y) ⇒ Object



355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'sample/tkextlib/treectrl/help.rb', line 355

def helpMotion(w, x, y)
  id = w.identify(x, y)
  if id.empty?
  elsif id[0] == 'header'
  elsif id[0] == 'item'
    item = id[1]
    if id.length == 6
      if @Priv[:help, :prev] != TkComm._get_eval_string(item)
        if @Priv[:help, :prev] != ''
          w.item_state_set(@Priv[:help, :prev], '!mouseover')
        end
        w.item_state_set(item, 'mouseover')
        @Priv[:help, :prev] = item
      end
      return
    end
  end
  if @Priv[:help, :prev] != ''
    w.item_state_set(@Priv[:help, :prev], '!mouseover')
    @Priv[:help, :prev] = ''
  end
end

#helpMotion1(w, x, y) ⇒ Object



330
331
332
333
334
335
# File 'sample/tkextlib/treectrl/help.rb', line 330

def helpMotion1(w, x, y)
  case @Priv['buttonMode']
  when 'resize', 'header'
    Tk::TreeCtrl::BindCallback.motion1(w, x, y)
  end
end

#helpMotion2(w, x, y) ⇒ Object

Alternate implementation doesn’t rely on mouseover state



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
# File 'sample/tkextlib/treectrl/help.rb', line 379

def helpMotion2(w, x, y)
  id = w.identify(x, y)
  if id[0] == 'header'
  elsif !id.empty?
    item = id[1]
    if id.kength == 6
      if @Priv[:help, :prev] != TkComm._get_eval_string(item)
        if @Priv[:help, :prev] != ''
          style = w.item_style_set(@Priv[:help, :prev], 0)
          style.sub!(/\.f$/, '')
          w.item_style_map(@Priv[:help, :prev], 0, style, ['e5', 'e3'])
        end
        style = w.item_style_set(item, 0)
        w.item_style_map(item, 0, style + '.f', ['e3', 'e5'])
        @Priv[:help, :prev] = item
      end
      return
    end
  end
  if @Priv[:help, :prev] != ''
    style = w.item_style_set(@Priv[:help, :prev], 0)
    style.sub!(/\.f$/, '')
    w.item_style_map(@Priv[:help, :prev], 0, style, ['e5', 'e3'])
    @Priv[:help, :prev] = ''
  end
end

#helpRelease1(w, x, y) ⇒ Object



347
348
349
350
351
352
353
# File 'sample/tkextlib/treectrl/help.rb', line 347

def helpRelease1(w, x, y)
  case @Priv['buttonMode']
  when 'resize', 'header'
    Tk::TreeCtrl::BindCallback.release1(w, x, y)
  end
  @Priv['buttonMode'] = ''
end

#iMovieButton1(w, x, y) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'sample/tkextlib/treectrl/imovie.rb', line 87

def iMovieButton1(w, x, y)
  w.set_focus
  id = w.identify(x,y)

  if id.empty?
    # Click outside any item

  elsif id[0] == 'header'
    # Click in header
    Tk::TreeCtrl::BindCallback.buttonPress1(w, x, y)

  elsif id[0] == 'item'
    # Click in item
    Tk::TreeCtrl::BindCallback.buttonPress1(w, x, y)
    Tk.update
    where, item, arg1, arg2, arg3, arg4 = id
    case arg1
    when 'column'
      i = id[1]
      if id.length == 6
        e = id[-1]
        if e == 'elemName'
          exists = TkWinfo.exist?(w.path + '.entry')
          Tk::TreeCtrl::BindCallback.entryOpen(w, i, 0, e)
          ent = TkComm.window(w.path + '.entry')
          unless exists
            ent.configure(:borderwidth=>0, :justify=>:center, 
                          :background=>'#ffdc5a')
            x1, y1, x2, y2 = w.item_bbox(i, 0, e)
            ent.place(:y=>y1 - 1)
          end
          ent.selection_clear
          x1, y1, x2, y2 = w.item_bbox(i)
          ent.place(:x=>x1 + 1, :width=>x2 - x1 - 5)
          puts "@#{x - (x1 + 1)}"
          # ent.icursor = ent.index("@#{x - (x1 + 1)}")
          ent.icursor = ent.index(TkComm._at(x - (x1 + 1)))
        end
      end
    end
  end

  Tk.callback_break
end

#itemDrag(c, x, y) ⇒ Object



359
360
361
362
363
364
365
# File 'sample/demos-en/items.rb', line 359

def itemDrag(c,x,y)
  x = c.canvasx(x)
  y = c.canvasy(y)
  c.move 'current', x - $lastX, y - $lastY
  $lastX = x
  $lastY = y
end

#itemEnter(c) ⇒ Object



281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'sample/demos-en/items.rb', line 281

def itemEnter (c)
  if TkWinfo.depth(c).to_i == 1
    $restoreCmd = nil
    return
  end
  type = c.itemtype('current')
  if type == TkcWindow
    $restoreCmd = nil
    return
  end
  if type == TkcBitmap
    bg = (c.itemconfiginfo('current', 'background'))[4]
    $restoreCmd = proc{c.itemconfigure 'current', 'background', bg}
    c.itemconfigure 'current', 'background', 'SteelBlue2'
    return
  end
  fill = (c.itemconfiginfo('current', 'fill'))[4]
  if (type == TkcRectangle || type == TkcOval || type == TkcArc) && fill == []
    outline = (c.itemconfiginfo('current', 'outline'))[4]
    $restoreCmd = proc{c.itemconfigure 'current', 'outline', outline}
    c.itemconfigure 'current', 'outline', 'SteelBlue2'
  else
    $restoreCmd = proc{c.itemconfigure 'current', 'fill', fill}
    c.itemconfigure 'current', 'fill', 'SteelBlue2'
  end
end

#itemLeave(c) ⇒ Object



308
309
310
# File 'sample/demos-en/items.rb', line 308

def itemLeave(c)
  $restoreCmd.call if $restoreCmd
end

#itemMark(c, x, y) ⇒ Object

Utility methods for stroking out a rectangle and printing what’s underneath the rectangle’s area.



315
316
317
318
319
# File 'sample/demos-en/items.rb', line 315

def itemMark(c,x,y)
  $areaX1 = c.canvasx(x)
  $areaY1 = c.canvasy(y)
  c.delete 'area'
end

#itemStartDrag(c, x, y) ⇒ Object

Utility methods to support dragging of items.



354
355
356
357
# File 'sample/demos-en/items.rb', line 354

def itemStartDrag(c,x,y)
  $lastX = c.canvasx(x)
  $lastY = c.canvasy(y)
end

#itemStroke(c, x, y) ⇒ Object



321
322
323
324
325
326
327
328
329
330
331
# File 'sample/demos-en/items.rb', line 321

def itemStroke(c,x,y)
  x = c.canvasx(x)
  y = c.canvasy(y)
  if $areaX1 != x && $areaY1 != y
    c.delete 'area'
    c.addtag_withtag 'area', TkcRectangle.new(c, $areaX1, $areaY1, x, y, 
                                              '-outline', 'black')
    $areaX2 = x
    $areaY2 = y
  end
end

#itemsUnderArea(c) ⇒ Object



333
334
335
336
337
338
339
340
341
342
343
344
345
# File 'sample/demos-en/items.rb', line 333

def itemsUnderArea(c)
  area = c.find_withtag('area')
  items = []
  c.find_enclosed($areaX1,$areaY1,$areaX2,$areaY2).each{|i|
    items.push(i) if i.gettags.include?($tag_item)
  }
  print "Items enclosed by area: #{items.inspect}\n"; STDOUT.flush
  items.clear
  c.find_overlapping($areaX1,$areaY1,$areaX2,$areaY2).each{|i|
    items.push(i) if i.gettags.include?($tag_item)
  }
  print "Items overlapping area: #{items.inspect}\n"; STDOUT.flush
end

#kroc_rb_settingsObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'sample/tkextlib/tile/themes/kroc.rb', line 17

def kroc_rb_settings
  # Tk::Tile::Style.default(TkRoot, :background=>'#FCB64F', 
  #                         :troughcolor=>'#F8C278', :borderwidth=>1)
  #   or
  # Tk::Tile::Style.default(Tk.root, :background=>'#FCB64F', 
  #                         :troughcolor=>'#F8C278', :borderwidth=>1)
  #   or
  # Tk::Tile::Style.default('.', :background=>'#FCB64F', 
  #                         :troughcolor=>'#F8C278', :borderwidth=>1)
  #   or
  # Tk::Tile::Style.default(nil, :background=>'#FCB64F', 
  #                         :troughcolor=>'#F8C278', :borderwidth=>1)
  #   or
  Tk::Tile::Style.default(:background=>'#FCB64F', :troughcolor=>'#F8C278', 
                          :borderwidth=>1)
  # Tk::Tile::Style.default(TkRoot, :font=>Tk::Tile::Font::Default, 
  #                         :borderwidth=>1)
  #   or
  # Tk::Tile::Style.default(Tk.root, :font=>Tk::Tile::Font::Default, 
  #                         :borderwidth=>1)
  #   or
  # Tk::Tile::Style.default('.', :font=>Tk::Tile::Font::Default, 
  #                         :borderwidth=>1)
  #   or
  # Tk::Tile::Style.default(nil, :font=>Tk::Tile::Font::Default, 
  #                         :borderwidth=>1)
  #   or
  Tk::Tile::Style.default(:font=>Tk::Tile::Font::Default, :borderwidth=>1)

  # Tk::Tile::Style.map(TkRoot, :background=>[:active, '#694418'])
  #   or
  # Tk::Tile::Style.map(Tk.root, :background=>[:active, '#694418'])
  #   or
  # Tk::Tile::Style.map('.', :background=>[:active, '#694418'])
  #   or
  # Tk::Tile::Style.map(nil, :background=>[:active, '#694418'])
  #   or
  Tk::Tile::Style.map(:background=>[:active, '#694418'])
  Tk::Tile::Style.map(:foreground=>[:disabled, '#B2B2B2', :active, '#FFE7CB'])

  # Tk::Tile::Style.default('TButton', :padding=>[10,4])
  Tk::Tile::Style.default(Tk::Tile::TButton, :padding=>[10,4])

  # Tk::Tile::Style.default('TNotebook.Tab', 
  Tk::Tile::Style.default($TNotebook_Tab, 
                          :padding=>[10, 3], :font=>Tk::Tile::Font::Default)
  # Tk::Tile::Style.map('TNotebook.Tab', 
  Tk::Tile::Style.map($TNotebook_Tab, 
                      :background=>[:selected, '#FCB64F', '', '#FFE6BA'], 
                      :foreground=>['', 'black'], 
                      :padding=>[:selected, [10, 6, 10, 3]])

  # Tk::Tile::Style.map('TScrollbar', 
  Tk::Tile::Style.map(Tk::Tile::TScrollbar, 
                      :background=>[:pressed, '#694418'], 
                      :arrowcolor=>[:pressed, '#FEF7CB'], 
                      :relief=>[:pressed, :sunken])

  # Tk::Tile::Style.layout('Vertical.TScrollbar', 
  Tk::Tile::Style.layout(Tk::Tile.style('Vertical', Tk::Tile::TScrollbar), 
                         ['Scrollbar.trough', {:children=>[
                             'Scrollbar.uparrow',   {:side=>:top}, 
                             'Scrollbar.downarrow', {:side=>:bottom}, 
                             'Scrollbar.uparrow',   {:side=>:bottom}, 
                             'Scrollbar.thumb',  {:side=>:top, :expand=>true}
                           ]}
                         ])

  # Tk::Tile::Style.layout('Horizontal.TScrollbar', 
  Tk::Tile::Style.layout(Tk::Tile.style('Horizontal', Tk::Tile::TScrollbar), 
                         ['Scrollbar.trough', {:children=>[
                             'Scrollbar.leftarrow',   {:side=>:left}, 
                             'Scrollbar.rightarrow', {:side=>:right}, 
                             'Scrollbar.leftarrow',   {:side=>:right}, 
                             'Scrollbar.thumb',  {:side=>:left, :expand=>true}
                           ]}
                         ])

  #
  # Elements:
  #
  if TkPackage.vcompare(Tk::Tile.package_version, '0.5') >= 0

    Tk::Tile::Style.element_create('Button.button', 
                                   :image, $images['button-n'],
                                   :map=>[
                                     :pressed, $images['button-p'], 
                                     :active,  $images['button-h'], 
                                   ], :border=>3, :sticky=>:ew)

    Tk::Tile::Style.element_create('Checkbutton.indicator', 
                                   :image, $images['check-nu'],
                                   :map=>[
                                     [:pressed, :selected],$images['check-nc'],
                                     :pressed,             $images['check-nu'],
                                     [:active, :selected], $images['check-hc'],
                                     :active,              $images['check-hu'],
                                     :selected,            $images['check-nc'],
                                   ], :sticky=>:w)

    Tk::Tile::Style.element_create('Radiobutton.indicator', 
                                   :image, $images['radio-nu'],
                                   :map=>[
                                     [:pressed, :selected],$images['radio-nc'],
                                     :pressed,             $images['radio-nu'],
                                     [:active, :selected], $images['radio-hc'],
                                     :active,              $images['radio-hu'],
                                     :selected,            $images['radio-nc'],
                                   ], :sticky=>:w)

  else # tile 0.4 or earlier

    Tk::Tile::Style.element_create('Button.button', :pixmap, 
                                   :images=>[
                                     :pressed, $images['button-p'], 
                                     :active,  $images['button-h'], 
                                     '',       $images['button-n']
                                   ], :border=>3, :tiling=>:tile)

    Tk::Tile::Style.element_create('Checkbutton.indicator', :pixmap, 
                                   :images=>[
                                     [:pressed, :selected],$images['check-nc'],
                                     :pressed,             $images['check-nu'],
                                     [:active, :selected], $images['check-hc'],
                                     :active,              $images['check-hu'],
                                     :selected,            $images['check-nc'],
                                     '',                   $images['check-nu'],
                                   ], :tiling=>:fixed)

    Tk::Tile::Style.element_create('Radiobutton.indicator', :pixmap, 
                                   :images=>[
                                     [:pressed, :selected],$images['radio-nc'],
                                     :pressed,             $images['radio-nu'],
                                     [:active, :selected], $images['radio-hc'],
                                     :active,              $images['radio-hu'],
                                     :selected,            $images['radio-nc'],
                                     '',                   $images['radio-nu'],
                                   ], :tiling=>:fixed)

  end

  #
  # Settings:
  #
  # Tk::Tile::Style.layout(Tk::Tile::TButton, 
  Tk::Tile::Style.layout('TButton', [
      'Button.button', {:children=>[
           'Button.focus', {:children=>[
                'Button.padding', {:children=>[
                    'Button.label', {:expand=>true, :sticky=>''}
                ]}
           ]}
      ]}
  ])

  # Tk::Tile::Style.layout(Tk::Tile::TCheckbutton, 
  Tk::Tile::Style.layout('TCheckbutton', [
      'Checkbutton.background', # this is not needed in tile 0.5 or later
      'Checkbutton.border', {:children=>[
           'Checkbutton.padding', {:children=>[
                'Checkbutton.indicator', {:side=>:left}, 
                'Checkbutton.focus', {:side=>:left, :children=>[
                    'Checkbutton.label'
                ]}
           ]}
      ]}
  ])

  # Tk::Tile::Style.layout(Tk::Tile::TRadiobutton, 
  Tk::Tile::Style.layout('TRadiobutton', [
      'Radiobutton.background', # this is not needed in tile 0.5 or later
      'Radiobutton.border', {:children=>[
           'Radiobutton.padding', {:children=>[
                'Radiobutton.indicator', {:side=>:left}, 
                'Radiobutton.focus', {:expand=>true, :sticky=>:w, :children=>[
                    'Radiobutton.label', {:side=>:right, :expand=>true}
                ]}
           ]}
      ]}
  ])
end

#lfEnableButtons(w) ⇒ Object



67
68
69
70
71
72
73
74
75
76
# File 'sample/demos-en/labelframe.rb', line 67

def lfEnableButtons(w)
  TkWinfo.children(w).each{|child|
    next if child.path =~ /\.cb$/
    if $lfdummy == 1
      child.state(:normal)
    else
      child.state(:disabled)
    end
  }
end

#loadDir(w) ⇒ Object



95
96
97
98
99
100
# File 'sample/demos-en/image2.rb', line 95

def loadDir(w)
  w.delete(0,'end')
  Dir.glob([$dirName,'*'].join(File::Separator)).sort.each{|f|
    w.insert('end',File.basename(f))
  }
end

#loadIcons(file) ⇒ Object



127
128
129
130
131
132
133
# File 'sample/tkextlib/tile/demo.rb', line 127

def loadIcons(file)
  Tk.load_tclscript(file)
  img_data = TkVarAccess.new('ImgData')
  img_data.keys.each{|icon|
    $ICON[icon] = TkPhotoImage.new(:data=>img_data[icon])
  }
end

#loadImage(w, x, y) ⇒ Object



102
103
104
# File 'sample/demos-en/image2.rb', line 102

def loadImage(img,w,x,y)
  img.file([$dirName, w.get("@#{x},#{y}")].join(File::Separator))
end

#MainloopObject



45
46
47
# File 'lib/tkclass.rb', line 45

def Mainloop
  Tk.mainloop
end

#makeCompoundMenu(mb) ⇒ Object

Toolbar :compound control:



259
260
261
262
263
264
265
266
267
# File 'sample/tkextlib/tile/demo.rb', line 259

def makeCompoundMenu(mb)
  menu = TkMenu.new(mb)
  %w(text image none top bottom left right center).each{|str|
    menu.add(:radiobutton, :label=>Tk.tk_call('string', 'totitle', str), 
             :variable=>$V.ref(:COMPOUND), :value=>str, 
             :command=>proc{ changeToolbars() })
  }
  menu
end

#makeNotebookObject

Notebook demonstration:



316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'sample/tkextlib/tile/demo.rb', line 316

def makeNotebook
  nb = Tk::Tile::Notebook.new($BASE, :padding=>6)
  nb.enable_traversal
  client = Tk::Tile::Frame.new(nb)
  nb.add(client, :text=>'Demo', :underline=>0)
  nb.select(client)

  scales = Tk::Tile::Frame.new(nb)
  nb.add(scales, :text=>'Scales')
  combo = Tk::Tile::Frame.new(nb)
  nb.add(combo, :text=>'Combobox', :underline=>7)
  tree = Tk::Tile::Frame.new(nb)
  nb.add(tree, :text=>'Tree')
  others = Tk::Tile::Frame.new(nb)
  nb.add(others, :text=>'Others', :underline=>4)

  [nb, client, scales, combo, tree, others]
end

#makeThemeControl(parent) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'sample/tkextlib/tile/demo.rb', line 75

def makeThemeControl(parent)
  c = Tk::Tile::Labelframe.new(parent, :text=>'Theme')
  $THEMELIST.each{|theme, name|
    b = Tk::Tile::Radiobutton.new(c, :text=>name, :value=>theme, 
                                  :variable=>$V.ref(:THEME), 
                                  :command=>proc{setTheme(theme)})
    b.grid(:sticky=>:ew)
    unless (TkPackage.names.find{|n| n == "tile::theme::#{theme}"})
      b.state(:disabled)
    end
  }
  $RUBY_THEMELIST.each{|theme, name, available|
    b = Tk::Tile::Radiobutton.new(c, :text=>name, :value=>theme, 
                                  :variable=>$V.ref(:THEME), 
                                  :command=>proc{setTheme(theme)})
    b.grid(:sticky=>:ew)
    b.state(:disabled) unless available
  }
  c
end

#makeThemeMenu(parent) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'sample/tkextlib/tile/demo.rb', line 96

def makeThemeMenu(parent)
  m = TkMenu.new(parent)
  $THEMELIST.each{|theme, name|
    m.add(:radiobutton, :label=>name, :variable=>$V.ref(:THEME), 
          :value=>theme, :command=>proc{setTheme(theme)})
    unless (TkPackage.names.find{|n| n == "tile::theme::#{theme}"})
      m.entryconfigure(:end, :state=>:disabled)
    end
  }
  $RUBY_THEMELIST.each{|theme, name, available|
    m.add(:radiobutton, :label=>name, :variable=>$V.ref(:THEME), 
          :value=>theme, :command=>proc{setTheme(theme)})
    m.entryconfigure(:end, :state=>:disabled) unless available
  }
  m
end

#makeToolbarsObject

Toolbar button standard vs. tile comparison:



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'sample/tkextlib/tile/demo.rb', line 192

def makeToolbars
  #
  # Tile toolbar:
  #
  tb = Tk::Tile::Frame.new($BASE, :class=>'Toolbar')
  $TOOLBARS << tb
  i = 0
  $BUTTONS.each{|icon|
    i += 1
    Tk::Tile::Button.new(tb, :text=>icon, :image=>$ICON[icon], 
                         :compound=>$V[:COMPOUND], 
                         :style=>:Toolbutton).grid(:row=>0, :column=>i, 
                                                   :sticky=>:news)
  }
  $CHECKBOXES.each{|icon|
    i += 1
    Tk::Tile::Checkbutton.new(tb, :text=>icon, :image=>$ICON[icon], 
                              :variable=>$V.ref(icon), 
                              :compound=>$V[:COMPOUND], 
                              :style=>:Toolbutton).grid(:row=>0, :column=>i, 
                                                        :sticky=>:news)
  }

  mb = Tk::Tile::Menubutton.new(tb, :text=>'toolbar', :image=>$ICON['file'], 
                                :compound=>$V[:COMPOUND])
  mb.configure(:menu=>makeCompoundMenu(mb))
  i += 1
  mb.grid(:row=>0, :column=>i, :sticky=>:news)

  i += 1
  tb.grid_columnconfigure(i, :weight=>1)

  #
  # Standard toolbar:
  #
  tb = TkFrame.new($BASE, :class=>'Toolbar')
  $TOOLBARS << tb
  i = 0
  $BUTTONS.each{|icon|
    i += 1
    TkButton.new(tb, :text=>icon, :image=>$ICON[icon], 
                 :compound=>$V[:COMPOUND], :relief=>:flat, 
                 :overrelief=>:raised).grid(:row=>0, :column=>i, 
                                            :sticky=>:news)
  }
  $CHECKBOXES.each{|icon|
    i += 1
    TkCheckbutton.new(tb, :text=>icon, :image=>$ICON[icon], 
                      :variable=>$V.ref(icon), :compound=>$V[:COMPOUND], 
                      :indicatoron=>false, :selectcolor=>'', :relief=>:flat, 
                      :overrelief=>:raised).grid(:row=>0, :column=>i, 
                                                 :sticky=>:news)
  }

  mb = TkMenubutton.new(tb, :text=>'toolbar', :image=>$ICON['file'], 
                        :compound=>$V[:COMPOUND])
  mb.configure(:menu=>makeCompoundMenu(mb))
  i += 1
  mb.grid(:row=>0, :column=>i, :sticky=>:news)

  i += 1
  tb.grid_columnconfigure(i, :weight=>1)
end

#messageReadDelayed(t) ⇒ Object



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'sample/tkextlib/treectrl/outlook-newgroup.rb', line 186

def messageReadDelayed(t)
  @Message[:afterId].delete(:id)
  i = @Message[:afterId][:item]
  return unless t.selection_includes(i)

  # This message is not read
  unless @Message[:read][i]
    # Read the message
    t.item_state_set(i, 'read')
    @Message[:read][i] = true

    # Check ancestors (except root)
    t.item_ancestors(i)[0..-2].each{|i2|
      # This ancestor has no more unread descendants
      t.item_state_set(i2, '!unread') unless anyUnreadDescendants(t, i2)
    }
  end
end

#mkTextConfig(w, x, y, option, value, color) ⇒ Object

Next, create some items that allow the text’s anchor position to be edited.



91
92
93
94
95
96
# File 'sample/demos-en/ctext.rb', line 91

def mkTextConfig(w,x,y,option,value,color)
  item = TkcRectangle.new(w, x, y, x+30, y+30, 
                          'outline'=>'black', 'fill'=>color, 'width'=>1)
  item.bind('1', proc{$ctag_text.configure option, value})
  w.addtag_withtag('config', item)
end

#newRoom(w) ⇒ Object

newRoom – This method is invoked whenever the mouse enters a room in the floorplan. It changes tags so that the current room is highlighted.

Arguments: w - The name of the canvas window.



68
69
70
71
72
# File 'sample/demos-en/floor.rb', line 68

def newRoom(w)
  id = w.find_withtag('current')[0]
  $currentRoom.value = $floorLabels[id.id] if id != ""
  Tk.update(true)
end

#newRoom2(w) ⇒ Object

newRoom2 – This method is invoked whenever the mouse enters a room in the floorplan. It changes tags so that the current room is highlighted.

Arguments: w - The name of the canvas window.



68
69
70
71
72
# File 'sample/demos-en/floor2.rb', line 68

def newRoom2(w)
  id = w.find_withtag('current')[0]
  $currentRoom2.value = $floorLabels2[id.id] if id != ""
  Tk.update(true)
end

#optionButton1(w, x, y) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'sample/tkextlib/treectrl/www-options.rb', line 110

def optionButton1(w, x, y)
  w.set_focus
  id = w.identify(x, y)
  if id[0] == 'header'
    Tk::TreeCtrl::BindCallback.buttonPress1(w, x, y)
  elsif id.empty?
    @Priv['buttonMode'] = ''
  else
    @Priv['buttonMode'] = ''
    item = id[1]
    w.selection_modify(item, :all)
    w.activate(item)
    return if @Option[:option, item] == ''
    group = @Option[:group, item]
    if group == ''
      # a checkbutton
      w.item_state_set(item, '~on')
      if @Option[:setting, item] == 'on'
        setting = :off
      else
        setting = :on
      end
      @Option[:setting, item] = setting
    else
      # a radiobutton
      current = @Option[:current, group]
      return if current == item.to_s
      w.item_state_set(current, '!on')
      w.item_state_set(item, 'on')
      @Option[:setting, item] = :on
      @Option[:current, group] = item
    end
  end
end

#optionButton1_2(w, x, y) ⇒ Object



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'sample/tkextlib/treectrl/www-options.rb', line 238

def optionButton1_2(w, x, y)
  w.set_focus
  id = w.identify(x, y)
  if id[0] == 'header'
    Tk::TreeCtrl::BindCallback.buttonPress1(w, x, y)
  elsif id.empty?
    @Priv['buttonMode'] = ''
  else
    @Priv['buttonMode'] = ''
    item = id[1]
    w.selection_modify(item, :all)
    w.activate(item)
    return if @Option[:option, item] == ''
    group = @Option[:group, item]
    if group == ''
      # a checkbutton
      if @Option[:setting, item] == 'on'
        setting = :off
      else
        setting = :on
      end
      w.item_element_configure(item, 0, 'e1', 
                               :image=>@images["internet-check-#{setting}"])
      @Option[:setting, item] = setting
    else
      # a radiobutton
      current = @Option[:current, group]
      return if current == item.to_s
      w.item_element_configure(current, 0, 'e1', 
                               :image=>@images["internet-radio-off"])
      w.item_element_configure(item, 0, 'e1', 
                               :image=>@images["internet-radio-on"])
      @Option[:setting, item] = :on
      @Option[:current, group] = item
    end
  end
end

#optionLeave1(w, x, y) ⇒ Object



283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'sample/tkextlib/treectrl/www-options.rb', line 283

def optionLeave1(w, x, y)
  # This is called when I do ButtonPress-1 on Unix for some reason,
  # and buttonMode is undefined.
  begin
    mode = @Priv['buttonMode']
  rescue
  else
    case mode
    when 'header'
      t.column_configure(@Priv['column'], :sunken=>false)
    end
  end
end

#optionMenu(menubutton, varName, firstValue, *rest) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'sample/demos-en/menubu.rb', line 8

def optionMenu(menubutton, varName, firstValue, *rest)
  varName.value = firstValue
  configoptions = {'textvariable'=>varName,'indicatoron'=>'on',
    'relief'=>'raised','borderwidth'=>2,'highlightthickness'=>2,
    'anchor'=>'c','direction'=>'flush'}
  configoptions.each {|key, value|
    menubutton.configure(key, value)
  }
  menu = TkMenu.new(menubutton) {
    tearoff 'off'
    add 'radio', 'label'=>firstValue, 'variable'=>varName
  }
  menubutton.menu(menu)
  for i in rest
    menu.add 'radio', 'label'=>i, 'variable'=>varName
  end
  
  return menu
end

#optionMotion1(w, x, y) ⇒ Object



276
277
278
279
280
281
# File 'sample/tkextlib/treectrl/www-options.rb', line 276

def optionMotion1(w, x, y)
  case @Priv['buttonMode']
  when 'resize', 'header'
    Tk::TreeCtrl::BindCallback.motion1(w, x, y)
  end
end

#optionRelease1(w, x, y) ⇒ Object



297
298
299
300
301
302
303
# File 'sample/tkextlib/treectrl/www-options.rb', line 297

def optionRelease1(w, x, y)
  case @Priv['buttonMode']
  when 'resize', 'header'
    Tk::TreeCtrl::BindCallback.release1(w, x, y)
  end
  @Priv['buttonMode'] = ''
end

#pbMode(progress, vprogress) ⇒ Object



503
504
505
506
507
508
509
510
# File 'sample/tkextlib/tile/demo.rb', line 503

def pbMode(progress, vprogress)
  if vprogress.mode != $V[:PBMODE]
    vprogress.value(vprogress.maximum - vprogress.value)
  end

  progress.mode $V[:PBMODE]
  vprogress.mode $V[:PBMODE]
end

#pbStart(progress, vprogress) ⇒ Object



514
515
516
517
518
519
# File 'sample/tkextlib/tile/demo.rb', line 514

def pbStart(progress, vprogress)
  # $V[:PBMODE] = 'indeterminate'
  pbMode(progress, vprogress)
  progress.start 10
  vprogress.start
end

#pbStop(progress, vprogress) ⇒ Object



523
524
525
526
# File 'sample/tkextlib/tile/demo.rb', line 523

def pbStop(progress, vprogress)
  progress.stop
  vprogress.stop
end

#phoneSkipLeft(widget) ⇒ Object

phoneSkipLeft – Skip over fixed characters in a phone-number string when moving left.

Arguments: widget - The entry widget containing the phone-number.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'sample/demos-en/entry3.rb', line 105

def phoneSkipLeft(widget)
  idx = widget.index('insert')
  if idx == 8
    # Skip back two extra characters
    widget.cursor = idx - 2
  elsif idx == 7 || idx == 12
    # Skip back one extra character
    widget.cursor = idx - 1
  elsif idx <= 3
    # Can't move any further
    Tk.bell
    Tk.callback_break
  end
end

#phoneSkipRight(widget, add = 0) ⇒ Object

phoneSkipRight – Skip over fixed characters in a phone-number string when moving right.

Arguments: widget - The entry widget containing the phone-number. add - Offset to add to index before calculation (used by validation.)



126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'sample/demos-en/entry3.rb', line 126

def phoneSkipRight(widget, add = 0)
  idx = widget.index('insert')
  if (idx + add == 5)
    # Skip forward two extra characters
    widget.cursor = idx + 2
  elsif (idx + add == 6 || idx + add == 10)
    # Skip forward one extra character
    widget.cursor = idx + 1
  elsif (idx + add == 15 && add == 0)
    # Can't move any further
    Tk.bell
    Tk.callback_break
  end
end

#plotDown(w, x, y) ⇒ Object

plotDown – This method is invoked when the mouse is pressed over one of the data points. It sets up state to allow the point to be dragged.

Arguments: w - The canvas window. x, y - The coordinates of the mouse press.



101
102
103
104
105
106
107
# File 'sample/demos-en/plot.rb', line 101

def plotDown (w, x, y)
  w.dtag 'selected'
  w.addtag_withtag 'selected', 'current'
  w.raise 'current'
  $plot['lastX'] = x
  $plot['lastY'] = y
end

#plotMove(w, x, y) ⇒ Object

plotMove – This method is invoked during mouse motion events. It drags the current item.

Arguments: w - The canvas window. x, y - The coordinates of the mouse.



117
118
119
120
121
# File 'sample/demos-en/plot.rb', line 117

def plotMove (w, x, y)
  w.move 'selected', x - $plot['lastX'], y - $plot['lastY']
  $plot['lastX'] = x
  $plot['lastY'] = y
end

#pop_upObject



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'sample/tkbiff.rb', line 121

def pop_up
  outcount = 0;
  $list.delete 0, 'end'
  f = open($spool, "r")
  while !f.eof?
    mail = Mail.new(f)
    date, from, subj =  mail.header['Date'], mail.header['From'], mail.header['Subject']
    next if !date
    y = m = d = 0
    y, m, d = parsedate(date) if date
    from = "sombody@somewhere" if ! from
    subj = "(nil)" if ! subj
    from = decode_b(from)
    subj = decode_b(subj)
    $list.insert 'end', format('%-02d/%02d/%02d [%-28.28s] %s',y,m,d,from,subj)
    outcount += 1
  end
  f.close
  if outcount == 0
    $list.insert 'end', "You have no mail."
  else
    $list.see 'end'
  end
  $top.deiconify
  Tk.after 2000, proc{$top.iconify}
end

#pthread_checkObject



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'extconf.rb', line 98

def pthread_check()
  tcl_major_ver = nil
  tcl_minor_ver = nil

  # Is tcl-thread given by user ?
  case enable_config("tcl-thread")
  when true
    tcl_enable_thread = true
  when false
    tcl_enable_thread = false
  else
    tcl_enable_thread = nil
  end

  if (tclConfig = with_config("tclConfig-file"))
    if tcl_enable_thread == true
      puts("Warning: --with-tclConfig-file option is ignored, because --enable-tcl-thread option is given.")
    elsif tcl_enable_thread == false
      puts("Warning: --with-tclConfig-file option is ignored, because --disable-tcl-thread option is given.")
    else
      # tcl-thread is unknown and tclConfig.sh is given
      begin
        open(tclConfig, "r") do |cfg|
          while line = cfg.gets()
            if line =~ /^\s*TCL_THREADS=(0|1)/
              tcl_enable_thread = ($1 == "1")
              break
            end

            if line =~ /^\s*TCL_MAJOR_VERSION=("|')(\d+)\1/
              tcl_major_ver = $2
              if tcl_major_ver =~ /^[1-7]$/
                tcl_enable_thread = false
                break
              end
              if tcl_major_ver == "8" && tcl_minor_ver == "0"
                tcl_enable_thread = false
                break
              end
            end

            if line =~ /^\s*TCL_MINOR_VERSION=("|')(\d+)\1/
              tcl_minor_ver = $2
              if tcl_major_ver == "8" && tcl_minor_ver == "0"
                tcl_enable_thread = false
                break
              end
            end
          end
        end

        if tcl_enable_thread == nil
          # not find definition
          if tcl_major_ver
            puts("Warning: '#{tclConfig}' doesn't include TCL_THREADS definition.")
          else
            puts("Warning: '#{tclConfig}' may not be a tclConfig file.")
          end
          tclConfig = false
        end
      rescue Exception
        puts("Warning: fail to read '#{tclConfig}'!! --> ignore the file")
        tclConfig = false
      end
    end
  end

  if tcl_enable_thread == nil && !tclConfig
    # tcl-thread is unknown and tclConfig is unavailable
    begin
      try_run_available = try_run("int main() { exit(0); }")
    rescue Exception
      # cannot try_run. Is CROSS-COMPILE environment?
      puts(%Q'\
*****************************************************************************
**
** PTHREAD SUPPORT CHECK WARNING: 
**
**   We cannot check the consistency of pthread support between Ruby 
**   and the Tcl/Tk library in your environment (are you perhaps
**   cross-compiling?). If pthread support for these 2 packages is
**   inconsistent you may find you get errors when running Ruby/Tk
**   (e.g. hangs or segmentation faults).  We strongly recommend
**   you to check the consistency manually.
**
*****************************************************************************
')
      return true
    end
  end

  if tcl_enable_thread == nil
    # tcl-thread is unknown
    if try_run(<<EOF)
#include <tcl.h>
int main() { 
   Tcl_Interp *ip;
   ip = Tcl_CreateInterp();
   exit((Tcl_Eval(ip, "set tcl_platform(threaded)") == TCL_OK)? 0: 1);
}
EOF
      tcl_enable_thread = true
    elsif try_run(<<EOF)
#include <tcl.h>
static Tcl_ThreadDataKey dataKey;
int main() { exit((Tcl_GetThreadData(&dataKey, 1) == dataKey)? 1: 0); }
EOF
      tcl_enable_thread = true
    else
      tcl_enable_thread = false
    end
  end

  # check pthread mode
  if (macro_defined?('HAVE_NATIVETHREAD', '#include "ruby.h"'))
    # ruby -> enable
    unless tcl_enable_thread
      # ruby -> enable && tcl -> disable
      puts(%Q'\
*****************************************************************************
**
** PTHREAD SUPPORT MODE WARNING: 
**
**   Ruby is compiled with --enable-pthread, but your Tcl/Tk library
**   seems to be compiled without pthread support. Although you can
**   create the tcltklib library, this combination may cause errors
**   (e.g. hangs or segmentation faults). If you have no reason to
**   keep the current pthread support status, we recommend you reconfigure
**   and recompile the libraries so that both or neither support pthreads.
**
**   If you want change the status of pthread support, please recompile 
**   Ruby without "--enable-pthread" configure option or recompile Tcl/Tk 
**   with "--enable-threads" configure option (if your Tcl/Tk is later 
**   than or equal to Tcl/Tk 8.1).
**
*****************************************************************************
')
    end

    # ruby -> enable && tcl -> enable/disable
    if tcl_enable_thread
      $CPPFLAGS += ' -DWITH_TCL_ENABLE_THREAD=1'
    else
      $CPPFLAGS += ' -DWITH_TCL_ENABLE_THREAD=0'
    end

    return true

  else
    # ruby -> disable
    if tcl_enable_thread
      # ruby -> disable && tcl -> enable
      puts(%Q'\
*****************************************************************************
**
** PTHREAD SUPPORT MODE ERROR: 
**
**   Ruby is not compiled with --enable-pthread, but your Tcl/Tk 
**   library seems to be compiled with pthread support. This
**   combination may cause frequent hang or segmentation fault
**   errors when Ruby/Tk is working. We recommend that you NEVER
**   create the library with such a combination of pthread support.
**
**   Please recompile Ruby with the "--enable-pthread" configure option
**   or recompile Tcl/Tk with the "--disable-threads" configure option.
**
*****************************************************************************
')
      $CPPFLAGS += ' -DWITH_TCL_ENABLE_THREAD=1'
      return false
    else
      # ruby -> disable && tcl -> disable
      $CPPFLAGS += ' -DWITH_TCL_ENABLE_THREAD=0'
      return true
    end
  end
end

#puzzleSwitch(w, num) ⇒ Object

puzzleSwitch – This procedure is invoked when the user clicks on a particular button; if the button is next to the empty space, it moves the button into the empty space.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'sample/demos-en/puzzle.rb', line 102

def puzzleSwitch(w, num)
  if ( ($ypos[num] >= ($ypos['space'] - 0.01))     \
      && ($ypos[num] <= ($ypos['space'] + 0.01))   \
      && ($xpos[num] >= ($xpos['space'] - 0.26))   \
      && ($xpos[num] <= ($xpos['space'] + 0.26)))  \
    || (($xpos[num] >= ($xpos['space'] - 0.01))    \
        && ($xpos[num] <= ($xpos['space'] + 0.01)) \
        && ($ypos[num] >= ($ypos['space'] - 0.26)) \
        && ($ypos[num] <= ($ypos['space'] + 0.26)))
    tmp = $xpos['space']
    $xpos['space'] = $xpos[num]
    $xpos[num] = tmp
    tmp = $ypos['space']
    $ypos['space'] = $ypos[num]
    $ypos[num] = tmp
    w.place('relx'=>$xpos[num], 'rely'=>$ypos[num])
  end
end

#quit(button) ⇒ Object



56
57
58
59
# File 'sample/tkdialog.rb', line 56

def quit(button)
  print "You pressed the \"#{button}\" button;  bye-bye!\n"
  exit
end

#rand_boolObject



28
29
30
# File 'sample/tkextlib/vu/vu_demo.rb', line 28

def rand_bool
  
end

#random_NObject



2
3
4
# File 'sample/tkextlib/treectrl/random.rb', line 2

def random_N
  @RandomN[0] || 500
end

#randomAutoScanCheck(t, x, y) ⇒ Object

Same as TreeCtrl::AutoScanCheck, but calls RandomMotion and RandomAutoScanCheckAux



454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
# File 'sample/tkextlib/treectrl/random.rb', line 454

def randomAutoScanCheck(t, x, y)
  x1, y1, x2, y2 = t.contentbox
  margin = t.winfo_pixels(t.scrollmargin)
  if x < x1 + margin || x >= x2 - margin || y < y1 + margin || y >= y2 - margin
    if ! @Priv.exist?(:autoscan, :afterId, t)
      if y >= y2 - margin
        t.yview(:scroll, 1, :units)
        delay = t.yscrolldelay
      elsif y < y1 + margin
        t.yview(:scroll, -1, :units)
        delay = t.yscrolldelay
      elsif x >= x2 - margin
        t.xview(:scroll, 1, :units)
        delay = t.xscrolldelay
      elsif x < x1 + margin
        t.xview(:scroll, -1, :units)
        delay = t.xscrolldelay
      end
      if @Priv.exist?(:autoscan, :scanning, t)
        delay = delay[1] if delay.kind_of?(Array)
      else
        delay = delay[0] if delay.kind_of?(Array)
        @Priv[:autoscan, :scanning, t] = true
      end
      case @Priv['buttonMode']
      when 'drag', 'marquee'
        randomMotion(t, x, y)
      end
      @Priv[:autoscan, :afterId, t] = 
        Tk.after(delay, proc{ randomAutoScanCheckAux(t) })
    end
    return
  end
  Tk::TreeCtrl::BindCallback.autoScanCancel(t)
end

#randomAutoScanCheckAux(t) ⇒ Object



490
491
492
493
494
495
# File 'sample/tkextlib/treectrl/random.rb', line 490

def randomAutoScanCheckAux(t)
  @Priv.unset(:autoscan, :afterId, t)
  x = t.winfo_pointerx - t.winfo_rootx
  y = t.winfo_pointery - t.winfo_rooty
  randomAutoScanCheck(t, x, y)
end

#randomButton1(t, x, y) ⇒ Object



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'sample/tkextlib/treectrl/random.rb', line 176

def randomButton1(t, x, y)
  t.set_focus
  id = t.identify(x, y)
  puts id.inspect
  @Priv['buttonMode'] = ''

  # Click outside any item
  if id.empty?
    t.selection_clear

  # Click in header
  elsif id[0] == 'header'
    Tk::TreeCtrl::BindCallback.buttonPress1(t, x, y)

  # Click in item
  else
    where, item, arg1, arg2, arg3, arg4 = id
    case arg1
    when 'button'
      if $Version_1_1_OrLater
        t.item_toggle(item)
      else # TreeCtrl 1.0
        t.toggle(item)
      end

    when 'line'
      if $Version_1_1_OrLater
        t.item_toggle(arg2)
      else # TreeCtrl 1.0
        t.toggle(arg2)
      end

    when 'column'
      ok = false
      # Clicked an element
      if id.length == 6
        column = id[3]
        e = id[5]
        @Priv.list_element(:sensitive, t).each{|lst|
          c, s, *eList = TkComm.simplelist(lst)
          next if column != t.column_index(c)
          next if t.item_style_set(item, c) != s
          next if eList.find{|le| le == e} == nil
          ok = true
          break
        }
      end
      unless ok
        t.selection_clear
        return
      end

      @Priv[:drag, :motion] = 0
      @Priv[:drag, :x] = t.canvasx(x)
      @Priv[:drag, :y] = t.canvasy(y)
      @Priv[:drop] = ''

      if @Priv['selectMode'] == 'add'
          Tk::TreeCtrl::BindCallback.beginExtend(t, item)
      elsif @Priv['selectMode'] == 'toggle'
          Tk::TreeCtrl::BindCallback.beginToggle(t, item)
      elsif ! t.selection_includes(item)
          Tk::TreeCtrl::BindCallback.beginSelect(t, item)
      end
      t.activate(item)

      if t.selection_includes(item)
        @Priv['buttonMode'] = 'drag'
      end
    end
  end
end

#randomDrop(t, target, src, pos) ⇒ Object



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
# File 'sample/tkextlib/treectrl/random.rb', line 373

def randomDrop(t, target, src, pos)
  parentList = []
  case pos
  when 'lastchild'
    parent = target
  when 'prevsibling'
    parent = t.item_parent(target)
  when 'nextsibling'
    parent = t.item_parent(target)
  end
  src.each{|item|
    # Ignore any item whose ancestor is also selected
    ignore = false
    t.item_ancestors(item).each{|ancestor|
      if src.find{|val| val.to_s == ancestor.to_s}
        ignore = true
        break
      end
    }
    next if ignore

    # Update the old parent of this moved item later
    unless parentList.find{|val| val.to_s == item.to_s}
      parentList << t.item_parent(item)
    end

    # Add to target
    t.__send__("item_#{pos}", target, item)

    # Update text: parent
    t.item_element_configure(item, 'parent', 'e6', :text=>parent)

    # Update text: depth
    t.item_element_configure(item, 'depth', 'e6', :text=>t.depth(item))

    # Recursively update text: depth
    itemList = []
    item = t.item_firstchild(item)
    itemList << item if item != ''

    while item = itemList.pop
      t.item_element_configure(item, 'depth', 'e6', :text=>t.depth(item))

      item2 = t.item_nextsibling(item)
      itemList << item2 if item2 != ''

      item2 = t.item_firstchild(item)
      itemList << item2 if item2 != ''
    end
  }

  # Update items that lost some children
  parentList.each{|item|
    numChildren = t.item_numchildren(item)
    if numChildren == 0
      if $Version_1_1_OrLater
        t.item_configure(item, :button=>false)
      else # TreeCtrl 1.0
        t.item_hasbutton(item, false)
      end
      t.item_style_map(item, 'item', 's2', ['e3', 'e3'])
    else
      t.item_element_configure(item, 'item', 'e4', :text=>"(#{numChildren})")
    end
  }

  # Update the target that gained some children
  if t.item_style_set(parent, 0) != 's1'
    if $Version_1_1_OrLater
      t.item_configure(parent, :button=>true)
    else # TreeCtrl 1.0
      t.item_hasbutton(parent, true)
    end
    t.item_style_map(parent, 'item', 's1', ['e3', 'e3'])
  end
  numChildren = t.item_numchildren(parent)
  t.item_element_configure(parent, 'item', 'e4', :text=>"(#{numChildren})")
end

#randomLeave1(t, x, y) ⇒ Object



346
347
348
349
350
351
352
353
354
# File 'sample/tkextlib/treectrl/random.rb', line 346

def randomLeave1(t, x, y)
  # This is called when I do ButtonPress-1 on Unix for some reason,
  # and buttonMode is undefined.
  return unless @Priv.exist?('buttonMode')
  case @Priv['buttonMode']
  when 'header'
    Tk::TreeCtrl::BindCallback.leave1(t, x, y)
  end
end

#randomMotion(t, x, y) ⇒ Object



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'sample/tkextlib/treectrl/random.rb', line 259

def randomMotion(t, x, y)
  case @Priv['buttonMode']
  when 'resize', 'header'
    Tk::TreeCtrl::BindCallback.motion1(t, x, y)

  when 'drag'
    # Detect initial mouse movement
    unless @Priv.bool_element(:drag, :motion)
      @Priv[:selection] = t.selection_get
      @Priv[:drop] = ''
      t.dragimage_clear
      # For each selected item, add 2nd and 3rd elements of
      # column "item" to the dragimage
      @Priv.list_element(:selection).each{|i|
        @Priv.list_element(:dragimage,t).each{|lst|
          c, s, *eList = TkComm.simplelist(lst)
          if t.item_style_set(i, c) == s
            t.dragimage_add(i, c, *eList)
          end
        }
      }
      @Priv[:drag,:motion] = true
    end

    # Find the item under the cursor
    cursor = 'X_cursor'
    drop = ''
    id = t.identify(x, y)
    ok = false
    if !id.empty? && id[0] == 'item' && id.length == 6
      item = id[1]
      column = id[3]
      e = id[5]
      @Priv.list_element(:sensitive,t).each{|lst|
        c, s, *eList = TkComm.simplelist(lst)
        next if column != t.column_index(c)
        next if t.item_style_set(item, c) != s
        next unless eList.find{|val| val.to_s == e.to_s}
        ok = true
        break
      }
      ok = true if @Priv.list_element(:sensitive,t).find{|val| TkComm.simplelist(val).index(e)}
    end

    if ok
      # If the item is not in the pre-drag selection
      # (i.e. not being dragged) see if we can drop on it
      unless @Priv.list_element(:selection).find{|val| val.to_s == item.to_s}
        drop = item
        # We can drop if dragged item isn't an ancestor
        @Priv.list_element(:selection).each{|item2|
          if t.item_isancestor(item2, item)
            drop = ''
            break
          end
        }
        if drop != ''
          x1, y1, x2, y2 = t.item_bbox(drop)
          if y < y1 + 3
            cursor = 'top_side'
            @Priv[:drop,:pos] = 'prevsibling'
          elsif y >= y2 - 3
            cursor = 'bottom_side'
            @Priv[:drop,:pos] = 'nextsibling'
          else
            cursor = ''
            @Priv[:drop,:pos] = 'lastchild'
          end
        end
      end
    end

    t[:cursor] = cursor if t[:cursor] != cursor

    # Select the item under the cursor (if any) and deselect
    # the previous drop-item (if any)
    t.selection_modify(drop, @Priv[:drop])
    @Priv[:drop] = drop

    # Show the dragimage in its new position
    x = t.canvasx(x) - @Priv.numeric_element(:drag,:x)
    y = t.canvasx(y) - @Priv.numeric_element(:drag,:y)
    t.dragimage_offset(x, y)
    t.dragimage_configure(:visible=>true)
  end
end

#randomMotion1(t, x, y) ⇒ Object



249
250
251
252
253
254
255
256
257
# File 'sample/tkextlib/treectrl/random.rb', line 249

def randomMotion1(t, x, y)
  case @Priv['buttonMode']
  when 'resize', 'header'
    Tk::TreeCtrl::BindCallback.motion1(t, x, y)
  when 'drag'
    randomAutoScanCheck(t, x, y)
    randomMotion(t, x, y)
  end
end

#randomRelease1(t, x, y) ⇒ Object



356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'sample/tkextlib/treectrl/random.rb', line 356

def randomRelease1(t, x, y)
  case @Priv['buttonMode']
  when 'resize', 'header'
    Tk::TreeCtrl::BindCallback.release1(t, x, y)
  when 'drag'
    Tk::TreeCtrl::BindCallback.autoScanCancel(t)
    t.dragimage_configure(:visible=>false)
    t.selection_modify('', @Priv[:drop])
    t[:cursor] = ''
    if @Priv[:drop] != ''
      randomDrop(t, @Priv[:drop], @Priv.list_element(:selection), 
                 @Priv[:drop, :pos])
    end
  end
  @Priv['buttonMode'] = ''
end

#repeatDemoObject

Repeating buttons demo:



947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
# File 'sample/tkextlib/tile/demo.rb', line 947

def repeatDemo
  if defined?($repeatDemo) && $repeatDemo.exist?
    $repeatDemo.deiconify; return
  end
  $repeatDemo = TkToplevel.new(:title=>'Repeating button')

  f = Tk::Tile::Frame.new($repeatDemo)
  b = Tk::Tile::Button.new(f, :class=>'Repeater', :text=>'Press and hold')
  if version?('0.6')
    p = Tk::Tile::Progressbar.new(f, :orient=>:horizontal, :maximum=>10)
  else # progressbar is not supported
    p = Tk::Tile::Progress.new(f, :orient=>:horizontal, :from=>0, :to=>10)
    def p.step
      i = self.get + 1
      i = self.from if i > self.to
      self.set(i)
    end
  end
  b.command {p.step}

  b.pack(:side=>:left, :expand=>false, :fill=>:none, :padx=>6, :pady=>6)
  p.pack(:side=>:right, :expand=>true, :fill=>:x, :padx=>6, :pady=>6)
  f.pack(:expand=>true, :fill=>:both)
end

#roomChanged(w, *args) ⇒ Object

roomChanged – This method is invoked whenever the currentRoom variable changes. It highlights the current room and unhighlights any previous room.

Arguments: w - The canvas window displaying the floorplan. args - Not used.



82
83
84
85
86
87
88
89
# File 'sample/demos-en/floor.rb', line 82

def roomChanged(w,*args)
  w.delete('highlight')
  item = $floorItems[$currentRoom.value]
  return if item == nil
  new = TkcPolygon.new(w, *(w.coords(item)))
  new.configure('fill'=>$floor_colors['active'], 'tags'=>'highlight')
  w.raise(new, 'marker')
end

#roomChanged2(w, *args) ⇒ Object

roomChanged2 – This method is invoked whenever the currentRoom variable changes. It highlights the current room and unhighlights any previous room.

Arguments: w - The canvas window displaying the floorplan. args - Not used.



82
83
84
85
86
87
88
89
# File 'sample/demos-en/floor2.rb', line 82

def roomChanged2(w,*args)
  w.delete('highlight')
  item = $floorItems2[$currentRoom2.value]
  return if item == nil
  new = TkcPolygon.new(w, *(w.coords(item)))
  new.configure('fill'=>$floor2_colors['active'], 'tags'=>'highlight')
  w.raise(new, 'marker')
end

#rulerMkTab(c, x, y) ⇒ Object

rulerMkTab – This method creates a new triangular polygon in a canvas to represent a tab stop.

Arguments: c - The canvas window. x, y - Coordinates at which to create the tab stop.



17
18
19
20
# File 'sample/demos-en/ruler.rb', line 17

def rulerMkTab(c,x,y)
  v = $demo_rulerInfo
  TkcPolygon.new(c, x, y, x+v.size, y+v.size, x-v.size, y+v.size)
end

#rulerMoveTab(c, x, y) ⇒ Object

rulerMoveTab – This method is invoked during mouse motion events to drag a tab. It adjusts the position of the tab, and changes its appearance if it is about to be dragged out of the ruler.

Arguments: c - The canvas widget. x, y - The coordinates of the mouse.



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'sample/demos-en/ruler.rb', line 165

def rulerMoveTab(c,x,y)
  v = $demo_rulerInfo
  return if c.find_withtag('active') == []
  cx = c.canvasx(x,v.grid)
  cy = c.canvasy(y)
  cx = v.left if cx < v.left
  cx = v.right if cx > v.right
  if (cy >= v.top && cy <= v.bottom)
    cy = v.top+2
    c.itemconfigure('active', v.activeStyle)
  else
    cy = cy-v.size-2
    c.itemconfigure('active', v.deleteStyle)
  end
  c.move('active', cx-v.x, cy-v.y)
  v.x = cx
  v.y = cy
end

#rulerNewTab(c, x, y) ⇒ Object

rulerNewTab – Does all the work of creating a tab stop, including creating the triangle object and adding tags to it to give it tab behavior.

Arguments: c - The canvas window. x, y - The coordinates of the tab stop.



128
129
130
131
132
133
134
135
# File 'sample/demos-en/ruler.rb', line 128

def rulerNewTab(c,x,y)
  v = $demo_rulerInfo
  c.addtag_withtag('active', rulerMkTab(c,x,y))
  c.addtag_withtag('tab', 'active')
  v.x = x
  v.y = y
  rulerMoveTab(c,x,y)
end

#rulerReleaseTab(c) ⇒ Object

rulerReleaseTab – This method is invoked during button release events that end a tab drag operation. It deselects the tab and deletes the tab if it was dragged out of the ruler.

Arguments: c - The canvas widget. x, y - The coordinates of the mouse.



193
194
195
196
197
198
199
200
201
202
# File 'sample/demos-en/ruler.rb', line 193

def rulerReleaseTab(c)
  v = $demo_rulerInfo
  return if c.find_withtag('active') == []
  if v.y != v.top+2
    c.delete('active')
  else
    c.itemconfigure('active', v.normalStyle)
    c.dtag('active')
  end
end

#rulerSelectTab(c, x, y) ⇒ Object

rulerSelectTab – This method is invoked when mouse button 1 is pressed over a tab. It remembers information about the tab so that it can be dragged interactively.

Arguments: c - The canvas widget. x, y - The coordinates of the mouse (identifies the point by

which the tab was picked up for dragging).


147
148
149
150
151
152
153
154
# File 'sample/demos-en/ruler.rb', line 147

def rulerSelectTab(c,x,y)
  v = $demo_rulerInfo
  v.x = c.canvasx(x, v.grid)
  v.y = v.top+2
  c.addtag_withtag('active', 'current')
  c.itemconfigure('active', v.activeStyle)
  c.raise('active')
end

#sbstub(sb, cmd, num, units = 'units') ⇒ Object

sbstub Used as the :command option for a scrollbar, updates the scrollbar’s position.



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'sample/tkextlib/tile/demo.rb', line 151

def sbstub(sb, cmd, num, units = 'units')
  num = TkComm.number(num)
  case cmd.to_s
  when 'moveto'
    sb.set(num, num+0.5)

  when 'scroll'
    if units.to_s == 'pages'
      delta = 0.2
    else
      delta = 0.05
    end
    current = sb.get
    sb.set(current[0] + delta * num, current[1] + delta * num)
  end
end

#scrollbarResizeDemoObject



779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
# File 'sample/tkextlib/tile/demo.rb', line 779

def scrollbarResizeDemo
  if $scrollbars
    begin
      $scrollbars.destroy
    rescue
    end
  end
  $scrollbars = TkToplevel.new(:title=>'Scrollbars', :geometry=>'200x200')
  f = TkFrame.new($scrollbars, :height=>200)
  tsb = Tk::Tile::Scrollbar.new(f, :command=>proc{|*args| sbstub(tsb, *args)})
  sb = TkScrollbar.new(f, :command=>proc{|*args| sbstub(sb, *args)})
  Tk.grid(tsb, sb, :sticky=>:news)

  sb.set(0, 0.5)  # prevent backwards-compatibility mode for old SB

  f.grid_columnconfigure(0, :weight=>1)
  f.grid_columnconfigure(1, :weight=>1)
  f.grid_rowconfigure(0, :weight=>1)

  f.pack(:expand=>true, :fill=>:both)
end

#scrollButton(c) ⇒ Object



129
130
131
132
133
# File 'sample/demos-en/cscroll.rb', line 129

def scrollButton(c)
  id = c.find_withtag('current')[0].id
  id += 1 unless c.gettags('current').include?('text')
  print "You buttoned at #{c.itemconfiginfo(id,'text')[4]}\n"
end

#scrolledWidget(parent, klass, themed, *args) ⇒ Object



290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'sample/tkextlib/tile/demo.rb', line 290

def scrolledWidget(parent, klass, themed, *args)
  if themed
    f = Tk::Tile::Frame.new(parent)
    t = klass.new(f, *args)
    vs = Tk::Tile::Scrollbar.new(f)
    hs = Tk::Tile::Scrollbar.new(f)
  else
    f = TkFrame.new(parent)
    t = klass.new(f, *args)
    vs = TkScrollbar.new(f)
    hs = TkScrollbar.new(f)
  end
  t.yscrollbar(vs)
  t.xscrollbar(hs)

  TkGrid.configure(t, vs, :sticky=>:news)
  TkGrid.configure(hs, 'x', :sticky=>:news)
  TkGrid.rowconfigure(f, 0, :weight=>1)
  TkGrid.columnconfigure(f, 0, :weight=>1)

  [f, t]
end

#scrollEnter(c) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
# File 'sample/demos-en/cscroll.rb', line 110

def scrollEnter(c)
  id = c.find_withtag('current')[0].id
  id -= 1 if c.gettags('current').include?('text')
  $oldFill = c.itemconfiginfo(id, 'fill')[4]
  if TkWinfo.depth(c) > 1
    c.itemconfigure(id, 'fill'=>'SeaGreen1')
  else
    c.itemconfigure(id, 'fill'=>'black')
    c.itemconfigure(id+1, 'fill'=>'white')
  end
end

#scrollLeave(c) ⇒ Object



122
123
124
125
126
127
# File 'sample/demos-en/cscroll.rb', line 122

def scrollLeave(c)
  id = c.find_withtag('current')[0].id
  id -= 1 if c.gettags('current').include?('text')
  c.itemconfigure(id, 'fill'=>$oldFill)
  c.itemconfigure(id+1, 'fill'=>'black')
end

#selectAndLoadDir(w, lbox) ⇒ Object

selectAndLoadDir – This procedure pops up a dialog to ask for a directory to load into the listobx and (if the user presses OK) reloads the directory listbox from the directory named in the demo’s entry.

Arguments: w - Name of the toplevel window of the demo.



37
38
39
40
41
42
43
44
# File 'sample/demos-en/image3.rb', line 37

def selectAndLoadDir(w, lbox)
  dir = Tk.chooseDirectory(:initialdir=>$dirName.value, 
                           :parent=>w, :mustexist=>true)
  if dir.length > 0
    $dirName.value = dir 
    loadDir(lbox)
  end
end

#set_class_bindObject



13
14
15
16
17
18
# File 'sample/bindtag_sample.rb', line 13

def set_class_bind
  TkButton.bind('ButtonPress-1', 
                proc{puts 'bind "ButtonPress-1" of TkButton class'})
  TkButton.bind('ButtonRelease-1', 
                proc{puts 'bind "ButtonRelease-1" of TkButton class'})
end

#set_msg(x, y, bhelp, parent) ⇒ Object

CASE4b : command is a Method object and takes 4 arguemnts



176
177
178
# File 'sample/tkballoonhelp.rb', line 176

def set_msg(x, y, bhelp, parent)
  bhelp.text "current index == #{parent.nearest(y)}"
end

#setColor(w, button, name, options) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
# File 'sample/demos-en/clrpick.rb', line 54

def setColor(w,button,name,options)
  w.grab
  initialColor = button[name]
  color = Tk.chooseColor('title'=>"Choose a #{name} color", 'parent'=>w, 
                         'initialcolor'=>initialColor)
  if color != ""
    setColor_helper(w,options,color)
  end

  w.grab('release')
end

#setColor_helper(w, options, color) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
# File 'sample/demos-en/clrpick.rb', line 66

def setColor_helper(w, options, color)
  options.each{|opt|
    begin
      w[opt] = color
    rescue
    end
  }
  TkWinfo.children(w).each{|child|
    setColor_helper child, options, color
  }
end

#setHeight(w, height) ⇒ Object



70
71
72
73
74
75
76
77
78
# File 'sample/demos-en/vscale.rb', line 70

def setHeight(w, height)
  height = height + 21
  y2 = height - 30
  if y2 < 21
    y2 = 21
  end
  w.coords 'poly',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
  w.coords 'line',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
end

#setTheme(theme) ⇒ Object



113
114
115
116
117
118
# File 'sample/tkextlib/tile/demo.rb', line 113

def setTheme(theme)
  if (TkPackage.names.find{|n| n == "tile::theme::#{theme}"})
    TkPackage.require("tile::theme::#{theme}")
  end
  Tk::Tile::Style.theme_use(theme)
end

#setWidth(w, width) ⇒ Object



66
67
68
69
70
71
72
73
74
# File 'sample/demos-en/hscale.rb', line 66

def setWidth(w, width)
  width = width + 21
  x2 = width - 30
  if x2 < 21
    x2 = 21
  end
  w.coords 'poly',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
  w.coords 'line',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
end

#show_loupe(setting = nil) ⇒ Object



1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
# File 'sample/tkextlib/treectrl/demo.rb', line 1279

def show_loupe(setting=nil)
  loupe = (setting.kind_of?(Hash))? setting: {}
  loupe[:zoom] = 3 unless loupe[:zoom]
  loupe[:x] = 0 unless loupe[:x]
  loupe[:y] = 0 unless loupe[:y]
  loupe[:auto] = true unless loupe[:auto]
  loupe[:delay] = 500 unless loupe[:delay]
  loupe[:image] = 
    TkPhotoImage.new(:width=>150, :height=>150) unless loupe[:image]

  top = TkToplevel.new(:geometry=>'-0+30', 
                       :title=>'A little screen magnifier for X11')
  TkLabel.new(top, :image=>loupe[:image]).pack

  TkTimer.new(proc{loupe[:delay]}, -1, proc{
                x, y = TkWinfo.pointerxy(Tk.root)
                if loupe[:auto] || loupe[:x] != x || loupe[:y] != y
                  w = loupe[:image].width
                  h = loupe[:image].height
                  Tk::TreeCtrl.loupe(loupe[:image], x, y, w, h, loupe[:zoom])
                  loupe[:x] = x
                  loupe[:y] = y
                end
              }).start
end

#showHelpObject



172
173
174
# File 'sample/tkextlib/tile/demo.rb', line 172

def showHelp()
  Tk.messageBox(:message=>'No help yet...')
end

#showMessageBox(w) ⇒ Object



80
81
82
83
84
85
86
87
# File 'sample/demos-en/msgbox.rb', line 80

def showMessageBox(w)
  button = Tk.messageBox('icon'=>$msgboxIcon.value, 'type'=>$msgboxType.value, 
                         'title'=>'Message', 'parent'=>w,
                         'message'=>"This is a \"#{$msgboxType.value}\" type messagebox with the \"#{$msgboxIcon.value}\" icon")

  Tk.messageBox('icon'=>'info', 'type'=>'ok', 'parent'=>w, 
                'message'=>"You have selected  \"#{button}\"")
end

#start_randomObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'sample/tkline.rb', line 5

def start_random
  return if $tkline_init
  $tkline_init = TRUE
  if defined? Thread
    Thread.start do
      loop do
        sleep 2
        Line.new($c, rand(400), rand(200), rand(400), rand(200))
      end
    end
  end
end

#stateMonitorObject



917
918
919
920
# File 'sample/tkextlib/tile/demo.rb', line 917

def stateMonitor
  updateStates() if $Widget.value != ''
  $Timers[:StateMonitor] = Tk.after(200, proc{ stateMonitor() })
end

#subdir_check(dir, verbose = false) ⇒ Object



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/tkextlib/pkg_checker.rb', line 143

def subdir_check(dir, verbose=false)
  Dir.foreach(dir){|f|
    next if f == '.' || f == '..'
    if File.directory?(f)
      subdir_check(File.join(dir, f))
    elsif File.extname(f) == '.rb'
      path = File.join(dir, f)
      suc, err = check_pkg(path, verbose)
      if err.empty?
        print 'Ready : ', path, ' : require->', suc.inspect, "\n"
      else
        print '*LACK : ', path, ' : require->', suc.inspect, 
          '  FAIL->', err.inspect, "\n"
      end
    end
  }
end

#table_validate(w, idx) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'sample/tkextlib/tktable/dynarows.rb', line 14

def table_validate(w, idx)
  return unless idx =~ /^(\d+),(\d+)$/
  row = Integer($1)
  col = Integer($2)
  val = w.get(idx)

 [w, idx]
  nrows = w[:rows]
  return if row == nrows - 1 && val == ''

  begin
    time = Tk.tk_call('clock', 'scan', val)
    date = []
    Tk.tk_call('clock', 'format', time, 
               :format=>'%m %d %Y').split(' ').each{|item|
      date << item.sub(/^\s*0*/,'')
    }
    w.set(idx, date.join('/'))
    if row == nrows - 1
      if w.get([row,1]) != '' && w.get([row,2]) != ''
        w.tag_row_reset(row)
        w.set([row,0], row)
        nrows += 1
        row += 1
        w.configure(:rows=>nrows)
        w.tag_row('unset', row)
        w.set([row,0], '*')
        w.see([row,1])
        w.activate([row,1])
      end
    end
  rescue
    Tk.bell
    w.activate(idx)
    w.selection_clear_all
    w.selection_set(:active)
    w.see(:active)
  end
end

#tag_binding_for_bind_demo(tag, enter_style, leave_style) ⇒ Object

bind



40
41
42
43
# File 'sample/demos-en/bind.rb', line 40

def tag_binding_for_bind_demo(tag, enter_style, leave_style)
  tag.bind('Any-Enter', proc{tag.configure enter_style})
  tag.bind('Any-Leave', proc{tag.configure leave_style})
end

#textB1Move(w, x, y) ⇒ Object



166
167
168
# File 'sample/demos-en/ctext.rb', line 166

def textB1Move(w,x,y)
  w.select_to 'current', "@#{x},#{y}"
end

#textB1Press(w, x, y) ⇒ Object



159
160
161
162
163
164
# File 'sample/demos-en/ctext.rb', line 159

def textB1Press(w,x,y)
  w.icursor 'current', "@#{x},#{y}"
  w.itemfocus 'current'
  w.focus
  w.select_from 'current', "@#{x},#{y}"
end

#textBs(w) ⇒ Object



170
171
172
173
174
175
176
177
# File 'sample/demos-en/ctext.rb', line 170

def textBs(w)
  begin
    $ctag_text.dchars 'sel.first', 'sel.last'
  rescue
    char = $ctag_text.index('insert').to_i - 1
    $ctag_text.dchars(char) if char >= 0
  end
end

#textDel(w) ⇒ Object



179
180
181
182
183
184
185
# File 'sample/demos-en/ctext.rb', line 179

def textDel(w)
  begin
    $ctag_text.dchars 'sel.first', 'sel.last'
  rescue
    $ctag_text.dchars 'insert'
  end
end

#textEnter(w) ⇒ Object



138
139
140
141
# File 'sample/demos-en/ctext.rb', line 138

def textEnter(w)
  $textConfigFill = (w.itemconfiginfo 'current', 'fill')[4]
  w.itemconfigure 'current', 'fill', 'black'
end

#textInsert(w, string) ⇒ Object



143
144
145
146
147
148
149
150
# File 'sample/demos-en/ctext.rb', line 143

def textInsert(w, string)
  return if string == ""
  begin
    $ctag_text.dchars 'sel.first', 'sel.last'
  rescue
  end
  $ctag_text.insert 'insert', string
end

#textLoadFile(w, file) ⇒ Object

textLoadFile – This method below loads a file into a text widget, discarding the previous contents of the widget. Tags for the old widget are not affected, however.

Arguments: w - The window into which to load the file. Must be a

text widget.

file - The name of the file to load. Must be readable.



20
21
22
23
24
25
26
27
# File 'sample/demos-en/search.rb', line 20

def textLoadFile(w,file)
  w.delete('1.0', 'end')
  f = open(file, 'r')
  while(!f.eof?)
    w.insert('end', f.read(1000))
  end
  f.close
end

#textPaste(w, pos) ⇒ Object



152
153
154
155
156
157
# File 'sample/demos-en/ctext.rb', line 152

def textPaste(w, pos)
  begin
    $ctag_text.insert pos, TkSelection.get
  rescue
  end
end

#textSearch(w, string, tag) ⇒ Object

textSearch – Search for all instances of a given string in a text widget and apply a given tag to each instance found.

Arguments: w - The window in which to search. Must be a text widget. string - The string to search for. The search is done using

exact matching only;  no special characters.

tag - Tag to apply to each instance of a matching string.



39
40
41
42
43
44
45
46
47
48
49
# File 'sample/demos-en/search.rb', line 39

def textSearch(w, string, tag)
  tag.remove('0.0', 'end')
  return if string == ""
  cur = '1.0'
  loop {
    cur, len = w.search_with_length(string, cur, 'end')
    break if cur == ""
    tag.add(cur, "#{cur} + #{len} char")
    cur = w.index("#{cur} + #{len} char")
  }
end

#textToggle(cmd1, sleep1, cmd2, sleep2) ⇒ Object

textToggle – This method is invoked repeatedly to invoke two commands at periodic intervals. It normally reschedules itself after each execution but if an error occurs (e.g. because the window was deleted) then it doesn’t reschedule itself.

Arguments: cmd1 - Command to execute when method is called. sleep1 - Ms to sleep after executing cmd1 before executing cmd2. cmd2 - Command to execute in the next invocation of this method. sleep2 - Ms to sleep after executing cmd2 before executing cmd1 again.



63
64
65
66
67
# File 'sample/demos-en/search.rb', line 63

def textToggle(cmd1,sleep1,cmd2,sleep2)
  sleep_list = [sleep2, sleep1]
  TkAfter.new(proc{sleep = sleep_list.shift; sleep_list.push(sleep); sleep}, 
              -1, cmd1, cmd2).start(sleep1)
end

#textWinBigB2(w) ⇒ Object

methods



240
241
242
# File 'sample/demos-en/twind2.rb', line 240

def textWinBigB2(w)
  w.borderwidth 15
end

#textWinBigH2(w) ⇒ Object



246
247
248
# File 'sample/demos-en/twind2.rb', line 246

def textWinBigH2(w)
  w.highlightthickness 15
end

#textWinBigP2(w) ⇒ Object



252
253
254
# File 'sample/demos-en/twind2.rb', line 252

def textWinBigP2(w)
  w.configure(:padx=>15, :pady=>15)
end

#textWindDel(w) ⇒ Object



272
273
274
275
276
277
278
279
280
281
# File 'sample/demos-en/twind.rb', line 272

def textWindDel (w)
  if (defined? $twind_text) && TkWinfo.exist?($twind_plot)
    $twind_text.delete $twind_plot
    $twind_plot = nil
    while ($twind_text.get($mark_plot) =~ /[ \t\n]/)
      $twind_text.delete $mark_plot
    end
    $twind_text.insert $mark_plot,"  "
  end
end

#textWindDel2(w) ⇒ Object



369
370
371
372
373
374
375
376
377
378
# File 'sample/demos-en/twind2.rb', line 369

def textWindDel2 (w)
  if (defined? $twind2_text) && TkWinfo.exist?($twind2_plot)
    $twind2_text.delete $twind2_plot
    $twind2_plot = nil
    while ($twind2_text.get($mark2_plot) =~ /[ \t\n]/)
      $twind2_text.delete $mark2_plot
    end
    $twind2_text.insert $mark2_plot,"  "
  end
end

#textWindOff(w) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
# File 'sample/demos-en/twind.rb', line 185

def textWindOff (w)
  if defined? $twind_scroll
    begin
      $twind_scroll.destroy
    rescue
    end
    $twind_scroll = nil
  end
  w.xscrollcommand ''
  w.wrap 'word'
end

#textWindOff2(w) ⇒ Object



280
281
282
283
284
285
286
287
288
289
290
291
# File 'sample/demos-en/twind2.rb', line 280

def textWindOff2 (w)
  if defined? $twind2_scroll
    begin
      $twind2_scroll.destroy
    rescue
    end
    $twind2_scroll = nil
  end
  w.xscrollcommand ''
  #w.wrap 'word'
  w.wrap 'char'
end

#textWindOn(w, f) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'sample/demos-en/twind.rb', line 164

def textWindOn (w,f)
  if defined? $twind_scroll
    begin
      $twind_scroll.destroy
    rescue
    end
    $twind_scroll = nil
  end

  base = TkWinfo.parent( TkWinfo.parent(w) )
  $twind_scroll = TkScrollbar.new(base) {|s|
    orient 'horizontal'
    command proc{|*args| w.xview(*args)}
    w.xscrollcommand proc{|first,last| s.set first,last}
    w.wrap 'none'
    pack('after'=>f, 'side'=>'bottom', 'fill'=>'x')
  }

  return nil
end

#textWindOn2(w, f) ⇒ Object



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'sample/demos-en/twind2.rb', line 259

def textWindOn2 (w,f)
  if defined? $twind2_scroll
    begin
      $twind2_scroll.destroy
    rescue
    end
    $twind2_scroll = nil
  end

  base = TkWinfo.parent( TkWinfo.parent(w) )
  $twind2_scroll = TkScrollbar.new(base) {|s|
    orient 'horizontal'
    command proc{|*args| w.xview(*args)}
    w.xscrollcommand proc{|first,last| s.set first,last}
    w.wrap 'none'
    pack('after'=>f, 'side'=>'bottom', 'fill'=>'x')
  }

  return nil
end

#textWindPlot(t) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'sample/demos-en/twind.rb', line 197

def textWindPlot (t)
  if (defined? $twind_plot) && TkWinfo.exist?($twind_plot)
    return
  end

  $twind_plot = TkCanvas.new(t) {
    relief 'sunken'
    width  450
    height 300
    cursor 'top_left_arrow'
  }

  font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'

  TkcLine.new($twind_plot, 100, 250, 400, 250, 'width'=>2)
  TkcLine.new($twind_plot, 100, 250, 100,  50, 'width'=>2)
  TkcText.new($twind_plot, 225, 20, 
              'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown')

  (0..10).each {|i|
    x = 100 + (i * 30)
    TkcLine.new($twind_plot, x, 250, x, 245, 'width'=>2)
    TkcText.new($twind_plot, x, 254, 
                'text'=>10*i, 'font'=>font, 'anchor'=>'n')
  }
  (0..5).each {|i|
    y = 250 - (i * 40)
    TkcLine.new($twind_plot, 100, y, 105, y, 'width'=>2)
    TkcText.new($twind_plot, 96, y, 
                'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e')
  }

  for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]]
    x = 100 + (3*xx)
    y = 250 - (4*yy)/5
    item = TkcOval.new($twind_plot, x-6, y-6, x+6, y+6, 
                       'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2')
    item.addtag 'point'
  end

  $twind_plot.itembind('point', 'Any-Enter', 
                        proc{$twind_plot.itemconfigure 'current', 'fill', 'red'})
  $twind_plot.itembind('point', 'Any-Leave', 
                        proc{$twind_plot.itemconfigure 'current', 'fill', 'SkyBlue2'})
  $twind_plot.itembind('point', '1', 
                        proc{|x,y| embPlotDown $twind_plot,x,y}, "%x %y")
  $twind_plot.itembind('point', 'ButtonRelease-1', 
                        proc{$twind_plot.dtag 'selected'})
  $twind_plot.bind('B1-Motion', 
                    proc{|x,y| embPlotMove $twind_plot,x,y}, "%x %y")
  while ($twind_text.get($mark_plot) =~ /[ \t\n]/)
    $twind_text.delete $mark_plot
  end
  $twind_text.insert $mark_plot,"\n"
  TkTextWindow.new($twind_text, $mark_plot, 'window'=>$twind_plot)
  $tag_center.add $mark_plot
  $twind_text.insert $mark_plot,"\n"
end

#textWindPlot2(t) ⇒ Object



293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# File 'sample/demos-en/twind2.rb', line 293

def textWindPlot2 (t)
  if (defined? $twind2_plot) && (TkWinfo.exist?($twind2_plot))
    return
  end

  $twind2_plot = TkCanvas.new(t) {
    relief 'sunken'
    width  450
    height 300
    cursor 'top_left_arrow'
  }

  #font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
  font = 'Helvetica 18'

  TkcLine.new($twind2_plot, 100, 250, 400, 250, 'width'=>2)
  TkcLine.new($twind2_plot, 100, 250, 100,  50, 'width'=>2)
  TkcText.new($twind2_plot, 225, 20, 
              'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown')

  (0..10).each {|i|
    x = 100 + (i * 30)
    TkcLine.new($twind2_plot, x, 250, x, 245, 'width'=>2)
    TkcText.new($twind2_plot, x, 254, 
                'text'=>10*i, 'font'=>font, 'anchor'=>'n')
  }
  (0..5).each {|i|
    y = 250 - (i * 40)
    TkcLine.new($twind2_plot, 100, y, 105, y, 'width'=>2)
    TkcText.new($twind2_plot, 96, y, 
                'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e')
  }

  for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]]
    x = 100 + (3*xx)
    y = 250 - (4*yy)/5
    item = TkcOval.new($twind2_plot, x-6, y-6, x+6, y+6, 
                       'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2')
    item.addtag 'point'
  end

  $twind2_plot.itembind('point', 'Any-Enter', 
                        proc{$twind2_plot.itemconfigure 'current', 'fill', 'red'})
  $twind2_plot.itembind('point', 'Any-Leave', 
                        proc{$twind2_plot.itemconfigure 'current', 'fill', 'SkyBlue2'})
  $twind2_plot.itembind('point', '1', 
                        proc{|x,y| embPlotDown2 $twind2_plot,x,y}, "%x %y")
  $twind2_plot.itembind('point', 'ButtonRelease-1', 
                        proc{$twind2_plot.dtag 'selected'})
  $twind2_plot.bind('B1-Motion', 
                    proc{|x,y| embPlotMove2 $twind2_plot,x,y}, "%x %y")
  while ($twind2_text.get($mark2_plot) =~ /[ \t\n]/)
    $twind2_text.delete $mark2_plot
  end
  $twind2_text.insert $mark2_plot,"\n"
  TkTextWindow.new($twind2_text, $mark2_plot, 'window'=>$twind2_plot)
  $tag2_center.add $mark2_plot
  $twind2_text.insert $mark2_plot,"\n"
end

#textWinSmallB2(w) ⇒ Object



243
244
245
# File 'sample/demos-en/twind2.rb', line 243

def textWinSmallB2(w)
  w.borderwidth $text_normal2['border']
end

#textWinSmallH2(w) ⇒ Object



249
250
251
# File 'sample/demos-en/twind2.rb', line 249

def textWinSmallH2(w)
  w.highlightthickness $text_normal2['highlight']
end

#textWinSmallP2(w) ⇒ Object



255
256
257
# File 'sample/demos-en/twind2.rb', line 255

def textWinSmallP2(w)
  w.configure(:padx=>$text_normal2['pad'], :pady=>$text_normal2['pad'])
end

#tickObject



35
36
37
38
39
40
41
42
43
44
# File 'sample/tktimer.rb', line 35

def tick
  if $stopped then return end
  Tk.after 50, proc{tick}
  $hundredths+=5
  if $hundredths >= 100
    $hundredths=0
    $seconds+=1
  end
  $label.text format("%d.%02d", $seconds, $hundredths)
end

#tkObject

spreadsheet.rb

This demos shows how you can simulate a 3D table and has other basic features to begin a basic spreadsheet

( based on ‘spreadsheet.tcl’ included source archive of tktable extension )



9
# File 'sample/tkextlib/tktable/basic.rb', line 9

require 'tk'

#TkGrid(*args) ⇒ Object



8
# File 'lib/tk/autoload.rb', line 8

def TkGrid(*args); TkGrid.configure(*args); end

#TkPack(*args) ⇒ Object



11
# File 'lib/tk/autoload.rb', line 11

def TkPack(*args); TkPack.configure(*args); end

#TkPlace(*args) ⇒ Object



14
# File 'lib/tk/autoload.rb', line 14

def TkPlace(*args); TkPlace.configure(*args); end

#toggle_consoleObject



646
647
648
649
650
651
652
# File 'sample/tkextlib/tile/demo.rb', line 646

def toggle_console
  if TkComm.bool($V[:CONSOLE])
    TkConsole.show
  else
    TkConsole.hide
  end
end

#trackFocusObject



807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
# File 'sample/tkextlib/tile/demo.rb', line 807

def trackFocus
  if $focus
    begin
      $focus.destroy
    rescue
    end
  end
  $focus = TkToplevel.new(:title=>'Keyboard focus')
  i = 0
  [
    ["Focus widget:", :Widget], 
    ["Class:", :WidgetClass], 
    ["Next:", :WidgetNext], 
    ["Grab:", :Grab], 
    ["Status:", :GrabStatus]
  ].each{|label, var_index|
    Tk.grid(Tk::Tile::Label.new($focus, :text=>label, :anchor=>:e), 
            Tk::Tile::Label.new($focus, 
                                :textvariable=>$FocusInf.ref(var_index), 
                                :width=>40, :anchor=>:w, :relief=>:groove), 
            :sticky=>:ew)
    i += 1
  }
  $focus.grid_columnconfigure(1, :weight=>1)
  $focus.grid_rowconfigure(i, :weight=>1)

  $focus.bind('Destroy', proc{Tk.after_cancel($Timers[:FocusMonitor])})
  focusMonitor
end

#trackStatesObject



874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
# File 'sample/tkextlib/tile/demo.rb', line 874

def trackStates
  if $states
    begin
      $state.destroy
    rescue
    end
  end
  $states = TkToplevel.new(:title=>'Widget states')

  l_inf = Tk::Tile::Label.new($states, :text=>"Press Control-Shift-Button-1 on any widget")

  l_lw = Tk::Tile::Label.new($states, :text=>'Widget:', 
                             :anchor=>:e, :relief=>:groove)
  l_w = Tk::Tile::Label.new($states, :textvariable=>$Widget, 
                             :anchor=>:w, :relief=>:groove)

  Tk.grid(l_inf, '-', :sticky=>:ew, :padx=>6, :pady=>6)
  Tk.grid(l_lw, l_w, :sticky=>:ew)

  $states_list.each{|st|
    cb = Tk::Tile::Checkbutton.new($states, :text=>st, 
                                   :variable=>$State.ref(st), 
                                   :command=>proc{ changeState(st) })
    $states_btns[st] = cb
    Tk.grid('x', cb, :sticky=>:nsew)
  }

  $states.grid_columnconfigure(1, :weight=>1)

  f_cmd = Tk::Tile::Frame.new($states)
  Tk.grid('x', f_cmd, :sticky=>:nse)

  b_close = Tk::Tile::Button.new(f_cmd, :text=>'Close', 
                                 :command=>proc{ $states.destroy })
  Tk.grid('x', b_close, :padx=>4, :pady=>[6,4])
  f_cmd.grid_columnconfigure(0, :weight=>1)

  $states.bind('KeyPress-Escape', proc{Tk.event_generate(b_close, '<Invoke>')})

  $states.bind('Destroy', proc{Tk.after_cancel($Timers[:StateMonitor])})
  stateMonitor()
end

#updateStatesObject



922
923
924
925
926
927
928
929
930
931
932
# File 'sample/tkextlib/tile/demo.rb', line 922

def updateStates
  $states_list.each{|st|
    begin
      $State[st] = $Widget.window.instate(st)
    rescue
      $states_btns[st].state('disabled')
    else
      $states_btns[st].state('!disabled')
    end
  }
end

#validate_proc(c, val) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'sample/tkextlib/tktable/valid.rb', line 35

def validate_proc(c, val)
  if c % 3 == 1
    # AlphaNum
    regexp = /^[A-Za-z0-9 ]*$/
  elsif c % 2 == 1
    # Alpha
    regexp = /^[A-Za-z ]*$/
  elsif c != 0
    # 'Real'
    regexp = /^[-+]?[0-9]*\.?[0-9]*([0-9]\.?e[-+]?[0-9]*)?$/
  end
  if val =~ regexp
    return true
  else
    Tk.bell
    return false
  end
end

#validatePhoneChange(widget, vmode, idx, char) ⇒ Object

validatePhoneChange – Checks that the replacement (mapped to a digit) of the given character in an entry widget at the given position will leave a valid phone number in the widget.

widget - entry widget to validate vmode - The widget’s validation mode idx - The index where replacement is to occur char - The character (or string, though that will always be

refused) to be overwritten at that point.


152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'sample/demos-en/entry3.rb', line 152

def validatePhoneChange(widget, vmode, idx, char)
  return true if idx == nil
  Tk.after_idle(proc{widget.configure(:validate=>vmode, 
                                      :invcmd=>proc{Tk.bell})})
  if !(idx<3 || idx==6 || idx==7 || idx==11 || idx>15) && char =~ /[0-9A-Za-z]/
    widget.delete(idx)
    widget.insert(idx, $phoneNumberMap[char] || char)
    Tk.after_idle(proc{phoneSkipRight(widget, -1)})
    return true
    # Tk.update(true) # Don't work 'update' inter validation callback.
                      # It depends on Tcl/Tk side (tested on Tcl/Tk8.5a1). 
  end
  return false
end

#version?(ver) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'sample/tkextlib/tile/demo.rb', line 19

def version?(ver)
  TkPackage.vcompare(Tk::Tile.package_version, ver) >= 0
end