fxruby 1.6.40 → 1.6.41

Sign up to get free protection for your applications and to get access to all the features.
data/lib/fox16/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Fox
2
2
  def Fox.fxrubyversion
3
- "1.6.40"
3
+ "1.6.41"
4
4
  end
5
5
  end
@@ -83,7 +83,7 @@ module Fox
83
83
 
84
84
  # Test if OpenGL is possible.
85
85
  #
86
- # Same as {FXGLVisual.supported?}, but returns the first element (true/false) only.
86
+ # Same as {FXGLVisual.supported}, but returns the first element (true/false) only.
87
87
  #
88
88
  def FXGLVisual.supported?(app); end
89
89
 
@@ -267,6 +267,8 @@ module Fox
267
267
  # after the item is appended.
268
268
  def appendItem(text, bigIcon=nil, miniIcon=nil, data=nil, notify=false); end
269
269
 
270
+ alias << appendItem
271
+
270
272
  # Prepend a new (possibly subclassed) _item_ to the beginning of the list.
271
273
  # If _notify_ is +true+, a +SEL_INSERTED+ message is sent to the list's message target
272
274
  # after the item is prepended.
@@ -217,6 +217,8 @@ module Fox
217
217
  # Returns the integer index of the newly appended item.
218
218
  def appendItem(text, icon=nil, data=nil, notify=false) ; end
219
219
 
220
+ alias << appendItem
221
+
220
222
  # Prepend a (possibly subclassed) _item_ to the list, e.g.
221
223
  #
222
224
  # list.prependItem(FXListItem.new("clyde"))
@@ -186,6 +186,6 @@ module Fox
186
186
  # Sort items using current sort function
187
187
  def sortItems; end
188
188
 
189
- alias appendItem <<
189
+ alias << appendItem
190
190
  end
191
191
  end
@@ -436,8 +436,8 @@ module Fox
436
436
  #
437
437
  # Search for _string_ in text buffer, and return the extent of
438
438
  # the string as a two-element array of arrays.
439
- # The first array contains the beginning index (or indices)
440
- # and the second array contains the ending index (or indices).
439
+ # The first array contains the beginning index (or indices if +SEARCH_REGEX+)
440
+ # and the second array contains the ending index (or indices if +SEARCH_REGEX+) of the first match.
441
441
  # The search starts from the given
442
442
  # _start_ position, scans forward (+SEARCH_FORWARD+) or backward
443
443
  # (+SEARCH_BACKWARD+), and wraps around if +SEARCH_WRAP+ has been
@@ -445,6 +445,8 @@ module Fox
445
445
  # case insensitive search (+SEARCH_IGNORECASE+), or regular expression
446
446
  # search (+SEARCH_REGEX+).
447
447
  #
448
+ # For regular expression searches, the found regex match begin and end is returned at index 0 and captures are returned as entries starting at index 1 in both beginning and ending arrays.
449
+ #
448
450
  def findText(string, start=0, flags=SEARCH_FORWARD|SEARCH_WRAP|SEARCH_EXACT); end
449
451
 
450
452
  # Return +true+ if position _pos_ is selected
@@ -519,6 +519,8 @@ public:
519
519
 
520
520
  %extend {
521
521
  /**
522
+ * TODO: Change API to return [beg, end] instead of [[beg], [end]] for non regex.
523
+ *
522
524
  * Search for string in text buffer, returning the extent of
523
525
  * the string in beg and end. The search starts from the given
524
526
  * starting position, scans forward (SEARCH_FORWARD) or backward
@@ -536,23 +538,23 @@ public:
536
538
  FXint* beg;
537
539
  FXint* end;
538
540
  VALUE ary=Qnil;
539
- FXint ngroups=string.contains('(')+1; // FIXME: is this right?
541
+ FXint ngroups = flags&SEARCH_REGEX ? string.contains('(')+1 : 1; // FIXME: is this right?
540
542
  if(!FXMALLOC(&beg,FXint,ngroups)){
541
543
  return Qnil;
542
- }
544
+ }
543
545
  if(!FXMALLOC(&end,FXint,ngroups)){
544
546
  FXFREE(&beg);
545
- return Qnil;
546
- }
547
+ return Qnil;
548
+ }
547
549
  if(self->findText(string,beg,end,start,flags,ngroups)){
548
550
  ary=rb_ary_new();
549
- rb_ary_push(ary,FXRbMakeArray(beg,ngroups));
550
- rb_ary_push(ary,FXRbMakeArray(end,ngroups));
551
- }
551
+ rb_ary_push(ary,FXRbMakeArray(beg,ngroups));
552
+ rb_ary_push(ary,FXRbMakeArray(end,ngroups));
553
+ }
552
554
  FXFREE(&beg);
553
555
  FXFREE(&end);
554
556
  return ary;
555
- }
557
+ }
556
558
  }
557
559
 
558
560
  /// Return TRUE if position pos is selected
@@ -1165,6 +1165,15 @@
1165
1165
 
1166
1166
  %define DECLARE_FXTEXT_VIRTUALS(klass)
1167
1167
  %extend klass {
1168
+ virtual void eraseCursorOverhang();
1169
+ virtual void drawCursor(FXuint state);
1170
+ virtual FXuint style(FXint row,FXint beg,FXint end,FXint pos);
1171
+ virtual void drawBufferText(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXint pos,FXint n,FXuint style);
1172
+ virtual void fillBufferRect(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXuint style);
1173
+ virtual void drawTextRow(FXDCWindow& dc,FXint line,FXint left,FXint right);
1174
+ virtual void drawContents(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
1175
+ virtual void drawNumbers(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
1176
+
1168
1177
  virtual void setCursorPos(FXint pos,FXbool notify=FALSE);
1169
1178
  virtual FXbool extendSelection(FXint pos,FXTextSelectionMode mode=SELECT_CHARS,FXbool notify=FALSE);
1170
1179
  virtual FXbool killSelection(FXbool notify=FALSE);
data/test/TC_FXText.rb CHANGED
@@ -87,6 +87,13 @@ public
87
87
  assert_equal([10], endIndex)
88
88
  end
89
89
 
90
+ def test_find_text_with_startpos_wrap_nocase
91
+ @text.text = "I came, i saw, I conquered"
92
+ startIndex, endIndex = @text.findText("i ", 16, SEARCH_FORWARD|SEARCH_IGNORECASE|SEARCH_WRAP)
93
+ assert_equal([0], startIndex)
94
+ assert_equal([2], endIndex)
95
+ end
96
+
90
97
  def test_find_text_with_groups
91
98
  @text.text = "I came, I saw, I conquered"
92
99
  startIndex, endIndex = @text.findText("I ([a-z]+)(, )?", 0, SEARCH_REGEX)
@@ -94,6 +101,18 @@ public
94
101
  assert_equal([8, 6, 8], endIndex)
95
102
  end
96
103
 
104
+ def test_find_text_with_loop
105
+ @text.text = "() ()()"
106
+ e = Enumerator.new do |y|
107
+ pos = 0
108
+ while a=@text.findText("()", pos, SEARCH_FORWARD|SEARCH_EXACT)
109
+ y << a
110
+ pos = a[1][0]
111
+ end
112
+ end
113
+ assert_equal [[[0], [2]], [[4], [6]], [[6], [8]]], e.to_a
114
+ end
115
+
97
116
  if ''.respond_to?(:encoding)
98
117
  def test_encoding
99
118
  @text.text = "世界線航跡蔵"
data/test/TC_FXVec4f.rb CHANGED
@@ -5,6 +5,20 @@ require 'fox16'
5
5
  class TC_FXVec4f < Test::Unit::TestCase
6
6
  include Fox
7
7
 
8
+ def assert_in_delta(v1, v2, delta)
9
+ case v1
10
+ when FXVec3f
11
+ 3.times do |i|
12
+ super(v1[i], v2[i], delta)
13
+ end
14
+ when FXVec4f
15
+ 4.times do |i|
16
+ super(v1[i], v2[i], delta)
17
+ end
18
+ else
19
+ super(v1, v2, delta)
20
+ end
21
+ end
8
22
 
9
23
  def test_new
10
24
  FXVec4f.new
@@ -65,37 +79,37 @@ class TC_FXVec4f < Test::Unit::TestCase
65
79
  def test_neg
66
80
  vec = FXVec4f.new(1.0, 2.0, 3.0, 4.0)
67
81
  vec = -vec
68
- assert_equal(vec[0], -1.0)
69
- assert_equal(vec[1], -2.0)
70
- assert_equal(vec[2], -3.0)
71
- assert_equal(vec[3], -4.0)
82
+ assert_in_delta(vec[0], -1.0, 0.001)
83
+ assert_in_delta(vec[1], -2.0, 0.001)
84
+ assert_in_delta(vec[2], -3.0, 0.001)
85
+ assert_in_delta(vec[3], -4.0, 0.001)
72
86
  end
73
87
 
74
88
  def test_add
75
89
  v1 = FXVec4f.new(1.0, 2.0, 3.0, 4.0)
76
90
  v2 = FXVec4f.new(2.0, 4.0, 6.0, 8.0)
77
91
  v3 = FXVec4f.new(3.0, 6.0, 9.0, 12.0)
78
- assert_equal(v3, v1 + v2)
92
+ assert_in_delta(v3, v1 + v2, 0.001)
79
93
  end
80
94
 
81
95
  def test_sub
82
96
  v1 = FXVec4f.new(3.0, 6.0, 9.0, 12.0)
83
97
  v2 = FXVec4f.new(2.0, 4.0, 6.0, 8.0)
84
98
  v3 = FXVec4f.new(1.0, 2.0, 3.0, 4.0)
85
- assert_equal(v3, v1 - v2)
99
+ assert_in_delta(v3, v1 - v2, 0.001)
86
100
  end
87
101
 
88
102
  def test_mul
89
103
  v1 = FXVec4f.new(3.0, 6.0, 9.0, 12.0)
90
104
  v2 = FXVec4f.new(6.0, 12.0, 18.0, 24.0)
91
- assert_equal(v2, v1 * 2)
105
+ assert_in_delta(v2, v1 * 2, 0.001)
92
106
  end
93
107
 
94
108
  def test_mul2 # same as dot product
95
109
  v1 = FXVec4f.new(3.0, 6.0, 9.0, 12.0)
96
110
  v2 = FXVec4f.new(2.0, 4.0, 6.0, 8.0)
97
- assert_equal(180.0, v1*v2)
98
- assert_equal(180.0, v2*v1)
111
+ assert_in_delta(180.0, v1*v2, 0.001)
112
+ assert_in_delta(180.0, v2*v1, 0.001)
99
113
  end
100
114
 
101
115
  def test_div
@@ -110,8 +124,8 @@ class TC_FXVec4f < Test::Unit::TestCase
110
124
  def test_dot
111
125
  v1 = FXVec4f.new(3.0, 6.0, 9.0, 12.0)
112
126
  v2 = FXVec4f.new(2.0, 4.0, 6.0, 8.0)
113
- assert_equal(180.0, v1.dot(v2))
114
- assert_equal(180.0, v2.dot(v1))
127
+ assert_in_delta(180.0, v1.dot(v2), 0.001)
128
+ assert_in_delta(180.0, v2.dot(v1), 0.001)
115
129
  end
116
130
 
117
131
  def test_length
@@ -121,7 +135,7 @@ class TC_FXVec4f < Test::Unit::TestCase
121
135
 
122
136
  def test_normalize
123
137
  vec = FXVec4f.new(1.0, 1.0, 1.0, 1.0)
124
- assert_equal(FXVec4f.new(0.5, 0.5, 0.5, 0.5), vec.normalize)
138
+ assert_in_delta(FXVec4f.new(0.5, 0.5, 0.5, 0.5), vec.normalize, 0.001)
125
139
  end
126
140
 
127
141
  def test_lo
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fxruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.40
4
+ version: 1.6.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lyle Johnson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-12-28 00:00:00.000000000 Z
12
+ date: 2020-01-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mini_portile2
@@ -978,7 +978,7 @@ files:
978
978
  - test/stress2.rb
979
979
  - test/stress3.rb
980
980
  - test/testcase.rb
981
- homepage: http://fxruby.org/
981
+ homepage: https://github.com/larskanis/fxruby
982
982
  licenses:
983
983
  - LGPL-2.1
984
984
  metadata:
@@ -998,8 +998,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
998
998
  - !ruby/object:Gem::Version
999
999
  version: '0'
1000
1000
  requirements: []
1001
- rubyforge_project:
1002
- rubygems_version: 2.7.8
1001
+ rubygems_version: 3.1.2
1003
1002
  signing_key:
1004
1003
  specification_version: 4
1005
1004
  summary: FXRuby is the Ruby binding to the FOX GUI toolkit.