SOL9 2.0 Sample: FontDialog

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * FontDialog.cpp 
 * Copyright (c) 2009 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// Sample program to use FontDialog class of SOL++2000.
// 2000.02.18

#define ID_FONT        102

#include <sol\ApplicationView.h>
#include <sol\ScrolledText.h>
#include <sol\FontDialog.h>
#include <sol\Font.h>

#include "resource.h"


namespace SOL {

class AppView :public ApplicationView {
private:
    Font*        font;
    ScrolledText    sctext;
    FontDialog    fontdlg;
    
public:
    AppView(Application& applet, const TCHAR* name, Args& args)
    :ApplicationView(applet, name, args)
    {
        font = null;
        Args ar;
        sctext.create(this, _T(""), ar);
        add(&sctext);

        ar.reset();
        fontdlg.create(this, NULL, ar);
    
        addCallback(XmNmenuCallback, IDM_FONT, this,
            (Callback)&AppView::setFont, NULL);

        addCallback(XmNmenuCallback, IDM_EXIT, this,
            (Callback)&AppView::exit, NULL);

    }

public:
    ~AppView()
    {
        delete font;
    }

private:
    void setFont(Action& action)
    {
        fontdlg.popup(action);
        if (action.getResult()) {
            delete font;
            font = fontdlg.getFont();
            sctext.setFont(font);
        }
    }

};

}

void    Main(int argc, TCHAR** argv)
{
    const TCHAR* name = _T("AppView");
    try {
        Application applet(name, argc, argv);
    
        Args args;
        AppView appView(applet, name, args);
        appView.realize();
        applet.run();
    } catch (...) {

    }
}


Last modified: 11 Nov 2009

Copyright (c) 2009 Antillia.com ALL RIGHTS RESERVED.