Sha256: 3ecb938a51b5e1ec341fdb3283ca6a87ac99c52c70556595147b738a809a6f7b

Contents?: true

Size: 1.28 KB

Versions: 54

Compression:

Stored size: 1.28 KB

Contents

require 'glimmer/swt/widget_proxy'
require 'glimmer/swt/text_proxy'
require 'glimmer/swt/swt_proxy'

module Glimmer
  module SWT
    class StyledTextProxy < TextProxy
      attr_reader :alignment, :right_margin, :editable, :caret
      
      def alignment=(value)
        @alignment = %w[left center right].detect {|alignment_value| SWTProxy[alignment_value] == value}
        dom_element.css('text-align', @alignment)
      end
      
      def right_margin=(value)
        @right_margin = value.to_i
        dom_element.css('padding-right', @right_margin)
      end
      
      def editable=(value)
        @editable = value
        if !@editable
          dom_element.attr('disabled', true)
          dom_element.css('background', :white)
          dom_element.css('border', 'solid 1px rgb(118, 118, 118)')
          dom_element.css('border-radius', '3px')
          # :hover {
          #     border-color: rgb(80, 80, 80);
          # }        
        else
          dom_element.prop('disabled', false)
          dom_element.css('background', nil)
          dom_element.css('border', nil)
          dom_element.css('border-radius', nil)
        end
      end
      
      def caret=(value)
        @caret = value
        # TODO implement (not needed for disabling caret though)
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
glimmer-dsl-opal-0.9.1 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.9.0 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.8.0 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.7.5 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.7.4 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.7.3 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.7.2 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.7.1 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.7.0 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.6.1 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.6.0 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.5.1 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.5.0 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.4.0 lib/glimmer/swt/styled_text_proxy.rb