Changeset 23 for trunk/Lucide


Ignore:
Timestamp:
May 14, 2006, 1:12:27 PM (15 years ago)
Author:
Eugene Romanenko
Message:

text selection in continuous view fully works

Location:
trunk/Lucide/SOURCE
Files:
1 deleted
3 edited

Legend:

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

    r22 r23  
    44#include <os2.h>
    55
     6#include <string>
    67#include <process.h>
    78#include <stdio.h>
     
    7576    selectionStart.x = 0;  selectionStart.y = 0;
    7677    selectionEnd.x = 0;  selectionEnd.y = 0;
    77     selection.x1 = 0;  selection.y1 = 0;  selection.x2 = 0;  selection.y2 = 0;
     78    selection = NULL;
    7879    selrects = NULL;
    7980    // links
     
    126127    delete searchString;
    127128    delete pagesizes;
     129    delete selection;
    128130}
    129131
     
    147149    pagesizes   = NULL;
    148150
     151    delete selection;
     152    selection   = NULL;
     153
    149154    freeRects( foundrects );
    150155    delete foundrects;
     
    153158    freeRects( selrects );
    154159    delete selrects;
    155     selrects  = NULL;
     160    selrects    = NULL;
    156161
    157162    freeLinks();
     
    176181        links = new PLuLinkMapSequence[ totalpages ];
    177182        memset( links, 0, sizeof( PLuLinkMapSequence ) * totalpages );
     183
     184        selection = new LuRectangle[ totalpages ];
     185        memset( selection, 0, sizeof( LuRectangle ) * totalpages );
    178186
    179187        enableAsynchDraw = doc->isAsynchRenderingSupported( ev );
     
    260268void DocumentViewer::copyToClipbrd()
    261269{
    262     char *t = doc->getText( ev, currentpage, &selection );
    263     textToClipbrd( hab, t );
     270    if ( continuous )
     271    {
     272        std::string txt = "";
     273        for ( long i = 0; i < totalpages; i++ ) {
     274            if ( selrects[ i ] != NULL ) {
     275                txt += doc->getText( ev, i, &(selection[ i ]) );
     276            }
     277        }
     278        textToClipbrd( hab, txt.c_str() );
     279    }
     280    else {
     281        char *t = doc->getText( ev, currentpage, &(selection[ currentpage ]) );
     282        textToClipbrd( hab, t );
     283    }
    264284}
    265285
     
    969989                     aptlPoints, lRop, BBO_IGNORE );
    970990
    971         // TODO
    972991        drawSelection( pda->pagenum, hpsBuffer, &pda->drawrect );
    973992        drawFound( pda->pagenum, hpsBuffer, &pda->drawrect );
     
    10931112        }
    10941113    }
     1114    yinc = ( ( yinc / VScrollStep ) * VScrollStep );
    10951115    if ( yinc != 0 ) {
    10961116        vertScroll( hwnd, MPFROM2SHORT( ( ( sVscrollPos * VScrollStep ) + yinc ) / VScrollStep,
     
    11141134        if ( continuous )
    11151135        {
     1136            scrollToPos( hwnd, NULLHANDLE, xpos, ypos, true );
     1137
    11161138            RECTL selRect = {
    11171139                selectionStart.x < selectionEnd.x ? selectionStart.x : selectionEnd.x,
     
    11311153                PageDrawArea *pda = &(*areas)[ i ];
    11321154
    1133                 winPosToDocPos( pda, &selection );
     1155                winPosToDocPos( pda, &(selection[pda->pagenum]) );
    11341156
    11351157                HRGN clearRegion = rectsToRegion( pda->pagenum, hps, selrects[ pda->pagenum ], false );
    11361158                LuDocument::freeRectangles( ev, selrects[ pda->pagenum ] );
    1137                 selrects[ pda->pagenum ] = doc->getSelectionRectangles( ev, pda->pagenum, realzoom, &selection );
     1159                selrects[ pda->pagenum ] = doc->getSelectionRectangles( ev, pda->pagenum, realzoom, &(selection[pda->pagenum]) );
    11381160                HRGN selectRegion = rectsToRegion( pda->pagenum, hps, selrects[ pda->pagenum ], false );
    11391161                GpiCombineRegion( hps, selectRegion, selectRegion, clearRegion, CRGN_XOR );
     
    11481170        else
    11491171        {
    1150             winPosToDocPos( &selectionStart, &selectionEnd, &selection );
     1172            winPosToDocPos( &selectionStart, &selectionEnd, &(selection[currentpage]) );
    11511173
    11521174            HPS hps = WinGetPS( hwnd );
     
    11701192                 ( selectionStart.y == selectionEnd.y ) ) {
    11711193                selrects[ currentpage ] = NULL;
     1194                memset( &(selection[ currentpage ]), 0, sizeof( LuRectangle ) );
    11721195            }
    11731196            else {
    1174                 selrects[ currentpage ] = doc->getSelectionRectangles( ev, currentpage, realzoom, &selection );
     1197                selrects[ currentpage ] = doc->getSelectionRectangles( ev, currentpage, realzoom, &(selection[currentpage]) );
    11751198            }
    11761199            HRGN selectRegion = rectsToRegion( currentpage, hps, selrects[ currentpage ], false );
     
    13051328void DocumentViewer::wmButton1Down( HWND hwnd, SHORT xpos, SHORT ypos )
    13061329{
    1307     if ( continuous )
     1330    if ( continuous && ( doc != NULL ) )
    13081331    {
    13091332        // clear selection
     
    13281351
    13291352        freeRects( selrects );
     1353
     1354        memset( selection, 0, sizeof( LuRectangle ) * totalpages );
    13301355    }
    13311356
     
    13361361}
    13371362
     1363// handles WM_BUTTON1UP
     1364void DocumentViewer::wmButton1Up()
     1365{
     1366    WinSetCapture( HWND_DESKTOP, NULLHANDLE );
     1367    mousePressed = false;
     1368
     1369    bool haveSelection = false;
     1370    for ( long i = 0; i < totalpages; i++ ) {
     1371        if ( selrects[ i ] != NULL ) {
     1372            haveSelection = true;
     1373            break;
     1374        }
     1375    }
     1376
     1377    Lucide::enableCopy( haveSelection );
     1378}
    13381379
    13391380// static, window procedure
     
    13891430
    13901431        case WM_BUTTON1UP:
    1391             {
    1392                 WinSetCapture( HWND_DESKTOP, NULLHANDLE );
    1393                 _this->mousePressed = false;
    1394                 // TODO Lucide::enableCopy( _this->selrects != NULL );
    1395             }
     1432            _this->wmButton1Up();
    13961433            break;
    13971434
  • trunk/Lucide/SOURCE/gui/docViewer.h

    r22 r23  
    5656        void wmPaintContAsynch( HWND hwnd );
    5757        void wmButton1Down( HWND hwnd, SHORT xpos, SHORT ypos );
     58        void wmButton1Up();
    5859        BOOL wmMouseMove( HWND hwnd, SHORT xpos, SHORT ypos );
    5960        BOOL wmClick( HWND hwnd, SHORT xpos, SHORT ypos );
     
    126127        POINTL selectionStart;
    127128        POINTL selectionEnd;
    128         LuRectangle selection;
     129        LuRectangle *selection;
    129130        LuDocument_LuRectSequence **selrects;
    130131
  • trunk/Lucide/SOURCE/plugins/lupoppler/lupoppler.cpp

    r2 r23  
    461461    pdf_selection.y2 = selection->y2;
    462462
     463    DosRequestMutexSem( document->mutex, SEM_INDEFINITE_WAIT );
    463464    sel_text = text_dev->getSelectionText( &pdf_selection );
    464465
     
    466467    document->text = newstrdup( sel_text->getCString() );
    467468    delete sel_text;
     469    DosReleaseMutexSem( document->mutex );
    468470
    469471    return document->text;
Note: See TracChangeset for help on using the changeset viewer.