Paul,
> This may not be that bad.
>
> After drawing the entire run, scan the characters you just drew to see
> whether any of them are spaces. If so, do another drawing pass which draws
> dot characters "over" the space characters. Because we store the width of
> each character, you should be able to position those dots correctly.
Oki, I did it as you suggested and it works for me(tm). You are right, it was
not hard.
> Do you want to draw all the way from the left of the page to the right? If
This is solved, too (thanks for the pointer).
State of my little Project is currently: The toggleButton in the menu is there
and works (well, mostly, see my question on this issue), forceLineBreaks, Tabs
and Spaces are drawn with special Charackters. No funky P's, yet.
Ok, more questions.
You suggested in the POW 19.12, that the bShowParagraphs should be stored
inside a View. I did it this way, but if I choose "zoom", a new View
will be created and "ShowParagraphs" will be reseted. Can I do something
against this ? Or should I store bShowParagraphs in a Frame (like
bShowRuler) ?
I implemented the forcePageBreaks as a soild line. When I scroll a lot, the line
is not (re)drawn correctly. I'm not sure if I can blame my code, or the code
that does the scrolling (I will dig into this, I just want to be sure, that
this is not a known bug).
The Tabs and Spaces are drawn as special Latin1 Charackters. Can I savely
assume that every font has a Latin1 mapping (I think, the "Dingbats" hasn't) ?
> >I'm quite new to the source of AbiWord and hope, my questions aren't to
> >stupid :)
> You're doing fine. Anybody asking such detailed questions about specific
> spots in the code is going to find their way around quickly enough. :-)
Well, I hope so.
> Welcome aboard!
Thanks :-)
> Paul
Michael
P.S. I attach a patch against 0.7.7. It implents everythink I described above
(including the bugs, of cource). It's not alway conform with the programming
guidlines. I will fix this in my next patch.
--
GPG Fingerprint = EA71 B296 4597 4D8B 343E 821E 9624 83E1 5662 C734
/"\ o
\ / ASCII RIBBON CAMPAIGN /|\
X AGAINST HTML MAIL >>
/ \ o
--- abi-0.7.7/src/text/fmt/xp/fp_Run.cpp Wed Sep 22 23:59:33 1999
+++ ../abiword-0.7.7/abi-0.7.7/src/text/fmt/xp/fp_Run.cpp Sun Jan 23 19:05:17
+2000
@@ -362,34 +362,42 @@
void fp_TabRun::_draw(dg_DrawArgs* pDA)
{
UT_ASSERT(pDA->pG == m_pG);
-
- UT_RGBColor clrSelBackground(192, 192, 192);
- UT_RGBColor clrNormalBackground(255,255,255);
-
- UT_sint32 iFillHeight = m_pLine->getHeight();
- UT_sint32 iFillTop = pDA->yoff - m_pLine->getAscent();
-
FV_View* pView = m_pBL->getDocLayout()->getView();
- UT_uint32 iSelAnchor = pView->getSelectionAnchor();
- UT_uint32 iPoint = pView->getPoint();
+ UT_ASSERT(pView != NULL);
- UT_uint32 iSel1 = UT_MIN(iSelAnchor, iPoint);
- UT_uint32 iSel2 = UT_MAX(iSelAnchor, iPoint);
-
- UT_ASSERT(iSel1 <= iSel2);
-
- UT_uint32 iRunBase = m_pBL->getPosition() + m_iOffsetFirst;
+ if( pView->getShowPara() ) {
+ UT_RGBColor clrSelBackground(192, 192, 192);
+ UT_RGBColor clrNormalBackground(255,255,255);
+ UT_RGBColor tabColor(128,128,128);
- if (
- (iSel1 <= iRunBase)
- && (iSel2 > iRunBase)
- )
- {
- m_pG->fillRect(clrSelBackground, pDA->xoff, iFillTop, m_iWidth,
iFillHeight);
- }
- else
- {
- m_pG->fillRect(clrNormalBackground, pDA->xoff, iFillTop, m_iWidth,
iFillHeight);
+ UT_sint32 iFillHeight = m_pLine->getHeight();
+ UT_sint32 iFillTop = pDA->yoff - m_pLine->getAscent();
+
+ FV_View* pView = m_pBL->getDocLayout()->getView();
+ UT_uint32 iSelAnchor = pView->getSelectionAnchor();
+ UT_uint32 iPoint = pView->getPoint();
+
+ UT_uint32 iSel1 = UT_MIN(iSelAnchor, iPoint);
+ UT_uint32 iSel2 = UT_MAX(iSelAnchor, iPoint);
+
+ UT_ASSERT(iSel1 <= iSel2);
+
+ UT_uint32 iRunBase = m_pBL->getPosition() + m_iOffsetFirst;
+ UT_UCSChar tabCh = 0xBB; // char ">>" in Latin1 (is this
+
+ if (
+ (iSel1 <= iRunBase)
+ && (iSel2 > iRunBase)
+ )
+ {
+ m_pG->fillRect(clrSelBackground, pDA->xoff, iFillTop, m_iWidth,
+iFillHeight);
+ }
+ else
+ {
+ m_pG->fillRect(clrNormalBackground, pDA->xoff, iFillTop, m_iWidth,
+iFillHeight);
+ }
+ m_pG->setColor(tabColor);
+ m_pG->drawChars(&tabCh,0, 1, pDA->xoff, iFillTop);
}
}
@@ -469,6 +477,15 @@
void fp_ForcedLineBreakRun::_draw(dg_DrawArgs* pDA)
{
UT_ASSERT(pDA->pG == m_pG);
+ // FIXME: implement this
+ /*
+ UT_RGBColor lineBreakColor(128,128,128);
+ UT_UCSChar lineBreakCh = 0xAB; // char "<<" in Latin1
+
+ fprintf(stderr,"lineBreak! xoff: %i, yoff: %i \n",pDA->xoff,pDA->yoff);
+ m_pG->setColor(lineBreakColor);
+ m_pG->drawChars(&lineBreakCh,0, 1, pDA->xoff, pDA->yoff - m_iAscent);
+ */
}
//////////////////////////////////////////////////////////////////
@@ -900,7 +917,7 @@
m_pG->setFont(m_pFont);
m_pG->setColor(m_colorFG);
-
+
m_pG->drawChars(m_sFieldValue, 0, UT_UCS_strlen(m_sFieldValue), pDA->xoff,
pDA->yoff - m_iAscent);
}
@@ -976,6 +993,15 @@
void fp_ForcedColumnBreakRun::_draw(dg_DrawArgs* pDA)
{
UT_ASSERT(pDA->pG == m_pG);
+ // FIXME: Implement this
+ /*
+ UT_RGBColor columnBreakColor(128,128,128);
+ UT_UCSChar columnBreakCh = 0xA1; // char "!" in Latin1
+
+ fprintf(stderr,"columnBreak! xoff: %i, yoff: %i iAscent:
+%i\n",pDA->xoff,pDA->yoff, m_iAscent);
+ m_pG->setColor(columnBreakColor);
+ m_pG->drawChars(&columnBreakCh,0, 1, pDA->xoff, pDA->yoff - m_iAscent);
+ */
}
//////////////////////////////////////////////////////////////////
@@ -1040,10 +1066,41 @@
{
UT_ASSERT(!m_bDirty);
UT_ASSERT(m_pG->queryProperties(GR_Graphics::DGP_SCREEN));
+
+ // MICHAEL - FIXME: sometimes not everything is correct erased
+ UT_sint32 xoff = 0, yoff = 0;
+
+ // FIXME: is it more efficent to XOR the line ? Or is clearArea() better ?
+ // need to clear full height of line, in case we had a linebreak
+ m_pLine->getScreenOffsets(this, xoff, yoff);
+ UT_sint32 iLineHeight = m_pLine->getHeight();
+ // UT_sint32 iWidth = (m_pLine->getContainer())->getWidth();
+
+ FV_View* pView = m_pBL->getDocLayout()->getView();
+ UT_sint32 iXStart = pView->getPageViewLeftMargin() + 1;
+ UT_sint32 iXEnd = pView->getWindowWidth() + iXStart;
+
+ //fprintf(stderr, "iXStart: %i, iXEnd: %i \n",iXStart, iXEnd);
+ m_pG->clearArea(iXStart, yoff, iXEnd, iLineHeight);
}
void fp_ForcedPageBreakRun::_draw(dg_DrawArgs* pDA)
-{
- UT_ASSERT(pDA->pG == m_pG);
+{
+ UT_ASSERT(pDA->pG == m_pG);
+ FV_View* pView = m_pBL->getDocLayout()->getView();
+ UT_ASSERT(pView != NULL);
+
+ if( pView->getShowPara() ) {
+ UT_RGBColor pageBreakColor(128,128,128);
+ UT_sint32 iLineHeight = m_pLine->getHeight();
+
+ UT_sint32 iXStart = pView->getPageViewLeftMargin() + 1;
+ UT_sint32 iXEnd = pView->getWindowWidth() + iXStart;
+
+ // FIXME: sometimes iXEnd is far too big (2*regular iXEnd) Why?
+ // fprintf(stderr, "iXStart: %i, iXEnd: %i \n",iXStart, iXEnd);
+ m_pG->setColor(pageBreakColor);
+ m_pG->drawLine(iXStart, pDA->yoff - (iLineHeight/2) , iXEnd, pDA->yoff -
+(iLineHeight/2));
+ }
}
diff -u --recursive abi-0.7.7/src/text/fmt/xp/fp_TextRun.cpp
../abiword-0.7.7/abi-0.7.7/src/text/fmt/xp/fp_TextRun.cpp
--- abi-0.7.7/src/text/fmt/xp/fp_TextRun.cpp Wed Dec 1 04:02:30 1999
+++ ../abiword-0.7.7/abi-0.7.7/src/text/fmt/xp/fp_TextRun.cpp Sun Jan 23 19:06:56
+2000
@@ -652,6 +652,7 @@
UT_sint32 yTopOfRun = pDA->yoff - m_iAscent;
UT_sint32 yTopOfSel = yTopOfRun;
+
if (m_fPosition == TEXT_POSITION_SUPERSCRIPT)
{
@@ -712,7 +713,7 @@
_fillRect(clrSelBackground, pDA->xoff, yTopOfSel,
m_iOffsetFirst, iSel2 - iRunBase, pgbCharWidths);
_drawPart(pDA->xoff, yTopOfRun, m_iOffsetFirst, iSel2 -
iRunBase, pgbCharWidths);
-
+
_drawPart(pDA->xoff, yTopOfRun, iSel2 - iBase, m_iLen - (iSel2
- iRunBase), pgbCharWidths);
}
}
@@ -724,7 +725,7 @@
else
{
_drawPart(pDA->xoff, yTopOfRun, m_iOffsetFirst, iSel1 - iRunBase,
pgbCharWidths);
-
+
if (iSel2 >= (iRunBase + m_iLen))
{
_fillRect(clrSelBackground, pDA->xoff, yTopOfSel, iSel1 -
iBase, m_iLen - (iSel1 - iRunBase), pgbCharWidths);
@@ -734,11 +735,13 @@
{
_fillRect(clrSelBackground, pDA->xoff, yTopOfSel, iSel1 -
iBase, iSel2 - iSel1, pgbCharWidths);
_drawPart(pDA->xoff, yTopOfRun, iSel1 - iBase, iSel2 - iSel1,
pgbCharWidths);
-
_drawPart(pDA->xoff, yTopOfRun, iSel2 - iBase, m_iLen - (iSel2
- iRunBase), pgbCharWidths);
}
}
+ // MICHAEL: FIXME: better Name ?
+ if( pView->getShowPara() )
+ _drawDots(pDA->xoff, yTopOfRun, m_iOffsetFirst, m_iLen, pgbCharWidths);
_drawDecors(pDA->xoff, yTopOfRun);
// TODO: draw this underneath (ie, before) the text and decorations
@@ -810,6 +813,73 @@
}
}
+// MICHAEL: mostly a copy of _drawPart(). Is this ok ? Or is there a simpler way ?
+void fp_TextRun::_drawDots(UT_sint32 xoff,
+ UT_sint32 yoff,
+ UT_uint32 iStart,
+ UT_uint32 iLen,
+ const UT_GrowBuf * pgbCharWidths)
+{
+ const UT_UCSChar* pSpan;
+ UT_uint32 lenSpan;
+ UT_uint32 offset = iStart;
+ UT_uint32 len = iLen;
+ UT_Bool bContinue = UT_TRUE;
+
+ UT_UCSChar chDot = 0xB7; // nice "."
+ UT_RGBColor dotColor(128,128,128);
+
+ m_pG->setColor(dotColor);
+ // don't even try to draw a zero-length run
+ if (m_iLen == 0)
+ {
+ return;
+ }
+ UT_ASSERT(offset >= m_iOffsetFirst);
+ UT_ASSERT(offset + len <= m_iOffsetFirst + m_iLen);
+
+ UT_uint32 iLeftWidth = 0;
+ const UT_uint16 * pCharWidths = pgbCharWidths->getPointer(0);
+
+ UT_uint32 i;
+ for (i=m_iOffsetFirst; i<iStart; i++)
+ {
+ iLeftWidth += pCharWidths[i];
+ }
+
+ while (bContinue)
+ {
+ bContinue = m_pBL->getSpanPtr(offset, &pSpan, &lenSpan);
+ UT_ASSERT(lenSpan>0);
+
+ if (len <= lenSpan)
+ {
+ for(int i=0; i<len;i++)
+ {
+ if(pSpan[i] == UCS_SPACE)
+ m_pG->drawChars(&chDot, 0, 1, xoff + iLeftWidth, yoff);
+ iLeftWidth += pCharWidths[offset + i];
+ }
+ bContinue = UT_FALSE;
+ }
+ else
+ {
+ for(int i=0; i<lenSpan;i++)
+ {
+ if(pSpan[i] == UCS_SPACE)
+ m_pG->drawChars(&chDot, 0, 1, xoff + iLeftWidth, yoff);
+ iLeftWidth += pCharWidths[offset + i];
+ }
+ offset += lenSpan;
+ len -= lenSpan;
+
+ UT_ASSERT(offset >= m_iOffsetFirst);
+ UT_ASSERT(offset + len <= m_iOffsetFirst + m_iLen);
+ }
+ }
+}
+
+
void fp_TextRun::_drawPart(UT_sint32 xoff,
UT_sint32 yoff,
UT_uint32 iStart,
@@ -821,7 +891,7 @@
NOT the baseline.
*/
- const UT_UCSChar* pSpan;
+ const UT_UCSChar* pSpan;
UT_uint32 lenSpan;
UT_uint32 offset = iStart;
UT_uint32 len = iLen;
@@ -849,7 +919,7 @@
{
bContinue = m_pBL->getSpanPtr(offset, &pSpan, &lenSpan);
UT_ASSERT(lenSpan>0);
-
+
if (len <= lenSpan)
{
m_pG->drawChars(pSpan, 0, len, xoff + iLeftWidth, yoff);
diff -u --recursive abi-0.7.7/src/text/fmt/xp/fp_TextRun.h
../abiword-0.7.7/abi-0.7.7/src/text/fmt/xp/fp_TextRun.h
--- abi-0.7.7/src/text/fmt/xp/fp_TextRun.h Wed Dec 1 04:02:30 1999
+++ ../abiword-0.7.7/abi-0.7.7/src/text/fmt/xp/fp_TextRun.h Sun Jan 23 15:53:32
+2000
@@ -81,6 +81,12 @@
virtual void _clearScreen(UT_Bool bFullLineHeightRect);
void _drawDecors(UT_sint32, UT_sint32);
+ void _drawDots(UT_sint32 xoff,
+ UT_sint32
+yoff,
+ UT_uint32
+iStart,
+ UT_uint32
+iLen,
+ const
+UT_GrowBuf * pgbCharWidths);
+
void _drawSquiggle(UT_sint32 top, UT_sint32
left, UT_sint32 right);
void _getPartRect(UT_Rect* pRect,
diff -u --recursive abi-0.7.7/src/text/fmt/xp/fv_View.cpp
../abiword-0.7.7/abi-0.7.7/src/text/fmt/xp/fv_View.cpp
--- abi-0.7.7/src/text/fmt/xp/fv_View.cpp Thu Dec 9 00:14:31 1999
+++ ../abiword-0.7.7/abi-0.7.7/src/text/fmt/xp/fv_View.cpp Sun Jan 23 19:19:09
+2000
@@ -56,7 +56,6 @@
#include "sp_spell.h"
/****************************************************************/
-
class _fmtPair
{
public:
diff -u --recursive abi-0.7.7/src/text/fmt/xp/fv_View.h
../abiword-0.7.7/abi-0.7.7/src/text/fmt/xp/fv_View.h
--- abi-0.7.7/src/text/fmt/xp/fv_View.h Wed Dec 1 22:56:21 1999
+++ ../abiword-0.7.7/abi-0.7.7/src/text/fmt/xp/fv_View.h Sun Jan 23 19:13:30
+2000
@@ -156,6 +156,11 @@
void insertSectionBreak(void);
// ----------------------
+ // showParagraph stuff
+ UT_Bool getShowPara(void) { return m_bShowPara; };
+ void setShowPara(UT_Bool bShowPara) { m_bShowPara = bShowPara; };
+
+// ----------------------
UT_Bool isLeftMargin(UT_sint32 xPos, UT_sint32 yPos);
void cmdSelect(UT_sint32 xPos, UT_sint32 yPos, FV_DocPos
dpBeg, FV_DocPos dpEnd);
void cmdCharMotion(UT_Bool bForward, UT_uint32 count);
@@ -203,7 +208,7 @@
UT_Bool findAgain(void);
void findSetStartAtInsPoint(void);
-
+
// finds the next "find" and selects it, filling bool when done the entire
document
UT_Bool findNext(const UT_UCSChar * find, UT_Bool matchCase =
UT_TRUE, UT_Bool * bDoneEntireDocument = NULL);
UT_Bool _findNext(const UT_UCSChar * find, UT_Bool matchCase =
UT_TRUE, UT_Bool * bDoneEntireDocument = NULL);
@@ -314,6 +319,8 @@
fv_ChangeState m_chg;
+ // showPara
+ UT_Bool m_bShowPara;
// find and replace stuff
UT_Bool m_wrappedEnd;
PT_DocPosition m_startPosition;
diff -u --recursive abi-0.7.7/src/wp/ap/xp/ap_EditMethods.cpp
../abiword-0.7.7/abi-0.7.7/src/wp/ap/xp/ap_EditMethods.cpp
--- abi-0.7.7/src/wp/ap/xp/ap_EditMethods.cpp Sat Dec 4 06:15:11 1999
+++ ../abiword-0.7.7/abi-0.7.7/src/wp/ap/xp/ap_EditMethods.cpp Sun Jan 23 19:12:36
+2000
@@ -3725,14 +3725,14 @@
return UT_TRUE;
}
+// MICHAEL
Defun1(viewPara)
{
- XAP_Frame * pFrame = (XAP_Frame *) pAV_View->getParentData();
- UT_ASSERT(pFrame);
-
- // TODO: synch this implementation with ap_GetState_View
- s_TellNotImplemented(pFrame, "Show/Hide Paragraphs", __LINE__);
- return UT_TRUE;
+ // MICHAEL: FIXME: look at viewRuler(), improve this mess
+ ABIWORD_VIEW;
+ pView->setShowPara(!pView->getShowPara());
+ pView->draw();
+ return UT_TRUE;
}
Defun1(viewHeadFoot)
diff -u --recursive abi-0.7.7/src/wp/ap/xp/ap_Menu_Functions.cpp
../abiword-0.7.7/abi-0.7.7/src/wp/ap/xp/ap_Menu_Functions.cpp
--- abi-0.7.7/src/wp/ap/xp/ap_Menu_Functions.cpp Thu Dec 2 22:06:28 1999
+++ ../abiword-0.7.7/abi-0.7.7/src/wp/ap/xp/ap_Menu_Functions.cpp Sun Jan 23
+19:16:52 2000
@@ -515,9 +515,9 @@
AP_FrameData *pFrameData = (AP_FrameData *)pFrame->getFrameData();
UT_ASSERT(pFrameData);
-
+
EV_Menu_ItemState s = EV_MIS_ZERO;
-
+
switch(id)
{
@@ -529,6 +529,11 @@
break;
case AP_MENU_ID_VIEW_SHOWPARA:
+ if( pView->getShowPara() )
+ s = EV_MIS_Toggled;
+ else
+ s = EV_MIS_ZERO;
+ break;
case AP_MENU_ID_VIEW_HEADFOOT:
// TODO: implement view methods to check, toggle state
s = EV_MIS_Gray;