[sword-devel] How do you select verses from a range?
Troy A. Griffitts
scribe at crosswire.org
Fri Dec 15 15:00:35 MST 2006
Jari,
>> The way multiple verses are rendered for the user is up to the client
>> software, not the engine. You can decide if you show verse number,
>> verse headings, etc.
>>
>
> Do you mean that one way would be how you displayed the text for the
> console/terminal using cout << ? That much I do know but thank you for being
> clear!
I'm sorry for not being more clear. The engine will return a verse at a
time and let the client decide how to display it to the user, e.g.
1. In the beginning God created... 2. And the earth was without form...
or
[1] In the beginning God created...
[2] And the earth was without form and void
or
<a href="...">1</a> In the beginning God created...
<a href="...">2</a> And the earth was without form and void
etc.
> At the first glance it looks quite compilated. My current solution is like
> this:
...
Your solution is fine if you have a set output format. Using SWDisplay
would change your model. Basically, SWDisplay is used for linking the
book to a Window component like this:
RTFChapterDisplay disp(someDisplayControl.hwindow);
book->setDisplay(&disp);
...
book->setKey("John 3:16");
book->Display(); // will call our custom displayer which we've written
to iterate the current chapter in the book and populate an RTF display
component (in our case 'someDisplayControl') using the window handle
passed in the c-tor.
This allows us to set up all the associated GUI controls for each book,
right at the start of the program. Then when we would like to visually
display, say the KJV at John 3:16, to the user, we can just:
SWModule *book = library.getModule("KJV");
book->setKey("John 3:16");
book->Display();
You can, for example, set all the Bibles to use the same SWDisplay
instance pointing to the same UI control, or whatever your user
interface dictates. It's up to you. SWDisplay and SWModule::Display()
are merely a convenience hook to help facilitate UI development. You
can use or neglect them as much as you want.
-Troy.
>
> As you can see the result's length is limited. But of course I could and
> should use something like std::string and return that but I just wanted to
> make this in the right way.
>
>
>
>> Hope this helps. Glad you're making progress.
>>
>
> It sure does! Thanks.
>
> It's alright if I can't get a perfect solution for this now that I do have a
> code that works.
>
>
>
>
> May God bless you too Troy.
>
> Jari.
>
>
>> Blessings!
>> -Troy.
>>
>>
>>
>> Jari Strand wrote:
>>> Troy,
>>> thank you for the example, I was finally able to test it and it works
>> good.
>>> But I have one problem, you see when I used to select only one verse I
>> could
>>> return the string that was returned from RenderText() or StripText() but
>> now
>>> that you have to loop in the end in order to get all the strings you
>> can't
>>> just simply return the results from a function. So is there some other
>> way
>>> for this so that I don't have to create a return buffer my self?
>>> Maybe the loop isn't required if you select verse from a one range and
>> not
>>> from two or more like in the example?
>>>
>>> Thanks.
>>>
>>>
>>> Jari.
>>>
>>>> From: "Troy A. Griffitts" <scribe at crosswire.org>
>>>> Reply-To: SWORD Developers' Collaboration Forum
>> <sword-devel at crosswire.org>
>>>> To: SWORD Developers' Collaboration Forum <sword-devel at crosswire.org>
>>>> Subject: Re: [sword-devel] How do you select verses from a range?
>>>> Date: Sun, 10 Dec 2006 13:58:47 -0700
>>>>
>>>> Jari,
>>>> I've added a new example for you:
>>>>
>>>>
>> http://crosswire.org/svn/sword/trunk/examples/cmdline/verserangeparse.cpp
>>>> Please let me know if this does not answer your question.
>>>>
>>>> -Troy.
>>>>
>>>>
>>>>
>>>> Jari Strand wrote:
>>>>> Hi, is there example showing how to select verses within a range? i
>>>> think
>>>>> there was some example but I cannot find it anymore.
>>>>>
>>>>> I only know how to select one verse using setKey("Mat 2:10");
>>>>>
>>>>> Thanks!
>>>>>
>>>>> _________________________________________________________________
>>>>> FREE pop-up blocking with the new MSN Toolbar - get it now!
>>>>> http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> sword-devel mailing list: sword-devel at crosswire.org
>>>>> http://www.crosswire.org/mailman/listinfo/sword-devel
>>>>> Instructions to unsubscribe/change your settings at above page
>>>> _______________________________________________
>>>> sword-devel mailing list: sword-devel at crosswire.org
>>>> http://www.crosswire.org/mailman/listinfo/sword-devel
>>>> Instructions to unsubscribe/change your settings at above page
>>> _________________________________________________________________
>>> Express yourself instantly with MSN Messenger! Download today it's FREE!
>>> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>>>
>>>
>>> _______________________________________________
>>> sword-devel mailing list: sword-devel at crosswire.org
>>> http://www.crosswire.org/mailman/listinfo/sword-devel
>>> Instructions to unsubscribe/change your settings at above page
>>
>> _______________________________________________
>> sword-devel mailing list: sword-devel at crosswire.org
>> http://www.crosswire.org/mailman/listinfo/sword-devel
>> Instructions to unsubscribe/change your settings at above page
>
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today it's FREE!
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page
More information about the sword-devel
mailing list