[sword-devel] Here's a quick sample of a BCB6 front-end I'm developing
for personal research using CLX
Jonathan Mickelson
sword-devel@crosswire.org
Fri, 09 Apr 2004 11:02:49 -0400
Yes, I'm using the SWORD API. I'm using standard sword-api calls; very
simple when you're back down to the basics.
My objective publicly is to become a helpful, contributing member of
Crosswire and the sword project.
At the moment, this means developing some simple working examples of
sword-api in use that can be employed by interested parties with various
levels of programming skills. I want the examples to show the
minimalist approach to having a working program that can then be
enhanced, hacked, etc. Having something working in your hands is very
satisfying.
My personal objectives, for my inhouse program (PlowShare), is to
develop my dream bible tool considering my own goals and desires and not
for public release (too many support issues/questions/complaints for a
personal tool). When some UI feature works real well, I'll add it to
the list of tips and tricks. I greatly prefer CLX over VCL primarily
because CLX has an HTML widget that has made that first screen shot
possible with 10-15 of coding (once the development environment is setup
properly).
The screen shot was to garner interest in the Sword API and this
"tutorial".
The rest of this text is from a previous posting. My preference is too
have some other develops from scratch also, compare notes and make sure
we have all the information corrected and documented for others. So, I
will help you.
-----------
This thread will archive the neccesary steps to compile your own Sword
Project from scratch using BCB 6.0
Later, this material will be consolidated into a tutorial.
Create a new Borland BCB 6 project
[I am building a CLX project though either CLX or VCL (standard) may be
used. ]
1) modify the Project Options dialog box.
TAB "Directories/Conditional"
Include Path =
$(BCB)\include
$(BCB)\include
..\..\sword\include
..\..\icu-sword\source\common
..\..\icu-sword\source\i18n
Library Path =
$(BCB)\lib\obj
$(BCB)\lib
..\..\icu-sword\as_is\borland
..\..\sword\lib
Conditional Defines (VERY IMPORTANT)
_DEBUG
_ICU_
_ICUSWORD_
_USE_OLD_RW_STL
U_HAVE_PLACEMENT_NEW=0
2) here is my simple program to display module names and descriptions on
a form.
//-------------
// download and install BibleCS 1.5.6. This creates all the proper
production directories.
// download some bible modules
// test that BibleCS is working properly
//-------------
// Add a memo component to the form (it's under the "Standard" tab)
// Create Form Events for OnDestroy and OnShow
// judiciously use the code below putting things in their proper place
// compile and run
// the form should appear with a list of module names and descriptions
//-------------
#include <clx.h> // used for CLX projects
#pragma hdrstop
#include "MySampleProject.h"
#include <string>
#include <swmgr.h>
#include <swconfig.h>
#include <markupfiltmgr.h>
#define WM_VERSE (WM_APP + 1995)
extern AnsiString startVerse;
using namespace sword;
//---------------------------------------------------------------------------
//#pragma package(smart_init)
#pragma resource "*.xfm"
SWConfig *userPrefs;
SWMgr *mainmgr;
SWConfig *optionsconf;
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
if (mainmgr)
delete mainmgr;
if (userPrefs)
{
userPrefs->Save();
delete userPrefs;
}
if (optionsconf)
delete optionsconf;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
// MyLibrary = new SWMgr(0, 0, true, new
MarkupFilterMgr(FMT_HTMLHREF, ENC_HTML));
ModMap::iterator it;
SWModule *MyMod;
optionsconf = new SWConfig("./options.conf");
try
{
mainmgr = new SWMgr(0, 0, false, new MarkupFilterMgr(FMT_RTF,
ENC_RTF));
userPrefs = 0;
mainmgr->Load();
userPrefs = new SWConfig("./userprefs.conf");
if ((mainmgr->config) && (userPrefs))
(*(mainmgr->config)) += (*userPrefs);
}
catch (...)
{
Application->Terminate();
}
if (!mainmgr->config)
Application->Terminate();
for (it = mainmgr->Modules.begin(); it != mainmgr->Modules.end(); it++)
{
MyMod = (*it).second;
if (!strcmp((*it).second->Type(), "Biblical Texts"))
{
Memo1->Lines->Append(MyMod->Name());
Memo1->Lines->Append(MyMod->Description());
}
}
}
//----------------
// End of code
//----------------