Sha256: eb09715bb21562424389fdd6e7b0935b03988a54fbfb5bad9b873be51784e363

Contents?: true

Size: 1.77 KB

Versions: 5

Compression:

Stored size: 1.77 KB

Contents

require_relative './lib/wxapp_runner'

class TestDC < Test::Unit::TestCase

  def test_memory_dc
    bmp = Wx::Bitmap.new(100, 100)
    assert_nothing_raised do
      Wx::MemoryDC.draw_on(bmp) do |mdc|
        mdc.set_background(Wx::WHITE_BRUSH)
        mdc.clear
        mdc.set_pen(Wx::BLACK_PEN)
        mdc.set_brush(Wx::WHITE_BRUSH)
        mdc.draw_rectangle(0, 0, 60, 15)
        mdc.draw_line(0, 0, 59, 14)
        mdc.set_text_foreground(Wx::BLACK)
        mdc.draw_text("x1", 0, 0)
      end
    end
  end

  def test_gc_dc
    bmp = Wx::Bitmap.new(100, 100)
    assert_nothing_raised do
      Wx::MemoryDC.draw_on(bmp) do |mdc|
        Wx::GCDC.draw_on(mdc) do |gdc|
          gdc.set_background(Wx::WHITE_BRUSH)
          gdc.clear
          gdc.set_pen(Wx::BLACK_PEN)
          gdc.set_brush(Wx::WHITE_BRUSH)
          GC.start
          gdc.draw_rectangle(0, 0, 60, 15)
          gdc.draw_line(0, 0, 59, 14)
          gdc.set_text_foreground(Wx::BLACK)
          gdc.draw_text("x1", 0, 0)
          GC.start
        end
      end
    end
  end

  def test_gc_dc_stress
    10.times do
      bmp = Wx::Bitmap.new(100, 100)
      assert_nothing_raised do
        Wx::MemoryDC.draw_on(bmp) do |mdc|
          Wx::GCDC.draw_on(mdc) do |gdc|

            gc = gdc.get_graphics_context
            gc.scale(0.9, 0.9)

            10.times do |i|
              gdc.set_background(Wx::WHITE_BRUSH)
              gdc.clear
              gdc.set_pen(Wx::BLACK_PEN)
              gdc.set_brush(Wx::WHITE_BRUSH)
              GC.start
              gdc.draw_rectangle(0, 0, 60, 15)
              gdc.draw_line(0, 0, 59, 14)
              gdc.set_text_foreground(Wx::BLACK)
              gdc.draw_text("x1", 0, 0)
              GC.start
            end
          end
        end
      end
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wxruby3-0.9.0.pre.rc.3 tests/test_dc.rb
wxruby3-0.9.0.pre.rc.2 tests/test_dc.rb
wxruby3-0.9.0.pre.rc.1 tests/test_dc.rb
wxruby3-0.9.0.pre.beta.14 tests/test_dc.rb
wxruby3-0.9.0.pre.beta.13 tests/test_dc.rb