Class: Glimmer::SWT::CursorProxy
- Inherits:
-
Object
- Object
- Glimmer::SWT::CursorProxy
- Defined in:
- lib/glimmer/swt/cursor_proxy.rb
Overview
Proxy for org.eclipse.swt.graphics.Cursor
Invoking ‘#swt_cursor` returns the SWT Cursor object wrapped by this proxy
Follows the Proxy Design Pattern
Constant Summary collapse
- CURSOR_STYLES =
org.eclipse.swt.SWT.constants.select {|c| c.to_s.downcase.start_with?('cursor_')}.map {|c| c.to_s.downcase.sub('cursor_', '').to_sym}
- ERROR_INVALID_CURSOR_STYLE =
" is an invalid cursor style! Valid values are #{CURSOR_STYLES.map(&:to_s).join(", ")}"
Instance Attribute Summary collapse
-
#cursor_style ⇒ Object
readonly
Returns the value of attribute cursor_style.
-
#swt_cursor ⇒ Object
readonly
Returns the value of attribute swt_cursor.
Instance Method Summary collapse
-
#initialize(cursor_style) ⇒ CursorProxy
constructor
Builds a new CursorProxy from passed in cursor SWT style (e.g. :appstarting, :hand, or :help).
- #swt_style ⇒ Object
Constructor Details
#initialize(cursor_style) ⇒ CursorProxy
Builds a new CursorProxy from passed in cursor SWT style (e.g. :appstarting, :hand, or :help)
Cursor SWT styles are those that begin with “CURSOR_” prefix
They are expected to be passed in in short form without the prefix (but would work with the prefix too)
46 47 48 49 50 51 52 53 |
# File 'lib/glimmer/swt/cursor_proxy.rb', line 46 def initialize(cursor_style) @cursor_style = cursor_style @cursor_style = SWTProxy.reverse_lookup(@cursor_style).detect { |symbol| symbol.to_s.downcase.start_with?('cursor_') } if cursor_style.is_a?(Integer) @cursor_style = @cursor_style.to_s.downcase @cursor_style = @cursor_style.sub(/^cursor\_/, '') if @cursor_style.start_with?('cursor_') detect_invalid_cursor_style @swt_cursor = DisplayProxy.instance.swt_display.get_system_cursor(SWTProxy[swt_style]) end |
Instance Attribute Details
#cursor_style ⇒ Object (readonly)
Returns the value of attribute cursor_style.
39 40 41 |
# File 'lib/glimmer/swt/cursor_proxy.rb', line 39 def cursor_style @cursor_style end |
#swt_cursor ⇒ Object (readonly)
Returns the value of attribute swt_cursor.
39 40 41 |
# File 'lib/glimmer/swt/cursor_proxy.rb', line 39 def swt_cursor @swt_cursor end |
Instance Method Details
#swt_style ⇒ Object
55 56 57 |
# File 'lib/glimmer/swt/cursor_proxy.rb', line 55 def swt_style @swt_style ||= @cursor_style.upcase.start_with?('CURSOR_') ? @cursor_style : "CURSOR_#{@cursor_style}" end |