Method: CDK::SCREEN#refresh

Defined in:
lib/cdk/screen.rb

#refreshObject

This refreshes all the objects in the screen.



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
# File 'lib/cdk/screen.rb', line 220

def refresh
  focused = -1
  visible = -1

  CDK::SCREEN.refreshCDKWindow(@window)

  # We erase all the invisible objects, then only draw it all back, so
  # that the objects can overlap, and the visible ones will always be
  # drawn after all the invisible ones are erased
  (0...@object_count).each do |x|
    obj = @object[x]
    if obj.validObjType(obj.object_type)
      if obj.is_visible
        if visible < 0
          visible = x
        end
        if obj.has_focus && focused < 0
          focused = x
        end
      else
        obj.erase
      end
    end
  end

  (0...@object_count).each do |x|
    obj = @object[x]

    if obj.validObjType(obj.object_type)
      obj.has_focus = (x == focused)

      if obj.is_visible
        obj.draw(obj.box)
      end
    end
  end
end