Changeset 28766
- Timestamp:
- 01/21/09 23:18:50 (4 years ago)
- Location:
- lang/ruby/ruwin
- Files:
-
- 2 modified
-
lib/ruwin/window.rb (modified) (2 diffs)
-
test/ruwin/test_window.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/ruby/ruwin/lib/ruwin/window.rb
r28758 r28766 30 30 end 31 31 32 def msghandler msg 33 case msg.msg 34 when WM_COMMAND 35 wm_command msg 32 messages = { 33 :WM_COMMAND => :wm_command, 34 :WM_ACTIVATE => :wm_activate, 35 }.map{|command, event| "when #{command}; #{event} msg;" }.join 36 class_eval <<-"END" 37 def msghandler msg 38 case msg.msg 39 #{messages} 40 end 36 41 end 37 end42 END 38 43 39 44 def wm_command msg 40 w indow_id= LOWORD(msg.wParam)45 wID = LOWORD(msg.wParam) 41 46 wNotifyCode = HIWORD(msg.wParam) 42 47 hwndControl = msg.lParam … … 52 57 __send__ named_event 53 58 end 59 60 def wm_activate msg 61 fActive = LOWORD(msg.wParam) 62 fMinimized = HIWORD(msg.wParam) 63 hwndPre = msg.lParam 64 case fActive 65 when WA_INACTIVE 66 inactivated 67 when WA_ACTIVE, WA_CLICKACTIVE 68 if method(:activated).arity == 0 69 activated 70 else 71 activated(fActive == WA_CLICKACTIVE) 72 end 73 end 74 end 75 def inactivated; end 76 def activated; end 54 77 end 55 78 end -
lang/ruby/ruwin/test/ruwin/test_window.rb
r28758 r28766 63 63 64 64 { 65 WM_COMMAND => :wm_command, 65 WM_COMMAND => :wm_command, 66 WM_ACTIVATE => :wm_activate, 66 67 }.each do |command, event| 67 68 class_eval <<-"END2" 68 def test_msghandler 69 def test_msghandler_#{command} 69 70 klass = Class.new(Ruwin::Window) 70 71 klass.class_eval <<-'END' … … 106 107 assert_equal true, instance.button_updated_called 107 108 end 109 110 { 111 WA_INACTIVE => :inactivated, 112 WA_ACTIVE => :activated, 113 WA_CLICKACTIVE => :activated, 114 }.each do |command, event| 115 class_eval <<-"END2" 116 def test_wm_activate_#{command} 117 klass = Class.new(Ruwin::Window) 118 klass.class_eval <<-'END' 119 attr_reader :wm_active_called 120 def #{event} 121 @wm_active_called = :#{event} 122 end 123 END 124 instance = klass.new 125 126 msg = DummyMSG.new nil, WM_COMMAND, #{command} 127 instance.wm_activate msg 128 assert_equal :#{event}, instance.wm_active_called 129 end 130 END2 131 end 132 133 { 134 WA_ACTIVE => :false, 135 WA_CLICKACTIVE => :true, 136 }.each do |command, clicked| 137 class_eval <<-"END2" 138 def test_wm_activate_#{command}_with_clicked 139 klass = Class.new(Ruwin::Window) 140 klass.class_eval <<-'END' 141 attr_reader :wm_active_called 142 def activated clicked 143 @wm_active_called = clicked 144 end 145 END 146 instance = klass.new 147 148 msg = DummyMSG.new nil, WM_COMMAND, #{command} 149 instance.wm_activate msg 150 assert_equal #{clicked}, instance.wm_active_called 151 end 152 END2 153 end 108 154 end
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)