Changeset 277 for trunk/src/PagePter.cxx
- Timestamp:
- 06/11/07 09:12:09 (18 months ago)
- Files:
-
- 1 modified
-
trunk/src/PagePter.cxx (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/PagePter.cxx
r275 r277 16 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 18 #include <gdk/gdk.h> 18 19 #include "epdfview.h" 19 20 … … 48 49 gint y; 49 50 /// The horizontal position of the page view scroll when the drag started. 50 gdouble scrollX;51 int startX; 51 52 /// The vertical position of the page view scroll when the drag started. 52 gdouble scrollY;53 int startY; 53 54 }; 54 55 … … 61 62 PagePter::PagePter (IDocument *document) 62 63 { 64 m_LastSelection = NULL; 63 65 m_Document = document; 64 66 m_Document->attach (this); … … 66 68 m_NextPageScroll = PAGE_SCROLL_START; 67 69 m_PageView = NULL; 70 m_Mode = PagePterModeScroll; 68 71 } 69 72 … … 130 133 131 134 IPageView &view = getView (); 132 m_DragInfo->scrollX = view.getHorizontalScroll (); 133 m_DragInfo->scrollY = view.getVerticalScroll (); 134 view.setCursor (PAGE_VIEW_CURSOR_DRAG); 135 m_DragInfo->startX = x; 136 m_DragInfo->startY = y; 137 if(m_Mode == PagePterModeScroll) 138 view.setCursor (PAGE_VIEW_CURSOR_DRAG); 139 else 140 view.setCursor (PAGE_VIEW_CURSOR_SELECT_TEXT); 135 141 } 136 142 } … … 150 156 if ( 1 == button ) 151 157 { 158 if(m_LastSelection) 159 gdk_region_destroy(m_LastSelection); 160 m_LastSelection = NULL; 161 162 if(m_Document->isLoaded() && m_Mode == PagePterModeSelectText){ 163 DocumentRectangle rect(m_DragInfo->startX, m_DragInfo->startY, 164 m_DragInfo->x, m_DragInfo->y); 165 m_Document->setTextSelection(&rect); 166 } 167 152 168 delete m_DragInfo; 153 169 m_DragInfo = NULL; 170 171 refreshPage(PAGE_SCROLL_NONE, FALSE); 172 154 173 getView ().setCursor (PAGE_VIEW_CURSOR_NORMAL); 155 174 } … … 182 201 } 183 202 } 184 else 185 { 186 view.scrollPage (view.getHorizontalScroll (), view.getVerticalScroll (), 187 x - m_DragInfo->x, y - m_DragInfo->y); 203 else{ 204 m_DragInfo->x = x; 205 m_DragInfo->y = y; 206 207 if(m_Mode == PagePterModeScroll){ 208 view.scrollPage (view.getHorizontalScroll (), view.getVerticalScroll (), 209 x - m_DragInfo->startX, y - m_DragInfo->startY); 210 } 211 else{ 212 if(!m_Document->isLoaded()) 213 return ; 214 215 DocumentRectangle rect(m_DragInfo->startX, m_DragInfo->startY, 216 m_DragInfo->x, m_DragInfo->y); 217 218 GdkRegion *region = m_Document->getTextRegion (&rect); 219 220 if( !m_LastSelection || !gdk_region_equal(m_LastSelection, region)){ 221 if(m_LastSelection) 222 gdk_region_destroy(m_LastSelection); 223 m_LastSelection = gdk_region_copy(region); 224 DocumentPage *page = m_Document->getCurrentPage(); 225 if ( NULL != page ) 226 refreshPage (PAGE_SCROLL_NONE, FALSE); 227 } 228 } 188 229 } 189 230 } … … 274 315 { 275 316 g_WaitingForPage = FALSE; 317 if ( NULL != m_LastSelection ) 318 documentPage->setSelection(m_LastSelection); 276 319 view.showPage (documentPage, pageScroll); 277 320 }
