Class: XRC2Ruby::ObjectTypes::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/wx_sugar/xrc/xrc2ruby_types/object.rb

Overview

Anything deriving from Wx::Object

Direct Known Subclasses

MenuItem, Sizer, Window

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, win_class, sub_class = nil, var_name = nil) ⇒ Object

Returns a new instance of Object.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/wx_sugar/xrc/xrc2ruby_types/object.rb', line 15

def initialize(parent, win_class, sub_class = nil, var_name = nil)
  @parent    = parent
  @win_class = win_class.gsub(/^wx/, "Wx::")
  @sub_class = sub_class
  
  # A named and externally accessible item
  if var_name and not var_name.empty? and 
     var_name !~ /^ID_/ and var_name !~ /^wx/
    @name = "@#{var_name.downcase}"
  # Or just a local name
  else
    @local_id = Object.next_id
  end
end

Instance Attribute Details

#centeredObject

Returns the value of attribute centered.



4
5
6
# File 'lib/wx_sugar/xrc/xrc2ruby_types/object.rb', line 4

def centered
  @centered
end

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/wx_sugar/xrc/xrc2ruby_types/object.rb', line 14

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



14
15
16
# File 'lib/wx_sugar/xrc/xrc2ruby_types/object.rb', line 14

def parent
  @parent
end

#sub_classObject (readonly)

Returns the value of attribute sub_class.



14
15
16
# File 'lib/wx_sugar/xrc/xrc2ruby_types/object.rb', line 14

def sub_class
  @sub_class
end

#win_classObject (readonly)

Returns the value of attribute win_class.



14
15
16
# File 'lib/wx_sugar/xrc/xrc2ruby_types/object.rb', line 14

def win_class
  @win_class
end

Class Method Details

.next_idObject



9
10
11
12
# File 'lib/wx_sugar/xrc/xrc2ruby_types/object.rb', line 9

def self.next_id
  @id_counter ||= 0
  @id_counter += 1
end

Instance Method Details

#inspectObject



6
7
8
# File 'lib/wx_sugar/xrc/xrc2ruby_types/object.rb', line 6

def inspect 
  "<#{self.class}>"
end

#outputObject



34
35
36
37
# File 'lib/wx_sugar/xrc/xrc2ruby_types/object.rb', line 34

def output
  # Should be defined in subclasses
  Kernel.raise "Shouldn't be called"
end

#var_nameObject



30
31
32
# File 'lib/wx_sugar/xrc/xrc2ruby_types/object.rb', line 30

def var_name
  @name || "#{self.class.name[/\w+$/].downcase}_#{@local_id}"
end