Index: src/wp/ap/xp/ap_LeftRuler.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/xp/ap_LeftRuler.cpp,v retrieving revision 1.33 diff -u -r1.33 ap_LeftRuler.cpp --- src/wp/ap/xp/ap_LeftRuler.cpp 2001/04/22 04:08:48 1.33 +++ src/wp/ap/xp/ap_LeftRuler.cpp 2001/04/22 08:10:27 @@ -96,6 +96,9 @@ UT_ASSERT(m_pG); m_pG->setZoomPercentage(iZoom); + + // TODO this dimension shouldn't be hard coded. + m_minPageLength = m_pG->convertDimension("0.5in"); } void AP_LeftRuler::setView(AV_View * pView) @@ -250,6 +253,15 @@ m_draggingWhat = DW_NOTHING; return; } + + const XML_Char * properties[3]; + + FV_View * fv = static_cast(m_pView); + bool hdrftr = fv->isHdrFtrEdit(); + + bool hdr = hdrftr && fv->getEditShadow()->getHdrFtrSectionLayout()->getHFType() == FL_HDRFTR_HEADER; + + double dxrel; switch (m_draggingWhat) { @@ -259,42 +271,45 @@ case DW_TOPMARGIN: { - double dxrel = tick.scalePixelDistanceToUnits(m_draggingCenter - yAbsTop); - - const XML_Char * properties[3]; - properties[0] = "page-margin-top"; - properties[1] = m_pG->invertDimension(tick.dimType,dxrel); - properties[2] = 0; - UT_DEBUGMSG(("LeftRuler: page-margin-top [%s]\n",properties[1])); - - _xorGuide(true); - m_draggingWhat = DW_NOTHING; - FV_View *pView = static_cast(m_pView); - pView->setSectionFormat(properties); + dxrel = tick.scalePixelDistanceToUnits(m_draggingCenter - yAbsTop); + if (!hdrftr || !hdr) + properties[0] = "page-margin-top"; + else + properties[0] = "page-margin-header"; } - return; + break; case DW_BOTTOMMARGIN: { - UT_sint32 yOrigin = m_infoCache.m_yPageStart + m_infoCache.m_yTopMargin - m_yScrollOffset; - UT_sint32 yEnd = yOrigin - m_infoCache.m_yTopMargin + m_infoCache.m_yPageSize; + UT_sint32 yOrigin = m_infoCache.m_yPageStart + + m_infoCache.m_yTopMargin - m_yScrollOffset; + UT_sint32 yEnd = yOrigin - m_infoCache.m_yTopMargin + + m_infoCache.m_yPageSize; + + dxrel = tick.scalePixelDistanceToUnits(yEnd - m_draggingCenter); + if (!hdrftr || hdr) + properties[0] = "page-margin-bottom"; + else + properties[0] = "page-margin-footer"; + } + break; + } - double dxrel = tick.scalePixelDistanceToUnits(yEnd - m_draggingCenter); + properties[1] = m_pG->invertDimension(tick.dimType,dxrel); + properties[2] = 0; - const XML_Char * properties[3]; - properties[0] = "page-margin-bottom"; - properties[1] = m_pG->invertDimension(tick.dimType,dxrel); - properties[2] = 0; - UT_DEBUGMSG(("LeftRuler: page-margin-bottom [%s]\n",properties[1])); - - _xorGuide(true); - m_draggingWhat = DW_NOTHING; - FV_View *pView = static_cast(m_pView); - pView->setSectionFormat(properties); - } - return; + UT_DEBUGMSG(("LeftRuler: %s [%s]\n",properties[0], properties[1])); + _xorGuide(true); + m_draggingWhat = DW_NOTHING; + FV_View *pView = static_cast(m_pView); + if (!hdrftr) + pView->setSectionFormat(properties); + else + { + // i give up! how do we set the properties?!?! - PL } + return; } /*****************************************************************/ @@ -308,7 +323,7 @@ m_bEventIgnored = false; - UT_DEBUGMSG(("mouseMotion: [ems 0x%08lx][x %ld][y %ld]\n",ems,x,y)); +// UT_DEBUGMSG(("mouseMotion: [ems 0x%08lx][x %ld][y %ld]\n",ems,x,y)); ap_RulerTicks tick(m_pG,m_dim); // if they drag vertically off the ruler, we ignore the whole thing. @@ -344,6 +359,34 @@ m_draggingCenter = tick.snapPixelToGrid(y); + // bounds checking for end-of-page + + if (m_draggingCenter < yAbsTop) + m_draggingCenter = yAbsTop; + + if (m_draggingCenter > (UT_sint32)(yAbsTop + m_infoCache.m_yPageSize)) + m_draggingCenter = yAbsTop + m_infoCache.m_yPageSize; + + UT_sint32 effectiveSize; + UT_sint32 yOrigin = m_infoCache.m_yPageStart + m_infoCache.m_yTopMargin; + UT_sint32 yEnd = yOrigin - m_infoCache.m_yTopMargin + + m_infoCache.m_yPageSize - m_infoCache.m_yBottomMargin; + if (m_draggingWhat == DW_TOPMARGIN) + { + UT_sint32 rel = m_draggingCenter + m_yScrollOffset; + effectiveSize = yEnd - rel; + } + else + { + UT_sint32 rel = m_draggingCenter + m_yScrollOffset; + effectiveSize = rel - yOrigin; + } + +// UT_DEBUGMSG(("effective size %d, limit %d\n", effectiveSize, m_minPageLength)); + + if (effectiveSize < m_minPageLength) + m_draggingCenter = oldDragCenter; + if(m_draggingCenter == oldDragCenter) { // Position not changing so finish here. @@ -357,7 +400,7 @@ // Display in margin in status bar. - double dyrel = tick.scalePixelDistanceToUnits(m_draggingCenter - yAbsTop); +// double dyrel = tick.scalePixelDistanceToUnits(m_draggingCenter - yAbsTop); // UT_sint32 newMargin = m_draggingCenter - yAbsTop; // _displayStatusMessage(AP_STRING_ID_LeftMarginStatus, tick, dxrel); Index: src/wp/ap/xp/ap_LeftRuler.h =================================================================== RCS file: /cvsroot/abi/src/wp/ap/xp/ap_LeftRuler.h,v retrieving revision 1.15 diff -u -r1.15 ap_LeftRuler.h --- src/wp/ap/xp/ap_LeftRuler.h 2001/04/22 04:08:48 1.15 +++ src/wp/ap/xp/ap_LeftRuler.h 2001/04/22 08:10:27 @@ -153,6 +153,8 @@ bool m_bValidMouseClick; bool m_bEventIgnored; + + UT_sint32 m_minPageLength; }; #endif /* AP_LEFTRULER_H */ Index: src/wp/ap/xp/ap_TopRuler.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/xp/ap_TopRuler.cpp,v retrieving revision 1.102 diff -u -r1.102 ap_TopRuler.cpp --- src/wp/ap/xp/ap_TopRuler.cpp 2001/04/22 04:08:48 1.102 +++ src/wp/ap/xp/ap_TopRuler.cpp 2001/04/22 08:10:28 @@ -1516,7 +1516,7 @@ m_bEventIgnored = false; - UT_DEBUGMSG(("mouseMotion: [ems 0x%08lx][x %ld][y %ld]\n",ems,x,y)); +// UT_DEBUGMSG(("mouseMotion: [ems 0x%08lx][x %ld][y %ld]\n",ems,x,y)); // if they drag vertically off the ruler, we ignore the whole thing.