Changeset 19 for trunk


Ignore:
Timestamp:
May 9, 2006, 3:03:18 PM (15 years ago)
Author:
Eugene Romanenko
Message:

text search in continuous view works now

Location:
trunk/Lucide/SOURCE/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Lucide/SOURCE/gui/docViewer.cpp

    r18 r19  
    310310            if ( _this->foundrects[i]->_length > 0 ) {
    311311                RECTL r;
    312                 _this->docPosToWinPos( 0, &(_this->foundrects[i]->_buffer[0]), &r );
     312                _this->docPosToWinPos( i, &(_this->foundrects[i]->_buffer[0]), &r );
    313313                _this->scrollToPos( _this->hWndDoc, NULLHANDLE, r.xLeft, r.yBottom, false );
    314314            }
     
    620620                HPS hps = WinGetPS( _this->hWndDoc );
    621621                if ( hps != NULLHANDLE ) {
    622                     if ( !_this->continuous )   // TODO: continuous
     622                    for ( int i = 0; i < _this->drawareas->size(); i++ )
    623623                    {
    624                         for ( int i = 0; i < _this->drawareas->size(); i++ )
    625                         {
    626                             PageDrawArea *pda = &(*_this->drawareas)[ i ];
    627 
    628                             _this->drawSelection( hps, &pda->drawrect );
    629                             _this->drawFound( hps, &pda->drawrect );
    630                         }
     624                        PageDrawArea *pda = &(*_this->drawareas)[ i ];
     625
     626                        // TODO: continuous
     627                        //_this->drawSelection( hps, &pda->drawrect );
     628                        _this->drawFound( pda->pagenum, hps, &pda->drawrect );
    631629                    }
    632630                    WinReleasePS( hps );
     
    815813                     aptlPoints, lRop, BBO_IGNORE );
    816814
    817         drawSelection( hpsBuffer, &rclDraw );
    818         drawFound( hpsBuffer, &rclDraw );
     815        drawSelection( currentpage, hpsBuffer, &rclDraw );
     816        drawFound( currentpage, hpsBuffer, &rclDraw );
    819817
    820818        BlitGraphicsBuffer( hps, hpsBuffer, &rcl );
     
    962960        // TODO
    963961        //drawSelection( hpsBuffer, &rclDraw );
    964         //drawFound( hpsBuffer, &rclDraw );
     962        drawFound( pda->pagenum, hpsBuffer, &pda->drawrect );
    965963
    966964        delete pixbuf;
     
    986984
    987985// converts document position to window position
    988 void DocumentViewer::docPosToWinPos( long pagenum, LuRectangle *r, PRECTL rcl )
    989 {
    990     if ( continuous )
    991     {
    992         double yplus = pagenumToPos( pagenum );
    993 
    994         rcl->xLeft   = ( r->x1 * realzoom ) - sHscrollPos;
    995         rcl->yBottom = cyClient - ( ( yplus + r->y2 ) * realzoom ) +
    996                             ( sVscrollPos * VScrollStep );
    997         rcl->xRight  = ( r->x2 * realzoom ) - sHscrollPos;
    998         rcl->yTop    = cyClient - ( ( yplus + r->y1 ) * realzoom ) +
    999                             ( sVscrollPos * VScrollStep );
    1000     }
    1001     else
    1002     {
    1003         rcl->xLeft   = ( r->x1 * realzoom ) - sHscrollPos;
    1004         rcl->yBottom = cyClient - ( r->y2 * realzoom ) + sVscrollPos;
    1005         rcl->xRight  = ( r->x2 * realzoom ) - sHscrollPos;
    1006         rcl->yTop    = cyClient - ( r->y1 * realzoom ) + sVscrollPos;
    1007     }
     986void DocumentViewer::docPosToWinPos( long pagenum, LuRectangle *r, PRECTL rcl, bool useZoom )
     987{
     988    double scale = useZoom ? realzoom : 1.0;
     989    double yplus = continuous ? pagenumToPos( pagenum ) : 0;
     990
     991    rcl->xLeft   = ( r->x1 * scale ) - sHscrollPos;
     992    rcl->yBottom = cyClient - ( yplus + ( r->y2 * scale ) ) + ( sVscrollPos * VScrollStep );
     993    rcl->xRight  = ( r->x2 * scale ) - sHscrollPos;
     994    rcl->yTop    = cyClient - ( yplus + ( r->y1 * scale ) ) + ( sVscrollPos * VScrollStep );
    1008995}
    1009996
    1010997// creates region from sequence of rectangles
    1011 HRGN DocumentViewer::rectsToRegion( HPS hps, LuDocument_LuRectSequence *rects, bool useScale )
     998HRGN DocumentViewer::rectsToRegion( long pagenum, HPS hps,
     999                                    LuDocument_LuRectSequence *rects, bool useZoom )
    10121000{
    10131001    HRGN hrgn = GpiCreateRegion( hps, 0, NULL );
     
    10171005        for ( int i = 0; i < rects->_length; i++ )
    10181006        {
    1019             if ( useScale ) {
    1020                 docPosToWinPos( 0, &(rects->_buffer[i]), &r );
    1021             }
    1022             else
    1023             {
    1024                 r.xLeft = rects->_buffer[i].x1 - sHscrollPos;
    1025                 r.yBottom = cyClient - rects->_buffer[i].y2 + sVscrollPos;
    1026                 r.xRight = rects->_buffer[i].x2 - sHscrollPos;
    1027                 r.yTop = cyClient - rects->_buffer[i].y1 + sVscrollPos;
    1028             }
     1007            docPosToWinPos( pagenum, &(rects->_buffer[i]), &r, useZoom );
    10291008            HRGN tmprgn = GpiCreateRegion( hps, 1, &r );
    10301009            GpiCombineRegion( hps, hrgn, hrgn, tmprgn, CRGN_OR );
     
    10371016// draws selected area in window, using XOR mix
    10381017// drawing area may be restricted by r rectangle
    1039 void DocumentViewer::drawSelection( HPS hps, PRECTL r )
     1018void DocumentViewer::drawSelection( long pagenum, HPS hps, PRECTL r )
    10401019{
    10411020    GpiSetMix( hps, FM_XOR );
    10421021    GpiSetColor( hps, CLR_YELLOW );
    1043     HRGN selectRegion = rectsToRegion( hps, selrects, false );
     1022    HRGN selectRegion = rectsToRegion( pagenum, hps, selrects, false );
    10441023    if ( r != NULL )
    10451024    {
     
    10521031}
    10531032
    1054 void DocumentViewer::drawFound( HPS hps, PRECTL r )
     1033void DocumentViewer::drawFound( long pagenum, HPS hps, PRECTL r )
    10551034{
    10561035    GpiSetMix( hps, FM_XOR );
    10571036    GpiSetColor( hps, CLR_CYAN );
    1058     HRGN selectRegion = rectsToRegion( hps, foundrects[ currentpage ], true );
     1037    HRGN selectRegion = rectsToRegion( pagenum, hps, foundrects[ pagenum ], true );
    10591038    if ( r != NULL )
    10601039    {
     
    10681047
    10691048// scrolls window to specified pos (optionally with text selection)
    1070 void DocumentViewer::scrollToPos( HWND hwnd, HRGN hrgn, SHORT xpos, SHORT ypos,
     1049void DocumentViewer::scrollToPos( HWND hwnd, HRGN hrgn, LONG xpos, LONG ypos,
    10711050                                  bool withSelection )
    10721051{
     
    10801059    }
    10811060    if ( ( ypos < 0 ) && ( sVscrollPos < sVscrollMax ) ) {
    1082         yinc = __min( sVscrollMax - sVscrollPos, ypos * -1 );
     1061        yinc = __min( ( sVscrollMax - sVscrollPos ) * VScrollStep, ypos * -1 );
    10831062    }
    10841063    else if ( ( ypos > cyClient ) && ( sVscrollPos > 0 ) ) {
    1085         yinc = __max( sVscrollPos * -1, cyClient - ypos );
     1064        yinc = __max( ( sVscrollPos * -1 ) * VScrollStep, cyClient - ypos );
    10861065    }
    10871066
     
    10931072    }
    10941073    if ( yinc != 0 ) {
    1095         vertScroll( hwnd, MPFROM2SHORT( sVscrollPos + yinc, SB_SLIDERPOSITION ), hrgn );
     1074        vertScroll( hwnd, MPFROM2SHORT( ( ( sVscrollPos * VScrollStep ) + yinc ) / VScrollStep,
     1075                                        SB_SLIDERPOSITION ), hrgn );
    10961076        if ( withSelection ) {
    10971077            selectionStart.y += yinc;
     
    11321112        //GpiSetColor( hps, 100 );
    11331113
    1134         HRGN clearRegion = rectsToRegion( hps, selrects, false );
     1114        HRGN clearRegion = rectsToRegion( currentpage, hps, selrects, false );
    11351115        LuDocument::freeRectangles( ev, selrects );
    11361116        if ( ( selectionStart.x == selectionEnd.x ) &&
     
    11411121            selrects = doc->getSelectionRectangles( ev, currentpage, realzoom, &selection );
    11421122        }
    1143         HRGN selectRegion = rectsToRegion( hps, selrects, false );
     1123        HRGN selectRegion = rectsToRegion( currentpage, hps, selrects, false );
    11441124        GpiCombineRegion( hps, selectRegion, selectRegion, clearRegion, CRGN_XOR );
    11451125        //GpiCombineRegion( hps, selectRegion, selectRegion, scrolledRegion, CRGN_DIFF );
  • trunk/Lucide/SOURCE/gui/docViewer.h

    r18 r19  
    5959        BOOL wmChar( HWND hwnd, MPARAM mp1, MPARAM mp2 );
    6060        void winPosToDocPos( PPOINTL startpoint, PPOINTL endpoint, LuRectangle *r );
    61         void docPosToWinPos( long pagenum, LuRectangle *r, PRECTL rcl );
    62         HRGN rectsToRegion( HPS hps, LuDocument_LuRectSequence *rects, bool useScale );
    63         void drawSelection( HPS hps, PRECTL r );
    64         void scrollToPos( HWND hwnd, HRGN hrgn, SHORT xpos, SHORT ypos, bool withSelection );
     61        void docPosToWinPos( long pagenum, LuRectangle *r, PRECTL rcl, bool useZoom = true );
     62        HRGN rectsToRegion( long pagenum, HPS hps, LuDocument_LuRectSequence *rects, bool useZoom );
     63        void drawSelection( long pagenum, HPS hps, PRECTL r );
     64        void scrollToPos( HWND hwnd, HRGN hrgn, LONG xpos, LONG ypos, bool withSelection );
    6565        void freeFoundrects();
    6666        void freeLinks();
    67         void drawFound( HPS hps, PRECTL r );
     67        void drawFound( long pagenum, HPS hps, PRECTL r );
    6868        DrawAreas *foundDrawAreas( PRECTL r );
    6969        void determineCurrentPage();
Note: See TracChangeset for help on using the changeset viewer.