Sha256: 9bb6989f4c649deafd7582bc552255fd24e9045ce61a19a24379c1fdda6d9e48

Contents?: true

Size: 1.77 KB

Versions: 23

Compression:

Stored size: 1.77 KB

Contents

# encoding: ascii-8bit

# Copyright 2014 Ball Aerospace & Technologies Corp.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
# under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt

require 'cosmos'
require 'cosmos/tools/tlm_viewer/widgets/canvasvalue_widget'

module Cosmos

  class CanvaslabelvalueWidget < CanvasvalueWidget
    def initialize(parent_layout, target_name, packet_name, item_name, x1, y1, font_size = 12, color = 'black', frame = true, frame_width = 3, value_type = :CONVERTED)
      super(parent_layout, target_name, packet_name, item_name, value_type)
      @x = x1.to_i
      @y = y1.to_i
      @color = Cosmos.getColor(color)
      @pen = Cosmos.getPen(color)
      @font = Cosmos.getFont("helvetica", font_size.to_i)
      @fm = Cosmos.getFontMetrics(@font)
      @frame = ConfigParser.handle_true_false(frame)
      @frame_width = frame_width.to_i
      @value = ''
    end

    def value=(data)
      if @value != data
        @value = data
        @parent_layout.update_widget
      end
    end

    def draw_widget(painter, on_state)
      painter.save
      painter.setPen(@pen)
      painter.setFont(@font)
      painter.drawText(@x, @y, @value.to_s)
      if @frame
        h = @fm.height
        w = @fm.width(@value.to_s)
        @pen.setWidth(@frame_width)
        painter.drawLine(@x - 5, @y + 5, @x + w + 10, @y + 5) # bottom line
        painter.drawLine(@x - 5, @y + 5, @x - 5, @y - h - 5) # left line
        painter.drawLine(@x - 5, @y - h - 5, @x + w + 10, @y - h - 5) # top line
        painter.drawLine(@x + w + 10, @y + 5, @x + w + 10, @y - h - 5) # right line
      end
      painter.restore
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
cosmos-4.3.0-java lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.3.0 lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.2.4-java lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.2.4 lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.2.3-java lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.2.3 lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.2.2-java lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.2.2 lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.2.1-java lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.2.1 lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.2.0-java lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.2.0 lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.1.1-java lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.1.1 lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.1.0-java lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.1.0 lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.0.3-java lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.0.3-universal-java-1.8 lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.0.3 lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb
cosmos-4.0.2-universal-java-1.8 lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb