SOL9 Sample: ColorMixer

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * ColorMixer.CPP 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */



// SOL++2000 
// 1999.09.23 Modified
// 2000.02.18
// 2009/10/11 Updated.

#include <sol\ApplicationView.h>
#include <sol\ColorMixer.h>
#include "resource.h"

namespace SOL {

class MainView :public ApplicationView {

private:
  ColorMixer mixer;

private:
  long colorChanged(Event& event)
  {
    COLORREF color = (COLORREF)event.getLParam();
    TCHAR rgb[128];
    _stprintf_s(rgb, CountOf(rgb), _T("RGB=(0x%02x, 0x%02x, 0x%02x)"), 
      GetRValue(color),
      GetGValue(color),
      GetBValue(color));

    setText(rgb);

    return 1;
  }


private:
  long size(Event& event)
  {
    int w, h;
    event.getSize(w, h);
    mixer.reshape(10, 10, 290, 160);

    return 0L;
  }

public:
  /**
   * Constructor
   */
  MainView(Application& applet, const TCHAR* caption, Args& args)
  :ApplicationView(applet, caption, args.set(XmNstyle, WS_CLIPCHILDREN))
  {
    Args ar;
    ar.reset();
    mixer.create(this, _T(""), ar);

    addEventHandler(WM_COLORCHANGED, this, 
      (Handler)&MainView::colorChanged, NULL);

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

};

}

//
void  Main(int argc, TCHAR** argv)
{
  ModuleFileName module(argv[0]);
  const TCHAR* name = module.getFileName();
  try {
    Application applet(name, argc, argv);

    Args args;
    args.set(XmNwidth,  400);
    args.set(XmNheight, 400);
    MainView mainView(applet, name, args);
    mainView.realize();

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

Last modified: 1 Feb 2017

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