patch: tab leaders


Subject: patch: tab leaders
From: Patrick Lam (plam@plam.lcs.mit.edu)
Date: Wed Mar 28 2001 - 00:15:57 CST


Hi,

This will hopefully ZAP the POW from January 21.

Index: src/text/fmt/xp/fl_BlockLayout.cpp
===================================================================
RCS file: /cvsroot/abi/src/text/fmt/xp/fl_BlockLayout.cpp,v
retrieving revision 1.276
diff -u -r1.276 fl_BlockLayout.cpp
--- src/text/fmt/xp/fl_BlockLayout.cpp 2001/03/27 04:59:08 1.276
+++ src/text/fmt/xp/fl_BlockLayout.cpp 2001/03/28 06:11:53
@@ -336,7 +336,7 @@
                         UT_ASSERT(iPosLen < sizeof pszPosition);
 
                         memcpy(pszPosition, pStart, iPosLen);
- pszPosition[iPosLen] = 0;
+ pszPosition[iPosLen] = 0;
 
                         iPosition = pG->convertDimension(pszPosition);
 
@@ -4357,6 +4357,7 @@
                 {
                         iPosition = pTab->getPosition();
                         iType = pTab->getType();
+ iLeader = pTab->getLeader();
 
                         return true;
                 }
@@ -4415,8 +4416,6 @@
         UT_uint32 iCountTabs = m_vecTabs.getItemCount();
         UT_uint32 i;
 
- UT_UNUSED(iLeader); // TODO FIXME
-
         for (i=0; i<iCountTabs; i++)
         {
                 fl_TabStop* pTab = (fl_TabStop*) m_vecTabs.getNthItem(i);
@@ -4430,6 +4429,7 @@
                 {
                         iPosition = pTab->getPositionLayoutUnits();
                         iType = pTab->getType();
+ iLeader = pTab->getLeader();
 
                         return true;
                 }
Index: src/text/fmt/xp/fp_Line.cpp
===================================================================
RCS file: /cvsroot/abi/src/text/fmt/xp/fp_Line.cpp,v
retrieving revision 1.93
diff -u -r1.93 fp_Line.cpp
--- src/text/fmt/xp/fp_Line.cpp 2001/03/25 08:04:31 1.93
+++ src/text/fmt/xp/fp_Line.cpp 2001/03/28 06:11:56
@@ -783,6 +783,8 @@
                         int iScanWidth = 0;
                         int iScanWidthLayoutUnits = 0;
 
+ pTabRun->setLeader(iTabLeader);
+
                         // for everybody except the left tab, we need to know how much text is to follow
                         switch ( iTabType )
                         {
Index: src/text/fmt/xp/fp_Run.cpp
===================================================================
RCS file: /cvsroot/abi/src/text/fmt/xp/fp_Run.cpp,v
retrieving revision 1.152
diff -u -r1.152 fp_Run.cpp
--- src/text/fmt/xp/fp_Run.cpp 2001/03/27 05:38:24 1.152
+++ src/text/fmt/xp/fp_Run.cpp 2001/03/28 06:12:01
@@ -665,6 +665,18 @@
         m_iWidth = iWidth;
 }
 
+void fp_TabRun::setLeader(eTabLeader iLeader)
+{
+ clearScreen();
+ m_leader = iLeader;
+}
+
+eTabLeader fp_TabRun::getLeader(void)
+{
+ return m_leader;
+}
+
+
 void fp_TabRun::_clearScreen(bool /* bFullLineHeightRect */)
 {
         UT_ASSERT(!m_bDirty);
@@ -741,6 +753,52 @@
         UT_uint32 iRunBase = m_pBL->getPosition() + m_iOffsetFirst;
 #endif
 
+ if (m_leader != FL_LEADER_NONE || 1)
+ {
+ UT_UCSChar tmp[151];
+ unsigned short wid[151];
+ int i, cumWidth;
+
+ tmp[0] = 150;
+ switch (m_leader)
+ {
+ case FL_LEADER_DOT:
+ tmp[1] = '.';
+ break;
+ case FL_LEADER_HYPHEN:
+ tmp[1] = '-';
+ break;
+ case FL_LEADER_UNDERLINE:
+ tmp[1] = '_';
+ break;
+ default:
+ tmp[1] = 'q';
+ break;
+ }
+
+ for (i = 2; i < 151; i++)
+ tmp[i] = tmp[1];
+
+ m_pG->setFont(m_pScreenFont);
+ m_pG->measureString(tmp, 1, 150, wid);
+ // one would think that one could measure
+ // one character and divide the needed
+ // width by that; would one be so wrong?
+ // we're not dealing with different letters
+ // here, after all.
+
+ i = 1;
+ cumWidth = 0;
+ while (cumWidth < m_iWidth && i < 151)
+ cumWidth += wid[i++];
+
+ i = (i>=3) ? i - 2 : 1;
+
+ UT_RGBColor clrBlack = UT_RGBColor(0,0,0);
+ m_pG->setColor(clrBlack);
+ m_pG->drawChars(tmp, 1, i, pDA->xoff, iFillTop);
+ }
+ else
         if (
                 pView->getFocus()!=AV_FOCUS_NONE &&
                 (iSel1 <= iRunBase)
Index: src/text/fmt/xp/fp_Run.h
===================================================================
RCS file: /cvsroot/abi/src/text/fmt/xp/fp_Run.h,v
retrieving revision 1.77
diff -u -r1.77 fp_Run.h
--- src/text/fmt/xp/fp_Run.h 2001/03/25 19:19:18 1.77
+++ src/text/fmt/xp/fp_Run.h 2001/03/28 06:12:03
@@ -31,8 +31,8 @@
 #include "pt_Types.h"
 #include "ut_assert.h"
 #include "ap_Strings.h"
+#include "fl_BlockLayout.h"
 
-
 class UT_GrowBuf;
 class fl_BlockLayout;
 class fp_Line;
@@ -260,10 +260,13 @@
         virtual bool canBreakAfter(void) const;
         virtual bool canBreakBefore(void) const;
         virtual bool letPointPass(void) const;
- void setWidth(UT_sint32);
-
+ void setWidth(UT_sint32);
+ void setLeader(eTabLeader);
+ eTabLeader getLeader(void);
+
 protected:
         UT_RGBColor m_colorFG;
+ eTabLeader m_leader;
 
         virtual void _drawArrow(UT_uint32 iLeft,UT_uint32 iTop,UT_uint32 iWidth, UT_uint32 iHeight);
         virtual void _draw(dg_DrawArgs*);
Index: src/wp/ap/beos/ap_BeOSDialog_Tab.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/beos/ap_BeOSDialog_Tab.cpp,v
retrieving revision 1.4
diff -u -r1.4 ap_BeOSDialog_Tab.cpp
--- src/wp/ap/beos/ap_BeOSDialog_Tab.cpp 2001/02/06 22:54:42 1.4
+++ src/wp/ap/beos/ap_BeOSDialog_Tab.cpp 2001/03/28 06:12:06
@@ -320,7 +320,7 @@
 
 eTabLeader AP_BeOSDialog_Tab::_gatherLeader()
 {
- return FL_LEADER_NONE;
+ return m_current_leader;
 }
 
 void AP_BeOSDialog_Tab::_setLeader( eTabLeader a )
@@ -348,6 +348,8 @@
         
         if(pButton)
                 pButton->SetValue(1);
+
+ m_current_leader = a;
 }
 
 const XML_Char * AP_BeOSDialog_Tab::_gatherDefaultTabStop()
Index: src/wp/ap/unix/ap_UnixDialog_Tab.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/unix/ap_UnixDialog_Tab.cpp,v
retrieving revision 1.12
diff -u -r1.12 ap_UnixDialog_Tab.cpp
--- src/wp/ap/unix/ap_UnixDialog_Tab.cpp 2001/02/28 04:40:32 1.12
+++ src/wp/ap/unix/ap_UnixDialog_Tab.cpp 2001/03/28 06:12:08
@@ -970,7 +970,7 @@
 
 eTabLeader AP_UnixDialog_Tab::_gatherLeader()
 {
- return FL_LEADER_NONE;
+ return m_current_leader;
 }
 
 void AP_UnixDialog_Tab::_setLeader( eTabLeader a )
@@ -991,6 +991,8 @@
         m_bInSetCall = true;
         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(w), TRUE );
         m_bInSetCall = false;
+
+ m_current_leader = a;
 }
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
Index: src/wp/ap/xp/ap_Dialog_Tab.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/xp/ap_Dialog_Tab.cpp,v
retrieving revision 1.12
diff -u -r1.12 ap_Dialog_Tab.cpp
--- src/wp/ap/xp/ap_Dialog_Tab.cpp 2001/02/06 22:54:58 1.12
+++ src/wp/ap/xp/ap_Dialog_Tab.cpp 2001/03/28 06:12:11
@@ -158,12 +158,6 @@
         // alignment
         _controlEnable( id_ALIGN_BAR, false );
 
- // leaders
- _controlEnable( id_LEADER_NONE, false );
- _controlEnable( id_LEADER_DOT, false );
- _controlEnable( id_LEADER_DASH, false );
- _controlEnable( id_LEADER_UNDERLINE, false );
-
         // buttons
         _controlEnable( id_BUTTON_SET, false );
         _controlEnable( id_BUTTON_CLEAR, false );
@@ -198,6 +192,7 @@
                 // again. Here, since enum is rel 0, i'm subtracting one and doing an
                 // ugly type cast
                 _setAlignment( pTabInfo->getType() );
+ _setLeader( pTabInfo->getLeader() );
 
                 _setTabEdit( _getTabDimensionString(index) );
                 
@@ -254,7 +249,7 @@
         }
         strcat(p_temp, buffer);
         delete m_pszTabStops;
- m_pszTabStops = p_temp;;
+ m_pszTabStops = p_temp;
 
         UT_ASSERT(m_pFrame); // needs to be set from runModal for some of the event_'s to work
 
@@ -412,15 +407,14 @@
 }
 
 
-void AP_Dialog_Tab::buildTab( char *buffer, UT_uint32 /*bufflen*/ )
+void AP_Dialog_Tab::buildTab( char *buffer, UT_uint32 bufflen )
 {
         // get current value from member
         const XML_Char* szOld = _gatherTabEdit();
         const XML_Char* szNew = UT_reformatDimensionString(m_dim, szOld);
-
- // TODO - use snprintf
 
- sprintf( buffer, "%s/%c", szNew, AlignmentToChar(_gatherAlignment()));
+ snprintf( buffer, bufflen, "%s/%c%c", szNew, AlignmentToChar(_gatherAlignment()),
+ ((char)_gatherLeader())+'0');
 }
 
 void AP_Dialog_Tab::_event_somethingChanged()
@@ -436,10 +430,13 @@
         bool bEnableSet = true; // only disabled if current selection exactly matches current ones
                                                                                 // or there are no items in the list.
 
+// this just looks broken for the initial tab thingie.
+#if 0
         if(m_tabInfo.getItemCount() == 0)
         {
                 bEnableSet = false;
         }
+#endif
 
         for ( UT_uint32 i = 0; i < m_tabInfo.getItemCount(); i++ )
         {



This archive was generated by hypermail 2b25 : Wed Mar 28 2001 - 00:22:16 CST