/*
* FileDialog.cpp
* Copyright (c) 2009 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL++2000
// 2000.02.18
#include <sol\ApplicationView.h>
#include <sol\ScrolledText.h>
#include <sol\FileDialog.h>
#include "MenuID.h"
namespace SOL {
class AppView :public ApplicationView {
ScrolledText sctext;
FileDialog filedlg;
FileDialog savedlg;
void open(Action& action)
{
filedlg.popup(action);
if (action.getResult()) {
TCHAR* filename = filedlg.getFileName();
sctext.load(filename);
TCHAR title[MAX_PATH*2];
_stprintf_s(title, SizeOf(title), _T("Opened:%s - FileDialog"), filename);
setText(title);
}
}
void save(Action& action)
{
savedlg.popup(action);
if (action.getResult()) {
TCHAR* filename = savedlg.getFileName();
sctext.save(savedlg.getFileName());
TCHAR title[MAX_PATH*2];
_stprintf_s(title, SizeOf(title), _T("Saved:%s - FileDialog"), filename);
setText(title);
}
}
public:
AppView(Application& applet, const TCHAR* name, Args& args)
:ApplicationView(applet, name, args)
{
Args ar;
sctext.create(this, _T(""), ar);
add(&sctext);
ar.reset();
ar.set(XmNaccessMode, FileDialog::OPEN);
filedlg.create(this, NULL, ar);
ar.reset();
ar.set(XmNaccessMode, FileDialog::SAVE);
savedlg.create(this, NULL, ar);
addCallback(XmNmenuCallback, ID_OPEN, this,
(Callback)&AppView::open, NULL);
addCallback(XmNmenuCallback, ID_SAVE, this,
(Callback)&AppView::save, NULL);
addCallback(XmNmenuCallback, ID_EXIT, this,
(Callback)&AppView::exit, NULL);
}
};
}
void Main(int argc, TCHAR** argv)
{
const TCHAR* name = _T("AppView");
try {
Application applet(name, argc, argv);
Args args;
AppView appView(applet, name, args);
appView.realize();
applet.run();
} catch (...) {
}
}
|