25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more...
Home   Projects   Up   Sitemap   Search   Blog   Forum+Chat   About Us   Privacy   Terms of Use   Feedback   FAQ   Images   Services   Ads   Donate   Humor

Dialogs.cpp for the WTalk.cpp project

Defines a dialog box, used by the WTalk.cpp natural language processing chatbot project, that allows the user to manually edit a Rule.

dialogs.h

/*	dialogs.h			7-27-01
	This is part of the WTalk project.
	Copyright (C)2000-2001 Steven Whitney.
	Published under GNU GPL (General Public License) Version 2, with ABSOLUTELY NO WARRANTY.
	Initially published by http://25yearsofprogramming.com.

Rule Editor Dialog

This is the dialog box for the user to create or edit a specific Rule, defining its
stimulus and response. The Rule becomes part of the program's ruleset used for
responding to user input, generating its reponses.

*/
#ifndef __DIALOGS_H
#define __DIALOGS_H

#include <owl\owlpch.h>
#include <owl\editsear.h>

#pragma hdrstop

#define MAXRULECHARS	2000	// size of buffer for rule editing
#define MAXWORDEDIT		 128    // maximum size of a dictionary entry

//////////////////////////////////////////////////////////////////////////////
// transfer struct for the Rule Editor dialog box
// keep this: the dialog may get more controls
struct TranStruct
{
	TranStruct() { filechars[0] = 0; }		// constructor

	char filechars[MAXRULECHARS]; 			// only has to hold text for 1 Rule
};
//////////////////////////////////////////////////////////////////////////////
// Rule Editor dialog box
// #error This dialog should also have 2 listboxes: one for state variables,
// one for actions, for user reference.  Later, when user selects either,
// program could insert the selection at the insertion point in the TEdit.
class SRuleEditDialog : public TDialog
{
public:
	SRuleEditDialog(TWindow* parent, TranStruct*);			// constructor
	~SRuleEditDialog();

	// functions
	void SetupWindow();

	// variables
	TEdit* Editor;
	TFont* editorfont; 		// monospaced font for the edit control

protected:
	void CmHelp();
	void EnSetFocus() { Editor->SetSelection(-1,-1); }	// go to end and deselect

DECLARE_RESPONSE_TABLE(SRuleEditDialog);
};
//////////////////////////////////////////////////////////////////////////////


#endif			// __DIALOGS_H

dialogs.cpp

/*	dialogs.cpp		7-27-01
	This is part of the WTalk project.
	Copyright (C)2000-2001 Steven Whitney.
	Published under GNU GPL (General Public License) Version 2, with ABSOLUTELY NO WARRANTY.
	Initially published by http://25yearsofprogramming.com.

Rule Editor Dialog

------
To Do:
------
Notes:

*/
#include <owl\owlpch.h>
#include <owl\radiobut.h>
#include <owl\buttonga.h>
#include <owl\editsear.h>
#include <bwcc.h>					// IDHELP

#include "c:\bcs\my.h"
#include "dialogs.h"
#include "library.h"
#pragma hdrstop

#include "wtalk.rh"

extern string HelpFilename;

//////////////////////////////////////////////////////////////////////////////
// SRuleEditDialog
//----------------------------------------------------------------------------

DEFINE_RESPONSE_TABLE1(SRuleEditDialog,TDialog)
	EV_COMMAND(IDHELP,CmHelp),
	EV_EN_SETFOCUS(IDC_RULEEDIT, EnSetFocus),
END_RESPONSE_TABLE;

//----------------------------------------------------------------------------
// constructor
SRuleEditDialog::SRuleEditDialog(TWindow* parent,TranStruct* tts)
	: TDialog(parent,RULEEDITDIALOG)
{
Editor = new TEdit(this,IDC_RULEEDIT,MAXRULECHARS);
editorfont = new TFont("Courier New",FontHeightInPixels(10),0,0,0,FW_BOLD);	// use this one
SetTransferBuffer(tts);
}
//----------------------------------------------------------------------------
// destructor
SRuleEditDialog::~SRuleEditDialog()
{
delete editorfont;
}
//----------------------------------------------------------------------------
void SRuleEditDialog::SetupWindow()
{
TDialog::SetupWindow();

// initialize controls
Editor->SetWindowFont(*editorfont,TRUE);

}						//SetupWindow
//----------------------------------------------------------------------------
void SRuleEditDialog::CmHelp()
{
WinHelp(HelpFilename.c_str(),HELP_PARTIALKEY,(DWORD)(LPSTR)"Rule Editor Dialog");
}                  			// CmHelp
//----------------------------------------------------------------------------
//					// end class SRuleEditDialog
//////////////////////////////////////////////////////////////////////////////

 

 

Valid HTML 4.01 Transitional Valid CSS
View content labeling at ICRA.
Copyright ©2007 Steven Whitney. Last modified 09/25/2007.