SOL9 Sample: SolProtocolEnumerator

SOL9 2.0 Samples

1 Screenshot


2 Source code

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



// SOL9 2.0
#define COMMONCONTROLS_V6

#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)
{
  ModuleFileName module(argv[0]);
  const TCHAR* name = module.getFileName();

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

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

    applet.run();

  } catch (Exception& ex) {
    caught(ex);
  } catch (...) {
    caught(UnknownException());
  }
}


Last modified: 1 Feb 2017

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