fxruby 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,45 +1,48 @@
1
1
  module Fox
2
- # Memory Store Definition
3
- class FXMemoryStream : public FXStream {
2
+ #
3
+ # A FXMemoryStream is a stream that reads from (or writes to) a buffer of bytes in memory.
4
+ # That buffer may "owned" by either the application code or by the stream object itself.
5
+ # In the latter case, the stream object will dispose of the buffer contents when the stream
6
+ # is closed.
7
+ #
8
+ class FXMemoryStream < FXStream
4
9
 
5
10
  #
6
- # Return an initialized FXMemoryStream instance.
11
+ # Construct a new memory stream with given container object.
12
+ # The container object is an object that will itself not be
13
+ # saved to or loaded from the stream, but which may be referenced
14
+ # by other objects. These references will be properly saved and restored.
15
+ #
16
+ # ==== Parameters:
17
+ #
18
+ # +cont+:: the container object, or +nil+ if there is none [FXObject].
7
19
  #
8
20
  def initialize(cont=nil) # :yields: theMemoryStream
9
21
  end
10
22
 
11
23
  #
12
24
  # Open memory stream for reading or writing.
13
- # Returns true if successful, false otherwise.
25
+ # Returns +true+ if successful, +false+ otherwise.
14
26
  #
15
27
  # ==== Parameters:
16
28
  #
17
- # +save_or_load+:: access mode, either +FXStreamSave+ or +FXStreamLoad+ [Integer]
18
- # +data+:: memory buffer used for the stream [String]
29
+ # +save_or_load+:: access mode, either +FXStreamSave+ or +FXStreamLoad+ [Integer]
30
+ # +data+:: memory buffer to be used for the stream, or +nil+ if the stream object should allocate its own buffer [String]
19
31
  #
20
32
  def open(save_or_load, data); end
21
33
 
22
34
  #
23
- # Open memory stream for reading or writing.
24
- # Returns true if successful, false otherwise.
25
- #
26
- # ==== Parameters:
27
- #
28
- # +save_or_load+:: access mode, either +FXStreamSave+ or +FXStreamLoad+ [Integer]
29
- # +size+:: what is it? [Integer]
30
- # +data+:: memory buffer used for the stream [String]
31
- #
32
- def open(save_or_load, size, data); end
33
-
34
- #
35
- # Take buffer away from stream; returns a String containing the buffer contents.
35
+ # Take buffer away from stream, thus transferring ownership of the buffer
36
+ # from the stream object to the caller.
37
+ # Returns a string containing the buffer contents.
36
38
  #
37
39
  def takeBuffer; end
38
40
 
39
41
  #
40
- # Give buffer to stream
42
+ # Give buffer (a string) to this stream, thus transferring ownership of
43
+ # the buffer from the caller to the stream object.
41
44
  #
42
- def giveBuffer(buffer, sp); end
45
+ def giveBuffer(buffer); end
43
46
  end
44
47
  end
45
48
 
@@ -38,23 +38,23 @@ module Fox
38
38
  # of the modifiers _Ctrl_, _Alt_ and _Shift_, plus the key of interest.
39
39
  # For example, to get the accelerator key for Ctrl+Alt+F7, you'd use:
40
40
  #
41
- # hotKey = fxparseaccel("Ctrl+Alt+F7")
41
+ # hotKey = fxparseAccel("Ctrl+Alt+F7")
42
42
  #
43
- def Fox.fxparseaccel(str); end
43
+ def Fox.fxparseAccel(str); end
44
44
 
45
45
  #
46
46
  # Return a hot key value that represents the hot key described in
47
47
  # the string _str_. This method is less flexible than the similar
48
- # Fox.fxparseaccel, and is mainly used internally for parsing the
48
+ # Fox.fxparseAccel, and is mainly used internally for parsing the
49
49
  # labels for FXButton and FXMenuCommand widgets. For example, this:
50
50
  #
51
- # fxparsehotkey("&File")
51
+ # fxparseHotKey("&File")
52
52
  #
53
53
  # returns the equivalent of:
54
54
  #
55
- # fxparseaccel("Alt+F")
55
+ # fxparseAccel("Alt+F")
56
56
  #
57
- def Fox.fxparsehotkey(s); end
57
+ def Fox.fxparseHotKey(s); end
58
58
 
59
59
  # Locate hot key underline offset from begin of string
60
60
  def Fox.fxfindhotkeyoffset(s); end
data/tests/TC_FXImage.rb CHANGED
@@ -8,46 +8,55 @@ class TC_FXImage < TestCase
8
8
  def setup
9
9
  super(self.class.name)
10
10
  end
11
-
12
- def test_default_constructor_args
11
+
12
+ def test_default_constructor_args_1
13
13
  img = FXImage.new(app)
14
14
  assert_same(nil, img.data)
15
15
  assert_equal(0, img.options)
16
16
  assert_equal(1, img.width)
17
17
  assert_equal(1, img.height)
18
-
18
+ end
19
+
20
+ def test_default_constructor_args_2
19
21
  img = FXImage.new(app, nil)
20
22
  assert_same(nil, img.data)
21
23
  assert_equal(0, img.options)
22
24
  assert_equal(1, img.width)
23
25
  assert_equal(1, img.height)
26
+ end
24
27
 
28
+ def test_default_constructor_args_3
25
29
  img = FXImage.new(app, nil, 0)
26
30
  assert_same(nil, img.data)
27
31
  assert_equal(0, img.options)
28
32
  assert_equal(1, img.width)
29
33
  assert_equal(1, img.height)
34
+ end
30
35
 
36
+ def test_default_constructor_args_4
31
37
  img = FXImage.new(app, nil, 0, 1)
32
38
  assert_same(nil, img.data)
33
39
  assert_equal(0, img.options)
34
40
  assert_equal(1, img.width)
35
41
  assert_equal(1, img.height)
42
+ end
36
43
 
44
+ def test_default_constructor_args_5
37
45
  img = FXImage.new(app, nil, 0, 1, 1)
38
46
  assert_same(nil, img.data)
39
47
  assert_equal(0, img.options)
40
48
  assert_equal(1, img.width)
41
49
  assert_equal(1, img.height)
42
50
  end
43
-
44
- def test_image_owned
45
- img = FXImage.new(app, nil, IMAGE_OWNED, 2, 2)
46
- assert_equal(2, img.width)
47
- assert_equal(2, img.height)
51
+
52
+ def test_new_image_nil_pixels_owned
53
+ img = FXImage.new(app, nil, IMAGE_OWNED)
54
+ assert_equal(1, img.width)
55
+ assert_equal(1, img.height)
48
56
  data = img.data
49
57
  assert_instance_of(FXMemoryBuffer, data)
50
- assert_equal(2*2, data.size)
58
+ assert_equal(1*1, data.size)
59
+ assert_equal(IMAGE_OWNED, img.options)
51
60
  end
52
61
 
53
62
  def test_create
@@ -94,7 +103,7 @@ class TC_FXImage < TestCase
94
103
  img = FXImage.new(app)
95
104
  img.render
96
105
  end
97
-
106
+
98
107
  =begin
99
108
 
100
109
  def test_scale
@@ -140,5 +149,7 @@ class TC_FXImage < TestCase
140
149
 
141
150
  def test_loadPixels
142
151
  end
152
+
143
153
  =end
154
+
144
155
  end
@@ -15,44 +15,54 @@ class TC_FXMemoryStream < Test::Unit::TestCase
15
15
 
16
16
  public
17
17
 
18
- def test_open
19
- s1 = FXMemoryStream.new
20
- assert(s1.open(FXStreamLoad, nil))
21
- assert_equal(DEFAULT_BUFFER_SIZE, s1.space)
22
- s1.close
23
-
24
- s2 = FXMemoryStream.new
25
- assert(s2.open(FXStreamSave, nil))
26
- assert_equal(DEFAULT_BUFFER_SIZE, s2.space)
27
- s2.close
28
-
29
- s3 = FXMemoryStream.new
30
- assert(s3.open(FXStreamLoad, "foo"))
31
- assert_equal(3, s3.space)
32
- s3.close
33
-
34
- s4 = FXMemoryStream.new
35
- assert(s4.open(FXStreamSave, "foo"))
36
- assert_equal(3, s4.space)
37
- s4.close
18
+ def test_open_streamload_nil_data
19
+ s = FXMemoryStream.new
20
+ assert(s.open(FXStreamLoad, nil))
21
+ assert_equal(DEFAULT_BUFFER_SIZE, s.space)
22
+ s.close
38
23
  end
39
24
 
40
- def test_open_s
41
- s1 = FXMemoryStream.open(FXStreamLoad, nil)
42
- assert_equal(DEFAULT_BUFFER_SIZE, s1.space)
43
- s1.close
25
+ def test_open_streamsave_nil_data
26
+ s = FXMemoryStream.new
27
+ assert(s.open(FXStreamSave, nil))
28
+ assert_equal(DEFAULT_BUFFER_SIZE, s.space)
29
+ s.close
30
+ end
44
31
 
45
- s2 = FXMemoryStream.open(FXStreamSave, nil)
46
- assert_equal(DEFAULT_BUFFER_SIZE, s2.space)
47
- s2.close
32
+ def test_open_streamload_unknown_size
33
+ s = FXMemoryStream.new
34
+ assert(s.open(FXStreamLoad, "foo"))
35
+ s.close
36
+ end
37
+
38
+ def test_open_streamsave_unknown_size
39
+ s = FXMemoryStream.new
40
+ assert(s.open(FXStreamSave, "foo"))
41
+ s.close
42
+ end
43
+
44
+ def test_open_s_load_nil_buffer
45
+ s = FXMemoryStream.open(FXStreamLoad, nil)
46
+ assert_equal(DEFAULT_BUFFER_SIZE, s.space)
47
+ s.close
48
+ end
48
49
 
49
- s3 = FXMemoryStream.open(FXStreamLoad, "foo")
50
- assert_equal(3, s3.space)
51
- s3.close
50
+ def test_open_s_save_nil_buffer
51
+ s = FXMemoryStream.open(FXStreamSave, nil)
52
+ assert_equal(DEFAULT_BUFFER_SIZE, s.space)
53
+ s.close
54
+ end
55
+
56
+ def test_open_s_load_unknown_buffer_size
57
+ s = FXMemoryStream.open(FXStreamLoad, "foo")
58
+ assert_equal(3, s.space)
59
+ s.close
60
+ end
52
61
 
53
- s4 = FXMemoryStream.open(FXStreamSave, "foo")
54
- assert_equal(3, s4.space)
55
- s4.close
62
+ def test_open_s_save_unknown_buffer_size
63
+ s = FXMemoryStream.open(FXStreamSave, "foo")
64
+ assert_equal(3, s.space)
65
+ s.close
56
66
  end
57
67
 
58
68
  def test_open_s_with_block
@@ -73,7 +83,7 @@ class TC_FXMemoryStream < Test::Unit::TestCase
73
83
  def test_takeBuffer_empty
74
84
  FXMemoryStream.open(FXStreamSave, nil) do |stream|
75
85
  buffer = stream.takeBuffer
76
- assert_equal("\0", buffer)
86
+ assert_equal("\0" * 16, buffer)
77
87
  end
78
88
  end
79
89
 
data/tests/testcase.rb CHANGED
@@ -13,12 +13,11 @@ module Fox
13
13
  if FXApp.instance.nil?
14
14
  @theApp = FXApp.new(appName, 'FXRuby')
15
15
  @theApp.init([])
16
- FXMainWindow.new(@theApp, appName)
17
16
  else
18
17
  @theApp = FXApp.instance
19
18
  end
20
- end
21
- @theMainWindow = FXMainWindow.new(@theApp, appName)
19
+ @theMainWindow = FXMainWindow.new(@theApp, appName)
20
+ end
22
21
  end
23
22
 
24
23
  # Return a reference to the application
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.4
3
3
  specification_version: 1
4
4
  name: fxruby
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.2.3
7
- date: 2005-01-22
6
+ version: 1.2.4
7
+ date: 2005-02-23
8
8
  summary: FXRuby is the Ruby binding to the FOX GUI toolkit.
9
9
  require_paths:
10
10
  - ext/fox12
@@ -30,7 +30,6 @@ authors:
30
30
  files:
31
31
  - ANNOUNCE
32
32
  - ChangeLog
33
- - INSTALL
34
33
  - LICENSE
35
34
  - README
36
35
  - index.html
@@ -127,6 +126,7 @@ files:
127
126
  - examples/inputs.rb
128
127
  - examples/iRAA.rb
129
128
  - examples/mditest.rb
129
+ - examples/mditest2.rb
130
130
  - examples/pig.rb
131
131
  - examples/RAA.rb
132
132
  - examples/raabrowser.rb
data/INSTALL DELETED
@@ -1,50 +0,0 @@
1
- **** WAIT! ****
2
-
3
- If you're planning to use FXRuby on Windows, be aware that the Pragmatic
4
- Programmers' Ruby installer for Windows contains a version of FXRuby,
5
- although it may not be the most recent one.
6
-
7
- The Basics
8
- ============
9
-
10
- This is more or less a plain text transcription of the first part of the
11
- build instructions found in the FXRuby User's Guide here:
12
-
13
- http://www.fxruby.org/doc/build.html
14
-
15
- If you have additional questions about how the build and installation process
16
- works you might want to also read that document.
17
-
18
- These instructions assume that you've already downloaded, compiled and
19
- installed FOX. And if you're reading this, you must have already downloaded
20
- and unpacked the FXRuby source tarball. The next step is to change directories
21
- to the top-level and type:
22
-
23
- ruby install.rb config
24
-
25
- By default, the install.rb script will look for the FOX include files and
26
- library in the standard /usr/local/include/fox and /usr/local/lib directories,
27
- respectively. You can override these locations by passing a few additional
28
- arguments to install.rb during this step, e.g.
29
-
30
- ruby install.rb config -- \
31
- --with-fox-include=/home/lyle/fox-1.0.42/include \
32
- --with-fox-lib=/home/lyle/fox-1.0.42/src/.libs
33
-
34
- Once the build has been configured, you can start the build by typing:
35
-
36
- ruby install.rb setup
37
-
38
- It will take quite awhile to build FXRuby, even on a fast machine, so this
39
- might be a good time to take a coffee break. If you run into problems during
40
- the compilation, please check the list of things that go wrong:
41
-
42
- http://www.fxruby.org/doc/build.html#TRAGEDIES
43
-
44
- before sending Lyle an e-mail. There's a good chance that someone else has
45
- run into this problem already and that we've documented the workaround(s).
46
-
47
- Once it's finished compiling, install FXRuby by typing:
48
-
49
- ruby install.rb install
50
-