fxruby 1.2.4 → 1.2.5

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.
@@ -0,0 +1,112 @@
1
+ /***********************************************************************
2
+ * $Id: unregisterOwnedObjects.cpp,v 1.2 2005/03/01 03:14:59 lyle Exp $
3
+ ***********************************************************************/
4
+
5
+ /**
6
+ * The purpose of an unregisterOwnedObjects() function for a particular
7
+ * class is to call FXRbUnregisterRubyObj() on any objects that this object
8
+ * created itself, and which it "owns" and will destroy in its destructor.
9
+ * This includes not only child widgets, like the horizontal and vertical
10
+ * scrollbars managed by an FXScrollArea, but other non-widget objects
11
+ * like list items.
12
+ *
13
+ * You don't need to worry about objects that the user created himself
14
+ * using Ruby code, because those should get unregistered automatically
15
+ * when they're destroyed. So, for example, if I create a button as a child
16
+ * of a frame, e.g.
17
+ *
18
+ * FXButton.new(parentFrame, ...)
19
+ *
20
+ * that Ruby object's peer is an FXRbButton instance, and the destructor for
21
+ * the FXRbButton class calls FXRbUnregisterRubyObj(this). We only need to
22
+ * worry about the C++ objects that aren't subclasses of regular FOX classes,
23
+ * but which have somehow been "exposed" to the Ruby layer.
24
+ */
25
+
26
+ #include "FXRbCommon.h"
27
+
28
+ void FXRbHeader::unregisterOwnedObjects(FXHeader *self)
29
+ {
30
+ // FXRbFrame::unregisterOwnedObjects(self);
31
+ for (FXint i = 0; i < self->getNumItems(); i++) FXRbUnregisterRubyObj(self->getItem(i));
32
+ }
33
+
34
+ void FXRbScrollArea::unregisterOwnedObjects(FXScrollArea *self)
35
+ {
36
+ // FXRbComposite::unregisterOwnedObjects(self);
37
+ FXRbUnregisterRubyObj(self->horizontalScrollBar());
38
+ FXRbUnregisterRubyObj(self->verticalScrollBar());
39
+ }
40
+
41
+ /*
42
+ void FXRbBitmapView::unregisterOwnedObjects(FXBitmapView *self)
43
+ {
44
+ FXRbScrollArea::unregisterOwnedObjects(self);
45
+ }
46
+ */
47
+
48
+ void FXRbFoldingList::unregisterOwnedObjects(FXFoldingList *self)
49
+ {
50
+ FXRbScrollArea::unregisterOwnedObjects(self);
51
+ FXRbUnregisterRubyObj(self->getHeader());
52
+
53
+ // Save pointer(s) to the soon-to-be-destroyed items
54
+ FXObjectListOf<FXFoldingItem> items;
55
+ FXRbFoldingList::enumerateItems(self->getFirstItem(),self->getLastItem(),items);
56
+
57
+ // Now zero-out pointers held by still-alive Ruby objects
58
+ for (FXint i = 0; i <items.no(); i++) FXRbUnregisterRubyObj(items[i]);
59
+ }
60
+
61
+ void FXRbIconList::unregisterOwnedObjects(FXIconList *self)
62
+ {
63
+ FXRbScrollArea::unregisterOwnedObjects(self);
64
+ FXRbUnregisterRubyObj(self->getHeader());
65
+ for (FXint i = 0; i <self->getNumItems(); i++) FXRbUnregisterRubyObj(self->getItem(i));
66
+ }
67
+
68
+ void FXRbImageView::unregisterOwnedObjects(FXImageView *self)
69
+ {
70
+ FXRbScrollArea::unregisterOwnedObjects(self);
71
+ }
72
+
73
+ void FXRbList::unregisterOwnedObjects(FXList *self)
74
+ {
75
+ FXRbScrollArea::unregisterOwnedObjects(self);
76
+ for (FXint i = 0; i < self->getNumItems(); i++) FXRbUnregisterRubyObj(self->getItem(i));
77
+ }
78
+
79
+ void FXRbScrollWindow::unregisterOwnedObjects(FXScrollWindow *self)
80
+ {
81
+ FXRbScrollArea::unregisterOwnedObjects(self);
82
+ }
83
+
84
+ void FXRbTable::unregisterOwnedObjects(FXTable *self)
85
+ {
86
+ FXRbScrollArea::unregisterOwnedObjects(self);
87
+ FXRbUnregisterRubyObj(self->getColumnHeader());
88
+ FXRbUnregisterRubyObj(self->getRowHeader());
89
+ for(FXint r=0; r<self->getNumRows(); r++){
90
+ for(FXint c=0; c<self->getNumColumns(); c++){
91
+ FXRbUnregisterRubyObj(self->getItem(r,c));
92
+ }
93
+ }
94
+ }
95
+
96
+ void FXRbText::unregisterOwnedObjects(FXText *self)
97
+ {
98
+ FXRbScrollArea::unregisterOwnedObjects(self);
99
+ }
100
+
101
+ void FXRbTreeList::unregisterOwnedObjects(FXTreeList *self)
102
+ {
103
+ FXRbScrollArea::unregisterOwnedObjects(self);
104
+
105
+ // Save pointer(s) to the soon-to-be-destroyed items
106
+ FXObjectListOf<FXTreeItem> items;
107
+ FXRbTreeList::enumerateItems(self->getFirstItem(), self->getLastItem(), items);
108
+
109
+ // Now zero-out pointers held by still-alive Ruby objects
110
+ for (FXint i = 0; i < items.no(); i++) FXRbUnregisterRubyObj(items[i]);
111
+ }
112
+
@@ -271,6 +271,15 @@ module Fox
271
271
  def appendRows(numRows=1, notify=false)
272
272
  insertRows(self.numRows, numRows, notify)
273
273
  end
274
+
275
+ # Select cell at (_row_, _col_).
276
+ # If _notify_ is +true+, a +SEL_SELECTED+ message is sent to the table's message target
277
+ # after the item is selected.
278
+ # Raises IndexError if either _row_ or _col_ is out of bounds.
279
+ #
280
+ def selectItem(row, col, notify=false)
281
+ selectRange(row, row, col, col, notify)
282
+ end
274
283
  end
275
284
  end
276
285
 
@@ -5,7 +5,7 @@ module Fox
5
5
  # Returns the FXRuby version number as a string, e.g. "1.0.19".
6
6
  #
7
7
  def Fox.fxrubyversion
8
- "1.2.4"
8
+ "1.2.5"
9
9
  end
10
10
  end
11
11
 
@@ -430,6 +430,9 @@ module Fox
430
430
  # indicating which cells (if any) were added as a result of the resize; and,
431
431
  # * a +SEL_CHANGED+ message will be sent to the table's message target
432
432
  # indicating the new current cell.
433
+ #
434
+ # Raises ArgError if either _numRows_ or _numCols_ is less than zero.
435
+ #
433
436
  def setTableSize(numRows, numCols, notify=false) ; end
434
437
 
435
438
  #
@@ -578,10 +581,49 @@ module Fox
578
581
  # Raises IndexError if either _row_ or _column_ is out of bounds.
579
582
  def getItemData(row, column) ; end
580
583
 
581
- # Extract cells from given range as text.
584
+ #
585
+ # Extract the text from all the cells in the specified range and
586
+ # return the result as a string.
587
+ # Within the result string, each column's text is delimited by
588
+ # the character specified by _cs_, and each row is delimited by
589
+ # the character specified by _rs_.
590
+ # To reverse this operation (i.e. set the table cells' text
591
+ # from a string), see #overlayText.
592
+ # Raises IndexError if any of _startrow_, _endrow_, _startcol_
593
+ # or _endcol_ is out of bounds.
594
+ #
595
+ # ==== Parameters:
596
+ #
597
+ # +startrow+:: the starting row for the range [Integer]
598
+ # +endrow+:: the ending row for the range [Integer]
599
+ # +startcol+:: the starting column for the range [Integer]
600
+ # +endcol+:: the ending column for the range [Integer]
601
+ # +cs+:: the character to insert at each column break [String]
602
+ # +rs+:: the character to insert at each row break [String]
603
+ #
582
604
  def extractText(startrow, endrow, startcol, endcol, cs='\t', rs='\n'); end
583
605
 
584
- # Overlay text over given cell range.
606
+ #
607
+ # Overlay the text for the cells in the specified range with
608
+ # the fields specified in _text_.
609
+ # Within the _text_ string, each column's text should delimited by
610
+ # the character specified by _cs_, and each row should be delimited by
611
+ # the character specified by _rs_.
612
+ # To reverse this operation (i.e. extract the table cells' text
613
+ # into a string), see #extractText.
614
+ # Raises IndexError if any of _startrow_, _endrow_, _startcol_
615
+ # or _endcol_ is out of bounds.
616
+ #
617
+ # ==== Parameters:
618
+ #
619
+ # +startrow+:: the starting row for the range [Integer]
620
+ # +endrow+:: the ending row for the range [Integer]
621
+ # +startcol+:: the starting column for the range [Integer]
622
+ # +endcol+:: the ending column for the range [Integer]
623
+ # +text+:: the text containing the new cell text [String]
624
+ # +cs+:: the character to insert at each column break [String]
625
+ # +rs+:: the character to insert at each row break [String]
626
+ #
585
627
  def overlayText(startrow, endrow, startcol, endcol, text, cs='\t', rs='\n'); end
586
628
 
587
629
  # Return +true+ if the cell at position (_r_, _c_) is a spanning cell.
@@ -164,14 +164,16 @@ public
164
164
 
165
165
  def setup
166
166
  super(self.class.name)
167
- @table = FXTable.new(mainWindow, 0, 0)
168
- @customTable = CustomTable.new(mainWindow, 0, 0)
167
+ @table = FXTable.new(mainWindow)
168
+ @customTable = CustomTable.new(mainWindow)
169
169
  populateTable
170
170
  end
171
-
171
+
172
+ =begin
172
173
  def test_setTableSize
173
174
  100.times { loadLog } # this should be enough to do it
174
175
  end
176
+ =end
175
177
 
176
178
  def test_getCellColor
177
179
  assert_nothing_raised {
@@ -234,19 +236,19 @@ public
234
236
  def test_updateRange
235
237
  @table.setTableSize(5, 5)
236
238
  assert_nothing_raised {
237
- @table.updateRange(0, 5, 0, 5)
239
+ @table.updateRange(0, 4, 0, 4)
238
240
  }
239
241
  assert_raises(IndexError) {
240
- @table.updateRange(-1, 5, 0, 5) # startRow < 0
242
+ @table.updateRange(-1, 0, 0, 0) # startRow < 0
241
243
  }
242
244
  assert_raises(IndexError) {
243
- @table.updateRange(0, 6, 0, 5) # endRow > numRows
245
+ @table.updateRange(0, 5, 0, 0) # endRow >= numRows
244
246
  }
245
247
  assert_raises(IndexError) {
246
- @table.updateRange(0, 5, -1, 5) # startCol < 0
248
+ @table.updateRange(0, 0, -1, 0) # startCol < 0
247
249
  }
248
250
  assert_raises(IndexError) {
249
- @table.updateRange(0, 5, 0, 6) # endCol > numColumns
251
+ @table.updateRange(0, 0, 0, 5) # endCol >= numColumns
250
252
  }
251
253
  end
252
254
 
@@ -313,7 +315,7 @@ public
313
315
  @table.removeColumns(@table.numColumns)
314
316
  }
315
317
  end
316
-
318
+
317
319
  def test_getColumnX
318
320
  @table.setTableSize(5, 5)
319
321
  assert_raises(IndexError) {
@@ -323,10 +325,10 @@ public
323
325
  @table.getColumnX(0)
324
326
  }
325
327
  assert_nothing_raised {
326
- @table.getColumnX(5)
328
+ @table.getColumnX(4)
327
329
  }
328
330
  assert_raises(IndexError) {
329
- @table.getColumnX(6)
331
+ @table.getColumnX(5)
330
332
  }
331
333
  end
332
334
 
@@ -355,114 +357,44 @@ public
355
357
  @table.getRowY(0)
356
358
  }
357
359
  assert_nothing_raised {
358
- @table.getRowY(5)
360
+ @table.getRowY(4)
359
361
  }
360
362
  assert_raises(IndexError) {
361
- @table.getRowY(6)
363
+ @table.getRowY(5)
362
364
  }
363
365
  end
364
-
366
+
365
367
  def test_setRowY
366
368
  @table.setTableSize(5, 5)
367
369
  assert_raises(IndexError) {
368
- @table.setRowY(-1, 0)
370
+ @table.setRowY(-1, 0) # out of bounds
369
371
  }
370
372
  assert_nothing_raised {
371
- @table.setRowY(0, 0)
373
+ @table.setRowY(0, 0) # top edge
372
374
  }
373
375
  assert_nothing_raised {
374
- @table.setRowY(5, 0)
375
- }
376
- assert_raises(IndexError) {
377
- @table.setRowY(6, 0)
376
+ @table.setRowY(5, 0) # bottom edge
378
377
  }
379
- end
380
-
381
- def test_setLeadingRows
382
- @table.setTableSize(5, 5)
383
- @table.trailingRows = 2
384
378
  assert_raises(IndexError) {
385
- @table.leadingRows = -1
379
+ @table.setRowY(6, 0) # out of bounds
386
380
  }
387
- assert_nothing_raised {
388
- @table.leadingRows = 0
389
- }
390
- assert_nothing_raised {
391
- @table.leadingRows = @table.numRows - @table.trailingRows
392
- }
393
- assert_raises(IndexError) {
394
- @table.leadingRows = @table.numRows - @table.trailingRows + 1
395
- }
396
- end
397
-
398
- def test_setLeadingCols
399
- @table.setTableSize(5, 5)
400
- @table.trailingColumns = 2
401
- assert_raises(IndexError) {
402
- @table.leadingColumns = -1
403
- }
404
- assert_nothing_raised {
405
- @table.leadingColumns = 0
406
- }
407
- assert_nothing_raised {
408
- @table.leadingColumns = @table.numColumns - @table.trailingColumns
409
- }
410
- assert_raises(IndexError) {
411
- @table.leadingColumns = @table.numColumns - @table.trailingColumns + 1
412
- }
413
- end
414
-
415
- def test_setTrailingRows
416
- @table.setTableSize(5, 5)
417
- @table.leadingRows = 2
418
- assert_raises(IndexError) {
419
- @table.trailingRows = -1
420
- }
421
- assert_nothing_raised {
422
- @table.trailingRows = 0
423
- }
424
- assert_nothing_raised {
425
- @table.trailingRows = @table.numRows - @table.leadingRows
426
- }
427
- assert_raises(IndexError) {
428
- @table.trailingRows = @table.numRows - @table.leadingRows + 1
429
- }
430
- end
431
-
432
- def test_setTrailingCols
433
- @table.setTableSize(5, 5)
434
- @table.leadingColumns = 2
435
- assert_raises(IndexError) {
436
- @table.trailingColumns = -1
437
- }
438
- assert_nothing_raised {
439
- @table.trailingColumns = 0
440
- }
441
- assert_nothing_raised {
442
- @table.trailingColumns = @table.numColumns - @table.leadingColumns
443
- }
444
- assert_raises(IndexError) {
445
- @table.trailingColumns = @table.numColumns - @table.leadingColumns + 1
446
- }
447
- end
448
-
449
- def test_overridden_setColumnWidth
450
- # What can we do to simulate a call to setColumnWidth?
451
- end
381
+ end
452
382
 
453
- def test_overridden_setRowHeight
454
- # What can we do to simulate a call to setRowHeight?
383
+ def test_extractText
384
+ @table.setTableSize(2, 2)
385
+ @table.setItemText(0, 0, "(0, 0)")
386
+ @table.setItemText(0, 1, "(0, 1)")
387
+ @table.setItemText(1, 0, "(1, 0)")
388
+ @table.setItemText(1, 1, "(1, 1)")
389
+ assert_equal("(0, 0)\t(0, 1)\n(1, 0)\t(1, 1)\n", @table.extractText(0, 1, 0, 1))
455
390
  end
456
-
457
- def test_overridden_setColumnX
458
- # assert_raises(OverrideError) {
459
- # @customTable.handle(nil, FXSEL(SEL_MOTION, 0), event)
460
- # }
461
- end
462
-
463
- def test_overridden_setRowY
464
- # assert_raises(OverrideError) {
465
- # @customTable.handle(nil, FXSEL(SEL_MOTION, 0), event)
466
- # }
391
+
392
+ def test_overlayText
393
+ @table.setTableSize(2, 2)
394
+ @table.overlayText(0, 1, 0, 1, "(0, 0)\t(0, 1)\n(1, 0)\t(1, 1)\n")
395
+ assert_equal("(0, 0)", @table.getItemText(0, 0))
396
+ assert_equal("(0, 1)", @table.getItemText(0, 1))
397
+ assert_equal("(1, 0)", @table.getItemText(1, 0))
398
+ assert_equal("(1, 1)", @table.getItemText(1, 1))
467
399
  end
468
400
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.4
2
+ rubygems_version: 0.8.6
3
3
  specification_version: 1
4
4
  name: fxruby
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.2.4
7
- date: 2005-02-23
6
+ version: 1.2.5
7
+ date: 2005-03-01
8
8
  summary: FXRuby is the Ruby binding to the FOX GUI toolkit.
9
9
  require_paths:
10
10
  - ext/fox12
@@ -265,6 +265,7 @@ files:
265
265
  - ext/fox12/text_wrap.cpp
266
266
  - ext/fox12/treelist_wrap.cpp
267
267
  - ext/fox12/ui_wrap.cpp
268
+ - ext/fox12/unregisterOwnedObjects.cpp
268
269
  - ext/fox12/include/FXMemoryBuffer.h
269
270
  - ext/fox12/include/FXRb4Splitter.h
270
271
  - ext/fox12/include/FXRbAccelTable.h