/*
* Console.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\DesktopWindow.h>
#include <sol\Profile.h>
#include <sol\MessageFont.h>
#include <sol\Paintdc.h>
#include <sol\Stdio.h>
#include <sol\ClientDC.h>
// 1997.07.19
#include <sol\Mutex.h>
#include "resource.h"
namespace SOL {
class Console :public ApplicationView {
private:
Profile profile;
MessageFont font;
ScrolledText sctext;
public:
Console(Application& applet, const TCHAR* name, Args& args)
:ApplicationView(applet, name, args)
{
Args ar;
font.create(9);
ar.reset();
sctext.create(this, NULL, ar);
// Add sctext to the default layout manager.
add(&sctext);
sctext.limitText(32000);
sctext.setFont(&font);
sctext.addCallback(XmNmaxTextCallback, this,
(Callback)&Console::clear, null);
addCallback(XmNmenuCallback, ID_CLEAR, this,
(Callback)&Console::clear, null);
addCallback(XmNmenuCallback, ID_EXIT, this,
(Callback)&Console::exit, null);
addEventHandler(WM_CLOSE, this,
(Handler)&Console::close, NULL);
DesktopWindow desktopw;
desktopw.setProp(_T("SCROLLED_TEXT"), (HANDLE)sctext.getWindow());
restorePlacement();
}
private:
long close(Event& event)
{
DesktopWindow desktopw;
desktopw.removeProp(_T("SCROLLED_TEXT"));
savePlacement();
return defaultProc(event);
}
private:
void clear(Action& action) {
sctext.setText(_T(""));
}
};
}
// Console Main
void Main(int argc, TCHAR** argv)
{
const TCHAR* appClass = _T("Console");
try {
Application applet(appClass, argc, argv);
// 1997.07.19
HWND hwnd = FindWindow(appClass, appClass);
if(hwnd == NULL) {
Mutex mutex(NULL, TRUE, appClass);
if(mutex.wait() == WAIT_OBJECT_0) {
Args args;
//args.set(XmNclassName, appClass);
Console console(applet, appClass, args);
console.realize();
applet.run();
}
} else {
SetForegroundWindow(hwnd);
}
} catch (...) {
}
}
|