Changeset 29123
- Timestamp:
- 01/27/09 19:06:04 (4 years ago)
- Location:
- lang/ruby/ruwin
- Files:
-
- 4 modified
-
lib/ruwin/edit_field.rb (modified) (4 diffs)
-
lib/ruwin/edit_field/rich.rb (modified) (1 diff)
-
test/ruwin/edit_field/test_rich.rb (modified) (1 diff)
-
test/ruwin/testm_edit_field.rb (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/ruby/ruwin/lib/ruwin/edit_field.rb
r29107 r29123 30 30 end 31 31 32 33 32 def string 34 caption 33 caption.kconv(Kconv::UTF8, Kconv::SJIS).gsub(/\r\n|\r|\n/m, self.class::RETURN_CODE) 35 34 end 36 35 alias to_s string 36 37 def string= string 38 self.caption = string.gsub(/\r\n|\r|\n/m, self.class::RETURN_CODE).kconv(Kconv::SJIS, Kconv::UTF8) 39 end 37 40 38 41 def clear … … 76 79 77 80 def upcase 78 caption.upcase81 string.upcase 79 82 end 80 83 81 84 def upcase! 82 self. caption= upcase85 self.string = upcase 83 86 end 84 87 … … 97 100 STYLE = Control::STYLE | ES_AUTOHSCROLL 98 101 EXSTYLE = WS_EX_CLIENTEDGE 102 RETURN_CODE = "" 99 103 100 104 property_accessor :writable => true 105 private :caption, :caption= 106 107 def wm_lbuttondown 108 p :wm_lbuttondown 109 end 101 110 102 111 def self.read_only … … 104 113 end 105 114 106 private :caption=107 def string= string108 self.caption = string.gsub(/\r\n|\r|\n/m, "")109 end110 111 115 class Multiline < EditField 112 116 STYLE = Control::STYLE | ES_MULTILINE | ES_AUTOVSCROLL 113 114 def string= string 115 self.caption = string.gsub(/\r\n|\r|\n/m, "\r\n") 116 end 117 RETURN_CODE = "\r\n" 117 118 end 118 119 end -
lang/ruby/ruwin/lib/ruwin/edit_field/rich.rb
r29107 r29123 97 97 class Multiline < Rich 98 98 STYLE = EditField::Multiline::STYLE 99 100 def string= string 101 self.caption = string.gsub(/\r\n|\r|\n/m, "\r\n") 102 end 99 RETURN_CODE = "\r\n" 103 100 end 104 101 end -
lang/ruby/ruwin/test/ruwin/edit_field/test_rich.rb
r29101 r29123 128 128 assert_equal "RICHEDIT20A", @control.classname 129 129 end 130 131 # 改行をそもそも含めることができない。ここのテスト手法は要検討 132 undef test_string_getter_should_deny_return 130 133 end 131 134 -
lang/ruby/ruwin/test/ruwin/testm_edit_field.rb
r29107 r29123 25 25 # assert_equal false, @control.undo # 単一行の際に正しく戻らない 26 26 @control.undo 27 assert_equal "", @control. caption27 assert_equal "", @control.string 28 28 end 29 29 … … 31 31 @control.selection.string = "test" 32 32 assert_equal true, @control.undo 33 assert_equal "", @control. caption33 assert_equal "", @control.string 34 34 end 35 35 … … 174 174 @control.string = "caption" 175 175 assert_equal "CAPTION", @control.upcase 176 assert_equal "caption", @control. caption176 assert_equal "caption", @control.string 177 177 end 178 178 … … 180 180 @control.string = "caption" 181 181 assert_equal "CAPTION", @control.upcase! 182 assert_equal "CAPTION", @control. caption182 assert_equal "CAPTION", @control.string 183 183 end 184 184 … … 187 187 msg = DummyMSG.new nil, nil, nil 188 188 assert_equal :updated, @control.wm_command(msg, nil, EN_UPDATE, nil) 189 end 190 191 def test_string_setter_should_encode_utf8_to_sjis 192 klass = Class.new(self.class::TARGET_CLASS) 193 control = klass.new(@window) 194 control.string = "あいう" 195 assert_equal "あいう".tosjis, control.__send__(:caption) 196 end 197 198 def test_string_getter_should_encode_sjis_to_utf8 199 klass = Class.new(self.class::TARGET_CLASS) 200 control = klass.new(@window) 201 control.__send__ :caption=, "あいう".tosjis 202 assert_equal "あいう", control.string 189 203 end 190 204 end … … 199 213 200 214 201 def test_string_s hould_deny_return215 def test_string_setter_should_deny_return 202 216 klass = Class.new(self.class::TARGET_CLASS) 203 217 control = klass.new(@window) 204 218 control.string = "caption\r\ncaption\rcaption\ncaption" 205 assert_equal "captioncaptioncaptioncaption", control.caption 219 assert_equal "captioncaptioncaptioncaption", control.__send__(:caption) 220 end 221 222 def test_string_getter_should_deny_return 223 klass = Class.new(self.class::TARGET_CLASS) 224 control = klass.new(@window) 225 control.__send__ :caption=, "caption\r\ncaption\rcaption\ncaption" 226 assert_equal "captioncaptioncaptioncaption", control.string 206 227 end 207 228 end … … 219 240 220 241 221 def test_string_s hould_allow_return242 def test_string_setter_should_allow_return_and_convert_to_crlf 222 243 klass = Class.new(self.class::TARGET_CLASS) 223 244 control = klass.new(@window) 224 245 control.string = "caption\r\ncaption\rcaption\ncaption" 225 assert_equal "caption\r\ncaption\r\ncaption\r\ncaption", control.caption 246 assert_equal "caption\r\ncaption\r\ncaption\r\ncaption", control.__send__(:caption) 247 end 248 249 def test_string_getter_should_allow_return_and_convert_to_crlf 250 klass = Class.new(self.class::TARGET_CLASS) 251 control = klass.new(@window) 252 control.__send__ :caption=, "caption\r\ncaption\rcaption\ncaption" 253 assert_equal "caption\r\ncaption\r\ncaption\r\ncaption", control.string 226 254 end 227 255 end … … 353 381 @selection.change 3, 6 354 382 @selection.string = "ricor" 355 assert_equal "capricorn", @control. caption383 assert_equal "capricorn", @control.string 356 384 end 357 385 … … 360 388 @selection_without_reflection.change 3, 6 361 389 @selection_without_reflection.string = "ricor" 362 assert_equal "capricorn", @control. caption390 assert_equal "capricorn", @control.string 363 391 assert_equal 0...0, @selection.range 364 392 end
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)