B
boxofsoxx-goognews
I have a ruby program that uses FXRuby. I have created a canvas widget,
and I can draw lines, rectangles and elipses, but if I try to draw
text, I get the bizzare error shown below. I also get this error if I
try to assign a FXfont to the canvas. I think I might be using the font
incorrectly. Please help. Thanks.
The error is:
This application has requested the Runtime to terminate it in an
unusual way.
Please contact the application's support team for more information.
This is the sample code that is a greatly reduced version of my code
that still exhibits the problem. If Either line 58 or 59 is uncommented
the error occurs.
#/usr/bin/env ruby
require 'fox14'
require 'fox14/colors'
include Fox
class PlotterWindow < FXMainWindow
def initialize(app)
# Invoke base class initialize first
super(app, "Plotter", nil, nil, DECOR_ALL, 0, 0, 500, 700)
@color4 = FXColor::LightBlue1
@color5 = FXColor::Blue
@font = FXFont.new(app,"times",14)
dumpFontDesc("Initial Font",@font.getFontDesc)
#@font.setFont("courier, 140")
# Dialogs for later use
colorDialog = FXColorDialog.new(self, "Color Dialog")
# Create a font dialog for later use
@fontDialog = FXFontDialog.new(self, "Axis Font Dialog")
# Create a tooltip so we get tool tips for things in this window
FXToolTip.new(self.getApp())
statusbar = FXStatusBar.new(self,
LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|STATUSBAR_WITH_DRAGCORNER)
#BUTTONS
@rightFrame = FXVerticalFrame.new(self,
LAYOUT_SIDE_TOP|LAYOUT_SIDE_RIGHT|LAYOUT_FILL_Y)
FXVerticalSeparator.new(self,
LAYOUT_SIDE_RIGHT|LAYOUT_FILL_Y|SEPARATOR_GROOVE)
colorButton = FXButton.new(@rightFrame,
"&Colors\tOpen Color Dialog\tOpen a dialog for selecting colors",
nil, colorDialog, FXWindow::ID_SHOW,
FRAME_RAISED|FRAME_THICK|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT, 0,
0, 70, 30)
fontButton = FXButton.new(@rightFrame,
"&Axes\nFont\tChoose Axis Font\tSelect a font for the Axis
Display",
nil, @fontDialog, FXWindow::ID_SHOW,
FRAME_RAISED|FRAME_THICK|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,0, 0,
70, 30)
quitButton = FXButton.new(@rightFrame,
"&Quit\tExit the Program\tTerminate Ruby Plot Program",
nil, nil, 0,
FRAME_RAISED|FRAME_THICK|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,0, 0,
70, 30)
quitButton.connect(SEL_COMMAND) {
getApp().exit(0)
}
#CANVAS FRAME
canvasFrame = FXVerticalFrame.new(self,
FRAME_RIDGE|LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT,
0, 0, 0, 0, 0,0,0,0)
@canvas = FXCanvas.new(canvasFrame, nil, 0,
FRAME_RAISED|LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT)
@canvas.connect(SEL_PAINT) do |sender, sel, event|
FXDCWindow.new(@canvas, event) do |dc|
@canvas.backColor = @color4
dc.foreground = @canvas.backColor
dc.fillRectangle(event.rect.x, event.rect.y, event.rect.w,
event.rect.h)
dc.foreground = @color5
dc.drawEllipse(100,100,100,200)
#dc.setFont(@font) #this generates an error
#dc.drawText(100,100,"test") #this generates an error
end
end
end
def dumpFontDesc(lab,fd)
print "fontDesc #{lab} = #{fd.inspect}\n"
print "#{fd.face}, #{fd.size},#{fd.weight},"
print "#{fd.slant}, #{fd.setwidth},#{fd.encoding},"
print "#{fd.flags}\n\n"
STDOUT.flush
end
def create
super
show(PLACEMENT_SCREEN)
end
end
if __FILE__ == $0
# Construct an application
application = FXApp.new("Button", "FoxTest")
# Construct the main window
PlotterWindow.new(application)
# Create the application
application.create
# Run it
application.run
end
and I can draw lines, rectangles and elipses, but if I try to draw
text, I get the bizzare error shown below. I also get this error if I
try to assign a FXfont to the canvas. I think I might be using the font
incorrectly. Please help. Thanks.
The error is:
This application has requested the Runtime to terminate it in an
unusual way.
Please contact the application's support team for more information.
Exit code: 3
This is the sample code that is a greatly reduced version of my code
that still exhibits the problem. If Either line 58 or 59 is uncommented
the error occurs.
#/usr/bin/env ruby
require 'fox14'
require 'fox14/colors'
include Fox
class PlotterWindow < FXMainWindow
def initialize(app)
# Invoke base class initialize first
super(app, "Plotter", nil, nil, DECOR_ALL, 0, 0, 500, 700)
@color4 = FXColor::LightBlue1
@color5 = FXColor::Blue
@font = FXFont.new(app,"times",14)
dumpFontDesc("Initial Font",@font.getFontDesc)
#@font.setFont("courier, 140")
# Dialogs for later use
colorDialog = FXColorDialog.new(self, "Color Dialog")
# Create a font dialog for later use
@fontDialog = FXFontDialog.new(self, "Axis Font Dialog")
# Create a tooltip so we get tool tips for things in this window
FXToolTip.new(self.getApp())
statusbar = FXStatusBar.new(self,
LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|STATUSBAR_WITH_DRAGCORNER)
#BUTTONS
@rightFrame = FXVerticalFrame.new(self,
LAYOUT_SIDE_TOP|LAYOUT_SIDE_RIGHT|LAYOUT_FILL_Y)
FXVerticalSeparator.new(self,
LAYOUT_SIDE_RIGHT|LAYOUT_FILL_Y|SEPARATOR_GROOVE)
colorButton = FXButton.new(@rightFrame,
"&Colors\tOpen Color Dialog\tOpen a dialog for selecting colors",
nil, colorDialog, FXWindow::ID_SHOW,
FRAME_RAISED|FRAME_THICK|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT, 0,
0, 70, 30)
fontButton = FXButton.new(@rightFrame,
"&Axes\nFont\tChoose Axis Font\tSelect a font for the Axis
Display",
nil, @fontDialog, FXWindow::ID_SHOW,
FRAME_RAISED|FRAME_THICK|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,0, 0,
70, 30)
quitButton = FXButton.new(@rightFrame,
"&Quit\tExit the Program\tTerminate Ruby Plot Program",
nil, nil, 0,
FRAME_RAISED|FRAME_THICK|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,0, 0,
70, 30)
quitButton.connect(SEL_COMMAND) {
getApp().exit(0)
}
#CANVAS FRAME
canvasFrame = FXVerticalFrame.new(self,
FRAME_RIDGE|LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT,
0, 0, 0, 0, 0,0,0,0)
@canvas = FXCanvas.new(canvasFrame, nil, 0,
FRAME_RAISED|LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT)
@canvas.connect(SEL_PAINT) do |sender, sel, event|
FXDCWindow.new(@canvas, event) do |dc|
@canvas.backColor = @color4
dc.foreground = @canvas.backColor
dc.fillRectangle(event.rect.x, event.rect.y, event.rect.w,
event.rect.h)
dc.foreground = @color5
dc.drawEllipse(100,100,100,200)
#dc.setFont(@font) #this generates an error
#dc.drawText(100,100,"test") #this generates an error
end
end
end
def dumpFontDesc(lab,fd)
print "fontDesc #{lab} = #{fd.inspect}\n"
print "#{fd.face}, #{fd.size},#{fd.weight},"
print "#{fd.slant}, #{fd.setwidth},#{fd.encoding},"
print "#{fd.flags}\n\n"
STDOUT.flush
end
def create
super
show(PLACEMENT_SCREEN)
end
end
if __FILE__ == $0
# Construct an application
application = FXApp.new("Button", "FoxTest")
# Construct the main window
PlotterWindow.new(application)
# Create the application
application.create
# Run it
application.run
end