Show
Ignore:
Timestamp:
06/11/07 09:12:09 (18 months ago)
Author:
jordi
Message:

Added a patch by Igor Vagulin which adds text selection and copy to clipboard features. This fixes bug #14.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/DocumentPage.cxx

    r206 r277  
    1818#include <config.h> 
    1919#include <string.h> 
     20#include <gdk/gdk.h> 
    2021#include "epdfview.h" 
    2122 
     
    2930DocumentPage::DocumentPage () 
    3031{ 
     32    m_Selection = NULL; 
    3133    m_Data = NULL; 
    3234    m_HasSelection = FALSE; 
     
    5052    } 
    5153    g_list_free (m_LinkList); 
     54 
     55    if(m_Selection) 
     56        gdk_region_destroy(m_Selection); 
    5257} 
    5358 
     
    7984        invertArea (m_SelectionX1, m_SelectionY1, m_SelectionX2, m_SelectionY2); 
    8085        m_HasSelection = FALSE; 
     86    } 
     87 
     88    if(NULL != m_Selection){ 
     89        invertRegion(m_Selection); 
     90        gdk_region_destroy(m_Selection); 
     91        m_Selection = NULL; 
    8192    } 
    8293} 
     
    196207} 
    197208 
     209void 
     210DocumentPage::invertRegion (GdkRegion* region) 
     211{ 
     212    int count; 
     213    GdkRectangle *rectangles; 
     214    gdk_region_get_rectangles(region, &rectangles, &count); 
     215    while(count--){ 
     216        GdkRectangle r = rectangles[count]; 
     217        invertArea(r.x, r.y, r.x + r.width, r.y + r.height); 
     218    } 
     219    g_free(rectangles); 
     220} 
     221 
     222 
    198223/// 
    199224/// @brief Allocates the memory for a new page. 
     
    254279    m_HasSelection = TRUE; 
    255280} 
     281 
     282void 
     283DocumentPage::setSelection (GdkRegion *region) 
     284{ 
     285    clearSelection (); 
     286     
     287    invertRegion (region); 
     288     
     289    m_Selection = gdk_region_copy(region); 
     290}