Font is now instanciated after selction.
authorsl
Wed, 21 May 2014 09:03:40 +0200
changeset 7e8c05ae7f418
parent 6 7d41682fce1a
child 8 631f53604811
Font is now instanciated after selction.
MainWindow.h
test.cpp
     1.1 --- a/MainWindow.h	Wed May 21 08:54:35 2014 +0200
     1.2 +++ b/MainWindow.h	Wed May 21 09:03:40 2014 +0200
     1.3 @@ -117,6 +117,7 @@
     1.4      unsigned char* iOutputReportBuffer;
     1.5      unsigned char iDimming; //Current VFD dimming
     1.6      FXFontDesc iCurrentFontDesc;
     1.7 +    FXFont* iCurrentFont;
     1.8  
     1.9      struct hid_device_info *devices;
    1.10      hid_device *connected_device;
     2.1 --- a/test.cpp	Wed May 21 08:54:35 2014 +0200
     2.2 +++ b/test.cpp	Wed May 21 09:03:40 2014 +0200
     2.3 @@ -51,7 +51,8 @@
     2.4  FXIMPLEMENT(MainWindow, FXMainWindow, MainWindowMap, ARRAYNUMBER(MainWindowMap));
     2.5  
     2.6  MainWindow::MainWindow(FXApp *app)
     2.7 -	: FXMainWindow(app, "HIDAPI Test Application", NULL, NULL, DECOR_ALL, 200,100, 600,900)
     2.8 +	: FXMainWindow(app, "HIDAPI Test Application", NULL, NULL, DECOR_ALL, 200,100, 600,900),
     2.9 +    iCurrentFont(NULL)
    2.10  {
    2.11  	iDimming=0x35;
    2.12  	devices = NULL;
    2.13 @@ -174,6 +175,9 @@
    2.14  
    2.15  MainWindow::~MainWindow()
    2.16  {
    2.17 +    delete iCurrentFont;
    2.18 +    iCurrentFont = NULL;
    2.19 +
    2.20  	if (connected_device)
    2.21  		hid_close(connected_device);
    2.22  	hid_exit();
    2.23 @@ -738,13 +742,20 @@
    2.24  
    2.25  */
    2.26  long MainWindow::onSelectFont(FXObject *sender, FXSelector sel, void *ptr)
    2.27 -{
    2.28 +    {
    2.29      FXFontDialog* dlg=new FXFontDialog(this,"Pick a font");
    2.30 -    dlg->execute();
    2.31 -    dlg->getFontSelection(iCurrentFontDesc);
    2.32 +    if (dlg->execute())
    2.33 +        {
    2.34 +        dlg->getFontSelection(iCurrentFontDesc);
    2.35 +        delete iCurrentFont;
    2.36 +        iCurrentFont = NULL;
    2.37 +        iCurrentFont = new FXFont(getApp(),iCurrentFontDesc);
    2.38 +
    2.39 +        }
    2.40 +
    2.41      delete dlg;
    2.42      return 1;
    2.43 -}
    2.44 +    }
    2.45  
    2.46  
    2.47