#include "ApplicationInterface.h" #include "VerseTextControl.h" #include //#define NOHTML #ifndef NOHTML #include #define controlToVerse(window,versenr) SendMessage(window, DTM_ANCHORW, FALSE, (LPARAM)(versenr)) VerseTextControl::VerseTextControl(int x, int y, int width, int height) : TextControl(x,y,width,height) {} void VerseTextControl::addAnchoredText(const WCString &text, int anchor) { // anchor is assumed to be embedded in the text addText(text); } void VerseTextControl::gotoAnchor(int anchor) { wchar_t wanchor[16]; _itow(anchor, wanchor, 10); if(!primed || preview) controlToVerse(htmlPrimed,wanchor); else controlToVerse(htmlFull,wanchor); } void VerseTextControl::paint() { TextControl::paint(); } void VerseTextControl::clearText() { TextControl::clearText(); } #else //ifndef NOHTML VerseTextControl::VerseTextControl(int x, int y, int width, int height) : TextControl(x,y,width,height) { currentAnchor=-1; } void VerseTextControl::paint() { AnchorIterator current=anchorPositions.find(currentAnchor); if (current==(AnchorIterator)anchorPositions.end()) { current=anchorPositions.begin(); // no or invalid anchor, start at the first anchor } RECT textArea=area; int start, end; if (current==(AnchorIterator)anchorPositions.end()) start=0; else start=current->second; while (textArea.topsecond; } if (end<=start) { clearRect(&textArea); break; // no more text left } textArea.top+=drawVerseText(&textArea,buffer.substr(start, end-start)); start=end; } } void VerseTextControl::clearText() { TextControl::clearText(); currentAnchor=-1; anchorPositions.clear(); } void VerseTextControl::addAnchoredText(UString text, int anchor) { anchorPositions[anchor]=buffer.length(); addText(text); } void VerseTextControl::gotoAnchor(int anchor) { currentAnchor=anchor; refreshScreen(); } #endif