Thomas, Jason M (Software)
2007-Aug-24 15:37 UTC
[fxruby-users] setting the font in FXText
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.
On Aug 24, 2007, at 10:37 AM, Thomas, Jason M ((Software)) wrote:> How do I set my font once I have already created the dialog box or is > this possible?You need to call create() on the font before you assign it: def set_font() font = FXFont.new(getApp(), "courier", 8) font.create @fxtext.font = font end There''s also an entry about this in the FOX FAQ (see http://www.fox- toolkit.org/). Hope this helps, Lyle
I think you need to call create on the font before using it like so: def set_font() myfont = FXFont.new(getApp(), "courier", 8) myfont.create @fxtext.font = myfont end -----Original Message----- From: fxruby-users-bounces at rubyforge.org [mailto:fxruby-users-bounces at rubyforge.org] On Behalf Of Thomas, Jason M (Software) Sent: Friday, August 24, 2007 9:38 AM To: fxruby-users at rubyforge.org Subject: [fxruby-users] setting the font in FXText 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. _______________________________________________ fxruby-users mailing list fxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/fxruby-users 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.