Class: XRC2Ruby::ObjectTypes::Window
- Extended by:
- InitArgs
- Defined in:
- lib/wx_sugar/xrc/xrc2ruby_types/window.rb
Direct Known Subclasses
BitmapButton, Container, ControlWithItems, Gauge, Labelled, ListCtrl, Menu, MenuBar, ScrollBar, SearchCtrl, Slider, SpinButton, SpinCtrl, StaticBitmap, StaticBox, StaticLine, StaticText, StyledTextCtrl, TextCtrl, ToolBar, TopLevelWindow
Constant Summary collapse
- BASE_NAME =
"window"
Instance Attribute Summary collapse
-
#bg ⇒ Object
Tooltip and help text, applicable to all windows.
-
#enabled ⇒ Object
Tooltip and help text, applicable to all windows.
-
#exstyle ⇒ Object
Tooltip and help text, applicable to all windows.
-
#fg ⇒ Object
Tooltip and help text, applicable to all windows.
-
#help ⇒ Object
Tooltip and help text, applicable to all windows.
-
#hidden ⇒ Object
Tooltip and help text, applicable to all windows.
-
#tooltip ⇒ Object
Tooltip and help text, applicable to all windows.
Attributes inherited from Object
#centered, #name, #parent, #sub_class, #win_class
Instance Method Summary collapse
-
#args ⇒ Object
Returns the constructor arguments as a Ruby string.
- #output ⇒ Object
-
#setup ⇒ Object
Some classes define XRC property elements that are set in wxWidgets by method calls rather than passed as part of the constructor.
Methods included from InitArgs
inherited, init_arg, init_args, translatable_string_init_arg
Methods inherited from Object
#initialize, #inspect, next_id, #var_name
Constructor Details
This class inherits a constructor from XRC2Ruby::ObjectTypes::Object
Instance Attribute Details
#bg ⇒ Object
Tooltip and help text, applicable to all windows
47 48 49 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/window.rb', line 47 def bg @bg end |
#enabled ⇒ Object
Tooltip and help text, applicable to all windows
47 48 49 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/window.rb', line 47 def enabled @enabled end |
#exstyle ⇒ Object
Tooltip and help text, applicable to all windows
47 48 49 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/window.rb', line 47 def exstyle @exstyle end |
#fg ⇒ Object
Tooltip and help text, applicable to all windows
47 48 49 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/window.rb', line 47 def fg @fg end |
#help ⇒ Object
Tooltip and help text, applicable to all windows
47 48 49 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/window.rb', line 47 def help @help end |
#hidden ⇒ Object
Tooltip and help text, applicable to all windows
47 48 49 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/window.rb', line 47 def hidden @hidden end |
#tooltip ⇒ Object
Tooltip and help text, applicable to all windows
47 48 49 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/window.rb', line 47 def tooltip @tooltip end |
Instance Method Details
#args ⇒ Object
Returns the constructor arguments as a Ruby string
115 116 117 118 119 120 121 122 123 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/window.rb', line 115 def args defined_args = [] self.class.init_args.keys.each do | arg | if arg_val = send(arg) defined_args << ":#{arg} => #{arg_val}" end end defined_args.join(",\n") end |
#output ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/window.rb', line 49 def output # The base constructor if parent base = "#{var_name} = #{win_class}.new(#{parent.var_name}" base << ( args.empty? ? ")" : ",\n#{args})" ) else base = "#{var_name} = #{win_class}.new(nil" base << ( args.empty? ? ")" : ",\n#{args})" ) end # Re-indent the keyword arguments indent = base.index("(") + 1 base.gsub!(/\n:/, "\n" + (" " * indent ) + ":") || base base << "\n" # If help text is defined if self.help base << "#{var_name}.help_text = '#{self.help}'\n" end # If a tooltip is defined if self.tooltip base << "#{var_name}.tool_tip = '#{self.tooltip}'\n" end # If foreground colour is specified, convert hex->int and set if self.fg colour = self.bg.scan(/[0-9a-fA-F]{2}/).map { | e | e.to_i(16) } base << "#{var_name}.background_colour = " base << "Wx::Colour.new(#{colour.join(', ')})\n" end # If background colour is specified, convert hex->int and set if self.bg colour = self.bg.scan(/[0-9a-fA-F]{2}/).map { | e | e.to_i(16) } base << "#{var_name}.foreground_colour = " base << "Wx::Colour.new(#{colour.join(', ')})\n" end # If extra style set if self.exstyle base << "#{var_name}.extra_style = #{exstyle.gsub(/^wx/, "Wx::")}" end # If explicitly disabled or enabled if self.enabled if self.enabled.to_i.zero? base << "#{var_name}.disable\n" else base << "#{var_name}.enable\n" end end # If explicitly shown or hidden if self.hidden if self.hidden.to_i.zero? base << "#{var_name}.hide\n" else base << "#{var_name}.show\n" end end base << setup base end |
#setup ⇒ Object
Some classes define XRC property elements that are set in wxWidgets by method calls rather than passed as part of the constructor. This method can be overridden in subclasses to return a string with those arguments.
129 130 131 |
# File 'lib/wx_sugar/xrc/xrc2ruby_types/window.rb', line 129 def setup '' end |