1 Screenshot
2 Source code
/*
* ColorModel.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL++2000
// 2000.06.15
#include <sol\ApplicationView.h>
#include <sol\PaintDC.h>
#include <sol\ClientDC.h>
#include <sol\DIBSection.h>
#include "resource.h"
namespace SOL {
#define WM_CREATE_COLORS (WM_USER+200)
class ColorModel :public ApplicationView {
DIBSection colorSpace;
int num;
long createColors(Event& event) {
ClientDC cdc(this);
num = 256;
colorSpace.create(cdc, num*2, num*2);
colorSpace.clear();
for (int r = 0; r<num; r++) {
for(int g = 0; g<num; g++) {
for(int b = 0; b<num; b++) {
colorSpace.setPixel(b + r,g + r, RGB(r, g, b));
}
}
}
return 0;
}
long paint(Event& event)
{
PaintDC pdc(this);
pdc.rectangle(10, 10, 10+num*2+2, 10+num*2+2);
colorSpace.draw(pdc, 11, 11);
return 0;
}
public:
/**
* Constructor
*/
ColorModel(Application& applet, const TCHAR* label, Args& args)
:ApplicationView(applet, label, args)
{
addCallback(XmNmenuCallback, IDM_EXIT, this,
(Callback)&ColorModel::exit, NULL);
addEventHandler(WM_PAINT, this,
(Handler)&ColorModel::paint, NULL);
addEventHandler(WM_CREATE_COLORS, this,
(Handler)&ColorModel::createColors, NULL);
post(WM_CREATE_COLORS, 0, 0);
}
};
}
//
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, 540);
args.set(XmNheight, 580);
//2009/10/11 To avoid a window flicker
args.set(XmNclassStyle, 0);
args.set(XmNexStyle, (ulong)WS_EX_CLIENTEDGE);
ColorModel colorModel(applet, name, args);
colorModel.realize();
applet.run();
} catch (Exception& ex) {
caught(ex);
} catch (...) {
caught(UnknownException());
}
}
Last modified: 1 Feb 2017
Copyright (c) 2017 Antillia.com ALL RIGHTS RESERVED.