[sword-devel] Kylix CLX bindings and test program
Troy A. Griffitts
sword-devel@crosswire.org
Mon, 14 Jan 2002 10:50:01 -0700
There is a new 'bindings' subdirectory with a helper flatapi.cpp that
exports a flat extern "C" interface the to SWORD API (or some of it, at
least for now).
In bindings/clx you will find Kylix / CLX bindings to the SWORD API.
There is a test program under bindings/clx/test1 if anyone would like to
see how to use it.
* FINALLY: THERE IS A BINARY that I would love to hear the outcome, if
you try it on your linux box. Please report on what distro you are
experimenting. The tarball contains the Qt version that Kylix wants.
Please, also let me know if your default Qt lib worked or if you needed
the one in the tarball. I'll paste the code for this program at the end
of this message so you can get an idea of how the clx sword components
work.
* WARNING: The libsword.so that is shipped with the tarball MUST BE USED
over any older libsword.so. I just realized IT WAS BUILT WITH NEW
DEFAULT ./configure OPTIONS WHICH MEANS IT IS LOOKING FOR sword.conf in
/usr/local/etc/sword.conf Please adjust. Thanks again!
Usual place:
http://www.crosswire.org/sword/ALPHAcckswwlkrfre22034820285912/alpha/
file: clxSWORD.tar.gz
[KJV][Ephesians 5:2] And walk in love, as Christ also hath loved us, and
hath given himself for us an offering and a sacrifice to God for a
sweetsmelling savour.
Goodnight!
-Troy.
______________________________________
MainForm.pas:
unit MainFrm;
interface
uses
SysUtils, Types, Classes, Variants, QGraphics, QControls, QForms,
QDialogs,
QStdCtrls, QComCtrls, QExtCtrls, Sword;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
TreeView1: TTreeView;
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
TextBrowser1: TTextBrowser;
procedure Edit1Change(Sender: TObject);
procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
procedure lookup();
public
{ Public declarations }
end;
var
Form1: TForm1;
mgr : SWMgr;
implementation
{$R *.xfm}
procedure TForm1.Edit1Change(Sender: TObject);
begin
lookup();
end;
procedure TForm1.lookup();
var
module : SWModule;
node : TTreeNode;
begin
node := TreeView1.Selected;
if (node <> nil) then
begin
module := mgr.getModuleByName(node.Text);
if (module <> nil) then
begin
module.setKeyText(Edit1.Text);
TextBrowser1.Text :=
'<HTML><BODY>' +
'<small><b>' + module.getKeyText() + '<b></small> ' +
module.getRenderText() +
'</BODY></HTML>';
Label1.Caption := ': ' + module.getKeyText();
end;
end;
end;
procedure TForm1.TreeView1Change(Sender: TObject; Node: TTreeNode);
begin
lookup();
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
mgr := SWMgr.Create;
end;
procedure TForm1.FormShow(Sender: TObject);
var
root, node : TTreeNode;
module : SWModule;
modIt : ModIterator;
found : Boolean;
begin
modIt := mgr.getModulesIterator;
module := modIt.getValue;
while (module <> nil) do
begin
node := TreeView1.Items.GetFirstNode;
found := false;
while ((node <> nil) AND (NOT found)) do
begin
if (node.Text = module.getType) then
found := true
else node := node.getNextSibling;
end;
if (node = nil) then
node := TreeView1.Items.AddChild(TreeView1.TopItem,
module.GetType());
TreeView1.Items.AddChild(node, module.GetName());
modIt.Next;
module := modIt.getValue;
end;
end;
end.