Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TNZ_EXPRESSIONFIELD_INCLUDED
Toshihiro Shimizu 890ddd
#define TNZ_EXPRESSIONFIELD_INCLUDED
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tw/textfield.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TWIN_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef WIN32
Toshihiro Shimizu 890ddd
#pragma warning(push)
Toshihiro Shimizu 890ddd
#pragma warning(disable : 4251)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// forward declaration
Toshihiro Shimizu 890ddd
namespace TSyntax
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
class Parser;
Toshihiro Shimizu 890ddd
class Grammar;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class DVAPI TExpressionField : public TTextField
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	class Listener
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
	public:
Toshihiro Shimizu 890ddd
		virtual void onExpressionChange(string s, bool isValid) = 0;
Toshihiro Shimizu 890ddd
		virtual ~Listener() {}
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TSyntax::Parser *m_parser;
Toshihiro Shimizu 890ddd
	Listener *m_listener;
Toshihiro Shimizu 890ddd
	void apply();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	TExpressionField(TWidget *parent, string name = "expressionField");
Toshihiro Shimizu 890ddd
	~TExpressionField();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setGrammar(TSyntax::Grammar *grammar);
Toshihiro Shimizu 890ddd
	TSyntax::Grammar *getGrammar() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setListener(Listener *listener)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		m_listener = listener;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void keyDown(int key, TUINT32 status, const TPoint &p);
Toshihiro Shimizu 890ddd
	void drawFieldText(const TPoint &origin, wstring text);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	string getError() const;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef WIN32
Toshihiro Shimizu 890ddd
#pragma warning(pop)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif