#--------------------------------------------------------------------------
# ● 更新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
# 光标位置不满 0 的情况下
if @index < 0
self.cursor_rect.empty
return
end
# 获取当前的行
row = @index / @column_max
# 当前行被显示开头行前面的情况下
if row < self.top_row
# 从当前行向开头行滚动
self.top_row = row
end
# 当前行被显示末尾行之后的情况下
if row > self.top_row + (self.page_row_max - 1)
# 从当前行向末尾滚动
self.top_row = row - (self.page_row_max - 1)
end
# 计算光标的宽
cursor_width = @width_txt
# 计算光标坐标
x = @index % @column_max * cursor_width
y = @index / @column_max * 32 - self.oy
# 设置光标位置
self.cursor_rect.set(x, y, @width_txt, 32)
x_y = []
# 获取文字颜色坐标
for i in x..(x + @width_txt - 1)
for j in y..y+31
x_y.push([i,j]) if self.contents.get_pixel(i,j) == normal_color
end
end
# 填充选择框
self.contents.fill_rect(self.cursor_rect, normal_color)
# 文字位置设置为背景色
x_y.each do |i|
self.contents.set_pixel(i[0],i[1],back_color)
end
end
end
#--------------------------------------------------------------------------
# ● 更新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
# 光标位置不满 0 的情况下
if @index < 0
self.cursor_rect.empty
return
end
# 获取当前的行
row = @index / @column_max
# 当前行被显示开头行前面的情况下
if row < self.top_row
# 从当前行向开头行滚动
self.top_row = row
end
# 当前行被显示末尾行之后的情况下
if row > self.top_row + (self.page_row_max - 1)
# 从当前行向末尾滚动
self.top_row = row - (self.page_row_max - 1)
end
# 计算光标的宽
cursor_width = @width_txt
# 计算光标坐标
x = @index % @column_max * cursor_width
y = @index / @column_max * 32 - self.oy
# 设置光标位置
self.cursor_rect.set(x, y, @width_txt, 32)
x_y = []
# 获取文字颜色坐标
for i in x..(x + @width_txt - 1)
for j in y..y+31
x_y.push([i,j]) if self.contents.get_pixel(i,j) == normal_color
end
end
# 填充选择框
self.contents.fill_rect(self.cursor_rect, normal_color)
# 文字位置设置为背景色
x_y.each do |i|
self.contents.set_pixel(i[0],i[1],back_color)
end
end
end