Class: Shoes::TextBlock
- Inherits:
-
Basic
show all
- Defined in:
- lib/shoes/basic.rb,
lib/shoes/style.rb
Instance Attribute Summary
Attributes inherited from Basic
#args, #hided, #initials, #parent, #shows
Attributes included from Mod
#click_proc, #hover_proc, #hovered, #leave_proc, #margin_bottom, #margin_left, #margin_right, #margin_top, #release_proc
Instance Method Summary
(collapse)
Methods inherited from Basic
#clear, #fix_size, #hide, #move, #move3, #show, #toggle
Methods included from Mod
#click, #hover, #leave, #release, #set_margin
Constructor Details
- (TextBlock) initialize(args)
A new instance of TextBlock
185
186
187
188
189
|
# File 'lib/shoes/basic.rb', line 185
def initialize args
super
@app.mlcs << self if !@real or @add_mlcs
@add_mlcs = false
end
|
Instance Method Details
226
227
228
|
# File 'lib/shoes/basic.rb', line 226
def cursor
@app.textcursors[self] ? @app.textcursors[self][0] : nil
end
|
- (Object) cursor=(n)
217
218
219
220
221
222
223
224
|
# File 'lib/shoes/basic.rb', line 217
def cursor=(n)
if !n
@app.textcursors[self][1].clear if @app.textcursors[self][1]
@app.textcursors.delete self
else
@app.textcursors[self] ? (@app.textcursors[self][0] = n) : (@app.textcursors[self] = [n, nil])
end
end
|
- (Object) highlight
248
249
250
251
252
253
254
255
256
|
# File 'lib/shoes/basic.rb', line 248
def highlight
unless cursor
return nil, 0
else
cindex = cursor == -1 ? text.length : cursor
mindex = marker ? marker : cindex
return marker, cindex - mindex
end
end
|
- (Object) hit(x, y)
230
231
232
233
|
# File 'lib/shoes/basic.rb', line 230
def hit x, y
a, b, c = @app.make_textcursor_index(self, x - left, y - top + @app.scroll_top)
a ? b : nil
end
|
244
245
246
|
# File 'lib/shoes/basic.rb', line 244
def marker
@app.textmarkers[self]
end
|
- (Object) marker=(n)
235
236
237
238
239
240
241
242
|
# File 'lib/shoes/basic.rb', line 235
def marker=(n)
if cursor
cindex = cursor == -1 ? text.length : cursor
len = cindex - n
self.text = text[0...n] + @app.bg(text[n, len], @app.yellow) + text[n+len..-1] if len > 1
end
@app.textmarkers[self] = n
end
|
- (Object) move2(x, y)
207
208
209
210
|
# File 'lib/shoes/basic.rb', line 207
def move2 x, y
self.text = @args[:markup]
super
end
|
- (Object) positioning(x, y, max)
202
203
204
205
|
# File 'lib/shoes/basic.rb', line 202
def positioning x, y, max
self.text = @args[:markup]
super
end
|
212
213
214
215
|
# File 'lib/shoes/basic.rb', line 212
def remove
flag = @args[:hidden] ? @shows : @hided
@app.canvas.remove @real unless flag
end
|
- (Object) style(args)
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/shoes/style.rb', line 44
def style args
args[:markup] ||= @args[:markup]
args[:size] ||= @args[:size]
args[:font] ||= @args[:font]
args[:align] ||= @args[:align]
clear if @real
@width = (@left + parent.width <= @app.width) ? parent.width : @app.width - @left
@width = initials[:width] unless initials[:width].zero?
@height = 20 if @height.zero?
m = self.class.to_s.downcase[7..-1]
args = [args[:markup], @args.merge({left: @left, top: @top, width: @width, height: @height,
create_real: true, nocontrol: true, size: args[:size], font: args[:font], align: args[:align]})]
tb = @app.send(m, *args)
@real, @height = tb.real, tb.height
@args[:markup], @args[:size], @args[:font], @args[:align] = tb.markup, tb.size, tb.font, tb.align
@markup, @size, @font, @align = @args[:markup], @args[:size], @args[:font], @args[:align]
end
|
191
192
193
|
# File 'lib/shoes/basic.rb', line 191
def text
@args[:markup].gsub(/\<.*?>/, '').gsub('&', '&').gsub('<', '<')
end
|
- (Object) text=(s)
Also known as:
replace
195
196
197
198
|
# File 'lib/shoes/basic.rb', line 195
def text= s
@args[:add_mlcs] = false
style markup: s if !@hided or @args[:hidden]
end
|