SOL9 2.0 Sample: TextField

SOL9 2.0 Samples

1 Screenshot


2 Source code

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


// SOL++2000
// 2000.02.18


#include <sol\ApplicationView.h>
#include <sol\TextField.h>
#include <sol\FlowLayout.h>
#include <sol\Static.h>

namespace SOL {

class AppView :public ApplicationView {
private:
    FlowLayout    flowLayout;
    Static        label;
    TextField    textField;


public:
    /**
     * Constructor
     */
    AppView(Application& applet, const TCHAR* name, Args& args)
        :ApplicationView(applet, name, args)
    {
        setLayout(&flowLayout);

        Args ar;
        label.create(this, _T("ProgramName to run"), ar);
        add(label);

        ar.reset();
        ar.set(XmNwidth, 300);
        textField.create(this, NULL, ar);
        textField.limitText(256);
        add(textField);

        textField.addCallback(XmNactivateCallback, this,
            (Callback)&AppView::exec, NULL);
    }

private:
    void exec(Action& action)
    {
        TCHAR text[256];
        textField.getText(text, sizeof(text));
        ::ShellExecute(NULL, _T("open"), text, NULL, NULL, SW_SHOW);

    }

};

}

//
void    Main(int argc, TCHAR** argv)
{
    const String name = "TextFieldApplet";
    try {
        Application applet(name, argc, argv);

        Args args;
        args.set(XmNbackground, (ulong)(COLOR_BTNFACE+1));
        args.set(XmNwidth, 500);
        args.set(XmNheight, 200);
        AppView appView(applet, name, args);
        appView.realize();
        applet.run();
    } catch (...) {

    }
}


Last modified: 11 Nov 2009

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