[fxruby-users] setting the font in FXText

Thomas, Jason M (Software) jmthomas at ball.com
Fri Aug 24 11:37:52 EDT 2007


I have subclassed a FXDialogBox and put a FXText in it for displaying a
hex dump in my application. I want to change the font to a courier type
font since it's a hex dump. When do the following it works as expected:
 
# A little dialog box to use in our tests
class FXTextDialog < FXDialogBox
  def initialize(owner)
    # Invoke base class initialize function first
    super(owner, "Temp", DECOR_TITLE|DECOR_BORDER, 0, 0, 200, 200)
 
    button = FXHorizontalFrame.new(self,
      LAYOUT_SIDE_BOTTOM|FRAME_NONE|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH)
    contents = FXHorizontalFrame.new(self,
 
LAYOUT_SIDE_TOP|FRAME_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDT
H)
  
    @fxtext = FXText.new(contents, nil, 0,
TEXT_READONLY|TEXT_WORDWRAP|LAYOUT_FILL_X|LAYOUT_FILL_Y)
    @fxtext.font = FXFont.new(getApp(), "courier", 8)
 
    # Ok button
    ok = FXButton.new(button, "OK", nil, self, ID_CANCEL,
 
FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X|LAYOUT_CENTER_Y|LAYOUT_FILL_X)
    ok.setDefault  
    ok.setFocus
  end
end

However, when I add the following method to FXTextDialog and call it I
get a Seg Fault!:
  def set_font()
    @fxtext.font = FXFont.new(getApp(), "courier", 8)
  end
 
Usage in my application:
  def onTableHex(sender, sel, ptr)
    @dialog = FXTextDialog.new(self)
    @dialog.set_font()
    @dialog.show
  end
 
How do I set my font once I have already created the dialog box or is
this possible?

Jason




This message and any enclosures are intended only for the addressee.  Please  
notify the sender by email if you are not the intended recipient.  If you are  
not the intended recipient, you may not use, copy, disclose, or distribute this  
message or its contents or enclosures to any other person and any such actions  
may be unlawful.  Ball reserves the right to monitor and review all messages  
and enclosures sent to or from this email address.


More information about the fxruby-users mailing list