Class: Glimmer::LibUI::ControlProxy::DateTimePickerProxy

Inherits:
Glimmer::LibUI::ControlProxy show all
Defined in:
lib/glimmer/libui/control_proxy/date_time_picker_proxy.rb,
lib/glimmer/libui/control_proxy/date_time_picker_proxy/date_picker_proxy.rb,
lib/glimmer/libui/control_proxy/date_time_picker_proxy/time_picker_proxy.rb

Overview

Proxy for LibUI date time picker objects

Follows the Proxy Design Pattern

Direct Known Subclasses

DatePickerProxy, TimePickerProxy

Defined Under Namespace

Classes: DatePickerProxy, TimePickerProxy

Constant Summary

Constants inherited from Glimmer::LibUI::ControlProxy

BOOLEAN_PROPERTIES, KEYWORD_ALIASES, STRING_PROPERTIES, TransformProxy

Instance Attribute Summary

Attributes inherited from Glimmer::LibUI::ControlProxy

#args, #block, #content_added, #custom_control, #keyword, #libui, #options, #parent_custom_control, #parent_proxy, #slot

Instance Method Summary collapse

Methods inherited from Glimmer::LibUI::ControlProxy

#append_properties, #append_property, #bind_content, #can_handle_listener?, constant_symbol, #content, control_proxies, control_proxy_class, create, #custom_listener_name_aliases, #custom_listener_names, #default_destroy, #deregister_all_custom_listeners, #deregister_custom_listeners, descendant_keyword_constant_map, #destroy_child, #enabled, exists?, #handle_custom_listener, #handle_listener, #has_custom_listener?, image_proxies, #initialize, keyword, #listeners, #listeners_for, main_window_proxy, map_descendant_keyword_constants_for, menu_proxies, #method_missing, new_control, #notify_custom_listeners, #post_add_content, #post_initialize_child, reset_descendant_keyword_constant_map, #respond_to?, #respond_to_libui?, #send_to_libui, #visible, #window_proxy

Methods included from DataBindable

#data_bind, #data_bind_read, #data_binding_model_attribute_observer_registrations

Methods included from Parent

#children, #post_initialize_child

Constructor Details

This class inherits a constructor from Glimmer::LibUI::ControlProxy

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Glimmer::LibUI::ControlProxy

Instance Method Details

#data_bind_write(property, model_binding) ⇒ Object



68
69
70
# File 'lib/glimmer/libui/control_proxy/date_time_picker_proxy.rb', line 68

def data_bind_write(property, model_binding)
  handle_listener('on_changed') { model_binding.call(time) } if property == 'time'
end

#destroyObject



63
64
65
66
# File 'lib/glimmer/libui/control_proxy/date_time_picker_proxy.rb', line 63

def destroy
  Fiddle.free @time unless @time.nil?
  super
end

#libui_api_keywordObject



31
32
33
# File 'lib/glimmer/libui/control_proxy/date_time_picker_proxy.rb', line 31

def libui_api_keyword
  'date_time_picker'
end

#time(value = nil) ⇒ Object Also known as: set_time, time=



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
# File 'lib/glimmer/libui/control_proxy/date_time_picker_proxy.rb', line 35

def time(value = nil)
  @time ||= ::LibUI::FFI::TM.malloc
  ::LibUI.date_time_picker_time(@libui, @time)
  if value.nil?
    {
      sec: @time.tm_sec,
      min: @time.tm_min,
      hour: @time.tm_hour,
      mday: @time.tm_mday,
      mon: @time.tm_mon + 1,
      year: @time.tm_year + 1900,
      wday: @time.tm_wday + 1,
      yday: @time.tm_yday + 1,
      dst: @time.tm_isdst == 1
    }
  else
    @time.tm_sec = value[:sec] unless value[:sec].nil?
    @time.tm_min = value[:min] unless value[:min].nil?
    @time.tm_hour = value[:hour] unless value[:hour].nil?
    @time.tm_mday = value[:mday] unless value[:mday].nil?
    @time.tm_mon = value[:mon] - 1 unless value[:mon].nil?
    @time.tm_year = value[:year] - 1900 unless value[:year].nil?
    ::LibUI.date_time_picker_set_time(@libui, @time)
  end
end