SOL9 Sample: SolProtocolEnumerator

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * SolProtocolEnumerator.cpp 
 * Copyright (c) 2010 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */



// SOL9 2.0

#include <sol\ApplicationView.h>
#include <sol\TreeView.h>

#include <sol\FileVersionDialog.h>
#include <sol\ImageList.h>
#include "resource.h"
#include "ProtocolEnumerator.h"

namespace SOL {

class SolProtocolEnumerator :public ApplicationView {

private:
    ImageList    imageList;
    int            iconId;
    int            propIconId;
    TreeView    treev;

    FileVersionDialog fileVersion;

private:    
    void    refresh(Action& action) {
        build();        
    }

private:
    long close(Event& event)
    {
        savePlacement();
        return defaultProc(event);
    }

private:    
    void    version(Action& action) 
    {
        fileVersion.popupAt(action);        
    }

private:
    void    build() 
    {
        treev.deleteAllItems();
        
        ProtocolEnumerator enumerator(treev, iconId, propIconId);
        enumerator.display();

        treev.expand(TVI_ROOT, TVE_EXPAND);
    }
    
public:
    /** 
     * Constructor
     */
    SolProtocolEnumerator(Application& applet, const TCHAR* name, Args& args)
        :ApplicationView(applet, name, 
            args.set(XmNbackground, (ulong)(COLOR_BTNFACE+1))    )
    {
        //Create an ImageList 
        imageList.create(16, 16, ILC_COLOR32|ILC_MASK, 10, 5);
        HINSTANCE hInst = applet.getInstance();
        iconId = imageList.addIcon(LoadIcon(hInst, MAKEINTRESOURCE(IDI_WINDOW) ));
        propIconId = imageList.addIcon(LoadIcon(hInst, MAKEINTRESOURCE(IDI_PROPERTY) ));

        //Create a fileVersionDialog
        fileVersion.create(this);

        addCallback(XmNmenuCallback, IDM_REFRESH, this,
                (Callback)&SolProtocolEnumerator::refresh, NULL);
        addCallback(XmNmenuCallback, IDM_EXIT, this,
                (Callback)&SolProtocolEnumerator::exit, NULL);

        addCallback(XmNmenuCallback, IDM_VERSION, this,
                (Callback)&SolProtocolEnumerator::version, NULL);

        Args ar;
        ar.set(XmNexStyle, (ulong)WS_EX_CLIENTEDGE);
        ar.set(XmNstyle, TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT);
        treev.create(this, NULL, ar);
        //Set a smallImageList
        treev.setImageList(imageList.getImageList(), 0);    
        add(treev);        

        build();

        restorePlacement();
    }
};

}

//
void    Main(int argc, TCHAR** argv)
{
    const String appClass = "SolProtocolEnumerator";

    try {
        Application applet(appClass, argc, argv);

        Args args;
        SolProtocolEnumerator enumerator(applet, appClass, args);
        enumerator.realize();

        applet.run();

    } catch (...) {

    }
}


Last modified: 6 Jan 2011

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