SOL9 Sample: ListViewColorChooser

SOL9 2.0 Samples

1 Screenshot


2 Source code

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



// SOL9 2.0 
// 2012/05/28 Sample program to use SOL::ColorListView class


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

#include <sol\ClientDC.h>
#include <sol\ListViewColorChooser.h>
#include <sol\ColorBox.h>

#include "resource.h"

namespace SOL {

class MainView :public ApplicationView {

private:
  ColorBox       colorBox;
  ListViewColorChooser  listView;

public:
  MainView(Application& applet, const TCHAR* caption, Args& args)
        :ApplicationView(applet, caption, args.set(XmNstyle, WS_CLIPCHILDREN|WS_CLIPSIBLINGS)) 
  {
    Args ar;
    ar.reset();

    colorBox.create(this, _T(""), ar);
    // Set color white
    colorBox.setColor(RGB(255,255,255));

    ar.reset();
    ar.set(XmNcolorChooserTitle, _T("Background"));
    ar.set(XmNstyle, WS_VISIBLE);
    ar.set(XmNitemHeight, 30);
    //ar.set(XmNrgbStep, 0x33);
    ar.set(XmNrgbStep, 0x20);
    
    listView.create(this, NULL, ar);
    //listView.setVisible(False);

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

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

private:
  long colorChanged(Event& event)
  {
    COLORREF color = (COLORREF)event.getLParam();
    colorBox.setColor(color);

    return 0;
  }

private:
  long size(Event& event)
  {
    int width, height;
    event.getSize(width, height);

    ClientDC dc(this);
    int h = dc.getTextHeight();

    //listView.reshape(2, 4, 230, height-6);
    listView.reshape(2, 4, 230, height-6,TRUE);

    colorBox.reshape(250, 4, width - 250-10, height-10);

    return 0L;
  }
};

}



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(XmNbackground, (COLOR_BTNFACE +1));
    MainView appview(applet, name, args);
    appview.realize();

    applet.run();

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


Last modified: 1 Feb 2017

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