source-code/screens/waves-screens/intensity_screen.rb
def intensity_screen
    @heading = 'Intensity = power / area'
    background('images/waves_large.png')

    # Intensity screen header
    ScreenHeader.new(self, '/title_screen/waves_screen', @@font, @heading)

    # Intensity screen content
    flow(:height => 640, :width => 1080, :scroll => true) do
      # Left margin offset
      stack(:height => 640, :width => 80) do
      end
      # Content column
      stack(:height => 640, :width => 1000) do
        ScreenLabel.new(self, @@font, @heading, 'Power')
        flow do
          @power = ScreenEditLine.new(self, @@font, @heading)
          @power_unit = para(strong(' W'))
          @power_unit.style(@@screen_unit_text_styles)
        end

        ScreenLabel.new(self, @@font, @heading, 'Area')
        flow do
          @area = ScreenEditLine.new(self, @@font, @heading)
          @area_unit = para(strong(' m'), strong(sup('2')))
          @area_unit.style(@@screen_unit_text_styles)
        end

        @calculate = button('Calculate')

        @result_display = flow

        @error_display = flow

        @calculate.click do
          @result_display.clear do
            @result = Joules.intensity(@power.text.to_f,
                                       @area.text.to_f)
            @intensity = para(@result.to_s)
            @intensity_unit = para(' Wm', sup('-2'))
            @intensity.style(@@screen_result_text_styles)
            @intensity_unit.style(@@screen_result_text_styles)
          end
        end
      end
    end
  end
# Draws the intensity screen on the Shoes app window.
Draws the intensity screen on the Shoes app window.
Draws the intensity screen on the Shoes app window .
def intensity_screen
    @heading = 'Intensity = power / area'
    background('images/waves_large.png')
    ScreenHeader.new(self, '/title_screen/waves_screen', @@font, @heading)
    flow(:height => 640, :width => 1080, :scroll => true) do
      stack(:height => 640, :width => 80) do
      end
      stack(:height => 640, :width => 1000) do
        ScreenLabel.new(self, @@font, @heading, 'Power')
        flow do
          @power = ScreenEditLine.new(self, @@font, @heading)
          @power_unit = para(strong(' W'))
          @power_unit.style(@@screen_unit_text_styles)
        end
        ScreenLabel.new(self, @@font, @heading, 'Area')
        flow do
          @area = ScreenEditLine.new(self, @@font, @heading)
          @area_unit = para(strong(' m'), strong(sup('2')))
          @area_unit.style(@@screen_unit_text_styles)
        end
        @calculate = button('Calculate')
        @result_display = flow
        @error_display = flow
        @calculate.click do
          @result_display.clear do
            @result = Joules.intensity(@power.text.to_f,
                                       @area.text.to_f)
            @intensity = para(@result.to_s)
            @intensity_unit = para(' Wm', sup('-2'))
            @intensity.style(@@screen_result_text_styles)
            @intensity_unit.style(@@screen_result_text_styles)
          end
        end
      end
    end
  end
def intensity_screen @heading = 'Intensity = power / area' background ( 'images/waves_large.png' ) ScreenHeader . new ( self , '/title_screen/waves_screen' , @@font , @heading ) flow ( :height => 640 , :width => 1080 , :scroll => true ) do stack ( :height => 640 , :width => 80 ) do end stack ( :height => 640 , :width => 1000 ) do ScreenLabel . new ( self , @@font , @heading , 'Power' ) flow do @power = ScreenEditLine . new ( self , @@font , @heading ) @power_unit = para ( strong ( ' W' ) ) @power_unit . style ( @@screen_unit_text_styles ) end ScreenLabel . new ( self , @@font , @heading , 'Area' ) flow do @area = ScreenEditLine . new ( self , @@font , @heading ) @area_unit = para ( strong ( ' m' ) , strong ( sup ( '2' ) ) ) @area_unit . style ( @@screen_unit_text_styles ) end @calculate = button ( 'Calculate' ) @result_display = flow @error_display = flow @calculate . click do @result_display . clear do @result = Joules . intensity ( @power . text . to_f , @area . text . to_f ) @intensity = para ( @result . to_s ) @intensity_unit = para ( ' Wm' , sup ( '-2' ) ) @intensity . style ( @@screen_result_text_styles ) @intensity_unit . style ( @@screen_result_text_styles ) end end end end end
Draws the intensity screen on the Shoes app window.
Draws the intensity screen on the Shoes app window .
# Intensity screen header # Intensity screen content # Left margin offset # Content column