Changeset 29236 for lang

Show
Ignore:
Timestamp:
01/29/09 19:19:58 (4 years ago)
Author:
isaisstillalive
Message:
  • クライアント座標からスクリーン座標を求めるメソッドを追加。
Location:
lang/ruby/ruwin
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/ruwin/lib/ruwin/component.rb

    r29230 r29236  
    22  class Component < SWin::Window 
    33    autoload :Scrollable, "ruwin/component/scrollable" 
     4    ClientToScreen = Win32API.new "USER32.DLL", "ClientToScreen", %{L P}, "I" 
    45     
    56    include Ruwin 
     
    8283     
    8384     
     85    def get_screen_position x, y 
     86      point = [x, y].pack("LL") 
     87      ClientToScreen.call hWnd, point 
     88      point.unpack("LL") 
     89    end 
     90     
    8491    private 
    8592    def send_message_with_error_code message, wparam, lparam, error_code = self.class::ERR, &alternate 
  • lang/ruby/ruwin/test/ruwin/test_component.rb

    r29151 r29236  
    196196    assert_equal [[WM_SETREDRAW, 0, 0], [:inter], [WM_SETREDRAW, 1, 0]], instance.messages 
    197197  end 
     198   
     199   
     200  def test_getscreenposition 
     201    instance = Ruwin::Component.new do |component| 
     202      component.move 10, 10, 10, 10 
     203    end 
     204     
     205    # BORDERやWindowの関連か。定数っぽい 
     206    assert_equal [10+4, 10+23], instance.get_screen_position(0, 0) 
     207  end 
    198208end