Class: TkEnumType

Inherits:
TkTy
  • Object
show all
Defined in:
ext/ae-rad/ae-rad-inspector.rb

Direct Known Subclasses

TkEnumProcType

Instance Attribute Summary

Attributes inherited from TkTy

#agobj, #labelhost, #prop

Instance Method Summary collapse

Methods inherited from TkTy

#free

Constructor Details

#initialize(_host, _family, _agobj, _prop, _editable = false) ⇒ TkEnumType

Returns a new instance of TkEnumType.



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
# File 'ext/ae-rad/ae-rad-inspector.rb', line 109

def initialize(_host, _family, _agobj, _prop, _editable = false)
  @agobj = _agobj
  @prop = _prop
  @labelhost = _host
  @family = _family
  @bool = _prop['type'].values[0].class.to_s == 'TrueClass'
  if @bool
    do_update = proc{
      @etextvalue = @propobj.cget('text')
      @agobj.update_property(self, @family, @prop['name'], source_to_bool(@etextvalue))
      $arcadia['objic.action.raise_active_obj'].call
    }
    _values = []
    _prop['type'].values.each{|value|
      _values << bool_to_string(value)
    }
    #Tk.messageBox('message'=>_values.to_s)
  else
    do_update = proc{ 
      #Tk.messageBox('message'=>'sasda')
      @etextvalue = @propobj.cget('text')
      @agobj.update_property(self, @family, @prop['name'], @etextvalue)
      $arcadia['objic.action.raise_active_obj'].call
    }
    _values = _prop['type'].values
    #Tk.messageBox('message'=>_values.class.to_s)
  end
  @propobj = Tk::BWidget::ComboBox.new(_host, Arcadia.style('combobox')){
    values  _values
    modifycmd do_update
    editable _editable
    place('x'=>0, 'y'=>0,'relheight'=>1, 'relwidth'=>1, 'bordermode'=>'outside')
    def e
      TkWinfo.children(self)[0]
    end
    def b
      TkWinfo.children(self)[1]
    end
  }
  setpropvalue(@prop['get'].call.to_s)
end

Instance Method Details

#bool_to_string(_source) ⇒ Object



151
152
153
154
155
156
157
# File 'ext/ae-rad/ae-rad-inspector.rb', line 151

def bool_to_string(_source)
  if _source
    return 'true'
  else
    return 'false'
  end
end

#setpropvalue(_value) ⇒ Object



168
169
170
171
172
173
174
175
176
177
# File 'ext/ae-rad/ae-rad-inspector.rb', line 168

def setpropvalue(_value)
  #Tk.messageBox('message'=>'dip')
  _index = @prop['type'].values.index(_value)
  if _index != nil
    @propobj.set_value(_index)
  else
    @propobj.e.insert( 0, _value)
  end
  @etextvalue = _value
end

#source_to_bool(_source) ⇒ Object



159
160
161
162
163
164
165
166
# File 'ext/ae-rad/ae-rad-inspector.rb', line 159

def source_to_bool(_source)
  _source = _source.to_s
  if (_source == '1') or (_source == 'true')
    return true
  else
    return false
  end
end