Changeset 59 for trunk/Lucide/SOURCE


Ignore:
Timestamp:
Jun 30, 2006, 3:46:31 PM (15 years ago)
Author:
Eugene Romanenko
Message:

rotation and text selection in rotated mode fully works

Location:
trunk/Lucide/SOURCE
Files:
11 edited

Legend:

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

    r55 r59  
    406406            selection[ i ].y2 = pagesizes[ i ].y;
    407407            LuDocument::freeRectangles( ev, selrects[ i ] );
    408             selrects[ i ] = doc->getSelectionRectangles( ev, i, realzoom, &(selection[i]) );
     408            selrects[ i ] = doc->getSelectionRectangles( ev, i, &(selection[i]) );
    409409        }
    410410    }
     
    416416        selection[ currentpage ].y2 = pagesizes[ currentpage ].y;
    417417        LuDocument::freeRectangles( ev, selrects[ currentpage ] );
    418         selrects[ currentpage ] = doc->getSelectionRectangles( ev, currentpage, realzoom, &(selection[currentpage]) );
     418        selrects[ currentpage ] = doc->getSelectionRectangles( ev, currentpage, &(selection[currentpage]) );
    419419    }
    420420
     
    11561156
    11571157
     1158// Rotates document rectangle
     1159void DocumentViewer::rotateRectangle( long pagenum, LuRectangle *r )
     1160{
     1161    double tmp_x1 = r->x1;
     1162    double tmp_y1 = r->y1;
     1163    double tmp_x2 = r->x2;
     1164    double tmp_y2 = r->y2;
     1165
     1166    double w = pagesizes[ pagenum ].x;
     1167    double h = pagesizes[ pagenum ].y;
     1168
     1169    if ( rotation == 90 ) {
     1170        r->x1 = tmp_y1;
     1171        r->y1 = w - tmp_x1;
     1172        r->x2 = tmp_y2;
     1173        r->y2 = w - tmp_x2;
     1174    }
     1175    else if ( rotation == 180 )
     1176    {
     1177        r->x1 = w - tmp_x2;
     1178        r->y1 = h - tmp_y2;
     1179        r->x2 = w - tmp_x1;
     1180        r->y2 = h - tmp_y1;
     1181    }
     1182    else if ( rotation == 270 )
     1183    {
     1184        r->x1 = h - tmp_y1;
     1185        r->y1 = tmp_x1;
     1186        r->x2 = h - tmp_y2;
     1187        r->y2 = tmp_x2;
     1188    }
     1189
     1190    if ( r->x1 > r->x2 ) {
     1191        double tmp = r->x1;
     1192        r->x1 = r->x2;
     1193        r->x2 = tmp;
     1194    }
     1195
     1196    if ( r->y1 > r->y2 ) {
     1197        double tmp = r->y1;
     1198        r->y1 = r->y2;
     1199        r->y2 = tmp;
     1200    }
     1201}
     1202
    11581203// converts window position to document position
    11591204// single page mode only
     
    11651210    r->y2 = ( ( cyClient - endpoint->y ) + sVscrollPos ) / realzoom;
    11661211
    1167     /*double tmp_x1 = r->x1;
    1168     double tmp_y1 = r->y1;
    1169     double tmp_x2 = r->x2;
    1170     double tmp_y2 = r->y2;
    1171 
    1172     somPrintf( "1: x1: %f, y1: %f, x2: %f, y2: %f, height: %f\n", r->x1, r->y1, r->x2, r->y2, height );
    1173     if ( rotation == 90 ) {
    1174         r->x1 = height - tmp_y1;
    1175         r->y1 = tmp_x1;
    1176         r->x2 = height - tmp_y2;
    1177         r->y2 = tmp_x2;
    1178     }
    1179     somPrintf( "2: x1: %f, y1: %f, x2: %f, y2: %f, height: %f\n", r->x1, r->y1, r->x2, r->y2, height );
    1180     */
     1212    rotateRectangle( currentpage, r );
    11811213}
    11821214
     
    11891221    r->x2 = ( ( pda->drawrect.xRight - pda->drawrect.xLeft ) / realzoom ) + r->x1;
    11901222    r->y2 = ( ( pda->drawrect.yTop - pda->drawrect.yBottom ) / realzoom ) + r->y1;
     1223
     1224    rotateRectangle( pda->pagenum, r );
    11911225}
    11921226
    11931227// converts document position to window position
    1194 void DocumentViewer::docPosToWinPos( long pagenum, LuRectangle *r, PRECTL rcl, bool useZoom )
    1195 {
    1196     double scale = useZoom ? realzoom : 1.0;
     1228void DocumentViewer::docPosToWinPos( long pagenum, LuRectangle *r, PRECTL rcl )
     1229{
    11971230    double yplus = continuous ? pagenumToPos( pagenum ) : 0;
     1231    double w = pagesizes[ pagenum ].x;
     1232    double h = pagesizes[ pagenum ].y;
    11981233
    11991234    double tmp_x1 = r->x1;
     
    12041239    if ( rotation == 90 )
    12051240    {
    1206         tmp_x1 = ( width / scale ) - r->y2;
     1241        tmp_x1 = w - r->y2;
    12071242        tmp_y1 = r->x1;
    1208         tmp_x2 = ( width / scale ) - r->y1;
     1243        tmp_x2 = w - r->y1;
    12091244        tmp_y2 = r->x2;
    12101245    }
    12111246    else if ( rotation == 180 )
    12121247    {
    1213         tmp_x1 = ( width / scale ) - r->x2;
    1214         tmp_y1 = ( height / scale ) - r->y2;
    1215         tmp_x2 = ( width / scale ) - r->x1;
    1216         tmp_y2 = ( height / scale ) - r->y1;
     1248        tmp_x1 = w - r->x2;
     1249        tmp_y1 = h - r->y2;
     1250        tmp_x2 = w - r->x1;
     1251        tmp_y2 = h - r->y1;
    12171252    }
    12181253    else if ( rotation == 270 )
    12191254    {
    12201255        tmp_x1 = r->y1;
    1221         tmp_y1 = ( height / scale ) - r->x2;
     1256        tmp_y1 = h - r->x2;
    12221257        tmp_x2 = r->y2;
    1223         tmp_y2 = ( height / scale ) - r->x1;
    1224     }
    1225 
    1226     rcl->xLeft   = ( tmp_x1 * scale ) - sHscrollPos;
    1227     rcl->yBottom = cyClient - ( yplus + ( tmp_y2 * scale ) ) + ( sVscrollPos * VScrollStep );
    1228     rcl->xRight  = ( tmp_x2 * scale ) - sHscrollPos;
    1229     rcl->yTop    = cyClient - ( yplus + ( tmp_y1 * scale ) ) + ( sVscrollPos * VScrollStep );
     1258        tmp_y2 = h - r->x1;
     1259    }
     1260
     1261    rcl->xLeft   = ( tmp_x1 * realzoom ) - sHscrollPos;
     1262    rcl->yBottom = cyClient - ( yplus + ( tmp_y2 * realzoom ) ) + ( sVscrollPos * VScrollStep );
     1263    rcl->xRight  = ( tmp_x2 * realzoom ) - sHscrollPos;
     1264    rcl->yTop    = cyClient - ( yplus + ( tmp_y1 * realzoom ) ) + ( sVscrollPos * VScrollStep );
    12301265}
    12311266
    12321267// creates region from sequence of rectangles
    1233 HRGN DocumentViewer::rectsToRegion( long pagenum, HPS hps,
    1234                                     LuDocument_LuRectSequence *rects, bool useZoom )
     1268HRGN DocumentViewer::rectsToRegion( long pagenum, HPS hps, LuDocument_LuRectSequence *rects )
    12351269{
    12361270    HRGN hrgn = GpiCreateRegion( hps, 0, NULL );
     
    12401274        for ( int i = 0; i < rects->_length; i++ )
    12411275        {
    1242             docPosToWinPos( pagenum, &(rects->_buffer[i]), &r, useZoom );
     1276            docPosToWinPos( pagenum, &(rects->_buffer[i]), &r );
    12431277            HRGN tmprgn = GpiCreateRegion( hps, 1, &r );
    12441278            GpiCombineRegion( hps, hrgn, hrgn, tmprgn, CRGN_OR );
     
    12551289    GpiSetMix( hps, FM_XOR );
    12561290    GpiSetColor( hps, CLR_YELLOW );
    1257     HRGN selectRegion = rectsToRegion( pagenum, hps, selrects[ pagenum ], false );
     1291    HRGN selectRegion = rectsToRegion( pagenum, hps, selrects[ pagenum ] );
    12581292    if ( r != NULL )
    12591293    {
     
    12701304    GpiSetMix( hps, FM_XOR );
    12711305    GpiSetColor( hps, CLR_CYAN );
    1272     HRGN selectRegion = rectsToRegion( pagenum, hps, foundrects[ pagenum ], true );
     1306    HRGN selectRegion = rectsToRegion( pagenum, hps, foundrects[ pagenum ] );
    12731307    if ( r != NULL )
    12741308    {
     
    13491383                winPosToDocPos( pda, &(selection[pda->pagenum]) );
    13501384
    1351                 HRGN clearRegion = rectsToRegion( pda->pagenum, hps, selrects[ pda->pagenum ], false );
     1385                HRGN clearRegion = rectsToRegion( pda->pagenum, hps, selrects[ pda->pagenum ] );
    13521386                LuDocument::freeRectangles( ev, selrects[ pda->pagenum ] );
    1353                 selrects[ pda->pagenum ] = doc->getSelectionRectangles( ev, pda->pagenum, realzoom, &(selection[pda->pagenum]) );
    1354                 HRGN selectRegion = rectsToRegion( pda->pagenum, hps, selrects[ pda->pagenum ], false );
     1387                selrects[ pda->pagenum ] = doc->getSelectionRectangles( ev, pda->pagenum, &(selection[pda->pagenum]) );
     1388                HRGN selectRegion = rectsToRegion( pda->pagenum, hps, selrects[ pda->pagenum ] );
    13551389                GpiCombineRegion( hps, selectRegion, selectRegion, clearRegion, CRGN_XOR );
    13561390                GpiPaintRegion( hps, selectRegion );
     
    13811415            //GpiSetColor( hps, 100 );
    13821416
    1383             HRGN clearRegion = rectsToRegion( currentpage, hps, selrects[ currentpage ], false );
     1417            HRGN clearRegion = rectsToRegion( currentpage, hps, selrects[ currentpage ] );
    13841418            LuDocument::freeRectangles( ev, selrects[ currentpage ] );
    13851419            if ( ( selectionStart.x == selectionEnd.x ) &&
     
    13891423            }
    13901424            else {
    1391                 selrects[ currentpage ] = doc->getSelectionRectangles( ev, currentpage, realzoom, &(selection[currentpage]) );
    1392             }
    1393             HRGN selectRegion = rectsToRegion( currentpage, hps, selrects[ currentpage ], false );
     1425                selrects[ currentpage ] = doc->getSelectionRectangles( ev, currentpage, &(selection[currentpage]) );
     1426            }
     1427            HRGN selectRegion = rectsToRegion( currentpage, hps, selrects[ currentpage ] );
    13941428            GpiCombineRegion( hps, selectRegion, selectRegion, clearRegion, CRGN_XOR );
    13951429            //GpiCombineRegion( hps, selectRegion, selectRegion, scrolledRegion, CRGN_DIFF );
     
    15371571            PageDrawArea *pda = &(*areas)[ i ];
    15381572
    1539             HRGN clearRegion = rectsToRegion( pda->pagenum, hps, selrects[ pda->pagenum ], false );
     1573            HRGN clearRegion = rectsToRegion( pda->pagenum, hps, selrects[ pda->pagenum ] );
    15401574            GpiPaintRegion( hps, clearRegion );
    15411575            GpiDestroyRegion( hps, clearRegion );
  • trunk/Lucide/SOURCE/gui/docViewer.h

    r55 r59  
    103103        void winPosToDocPos( PPOINTL startpoint, PPOINTL endpoint, LuRectangle *r );
    104104        void winPosToDocPos( PageDrawArea *pda, LuRectangle *r );
    105         void docPosToWinPos( long pagenum, LuRectangle *r, PRECTL rcl, bool useZoom = true );
    106         HRGN rectsToRegion( long pagenum, HPS hps, LuDocument_LuRectSequence *rects, bool useZoom );
     105        void docPosToWinPos( long pagenum, LuRectangle *r, PRECTL rcl );
     106        void rotateRectangle( long pagenum, LuRectangle *r );
     107        HRGN rectsToRegion( long pagenum, HPS hps, LuDocument_LuRectSequence *rects );
    107108        void drawSelection( long pagenum, HPS hps, PRECTL r );
    108109        void scrollToPos( HWND hwnd, HRGN hrgn, LONG xpos, LONG ypos, bool withSelection );
  • trunk/Lucide/SOURCE/gui/lucide.cpp

    r55 r59  
    421421void Lucide::openDocument()
    422422{
     423        char dirbuf[ CCHMAXPATH ];
    423424    PFILEDLG fd = new FILEDLG;
    424425    memset( fd, 0, sizeof( FILEDLG ) );
     
    426427    fd->fl = FDS_CENTER | FDS_OPEN_DIALOG;
    427428    PrfQueryProfileString( HINI_USERPROFILE, appName, lvd, "",
    428                            fd->szFullFile, sizeof( fd->szFullFile ) );
    429     strcat( fd->szFullFile, pluginMan->getExtsMask().c_str() );
     429                           dirbuf, sizeof( dirbuf ) );
     430    snprintf( fd->szFullFile, sizeof( fd->szFullFile ),
     431              "%s%s", dirbuf, pluginMan->getExtsMask().c_str() );
    430432    WinFileDlg( HWND_DESKTOP, hWndFrame, fd );
    431433    if ( fd->lReturn == DID_OK )
  • trunk/Lucide/SOURCE/gui/makefile

    r55 r59  
    11.autodepend
    22
    3 TEST=0
     3TEST=1
    44VERSION=Beta 1.2
    55
  • trunk/Lucide/SOURCE/plugins/ludoc/ludoc.cpp

    r35 r59  
    167167                                                                    Environment *ev,
    168168                                                                   long pagenum,
    169                                                                    double scale,
    170169                                                                   LuRectangle* selection)
    171170{
  • trunk/Lucide/SOURCE/plugins/ludoc/ludoc.idl

    r27 r59  
    150150     * getSelectionRectangles
    151151     * pagenum: page number
    152      * scale: scale specified as pixels per point
    153152     * selection: start and end point of selection as a rectangle
    154153     *
     
    164163     **/
    165164    LuRectSequence *getSelectionRectangles( in long pagenum,
    166                                in double scale, in LuRectangle selection );
     165                                           in LuRectangle selection );
    167166
    168167
  • trunk/Lucide/SOURCE/plugins/ludoc/ludoc.xh

    r27 r59  
    232232typedef LuDocument_LuRectSequence*   SOMLINK somTP_LuDocument_getSelectionRectangles(LuDocument *somSelf, Environment *ev,
    233233                long pagenum,
    234                 double scale,
    235234                LuRectangle* selection);
    236235typedef somTP_LuDocument_getSelectionRectangles *somTD_LuDocument_getSelectionRectangles;
     
    590589LuDocument_LuRectSequence*   getSelectionRectangles(Environment *ev,
    591590                long pagenum,
    592                 double scale,
    593591                LuRectangle* selection)
    594592{
    595593   return SOM_ResolveD(this,LuDocument,LuDocument,getSelectionRectangles)
    596         (this, ev,pagenum,scale,selection);
     594        (this, ev,pagenum,selection);
    597595}
    598596
  • trunk/Lucide/SOURCE/plugins/ludoc/ludoc.xih

    r27 r59  
    357357SOM_Scope LuDocument_LuRectSequence*  SOMLINK getSelectionRectangles(LuDocument *somSelf, Environment *ev,
    358358                long pagenum,
    359                 double scale,
    360359                LuRectangle* selection);
    361360#ifndef somMN_getSelectionRectangles_defined
     
    369368static somId somDI_getSelectionRectangles = &somDS_getSelectionRectangles;
    370369#endif  /* somDS_getSelectionRectangles_defined */
    371 
    372 static somFloatMap getSelectionRectanglesFloatMap = {
    373 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
    374 
    375 static somMethodInfo getSelectionRectanglesMethodInfo = {1, 24, &getSelectionRectanglesFloatMap};
    376 
    377 static somApRdInfo getSelectionRectanglesStubs = {0, 0, &getSelectionRectanglesMethodInfo};
     370#define getSelectionRectangles_somApRdDefault
    378371
    379372/*
  • trunk/Lucide/SOURCE/plugins/lupoppler/lupoppler.cpp

    r50 r59  
    425425                                                                    Environment *ev,
    426426                                                                   long pagenum,
    427                                                                    double scale,
    428427                                                                   LuRectangle* selection)
    429428{
     
    442441    poppler_selection.y2 = selection->y2;
    443442
    444     GooList *list = text_dev->getSelectionRegion( &poppler_selection, scale );
     443    GooList *list = text_dev->getSelectionRegion( &poppler_selection, 1.0 );
    445444    int len = list->getLength();
    446445
  • trunk/Lucide/SOURCE/plugins/lupoppler/lupoppler.xh

    r27 r59  
    114114typedef LuDocument_LuRectSequence*   SOMLINK somTP_LuPopplerDocument_getSelectionRectangles(LuPopplerDocument *somSelf, Environment *ev,
    115115                long pagenum,
    116                 double scale,
    117116                LuRectangle* selection);
    118117typedef somTP_LuPopplerDocument_getSelectionRectangles *somTD_LuPopplerDocument_getSelectionRectangles;
     
    472471LuDocument_LuRectSequence*   getSelectionRectangles(Environment *ev,
    473472                long pagenum,
    474                 double scale,
    475473                LuRectangle* selection)
    476474{
    477475   return SOM_ResolveD(this,LuPopplerDocument,LuDocument,getSelectionRectangles)
    478         (this, ev,pagenum,scale,selection);
     476        (this, ev,pagenum,selection);
    479477}
    480478
  • trunk/Lucide/SOURCE/plugins/lupoppler/lupoppler.xih

    r27 r59  
    585585SOM_Scope LuDocument_LuRectSequence*  SOMLINK getSelectionRectangles(LuPopplerDocument *somSelf, Environment *ev,
    586586                long pagenum,
    587                 double scale,
    588587                LuRectangle* selection);
    589588static char *somMN_LuPopplerDocumentgetSelectionRectangles = "LuDocument::getSelectionRectangles";
     
    596595typedef LuDocument_LuRectSequence*   SOMLINK somTP_xih_LuPopplerDocument_getSelectionRectangles(LuPopplerDocument *somSelf, Environment *ev,
    597596                long pagenum,
    598                 double scale,
    599597                LuRectangle* selection);
    600598typedef somTP_xih_LuPopplerDocument_getSelectionRectangles *somTD_xih_LuPopplerDocument_getSelectionRectangles;
    601599/* define the parent method call macro */
    602600static somMethodProc* LuPopplerDocument_parent_LuDocument_getSelectionRectangles_resolved;
    603 #define LuPopplerDocument_parent_LuDocument_getSelectionRectangles(somSelf,ev,pagenum,scale,selection) \
     601#define LuPopplerDocument_parent_LuDocument_getSelectionRectangles(somSelf,ev,pagenum,selection) \
    604602  ((( somTD_xih_LuPopplerDocument_getSelectionRectangles ) \
    605603      LuPopplerDocument_parent_LuDocument_getSelectionRectangles_resolved) \
    606         (somSelf,ev,pagenum,scale,selection))
     604        (somSelf,ev,pagenum,selection))
    607605/* define a variety of (possibly ambiguous) short forms */
    608606#ifndef SOMGD_pmc_parent_getSelectionRectangles
     
    622620  #endif
    623621#endif
    624 #define LuPopplerDocument_parents_getSelectionRectangles(somSelf,ev,pagenum,scale,selection) (\
    625    LuPopplerDocument_parent_LuDocument_getSelectionRectangles(somSelf,ev,pagenum,scale,selection))
     622#define LuPopplerDocument_parents_getSelectionRectangles(somSelf,ev,pagenum,selection) (\
     623   LuPopplerDocument_parent_LuDocument_getSelectionRectangles(somSelf,ev,pagenum,selection))
    626624
    627625/*
Note: See TracChangeset for help on using the changeset viewer.