/*
* ColorDialog.h
* Copyright (c) 2011 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL++2000
// 2000.02.18
#pragma once
#include <sol\CommonDialog.h>
namespace SOL {
class ColorDialog :public CommonDialog {
private:
COLORREF custColors[16];
private:
CHOOSECOLOR cc;
public:
ColorDialog():CommonDialog() { }
public:
ColorDialog(View* parent, const TCHAR* name, Args& args)
:CommonDialog(parent, &cc)
{
for(int i = 0; i<16; i++) {
custColors[i] = RGB(255, 255, 255);
}
memset(&cc, 0, sizeof(CHOOSECOLOR));
cc . lStructSize = sizeof(CHOOSECOLOR);
cc . Flags = CC_FULLOPEN;
cc . rgbResult = RGB(255, 255, 255);
cc . lpCustColors = custColors;
if(parent) {
cc . hwndOwner = parent -> getWindow();
}
cc . hInstance = (HWND)GetModuleHandle(NULL);//(HWND)Application::getInstance();
setValues(args);
}
public:
~ColorDialog()
{
}
public:
virtual Boolean create(View* parent, const TCHAR* name, Args& args)
{
Boolean rc = True;
CommonDialog::create(parent, &cc);
for(int i = 0; i<16; i++) {
custColors[i] = RGB(255, 255, 255);
}
memset(&cc, 0, sizeof(CHOOSECOLOR));
cc . lStructSize = sizeof(CHOOSECOLOR);
cc . Flags = CC_FULLOPEN;
cc . rgbResult = RGB(255, 255, 255);
cc . lpCustColors = custColors;
if(parent) {
cc . hwndOwner = parent -> getWindow();
}
cc . hInstance = (HWND)GetModuleHandle(NULL);//(HWND)Application::getInstance();
setValues(args);
return rc;
}
public:
void getValues(Args& args)
{
ulong* val = NULL;
int num = args.getCount();
Arg* arg = args.getArgList();
for(int i = 0; i<num; i++) {
const TCHAR* name = arg[i].name;
// <modified date="2000.01.09">
val = (ulong*)arg[i].value;
// </modified>
if(name == XmNflags) {
*val = (ulong)cc.Flags;
continue;
}
if(name == XmNrgbResult) {
*val = (ulong)cc.rgbResult;
continue;
}
}
}
public:
void setValues(Args& args)
{
ulong val;
if (args.get(XmNhook, &val)) {
cc . Flags |= CC_ENABLEHOOK;
cc . lpfnHook = (HOOKFUN)hookProc;
}
if (args.get(XmNflags, &val)) {
cc . Flags |= (DWORD)val;
}
if (args.get(XmNtemplateName, &val)) {
cc . Flags |= CC_ENABLETEMPLATE;
cc . lpTemplateName = (TCHAR*)val;
}
}
public:
int choose()
{
return ::ChooseColor(&cc);
}
public:
void popup(Action& action)
{
int result = choose();
action.setResult(result);
}
COLORREF getRGBResult() {
return cc.rgbResult;
}
COLORREF* getCustomColors() {
return custColors;
}
/*
void getValues(Args& args);
void setValues(Args& args);
void popup(Action& action);
*/
};
}
|