Notes on Smartwin++, (A free, standard C++, Win32, GUI library)

My personal experience with SmartWin++.

The official source for information is the Web site at http://smartwin.sourceforge.net/

SmartWin++'s SourceForge site,  sourceforge.net/projects/smartwin/ , has mailing lists, screenshots, CVS access, etc.

You can download the current released version which has 41 SmartWin++ samples.

You can interact with the developers at the forums

SmartWin++ C++ class documentation

Here is the source to a hello world program:

#include "SmartWin.h"
using namespace SmartWin;


class HelloWinClass
    : public WidgetFactory< WidgetWindow, HelloWinClass >
{
private:
    WidgetMenuPtr    itsMainMenu;
    WidgetButton      * itsButton;
    WidgetCheckBox    * itsCheckBox;
   
public:
    void menuSayHello( WidgetMenu * menu, unsigned item )
    {
        createMessageBox().show( _T("Hello !" ), menu->getText( item ) );
    }

    void menuClose( WidgetMenu * menu, unsigned item )
    {
        close();
    }

    void buttonClicked( WidgetButton * button )
    {
        if ( itsCheckBox->getChecked() ) {
            createMessageBox().show( _T("Hello World!" ), button->getText() );
        } else {
            createMessageBox().show( _T("Hello !" ), button->getText() );
        }
    }

    void initAndCreate()
    {
        createWindow();
        setText( _T("Hello SmartWin") );    // Title

        SmartWin::Rectangle desktop( getDesktopSize() );
        setSize( desktop.top(0.2).left(0.3) );

        itsButton = createButton();
        itsButton->setText( _T("Hello from a button") );
        itsButton->onClicked( &HelloWinClass::buttonClicked );
        itsButton->setSize( Point( 200, 30 ) );

        itsCheckBox = createCheckBox();
        itsCheckBox->setText( _T("&Global") );
        itsCheckBox->setSize( Point( 200, 30 ) );

        // Creating main menu
        itsMainMenu = createMenu();
        WidgetMenuPtr file = itsMainMenu->appendPopup( _T("&MenuCommands") );
        int m = 1;
        file->appendItem( m++, _T("Hello from the menu"), &HelloWinClass::menuSayHello );
        file->appendItem( m++, _T("Close"), &HelloWinClass::menuClose );
        itsMainMenu->attach( this );

        layout();
        onSized( &HelloWinClass::isResized );   
    }

    void isResized( const WindowSizedEventResult & sz )
    {
        layout();
    }

    void layout()
    {
        SmartWin::Place p;
        SmartWin::Rectangle r( getSizeClientArea() );
        p.setBoundsBorders( r, 4, 4 );
            
        itsCheckBox->setPositionPerPlace( p );
        itsButton->setPositionPerPlace( p );
    }
};

int SmartWinMain( Application & app )
{
    HelloWinClass * testHello = new HelloWinClass;
    testHello->initAndCreate();
    return app.run();
}