1 Screenshot
2 Source code
/*
* Style.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL++2000
// 1999.09.25 Modified
// 2000.02.18
#define COMMONCONTROLS_V6
#include <sol\ApplicationView.h>
#include <sol\PaintDC.h>
#include <sol\ListBox.h>
#include <sol\PushButton.h>
#include <sol\ClientDC.h>
#include <sol\Font.h>
#include <sol\FileDialog.h>
#include "resource.h"
namespace SOL {
class AppView :public ApplicationView {
static Arg styles[];
static Arg exStyles[];
PushButton create;
PushButton destroy;
//TextField* textField;
View* view;
Font font;
ListBox stylesList;
ListBox selList;
ListBox windows;
ListBox selExList;
FileDialog filedlg;
long size(Event& event);
void selected(Action& action);
void exSelected(Action& action);
void removeStyle(Action& action);
void removeExStyle(Action& action);
DWORD getStyle(TCHAR* text);
DWORD getExStyle(TCHAR* text);
void createView(Action& action);
void destroyView(Action& action);
//void open(Action& action);
public:
AppView(Application& applet, const TCHAR* label, Args& args);
~AppView();
};
Arg AppView::styles[] = {
_T("WS_BORDER"), WS_BORDER,
_T("WS_CAPTION"), WS_CAPTION,
_T("WS_CHILD"), WS_CHILD,
_T("WS_DLGFRAME"), WS_DLGFRAME,
_T("WS_HSCROLL"), WS_HSCROLL,
_T("WS_ICONIC"), WS_ICONIC,
_T("WS_MAXIMIZE"), WS_MAXIMIZE,
_T("WS_MAXIMIZEBOX"), WS_MAXIMIZEBOX,
_T("WS_MINIMIZE"), WS_MINIMIZE,
_T("WS_MINIMIZEBOX"), WS_MINIMIZEBOX,
_T("WS_OVERLAPPED"), WS_OVERLAPPED,
_T("WS_OVERLAPPEDWINDOW"), WS_OVERLAPPEDWINDOW,
_T("WS_POPUP"), WS_POPUP,
_T("WS_POPUPWINDOW"), WS_POPUPWINDOW,
_T("WS_SYSMENU"), WS_SYSMENU,
_T("WS_THICKFRAME"), WS_THICKFRAME,
_T("WS_VISIBLE"), WS_VSCROLL,
_T("WS_VSCROLL"), WS_VSCROLL,
};
Arg AppView::exStyles[] = {
_T("WS_EX_DLGMODALFRAME") ,WS_EX_DLGMODALFRAME,
_T("WS_EX_NOPARENTNOTIFY") ,WS_EX_NOPARENTNOTIFY,
_T("WS_EX_TOPMOST") ,WS_EX_TOPMOST,
_T("WS_EX_ACCEPTFILES") ,WS_EX_ACCEPTFILES,
_T("WS_EX_TRANSPARENT") ,WS_EX_TRANSPARENT,
//Version >=4.0
// WS_EX_MDICHILD
_T("WS_EX_TOOLWINDOW") ,WS_EX_TOOLWINDOW,
_T("WS_EX_WINDOWEDGE") ,WS_EX_WINDOWEDGE,
_T("WS_EX_CLIENTEDGE") ,WS_EX_CLIENTEDGE,
_T("WS_EX_CONTEXTHELP") ,WS_EX_CONTEXTHELP,
_T("WS_EX_RIGHT") ,WS_EX_RIGHT,
_T("WS_EX_LEFT") ,WS_EX_LEFT,
_T("WS_EX_RTLREADING") ,WS_EX_RTLREADING,
_T("WS_EX_LTRREADING") ,WS_EX_LTRREADING,
_T("WS_EX_LEFTSCROLLBAR") ,WS_EX_LEFTSCROLLBAR,
_T("WS_EX_RIGHTSCROLLBAR") ,WS_EX_RIGHTSCROLLBAR,
_T("WS_EX_CONTROLPARENT") ,WS_EX_CONTROLPARENT,
_T("WS_EX_STATICEDGE") ,WS_EX_STATICEDGE,
_T("WS_EX_APPWINDOW") ,WS_EX_APPWINDOW,
};
AppView::AppView(Application& applet, const TCHAR* label, Args& args)
:ApplicationView(applet, label, args)
{
Args ar;
ClientDC dc(this);
//UINT charSet = dc.getTextCharsetInfo(NULL);
ar.reset();
ar.set(XmNheight, (-12));
ar.set(XmNfaceName, _T("Arial"));
//ar.set(XmNcharSet, (ulong)charSet);
font.create(ar);
// = new Font(ar);
ar.reset();
destroy.create(this, _T("Destroy"), ar);
destroy.setFont(&font);
destroy.addCallback(XmNactivateCallback, this,
(Callback)&AppView::destroyView, NULL);
ar.reset();
create.create(this, _T("Create"), ar);
create.addCallback(XmNactivateCallback, this,
(Callback)&AppView::createView, NULL);
create.setFont(&font);
ar.reset();
ar.set(XmNstyle, (ulong)WS_VSCROLL|LBS_NOINTEGRALHEIGHT);
stylesList.create(this, NULL, ar);
stylesList.setFont(&font);
for(int i = 0; i< XtNumber(styles); i++) {
stylesList.addString(styles[i].name);
}
stylesList.addCallback(XmNselChangeCallback, this,
(Callback)&AppView::selected, NULL);
ar.reset();
ar.set(XmNstyle, (ulong)WS_VSCROLL|LBS_NOINTEGRALHEIGHT);
selList.create(this, NULL, ar);
selList.setFont(&font);
selList.addCallback(XmNselChangeCallback, this,
(Callback)&AppView::removeStyle, NULL);
ar.reset();
ar.set(XmNstyle, (ulong)WS_VSCROLL|LBS_NOINTEGRALHEIGHT);
windows.create(this, NULL, ar);
windows.setFont(&font);
for(int n = 0; n< XtNumber(exStyles); n++) {
windows.addString(exStyles[n].name);
}
windows.addCallback(XmNselChangeCallback, this,
(Callback)&AppView::exSelected, NULL);
ar.reset();
ar.set(XmNstyle, (ulong)WS_VSCROLL|LBS_NOINTEGRALHEIGHT);
selExList.create(this, NULL, ar);
selExList.setFont(font);
selExList.addCallback(XmNselChangeCallback, this,
(Callback)&AppView::removeExStyle, NULL);
view = NULL;
addCallback(XmNmenuCallback, IDM_EXIT, this,
(Callback)&AppView::exit, NULL);
}
AppView::~AppView()
{
if (view) {
delete view;
}
}
void AppView::selected(Action& action)
{
TCHAR* text = stylesList.getCurText();
if(text) {
selList.addString(text);
delete text;
}
}
void AppView::exSelected(Action& action)
{
TCHAR* text = windows.getCurText();
if(text) {
selExList.addString(text);
delete text;
}
}
//
void AppView::removeStyle(Action& action)
{
int id = selList.getCurSel();
if(id !=LB_ERR) {
selList.deleteString(id);
}
}
void AppView::removeExStyle(Action& action)
{
int id = selExList.getCurSel();
if(id !=LB_ERR) {
selExList.deleteString(id);
}
}
DWORD AppView::getStyle(TCHAR* text)
{
DWORD style = NULL;
for(int i = 0; i<XtNumber(styles); i++) {
if(strcmp(styles[i].name, text) == 0) {
style = (DWORD)styles[i].value;
break;
}
}
return style;
}
DWORD AppView::getExStyle(TCHAR* text)
{
DWORD style = NULL;
for(int i = 0; i<XtNumber(exStyles); i++) {
if(strcmp(exStyles[i].name, text) == 0) {
style = (DWORD)exStyles[i].value;
break;
}
}
return style;
}
void AppView::destroyView(Action& action)
{
if (view) {
delete view;
view = NULL;
}
}
void AppView::createView(Action& action)
{
DWORD exStyle = NULL;
DWORD style = NULL;
int num = selExList.getCount();
TCHAR text[128];
for(int i = 0; i<num; i++) {
selExList.getText(i, text);
exStyle |= getExStyle(text);
}
num = selList.getCount();
if(num > 0) {
for(int i = 0; i<num; i++) {
selList.getText(i, text);
style |= getStyle(text);
}
Args ar;
ar.set(XmNexStyle, exStyle);
ar.set(XmNstyle, style);
ar.set(XmNx, 20);
ar.set(XmNy, 20);
ar.set(XmNwidth, 400);
ar.set(XmNheight,200);
if(view) {
delete view;
view = NULL;
}
view = new View(this, _T("Window"), ar);
view -> setLocation(20, 20);
view -> setSize(400, 200);
view -> reshape(20, 20, 400, 200);
view -> show(SW_SHOW);
}
}
long AppView::size(Event& event)
{
int w, h;
event.getSize(w, h);
Dimension d;
create.getPreferredSize(d);
create.setLocation(10, 4);
Dimension td;
destroy.getPreferredSize(td);
destroy.setLocation(10+20+d.getWidth(), 4);
stylesList.reshape(2, 2+40, w/2 -1, h/2-1-40);
selList.reshape(w/2+1, 2+40, w/2 -1, h/2 -1-40);
windows.reshape(2, h/2+20, w/2-2, h/2-1-40);
selExList.reshape(w/2, h/2+20, w/2-2, h/2-1-40);
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, (ulong)(COLOR_BTNFACE+1));
AppView 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.