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.29.0 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.28.3 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.28.2 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.28.1 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.28.0 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.27.0 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.26.3 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.26.2 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.26.1 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.26.0 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.25.4 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.25.3 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.25.2 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.25.1 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.25.0 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.24.0 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.23.0 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.22.1 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.22.0 lib/glimmer/swt/styled_text_proxy.rb
glimmer-dsl-opal-0.21.0 lib/glimmer/swt/styled_text_proxy.rb