fxruby 1.6.22-x86-mingw32 → 1.6.23-x86-mingw32

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.
Files changed (203) hide show
  1. data/.gitignore +14 -0
  2. data/.yardopts +8 -0
  3. data/History.txt +6 -0
  4. data/Manifest.txt +317 -24
  5. data/README.git +3 -0
  6. data/README.rdoc +537 -0
  7. data/Rakefile +62 -46
  8. data/Rakefile.cross +397 -0
  9. data/doap.rdf +3 -3
  10. data/doap.rdf.erb +87 -0
  11. data/examples/WhatAQuietStiff.rb +356 -0
  12. data/examples/canvasdemo.rb +88 -0
  13. data/examples/gdchart.rb +76 -0
  14. data/examples/gembrowser.rb +289 -0
  15. data/examples/rmagick.rb +44 -0
  16. data/lib/1.8/fox16.so +0 -0
  17. data/lib/1.9/fox16.so +0 -0
  18. data/lib/fox16/canvas.rb +606 -0
  19. data/lib/fox16/irb.rb +1 -0
  20. data/lib/fox16/splashscreen.rb +1 -0
  21. data/lib/fox16/tkcompat.rb +56 -0
  22. data/lib/fox16/version.rb +1 -1
  23. data/rdoc-sources/FX4Splitter.rb +44 -44
  24. data/rdoc-sources/FX7Segment.rb +3 -3
  25. data/rdoc-sources/FXAccelTable.rb +1 -1
  26. data/rdoc-sources/FXApp.rb +51 -51
  27. data/rdoc-sources/FXArrowButton.rb +6 -6
  28. data/rdoc-sources/FXBMPIcon.rb +12 -12
  29. data/rdoc-sources/FXBMPImage.rb +6 -6
  30. data/rdoc-sources/FXBitmap.rb +9 -9
  31. data/rdoc-sources/FXBitmapFrame.rb +3 -3
  32. data/rdoc-sources/FXBitmapView.rb +12 -12
  33. data/rdoc-sources/FXButton.rb +5 -5
  34. data/rdoc-sources/FXCanvas.rb +4 -4
  35. data/rdoc-sources/FXCheckButton.rb +7 -7
  36. data/rdoc-sources/FXChoiceBox.rb +16 -16
  37. data/rdoc-sources/FXColorBar.rb +9 -9
  38. data/rdoc-sources/FXColorDialog.rb +4 -4
  39. data/rdoc-sources/FXColorList.rb +1 -1
  40. data/rdoc-sources/FXColorRing.rb +4 -4
  41. data/rdoc-sources/FXColorSelector.rb +38 -38
  42. data/rdoc-sources/FXColorWell.rb +15 -15
  43. data/rdoc-sources/FXColorWheel.rb +8 -8
  44. data/rdoc-sources/FXComboBox.rb +24 -24
  45. data/rdoc-sources/FXCursor.rb +12 -12
  46. data/rdoc-sources/FXDC.rb +176 -176
  47. data/rdoc-sources/FXDCPrint.rb +20 -20
  48. data/rdoc-sources/FXDCWindow.rb +2 -2
  49. data/rdoc-sources/FXDataTarget.rb +1 -1
  50. data/rdoc-sources/FXDebugTarget.rb +1 -1
  51. data/rdoc-sources/FXDelegator.rb +2 -2
  52. data/rdoc-sources/FXDial.rb +9 -9
  53. data/rdoc-sources/FXDialogBox.rb +3 -3
  54. data/rdoc-sources/FXDict.rb +2 -3
  55. data/rdoc-sources/FXDirBox.rb +2 -2
  56. data/rdoc-sources/FXDirList.rb +14 -14
  57. data/rdoc-sources/FXDirSelector.rb +14 -14
  58. data/rdoc-sources/FXDockBar.rb +35 -35
  59. data/rdoc-sources/FXDockHandler.rb +2 -2
  60. data/rdoc-sources/FXDockSite.rb +11 -11
  61. data/rdoc-sources/FXDockTitle.rb +2 -2
  62. data/rdoc-sources/FXDocument.rb +2 -2
  63. data/rdoc-sources/FXDragCorner.rb +2 -2
  64. data/rdoc-sources/FXDrawable.rb +5 -5
  65. data/rdoc-sources/FXDriveBox.rb +3 -3
  66. data/rdoc-sources/FXFileDialog.rb +24 -24
  67. data/rdoc-sources/FXFileDict.rb +11 -11
  68. data/rdoc-sources/FXFileList.rb +25 -25
  69. data/rdoc-sources/FXFileSelector.rb +31 -31
  70. data/rdoc-sources/FXFileStream.rb +3 -3
  71. data/rdoc-sources/FXFoldingList.rb +76 -76
  72. data/rdoc-sources/FXFont.rb +133 -133
  73. data/rdoc-sources/FXFontDialog.rb +1 -1
  74. data/rdoc-sources/FXFontSelector.rb +14 -14
  75. data/rdoc-sources/FXFrame.rb +5 -5
  76. data/rdoc-sources/FXGIFCursor.rb +6 -6
  77. data/rdoc-sources/FXGIFIcon.rb +6 -6
  78. data/rdoc-sources/FXGIFImage.rb +5 -5
  79. data/rdoc-sources/FXGLContext.rb +1 -1
  80. data/rdoc-sources/FXGLObject.rb +8 -8
  81. data/rdoc-sources/FXGLShape.rb +23 -23
  82. data/rdoc-sources/FXGLViewer.rb +51 -51
  83. data/rdoc-sources/FXGLVisual.rb +1 -0
  84. data/rdoc-sources/FXGradientBar.rb +31 -31
  85. data/rdoc-sources/FXGroupBox.rb +6 -6
  86. data/rdoc-sources/FXHeader.rb +30 -33
  87. data/rdoc-sources/FXHorizontalFrame.rb +12 -12
  88. data/rdoc-sources/FXICOIcon.rb +14 -14
  89. data/rdoc-sources/FXICOImage.rb +5 -5
  90. data/rdoc-sources/FXIcon.rb +7 -7
  91. data/rdoc-sources/FXIconDict.rb +1 -0
  92. data/rdoc-sources/FXIconList.rb +60 -60
  93. data/rdoc-sources/FXId.rb +1 -1
  94. data/rdoc-sources/FXImage.rb +49 -49
  95. data/rdoc-sources/FXImageFrame.rb +12 -12
  96. data/rdoc-sources/FXImageView.rb +10 -10
  97. data/rdoc-sources/FXInputDialog.rb +4 -4
  98. data/rdoc-sources/FXJPGIcon.rb +13 -13
  99. data/rdoc-sources/FXJPGImage.rb +5 -5
  100. data/rdoc-sources/FXKnob.rb +12 -12
  101. data/rdoc-sources/FXLabel.rb +3 -3
  102. data/rdoc-sources/FXList.rb +31 -31
  103. data/rdoc-sources/FXListBox.rb +7 -7
  104. data/rdoc-sources/FXMDIChild.rb +24 -24
  105. data/rdoc-sources/FXMDIClient.rb +1 -1
  106. data/rdoc-sources/FXMatrix.rb +2 -2
  107. data/rdoc-sources/FXMemoryBuffer.rb +1 -1
  108. data/rdoc-sources/FXMemoryStream.rb +1 -1
  109. data/rdoc-sources/FXMenuButton.rb +20 -19
  110. data/rdoc-sources/FXMenuCaption.rb +9 -9
  111. data/rdoc-sources/FXMenuCascade.rb +1 -1
  112. data/rdoc-sources/FXMenuCheck.rb +2 -2
  113. data/rdoc-sources/FXMenuCommand.rb +1 -1
  114. data/rdoc-sources/FXMenuRadio.rb +2 -2
  115. data/rdoc-sources/FXMenuSeparator.rb +2 -2
  116. data/rdoc-sources/FXMenuTitle.rb +5 -5
  117. data/rdoc-sources/FXMessageBox.rb +16 -16
  118. data/rdoc-sources/FXOptionMenu.rb +14 -14
  119. data/rdoc-sources/FXPCXIcon.rb +12 -12
  120. data/rdoc-sources/FXPCXImage.rb +5 -5
  121. data/rdoc-sources/FXPNGIcon.rb +12 -12
  122. data/rdoc-sources/FXPNGImage.rb +5 -5
  123. data/rdoc-sources/FXPPMIcon.rb +6 -6
  124. data/rdoc-sources/FXPPMImage.rb +5 -5
  125. data/rdoc-sources/FXPacker.rb +4 -4
  126. data/rdoc-sources/FXPopup.rb +5 -5
  127. data/rdoc-sources/FXPrintDialog.rb +21 -21
  128. data/rdoc-sources/FXProgressBar.rb +10 -10
  129. data/rdoc-sources/FXProgressDialog.rb +3 -3
  130. data/rdoc-sources/FXQuatd.rb +19 -19
  131. data/rdoc-sources/FXQuatf.rb +23 -23
  132. data/rdoc-sources/FXRGBIcon.rb +13 -13
  133. data/rdoc-sources/FXRGBImage.rb +5 -5
  134. data/rdoc-sources/FXRadioButton.rb +10 -10
  135. data/rdoc-sources/FXRanged.rb +2 -2
  136. data/rdoc-sources/FXRangef.rb +2 -2
  137. data/rdoc-sources/FXRealSlider.rb +33 -33
  138. data/rdoc-sources/FXRealSpinner.rb +31 -31
  139. data/rdoc-sources/FXRecentFiles.rb +14 -14
  140. data/rdoc-sources/FXRectangle.rb +22 -22
  141. data/rdoc-sources/FXRegistry.rb +3 -3
  142. data/rdoc-sources/FXReplaceDialog.rb +20 -20
  143. data/rdoc-sources/FXRootWindow.rb +2 -2
  144. data/rdoc-sources/FXRuler.rb +28 -28
  145. data/rdoc-sources/FXRulerView.rb +5 -5
  146. data/rdoc-sources/FXScrollArea.rb +27 -27
  147. data/rdoc-sources/FXScrollBar.rb +26 -26
  148. data/rdoc-sources/FXScrollPane.rb +3 -3
  149. data/rdoc-sources/FXScrollWindow.rb +6 -6
  150. data/rdoc-sources/FXSearchDialog.rb +8 -8
  151. data/rdoc-sources/FXSeparator.rb +24 -24
  152. data/rdoc-sources/FXSettings.rb +44 -44
  153. data/rdoc-sources/FXShutter.rb +35 -35
  154. data/rdoc-sources/FXSize.rb +14 -14
  155. data/rdoc-sources/FXSlider.rb +33 -33
  156. data/rdoc-sources/FXSphered.rb +2 -2
  157. data/rdoc-sources/FXSpheref.rb +2 -2
  158. data/rdoc-sources/FXSpinner.rb +30 -30
  159. data/rdoc-sources/FXSplashWindow.rb +5 -5
  160. data/rdoc-sources/FXSplitter.rb +18 -18
  161. data/rdoc-sources/FXSpring.rb +15 -15
  162. data/rdoc-sources/FXStatusBar.rb +14 -14
  163. data/rdoc-sources/FXStatusLine.rb +7 -7
  164. data/rdoc-sources/FXStream.rb +20 -20
  165. data/rdoc-sources/FXSwitcher.rb +23 -23
  166. data/rdoc-sources/FXTGAIcon.rb +12 -12
  167. data/rdoc-sources/FXTGAImage.rb +5 -5
  168. data/rdoc-sources/FXTIFIcon.rb +13 -13
  169. data/rdoc-sources/FXTIFImage.rb +5 -5
  170. data/rdoc-sources/FXTabBar.rb +31 -31
  171. data/rdoc-sources/FXTabBook.rb +13 -13
  172. data/rdoc-sources/FXTabItem.rb +22 -22
  173. data/rdoc-sources/FXTable.rb +148 -148
  174. data/rdoc-sources/FXText.rb +91 -91
  175. data/rdoc-sources/FXTextField.rb +39 -39
  176. data/rdoc-sources/FXToggleButton.rb +32 -32
  177. data/rdoc-sources/FXToolBar.rb +25 -25
  178. data/rdoc-sources/FXToolBarGrip.rb +12 -12
  179. data/rdoc-sources/FXToolBarShell.rb +13 -13
  180. data/rdoc-sources/FXToolBarTab.rb +16 -16
  181. data/rdoc-sources/FXTopWindow.rb +18 -18
  182. data/rdoc-sources/FXTranslator.rb +1 -1
  183. data/rdoc-sources/FXTreeList.rb +66 -66
  184. data/rdoc-sources/FXTreeListBox.rb +20 -20
  185. data/rdoc-sources/FXTriStateButton.rb +23 -23
  186. data/rdoc-sources/FXVec2d.rb +1 -1
  187. data/rdoc-sources/FXVec2f.rb +1 -1
  188. data/rdoc-sources/FXVec3d.rb +1 -1
  189. data/rdoc-sources/FXVec3f.rb +1 -1
  190. data/rdoc-sources/FXVec4d.rb +1 -1
  191. data/rdoc-sources/FXVec4f.rb +1 -1
  192. data/rdoc-sources/FXVerticalFrame.rb +12 -12
  193. data/rdoc-sources/FXVisual.rb +19 -19
  194. data/rdoc-sources/FXWindow.rb +96 -96
  195. data/rdoc-sources/FXWizard.rb +9 -9
  196. data/rdoc-sources/FXXBMIcon.rb +7 -7
  197. data/rdoc-sources/FXXBMImage.rb +6 -6
  198. data/rdoc-sources/FXXPMIcon.rb +13 -13
  199. data/rdoc-sources/FXXPMImage.rb +5 -5
  200. data/rdoc-sources/Makefile +3 -3
  201. metadata +44 -31
  202. data/README +0 -39
  203. data/README.txt +0 -483
@@ -0,0 +1,88 @@
1
+ require 'fox16'
2
+ require '../lib/fox16/canvas'
3
+
4
+ include Fox
5
+ include Canvas
6
+
7
+ class CanvasDemo < FXMainWindow
8
+ def initialize(app)
9
+ # Initialize base class first
10
+ super(app, "Canvas Demo", nil, nil, DECOR_ALL, 0, 0, 800, 600)
11
+
12
+ # Menu bar
13
+ menu_bar = FXMenubar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
14
+
15
+ # File menu
16
+ file_menu = FXMenuPane.new(self)
17
+ FXMenuCommand.new(file_menu, "&New...")
18
+ FXMenuCommand.new(file_menu, "&Open...")
19
+ FXMenuCommand.new(file_menu, "&Close")
20
+ FXMenuCommand.new(file_menu, "&Save")
21
+ FXMenuCommand.new(file_menu, "Save &As...")
22
+ FXMenuSeparator.new(file_menu)
23
+ FXMenuCommand.new(file_menu, "&Print...")
24
+ FXMenuCommand.new(file_menu, "Print &Setup...")
25
+ FXMenuCommand.new(file_menu, "Print Pre&view")
26
+ FXMenuSeparator.new(file_menu)
27
+ FXMenuCommand.new(file_menu, "E&xit", nil, app, FXApp::ID_QUIT)
28
+
29
+ # Edit menu
30
+ edit_menu = FXMenuPane.new(self)
31
+ FXMenuCommand.new(edit_menu, "&Undo")
32
+ FXMenuCommand.new(edit_menu, "&Redo")
33
+ FXMenuSeparator.new(edit_menu)
34
+ FXMenuCommand.new(edit_menu, "&Cut")
35
+ FXMenuSeparator.new(edit_menu)
36
+ FXMenuCommand.new(edit_menu, "Change &background color")
37
+ FXMenuCommand.new(edit_menu, "Edit &label")
38
+
39
+ # Recently used files
40
+ @mru_files = FXRecentFiles.new
41
+
42
+ # Help menu
43
+ help_menu = FXMenuPane.new(self)
44
+ aboutBox = FXMenuCommand.new(help_menu, "&About...")
45
+ aboutBox.connect(SEL_COMMAND) do |sender, sel, ptr|
46
+ FXMessageBox.information(self, MBOX_OK, "About Canvas",
47
+ "Canvas Demo\nTo draw a shape, select a shape on the toolbar and left-click on the canvas.\nTo draw a line, right-drag between shapes.")
48
+ end
49
+
50
+ # Attach menus to menu bar titles
51
+ FXMenuTitle.new(menu_bar, "&File", nil, file_menu)
52
+ FXMenuTitle.new(menu_bar, "&Edit", nil, edit_menu)
53
+ FXMenuTitle.new(menu_bar, "&Help", nil, help_menu)
54
+
55
+ # Status bar
56
+ FXStatusbar.new(self,
57
+ LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|STATUSBAR_WITH_DRAGCORNER)
58
+
59
+ # Shapes canvas fills the remainder
60
+ frame = FXHorizontalFrame.new(self,
61
+ LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK,
62
+ 0, 0, 0, 0, 0, 0, 0, 0)
63
+ canvas = ShapeCanvas.new(frame, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y)
64
+ canvas.scene = get_scene(canvas)
65
+ end
66
+
67
+ def get_scene(canvas)
68
+ scene = ShapeGroup.new
69
+ scene.addShape(CircleShape.new(5, 5, 10))
70
+ scene.addShape(CircleShape.new(50, 50, 20))
71
+ scene.addShape(LineShape.new(10, 10, 70, 70))
72
+ scene.addShape(RectangleShape.new(90, 90, 30, 40))
73
+ scene.addShape(TextShape.new(60, 60, 30, 40, "Hello!"))
74
+ scene
75
+ end
76
+
77
+ def create
78
+ super
79
+ show(PLACEMENT_SCREEN)
80
+ end
81
+ end
82
+
83
+ if __FILE__ == $0
84
+ app = FXApp.new("CanvasDemo", "FXRuby")
85
+ CanvasDemo.new(app)
86
+ app.create
87
+ app.run
88
+ end
@@ -0,0 +1,76 @@
1
+ require 'fox16'
2
+ require 'tempfile'
3
+ begin
4
+ require 'GDChart'
5
+ rescue LoadError
6
+ require 'fox16/missingdep'
7
+ MSG = <<EOM
8
+ Sorry, this example depends on the GDChart extension. Please
9
+ check the Ruby Application Archives for an appropriate
10
+ download site.
11
+ EOM
12
+ missingDependency(MSG)
13
+ end
14
+
15
+ include Fox
16
+
17
+ class GDChartViewer < FXMainWindow
18
+ def initialize(app)
19
+ # Invoke base class initialize first
20
+ super(app, "GDChart Viewer", :opts => DECOR_ALL, :width => 850, :height => 600)
21
+
22
+ # Sunken border for image widget
23
+ imagebox = FXHorizontalFrame.new(self,
24
+ FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y)
25
+
26
+ # Make image widget
27
+ @imageview = FXImageView.new(imagebox,
28
+ :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|HSCROLLER_NEVER|VSCROLLER_NEVER)
29
+
30
+ # Construct a PNG image and store it in the image viewer
31
+ @imageview.image = createChart
32
+
33
+ # Resize main window client area to fit image size
34
+ resize(@imageview.contentWidth, @imageview.contentHeight)
35
+ end
36
+
37
+ def createChart
38
+ # Create a simple chart
39
+ GDChart.title = "A Chart"
40
+ GDChart.xtitle = "X-axis"
41
+ GDChart.ytitle = "Y-axis"
42
+ data = [1, 2, 3, 4, 5, 6]
43
+ labels = ["label 1", "label 2", "label 3", "label 4", "label 5", "label 6"]
44
+
45
+ # Write chart data out as GIF to a temporary file
46
+ File.open('gdchart.gif', 'w') do |f|
47
+ GDChart.out_graph(200, 200, f, GDChart::LINE, labels.length, labels, 1, data)
48
+ end
49
+
50
+ # Reopen it and construct image
51
+ img = nil
52
+ File.open('gdchart.gif', 'rb') do |f|
53
+ img = FXGIFIcon.new(getApp(), f.read)
54
+ end
55
+ img
56
+ end
57
+
58
+ def create
59
+ super
60
+ show(PLACEMENT_SCREEN)
61
+ end
62
+ end
63
+
64
+ if __FILE__ == $0
65
+ # Make application
66
+ application = FXApp.new("GDChart Viewer", "FoxTest")
67
+
68
+ # Make window
69
+ window = GDChartViewer.new(application)
70
+
71
+ # Create it
72
+ application.create
73
+
74
+ # Run
75
+ application.run
76
+ end
@@ -0,0 +1,289 @@
1
+ require 'fox16'
2
+
3
+ include Fox
4
+
5
+ class GemBrowser
6
+
7
+ #
8
+ # A reference to the currently selected Gem specification, or +nil+
9
+ # if none is selected.
10
+ #
11
+ attr_accessor :currentSpec
12
+
13
+ def initialize
14
+ @currentSpec = nil
15
+ end
16
+
17
+ #
18
+ # Install the Gem described by the named spec file, and return the
19
+ # Specification for this Gem.
20
+ #
21
+ def install(filename)
22
+ Gem::Installer.new(filename).install
23
+ spec = nil
24
+ cache.each do |n, s|
25
+ spec = s if (File.basename(filename, ".gem") == s.full_name)
26
+ end
27
+ spec
28
+ end
29
+
30
+ #
31
+ # Uninstall the Gem described by this specification.
32
+ #
33
+ def uninstall(spec)
34
+ Gem::Uninstaller.new(spec.name).uninstall
35
+ end
36
+
37
+ # Return an array of the installed specifications.
38
+ def cache
39
+ # Gem.cache
40
+ Gem::Cache.from_installed_gems
41
+ end
42
+ end
43
+
44
+ class GemInfoPanel < FXVerticalFrame
45
+
46
+ attr_reader :browser
47
+
48
+ def initialize(p, b, opts)
49
+ # Initialize base class
50
+ super(p, opts)
51
+
52
+ @browser = b
53
+
54
+ self.backColor = FXRGB(255, 255, 255)
55
+
56
+ File.open(File.join("icons", "gem_big.png"), "rb") do |f|
57
+ @bigIcon = FXPNGIcon.new(getApp(), f.read)
58
+ end
59
+
60
+ nameLabel = FXLabel.new(self, "", @bigIcon, JUSTIFY_LEFT|JUSTIFY_TOP|ICON_BEFORE_TEXT|LAYOUT_FILL_X)
61
+ nameLabel.backColor = FXRGB(255, 255, 255)
62
+ nameLabel.connect(SEL_UPDATE) { |nameLabel, sel, ptr|
63
+ if currentSpec
64
+ nameLabel.text = specDescription(currentSpec)
65
+ nameLabel.show
66
+ else
67
+ nameLabel.text = ""
68
+ nameLabel.hide
69
+ end
70
+ }
71
+
72
+ summaryText = FXText.new(self, nil, 0, TEXT_READONLY|TEXT_WORDWRAP|LAYOUT_FILL_X|LAYOUT_FILL_Y)
73
+ summaryText.backColor = FXRGB(255, 255, 255)
74
+ summaryText.connect(SEL_UPDATE) { |summaryText, sel, ptr|
75
+ theText = currentSpec ? currentSpec.summary : nil
76
+ summaryText.text = theText unless (summaryText.text == theText)
77
+ }
78
+ end
79
+
80
+ #
81
+ # Return a reference to the currently selected Gem specification,
82
+ # or +nil+ if none is selected.
83
+ #
84
+ def currentSpec
85
+ browser.currentSpec
86
+ end
87
+
88
+ # Return a multiline string (suitable for use with an FXLabel) describing this spec.
89
+ def specDescription(spec)
90
+ [spec.name, "version #{spec.version}", spec.author, spec.email, spec.homepage].join("\n")
91
+ end
92
+
93
+ def create
94
+ super
95
+ @bigIcon.create
96
+ end
97
+ end
98
+
99
+ class GemsPanel < FXVerticalFrame
100
+
101
+ attr_reader :browser
102
+
103
+ def initialize(p, br, opts)
104
+ # Initialize base class
105
+ super(p, opts)
106
+
107
+ # Save a reference to the browser
108
+ @browser = br
109
+
110
+ File.open(File.join("icons", "gem_big.png"), "rb") do |f|
111
+ @bigIcon = FXPNGIcon.new(getApp(), f.read)
112
+ end
113
+ File.open(File.join("icons", "gem_small.png"), "rb") do |f|
114
+ @smallIcon = FXPNGIcon.new(getApp(), f.read)
115
+ end
116
+
117
+ @iconList = FXIconList.new(self, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y|ICONLIST_MINI_ICONS|ICONLIST_BROWSESELECT)
118
+ @iconList.connect(SEL_SELECTED) { |sender, sel, ptr|
119
+ browser.currentSpec = itemSpec(ptr)
120
+ }
121
+
122
+ # Fill the list with installed specifications.
123
+ browser.cache.each { |name, spec| appendItem(spec) }
124
+ if numItems > 0
125
+ selectItem(0)
126
+ browser.currentSpec = itemSpec(0)
127
+ end
128
+ end
129
+
130
+ def appendItem(spec)
131
+ @iconList.appendItem(spec.name, @bigIcon, @smallIcon, spec)
132
+ if numItems == 1
133
+ selectItem(0)
134
+ browser.currentSpec = itemSpec(0)
135
+ end
136
+ end
137
+
138
+ def currentItem
139
+ @iconList.currentItem
140
+ end
141
+
142
+ #
143
+ # Return the specification associated with the item at _index_, or
144
+ # +nil+ if no such item.
145
+ #
146
+ def itemSpec(index)
147
+ (index >= 0) ? getItem(index).data : nil
148
+ end
149
+
150
+ def currentItemSpec
151
+ itemSpec(currentItem)
152
+ end
153
+
154
+ def getItem(*args)
155
+ @iconList.getItem(*args)
156
+ end
157
+
158
+ def selectItem(index)
159
+ @iconList.selectItem(index, true)
160
+ end
161
+
162
+ def numItems
163
+ @iconList.numItems
164
+ end
165
+
166
+ def create
167
+ super
168
+ @bigIcon.create
169
+ @smallIcon.create
170
+ self.width = @iconList.font.getTextWidth("MMMMMMMMMMMMM")
171
+ end
172
+ end
173
+
174
+ class GemBrowserWindow < FXMainWindow
175
+
176
+ attr_reader :browser
177
+
178
+ def initialize(anApp)
179
+ # Initialize base class first
180
+ super(anApp, "Gem Browser", nil, nil, DECOR_ALL)
181
+
182
+ # Menu bar
183
+ menubar = FXMenuBar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
184
+
185
+ # File menu
186
+ filemenu = FXMenuPane.new(self)
187
+ FXMenuTitle.new(menubar, "&File", nil, filemenu)
188
+
189
+ installCmd = FXMenuCommand.new(filemenu, "Install a Gem...")
190
+ installCmd.connect(SEL_COMMAND) { install }
191
+
192
+ uninstallCmd = FXMenuCommand.new(filemenu, "Uninstall this Gem")
193
+ uninstallCmd.connect(SEL_COMMAND) { uninstall }
194
+ uninstallCmd.connect(SEL_UPDATE) do |sender, sel, ptr|
195
+ spec = browser.currentSpec
196
+ if spec
197
+ sender.text = "Uninstall #{spec.name}"
198
+ sender.enable
199
+ else
200
+ sender.text = "Uninstall this Gem"
201
+ sender.disable
202
+ end
203
+ end
204
+
205
+ FXMenuCommand.new(filemenu, "&Quit\tCtl-Q").connect(SEL_COMMAND) { quit }
206
+
207
+ # Main window interior
208
+ contents = FXVerticalFrame.new(self, LAYOUT_FILL_X|LAYOUT_FILL_Y)
209
+
210
+ @browser = GemBrowser.new
211
+
212
+ # Horizontal splitter with info pane on the left, icon list on the right
213
+ @splitter = FXSplitter.new(contents, LAYOUT_FILL_X|LAYOUT_FILL_Y|SPLITTER_HORIZONTAL|SPLITTER_REVERSED) do |splitter|
214
+ infoPanel = GemInfoPanel.new(splitter, @browser, LAYOUT_FILL_X|LAYOUT_FILL_X|FRAME_SUNKEN|FRAME_THICK)
215
+ @gemsPanel = GemsPanel.new(splitter, @browser, LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK)
216
+ end
217
+
218
+ # Catch these too
219
+ self.connect(SEL_CLOSE) { quit }
220
+ anApp.addSignal("SIGINT") { quit }
221
+ end
222
+
223
+ def install
224
+ FXFileDialog.new(self, "Install Gem") { |dlg|
225
+ dlg.directory = @directory unless @directory.empty?
226
+ dlg.patternList = ["Gem Files (*.gem)", "All Files (*)"]
227
+ if dlg.execute != 0
228
+ @directory = dlg.directory
229
+ begin
230
+ spec = browser.install(dlg.filename)
231
+ @gemsPanel.appendItem(spec)
232
+ rescue => ex
233
+ FXMessageBox.error(self, MBOX_OK, "Installation Failed", ex.to_s)
234
+ end
235
+ end
236
+ }
237
+ end
238
+
239
+ def uninstall
240
+ begin
241
+ browser.uninstall(browser.currentSpec)
242
+ rescue => ex
243
+ FXMessageBox.error(self, MBOX_OK, "Uninstall Failed", ex.to_s)
244
+ end
245
+ end
246
+
247
+ def quit
248
+ getApp().reg().writeIntEntry("SETTINGS", "x", x)
249
+ getApp().reg().writeIntEntry("SETTINGS", "y", y)
250
+ getApp().reg().writeIntEntry("SETTINGS", "width", width)
251
+ getApp().reg().writeIntEntry("SETTINGS", "height", height)
252
+ getApp().reg().writeIntEntry("SETTINGS", "listWidth", @splitter.first.next.width)
253
+ getApp().reg().writeStringEntry("SETTINGS", "directory", @directory) if @directory
254
+ getApp().exit(0)
255
+ end
256
+
257
+ def create
258
+ # Do base class create
259
+ super
260
+
261
+ # Get size, etc. from registry
262
+ xx = getApp().reg().readIntEntry("SETTINGS", "x", 0)
263
+ yy = getApp().reg().readIntEntry("SETTINGS", "y", 0)
264
+ ww = getApp().reg().readIntEntry("SETTINGS", "width", 450)
265
+ hh = getApp().reg().readIntEntry("SETTINGS", "height", 300)
266
+ position(xx, yy, ww, hh)
267
+
268
+ # Splitter child sizes
269
+ rightPaneSize = getApp().reg().readIntEntry("SETTINGS", "listWidth", -1)
270
+ if rightPaneSize >= 0
271
+ @splitter.first.next.width = rightPaneSize
272
+ end
273
+
274
+ # Last directory for Gem files
275
+ @directory = getApp().reg().readStringEntry("SETTINGS", "directory", "")
276
+
277
+ # Show it
278
+ show
279
+ end
280
+ end
281
+
282
+ if __FILE__ == $0
283
+ FXApp.new("GemBrowser", "FXRuby") do |theApp|
284
+ GemBrowserWindow.new(theApp)
285
+ theApp.create
286
+ theApp.run
287
+ end
288
+ end
289
+