|
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 Payments Humor Music |
Dialog box for the Natural Language Processing chatbot project, Borland C++ ObjectWindowsThe code on this page defines a dialog box used by the WTalk natural language processing chatbot project that allows the user to manually edit a Rule. The rules determine how the chatbot replies under different circumstances. |
/* 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 3, 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 7-27-01
This is part of the WTalk project.
Copyright (C)2000-2001 Steven Whitney.
Published under GNU GPL (General Public License) Version 3, 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
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
Copyright ©2012 Steven Whitney. Last modified Sun 07/29/2012 10:47:14 -0700. |
||