Class: Glimmer::SWT::GShell
- Defined in:
- lib/glimmer/swt/g_shell.rb
Constant Summary collapse
- WIDTH_MIN =
130
- HEIGHT_MIN =
0
Instance Attribute Summary collapse
-
#display ⇒ Object
readonly
Returns the value of attribute display.
Attributes inherited from GWidget
Instance Method Summary collapse
-
#center ⇒ Object
Centers shell within screen.
-
#initialize(*args) ⇒ GShell
constructor
Instantiates shell with same arguments expected by SWT Shell.
-
#open ⇒ Object
Opens shell and starts SWT’s UI thread event loop.
Methods inherited from GWidget
#add_listener, #apply_property_type_converters, #async_exec, #can_add_listener?, #dispose, #has_attribute?, #has_style?, #process_block, #property_type_converters, #set_attribute, swt_widget_class_for, #sync_exec, widget_exists?, #widget_listener_exists?
Methods included from Parent
Constructor Details
#initialize(*args) ⇒ GShell
Instantiates shell with same arguments expected by SWT Shell
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/glimmer/swt/g_shell.rb', line 16 def initialize(*args) if !args.first.is_a?(Display) && !args.first.is_a?(Shell) @display = GDisplay.instance.display args = [@display] + args end args = GSWT.constantify_args(args) @widget = Shell.new(*args) @display ||= @widget.getDisplay @widget.setLayout(FillLayout.new) @widget.setMinimumSize(WIDTH_MIN, HEIGHT_MIN) end |
Instance Attribute Details
#display ⇒ Object (readonly)
Returns the value of attribute display.
13 14 15 |
# File 'lib/glimmer/swt/g_shell.rb', line 13 def display @display end |
Instance Method Details
#center ⇒ Object
Centers shell within screen
29 30 31 32 33 34 35 36 |
# File 'lib/glimmer/swt/g_shell.rb', line 29 def center primary_monitor = @display.getPrimaryMonitor() monitor_bounds = primary_monitor.getBounds() shell_bounds = @widget.getBounds() location_x = monitor_bounds.x + (monitor_bounds.width - shell_bounds.width) / 2 location_y = monitor_bounds.y + (monitor_bounds.height - shell_bounds.height) / 2 @widget.setLocation(location_x, location_y) end |
#open ⇒ Object
Opens shell and starts SWT’s UI thread event loop
39 40 41 42 43 44 45 46 47 |
# File 'lib/glimmer/swt/g_shell.rb', line 39 def open @widget.pack center @widget.open until @widget.isDisposed @display.sleep unless @display.readAndDispatch end @display.dispose end |