# HG changeset patch # User sl # Date 1400655820 -7200 # Node ID e8c05ae7f41843a310a4b09ca89f82055ed907a5 # Parent 7d41682fce1aec70b31c27872c3a67b15dd904d6 Font is now instanciated after selction. diff -r 7d41682fce1a -r e8c05ae7f418 MainWindow.h --- a/MainWindow.h Wed May 21 08:54:35 2014 +0200 +++ b/MainWindow.h Wed May 21 09:03:40 2014 +0200 @@ -117,6 +117,7 @@ unsigned char* iOutputReportBuffer; unsigned char iDimming; //Current VFD dimming FXFontDesc iCurrentFontDesc; + FXFont* iCurrentFont; struct hid_device_info *devices; hid_device *connected_device; diff -r 7d41682fce1a -r e8c05ae7f418 test.cpp --- a/test.cpp Wed May 21 08:54:35 2014 +0200 +++ b/test.cpp Wed May 21 09:03:40 2014 +0200 @@ -51,7 +51,8 @@ FXIMPLEMENT(MainWindow, FXMainWindow, MainWindowMap, ARRAYNUMBER(MainWindowMap)); MainWindow::MainWindow(FXApp *app) - : FXMainWindow(app, "HIDAPI Test Application", NULL, NULL, DECOR_ALL, 200,100, 600,900) + : FXMainWindow(app, "HIDAPI Test Application", NULL, NULL, DECOR_ALL, 200,100, 600,900), + iCurrentFont(NULL) { iDimming=0x35; devices = NULL; @@ -174,6 +175,9 @@ MainWindow::~MainWindow() { + delete iCurrentFont; + iCurrentFont = NULL; + if (connected_device) hid_close(connected_device); hid_exit(); @@ -738,13 +742,20 @@ */ long MainWindow::onSelectFont(FXObject *sender, FXSelector sel, void *ptr) -{ + { FXFontDialog* dlg=new FXFontDialog(this,"Pick a font"); - dlg->execute(); - dlg->getFontSelection(iCurrentFontDesc); + if (dlg->execute()) + { + dlg->getFontSelection(iCurrentFontDesc); + delete iCurrentFont; + iCurrentFont = NULL; + iCurrentFont = new FXFont(getApp(),iCurrentFontDesc); + + } + delete dlg; return 1; -} + }