summaryrefslogtreecommitdiffstats
path: root/qtruby/rubylib/examples/qt-examples/chart
diff options
context:
space:
mode:
Diffstat (limited to 'qtruby/rubylib/examples/qt-examples/chart')
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/README8
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/canvastext.rb16
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/canvasview.rb53
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/chartform.rb488
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/chartform_canvas.rb212
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/chartform_files.rb102
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/element.rb161
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/chart-forms.sk256
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/file_new.xpm36
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/file_open.xpm33
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/file_print.xpm115
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/file_save.xpm33
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/file_saveaspostscript.xpm34
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/options_horizontalbarchart.xpm31
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/options_piechart.xpm30
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/options_setdata.xpm34
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/options_setfont.xpm27
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/options_setoptions.xpm32
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/options_verticalbarchart.xpm31
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/pattern01.xpm27
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/pattern02.xpm28
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/pattern03.xpm28
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/pattern04.xpm28
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/pattern05.xpm28
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/pattern06.xpm28
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/pattern07.xpm28
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/pattern08.xpm28
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/pattern09.xpm28
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/pattern10.xpm28
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/pattern11.xpm28
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/pattern12.xpm28
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/pattern13.xpm28
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/images/pattern14.xpm28
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/main.rb26
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/optionsform.rb127
-rw-r--r--qtruby/rubylib/examples/qt-examples/chart/setdataform.rb184
36 files changed, 2460 insertions, 0 deletions
diff --git a/qtruby/rubylib/examples/qt-examples/chart/README b/qtruby/rubylib/examples/qt-examples/chart/README
new file mode 100644
index 00000000..921437c5
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/README
@@ -0,0 +1,8 @@
+
+A Complete Canvas Application
+
+This is a complete example program with a main window, menus and
+toolbars. The main widget is a Qt::Canvas, and this example
+demonstrates basic canvas usage.
+
+This example is the subject of Qt Tutorial #2
diff --git a/qtruby/rubylib/examples/qt-examples/chart/canvastext.rb b/qtruby/rubylib/examples/qt-examples/chart/canvastext.rb
new file mode 100644
index 00000000..8a298faa
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/canvastext.rb
@@ -0,0 +1,16 @@
+
+class CanvasText < Qt::CanvasText
+
+ CANVAS_TEXT = 1100
+ attr :index
+
+ def initialize(index, *k)
+ super(*k)
+ @index = index
+ end
+
+ def rtti() return CANVAS_TEXT end
+
+end
+
+
diff --git a/qtruby/rubylib/examples/qt-examples/chart/canvasview.rb b/qtruby/rubylib/examples/qt-examples/chart/canvasview.rb
new file mode 100644
index 00000000..416b0de7
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/canvasview.rb
@@ -0,0 +1,53 @@
+class CanvasView < Qt::CanvasView
+
+ def initialize(canvas, elements, parent = nil, name = "canvas view", f = 0)
+ super(canvas, parent, name, f)
+ @elements = elements
+ @movingItem = nil
+ end
+
+ def contentsContextMenuEvent( e )
+ parent().optionsMenu.exec( Qt::Cursor.pos() )
+ end
+
+
+ def viewportResizeEvent( e )
+ canvas().resize( e.size().width(), e.size().height() )
+ parent().drawElements()
+ end
+
+
+ def contentsMousePressEvent( e )
+ list = canvas().collisions( e.pos() )
+ list.each do |it|
+ if it.rtti() == CanvasText::CANVAS_TEXT
+ @movingItem = it
+ @pos = e.pos()
+ return
+ end
+ end
+ @movingItem = nil
+ end
+
+
+ def contentsMouseMoveEvent( e )
+ if @movingItem
+ offset = e.pos() - @pos
+ @movingItem.moveBy( offset.x(), offset.y() )
+ @pos = e.pos()
+ form = parent()
+ form.changed = true
+ chartType = form.chartType()
+ item = @movingItem
+ i = item.index()
+
+ @elements[i].setProX( chartType, item.x() / canvas().width() )
+ @elements[i].setProY( chartType, item.y() / canvas().height() )
+
+ canvas().update()
+ end
+ end
+
+end
+
+
diff --git a/qtruby/rubylib/examples/qt-examples/chart/chartform.rb b/qtruby/rubylib/examples/qt-examples/chart/chartform.rb
new file mode 100644
index 00000000..a649ce12
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/chartform.rb
@@ -0,0 +1,488 @@
+class ChartForm < Qt::MainWindow
+
+ slots 'fileNew()',
+ 'fileOpen()',
+ 'fileOpenRecent( int )',
+ 'fileSave()',
+ 'fileSaveAs()',
+ 'fileSaveAsPixmap()',
+ 'filePrint()',
+ 'fileQuit()',
+ 'optionsSetData()',
+ 'updateChartType( QAction * )',
+ 'optionsSetFont()',
+ 'optionsSetOptions()',
+ 'helpHelp()',
+ 'helpAbout()',
+ 'helpAboutQt()',
+ 'saveOptions()'
+
+ attr_accessor :changed
+ attr_reader :chartType, :optionsMenu
+
+ MAX_ELEMENTS = 100
+ MAX_RECENTFILES = 9 # Must not exceed 9
+
+ PIE = 0
+ VERTICAL_BAR = 1
+ HORIZONTAL_BAR = 2
+
+ NO = 0
+ YES = 1
+ AS_PERCENTAGE = 2
+
+ WINDOWS_REGISTRY = "/Trolltech/QtExamples"
+ APP_KEY = "/Chart/"
+
+ def initialize( filename )
+ super( nil, nil, WDestructiveClose )
+ @filename = filename
+ setIcon( Qt::Pixmap.new( "images/options_piechart.xpm" ) )
+
+ fileNewAction = Qt::Action.new(
+ "New Chart", Qt::IconSet.new(Qt::Pixmap.new( "images/file_new.xpm" )),
+ "&New", Qt::KeySequence.new(CTRL+Key_N), self, "new" )
+ connect( fileNewAction, SIGNAL( 'activated()' ), self, SLOT( 'fileNew()' ) )
+
+ fileOpenAction = Qt::Action.new(
+ "Open Chart", Qt::IconSet.new(Qt::Pixmap.new( "images/file_open.xpm" )),
+ "&Open...", Qt::KeySequence.new(CTRL+Key_O), self, "open" )
+ connect( fileOpenAction, SIGNAL( 'activated()' ), self, SLOT( 'fileOpen()' ) )
+
+ fileSaveAction = Qt::Action.new(
+ "Save Chart", Qt::IconSet.new(Qt::Pixmap.new( "images/file_save.xpm" )),
+ "&Save", Qt::KeySequence.new(CTRL+Key_S), self, "save" )
+ connect( fileSaveAction, SIGNAL( 'activated()' ), self, SLOT( 'fileSave()' ) )
+
+ fileSaveAsAction = Qt::Action.new(
+ "Save Chart As", Qt::IconSet.new(Qt::Pixmap.new( "images/file_save.xpm" )),
+ "Save &As...", Qt::KeySequence.new(0), self, "save as" )
+ connect( fileSaveAsAction, SIGNAL( 'activated()' ),
+ self, SLOT( 'fileSaveAs()' ) )
+
+ fileSaveAsPixmapAction = Qt::Action.new(
+ "Save Chart As Bitmap", Qt::IconSet.new(Qt::Pixmap.new( "images/file_save.xpm" )),
+ "Save As &Bitmap...", Qt::KeySequence.new(CTRL+Key_B), self, "save as bitmap" )
+ connect( fileSaveAsPixmapAction, SIGNAL( 'activated()' ),
+ self, SLOT( 'fileSaveAsPixmap()' ) )
+
+ filePrintAction = Qt::Action.new(
+ "Print Chart", Qt::IconSet.new(Qt::Pixmap.new( "images/file_print.xpm" )),
+ "&Print Chart...", Qt::KeySequence.new(CTRL+Key_P), self, "print chart" )
+ connect( filePrintAction, SIGNAL( 'activated()' ),
+ self, SLOT( 'filePrint()' ) )
+
+ optionsSetDataAction = Qt::Action.new(
+ "Set Data", Qt::IconSet.new(Qt::Pixmap.new( "images/options_setdata.xpm" )),
+ "Set &Data...", Qt::KeySequence.new(CTRL+Key_D), self, "set data" )
+ connect( optionsSetDataAction, SIGNAL( 'activated()' ),
+ self, SLOT( 'optionsSetData()' ) )
+
+
+ chartGroup = Qt::ActionGroup.new( self ) # Connected later
+ chartGroup.setExclusive( true )
+
+ @optionsPieChartAction = Qt::Action.new(
+ "Pie Chart", Qt::IconSet.new(Qt::Pixmap.new( "images/options_piechart.xpm" )),
+ "&Pie Chart", Qt::KeySequence.new(CTRL+Key_I), chartGroup, "pie chart" )
+ @optionsPieChartAction.setToggleAction( true )
+
+ @optionsHorizontalBarChartAction = Qt::Action.new(
+ "Horizontal Bar Chart", Qt::IconSet.new(Qt::Pixmap.new( "images/options_horizontalbarchart.xpm" )),
+ "&Horizontal Bar Chart", Qt::KeySequence.new(CTRL+Key_H), chartGroup,
+ "horizontal bar chart" )
+ @optionsHorizontalBarChartAction.setToggleAction( true )
+
+ @optionsVerticalBarChartAction = Qt::Action.new(
+ "Vertical Bar Chart", Qt::IconSet.new(Qt::Pixmap.new( "images/options_verticalbarchart.xpm" )),
+ "&Vertical Bar Chart", Qt::KeySequence.new(CTRL+Key_V), chartGroup, "Vertical bar chart" )
+ @optionsVerticalBarChartAction.setToggleAction( true )
+
+
+ optionsSetFontAction = Qt::Action.new(
+ "Set Font", Qt::IconSet.new(Qt::Pixmap.new( "images/options_setfont.xpm" )),
+ "Set &Font...", Qt::KeySequence.new(CTRL+Key_F), self, "set font" )
+ connect( optionsSetFontAction, SIGNAL( 'activated()' ),
+ self, SLOT( 'optionsSetFont()' ) )
+
+ optionsSetOptionsAction = Qt::Action.new(
+ "Set Options", Qt::IconSet.new(Qt::Pixmap.new( "images/options_setoptions.xpm" )),
+ "Set &Options...", Qt::KeySequence.new(0), self, "set options" )
+ connect( optionsSetOptionsAction, SIGNAL( 'activated()' ),
+ self, SLOT( 'optionsSetOptions()' ) )
+
+ fileQuitAction = Qt::Action.new( "Quit", "&Quit", Qt::KeySequence.new(CTRL+Key_Q), self, "quit" )
+ connect( fileQuitAction, SIGNAL( 'activated()' ), self, SLOT( 'fileQuit()' ) )
+
+
+ fileTools = Qt::ToolBar.new( self, "file operations" )
+ fileTools.setLabel( "File Operations" )
+ fileNewAction.addTo( fileTools )
+ fileOpenAction.addTo( fileTools )
+ fileSaveAction.addTo( fileTools )
+ fileTools.addSeparator()
+ filePrintAction.addTo( fileTools )
+
+ optionsTools = Qt::ToolBar.new( self, "options operations" )
+ optionsTools.setLabel( "Options Operations" )
+ optionsSetDataAction.addTo( optionsTools )
+ optionsTools.addSeparator()
+ @optionsPieChartAction.addTo( optionsTools )
+ @optionsHorizontalBarChartAction.addTo( optionsTools )
+ @optionsVerticalBarChartAction.addTo( optionsTools )
+ optionsTools.addSeparator()
+ optionsSetFontAction.addTo( optionsTools )
+ optionsTools.addSeparator()
+ optionsSetOptionsAction.addTo( optionsTools )
+
+ @fileMenu = Qt::PopupMenu.new( self )
+ menuBar().insertItem( "&File", @fileMenu )
+ fileNewAction.addTo( @fileMenu )
+ fileOpenAction.addTo( @fileMenu )
+ fileSaveAction.addTo( @fileMenu )
+ fileSaveAsAction.addTo( @fileMenu )
+ @fileMenu.insertSeparator()
+ fileSaveAsPixmapAction.addTo( @fileMenu )
+ @fileMenu.insertSeparator()
+ filePrintAction.addTo( @fileMenu )
+ @fileMenu.insertSeparator()
+ fileQuitAction.addTo( @fileMenu )
+
+ @optionsMenu = Qt::PopupMenu.new( self )
+ menuBar().insertItem( "&Options", @optionsMenu )
+ optionsSetDataAction.addTo( @optionsMenu )
+ @optionsMenu.insertSeparator()
+ @optionsPieChartAction.addTo( @optionsMenu )
+ @optionsHorizontalBarChartAction.addTo( @optionsMenu )
+ @optionsVerticalBarChartAction.addTo( @optionsMenu )
+ @optionsMenu.insertSeparator()
+ optionsSetFontAction.addTo( @optionsMenu )
+ @optionsMenu.insertSeparator()
+ optionsSetOptionsAction.addTo( @optionsMenu )
+
+ menuBar().insertSeparator()
+
+ helpMenu = Qt::PopupMenu.new( self )
+ menuBar().insertItem( "&Help", helpMenu )
+ helpMenu.insertItem( "&Help", self, SLOT('helpHelp()'), Qt::KeySequence.new(Key_F1) )
+ helpMenu.insertItem( "&About", self, SLOT('helpAbout()') )
+ helpMenu.insertItem( "About &Qt", self, SLOT('helpAboutQt()') )
+
+
+ @printer = nil
+ @elements = Array.new(MAX_ELEMENTS)
+
+ settings = Qt::Settings.new
+ settings.insertSearchPath( Qt::Settings::Windows, WINDOWS_REGISTRY )
+ windowWidth = settings.readNumEntry( APP_KEY + "WindowWidth", 460 )
+ windowHeight = settings.readNumEntry( APP_KEY + "WindowHeight", 530 )
+ windowX = settings.readNumEntry( APP_KEY + "WindowX", -1 )
+ windowY = settings.readNumEntry( APP_KEY + "WindowY", -1 )
+ setChartType( settings.readNumEntry( APP_KEY + "ChartType", PIE ) )
+ @addValues = settings.readNumEntry( APP_KEY + "AddValues", NO )
+ @decimalPlaces = settings.readNumEntry( APP_KEY + "Decimals", 2 )
+ @font = Qt::Font.new( "Helvetica", 18, Qt::Font::Bold )
+ @font.fromString(
+ settings.readEntry( APP_KEY + "Font", @font.toString() ) )
+ @recentFiles = []
+ for i in 0...MAX_RECENTFILES
+ filename = settings.readEntry( APP_KEY + "File" + ( i + 1 ).to_s )
+ if !filename.nil?
+ @recentFiles.push( filename )
+ end
+ end
+ if @recentFiles.length() > 0
+ updateRecentFilesMenu()
+ end
+
+
+ # Connect *after* we've set the chart type on so we don't call
+ # drawElements() prematurely.
+ connect( chartGroup, SIGNAL( 'selected(QAction*)' ),
+ self, SLOT( 'updateChartType(QAction*)' ) )
+
+ resize( windowWidth, windowHeight )
+ if windowX != -1 || windowY != -1
+ move( windowX, windowY )
+ end
+
+ @canvas = Qt::Canvas.new( self )
+ @canvas.resize( width(), height() )
+ @canvasView = CanvasView.new( @canvas, @elements, self )
+ setCentralWidget( @canvasView )
+ @canvasView.show()
+
+ if ! @filename.nil?
+ load( @filename )
+ else
+ init()
+ @elements[0].set( 20, red, 14, "Red" )
+ @elements[1].set( 70, cyan, 2, "Cyan", darkGreen )
+ @elements[2].set( 35, blue, 11, "Blue" )
+ @elements[3].set( 55, yellow, 1, "Yellow", darkBlue )
+ @elements[4].set( 80, magenta, 1, "Magenta" )
+ drawElements()
+ end
+
+ statusBar().message( "Ready", 2000 )
+ end
+
+
+
+ def init()
+ setCaption( "Chart" )
+ @filename = nil
+ @changed = false
+
+ @elements[0] = Element.new( Element::INVALID, red )
+ @elements[1] = Element.new( Element::INVALID, cyan )
+ @elements[2] = Element.new( Element::INVALID, blue )
+ @elements[3] = Element.new( Element::INVALID, yellow )
+ @elements[4] = Element.new( Element::INVALID, green )
+ @elements[5] = Element.new( Element::INVALID, magenta )
+ @elements[6] = Element.new( Element::INVALID, darkYellow )
+ @elements[7] = Element.new( Element::INVALID, darkRed )
+ @elements[8] = Element.new( Element::INVALID, darkCyan )
+ @elements[9] = Element.new( Element::INVALID, darkGreen )
+ @elements[10] = Element.new( Element::INVALID, darkMagenta )
+ @elements[11] = Element.new( Element::INVALID, darkBlue )
+ for i in 12...MAX_ELEMENTS
+ x = (i.to_f / MAX_ELEMENTS) * 360
+ y = ((x * 256) % 105) + 151
+ z = ((i * 17) % 105) + 151;
+ @elements[i] = Element.new( Element::INVALID, Qt::Color.new( x, y, z, Qt::Color::Hsv ) )
+ end
+ end
+
+ def closeEvent( e )
+ fileQuit()
+ end
+
+
+ def fileNew()
+ if okToClear()
+ init()
+ drawElements()
+ end
+ end
+
+
+ def fileOpen()
+ if !okToClear()
+ return
+ end
+
+ filename = Qt::FileDialog.getOpenFileName(
+ nil, "Charts (*.cht)", self,
+ "file open", "Chart -- File Open" )
+ if !filename.nil?
+ load( filename )
+ else
+ statusBar().message( "File Open abandoned", 2000 )
+ end
+ end
+
+
+ def fileSaveAs()
+ filename = Qt::FileDialog.getSaveFileName(
+ nil, "Charts (*.cht)", self,
+ "file save as", "Chart -- File Save As" )
+ if !filename.nil?
+ answer = 0
+ if Qt::File.exists( filename )
+ answer = Qt::MessageBox.warning(
+ self, "Chart -- Overwrite File",
+ "Overwrite\n\'#{filename}\'?",
+ "&Yes", "&No", nil, 1, 1 )
+ end
+ if answer == 0
+ @filename = filename
+ updateRecentFiles( filename )
+ fileSave()
+ return
+ end
+ end
+ statusBar().message( "Saving abandoned", 2000 )
+ end
+
+
+ def fileOpenRecent( index )
+ if !okToClear()
+ return
+ end
+
+ load( @recentFiles[index] )
+ end
+
+
+ def updateRecentFiles( filename )
+ if @recentFiles.include?( filename )
+ return
+ end
+
+ @recentFiles.push( filename )
+ if @recentFiles.length() > MAX_RECENTFILES
+ @recentFiles.shift()
+ end
+
+ updateRecentFilesMenu()
+ end
+
+
+ def updateRecentFilesMenu()
+ for i in 0...MAX_RECENTFILES
+ if @fileMenu.findItem( i )
+ @fileMenu.removeItem( i )
+ end
+ if i < @recentFiles.length()
+ @fileMenu.insertItem( "&%d %s" % [i + 1, @recentFiles[i]],
+ self, SLOT( 'fileOpenRecent(int)' ),
+ Qt::KeySequence.new(0), i )
+ end
+ end
+ end
+
+
+ def fileQuit()
+ if okToClear()
+ saveOptions()
+ $qApp.exit( 0 )
+ end
+ end
+
+
+ def okToClear()
+ if @changed
+ if @filename.nil?
+ msg = "Unnamed chart "
+ else
+ msg = "Chart '#{@filename}'\n"
+ end
+ msg += "has been changed."
+
+ x = Qt::MessageBox.information( self, "Chart -- Unsaved Changes",
+ msg, "&Save", "Cancel", "&Abandon",
+ 0, 1 )
+ case x
+ when 0 # Save
+ fileSave()
+ when 1 # Cancel
+ when 2 # Abandon
+ else
+ return false
+ end
+ end
+ return true
+ end
+
+
+ def saveOptions()
+ settings = Qt::Settings.new
+ settings.insertSearchPath( Qt::Settings::Windows, WINDOWS_REGISTRY )
+ settings.writeEntry( APP_KEY + "WindowWidth", width() )
+ settings.writeEntry( APP_KEY + "WindowHeight", height() )
+ settings.writeEntry( APP_KEY + "WindowX", x() )
+ settings.writeEntry( APP_KEY + "WindowY", y() )
+ settings.writeEntry( APP_KEY + "ChartType", @chartType )
+ settings.writeEntry( APP_KEY + "AddValues", @addValues )
+ settings.writeEntry( APP_KEY + "Decimals", @decimalPlaces )
+ settings.writeEntry( APP_KEY + "Font", @font.toString() )
+ for i in 0...@recentFiles.length
+ settings.writeEntry( APP_KEY + "File" + ( i + 1 ).to_s,
+ @recentFiles[i] )
+ end
+ end
+
+
+ def optionsSetData()
+ setDataForm = SetDataForm.new( @elements, @decimalPlaces, self )
+ if setDataForm.exec()
+ @changed = true
+ drawElements()
+ end
+ end
+
+
+ def setChartType( chartType )
+ @chartType = chartType;
+ case @chartType
+ when PIE
+ @optionsPieChartAction.setOn( true )
+ when VERTICAL_BAR:
+ @optionsVerticalBarChartAction.setOn( true )
+ when HORIZONTAL_BAR:
+ @optionsHorizontalBarChartAction.setOn( true )
+ end
+ end
+
+
+ def updateChartType( action )
+ if action == @optionsPieChartAction
+ @chartType = PIE
+ elsif action == @optionsHorizontalBarChartAction
+ @chartType = HORIZONTAL_BAR
+ elsif action == @optionsVerticalBarChartAction
+ @chartType = VERTICAL_BAR
+ end
+
+ drawElements()
+ end
+
+
+ def optionsSetFont()
+ ok = Qt::Boolean.new
+ font = Qt::FontDialog.getFont( ok, @font, self )
+ if !ok.nil?
+ @font = font
+ drawElements()
+ end
+ end
+
+
+ def optionsSetOptions()
+ optionsForm = OptionsForm.new( self )
+ optionsForm.chartTypeComboBox.setCurrentItem( @chartType )
+ optionsForm.font = @font
+ case @addValues
+ when NO
+ optionsForm.noRadioButton.setChecked( true )
+ when YES
+ optionsForm.yesRadioButton.setChecked( true )
+ when AS_PERCENTAGE
+ optionsForm.asPercentageRadioButton.setChecked( true )
+ end
+ optionsForm.decimalPlacesSpinBox.setValue( @decimalPlaces )
+ if optionsForm.exec()
+ setChartType( optionsForm.chartTypeComboBox.currentItem() )
+ @font = optionsForm.font
+ if optionsForm.noRadioButton.isChecked()
+ @addValues = NO
+ elsif optionsForm.yesRadioButton.isChecked()
+ @addValues = YES
+ elsif optionsForm.asPercentageRadioButton.isChecked()
+ @addValues = AS_PERCENTAGE
+ end
+ @decimalPlaces = optionsForm.decimalPlacesSpinBox.value()
+ drawElements()
+ end
+ end
+
+
+ def helpHelp()
+ statusBar().message( "Help is not implemented yet", 2000 )
+ end
+
+
+ def helpAbout()
+ Qt::MessageBox.about( self, "Chart -- About",
+ "<center><h1><font color=blue>Chart<font></h1></center>" +
+ "<p>Chart your data with <i>chart</i>.</p>" )
+ end
+
+
+ def helpAboutQt()
+ Qt::MessageBox.aboutQt( self, "Chart -- About Qt" )
+ end
+
+end
+
diff --git a/qtruby/rubylib/examples/qt-examples/chart/chartform_canvas.rb b/qtruby/rubylib/examples/qt-examples/chart/chartform_canvas.rb
new file mode 100644
index 00000000..86c66f76
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/chartform_canvas.rb
@@ -0,0 +1,212 @@
+class ChartForm
+
+ def drawElements()
+ list = @canvas.allItems()
+ list.each do |it|
+ it.dispose
+ end
+
+ # 360 * 16 for pies Qt works with 16ths of degrees
+ scaleFactor = @chartType == PIE ? 5760 :
+ @chartType == VERTICAL_BAR ? @canvas.height() :
+ @canvas.width()
+ biggest = 0.0
+ count = 0
+ total = 0.0
+ scales = Array.new(MAX_ELEMENTS)
+
+ for i in 0...MAX_ELEMENTS
+ if @elements[i].isValid()
+ value = @elements[i].value()
+ count += 1
+ total += value
+ if value > biggest
+ biggest = value
+ end
+ scales[i] = @elements[i].value() * scaleFactor
+ end
+ end
+
+ if count > 0
+ # 2nd loop because of total and biggest
+ for i in 0...MAX_ELEMENTS
+ if @elements[i].isValid()
+ if @chartType == PIE
+ scales[i] = (@elements[i].value() * scaleFactor) / total
+ else
+ scales[i] = (@elements[i].value() * scaleFactor) / biggest
+ end
+ end
+ end
+
+ case @chartType
+ when PIE
+ drawPieChart( scales, total, count )
+ when VERTICAL_BAR:
+ drawVerticalBarChart( scales, total, count )
+ when HORIZONTAL_BAR:
+ drawHorizontalBarChart( scales, total, count )
+ end
+ end
+
+ @canvas.update()
+ end
+
+
+ def drawPieChart( scales, total, i )
+ width = @canvas.width().to_f
+ height = @canvas.height().to_f
+ size = width > height ? height : width
+ x = width / 2
+ y = height / 2
+ angle = 0
+
+ for i in 0...MAX_ELEMENTS
+ if @elements[i].isValid()
+ extent = scales[i]
+ arc = Qt::CanvasEllipse.new( size, size, angle, extent, @canvas )
+ arc.setX( x )
+ arc.setY( y )
+ arc.setZ( 0 )
+ arc.setBrush( Qt::Brush.new( @elements[i].valueColor(),
+ @elements[i].valuePattern() ) )
+ arc.show()
+ angle += extent
+ label = @elements[i].label()
+ if !label.empty? || @addValues != NO
+ label = valueLabel( label, @elements[i].value(), total )
+ text = CanvasText.new( i, label, @font, @canvas )
+ proX = @elements[i].proX( PIE ).to_f
+ proY = @elements[i].proY( PIE ).to_f
+ if proX < 0 || proY < 0
+ # Find the centre of the pie segment
+ rect = arc.boundingRect()
+ proX = ( rect.width() / 2 ) + rect.x()
+ proY = ( rect.height() / 2 ) + rect.y()
+ # Centre text over the centre of the pie segment
+ rect = text.boundingRect()
+ proX -= ( rect.width() / 2 )
+ proY -= ( rect.height() / 2 )
+ # Make proportional
+ proX /= width
+ proY /= height
+ end
+ text.setColor( @elements[i].labelColor() )
+ text.setX( proX * width )
+ text.setY( proY * height )
+ text.setZ( 1 )
+ text.show()
+ @elements[i].setProX( PIE, proX )
+ @elements[i].setProY( PIE, proY )
+ end
+ end
+ end
+ end
+
+
+ def drawVerticalBarChart(scales, total, count )
+ width = @canvas.width().to_f
+ height = @canvas.height().to_f
+ prowidth = width / count
+ x = 0
+ pen = Qt::Pen.new
+ pen.style = NoPen
+
+ for i in 0...MAX_ELEMENTS
+ if @elements[i].isValid()
+ extent = scales[i]
+ y = height - extent
+ rect = Qt::CanvasRectangle.new(x, y, prowidth, extent, @canvas )
+ rect.setBrush( Qt::Brush.new( @elements[i].valueColor(),
+ @elements[i].valuePattern() ) )
+ rect.setPen( pen )
+ rect.setZ( 0 )
+ rect.show()
+ label = @elements[i].label()
+ if !label.empty? || @addValues != NO
+ proX = @elements[i].proX( VERTICAL_BAR ).to_f
+ proY = @elements[i].proY( VERTICAL_BAR ).to_f
+ if proX < 0 || proY < 0
+ proX = x / width
+ proY = y / height
+ end
+ label = valueLabel( label, @elements[i].value(), total )
+ text = CanvasText.new( i, label, @font, @canvas )
+ text.setColor( @elements[i].labelColor() )
+ text.setX( proX * width )
+ text.setY( proY * height )
+ text.setZ( 1 )
+ text.show()
+ @elements[i].setProX( VERTICAL_BAR, proX )
+ @elements[i].setProY( VERTICAL_BAR, proY )
+ end
+ x += prowidth
+ end
+ end
+ end
+
+
+ def drawHorizontalBarChart(scales, total, count )
+ width = @canvas.width().to_f
+ height = @canvas.height().to_f
+ proheight = height / count
+ y = 0
+ pen = Qt::Pen.new
+ pen.style = NoPen
+
+ for i in 0...MAX_ELEMENTS
+ if @elements[i].isValid()
+ extent = scales[i]
+ rect = Qt::CanvasRectangle.new(0, y, extent, proheight, @canvas )
+ rect.setBrush( Qt::Brush.new( @elements[i].valueColor(),
+ @elements[i].valuePattern() ) )
+ rect.setPen( pen )
+ rect.setZ( 0 )
+ rect.show()
+ label = @elements[i].label()
+ if !label.empty? || @addValues != NO
+ proX = @elements[i].proX( HORIZONTAL_BAR ).to_f
+ proY = @elements[i].proY( HORIZONTAL_BAR ).to_f
+ if proX < 0 || proY < 0
+ proX = 0
+ proY = y / height
+ end
+ label = valueLabel( label, @elements[i].value(), total )
+ text = CanvasText.new( i, label, @font, @canvas )
+ text.setColor( @elements[i].labelColor() )
+ text.setX( proX * width )
+ text.setY( proY * height )
+ text.setZ( 1 )
+ text.show()
+ @elements[i].setProX( HORIZONTAL_BAR, proX )
+ @elements[i].setProY( HORIZONTAL_BAR, proY )
+ end
+ y += proheight
+ end
+ end
+ end
+
+
+ def valueLabel(label, value, total )
+ if @addValues == NO
+ return label
+ end
+
+ newLabel = label
+ if !label.empty?
+ if @chartType == VERTICAL_BAR
+ newLabel += "\n"
+ else
+ newLabel += ' '
+ end
+ end
+ if @addValues == YES
+ newLabel += "%.#{@decimalPlaces}f" % value
+ elsif @addValues == AS_PERCENTAGE
+ newLabel += "%.#{@decimalPlaces}f%s" % [(value / total) * 100, '%']
+ end
+ return newLabel
+ end
+
+end
+
diff --git a/qtruby/rubylib/examples/qt-examples/chart/chartform_files.rb b/qtruby/rubylib/examples/qt-examples/chart/chartform_files.rb
new file mode 100644
index 00000000..648aba62
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/chartform_files.rb
@@ -0,0 +1,102 @@
+class ChartForm
+
+ def load( filename )
+ file = Qt::File.new( filename )
+ if !file.open( Qt::IO_ReadOnly )
+ statusBar().message( "Failed to load \'%s\'" % filename, 2000 )
+ return
+ end
+
+ init() # Make sure we have colours
+ @filename = filename
+ ts = Qt::TextStream.new( file )
+ errors = 0
+ i = 0
+ while !ts.eof()
+ element = Element.new
+ ts >> element
+ if element.isValid()
+ @elements[i] = element
+ i += 1
+ else
+ errors += 1
+ end
+ if i == MAX_ELEMENTS
+ statusBar().message("Read maximum number of elements (%d) discarding others" % i, 2000 )
+ break
+ end
+ end
+
+ file.close()
+
+ bad = ""
+ if errors > 0
+ bad = " skipped %d bad record" % errors
+ if errors > 1
+ bad += "s"
+ end
+ end
+ statusBar().message( "Read %d values from \'%s\'" % [i, filename], 3000 )
+
+ setCaption( "Chart -- %s" % filename )
+ updateRecentFiles( filename )
+
+ drawElements()
+ @changed = false
+ end
+
+
+ def fileSave()
+ if @filename.nil?
+ fileSaveAs()
+ return
+ end
+
+ file = Qt::File.new( @filename )
+ if !file.open( Qt::IO_WriteOnly )
+ statusBar().message( "Failed to save \'%s\'" % @filename, 2000 )
+ return
+ end
+ ts = Qt::TextStream.new( file )
+ for i in 0...MAX_ELEMENTS
+ if @elements[i].isValid()
+ ts << @elements[i]
+ end
+ end
+
+ file.close()
+
+ setCaption( "Chart -- %s" % @filename )
+ statusBar().message( "Saved \'%s\'" % @filename, 2000 )
+ @changed = false
+ end
+
+
+ def fileSaveAsPixmap()
+ filename = Qt::FileDialog.getSaveFileName(nil, "Images (*.png *.xpm *.jpg)",
+ self, "file save as bitmap",
+ "Chart -- File Save As Bitmap" )
+ if Qt::Pixmap.grabWidget( @canvasView ).save( filename,
+ filename.sub(/.*\.([^.]*)$/, '\1').upcase() )
+ statusBar().message( "Wrote \'%s\'" % filename, 2000 )
+ else
+ statusBar().message( "Failed to write \'%s\'" % filename, 2000 )
+ end
+ end
+
+ def filePrint()
+ if !@printer
+ @printer = Qt::Printer.new
+ end
+ if @printer.setup()
+ painter = Qt::Painter.new( @printer )
+ @canvas.drawArea( Qt::Rect.new( 0, 0, @canvas.width(), @canvas.height() ),
+ painter, false )
+ if !@printer.outputFileName().empty?
+ statusBar().message( "Printed \'%s\'" % @printer.outputFileName(), 2000 )
+ end
+ end
+ end
+
+end
+
diff --git a/qtruby/rubylib/examples/qt-examples/chart/element.rb b/qtruby/rubylib/examples/qt-examples/chart/element.rb
new file mode 100644
index 00000000..ba135632
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/element.rb
@@ -0,0 +1,161 @@
+class Element
+
+ FIELD_SEP = ':'
+ PROPOINT_SEP = ';'
+ XY_SEP = ','
+
+ EPSILON = 0.0000001
+
+ INVALID = -1
+ NO_PROPORTION = -1
+ MAX_PROPOINTS = 3 # One proportional point per chart type
+
+ attr_accessor :value, :valueColor, :valuePattern, :label, :labelColor
+
+ def initialize( value = INVALID, valueColor = Qt::gray,
+ valuePattern = Qt::SolidPattern,
+ label = nil,
+ labelColor = Qt::black )
+ init( value, valueColor, valuePattern, label, labelColor )
+ @propoints = []
+ for i in 0...MAX_PROPOINTS * 2
+ @propoints[i] = NO_PROPORTION
+ end
+ end
+
+ def isValid() return @value > EPSILON end
+
+
+ def init( value, valueColor, valuePattern,
+ label, labelColor )
+ @value = value
+ @valueColor = valueColor
+ if Qt::SolidPattern >= valuePattern || Qt::DiagCrossPattern <= valuePattern
+ valuePattern = Qt::SolidPattern
+ end
+ @valuePattern = valuePattern
+ @label = label
+ @labelColor = labelColor
+ end
+
+ def set( value = INVALID, valueColor = Qt::gray,
+ valuePattern = Qt::SolidPattern,
+ label = nil,
+ labelColor = Qt::black )
+ init( value, valueColor, valuePattern, label, labelColor )
+ end
+
+ def setValuePattern( valuePattern )
+ if valuePattern < Qt::SolidPattern.to_i || valuePattern > Qt::DiagCrossPattern.to_i
+ valuePattern = Qt::SolidPattern
+ end
+ @valuePattern = valuePattern
+ end
+
+
+ def proX( index )
+ return @propoints[2 * index]
+ end
+
+
+ def proY( index )
+ return @propoints[(2 * index) + 1]
+ end
+
+
+ def setProX( index, value )
+ @propoints[2 * index] = value
+ end
+
+
+ def setProY( index, value )
+ @propoints[(2 * index) + 1] = value
+ end
+
+end
+
+class Qt::TextStream
+
+ alias op_write <<
+
+ def <<( item )
+ if !item.kind_of? Element
+ return op_write(item)
+ end
+ element = item
+ self << element.value() << Element::FIELD_SEP <<
+ element.valueColor().name() << Element::FIELD_SEP <<
+ element.valuePattern().to_i << Element::FIELD_SEP <<
+ element.labelColor().name() << Element::FIELD_SEP
+
+ for i in 0...Element::MAX_PROPOINTS
+ self << element.proX( i ) << Element::XY_SEP << element.proY( i )
+ self << ( i == Element::MAX_PROPOINTS - 1 ? Element::FIELD_SEP : Element::PROPOINT_SEP )
+ end
+
+ self << element.label() << "\n"
+
+ return self
+ end
+
+ alias op_read >>
+
+ def >>( item )
+ if !item.kind_of? Element
+ return op_read(item)
+ end
+
+ element = item
+ data = readLine()
+ element.value = Element::INVALID
+
+ errors = 0
+
+ fields = data.split( Element::FIELD_SEP )
+ if fields.length() >= 4
+ value = fields[0].to_f
+ if value.nil?
+ errors += 1
+ end
+ valueColor = Qt::Color.new( fields[1] )
+ if !valueColor.isValid()
+ errors += 1
+ end
+ valuePattern = fields[2].to_i
+ if valuePattern.nil?
+ errors += 1
+ end
+ labelColor = Qt::Color.new( fields[3] )
+ if !labelColor.isValid()
+ errors += 1
+ end
+ propoints = fields[4].split( Element::PROPOINT_SEP )
+ label = data.split(Element::FIELD_SEP)[5]
+ if errors == 0
+ element.set( value, valueColor, valuePattern, label, labelColor )
+ i = 0
+ propoints.each do |point|
+ errors = 0
+ xy = point.split( Element::XY_SEP )
+ x = xy[0].to_f
+ if x.nil? || x <= 0.0 || x >= 1.0
+ errors += 1
+ end
+ y = xy[1].to_f
+ if y.nil? || y <= 0.0 || y >= 1.0
+ errors += 1
+ end
+ if errors > 0
+ x = y = Element::NO_PROPORTION
+ end
+ element.setProX( i, x )
+ element.setProY( i, y )
+ i += 1
+ end
+ end
+ end
+
+ return self
+ end
+
+end
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/chart-forms.sk b/qtruby/rubylib/examples/qt-examples/chart/images/chart-forms.sk
new file mode 100644
index 00000000..d9087b48
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/chart-forms.sk
@@ -0,0 +1,256 @@
+##Sketch 1 2
+document()
+layout('A4',0)
+layer('Layer 1',1,1,0,0,(0,0,0))
+fp((0.9,0.9,0.9))
+le()
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+r(188.034,0,0,-149.201,526.688,-521.707)
+fp((0.9,0.9,0.9))
+le()
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+r(128.762,0,0,-92.995,341.407,-572.49)
+fp((0.9,0.9,0.9))
+le()
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+r(128.762,0,0,-92.995,768.68,-572.934)
+fp((0.9,0.9,0.9))
+le()
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+e(31.6796,0,0,31.6796,635.564,-722.4)
+fp((0.8,0.8,0.8))
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+r(188.034,0,0,-149.201,518.884,-513.603)
+fp((1,1,1))
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+r(158.398,0,0,-106.28,533.702,-545.185)
+fp((0,0,0))
+le()
+lw(1)
+Fn('Helvetica-Narrow-Bold')
+Fs(18)
+txt('ChartForm',(575.182,-535.064))
+fp((0.8,0.8,0.8))
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+r(128.762,0,0,-92.995,335.96,-566.743)
+fp((0,0,0))
+le()
+lw(1)
+Fn('Helvetica-Narrow-Bold')
+Fs(18)
+txt('OptionsForm',(354.009,-589.226))
+fp((0.8,0.8,0.8))
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+r(128.762,0,0,-92.995,763.221,-566.743)
+fp((0,0,0))
+le()
+lw(1)
+Fn('Helvetica-Narrow-Bold')
+Fs(18)
+txt('SetDataForm',(781.675,-587.279))
+fp((1,0,1))
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+e(31.6796,0,0,31.6796,631.296,-719.01)
+fp((0,0,0))
+le()
+lw(1)
+Fn('Helvetica-Narrow-BoldOblique')
+Fs(18)
+txt('chart',(613.251,-723.609))
+G()
+fp((0,0,0))
+le()
+lw(1)
+Fn('Helvetica-Narrow-Bold')
+Fs(18)
+txt('CanvasView',(569.827,-575.941))
+fp((0,0,0))
+le()
+lw(1)
+Fn('Helvetica-Narrow-Bold')
+Fs(18)
+txt('depicting a',(573.94,-595.357))
+fp((0,0,0))
+le()
+lw(1)
+Fn('Helvetica-Narrow-Bold')
+Fs(18)
+txt('QCanvas',(580.906,-614.774))
+G_()
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+b()
+bs(662.975,-716.966,0)
+bc(669.107,-712.686,671.463,-709.765,672.485,-707.625,2)
+bc(673.507,-705.485,677.438,-697.225,677.438,-696.155,2)
+bc(677.438,-695.085,679.326,-682.725,679.326,-682.725,2)
+bc(679.326,-682.725,679.326,-670.955,679.326,-670.955,2)
+bc(679.326,-670.955,679.326,-665.605,679.326,-664.535,2)
+lw(1.41732)
+la1(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+b()
+bs(710.729,-618.861,0)
+bs(759.036,-618.861,0)
+lw(1.41732)
+la1(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+b()
+bs(515.603,-617.742,0)
+bs(467.885,-617.742,0)
+G()
+fp((0,0.392,0))
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+e(29.7517,0,0,-7.65884,468.929,-768.389)
+fp((0,0.392,0))
+le()
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+r(58.9143,0,0,-44.1857,439.032,-724.349)
+fp((0,0.392,0))
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+e(29.7517,0,0,-7.65884,468.929,-722.581)
+G_()
+lw(1.41732)
+la1(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+b()
+bs(499.125,-739.077,0)
+bc(507.548,-735.049,508.671,-732.747,512.04,-728.144,2)
+bc(515.409,-723.54,519.901,-717.21,520.463,-716.059,2)
+bc(521.024,-714.909,531.132,-689.589,531.132,-689.589,2)
+bc(531.132,-689.589,533.378,-679.231,533.378,-679.231,2)
+bc(533.378,-679.231,535.062,-671.175,535.062,-671.175,2)
+bc(535.062,-671.175,535.062,-664.845,535.062,-664.845,2)
+fp((1,1,1))
+le()
+lw(1)
+Fn('Helvetica-Narrow-Bold')
+Fs(18)
+txt('disk',(453.761,-753.806))
+fp((0,0,0))
+le()
+lw(1)
+Fn('Helvetica-Narrow')
+Fs(18)
+txt('run',(681.17,-700.783))
+fp((0,0,0))
+le()
+lw(1)
+Fn('Helvetica-Narrow')
+Fs(18)
+txt('save',(524.007,-725.891))
+fp((0,0,0))
+le()
+lw(1)
+Fn('Helvetica-Narrow')
+Fs(18)
+txt('load',(494.295,-706.489))
+fp((0.9,0.9,0.9))
+le()
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+r(143.737,0,0,-67.586,525.422,-405.581)
+fp((0.596,0.984,0.596))
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+r(143.737,0,0,-67.586,519.327,-401.081)
+fp((0,0,0))
+le()
+lw(1)
+Fn('Helvetica-Narrow')
+Fs(18)
+txt('getOpenFileName()',(526.396,-420.297))
+fp((0.9,0.9,0.9))
+le()
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+r(143.737,0,0,-67.586,704.655,-405.581)
+fp((0.596,0.984,0.596))
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+r(143.737,0,0,-67.586,698.561,-401.081)
+fp((0,0,0))
+le()
+lw(1)
+Fn('Helvetica-Narrow')
+Fs(18)
+txt('getSaveFileName()',(706.863,-420.39))
+fp((0.9,0.9,0.9))
+le()
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+r(100.503,0,0,-67.586,375.286,-429.722)
+fp((0.529,0.808,0.98))
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+r(100.503,0,0,-67.586,371.024,-425.223)
+fp((0,0,0))
+le()
+lw(1)
+Fn('Helvetica-Narrow')
+Fs(18)
+txt('getFont()',(391.333,-444.571))
+fp((0.9,0.9,0.9))
+le()
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+r(100.503,0,0,-67.586,935.176,-580.856)
+fp((1,0.753,0.796))
+lw(1.41732)
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+r(100.503,0,0,-67.586,930.915,-576.357)
+fp((0,0,0))
+le()
+lw(1)
+Fn('Helvetica-Narrow')
+Fs(18)
+txt('getColor()',(948.361,-598.303))
+lw(1.41732)
+ld((1, 1))
+la1(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+b()
+bs(591.836,-511.466,0)
+bs(591.836,-471.702,0)
+lw(1.41732)
+ld((1, 1))
+la1(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+b()
+bs(674.96,-513.083,0)
+bs(749.29,-470.169,0)
+lw(1.41732)
+ld((1, 1))
+la1(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+b()
+bs(538.877,-513.083,0)
+bs(472.859,-474.968,0)
+lw(1.41732)
+ld((1, 1))
+la1(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+b()
+bs(410.746,-562.437,0)
+bs(410.746,-494.504,0)
+lw(1.41732)
+ld((1, 1))
+la1(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1))
+b()
+bs(895.423,-617.315,0)
+bs(928.721,-617.315,0)
+guidelayer('Guide Lines',1,0,0,1,(0,0,1))
+grid((0,0,20,20),0,(0,0,1),'Grid')
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/file_new.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/file_new.xpm
new file mode 100644
index 00000000..8537176c
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/file_new.xpm
@@ -0,0 +1,36 @@
+/* XPM */
+static const char *file_new[] = {
+"20 20 12 1",
+" c white",
+"! c None",
+"# c #000",
+"$ c #2e2e2e2e2e2e",
+"% c #ffffffffffff",
+"& c #5c5c5c5c5c5c",
+"( c #878787878787",
+") c #c2c2c2c2c2c2",
+"* c black",
+"+ c #00C900",
+", c #ffff00",
+"- c red",
+"!!!!!!!!!!!!!!!!!!!!",
+"!!##########$!!!!!!!",
+"!!#%%%%%%%%#&$!!!!!!",
+"!!#%%%%%%%%#(&$!!!!!",
+"!!#%%%%%%%%#)(&$!!!!",
+"!!#%%%%%%%%#%)(&$!!!",
+"!!#%%%%*****#####!!!",
+"!!#%%%*+++++*%%%#!!!",
+"!!#%%*,++++++*%%#!!!",
+"!!#%*,,,++++++*%#!!!",
+"!!#%*,,,,+++++*%#!!!",
+"!!#%*,,,,-++++*%#!!!",
+"!!#%*,,,---+++*%#!!!",
+"!!#%*,,-----++*%#!!!",
+"!!#%%*-------*%%#!!!",
+"!!#%%%*-----*%%%#!!!",
+"!!#%%%%*****%%%%#!!!",
+"!!#%%%%%%%%%%%%%#!!!",
+"!!###############!!!",
+"!!!!!!!!!!!!!!!!!!!!"
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/file_open.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/file_open.xpm
new file mode 100644
index 00000000..7a7b681d
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/file_open.xpm
@@ -0,0 +1,33 @@
+/* XPM */
+static const char *file_open[] = {
+"20 20 9 1",
+" c white",
+"! c None",
+"# c #002EFF",
+"$ c #000",
+"% c #ffffffff0",
+"& c #ffffffffffff",
+"( c #00C900",
+") c #ffff00",
+"* c #A500FF",
+"!!!!!!!!!!####!!!!#!",
+"!!!!!!!!!#!!!!##!##!",
+"!!!!!!!!!!!!!!!!###!",
+"!!!!!!!!!!!!!!!####!",
+"!!!!!!!!!!!!!!#####!",
+"!$$$$!!!!!!!!!!!!!!!",
+"$%&%&$$$$$$$$!!!!!!!",
+"$&%&%&%&%&%&$!!!!!!!",
+"$%&&&$$$$$&&$!!!!!!!",
+"$&&&$((((($&$!!!!!!!",
+"$%&$)(($$$$$$$$$$$$$",
+"$&$)))$***********$$",
+"$%$))$***********$$!",
+"$&$)$***********$$!!",
+"$%$$***********$$!!!",
+"$&$***********$$!!!!",
+"$$***********$$!!!!!",
+"$$***********$!!!!!!",
+"$$$$$$$$$$$$$!!!!!!!",
+"!!!!!!!!!!!!!!!!!!!!"
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/file_print.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/file_print.xpm
new file mode 100644
index 00000000..915f65ba
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/file_print.xpm
@@ -0,0 +1,115 @@
+/* XPM */
+static const char *file_print[] = {
+/* columns rows colors chars-per-pixel */
+"20 20 89 1",
+" c Gray0",
+". c #101008081010",
+"X c #101010101010",
+"o c #101010101818",
+"O c #181810101818",
+"+ c #181818181818",
+"@ c #181818182121",
+"# c #212118182121",
+"$ c Gray13",
+"% c #212121212929",
+"& c #292921212929",
+"* c Gray16",
+"= c #292929293131",
+"- c #313129293131",
+"; c #313131313131",
+": c #313131313939",
+"> c #393931313939",
+", c #393939393939",
+"< c #393939394242",
+"1 c #424239394242",
+"2 c Gray26",
+"3 c #4a4a4a4a5252",
+"4 c #5a5a52525a5a",
+"5 c #5a5a5a5a6363",
+"6 c #6b6b63636b6b",
+"7 c Gray42",
+"8 c #6b6b6b6b7373",
+"9 c #73736b6b7373",
+"0 c #7b7b73737b7b",
+"q c #7b7b73738484",
+"w c #0808ffff0808",
+"e c #2929ffff2929",
+"r c #3131ffff3131",
+"t c #5a5acece5a5a",
+"y c #6b6bffff6363",
+"u c #7b7bffff7b7b",
+"i c #84847b7b8484",
+"p c #84847b7b8c8c",
+"a c #8c8c7b7b9494",
+"s c #848484848c8c",
+"d c #8c8c84848c8c",
+"f c Gray55",
+"g c #8c8c84849494",
+"h c #8c8c8c8c9494",
+"j c #94948c8c9494",
+"k c #94948c8c9c9c",
+"l c Gray58",
+"z c #949494949c9c",
+"x c #9c9c94949c9c",
+"c c Gray61",
+"v c #9c9c9494a5a5",
+"b c #9c9c9c9ca5a5",
+"n c #a5a59c9ca5a5",
+"m c #a5a59c9cadad",
+"M c #adad9c9cadad",
+"N c #a5a5a5a5a5a5",
+"B c #a5a5a5a5adad",
+"V c #adada5a5adad",
+"C c Gray68",
+"Z c #adadadadb5b5",
+"A c #b5b5adadb5b5",
+"S c Gray71",
+"D c Gray74",
+"F c #9494c6c69494",
+"G c #9c9ccecea5a5",
+"H c #bdbdd6d6bdbd",
+"J c #c0c0c0c0c0c0",
+"K c #c6c6c6c6c6c6",
+"L c #cecec6c6cece",
+"P c #cececececece",
+"I c #cecececed6d6",
+"U c #d6d6ceced6d6",
+"Y c #d6d6cecedede",
+"T c Gray84",
+"R c #d6d6d6d6dede",
+"E c #deded6d6dede",
+"W c Gray87",
+"Q c #deded6d6e7e7",
+"! c #dedededee7e7",
+"~ c #d6d6ffffd6d6",
+"^ c #e7e7dedee7e7",
+"/ c #e7e7e7e7e7e7",
+"( c #e7e7e7e7efef",
+") c #efefe7e7efef",
+"_ c #efefefefefef",
+"` c #e7e7ffffe7e7",
+"' c Gray97",
+"] c Gray100",
+"[ c None",
+/* pixels */
+"[[[[[[SDPPKKDDCD[[[[",
+"[[[[[[D_///___WD[[[[",
+"[[[[[[DKKPKKKKDK[[[[",
+"[[[[[[SDDSDDSSCD[[[[",
+"[[[[[KCKDKDDDKS[[[[[",
+"[[[[[KDDDDDDDDS[[[[[",
+"[[[[[CP/WWWWTWNNZ[[[",
+"[[[Dc9STPTPTWWj427S[",
+"[[Dziq00000pag8<%@2N",
+"[DcE(!ERRUYGtFn2##O<",
+"Db)]]]]]]]~ewePa;@X#",
+"V']]]]]]]]`yru]Q0@ #",
+"BRILITRRWE!RHUILhO @",
+"jAZVBmBnmmnmMvzh6o #",
+"jZZmBnnnbbbbvxxg6o +",
+"lmmnbnbbbvxxxvjs6O 3",
+"jBnnvcvxvxvxzjhd8o+C",
+"lsdgfgdhghjhjkhg6+l[",
+"S9%@$%&&&-::>>:-:l[[",
+"[[C511,:;**%++.2c[[["
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/file_save.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/file_save.xpm
new file mode 100644
index 00000000..61638992
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/file_save.xpm
@@ -0,0 +1,33 @@
+/* XPM */
+static const char *file_save[] = {
+"20 20 9 1",
+" c white",
+"! c #000",
+"# c #002EFF",
+"$ c #999999999999",
+"% c None",
+"& c #00C900",
+"( c #ffff00",
+") c red1",
+"* c black",
+"!!!!!!!!!!!!!!!!!!!!",
+"!##!$$$!!!!!!$$$!%%!",
+"!##!$$!&&&&&&!$$!%%!",
+"!##!$!(&&&&&&&!$!!!!",
+"!##!!(((&&&&&&&!!##!",
+"!##!!((((&&&&&&!!##!",
+"!##!!((((()&&&&!!##!",
+"!##!!((())))&&&!!##!",
+"!##!!(())))))&&!!##!",
+"!##!$!))))))))!$!##!",
+"!###!$!))))))!$*###!",
+"!####***!!!!!***###!",
+"!##################!",
+"!###!!!!!!!!!!!!!##!",
+"!###!!!!!!!!!$$$!##!",
+"!###!!!!!!!!!$$$!##!",
+"!###!!!!!!!!!$$$!##!",
+"!###!!!!!!!!!$$$!##!",
+"!###!!!!!!!!!$$$!##!",
+"%!!!!!!!!!!!!!!!!!!%"
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/file_saveaspostscript.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/file_saveaspostscript.xpm
new file mode 100644
index 00000000..7dd75fcf
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/file_saveaspostscript.xpm
@@ -0,0 +1,34 @@
+/* XPM */
+static const char *file_saveaspostscript[] = {
+"20 20 10 1",
+" c white",
+"! c #000",
+"# c #002EFF",
+"$ c #999999999999",
+"% c None",
+"& c #00C900",
+"( c #ffff00",
+") c red1",
+"* c black",
+"+ c grey100",
+"!!!!!!!!!!!!!!!!!!!!",
+"!##!$$$!!!!!!$$$!%%!",
+"!##!$$!&&&&&&!$$!%%!",
+"!##!$!(&&&&&&&!$!!!!",
+"!##!!(((&&&&&&&!!##!",
+"!##!!((((&&&&&&!!##!",
+"!##!!((((()&&&&!!##!",
+"!##!!((())))&&&!!##!",
+"!##!!(())))))&&!!##!",
+"!##!$!))))))))!$!##!",
+"!###!$!))))))!$*###!",
+"!####***!!!!!***###!",
+"!##################!",
+"!###!!!!!!!!!!!!!##!",
+"!###!+++!+++!$$$!##!",
+"!###!+!+!+!!!$$$!##!",
+"!###!+++!+++!$$$!##!",
+"!###!+!!!!!+!$$$!##!",
+"!###!+!!!+++!$$$!##!",
+"%!!!!!!!!!!!!!!!!!!%"
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/options_horizontalbarchart.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/options_horizontalbarchart.xpm
new file mode 100644
index 00000000..afb06ffa
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/options_horizontalbarchart.xpm
@@ -0,0 +1,31 @@
+/* XPM */
+static const char *options_horizontalbarchart[] = {
+"20 20 7 1",
+"( c #A500FF",
+" c white",
+"! c red1",
+"# c None",
+"$ c #E9FF00",
+"% c #00C900",
+"& c #002EFF",
+"!!!!!!!!!!!!!!######",
+"!!!!!!!!!!!!!!######",
+"!!!!!!!!!!!!!!######",
+"!!!!!!!!!!!!!!######",
+"$$$$$$$$$$$$$$$$$###",
+"$$$$$$$$$$$$$$$$$###",
+"$$$$$$$$$$$$$$$$$###",
+"$$$$$$$$$$$$$$$$$###",
+"%%%%%%%%%%%%%%%%%%%%",
+"%%%%%%%%%%%%%%%%%%%%",
+"%%%%%%%%%%%%%%%%%%%%",
+"%%%%%%%%%%%%%%%%%%%%",
+"&&&&&&&&&&&&&&######",
+"&&&&&&&&&&&&&&######",
+"&&&&&&&&&&&&&&######",
+"&&&&&&&&&&&&&&######",
+"(((((((((((#########",
+"(((((((((((#########",
+"(((((((((((#########",
+"(((((((((((#########"
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/options_piechart.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/options_piechart.xpm
new file mode 100644
index 00000000..221c78de
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/options_piechart.xpm
@@ -0,0 +1,30 @@
+/* XPM */
+static const char *options_piechart[] = {
+"20 20 6 1",
+" c white",
+"! c None",
+"# c black",
+"$ c #00C900",
+"% c #E9FF00",
+"& c red1",
+"!!!!!!#######!!!!!!!",
+"!!!!##$$$$$$$##!!!!!",
+"!!!#%$$$$$$$$$$#!!!!",
+"!!#%%%$$$$$$$$$$#!!!",
+"!#%%%%%$$$$$$$$$$#!!",
+"!#%%%%%$$$$$$$$$$#!!",
+"#%%%%%%%$$$$$$$$$$#!",
+"#%%%%%%%%$$$$$$$$$#!",
+"#%%%%%%%%$$$$$$$$$#!",
+"#%%%%%%%%%$$$$$$$$#!",
+"#%%%%%%%%&&$$$$$$$#!",
+"#%%%%%%%&&&&$$$$$$#!",
+"#%%%%%%&&&&&&&$$$$#!",
+"#%%%%%&&&&&&&&&$$$#!",
+"!#%%%&&&&&&&&&&&&#!!",
+"!#%%&&&&&&&&&&&&&#!!",
+"!!#&&&&&&&&&&&&&#!!!",
+"!!!#&&&&&&&&&&&#!!!!",
+"!!!!##&&&&&&&##!!!!!",
+"!!!!!!#######!!!!!!!"
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/options_setdata.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/options_setdata.xpm
new file mode 100644
index 00000000..4ff70a54
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/options_setdata.xpm
@@ -0,0 +1,34 @@
+/* XPM */
+static const char *options_setdata[] = {
+"20 20 10 1",
+" c white",
+"! c None",
+"# c grey40",
+"$ c #002EFF",
+"% c black",
+"& c red1",
+"( c #00C900",
+") c #A500FF",
+"* c #E9FF00",
+"+ c cyan1",
+"!!!!!!!!!!!!!!!!!!!!",
+"!#####!$$!!#####!%%!",
+"!#####!$$!!#####!%%!",
+"!!!!!!!!!!!!!!!!!!!!",
+"!#####!&&!!#####!%%!",
+"!#####!&&!!#####!%%!",
+"!!!!!!!!!!!!!!!!!!!!",
+"!#####!((!!#####!%%!",
+"!#####!((!!#####!%%!",
+"!!!!!!!!!!!!!!!!!!!!",
+"!#####!))!!#####!%%!",
+"!#####!))!!#####!%%!",
+"!!!!!!!!!!!!!!!!!!!!",
+"!#####!**!!#####!%%!",
+"!#####!**!!#####!%%!",
+"!!!!!!!!!!!!!!!!!!!!",
+"!#####!++!!#####!%%!",
+"!#####!++!!#####!%%!",
+"!!!!!!!!!!!!!!!!!!!!",
+"!!!!!!!!!!!!!!!!!!!!"
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/options_setfont.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/options_setfont.xpm
new file mode 100644
index 00000000..ab552248
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/options_setfont.xpm
@@ -0,0 +1,27 @@
+/* XPM */
+static const char *options_setfont[] = {
+"20 20 3 1",
+" c white",
+"! c None",
+"# c #002EFF",
+"!!!!!!!!!!!!!!!!!!!!",
+"!!!!!!!!!!!!#####!!!",
+"!!!!!!!!!!!#######!!",
+"!!!!!!!!!!!##!!!!##!",
+"!!!!!!!!!!##!!!!###!",
+"!!!!!!!!!!##!!!!###!",
+"!!!!!!!!!###!!!!!!!!",
+"!!!!!!!!!##!!!!!!!!!",
+"!!!!!#############!!",
+"!!!!###!!########!!!",
+"!!!##!!!!##!!!!!!!!!",
+"!!!##!!!!#!!!!!!!!!!",
+"!!!!!!!!##!!!!!!!!!!",
+"!!!!!!!!##!!!!!!!!!!",
+"!!!!!!!###!!!!!!!!!!",
+"!!!!!!!##!!!!!!!!!!!",
+"!!!!!!##!!!!!!!!!!!!",
+"!#!!!###!!!!!!!!!!!!",
+"!######!!!!!!!!!!!!!",
+"!!####!!!!!!!!!!!!!!"
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/options_setoptions.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/options_setoptions.xpm
new file mode 100644
index 00000000..029cf47d
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/options_setoptions.xpm
@@ -0,0 +1,32 @@
+/* XPM */
+static const char *options_setoptions[] = {
+"20 20 8 1",
+"( c #A500FF",
+" c white",
+") c grey30",
+"! c None",
+"# c #000",
+"$ c grey60",
+"% c grey100",
+"& c black",
+"!!!!!!!!!!!!!!!!!!!!",
+"!#############$$$$$!",
+"!#%%%%%%%%%%%%&$$$$!",
+"!#%%%%%%%%%%%%%&$$$!",
+"!#%%%%%%%%%%%%%%&$$!",
+"!#%%%%%%%%%%%%%%%&$!",
+"!#%%((%%%%%%%%%%%%#!",
+"!#%%((%%%%%%%%%%%%#!",
+"!#%%((%%%%%%%%%%%%#!",
+"!#(((((((%%%%%%%%%#!",
+"!#(((((((%%%%%%%%%#!",
+"!#%%((%%%%%)%))))%#!",
+"!#%%((%%%%%%%%%%%%#!",
+"!#%%((%)))%)))%))%#!",
+"!#%%%%%%%%%%%%%%%%#!",
+"!#%%))%)%))))%))%%#!",
+"!#%%%%%%%%%%%%%%%%#!",
+"!#%%%%%%%%%%%%%%%%#!",
+"!##################!",
+"!!!!!!!!!!!!!!!!!!!!"
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/options_verticalbarchart.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/options_verticalbarchart.xpm
new file mode 100644
index 00000000..e812f0f9
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/options_verticalbarchart.xpm
@@ -0,0 +1,31 @@
+/* XPM */
+static const char *options_verticalbarchart[] = {
+"20 20 7 1",
+"( c #A500FF",
+" c white",
+"! c None",
+"# c #00C900",
+"$ c #E9FF00",
+"% c red1",
+"& c #002EFF",
+"!!!!!!!!####!!!!!!!!",
+"!!!!!!!!####!!!!!!!!",
+"!!!!!!!!####!!!!!!!!",
+"!!!!$$$$####!!!!!!!!",
+"!!!!$$$$####!!!!!!!!",
+"!!!!$$$$####!!!!!!!!",
+"%%%%$$$$####&&&&!!!!",
+"%%%%$$$$####&&&&!!!!",
+"%%%%$$$$####&&&&!!!!",
+"%%%%$$$$####&&&&((((",
+"%%%%$$$$####&&&&((((",
+"%%%%$$$$####&&&&((((",
+"%%%%$$$$####&&&&((((",
+"%%%%$$$$####&&&&((((",
+"%%%%$$$$####&&&&((((",
+"%%%%$$$$####&&&&((((",
+"%%%%$$$$####&&&&((((",
+"%%%%$$$$####&&&&((((",
+"%%%%$$$$####&&&&((((",
+"%%%%$$$$####&&&&(((("
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/pattern01.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/pattern01.xpm
new file mode 100644
index 00000000..26a70cbd
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/pattern01.xpm
@@ -0,0 +1,27 @@
+/* XPM */
+static const char *pattern01[] = {
+/* columns rows colors chars-per-pixel */
+"40 20 1 1",
+" c black",
+/* pixels */
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" "
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/pattern02.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/pattern02.xpm
new file mode 100644
index 00000000..cc5b7948
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/pattern02.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static const char *pattern02[] = {
+/* columns rows colors chars-per-pixel */
+"40 20 2 1",
+" c black",
+". c white",
+/* pixels */
+". . . . . . . . . . ",
+" ",
+" ",
+" ",
+". . . . . . . . . . ",
+" ",
+" ",
+" ",
+". . . . . . . . . . ",
+" ",
+" ",
+" ",
+". . . . . . . . . . ",
+" ",
+" ",
+" ",
+". . . . . . . . . . ",
+" ",
+" ",
+" "
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/pattern03.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/pattern03.xpm
new file mode 100644
index 00000000..d9fc57a9
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/pattern03.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static const char *pattern03[] = {
+/* columns rows colors chars-per-pixel */
+"40 20 2 1",
+" c black",
+". c white",
+/* pixels */
+" . . . . . . . . . . ",
+" ",
+". . . . . . . . . . ",
+" ",
+" . . . . . . . . . . ",
+" ",
+". . . . . . . . . . ",
+" ",
+" . . . . . . . . . . ",
+" ",
+". . . . . . . . . . ",
+" ",
+" . . . . . . . . . . ",
+" ",
+". . . . . . . . . . ",
+" ",
+" . . . . . . . . . . ",
+" ",
+". . . . . . . . . . ",
+" "
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/pattern04.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/pattern04.xpm
new file mode 100644
index 00000000..85b9223b
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/pattern04.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static const char *pattern04[] = {
+/* columns rows colors chars-per-pixel */
+"40 20 2 1",
+" c black",
+". c white",
+/* pixels */
+". . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+" . . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+". . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+" . . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+". . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+" . . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+". . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+" . . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+". . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+" . . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . ."
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/pattern05.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/pattern05.xpm
new file mode 100644
index 00000000..cc7beee9
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/pattern05.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static const char *pattern05[] = {
+/* columns rows colors chars-per-pixel */
+"40 20 2 1",
+" c black",
+". c white",
+/* pixels */
+" . . . . . . . . . . . . . . . . . . . .",
+". . . . . . . . . . . . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+". . . . . . . . . . . . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+". . . . . . . . . . . . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+". . . . . . . . . . . . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+". . . . . . . . . . . . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+". . . . . . . . . . . . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+". . . . . . . . . . . . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+". . . . . . . . . . . . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+". . . . . . . . . . . . . . . . . . . . ",
+" . . . . . . . . . . . . . . . . . . . .",
+". . . . . . . . . . . . . . . . . . . . "
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/pattern06.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/pattern06.xpm
new file mode 100644
index 00000000..ad8b0554
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/pattern06.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static const char *pattern06[] = {
+/* columns rows colors chars-per-pixel */
+"40 20 2 1",
+" c black",
+". c white",
+/* pixels */
+".. ... ... ... ... ... ... ... ... ... .",
+". . . . . . . . . . . . . . . . . . . . ",
+" ... ... ... ... ... ... ... ... ... ...",
+". . . . . . . . . . . . . . . . . . . . ",
+".. ... ... ... ... ... ... ... ... ... .",
+". . . . . . . . . . . . . . . . . . . . ",
+" ... ... ... ... ... ... ... ... ... ...",
+". . . . . . . . . . . . . . . . . . . . ",
+".. ... ... ... ... ... ... ... ... ... .",
+". . . . . . . . . . . . . . . . . . . . ",
+" ... ... ... ... ... ... ... ... ... ...",
+". . . . . . . . . . . . . . . . . . . . ",
+".. ... ... ... ... ... ... ... ... ... .",
+". . . . . . . . . . . . . . . . . . . . ",
+" ... ... ... ... ... ... ... ... ... ...",
+". . . . . . . . . . . . . . . . . . . . ",
+".. ... ... ... ... ... ... ... ... ... .",
+". . . . . . . . . . . . . . . . . . . . ",
+" ... ... ... ... ... ... ... ... ... ...",
+". . . . . . . . . . . . . . . . . . . . "
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/pattern07.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/pattern07.xpm
new file mode 100644
index 00000000..d01c55f9
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/pattern07.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static const char *pattern07[] = {
+/* columns rows colors chars-per-pixel */
+"40 20 2 1",
+" c black",
+". c white",
+/* pixels */
+" ... ... ... ... ... ... ... ... ... ...",
+"........................................",
+".. ... ... ... ... ... ... ... ... ... .",
+"........................................",
+" ... ... ... ... ... ... ... ... ... ...",
+"........................................",
+".. ... ... ... ... ... ... ... ... ... .",
+"........................................",
+" ... ... ... ... ... ... ... ... ... ...",
+"........................................",
+".. ... ... ... ... ... ... ... ... ... .",
+"........................................",
+" ... ... ... ... ... ... ... ... ... ...",
+"........................................",
+".. ... ... ... ... ... ... ... ... ... .",
+"........................................",
+" ... ... ... ... ... ... ... ... ... ...",
+"........................................",
+".. ... ... ... ... ... ... ... ... ... .",
+"........................................"
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/pattern08.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/pattern08.xpm
new file mode 100644
index 00000000..b0ce09fe
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/pattern08.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static const char *pattern08[] = {
+/* columns rows colors chars-per-pixel */
+"40 20 2 1",
+" c black",
+". c white",
+/* pixels */
+"........................................",
+"........................................",
+"... ... ... ... ... ... ... ... ... ... ",
+"........................................",
+"........................................",
+"........................................",
+"... ... ... ... ... ... ... ... ... ... ",
+"........................................",
+"........................................",
+"........................................",
+"... ... ... ... ... ... ... ... ... ... ",
+"........................................",
+"........................................",
+"........................................",
+"... ... ... ... ... ... ... ... ... ... ",
+"........................................",
+"........................................",
+"........................................",
+"... ... ... ... ... ... ... ... ... ... ",
+"........................................"
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/pattern09.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/pattern09.xpm
new file mode 100644
index 00000000..7d34bc42
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/pattern09.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static const char *pattern09[] = {
+/* columns rows colors chars-per-pixel */
+"40 20 2 1",
+" c black",
+". c white",
+/* pixels */
+"........................................",
+" ",
+"........................................",
+"........................................",
+"........................................",
+"........................................",
+"........................................",
+" ",
+"........................................",
+"........................................",
+"........................................",
+"........................................",
+"........................................",
+" ",
+"........................................",
+"........................................",
+"........................................",
+"........................................",
+"........................................",
+" "
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/pattern10.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/pattern10.xpm
new file mode 100644
index 00000000..c908016d
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/pattern10.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static const char *pattern10[] = {
+/* columns rows colors chars-per-pixel */
+"40 20 2 1",
+" c black",
+". c white",
+/* pixels */
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... .",
+".. ..... ..... ..... ..... ..... ..... ."
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/pattern11.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/pattern11.xpm
new file mode 100644
index 00000000..8feda9a4
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/pattern11.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static const char *pattern11[] = {
+/* columns rows colors chars-per-pixel */
+"40 20 2 1",
+" c black",
+". c white",
+/* pixels */
+". ..... ..... ..... ..... ..... ..... ..",
+". ..... ..... ..... ..... ..... ..... ..",
+" ",
+". ..... ..... ..... ..... ..... ..... ..",
+". ..... ..... ..... ..... ..... ..... ..",
+". ..... ..... ..... ..... ..... ..... ..",
+". ..... ..... ..... ..... ..... ..... ..",
+". ..... ..... ..... ..... ..... ..... ..",
+" ",
+". ..... ..... ..... ..... ..... ..... ..",
+". ..... ..... ..... ..... ..... ..... ..",
+". ..... ..... ..... ..... ..... ..... ..",
+". ..... ..... ..... ..... ..... ..... ..",
+". ..... ..... ..... ..... ..... ..... ..",
+" ",
+". ..... ..... ..... ..... ..... ..... ..",
+". ..... ..... ..... ..... ..... ..... ..",
+". ..... ..... ..... ..... ..... ..... ..",
+". ..... ..... ..... ..... ..... ..... ..",
+". ..... ..... ..... ..... ..... ..... .."
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/pattern12.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/pattern12.xpm
new file mode 100644
index 00000000..a57233f2
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/pattern12.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static const char *pattern12[] = {
+/* columns rows colors chars-per-pixel */
+"40 20 2 1",
+" c black",
+". c white",
+/* pixels */
+"..... ....... ....... ....... ....... ..",
+".... ....... ....... ....... ....... ...",
+"... ....... ....... ....... ....... ....",
+".. ....... ....... ....... ....... .....",
+". ....... ....... ....... ....... ......",
+" ....... ....... ....... ....... .......",
+"....... ....... ....... ....... ....... ",
+"...... ....... ....... ....... ....... .",
+"..... ....... ....... ....... ....... ..",
+".... ....... ....... ....... ....... ...",
+"... ....... ....... ....... ....... ....",
+".. ....... ....... ....... ....... .....",
+". ....... ....... ....... ....... ......",
+" ....... ....... ....... ....... .......",
+"....... ....... ....... ....... ....... ",
+"...... ....... ....... ....... ....... .",
+"..... ....... ....... ....... ....... ..",
+".... ....... ....... ....... ....... ...",
+"... ....... ....... ....... ....... ....",
+".. ....... ....... ....... ....... ....."
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/pattern13.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/pattern13.xpm
new file mode 100644
index 00000000..97f874fe
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/pattern13.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static const char *pattern13[] = {
+/* columns rows colors chars-per-pixel */
+"40 20 2 1",
+" c black",
+". c white",
+/* pixels */
+" ....... ....... ....... ....... .......",
+". ....... ....... ....... ....... ......",
+".. ....... ....... ....... ....... .....",
+"... ....... ....... ....... ....... ....",
+".... ....... ....... ....... ....... ...",
+"..... ....... ....... ....... ....... ..",
+"...... ....... ....... ....... ....... .",
+"....... ....... ....... ....... ....... ",
+" ....... ....... ....... ....... .......",
+". ....... ....... ....... ....... ......",
+".. ....... ....... ....... ....... .....",
+"... ....... ....... ....... ....... ....",
+".... ....... ....... ....... ....... ...",
+"..... ....... ....... ....... ....... ..",
+"...... ....... ....... ....... ....... .",
+"....... ....... ....... ....... ....... ",
+" ....... ....... ....... ....... .......",
+". ....... ....... ....... ....... ......",
+".. ....... ....... ....... ....... .....",
+"... ....... ....... ....... ....... ...."
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/images/pattern14.xpm b/qtruby/rubylib/examples/qt-examples/chart/images/pattern14.xpm
new file mode 100644
index 00000000..e9e68845
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/images/pattern14.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static const char *pattern14[] = {
+/* columns rows colors chars-per-pixel */
+"40 20 2 1",
+" c black",
+". c white",
+/* pixels */
+"... . ..... . ..... . ..... . ..... . ..",
+".. ... ... ... ... ... ... ... ... ... .",
+". ..... . ..... . ..... . ..... . ..... ",
+" ....... ....... ....... ....... .......",
+". ..... . ..... . ..... . ..... . ..... ",
+".. ... ... ... ... ... ... ... ... ... .",
+"... . ..... . ..... . ..... . ..... . ..",
+".... ....... ....... ....... ....... ...",
+"... . ..... . ..... . ..... . ..... . ..",
+".. ... ... ... ... ... ... ... ... ... .",
+". ..... . ..... . ..... . ..... . ..... ",
+" ....... ....... ....... ....... .......",
+". ..... . ..... . ..... . ..... . ..... ",
+".. ... ... ... ... ... ... ... ... ... .",
+"... . ..... . ..... . ..... . ..... . ..",
+".... ....... ....... ....... ....... ...",
+"... . ..... . ..... . ..... . ..... . ..",
+".. ... ... ... ... ... ... ... ... ... .",
+". ..... . ..... . ..... . ..... . ..... ",
+" ....... ....... ....... ....... ......."
+};
diff --git a/qtruby/rubylib/examples/qt-examples/chart/main.rb b/qtruby/rubylib/examples/qt-examples/chart/main.rb
new file mode 100644
index 00000000..db395a3e
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/main.rb
@@ -0,0 +1,26 @@
+require 'Qt'
+
+require 'canvasview.rb'
+require 'canvastext.rb'
+require 'element.rb'
+require 'chartform.rb'
+require 'chartform_canvas.rb'
+require 'chartform_files.rb'
+require 'optionsform.rb'
+require 'setdataform.rb'
+
+app = Qt::Application.new( ARGV )
+
+if app.ARGV.length > 0
+ filename = app.ARGV[0]
+ if filename.rindex( /.cht$/ ).nil?
+ filename = nil
+ end
+end
+
+cf = ChartForm.new( filename )
+app.mainWidget = cf
+cf.show
+
+app.exec
+
diff --git a/qtruby/rubylib/examples/qt-examples/chart/optionsform.rb b/qtruby/rubylib/examples/qt-examples/chart/optionsform.rb
new file mode 100644
index 00000000..6b2eeac4
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/optionsform.rb
@@ -0,0 +1,127 @@
+class OptionsForm < Qt::Dialog
+ slots 'chooseFont()'
+
+ attr_reader :chartTypeComboBox,
+ :noRadioButton,
+ :yesRadioButton,
+ :asPercentageRadioButton,
+ :decimalPlacesSpinBox,
+ :font
+
+ def initialize( parent = nil, name = "options form",
+ modal = false, f = 0 )
+ super( parent, name, modal, f )
+ setCaption( "Chart -- Options" )
+ resize( 320, 290 )
+
+ @optionsFormLayout = Qt::VBoxLayout.new( self, 11, 6 )
+
+ @chartTypeLayout = Qt::HBoxLayout.new( nil, 0, 6 )
+
+ @chartTypeTextLabel = Qt::Label.new( "&Chart Type", self )
+ @chartTypeLayout.addWidget( @chartTypeTextLabel )
+
+ @chartTypeComboBox = Qt::ComboBox.new( false, self )
+ @chartTypeComboBox.insertItem( Qt::Pixmap.new( "images/options_piechart.xpm" ), "Pie Chart" )
+ @chartTypeComboBox.insertItem( Qt::Pixmap.new( "images/options_verticalbarchart.xpm" ),
+ "Vertical Bar Chart" )
+ @chartTypeComboBox.insertItem( Qt::Pixmap.new( "images/options_horizontalbarchart.xpm" ),
+ "Horizontal Bar Chart" )
+ @chartTypeLayout.addWidget( @chartTypeComboBox )
+ @optionsFormLayout.addLayout( @chartTypeLayout )
+
+ @fontLayout = Qt::HBoxLayout.new( nil, 0, 6 )
+
+ @fontPushButton = Qt::PushButton.new( "&Font...", self )
+ @fontLayout.addWidget( @fontPushButton )
+ @spacer = Qt::SpacerItem.new( 0, 0, Qt::SizePolicy::Expanding,
+ Qt::SizePolicy::Minimum )
+ @fontLayout.addItem( @spacer )
+
+ @fontTextLabel = Qt::Label.new( self ) # Must be set by caller via setFont()
+ @fontLayout.addWidget( @fontTextLabel )
+ @optionsFormLayout.addLayout( @fontLayout )
+
+ @addValuesFrame = Qt::Frame.new( self )
+ @addValuesFrame.setFrameShape( Qt::Frame::StyledPanel )
+ @addValuesFrame.setFrameShadow( Qt::Frame::Sunken )
+ @addValuesFrameLayout = Qt::VBoxLayout.new( @addValuesFrame, 11, 6 )
+
+ @addValuesButtonGroup = Qt::ButtonGroup.new( "Show Values", @addValuesFrame )
+ @addValuesButtonGroup.setColumnLayout(0, Qt::Vertical )
+ @addValuesButtonGroup.layout().setSpacing( 6 )
+ @addValuesButtonGroup.layout().setMargin( 11 )
+ @addValuesButtonGroupLayout = Qt::VBoxLayout.new(
+ @addValuesButtonGroup.layout() )
+ @addValuesButtonGroupLayout.setAlignment( Qt::AlignTop )
+
+ @noRadioButton = Qt::RadioButton.new( "&No", @addValuesButtonGroup )
+ @noRadioButton.setChecked( true )
+ @addValuesButtonGroupLayout.addWidget( @noRadioButton )
+
+ @yesRadioButton = Qt::RadioButton.new( "&Yes", @addValuesButtonGroup )
+ @addValuesButtonGroupLayout.addWidget( @yesRadioButton )
+
+ @asPercentageRadioButton = Qt::RadioButton.new( "As &Percentage",
+ @addValuesButtonGroup )
+ @addValuesButtonGroupLayout.addWidget( @asPercentageRadioButton )
+ @addValuesFrameLayout.addWidget( @addValuesButtonGroup )
+
+ @decimalPlacesLayout = Qt::HBoxLayout.new( nil, 0, 6 )
+
+ @decimalPlacesTextLabel = Qt::Label.new( "&Decimal Places", @addValuesFrame )
+ @decimalPlacesLayout.addWidget( @decimalPlacesTextLabel )
+
+ @decimalPlacesSpinBox = Qt::SpinBox.new( @addValuesFrame )
+ @decimalPlacesSpinBox.setMinValue( 0 )
+ @decimalPlacesSpinBox.setMaxValue( 9 )
+ @decimalPlacesLayout.addWidget( @decimalPlacesSpinBox )
+
+ @addValuesFrameLayout.addLayout( @decimalPlacesLayout )
+
+ @optionsFormLayout.addWidget( @addValuesFrame )
+
+ @buttonsLayout = Qt::HBoxLayout.new( nil, 0, 6 )
+ @spacer = Qt::SpacerItem.new( 0, 0,
+ Qt::SizePolicy::Expanding, Qt::SizePolicy::Minimum )
+ @buttonsLayout.addItem( @spacer )
+
+ @okPushButton = Qt::PushButton.new( "OK", self )
+ @okPushButton.setDefault( true )
+ @buttonsLayout.addWidget( @okPushButton )
+
+ @cancelPushButton = Qt::PushButton.new( "Cancel", self )
+ @buttonsLayout.addWidget( @cancelPushButton )
+ @optionsFormLayout.addLayout( @buttonsLayout )
+
+ connect( @fontPushButton, SIGNAL( 'clicked()' ), self, SLOT( 'chooseFont()' ) )
+ connect( @okPushButton, SIGNAL( 'clicked()' ), self, SLOT( 'accept()' ) )
+ connect( @cancelPushButton, SIGNAL( 'clicked()' ), self, SLOT( 'reject()' ) )
+
+ @chartTypeTextLabel.setBuddy( @chartTypeComboBox )
+ @decimalPlacesTextLabel.setBuddy( @decimalPlacesSpinBox )
+ end
+
+
+ def chooseFont()
+ ok = Qt::Boolean.new
+ font = Qt::FontDialog.getFont( ok, @font, self )
+ if !ok.nil?
+ setFont( font )
+ end
+ end
+
+
+ def font=( font )
+ label = font.family() + " " + font.pointSize().to_s + "pt"
+ if font.bold()
+ label += " Bold"
+ end
+ if font.italic()
+ label += " Italic"
+ end
+ @fontTextLabel.setText( label )
+ @font = font
+ end
+
+end
diff --git a/qtruby/rubylib/examples/qt-examples/chart/setdataform.rb b/qtruby/rubylib/examples/qt-examples/chart/setdataform.rb
new file mode 100644
index 00000000..81a9403b
--- /dev/null
+++ b/qtruby/rubylib/examples/qt-examples/chart/setdataform.rb
@@ -0,0 +1,184 @@
+class SetDataForm < Qt::Dialog
+
+ slots 'setColor()',
+ 'setChosenColor( int, int )',
+ 'currentChanged( int, int )',
+ 'valueChanged( int, int )',
+ 'accept()'
+
+ MAX_PATTERNS = 14
+
+
+ def initialize( elements, decimalPlaces,
+ parent = nil, name = "set data form",
+ modal = true, f = 0 )
+ super( parent, name, modal, f )
+
+ @elements = elements
+ @decimalPlaces = decimalPlaces
+
+ setCaption( "Chart -- Set Data" )
+ resize( 540, 440 )
+
+ @tableButtonBox = Qt::VBoxLayout.new( self, 11, 6, "@table button box layout" )
+
+ @table = Qt::Table.new( self, "data @table" )
+ @table.setNumCols( 5 )
+ @table.setNumRows( ChartForm::MAX_ELEMENTS )
+ @table.setColumnReadOnly( 1, true )
+ @table.setColumnReadOnly( 2, true )
+ @table.setColumnReadOnly( 4, true )
+ @table.setColumnWidth( 0, 80 )
+ @table.setColumnWidth( 1, 60 ) # Columns 1 and 4 must be equal
+ @table.setColumnWidth( 2, 60 )
+ @table.setColumnWidth( 3, 200 )
+ @table.setColumnWidth( 4, 60 )
+ th = @table.horizontalHeader()
+ th.setLabel( 0, "Value" )
+ th.setLabel( 1, "Color" )
+ th.setLabel( 2, "Pattern" )
+ th.setLabel( 3, "Label" )
+ th.setLabel( 4, "Color" )
+ @tableButtonBox.addWidget( @table )
+
+ @buttonBox = Qt::HBoxLayout.new( nil, 0, 6, "button box layout" )
+
+ @colorPushButton = Qt::PushButton.new( self, "color button" )
+ @colorPushButton.setText( "&Color..." )
+ @colorPushButton .setEnabled( false )
+ @buttonBox.addWidget( @colorPushButton )
+
+ spacer = Qt::SpacerItem.new( 0, 0, Qt::SizePolicy::Expanding,
+ Qt::SizePolicy::Minimum )
+ @buttonBox.addItem( spacer )
+
+ okPushButton = Qt::PushButton.new( self, "ok button" )
+ okPushButton.setText( "OK" )
+ okPushButton.setDefault( true )
+ @buttonBox.addWidget( okPushButton )
+
+ cancelPushButton = Qt::PushButton.new( self, "cancel button" )
+ cancelPushButton.setText( "Cancel" )
+ cancelPushButton.setAccel( Qt::KeySequence.new(Key_Escape) )
+ @buttonBox.addWidget( cancelPushButton )
+
+ @tableButtonBox.addLayout( @buttonBox )
+
+ connect( @table, SIGNAL( 'clicked(int,int,int,const QPoint&)' ),
+ self, SLOT( 'setChosenColor(int,int)' ) )
+ connect( @table, SIGNAL( 'currentChanged(int,int)' ),
+ self, SLOT( 'currentChanged(int,int)' ) )
+ connect( @table, SIGNAL( 'valueChanged(int,int)' ),
+ self, SLOT( 'valueChanged(int,int)' ) )
+ connect( @colorPushButton, SIGNAL( 'clicked()' ), self, SLOT( 'setColor()' ) )
+ connect( okPushButton, SIGNAL( 'clicked()' ), self, SLOT( 'accept()' ) )
+ connect( cancelPushButton, SIGNAL( 'clicked()' ), self, SLOT( 'reject()' ) )
+
+ patterns = Array.new(MAX_PATTERNS)
+ patterns[0] = Qt::Pixmap.new( "images/pattern01.xpm" )
+ patterns[1] = Qt::Pixmap.new( "images/pattern02.xpm" )
+ patterns[2] = Qt::Pixmap.new( "images/pattern03.xpm" )
+ patterns[3] = Qt::Pixmap.new( "images/pattern04.xpm" )
+ patterns[4] = Qt::Pixmap.new( "images/pattern05.xpm" )
+ patterns[5] = Qt::Pixmap.new( "images/pattern06.xpm" )
+ patterns[6] = Qt::Pixmap.new( "images/pattern07.xpm" )
+ patterns[7] = Qt::Pixmap.new( "images/pattern08.xpm" )
+ patterns[8] = Qt::Pixmap.new( "images/pattern09.xpm" )
+ patterns[9] = Qt::Pixmap.new( "images/pattern10.xpm" )
+ patterns[10] = Qt::Pixmap.new( "images/pattern11.xpm" )
+ patterns[11] = Qt::Pixmap.new( "images/pattern12.xpm" )
+ patterns[12] = Qt::Pixmap.new( "images/pattern13.xpm" )
+ patterns[13] = Qt::Pixmap.new( "images/pattern14.xpm" )
+
+ rect = @table.cellRect( 0, 1 )
+ pix = Qt::Pixmap.new( rect.width(), rect.height() )
+
+ for i in 0...ChartForm::MAX_ELEMENTS
+ element = @elements[i]
+
+ if element.isValid()
+ @table.setText(i, 0, "%.#{@decimalPlaces}f" % element.value() )
+ end
+
+ color = element.valueColor()
+ pix.fill( color )
+ @table.setPixmap( i, 1, pix )
+ @table.setText( i, 1, color.name() )
+
+ combobox = Qt::ComboBox.new
+ for j in 0...MAX_PATTERNS
+ combobox.insertItem( patterns[j] )
+ end
+ combobox.setCurrentItem( element.valuePattern() - 1 )
+ @table.setCellWidget( i, 2, combobox )
+
+ @table.setText( i, 3, element.label() )
+
+ color = element.labelColor()
+ pix.fill( color )
+ @table.setPixmap( i, 4, pix )
+ @table.setText( i, 4, color.name() )
+ end
+
+ end
+
+
+ def currentChanged( i, col )
+ @colorPushButton.setEnabled( col == 1 || col == 4 )
+ end
+
+
+ def valueChanged( row, col )
+ if col == 0
+ d = @table.text( row, col ).to_f
+ if d && d > EPSILON
+ @table.setText( row, col, "%.#{@decimalPlaces}f" % d )
+ elsif ! @table.text( row, col ).empty?
+ @table.setText( row, col, @table.text( row, col ) + "?" )
+ end
+ end
+ end
+
+
+ def setColor()
+ setChosenColor( @table.currentRow(), @table.currentColumn() )
+ @table.setFocus()
+ end
+
+
+ def setChosenColor( row, col )
+ if !( col == 1 || col == 4 )
+ return
+ end
+
+ color = Qt::ColorDialog.getColor(
+ Qt::Color.new( @table.text( row, col ) ),
+ self, "color dialog" )
+ if color.isValid()
+ pix = @table.pixmap( row, col )
+ pix.fill( color )
+ @table.setPixmap( row, col, pix )
+ @table.setText( row, col, color.name() )
+ end
+ end
+
+
+ def accept()
+ for i in 0...ChartForm::MAX_ELEMENTS
+ element = @elements[i]
+ d = @table.text( i, 0 ).to_f
+ if d
+ element.value = d
+ else
+ element.value = Element::INVALID
+ end
+ element.valueColor = Qt::Color.new( @table.text( i, 1 ) )
+ element.valuePattern = (@table.cellWidget( i, 2 )).currentItem() + 1
+ element.label = @table.text( i, 3 )
+ element.labelColor = Qt::Color.new( @table.text( i, 4 ) )
+ end
+
+ super
+ end
+
+end